Example #1
0
function sf2AutoLoad()
{
    $loader = new UniversalClassLoader();
    $loader->registerNamespaces(array('Sf2Plugins' => __DIR__ . '/src'));
    $loader->registerPrefixes(array('Twig_Extensions_' => __DIR__ . '/lib/Twig-extensions/lib', 'Twig_' => __DIR__ . '/lib/Twig/lib'));
    $loader->register();
}
 public static function earlyInitialize()
 {
     $classLoader = new UniversalClassLoader();
     $classLoader->registerNamespace('Stagehand\\TestRunner', array(__DIR__ . '/../../..', __DIR__ . '/../../../../src/Stagehand/TestRunner/Resources/examples'));
     $classLoader->registerPrefix('Stagehand_TestRunner_', __DIR__ . '/../../../../src/Stagehand/TestRunner/Resources/examples');
     $classLoader->register();
 }
Example #3
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     $app = $this;
     $this['autoloader'] = $this->share(function () {
         $loader = new UniversalClassLoader();
         $loader->register();
         return $loader;
     });
     $this['routes'] = $this->share(function () {
         return new RouteCollection();
     });
     $this['controllers'] = $this->share(function () use($app) {
         return new ControllerCollection($app['routes']);
     });
     $this['dispatcher'] = $this->share(function () use($app) {
         $dispatcher = new EventDispatcher();
         $dispatcher->addSubscriber($app);
         return $dispatcher;
     });
     $this['resolver'] = $this->share(function () {
         return new ControllerResolver();
     });
     $this['kernel'] = $this->share(function () use($app) {
         return new HttpKernel($app['dispatcher'], $app['resolver']);
     });
     $this['request.http_port'] = 80;
     $this['request.https_port'] = 443;
 }
 /**
  * @group legacy
  */
 public function testLegacyHandleClassNotFound()
 {
     $prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception'));
     $symfonyUniversalClassLoader = new SymfonyUniversalClassLoader();
     $symfonyUniversalClassLoader->registerPrefixes($prefixes);
     $this->testHandleClassNotFound(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($symfonyUniversalClassLoader, 'loadClass'));
 }
 /**
  * @dataProvider getLoadClassPrefixCollisionTests
  */
 public function testLoadClassPrefixCollision($prefixes, $className, $message)
 {
     $loader = new UniversalClassLoader();
     $loader->registerPrefixes($prefixes);
     $loader->loadClass($className);
     $this->assertTrue(class_exists($className), $message);
 }
Example #6
0
 /**
  * Constructor
  *
  * @param KernelInterface $kernel
  */
 public function __construct(KernelInterface $kernel)
 {
     // register email address proxy class loader
     $loader = new UniversalClassLoader();
     $loader->registerNamespaces([self::ENTITY_PROXY_NAMESPACE => $kernel->getCacheDir() . DIRECTORY_SEPARATOR . self::CACHED_ENTITIES_DIR_NAME]);
     $loader->register();
 }
Example #7
0
 public function registerBundles()
 {
     $loader = new UniversalClassLoader();
     $loader->registerNamespace('SomeProject\\', array(__DIR__));
     $loader->registerNamespace('SomeAnotherProject\\', array(__DIR__));
     $loader->register();
     return array(new \SomeProject\Bundle\SomeBundle\SomeBundle(), new \SomeAnotherProject\Bundle\SomeAnotherBundle\SomeAnotherBundle());
 }
Example #8
0
 /**
  * Add new autoloader to the stack.
  *
  * @param string $namespace Namespace.
  * @param string $path      Path.
  * @param string $separator Separator, _ or \\.
  *
  * @return void
  */
 public static function addAutoloader($namespace, $path = '', $separator = '_')
 {
     if (in_array($namespace, self::$autoloaders->getNamespaces())) {
         return;
     }
     if ($separator == '_') {
         return self::$autoloaders->registerPrefix($namespace . '_', $path);
     }
     self::$autoloaders->register($namespace, $path, $separator);
 }
Example #9
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     $app = $this;
     $this['autoloader'] = $this->share(function () {
         $loader = new UniversalClassLoader();
         $loader->register();
         return $loader;
     });
     $this['debug'] = false;
     $this['charset'] = 'UTF-8';
 }
 public function provideLegacyClassNotFoundData()
 {
     $prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception'));
     $symfonyAutoloader = new SymfonyClassLoader();
     $symfonyAutoloader->addPrefixes($prefixes);
     $symfonyUniversalClassLoader = new SymfonyUniversalClassLoader();
     $symfonyUniversalClassLoader->registerPrefixes($prefixes);
     return array(array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($symfonyAutoloader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($symfonyUniversalClassLoader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?", function ($className) {
         /* do nothing here */
     }));
 }
 public function provideClassNotFoundData()
 {
     $prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception'));
     $symfonyAutoloader = new SymfonyClassLoader();
     $symfonyAutoloader->addPrefixes($prefixes);
     $symfonyUniversalClassLoader = new SymfonyUniversalClassLoader();
     $symfonyUniversalClassLoader->registerPrefixes($prefixes);
     return array(array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'WhizBangFactory\' not found'), 'Attempted to load class "WhizBangFactory" from the global namespace in foo.php line 12. Did you forget a use statement for this class?'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\WhizBangFactory\' not found'), 'Attempted to load class "WhizBangFactory" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace?'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'PEARClass\' not found'), 'Attempted to load class "PEARClass" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony_Component_Debug_Tests_Fixtures_PEARClass.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.', array($symfonyAutoloader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.', array($symfonyUniversalClassLoader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace?', function ($className) {
         /* do nothing here */
     }));
 }
Example #12
0
 public function __construct()
 {
     $app = $this;
     $this['autoloader'] = $this->share(function () {
         $loader = new UniversalClassLoader();
         $loader->register();
         return $loader;
     });
     $this['basedir'] = __DIR__ . '/../../../..';
     $this->register_twig();
     $this->register_markdown();
 }
Example #13
0
 /**
  * Check for composer in Namespace
  * and include via phar if possible
  */
 public static function checkComposer($pathToComposer = null)
 {
     if (!class_exists("Composer\\Factory")) {
         if (false === ($pathToComposer = self::whichComposer($pathToComposer))) {
             throw new \RuntimeException("Could not find composer.phar");
         }
         \Phar::loadPhar($pathToComposer, 'composer.phar');
         $loader = new UniversalClassLoader();
         $namespaces = (include "phar://composer.phar/vendor/composer/autoload_namespaces.php");
         $loader->registerNamespaces(array_merge(array('Composer' => "phar://composer.phar/src/"), $namespaces));
         $loader->register(true);
     }
 }
Example #14
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     $app = $this;
     $this['autoloader'] = $this->share(function () {
         $loader = new UniversalClassLoader();
         $loader->register();
         return $loader;
     });
     $this['routes'] = $this->share(function () {
         return new RouteCollection();
     });
     $this['controllers'] = $this->share(function () use($app) {
         return new ControllerCollection();
     });
     $this['exception_handler'] = $this->share(function () {
         return new ExceptionHandler();
     });
     $this['dispatcher'] = $this->share(function () use($app) {
         $dispatcher = new EventDispatcher();
         $dispatcher->addSubscriber($app);
         $urlMatcher = new LazyUrlMatcher(function () use($app) {
             return $app['url_matcher'];
         });
         $dispatcher->addSubscriber(new RouterListener($urlMatcher));
         return $dispatcher;
     });
     $this['resolver'] = $this->share(function () use($app) {
         return new ControllerResolver($app);
     });
     $this['kernel'] = $this->share(function () use($app) {
         return new HttpKernel($app['dispatcher'], $app['resolver']);
     });
     $this['request_context'] = $this->share(function () use($app) {
         $context = new RequestContext();
         $context->setHttpPort($app['request.http_port']);
         $context->setHttpsPort($app['request.https_port']);
         return $context;
     });
     $this['url_matcher'] = $this->share(function () use($app) {
         return new RedirectableUrlMatcher($app['routes'], $app['request_context']);
     });
     $this['request.default_locale'] = 'en';
     $this['request'] = function () {
         throw new \RuntimeException('Accessed request service outside of request scope. Try moving that call to a before handler or controller.');
     };
     $this['request.http_port'] = 80;
     $this['request.https_port'] = 443;
     $this['debug'] = false;
     $this['charset'] = 'UTF-8';
 }
Example #15
0
 protected function configureClassLoader()
 {
     if (!class_exists('Stagehand\\TestRunner\\Core\\Environment')) {
         if (!class_exists('Symfony\\Component\\ClassLoader\\UniversalClassLoader', false)) {
             require_once 'Symfony/Component/ClassLoader/UniversalClassLoader.php';
         }
         $includePaths = explode(PATH_SEPARATOR, get_include_path());
         $classLoader = new UniversalClassLoader();
         foreach (self::$namespaces as $namespace) {
             $classLoader->registerNamespace($namespace, $includePaths);
         }
         $classLoader->register();
     }
 }
Example #16
0
 /**
  * Initialise.
  *
  * Runs at plugin init time.
  *
  * @return void
  */
 public function initialize(GenericEvent $event)
 {
     // register namespace
     // Because the standard kernel classloader already has Doctrine registered as a namespace
     // we have to add a new loader onto the spl stack.
     $autoloader = new UniversalClassLoader();
     $autoloader->register();
     $autoloader->registerNamespaces(array('DoctrineProxy' => 'ztemp/doctrinemodels'));
     $container = $event->getDispatcher()->getContainer();
     $config = $GLOBALS['ZConfig']['DBInfo']['databases']['default'];
     $dbConfig = array('host' => $config['host'], 'user' => $config['user'], 'password' => $config['password'], 'dbname' => $config['dbname'], 'driver' => 'pdo_' . $config['dbdriver']);
     $r = new \ReflectionClass('Doctrine\\Common\\Cache\\' . $container['dbcache.type'] . 'Cache');
     $dbCache = $r->newInstance();
     $ORMConfig = new \Doctrine\ORM\Configuration();
     $container->set('doctrine.configuration', $ORMConfig);
     $ORMConfig->setMetadataCacheImpl($dbCache);
     // create proxy cache dir
     \CacheUtil::createLocalDir('doctrinemodels');
     // setup annotations base
     include_once \ZLOADER_PATH . '/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php';
     // setup annotation reader
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $cacheReader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache());
     $container->set('doctrine.annotationreader', $cacheReader);
     // setup annotation driver
     $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cacheReader);
     $container->set('doctrine.annotationdriver', $annotationDriver);
     // setup driver chains
     $driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $container->set('doctrine.driverchain', $driverChain);
     // configure Doctrine ORM
     $ORMConfig->setMetadataDriverImpl($annotationDriver);
     $ORMConfig->setQueryCacheImpl($dbCache);
     $ORMConfig->setProxyDir(\CacheUtil::getLocalDir('doctrinemodels'));
     $ORMConfig->setProxyNamespace('DoctrineProxy');
     if (isset($container['log.enabled']) && $container['log.enabled']) {
         $ORMConfig->setSQLLogger(new \Zikula\Core\Doctrine\Logger\ZikulaSqlLogger());
     }
     // setup doctrine eventmanager
     $dispatcher = new \Doctrine\Common\EventManager();
     $container->set('doctrine.eventmanager', $dispatcher);
     // setup MySQL specific listener (storage engine and encoding)
     if ($config['dbdriver'] == 'mysql') {
         $mysqlSessionInit = new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit($config['charset']);
         $dispatcher->addEventSubscriber($mysqlSessionInit);
     }
     // setup the doctrine entitymanager
     $entityManager = \Doctrine\ORM\EntityManager::create($dbConfig, $ORMConfig, $dispatcher);
     $container->set('doctrine.entitymanager', $entityManager);
 }
Example #17
0
 public function __construct()
 {
     $this->rootDir = sys_get_temp_dir() . '/sf2_' . rand(1, 9999);
     if (!is_dir($this->rootDir)) {
         if (false === @mkdir($this->rootDir)) {
             exit(sprintf('Unable to create a temporary directory (%s)', $this->rootDir));
         }
     } elseif (!is_writable($this->rootDir)) {
         exit(sprintf('Unable to write in a temporary directory (%s)', $this->rootDir));
     }
     parent::__construct('env', true);
     $loader = new UniversalClassLoader();
     $loader->registerNamespaces(array('TestBundle' => __DIR__ . '/Fixtures/', 'TestApplication' => __DIR__ . '/Fixtures/'));
     $loader->register();
 }
Example #18
0
 /**
  * Finds the path to the file where the class is defined.
  *
  * @param string $class The name of the class
  *
  * @return string|null The path, if found
  */
 public function findFile($class)
 {
     if ('\\' == $class[0]) {
         $class = substr($class, 1);
     }
     # Test if we have a namespace class name
     if (false === ($pos = strrpos($class, '\\'))) {
         # Use normal loading
         return parent::findFile($class);
     }
     # fetch the extension namespaces
     #find if any match the current namespace
     foreach ($this->getExtensionNamespace() as $ext_namespace => $ext_folder) {
         $pos = strrpos($class, '\\');
         $namespace = substr($class, 0, $pos);
         $className = substr($class, $pos + 1);
         # check if the extension namespace found in the current class (at string 0)
         if (0 === strpos($namespace, $ext_namespace)) {
             # apply call back to filter the namespace Faker_components'
             if ($this->filter instanceof \Closure) {
                 $filter = $this->filter;
                 $namespace = $filter($namespace);
             }
             $normalizedClass = strtolower(str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php');
             $file = $ext_folder . DIRECTORY_SEPARATOR . $normalizedClass;
             if (is_file($file)) {
                 return $file;
             }
         }
     }
     # Use normal loading
     return parent::findFile($class);
 }
 public static function earlyInitialize()
 {
     $classLoader = new UniversalClassLoader();
     $classLoader->registerNamespace('Stagehand\\TestRunner', array(__DIR__ . '/../../..', __DIR__ . '/../../../../examples'));
     $classLoader->registerPrefix('Stagehand_TestRunner_', __DIR__ . '/../../../../examples');
     $classLoader->register();
     self::$applicationContext = new TestApplicationContext();
     self::$applicationContext->setComponentFactory(new TestComponentFactory());
     self::$applicationContext->setEnvironment(new self());
     self::$applicationContext->setPlugin(PluginRepository::findByPluginID(PHPUnitPlugin::getPluginID()));
     ApplicationContext::setInstance(self::$applicationContext);
     $container = new Container();
     $transformation = new Transformation($container);
     $transformation->transformToContainerParameters();
     ApplicationContext::getInstance()->getComponentFactory()->setContainer($container);
 }
Example #20
0
 public function __construct()
 {
     $this->tmpDir = sys_get_temp_dir() . '/sf2_' . rand(1, 9999);
     if (!is_dir($this->tmpDir)) {
         if (false === @mkdir($this->tmpDir)) {
             die(sprintf('Unable to create a temporary directory (%s)', $this->tmpDir));
         }
     } elseif (!is_writable($this->tmpDir)) {
         die(sprintf('Unable to write in a temporary directory (%s)', $this->tmpDir));
     }
     parent::__construct('env', true);
     require_once __DIR__ . '/FacebookApiException.php';
     $loader = new UniversalClassLoader();
     $loader->loadClass('\\FacebookApiException');
     $loader->register();
 }
Example #21
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     $app = $this;
     $this['autoloader'] = $this->share(function () {
         $loader = new UniversalClassLoader();
         $loader->register();
         return $loader;
     });
     $this['routes'] = $this->share(function () {
         return new RouteCollection();
     });
     $this['controllers'] = $this->share(function () use($app) {
         return new ControllerCollection();
     });
     $this['exception_handler'] = $this->share(function () {
         return new ExceptionHandler();
     });
     $this['dispatcher'] = $this->share(function () use($app) {
         $dispatcher = new EventDispatcher();
         $dispatcher->addSubscriber($app);
         if (isset($app['exception_handler'])) {
             $dispatcher->addSubscriber($app['exception_handler']);
         }
         $dispatcher->addSubscriber(new ResponseListener($app['charset']));
         $dispatcher->addSubscriber(new RouterListener($app['url_matcher']));
         return $dispatcher;
     });
     $this['resolver'] = $this->share(function () use($app) {
         return new ControllerResolver($app);
     });
     $this['kernel'] = $this->share(function () use($app) {
         return new HttpKernel($app['dispatcher'], $app['resolver']);
     });
     $this['request_context'] = $this->share(function () use($app) {
         $context = new RequestContext();
         $context->setHttpPort($app['request.http_port']);
         $context->setHttpsPort($app['request.https_port']);
         return $context;
     });
     $this['url_matcher'] = $this->share(function () use($app) {
         return new RedirectableUrlMatcher($app['routes'], $app['request_context']);
     });
     $this['request.http_port'] = 80;
     $this['request.https_port'] = 443;
     $this['debug'] = false;
     $this['charset'] = 'UTF-8';
 }
Example #22
0
 /**
  * @param string $ns Namespace's description
  * @param string $path Namespace's path
  * @throws Exception
  */
 public static function registerNamespace($ns, $path)
 {
     switch (true) {
         case self::$loader instanceof \Composer\Autoload\ClassLoader:
             self::$loader->add($ns, $path);
             break;
         case self::$loader instanceof \Zend\Loader\SplAutoloader:
             self::$loader->registerPrefix($ns, $path . '/' . $ns);
             break;
             // @TODO: This hasn't been tested nor confirmed. Must test & check if OK.
         // @TODO: This hasn't been tested nor confirmed. Must test & check if OK.
         case self::$loader instanceof \Symfony\Component\ClassLoader\UniversalClassLoader:
             self::$loader->registerNamespace($ns, $path);
             break;
         default:
             throw new \Exception('No Loader detected!');
     }
 }
Example #23
0
 /**
  * An array of file paths retrieved from {@see files()}.
  *
  * @param  array  $files A list of file paths.
  * @return array         A list of classes.
  */
 public static function classes(array $files)
 {
     $loader = new UniversalClassLoader();
     // Support PSR-0 autoloading with a composer.json file
     // @todo: Add support for Composer's classmap autoloading.
     if (file_exists(VANITY_PROJECT_WORKING_DIR . '/vendor/composer/autoload_namespaces.php')) {
         // Register namespaces with the class loader
         $loader->registerNamespaces(include VANITY_PROJECT_WORKING_DIR . '/vendor/composer/autoload_namespaces.php');
     } elseif (file_exists(VANITY_PROJECT_WORKING_DIR . '/composer.json')) {
         // Register namespaces with the class loader
         $composer = json_decode(file_get_contents(VANITY_PROJECT_WORKING_DIR . '/composer.json'), true);
         if (isset($composer['autoload']) && isset($composer['autoload']['psr-0'])) {
             $loader->registerNamespaces($composer['autoload']['psr-0']);
         }
     }
     $loader->register();
     $class_list = array();
     // Collect all current classes, interfaces and traits
     if (SystemStore::get('_.php54')) {
         $before = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
     } else {
         $before = array_merge(get_declared_classes(), get_declared_interfaces());
     }
     foreach ($files as $file) {
         include_once $file;
     }
     // Handle traits if this version of PHP supports them.
     if (SystemStore::get('_.php54')) {
         $after = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
     } else {
         $after = array_merge(get_declared_classes(), get_declared_interfaces());
     }
     // We should be able to document ourselves
     if (defined('VANITY_AM_I')) {
         $after = array_filter($after, function ($class) {
             return substr($class, 0, 7) !== 'Vanity\\';
         });
     }
     $class_list = array_values(array_unique(array_diff($after, $before)));
     sort($class_list);
     return $class_list;
 }
Example #24
0
 /**
  * Initialise.
  *
  * Runs at plugin init time.
  *
  * @return void
  */
 public function initialize()
 {
     $autoloader = new UniversalClassLoader();
     $autoloader->register();
     $autoloader->register('DoctrineExtensions\\StandardFields', __DIR__ . '/lib');
     Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Gedmo', dirname(__DIR__) . '/../vendor/gedmo/doctrine-extensions/lib');
     Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('DoctrineExtensions\\StandardFields', __DIR__ . '/lib');
     include 'ExtensionsManager.php';
     $definition = new Definition('SystemPlugins_DoctrineExtensions_ExtensionsManager', array(new Reference('doctrine.eventmanager'), new Reference('service_container')));
     $this->container->setDefinition('doctrine_extensions', $definition);
     $types = array('Loggable', 'Sluggable', 'Timestampable', 'Translatable', 'Tree', 'Sortable');
     foreach ($types as $type) {
         // The listener for Translatable is incorrectly named TranslationListener
         if ($type != "Translatable") {
             $definition = new Definition("Gedmo\\{$type}\\{$type}Listener");
         } else {
             $definition = new Definition("Gedmo\\Translatable\\TranslationListener");
         }
         $this->container->setDefinition(strtolower("doctrine_extensions.listener.{$type}"), $definition);
     }
     $definition = new Definition("DoctrineExtensions\\StandardFields\\StandardFieldsListener");
     $this->container->setDefinition(strtolower("doctrine_extensions.listener.standardfields"), $definition);
 }
Example #25
0
<?php

use Symfony\Component\ClassLoader\UniversalClassLoader;
require_once __DIR__ . '/../vendor/symfony/lib/Symfony/Component/ClassLoader/UniversalClassLoader.php';
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array('BattleNet' => __DIR__ . '/../lib', 'BattleNet\\Tests' => __DIR__ . '/../tests', 'Doctrine\\Common' => __DIR__ . '/../vendor/doctrine-common/lib'));
$loader->register();
Example #26
0
<?php

use Symfony\Component\ClassLoader\UniversalClassLoader;

$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
    'Symfony'          => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
    'Sensio'           => __DIR__.'/../vendor/bundles',
    'JMS'              => __DIR__.'/../vendor/bundles',
    'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
    'Doctrine\\DBAL\\Migrations'         => __DIR__.'/../vendor/doctrine-migrations/lib',
    'Doctrine\\DBAL'   => __DIR__.'/../vendor/doctrine-dbal/lib',
    'Doctrine'         => __DIR__.'/../vendor/doctrine/lib',
    'Monolog'          => __DIR__.'/../vendor/monolog/src',
    'Assetic'          => __DIR__.'/../vendor/assetic/src',
    'Metadata'         => __DIR__.'/../vendor/metadata/src',
    'TaskBoxx'          => __DIR__.'/../src',
    'Bundle'           => __DIR__.'/../src',
    'Knplabs'           => __DIR__.'/../src/Bundle',
));
$loader->registerPrefixes(array(
    'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',
    'Twig_'            => __DIR__.'/../vendor/twig/lib',
));
$loader->registerPrefixFallbacks(array(
    __DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs',
));
$loader->registerNamespaceFallbacks(array(
    __DIR__.'/../src',
));
$loader->register();
Example #27
0
<?php

require_once $_SERVER['SYMFONY'] . '/Symfony/Component/ClassLoader/UniversalClassLoader.php';
use Symfony\Component\ClassLoader\UniversalClassLoader;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array('Sensio\\Bundle\\FrameworkExtraBundle' => __DIR__ . '/../../../..', 'Symfony' => $_SERVER['SYMFONY']));
$loader->register();
Example #28
0
<?php

/*
 * This file is part of the Symfony framework.
 *
 * (c) Fabien Potencier <*****@*****.**>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */
require_once __DIR__ . '/../../../../ClassLoader/UniversalClassLoader.php';
use Symfony\Component\ClassLoader\UniversalClassLoader;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Security\Acl\Dbal\Schema;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array('Symfony' => __DIR__ . '/../../../../../..', 'Doctrine\\Common' => __DIR__ . '/../../../../../../../vendor/doctrine-common/lib', 'Doctrine\\DBAL\\Migrations' => __DIR__ . '/../../../../../../../vendor/doctrine-migrations/lib', 'Doctrine\\DBAL' => __DIR__ . '/../../../../../../../vendor/doctrine-dbal/lib', 'Doctrine' => __DIR__ . '/../../../../../../../vendor/doctrine/lib'));
$loader->register();
$schema = new Schema(array('class_table_name' => 'acl_classes', 'entry_table_name' => 'acl_entries', 'oid_table_name' => 'acl_object_identities', 'oid_ancestors_table_name' => 'acl_object_identity_ancestors', 'sid_table_name' => 'acl_security_identities'));
$reflection = new ReflectionClass('Doctrine\\DBAL\\Platforms\\AbstractPlatform');
$finder = new Finder();
$finder->name('*Platform.php')->in(dirname($reflection->getFileName()));
foreach ($finder as $file) {
    require_once $file->getPathName();
    $className = 'Doctrine\\DBAL\\Platforms\\' . $file->getBasename('.php');
    $reflection = new ReflectionClass($className);
    if ($reflection->isAbstract()) {
        continue;
    }
    $platform = $reflection->newInstance();
    $targetFile = sprintf(__DIR__ . '/../schema/%s.sql', $platform->name);
    file_put_contents($targetFile, implode("\n\n", $schema->toSql($platform)));
Example #29
0
<?php

use Symfony\Component\ClassLoader\UniversalClassLoader;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array('Assetic' => __DIR__ . '/../vendor/assetic/src', 'Doctrine\\Common' => __DIR__ . '/../vendor/doctrine/common/lib', 'Doctrine\\MongoDB' => __DIR__ . '/../vendor/doctrine/mongodb/lib', 'Doctrine\\ODM\\MongoDB' => __DIR__ . '/../vendor/doctrine/mongodb-odm/lib', 'FOS' => __DIR__ . '/../src', 'Application' => __DIR__ . '/../src', 'Vespolina' => __DIR__ . '/../src', 'Symfony' => __DIR__ . '/../vendor/symfony/src', 'vendor' => __DIR__ . '/../src', 'Zend\\Log' => __DIR__ . '/../vendor/zend-log'));
$loader->registerPrefixes(array('Twig_Extensions_' => __DIR__ . '/../vendor/twig-extensions/lib', 'Twig_' => __DIR__ . '/../vendor/twig/lib', 'Swift_' => __DIR__ . '/../vendor/swiftmailer/lib/classes'));
$loader->register();
Example #30
0
<?php

use Symfony\Component\ClassLoader\UniversalClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array('Symfony' => array(__DIR__ . '/../vendor/symfony/src', __DIR__ . '/../vendor/bundles'), 'Sensio' => __DIR__ . '/../vendor/bundles', 'JMS' => __DIR__ . '/../vendor/bundles', 'Doctrine\\ODM\\MongoDB' => __DIR__ . '/../vendor/doctrine-mongodb-odm/lib', 'Doctrine\\MongoDB' => __DIR__ . '/../vendor/doctrine-mongodb/lib', 'Doctrine\\Common' => __DIR__ . '/../vendor/doctrine-common/lib', 'Doctrine\\DBAL' => __DIR__ . '/../vendor/doctrine-dbal/lib', 'Doctrine' => __DIR__ . '/../vendor/doctrine/lib', 'Monolog' => __DIR__ . '/../vendor/monolog/src', 'Assetic' => __DIR__ . '/../vendor/assetic/src', 'Metadata' => __DIR__ . '/../vendor/metadata/src', 'FOS' => __DIR__ . '/../vendor/bundles'));
$loader->registerPrefixes(array('Twig_Extensions_' => __DIR__ . '/../vendor/twig-extensions/lib', 'Twig_' => __DIR__ . '/../vendor/twig/lib'));
// intl
if (!function_exists('intl_get_error_code')) {
    require_once __DIR__ . '/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
    $loader->registerPrefixFallbacks(array(__DIR__ . '/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs'));
}
$loader->registerNamespaceFallbacks(array(__DIR__ . '/../src'));
$loader->register();
AnnotationRegistry::registerLoader(function ($class) use($loader) {
    $loader->loadClass($class);
    return class_exists($class, false);
});
AnnotationRegistry::registerFile(__DIR__ . '/../vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
AnnotationRegistry::registerFile(__DIR__ . '/../vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DoctrineAnnotations.php');
// Swiftmailer needs a special autoloader to allow
// the lazy loading of the init file (which is expensive)
require_once __DIR__ . '/../vendor/swiftmailer/lib/classes/Swift.php';
Swift::registerAutoload(__DIR__ . '/../vendor/swiftmailer/lib/swift_init.php');