Blame php-symfony3-generate-autoloaders.php

Shawn Iwinski ff43f55
#!/usr/bin/env php
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
define('SYMFONY_SOURCE_DIR', __DIR__.'/src');
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
require_once SYMFONY_SOURCE_DIR.'/Symfony/Component/ClassLoader/ClassLoader.php';
Shawn Iwinski ff43f55
$autoloader = new \Symfony\Component\ClassLoader\ClassLoader();
Shawn Iwinski ff43f55
$autoloader->addPrefix('Symfony\\', SYMFONY_SOURCE_DIR);
Shawn Iwinski ff43f55
$autoloader->register();
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
use Symfony\Component\Finder\Finder;
Shawn Iwinski ff43f55
use Symfony\Component\Finder\SplFileInfo;
7e7ce92
use Symfony\Component\Process\Exception\ProcessFailedException;
7e7ce92
use Symfony\Component\Process\Process;
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
$finder = new Finder();
7e7ce92
$finder
7e7ce92
    ->in(SYMFONY_SOURCE_DIR)
7e7ce92
    ->notPath('Tests')
7e7ce92
    ->name('composer.json')
7e7ce92
    ->sortByName();
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
foreach ($finder as $composerFile) {
7e7ce92
    fprintf(STDERR, 'generating autoloader from %s'.PHP_EOL, $composerFile);
Shawn Iwinski ff43f55
    $autoloadGenerator = new AutoloadGenerator($composerFile);
Shawn Iwinski 6780802
    echo $autoloadGenerator->getFilename().PHP_EOL;
Shawn Iwinski 6780802
    echo $autoloadGenerator->getDevFilename().PHP_EOL;
Shawn Iwinski ff43f55
}
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
//------------------------------------------------------------------------------
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
final class AutoloadGenerator {
Shawn Iwinski ff43f55
    private static $pkgMap = [
Shawn Iwinski 6780802
        'cache/integration-tests' => [
Shawn Iwinski 6780802
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski 6780802
            'path' => 'Cache/IntegrationTests/autoload.php',
Shawn Iwinski 6780802
        ],
18fa587
        'composer/package-versions-deprecated' => false,
Shawn Iwinski ff43f55
        'doctrine/annotations' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'Doctrine/Common/Annotations/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'doctrine/cache' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'Doctrine/Common/Cache/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski 6780802
        'doctrine/collections' => [
Shawn Iwinski 6780802
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski 6780802
            'path' => 'Doctrine/Common/Collections/autoload.php',
Shawn Iwinski 6780802
        ],
Shawn Iwinski ff43f55
        'doctrine/common' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'Doctrine/Common/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'doctrine/data-fixtures' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'Doctrine/Common/DataFixtures/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'doctrine/dbal' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'Doctrine/DBAL/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski 6780802
        'doctrine/doctrine-bundle' => [
Shawn Iwinski 6780802
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski 6780802
            'path' => 'Doctrine/Bundle/DoctrineBundle/autoload.php',
Shawn Iwinski 6780802
        ],
Shawn Iwinski ff43f55
        'doctrine/orm' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'Doctrine/ORM/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'egulias/email-validator' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
7e7ce92
            'path' => 'Egulias/EmailValidator2/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski a79a4be
        'fig/link-util' => [
Shawn Iwinski a79a4be
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski a79a4be
            'path' => 'Fig/Link/autoload.php',
Shawn Iwinski a79a4be
        ],
Shawn Iwinski ff43f55
        'monolog/monolog' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'Monolog/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'ocramius/proxy-manager' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'ProxyManager/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'phpdocumentor/reflection-docblock' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski 2da99e3
            'path' => 'phpDocumentor/Reflection/DocBlock/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski 6780802
        'predis/predis' => false,
Shawn Iwinski ff43f55
        'psr/cache-implementation' => false,
d8f130c
        'psr/container-implementation' => false,
d8f130c
        'psr/log-implementation' => false,
Shawn Iwinski ff43f55
        'psr/cache' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'Psr/Cache/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski a79a4be
        'psr/container' => [
Shawn Iwinski a79a4be
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski a79a4be
            'path' => 'Psr/Container/autoload.php',
Shawn Iwinski a79a4be
        ],
Shawn Iwinski a79a4be
        'psr/link' => [
Shawn Iwinski a79a4be
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski a79a4be
            'path' => 'Psr/Link/autoload.php',
Shawn Iwinski a79a4be
        ],
Shawn Iwinski ff43f55
        'psr/log' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'Psr/Log/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski a79a4be
        'psr/simple-cache' => [
Shawn Iwinski a79a4be
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski a79a4be
            'path' => 'Psr/SimpleCache/autoload.php',
Shawn Iwinski a79a4be
        ],
Shawn Iwinski 6780802
        'sensio/framework-extra-bundle' => false,
Shawn Iwinski ff43f55
        'symfony/asset' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Asset/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/browser-kit' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/BrowserKit/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/cache' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Cache/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/class-loader' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/ClassLoader/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/config' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Config/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/console' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Console/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/css-selector' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/CssSelector/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/debug-bundle' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Bundle/DebugBundle/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/debug' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Debug/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/dependency-injection' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/DependencyInjection/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/doctrine-bridge' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Bridge/Doctrine/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/dom-crawler' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/DomCrawler/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/event-dispatcher' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/EventDispatcher/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/expression-language' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/ExpressionLanguage/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/filesystem' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Filesystem/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/finder' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Finder/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/form' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Form/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/framework-bundle' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Bundle/FrameworkBundle/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/http-foundation' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/HttpFoundation/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/http-kernel' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/HttpKernel/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/inflector' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Inflector/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/intl' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Intl/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/ldap' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Ldap/autoload.php',
Shawn Iwinski ff43f55
        ],
0ce9aff
        'symfony/lock' => [
0ce9aff
            'prefix' => 'FEDORA_SYMFONY3_DIR',
0ce9aff
            'path' => 'Component/Lock/autoload.php',
0ce9aff
        ],
Shawn Iwinski ff43f55
        'symfony/monolog-bridge' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Monolog/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/options-resolver' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/OptionsResolver/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/phpunit-bridge' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Bridge/PhpUnit/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/polyfill-apcu' => false,
5a3e4af
        'symfony/polyfill-ctype' => false,
Shawn Iwinski ff43f55
        'symfony/polyfill-iconv' => false,
Shawn Iwinski ff43f55
        'symfony/polyfill-intl-grapheme' => false,
Shawn Iwinski ff43f55
        'symfony/polyfill-intl-icu' => false,
Shawn Iwinski ff43f55
        'symfony/polyfill-intl-normalizer' => false,
Shawn Iwinski ff43f55
        'symfony/polyfill-mbstring' => false,
8167c90
        'symfony/polyfill-php54' => false,
8167c90
        'symfony/polyfill-php55' => false,
8167c90
        'symfony/polyfill-php56' => false,
8167c90
        'symfony/polyfill-php70' => false,
Shawn Iwinski ff43f55
        'symfony/polyfill-util' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'Symfony/Polyfill/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/polyfill-xml' => false,
Shawn Iwinski ff43f55
        'symfony/polyfill' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => 'Symfony/Polyfill/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/process' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Process/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/property-access' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/PropertyAccess/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/property-info' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/PropertyInfo/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/proxy-manager-bridge' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Bridge/ProxyManager/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/routing' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Routing/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/security-acl' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski 6780802
            'path' => 'Symfony/Component/Security/Acl/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/security-bundle' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Bundle/SecurityBundle/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/security-core' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Security/Core/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/security-csrf' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Security/Csrf/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/security-guard' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Security/Guard/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/security-http' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Security/Http/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/security' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Security/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/serializer' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Serializer/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/stopwatch' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Stopwatch/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/templating' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Templating/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/translation' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Translation/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/twig-bridge' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Bridge/Twig/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/twig-bundle' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Bundle/TwigBundle/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/validator' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Validator/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'symfony/var-dumper' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/VarDumper/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski a79a4be
        'symfony/web-link' => [
Shawn Iwinski a79a4be
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski a79a4be
            'path' => 'Component/WebLink/autoload.php',
Shawn Iwinski a79a4be
        ],
Shawn Iwinski ff43f55
        'symfony/web-profiler-bundle' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Bundle/WebProfilerBundle/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski 6780802
        'symfony/workflow' => [
Shawn Iwinski 6780802
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski 6780802
            'path' => 'Component/Workflow/autoload.php',
Shawn Iwinski 6780802
        ],
Shawn Iwinski ff43f55
        'symfony/yaml' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_DIR',
Shawn Iwinski ff43f55
            'path' => 'Component/Yaml/autoload.php',
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
        'twig/twig' => [
Shawn Iwinski ff43f55
            'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
Shawn Iwinski ff43f55
            'path' => [
Shawn Iwinski ff43f55
                'Twig2/autoload.php',
Shawn Iwinski ff43f55
                'Twig/autoload.php',
Shawn Iwinski ff43f55
            ],
Shawn Iwinski ff43f55
        ],
Shawn Iwinski ff43f55
    ];
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
    private $filename = null;
Shawn Iwinski ff43f55
Shawn Iwinski 6780802
    private $devFilename = null;
Shawn Iwinski 6780802
Shawn Iwinski ff43f55
    public function __construct(SplFileInfo $composerFile) {
7e7ce92
        $composerPath = $composerFile->getPath();
Shawn Iwinski ff43f55
        $composerJson = static::composerJson($composerFile);
Shawn Iwinski 6780802
Shawn Iwinski 6780802
        // autoload.php
Shawn Iwinski ff43f55
        $content = static::content(
7e7ce92
            $composerPath,
7e7ce92
            $composerJson['name'],
7e7ce92
            isset($composerJson['autoload']['psr-0']) ? $composerJson['autoload']['psr-0'] : [],
7e7ce92
            isset($composerJson['autoload']['psr-4']) ? $composerJson['autoload']['psr-4'] : [],
7e7ce92
            isset($composerJson['autoload']['files']) ? $composerJson['autoload']['files'] : [],
7e7ce92
            isset($composerJson['autoload']['classmap']) ? $composerJson['autoload']['classmap'] : [],
Shawn Iwinski 6780802
            static::dependencyAutoloaders($composerJson, 'require'),
Shawn Iwinski 6780802
            static::dependencyAutoloaders($composerJson, 'suggest')
Shawn Iwinski ff43f55
        );
Shawn Iwinski ff43f55
        $this->filename = $composerFile->getPath() . '/autoload.php';
Shawn Iwinski e144428
        if (FALSE == file_put_contents($this->filename, $content)) {
Shawn Iwinski 49cb8bb
            throw new Exception(sprintf(
Shawn Iwinski 49cb8bb
                'Failed to generate autoload file "%s"',
Shawn Iwinski 49cb8bb
                $this->filename
Shawn Iwinski 49cb8bb
            ));
Shawn Iwinski 49cb8bb
        }
Shawn Iwinski 6780802
Shawn Iwinski 6780802
        // autoload-dev.php
Shawn Iwinski 6780802
        $content = static::content(
7e7ce92
            $composerPath,
7e7ce92
            $composerJson['name'],
7e7ce92
            [],
7e7ce92
            [],
7e7ce92
            [],
7e7ce92
            [],
Shawn Iwinski 6780802
            static::dependencyAutoloaders($composerJson, 'require-dev'),
Shawn Iwinski 6780802
            [],
Shawn Iwinski 6780802
            true
Shawn Iwinski 6780802
        );
Shawn Iwinski 6780802
        $this->devFilename = $composerFile->getPath() . '/autoload-dev.php';
Shawn Iwinski 6780802
        if (FALSE == file_put_contents($this->devFilename, $content)) {
Shawn Iwinski 6780802
            throw new Exception(sprintf(
Shawn Iwinski 6780802
                'Failed to generate autoload file "%s"',
Shawn Iwinski 6780802
                $this->filename
Shawn Iwinski 6780802
            ));
Shawn Iwinski 6780802
        }
Shawn Iwinski ff43f55
    }
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
    private static function composerJson(SplFileInfo $composerFile) {
Shawn Iwinski ff43f55
      $composerJson = json_decode(
Shawn Iwinski ff43f55
          file_get_contents($composerFile->getPathname()),
Shawn Iwinski ff43f55
          true
Shawn Iwinski ff43f55
      );
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
      if (!isset($composerJson)) {
Shawn Iwinski ff43f55
          throw new \Exception(sprintf(
Shawn Iwinski ff43f55
              'Failed to JSON decode "%s"',
Shawn Iwinski ff43f55
              $composerFile->getPathname()
Shawn Iwinski ff43f55
          ));
Shawn Iwinski ff43f55
      }
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
      return $composerJson;
Shawn Iwinski ff43f55
    }
Shawn Iwinski ff43f55
Shawn Iwinski 6780802
    private static function dependencyAutoloaders($composerJson, $composerKey) {
Shawn Iwinski ff43f55
        $dependencyAutoloaders = [];
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
        if (isset($composerJson[$composerKey])) {
Shawn Iwinski ff43f55
            $dependencies = array_keys(array_filter(
Shawn Iwinski ff43f55
                $composerJson[$composerKey],
Shawn Iwinski ff43f55
                function ($pkg) {
Shawn Iwinski ff43f55
                    return preg_match('#[^/]+/[^/]+#', $pkg);
Shawn Iwinski ff43f55
                },
Shawn Iwinski ff43f55
                ARRAY_FILTER_USE_KEY
Shawn Iwinski ff43f55
            ));
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
            foreach ($dependencies as $pkg) {
Shawn Iwinski 6780802
                // Use Symfony cache component as PSR cache implementation
Shawn Iwinski 6780802
                // for "require-dev" dependency.
Shawn Iwinski 6780802
                if (
Shawn Iwinski 6780802
                    ('require-dev' == $composerKey)
Shawn Iwinski 6780802
                    && ('psr/cache-implementation' == $pkg)
Shawn Iwinski 6780802
                ) {
Shawn Iwinski 6780802
                    $pkg = 'symfony/cache';
Shawn Iwinski 6780802
                }
Shawn Iwinski 6780802
Shawn Iwinski ff43f55
                if ($autoloader = self::pkg2Autoload($pkg)) {
Shawn Iwinski ff43f55
                    $dependencyAutoloaders[] = $autoloader;
Shawn Iwinski ff43f55
                }
Shawn Iwinski ff43f55
            }
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
            ksort($dependencyAutoloaders);
Shawn Iwinski ff43f55
        }
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
        return $dependencyAutoloaders;
Shawn Iwinski ff43f55
    }
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
    private static function pkg2Autoload ($pkg) {
Shawn Iwinski ff43f55
        if (!isset(self::$pkgMap[$pkg])) {
Shawn Iwinski ff43f55
            throw new Exception(sprintf('No autoload map found for pkg "%s"', $pkg));
Shawn Iwinski ff43f55
        } elseif (empty(self::$pkgMap[$pkg])) {
Shawn Iwinski ff43f55
            return null;
Shawn Iwinski ff43f55
        }
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
        $map = self::$pkgMap[$pkg];
Shawn Iwinski ff43f55
        $prefix = $map['prefix'];
Shawn Iwinski ff43f55
        $path = $map['path'];
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
        return is_array($path)
Shawn Iwinski ff43f55
            ? sprintf('[%s]', implode(', ', array_map(function ($map_path) use ($prefix) {
Shawn Iwinski ff43f55
                return sprintf("%s.'/%s'", $prefix, $map_path);
Shawn Iwinski ff43f55
            }, $path)))
Shawn Iwinski ff43f55
            : sprintf("%s.'/%s'", $prefix, $path);
Shawn Iwinski ff43f55
    }
Shawn Iwinski ff43f55
7e7ce92
    public function content(
7e7ce92
        $path,
7e7ce92
        $name,
7e7ce92
        array $psr0,
7e7ce92
        array $psr4,
7e7ce92
        array $files,
7e7ce92
        array $classmap,
7e7ce92
        array $dependencyAutoloadersRequired,
7e7ce92
        array $dependencyAutoloadersOptional,
7e7ce92
        $dev = false
7e7ce92
    ) {
7e7ce92
        $pkg = explode('/', $name)[1];
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
        $content = <<
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
/**
Shawn Iwinski ff43f55
 * Autoloader for php-symfony3-${pkg} and its' dependencies
Shawn Iwinski ff43f55
 * (created by php-symfony3-__VERSION__-__RELEASE__).
Shawn Iwinski ff43f55
 */
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
AUTOLOAD;
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
        // This switch statement handles the "autoload-common" require for sub-sub-modules.
Shawn Iwinski 6780802
        if (!$dev) {
Shawn Iwinski 6780802
            switch ($pkg) {
Shawn Iwinski 6780802
                case 'security-core':
Shawn Iwinski 6780802
                case 'security-csrf':
Shawn Iwinski 6780802
                case 'security-guard':
Shawn Iwinski 6780802
                case 'security-http':
Shawn Iwinski 6780802
                    $content .= "require_once dirname(dirname(dirname(__DIR__))).'/autoload-common.php';".PHP_EOL;
Shawn Iwinski 6780802
                    break;
Shawn Iwinski 6780802
                default:
Shawn Iwinski 6780802
                    $content .= "require_once dirname(dirname(__DIR__)).'/autoload-common.php';".PHP_EOL;
Shawn Iwinski 6780802
            }
Shawn Iwinski 6780802
        } else {
Shawn Iwinski 6780802
            switch ($pkg) {
Shawn Iwinski 6780802
                case 'security-core':
Shawn Iwinski 6780802
                case 'security-csrf':
Shawn Iwinski 6780802
                case 'security-guard':
Shawn Iwinski 6780802
                case 'security-http':
Shawn Iwinski 6780802
                    $content .= "require_once dirname(__DIR__).'/autoload.php';".PHP_EOL;
Shawn Iwinski 6780802
                    break;
Shawn Iwinski 6780802
                default:
Shawn Iwinski 6780802
                    $content .= "require_once __DIR__.'/autoload.php';".PHP_EOL;
Shawn Iwinski 6780802
            }
Shawn Iwinski ff43f55
        }
Shawn Iwinski ff43f55
7e7ce92
        // PSR-0
7e7ce92
        if (!empty($psr0)) {
7e7ce92
            $content .= PHP_EOL.'// Self PSR-0'.PHP_EOL;
7e7ce92
7e7ce92
            foreach ($psr0 as $namespace => $directory) {
7e7ce92
                $content .= sprintf(
7e7ce92
                    "\\Fedora\\Autoloader\\Autoload::addPsr0('%s', %s, true);".PHP_EOL,
7e7ce92
                    str_replace('\\', '\\\\', $namespace),
7e7ce92
                    $directory ? "'$directory'" : '__DIR__'
7e7ce92
                );
7e7ce92
            }
7e7ce92
        }
7e7ce92
7e7ce92
        // PSR-4
7e7ce92
        if (!empty($psr4)) {
7e7ce92
            $content .= PHP_EOL.'// Self PSR-4'.PHP_EOL;
7e7ce92
7e7ce92
            foreach ($psr4 as $namespace => $directory) {
7e7ce92
              $content .= sprintf(
7e7ce92
                  "\\Fedora\\Autoloader\\Autoload::addPsr4('%s', %s, true);".PHP_EOL,
7e7ce92
                  str_replace('\\', '\\\\', $namespace),
7e7ce92
                  $directory ? "'$directory'" : '__DIR__'
7e7ce92
              );
7e7ce92
            }
7e7ce92
        }
7e7ce92
7e7ce92
        // Files
7e7ce92
        if (!empty($files)) {
7e7ce92
            $content .= PHP_EOL.'// Self files'.PHP_EOL;
7e7ce92
7e7ce92
            foreach ($files as $file) {
7e7ce92
                $content .= sprintf(
7e7ce92
                  "require_once __DIR__.'/$file';".PHP_EOL,
7e7ce92
                  $file
7e7ce92
                );
7e7ce92
            }
7e7ce92
        }
7e7ce92
7e7ce92
        // Classmap
7e7ce92
        if (!empty($classmap)) {
7e7ce92
            $cmd = array_merge(
7e7ce92
              [
7e7ce92
                  'phpab',
7e7ce92
                  '--template', 'fedora',
7e7ce92
                  '--output', 'autoload.classmap.php',
7e7ce92
              ],
7e7ce92
              $classmap
7e7ce92
            );
7e7ce92
7e7ce92
            $process = new Process($cmd, $path);
7e7ce92
            $process->run();
7e7ce92
7e7ce92
            if (!$process->isSuccessful()) {
7e7ce92
                throw new ProcessFailedException($process);
7e7ce92
            }
7e7ce92
7e7ce92
            $content .= <<
7e7ce92
7e7ce92
// Self classmap
7e7ce92
require_once __DIR__.'/autoload.classmap.php';
7e7ce92
7e7ce92
SELF_CLASSMAP;
7e7ce92
        }
7e7ce92
7e7ce92
        // Required dependencies
Shawn Iwinski ff43f55
        if (!empty($dependencyAutoloadersRequired)) {
Shawn Iwinski ff43f55
            $dependencyAutoloadersRequiredString = implode(",\n    ", $dependencyAutoloadersRequired);
Shawn Iwinski ff43f55
            $content .= <<
Shawn Iwinski ff43f55
7e7ce92
// Required dependencies
Shawn Iwinski ff43f55
\Fedora\Autoloader\Dependencies::required([
Shawn Iwinski ff43f55
    $dependencyAutoloadersRequiredString
Shawn Iwinski ff43f55
]);
7e7ce92
Shawn Iwinski ff43f55
DEPENDENCY_AUTOLOADERS_REQUIRED;
Shawn Iwinski ff43f55
        }
Shawn Iwinski ff43f55
7e7ce92
        // Optional dependencies
Shawn Iwinski ff43f55
        if (!empty($dependencyAutoloadersOptional)) {
Shawn Iwinski ff43f55
            $dependencyAutoloadersOptionalString = implode(",\n    ", $dependencyAutoloadersOptional);
Shawn Iwinski ff43f55
            $content .= <<
Shawn Iwinski ff43f55
7e7ce92
// Optional dependencies
Shawn Iwinski ff43f55
\Fedora\Autoloader\Dependencies::optional([
Shawn Iwinski ff43f55
    $dependencyAutoloadersOptionalString
Shawn Iwinski ff43f55
]);
Shawn Iwinski ff43f55
DEPENDENCY_AUTOLOADERS_REQUIRED;
Shawn Iwinski ff43f55
        }
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
        return $content.PHP_EOL;
Shawn Iwinski ff43f55
    }
Shawn Iwinski ff43f55
Shawn Iwinski ff43f55
    public function getFilename() {
Shawn Iwinski ff43f55
        return $this->filename;
Shawn Iwinski ff43f55
    }
Shawn Iwinski 6780802
Shawn Iwinski 6780802
    public function getDevFilename() {
Shawn Iwinski 6780802
        return $this->devFilename;
Shawn Iwinski 6780802
    }
Shawn Iwinski ff43f55
}