#!/usr/bin/env php
<?php
/**
 * This file is part of OXID eSales IDE code completion helper script.
 *
 * OXID eSales IDE code completion helper script is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * OXID eSales IDE code completion helper script is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OXID eSales IDE code completion helper script. If not, see <http://www.gnu.org/licenses/>.
 *
 * @link          http://www.oxid-esales.com
 * @copyright (C) OXID eSales AG 2003-2016
 */

$installationRootPath = dirname(dirname(dirname(dirname(__FILE__))));
$vendorPath = $installationRootPath . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR;

require_once $vendorPath . 'autoload.php';

try {
    $facts = new OxidEsales\Facts\Facts();
    $unifiedNameSpaceClassMapProvider = new \OxidEsales\UnifiedNameSpaceGenerator\UnifiedNameSpaceClassMapProvider($facts);
    $backwardsCompatibilityClassMapProvider = new \OxidEsales\UnifiedNameSpaceGenerator\BackwardsCompatibilityClassMapProvider($facts);

    $generator = new OxidEsales\EshopIdeHelper\Generator(
        $facts,
        $unifiedNameSpaceClassMapProvider,
        $backwardsCompatibilityClassMapProvider
    );
    $generator->generate();
} catch (\Exception $exception) {
    $message = $exception->getMessage();
    $code = $exception->getCode();
    $traceString = $exception->getTraceAsString();

    echo $message . PHP_EOL;
    echo "error code: $code" . PHP_EOL;
    echo "stack trace:" . PHP_EOL;
    echo $traceString . PHP_EOL;
    exit(1);
}
exit(0);
