/** * @param LoaderInterface $loader */ public function registerContainerConfiguration(LoaderInterface $loader) { // We don't need that Environment stuff, just one config $loader->load(__DIR__ . '/config/config.yml'); $vendorDir = realpath(__DIR__ . '/../../../vendor'); require_once $vendorDir . '/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'; require_once $vendorDir . '/gedmo/doctrine-extensions/lib/Gedmo/Mapping/Annotation/All.php'; AnnotationRegistry::registerAutoloadNamespaces(array('Sensio\\Bundle\\FrameworkExtraBundle' => $vendorDir . '/sensio/framework-extra-bundle/')); }
public function setUp() { AnnotationRegistry::registerAutoloadNamespaces(array('JMS\\Serializer\\Annotation' => __DIR__ . '/../../../../../vendor/jms/serializer/src/')); $this->usd = new Currency('USD', 5, 2); $this->usdMoney = new Money($this->usd); $this->eur = new Currency('EUR', 5, 2); $this->eurMoney = new Money($this->eur); $this->rate = new ExchangeRate($this->usd, $this->eur, 1.5); }
public function setUp() { AnnotationRegistry::registerAutoloadNamespaces(array('JMS\\Serializer\\Annotation' => __DIR__ . '/../../../../../vendor/jms/serializer/src/')); $this->usd = new Currency('USD', 5, 2); $this->eur = new Currency('EUR', 5, 2); $this->gbp = new Currency('GBP', 5, 2); $this->usdToEur = new CurrencyPair($this->usd, $this->eur); $this->usdToGbp = new CurrencyPair($this->usd, $this->gbp); }
/** * Set up annotation metadata. * * @param array $options */ protected static function setupAnnotationMetadata(array $options) { foreach ($options['annotation_files'] as $file) { AnnotationRegistry::registerFile($file); } AnnotationRegistry::registerAutoloadNamespaces($options['annotation_namespaces']); foreach ($options['annotation_autoloaders'] as $autoloader) { AnnotationRegistry::registerLoader($autoloader); } }
/** * * @param array $config * @return AnnotationReader */ public static function factory(array $config) { AnnotationRegistry::registerAutoloadNamespaces($config['namespaces']); $reader = new AnnotationReader(); foreach ($config['ignored_annotations'] as $ignore) { $reader->addGlobalIgnoredName($ignore); } if (is_string($config['cache'])) { $reader = new CachedReader($reader, new FilesystemCache($config['cache'], 'cache'), $config['cache_debug']); } return $reader; }
public static function create(IContainer $context) { $loaders = array(); $context = new ValidatorContext(); AnnotationRegistry::registerAutoloadNamespaces(array('\\Doctrine\\ORM\\Mapping\\', '\\Symfony\\Component\\Validator\\Constraints\\')); $annotationReader = new AnnotationReader(); $annotationReader->setIgnoreNotImportedAnnotations(true); $loader = new AnnotationLoader($annotationReader); $context->setClassMetadataFactory(new ClassMetadataFactory($loader)); $context->setConstraintValidatorFactory(new ConstraintValidatorFactory()); $factory = new SymfonyValidatorFactory($context); return $factory->getValidator(); }
/** * Set up annotation metadata * * @param array $options */ protected static function setupAnnotationMetadata(array $options = []) { $annotationFiles = self::getOption($options, 'annotation_files'); if ($annotationFiles) { foreach ($annotationFiles as $file) { AnnotationRegistry::registerFile($file); } } $annotationNamespaces = self::getOption($options, 'annotation_namespaces'); if ($annotationNamespaces) { AnnotationRegistry::registerAutoloadNamespaces($annotationNamespaces); } $annotationAuloaders = self::getOption($options, 'annotation_autoloaders'); if ($annotationAuloaders) { foreach ($annotationAuloaders as $autoloader) { AnnotationRegistry::registerLoader($autoloader); } } }
/** * register all annotations and init the AnnotationReader * * @return boolean */ private function initAnnotationReader() { AnnotationRegistry::registerFile($this->getVendorDir() . '/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); // annotations require custom autoloading AnnotationRegistry::registerAutoloadNamespaces(['JMS\\Serializer\\Annotation' => $this->getVendorDir() . '/jms/serializer/src/']); AnnotationRegistry::registerLoader(function ($classname) { if (0 === strpos($classname, 'BackBee')) { return class_exists($classname); } if (0 === strpos($classname, 'Symfony\\Component\\Validator\\Constraints')) { return class_exists($classname); } return false; }); }
protected function registerAnnotationAutoloaderNamespace() { $annotation_namespaces = array('Drupal\\services\\Annotation' => DRUPAL_ROOT . '/modules/services/lib'); AnnotationRegistry::registerAutoloadNamespaces($annotation_namespaces); }
protected function getListener() { $refl = new \ReflectionClass('BackBee\\Rest\\Controller\\Annotations\\Pagination'); \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespaces(array('BackBee\\Rest\\Controller\\Annotations' => dirname($refl->getFileName()))); $metadataFactory = new \Metadata\MetadataFactory(new \BackBee\Rest\Mapping\Driver\AnnotationDriver(new \Doctrine\Common\Annotations\AnnotationReader())); $listener = new PaginationListener($metadataFactory, Validation::createValidator()); return $listener; }
/** * createMetadataDriver * * Create the required metadata driver instance * * @param Configuration $config The configuration data * @return Doctine\Common\Persistance\Mapping\Driver\MappingDriver */ protected function createMetadataDriver(array $options, array $entityDirs = array()) { if (!isset($options['type'])) { throw new \BadMethodCallException(sprintf('The metadata driver type has not been defined')); } switch (strtolower($options['type'])) { case 'annotation': if (isset($options['params']['file'])) { if (is_readable($options['params']['file'])) { Annotations\AnnotationRegistry::registerFile($options['params']['file']); } else { throw new \InvalidArgumentException(sprintf('The annotation file path %s provided is missing or unreadable', $options['params']['file'])); } } if (isset($options['params']['namespaces']) && is_array($options['params']['namespaces'])) { Annotations\AnnotationRegistry::registerAutoloadNamespaces($options['params']['namespaces']); } return new Driver\AnnotationDriver(new Annotations\CachedReader(new Annotations\AnnotationReader(), new Cache\ArrayCache()), $entityDirs); break; default: throw new \InvalidArgumentException('The metadata driver must be of type Doctine\\Common\\Persistance\\Mapping\\Driver\\MappingDriver'); } }
<?php use Doctrine\Common\Annotations\AnnotationRegistry; $rootDir = __DIR__ . '/../Annotation'; $vendorDir = __DIR__ . '/../vendor'; if (!is_file($autoloadFile = $vendorDir . '/autoload.php')) { throw new \LogicException('Could not find autoload.php in vendor/. Did you run "composer install --dev"?'); } require $autoloadFile; AnnotationRegistry::registerAutoloadNamespaces(array('Doctrine\\ORM\\Mapping' => $vendorDir . '/doctrine/orm/lib/', 'Symfony\\Component\\Validator\\Constraints' => $vendorDir . '/symfony/symfony/src', 'JMS\\DiExtraBundle\\Annotation' => $vendorDir . '/jms/di-extra-bundle')); AnnotationRegistry::registerFile($rootDir . '/Entity.php');
/** * Set up annotation metadata */ private function setupAnnotationMetadata() { $annotationFiles = $this->getOption('annotation_files'); if ($annotationFiles) { if (!is_array($annotationFiles)) { $annotationFiles = [$annotationFiles]; } foreach ($annotationFiles as $file) { AnnotationRegistry::registerFile($file); } } $annotationNamespaces = $this->getOption('annotation_namespaces'); if ($annotationNamespaces) { if (!is_array($annotationNamespaces)) { $annotationNamespaces = [$annotationNamespaces]; } AnnotationRegistry::registerAutoloadNamespaces($annotationNamespaces); } $annotationAuloaders = $this->getOption('annotation_autoloaders'); if ($annotationAuloaders) { if (!is_array($annotationAuloaders)) { $annotationAuloaders = [$annotationAuloaders]; } foreach ($annotationAuloaders as $autoloader) { AnnotationRegistry::registerLoader($autoloader); } } }
protected function setUp() { // annotations require custom autoloading AnnotationRegistry::registerAutoloadNamespaces(['Symfony\\Component\\Validator\\Constraint' => $this->getBBApp()->getVendorDir() . '/symfony/validator/', 'JMS\\Serializer\\Annotation' => $this->getBBApp()->getVendorDir() . '/jms/serializer/src/', 'BackBee' => $this->getBBApp()->getBaseDir()]); }
public function setUp() { // annotations don't auto-load correctly using just psr-0 // http://stackoverflow.com/questions/13582055/webtestcase-does-not-autoload-route-annotation AnnotationRegistry::registerAutoloadNamespaces(array('JMS\\Serializer\\Annotation\\' => dirname(__FILE__) . '/../../../../../vendor/jms/serializer/src/')); }
public function __construct($options = []) { $this->reader = new AnnotationReader(); $autoload = isset($options['autoload']) && is_array($options['autoload']) ? $options['autoload'] : ['Eoko\\ODM\\Metadata\\Annotation' => __DIR__ . '/../../../../']; AnnotationRegistry::registerAutoloadNamespaces($autoload); }
<?php /** * Author: Fedor Avetisov <*****@*****.**> * Date: 5/23/13 */ $loader = (require_once __DIR__ . '/../vendor/autoload.php'); use Doctrine\Common\Annotations\AnnotationRegistry; AnnotationRegistry::registerLoader(function ($class) use($loader) { $loader->loadClass($class); return class_exists($class, false); }); //AnnotationRegistry::registerPrefix('PHPExcel', __DIR__.'/../vendor/bundles/Export/ExcelBundle/Library/phpExcel/Classes'); $vendorDir = __DIR__ . '/../vendor/'; $namespaces = ['Sensio\\Bundle\\FrameworkExtraBundle' => __DIR__ . '/../vendor/sensio/framework-extra-bundle/']; AnnotationRegistry::registerFile(__DIR__ . '/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php'); AnnotationRegistry::registerAutoloadNamespaces($namespaces);
<?php use Doctrine\Common\Annotations\AnnotationRegistry; if (!is_dir('build')) { mkdir('build'); } $loader = (require __DIR__ . '/../vendor/autoload.php'); // Register the annotations AnnotationRegistry::registerAutoloadNamespaces(['Doxport\\Annotation' => $loader->getPrefixes()['Doxport\\'][0]]); // Load the tests directory into the main namespace $loader->add('Doxport\\', __DIR__);
<?php /* * This file is part of the MisdGuzzleBundle for Symfony2. * * (c) University of Cambridge * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Doctrine\Common\Annotations\AnnotationRegistry; $loader = @(include __DIR__ . '/../vendor/autoload.php'); if (false === $loader) { die(<<<'EOT' You must set up the project dependencies by running the following commands: curl -s http://getcomposer.org/installer | php php composer.phar install --dev EOT ); } AnnotationRegistry::registerAutoloadNamespaces(array('JMS\\Serializer' => __DIR__ . '/../vendor/jms/serializer/src'));