/**
  * Handle the command.
  *
  * @param ClassMapGenerator $generator
  * @param Filesystem $files
  */
 public function handle(ClassMapGenerator $generator, Filesystem $files)
 {
     foreach ($files->directories(base_path('storage/streams')) as $directory) {
         if (is_dir($models = $directory . '/models')) {
             $generator->dump($files->directories($models), $models . '/classmap.php');
         }
     }
 }
 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 #5
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 #8
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 #9
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);
 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;
 }
<?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'));
Example #15
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();
 }
Example #16
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__);
Example #18
0
<?php

require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\ClassLoader\ClassMapGenerator;
ClassMapGenerator::dump(array(__DIR__ . '/src'), __DIR__ . '/class_map.php');
use Symfony\Component\ClassLoader\MapClassLoader;
$mapping = (include __DIR__ . '/class_map.php');
$loader = new MapClassLoader($mapping);
$loader->register();
use Goutte\Client;
use Guzzle\Common\Event;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
date_default_timezone_set('Europe/London');
$client = new Client();
$url_crawl = 'http://www.sainsburys.co.uk/webapp/wcs/stores/servlet/CategoryDisplay?msg=&categoryId=185749&langId=44&storeId=10151&krypto=CWSPwJn7%2FfNCQJ17kIzWIEvEWIHZR3Bj3iR4i5MAF9M7qzk%2FP9%2B4zVL66KSWG186Uk9LnjKfPgCi%0AMsUYGCAI6oj6XhceppObUmu5R1ud8Z7wJuqB5X214E%2BBA47VydOEDYPnnJM%2BvN%2FIT5QMVV5%2B2aGv%0Alb1unCWjvafVBq7m6USN2aiCjWKM5mUPqPuXdvOWsUIFwpRb3OMbqw0sp5n8RyO6gCstruK1H%2B3L%0AGstBthGCZEJIXfuWPan04OtMjtzKYB1lUYa1f1JJu7YBoqhhyEgYYl0MlcS8vhp8Dn4dsKY%3D#langId=44&storeId=10151&catalogId=10137&categoryId=185749&parent_category_rn=12518&top_category=12518&pageSize=20&orderBy=FAVOURITES_FIRST&searchTerm=&beginIndex=0&hideFilters=true';
$crawler = $client->request('GET', $url_crawl);
$product_elms = new Products();
$crawler->filter('ul.productLister > li .productInner')->each(function ($node) use(&$product_elms) {
    $product_elm = new Product();
    $product_elm->setTitle($node->filter('h3 a')->text());
    $product_elm->setUnitPrice($node->filter('.pricePerUnit')->text());
    // get the item description from the linked page
    $client_internal = new Client();
    $crawler_internal = $client_internal->request('GET', $node->filter('h3 a')->attr('href'));
    $product_elm->setDescription($crawler_internal->filter('.productText')->text());
    $product_elm->setSize(strlen($crawler_internal->html()));
    // calc total unit price
    $product_elms->add($product_elm)->addUnitPrice($product_elm);
<?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 #21
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));
 }
namespace {
    require_once __DIR__ . '/vendor/autoload.php';
    use Dima\Legacy\TestClass as TestLoadedByMap;
    use Dima\Test as TestPsr0;
    use Symfony\Component\ClassLoader\ClassLoader;
    use Symfony\Component\ClassLoader\ClassMapGenerator;
    use Symfony\Component\ClassLoader\MapClassLoader;
    use Symfony\Component\ClassLoader\Psr4ClassLoader;
    use Symfony\Component\ClassLoader\XcacheClassLoader;
    use DG\SymfonyCert\Controller\HomeController;
    $psr0Loader = new ClassLoader();
    $psr0Loader->addPrefix('Dima', __DIR__ . '/srcPsr0');
    $cachedLoader = new XcacheClassLoader(sha1(__FILE__), $psr0Loader);
    $cachedLoader->register();
    $psr0Loader->unregister();
    $psr4Loader = new Psr4ClassLoader();
    $psr4Loader->addPrefix('DG\\SymfonyCert\\', __DIR__ . '/src');
    $psr4Loader->register();
    $mapLoader = new MapClassLoader(['Dima\\Legacy\\TestClass' => __DIR__ . '/srcPsr0/TestClass.php']);
    $mapLoader->register();
    ClassMapGenerator::dump(__DIR__ . '/srcThirdParty', __DIR__ . '/class_map.php');
    $classMap = (include __DIR__ . '/class_map.php');
    $mapLoader2 = new MapClassLoader($classMap);
    $mapLoader2->register();
    //Psr0 loader + XCache
    TestPsr0::output("Hello from Psr0 loaded class!");
    //Map loader
    TestLoadedByMap::test();
    $homeController = new HomeController();
    echo $homeController->indexAction()->getContent(), "\n";
}