protected function execute(InputInterface $input, OutputInterface $output)
 {
     $targetDir = 'src/EpicBattlerBundle/Resources/config/doctrine/mapping/';
     if ($input->getOption('overwrite')) {
         $finder = new Finder();
         $finder->files()->in($targetDir);
         foreach ($finder as $file) {
             /** @var SplFileInfo $file */
             unlink($file);
         }
     }
     $r = new Reader();
     $d = new Dumper();
     $kernel = $this->getContainer()->get('kernel');
     $path = $kernel->locateResource('@EpicBattlerBundle/thrift/EpicBattlerBundle');
     $classes = array_keys(ClassMapGenerator::createMap($path));
     foreach ($classes as $class) {
         try {
             $cmi = $r->read($class);
             $subNsClass = str_replace('EpicBattlerBundle\\', "", $class);
             $dottedSubNsClass = str_replace('\\', '.', $subNsClass);
             $ymlPath = 'src/EpicBattlerBundle/Resources/config/doctrine/mapping/' . $dottedSubNsClass . '.mongodb.yml';
             file_put_contents($ymlPath, $d->dump($cmi));
             $output->writeln($class);
         } catch (\Exception $e) {
             $output->writeln('<error>' . $e->getMessage() . '</error>');
         }
     }
 }
 private function getFullClass($file)
 {
     $dir = dirname($file);
     if (!isset($this->resolved[$file])) {
         $this->resolved += array_flip(ClassMapGenerator::createMap($dir));
     }
     return isset($this->resolved[$file]) ? $this->resolved[$file] : "";
 }
 public function testCreateMapFinderSupport()
 {
     if (!class_exists('Symfony\\Component\\Finder\\Finder')) {
         $this->markTestSkipped('Finder component is not available');
     }
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->files()->in(__DIR__ . '/Fixtures/beta/NamespaceCollision');
     $this->assertEqualsNormalized(array('NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__) . '/Fixtures/beta/NamespaceCollision/A/B/Bar.php', 'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__) . '/Fixtures/beta/NamespaceCollision/A/B/Foo.php', 'NamespaceCollision\\C\\B\\Bar' => realpath(__DIR__) . '/Fixtures/beta/NamespaceCollision/C/B/Bar.php', 'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__) . '/Fixtures/beta/NamespaceCollision/C/B/Foo.php'), ClassMapGenerator::createMap($finder));
 }
Example #4
0
 public function testClassMapValidity()
 {
     $actualCoreClasses = \Symfony\Component\ClassLoader\ClassMapGenerator::createMap(TUBEPRESS_ROOT . '/src');
     $actualVendorClasses = \Symfony\Component\ClassLoader\ClassMapGenerator::createMap(TUBEPRESS_ROOT . '/vendor');
     $actualClasses = array_merge($actualCoreClasses, $actualVendorClasses);
     $actualClassMap = (require TUBEPRESS_ROOT . '/src/php/scripts/classloading/classmap.php');
     ksort($actualClasses);
     $expected = $this->_getExpectedClassMap($actualClasses);
     $this->assertEquals($expected, $actualClassMap, $this->_messageForClassMapValidity($expected, $actualClassMap));
 }
 protected function compile()
 {
     //Build cache
     $this->compiler = new ThriftCompiler();
     $this->compiler->setModelPath($this->modelPath);
     $this->compiler->compile($this->definitionPath, true);
     // Init Loader
     $l = new MapClassLoader(ClassMapGenerator::createMap($this->modelPath));
     $l->register();
 }
 public function testClassMapIntegrity()
 {
     $map = \Symfony\Component\ClassLoader\ClassMapGenerator::createMap(dirname($this->getPathToManifest()));
     $missing = array();
     $manifest = $this->_decodeManifest();
     $toIgnore = $this->getClassNamesToIgnore();
     $manifestPath = $this->getPathToManifest();
     $manifestDir = dirname($manifestPath);
     foreach ($map as $className => $path) {
         if (strpos($path, "{$manifestDir}/tests") === 0) {
             unset($map[$className]);
         }
     }
     foreach ($map as $className => $path) {
         if (in_array($className, $toIgnore)) {
             continue;
         }
         if (!array_key_exists($className, $manifest['autoload']['classmap'])) {
             $missing[] = $className;
         }
     }
     if (!empty($missing)) {
         $missing = array_unique($missing);
         sort($missing);
         $expected = '';
         foreach ($missing as $className) {
             $expected .= "\"{$className}\" : \"classes/" . str_replace('_', '/', $className) . ".php\",\n";
         }
         $message = "The following classes are missing from the manifest's classmap: \n\n" . $expected;
         $this->fail($message);
         return;
     }
     $extra = array_diff(array_keys($manifest['autoload']['classmap']), array_keys($map));
     if (!empty($extra)) {
         $message = "The following extra classes are in the manifest's classmap: \n\n" . implode("\n", $extra);
         $this->fail($message);
         return;
     }
     foreach ($manifest['autoload']['classmap'] as $className => $path) {
         if (!is_file(dirname($this->getPathToManifest()) . DIRECTORY_SEPARATOR . $path)) {
             $this->fail(dirname(realpath($this->getPathToManifest())) . DIRECTORY_SEPARATOR . $path . ' does not exist');
             return;
         }
     }
     $this->assertTrue(true);
 }
Example #7
0
 /**
  * Get a list of installed AbuseIO parsers and return as an array
  * @return array
  */
 public static function getParsers()
 {
     $parsers = [];
     $parserClassList = ClassMapGenerator::createMap(base_path() . '/vendor/abuseio');
     /** @noinspection PhpUnusedParameterInspection */
     $parserClassListFiltered = array_where(array_keys($parserClassList), function ($key, $value) {
         // Get all parsers, ignore all other packages.
         if (strpos($value, 'AbuseIO\\Parsers\\') !== false) {
             return $value;
         }
         return false;
     });
     $parserList = array_map('class_basename', $parserClassListFiltered);
     foreach ($parserList as $parser) {
         if (!in_array($parser, ['Factory', 'Parser'])) {
             $parsers[] = $parser;
         }
     }
     return $parsers;
 }
Example #8
0
 /**
  * Get a list of installed AbuseIO notifications and return as an array
  *
  * @return array
  */
 public static function getNotification()
 {
     $notificationClassList = ClassMapGenerator::createMap(base_path() . '/vendor/abuseio');
     /** @noinspection PhpUnusedParameterInspection */
     $notificationClassListFiltered = array_where(array_keys($notificationClassList), function ($key, $value) {
         // Get all notifications, ignore all other packages.
         if (strpos($value, 'AbuseIO\\Notification\\') !== false) {
             return $value;
         }
         return false;
     });
     $notifications = [];
     $notificationList = array_map('class_basename', $notificationClassListFiltered);
     foreach ($notificationList as $notification) {
         if (!in_array($notification, ['Factory', 'Notification'])) {
             $notifications[] = $notification;
         }
     }
     return $notifications;
 }
<?php

use Symfony\Component\ClassLoader\ClassMapGenerator;
$loader = (require __DIR__ . '/../vendor/autoload.php');
define('BASE_PATH', realpath(dirname(__DIR__)));
if (!file_exists(BASE_PATH . '/vendor/autoload.php')) {
    echo 'You must first install the vendors using composer.' . PHP_EOL;
    exit(1);
}
//$loader->addPsr4('StudioBonito\\SilverStripe\\Queue\\Tests\\', BASE_PATH);
$classMap = ClassMapGenerator::createMap(BASE_PATH . '/framework');
unset($classMap['PHPUnit_Framework_TestCase']);
$loader->addClassMap($classMap);
<?php

use Symfony\Component\ClassLoader\ClassMapGenerator;
define('FRAMEWORK_PATH', dirname(__DIR__) . '/framework');
$filename = __DIR__ . '/../vendor/autoload.php';
if (!file_exists($filename)) {
    echo 'You must first install the vendors using composer.' . PHP_EOL;
    exit(1);
}
$loader = (require $filename);
$frameworkClassMap = ClassMapGenerator::createMap(dirname(__DIR__) . '/framework');
unset($frameworkClassMap['PHPUnit_Framework_TestCase']);
$loader->addClassMap($frameworkClassMap);
<?php

/**
 * Utility file for generating a class map file.
 */
// Return if CLI isn't being used.
if ('cli' !== php_sapi_name()) {
    die;
}
// Determine our project root.
$plugin_root_dir = dirname(__DIR__);
// Load the composer autoloader.
if (!file_exists($plugin_root_dir . '/vendor/autoload.php')) {
    die("You need to run `composer install` before attempting to use this file.");
}
require_once $plugin_root_dir . '/vendor/autoload.php';
use Symfony\Component\ClassLoader\ClassMapGenerator;
// Create the raw map.
$raw_map = array();
$locations = array('admin', 'includes', 'public');
foreach ($locations as $location) {
    $raw_map = array_merge($raw_map, ClassMapGenerator::createMap("{$plugin_root_dir}/{$location}"));
}
// Modify the default class map.
$map = array();
foreach ($raw_map as $class => $path) {
    $map[strtolower($class)] = str_replace($plugin_root_dir . DIRECTORY_SEPARATOR, '', $path);
}
// Save the map to the correct file.
file_put_contents($plugin_root_dir . '/class-map.php', sprintf("<?php\n\nreturn %s;\n", var_export($map, true)));
<?php

define('BASE_PATH', realpath(dirname(__DIR__)));
if (!file_exists(BASE_PATH . '/vendor/autoload.php')) {
    echo 'You must first install the vendors using composer.' . PHP_EOL;
    exit(1);
}
$loader = (require BASE_PATH . '/vendor/autoload.php');
use Symfony\Component\ClassLoader\ClassMapGenerator;
$loader->addClassMap(ClassMapGenerator::createMap(BASE_PATH . '/code'));
$loader->addClassMap(ClassMapGenerator::createMap(BASE_PATH . '/sapphire'));
$loader->addClassMap(ClassMapGenerator::createMap(BASE_PATH . '/tests'));
 public function traceAutoloads(array $config, $isRoot = false)
 {
     $autoloads = array();
     // @see https://getcomposer.org/doc/02-libraries.md#platform-packages
     if (isset($config['require'])) {
         $this->logger->debug('Tracing package autoload from "require" section');
         $autoloads = array_merge($autoloads, $this->traceAutoloadsWithRequirements($config, $config['require']));
     }
     if ($isRoot && isset($config['require-dev'])) {
         $this->logger->debug('Tracing package autoload from "require-dev" section');
         $autoloads = array_merge($autoloads, $this->traceAutoloadsWithRequirements($config, $config['require-dev']));
     }
     if (isset($config['autoload'])) {
         if ($isRoot) {
             $baseDir = $this->workingDir;
         } else {
             $baseDir = $this->workingDir . DIRECTORY_SEPARATOR . $this->vendorDir . DIRECTORY_SEPARATOR . $config['name'];
         }
         // target-dir is deprecated, but somehow we need to support some
         // psr-0 class loader with target-dir
         // @see https://getcomposer.org/doc/04-schema.md#target-dir
         if (isset($config['target-dir'])) {
             $this->logger->warn("Found deprecated property 'target-dir' in package " . $config['name']);
             $baseDir = $config['target-dir'];
             $autoloads[$config['name']] = $this->prependAutoloadPathPrefix($config['autoload'], $config['target-dir']);
         }
         if (isset($config['autoload']['classmap'])) {
             // Expand and replace classmap array
             $map = array();
             foreach ($config['autoload']['classmap'] as $path) {
                 $this->logger->debug("Scanning classmap in {$path}");
                 $map = array_merge($map, ClassMapGenerator::createMap($baseDir . DIRECTORY_SEPARATOR . $path));
             }
             // Strip paths with working directory:
             // ClassMapGenerator returns class map with files in absolute paths,
             // We need them to be relative paths.
             foreach ($map as $k => $filepath) {
                 $map[$k] = str_replace($baseDir . DIRECTORY_SEPARATOR, '', $filepath);
             }
             $config['autoload']['classmap'] = $map;
         }
         $autoloads[$config['name']] = $config;
     }
     return $autoloads;
 }
Example #14
0
 protected function loadModels()
 {
     $models = array();
     foreach ($this->dirs as $dir) {
         $dir = base_path() . '/' . $dir;
         if (file_exists($dir)) {
             foreach (ClassMapGenerator::createMap($dir) as $model => $path) {
                 $models[] = $model;
             }
         }
     }
     return $models;
 }
<?php

define('UNIT_TESTING', true);
define('ECOMMERCE_DEALS_BASE_PATH', dirname(__DIR__));
define('BASE_PATH', ECOMMERCE_DEALS_BASE_PATH);
if (!file_exists(BASE_PATH . '/vendor/autoload.php')) {
    echo 'You must first install the vendors using composer.' . PHP_EOL;
    exit(1);
}
$loader = (require BASE_PATH . '/vendor/autoload.php');
use Symfony\Component\ClassLoader\ClassMapGenerator;
$loader->addClassMap(ClassMapGenerator::createMap(BASE_PATH . '/sapphire'));
$loader->add('Heystack\\Deals\\Test', __DIR__);
<?php

define('UNIT_TESTING', true);
define('ECOMMERCE_PAYMENT_BASE_PATH', dirname(__DIR__));
define('BASE_PATH', ECOMMERCE_PAYMENT_BASE_PATH);
if (!file_exists(BASE_PATH . '/vendor/autoload.php')) {
    echo 'You must first install the vendors using composer.' . PHP_EOL;
    exit(1);
}
$loader = (require BASE_PATH . '/vendor/autoload.php');
use Symfony\Component\ClassLoader\ClassMapGenerator;
$loader->addClassMap(ClassMapGenerator::createMap(BASE_PATH . '/framework'));
$loader->add('Heystack\\Payment\\Test', __DIR__);
\Director::setBaseURL('http://localhost/');
<?php

use Symfony\Component\ClassLoader\ClassMapGenerator;
$filename = __DIR__ . '/../vendor/autoload.php';
if (!file_exists($filename)) {
    echo 'You must first install the vendors using composer.' . PHP_EOL;
    exit(1);
}
$loader = (require_once $filename);
$loader->addClassMap(ClassMapGenerator::createMap(__DIR__ . '/../framework'));
Example #18
0
 public function testCreateMapFinderSupport()
 {
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->files()->in(__DIR__ . '/Fixtures/beta/NamespaceCollision');
     $this->assertEqualsNormalized(array('NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__) . '/Fixtures/beta/NamespaceCollision/A/B/Bar.php', 'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__) . '/Fixtures/beta/NamespaceCollision/A/B/Foo.php', 'NamespaceCollision\\C\\B\\Bar' => realpath(__DIR__) . '/Fixtures/beta/NamespaceCollision/C/B/Bar.php', 'NamespaceCollision\\C\\B\\Foo' => realpath(__DIR__) . '/Fixtures/beta/NamespaceCollision/C/B/Foo.php'), ClassMapGenerator::createMap($finder));
 }
Example #19
0
 private function buildClassMap()
 {
     $map = [];
     foreach ($this->installedPackages as $package => $versions) {
         foreach ($versions as $version) {
             $composer = $this->reader->setPackage($package)->setVersion($version)->getComposerObject();
             if (!isset($composer['autoload'])) {
                 continue;
             }
             if (!isset($composer['autoload']['classmap'])) {
                 continue;
             }
             foreach ($composer['autoload']['classmap'] as $path) {
                 if ($package != null && $version != null) {
                     $path = $this->vendorDir . '/' . $package . '/' . $version . '/' . $path;
                 }
                 $map = array_merge($map, ClassMapGenerator::createMap($path));
             }
         }
     }
     return Linq::from($map)->orderBy('$k')->toArray();
 }