当前位置: 首页>>代码示例>>PHP>>正文


PHP Common\EventManager类代码示例

本文整理汇总了PHP中Doctrine\Common\EventManager的典型用法代码示例。如果您正苦于以下问题:PHP EventManager类的具体用法?PHP EventManager怎么用?PHP EventManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EventManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     $evm = new EventManager();
     $evm->addEventSubscriber(new TimestampableListener());
     $this->getMockDocumentManager($evm);
 }
开发者ID:esserj,项目名称:DoctrineExtensions,代码行数:7,代码来源:TimestampableEmbeddedDocumentTest.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $evm = new EventManager();
     $evm->addEventSubscriber(new TsVectorSubscriber());
     //		$this->getMock
 }
开发者ID:jbinfo,项目名称:DoctrineFullTextPostrgres,代码行数:7,代码来源:TsVectorTest.php

示例3: setUp

 protected function setUp()
 {
     $config = new Configuration();
     //$config->setHydratorDir(sys_get_temp_dir());
     //$config->setHydratorNamespace('Hydrators');
     $config->setProxyDir(sys_get_temp_dir());
     $config->setProxyNamespace('Proxies');
     $locatorXml = new SymfonyFileLocator(array(__DIR__ . '/../../../../../lib/Vespolina/Product/Mapping' => 'Vespolina\\Entity\\Product', __DIR__ . '/../../../../../vendor/vespolina/pricing/lib/Vespolina/Pricing/Mapping' => 'Vespolina\\Entity\\Pricing', __DIR__ . '/../../../../../vendor/vespolina/taxonomy/lib/Vespolina/Taxonomy/Mapping' => 'Vespolina\\Entity\\Taxonomy'), '.orm.xml');
     $drivers = new MappingDriverChain();
     $xmlDriver = new XmlDriver($locatorXml);
     $config->setMetadataDriverImpl($xmlDriver);
     $config->setMetadataCacheImpl(new ArrayCache());
     $config->setAutoGenerateProxyClasses(true);
     $eventManager = new EventManager();
     $treeListener = new TreeListener();
     $eventManager->addEventSubscriber($treeListener);
     $em = EntityManager::create(array('driver' => 'pdo_sqlite', 'path' => 'database.sqlite'), $config, $eventManager);
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $classes = array($em->getClassMetadata('Vespolina\\Entity\\Product\\Product'), $em->getClassMetadata('Vespolina\\Entity\\Taxonomy\\TaxonomyNode'));
     try {
         $schemaTool->dropSchema(array());
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
     $this->productGateway = new ProductDoctrineORMGateway($em, 'Vespolina\\Entity\\Product\\Product');
     $this->taxonomyGateway = new TaxonomyDoctrineORMGateway($em, 'Vespolina\\Entity\\Taxonomy\\TaxonomyNode');
     parent::setUp();
 }
开发者ID:vespolina,项目名称:commerce,代码行数:28,代码来源:ProductDoctrineORMGatewayTest.php

示例4: init

 /**
  * Executa as configurações iniciais e prepara o a entidade responsáveç
  * da biblioteca escolhida para ORM.
  */
 public function init()
 {
     $config = Config::getInstance();
     $paths = [SYS_ROOT . 'App' . DS . 'Models' . DS];
     $dev_mode = $config->get('database.debug');
     $conn_params = $this->loadConfiguration();
     $doctrine_config = Setup::createAnnotationMetadataConfiguration($paths, $dev_mode);
     if ($config->get('cache.cache')) {
         try {
             $cache = Cache::getInstance();
             if ($cache instanceof Cache) {
                 $doctrine_config->setResultCacheImpl($cache->getDriver());
             }
         } catch (\Exception $e) {
             $error = new Error();
             $error->log($e);
         }
     }
     $proxy_dir = SYS_ROOT . 'App' . DS . 'Models' . DS . 'Proxies';
     if (!is_dir($proxy_dir)) {
         if (mkdir($proxy_dir)) {
             $doctrine_config->setProxyDir($proxy_dir);
         }
     }
     $prefix = $config->get('database.connection.table_prefix');
     if ($prefix != '') {
         $evm = new EventManager();
         $table_prefix = new DoctrineTablePrefix($prefix);
         $evm->addEventListener(Events::loadClassMetadata, $table_prefix);
         $this->entityManager = EntityManager::create($conn_params, $doctrine_config, $evm);
     } else {
         $this->entityManager = EntityManager::create($conn_params, $doctrine_config);
     }
 }
开发者ID:anna-framework,项目名称:anna,代码行数:38,代码来源:DoctrineAdapter.php

示例5: getEntityManager

 /**
  * Get entity manager.
  *
  * @return EntityManagerInterface
  */
 protected function getEntityManager()
 {
     if (null === $this->entityManager) {
         $params = ['driver' => 'pdo_sqlite', 'memory' => true];
         $cache = new ArrayCache();
         /** @var AnnotationReader $reader */
         $reader = new CachedReader(new AnnotationReader(), $cache);
         $annotationDriver = new AnnotationDriver($reader, [__DIR__ . '/../../../src/ORM']);
         $driverChain = new MappingDriverChain();
         $driverChain->addDriver($annotationDriver, Commander::ENTITY_NAMESPACE);
         DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driverChain, $reader);
         $config = new Configuration();
         $config->setAutoGenerateProxyClasses(true);
         $config->setProxyDir(sys_get_temp_dir());
         $config->setProxyNamespace(Commander::ENTITY_NAMESPACE);
         $config->setMetadataDriverImpl($driverChain);
         $config->setMetadataCacheImpl($cache);
         $config->setQueryCacheImpl($cache);
         $config->setResultCacheImpl($cache);
         $config->setHydrationCacheImpl($cache);
         $timestampableListener = new TimestampableListener();
         $timestampableListener->setAnnotationReader($annotationDriver->getReader());
         $eventManager = new EventManager();
         $eventManager->addEventSubscriber($timestampableListener);
         $entityManager = EntityManager::create($params, $config, $eventManager);
         $schemaTool = new SchemaTool($entityManager);
         $schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata());
         $this->entityManager = $entityManager;
     }
     return $this->entityManager;
 }
开发者ID:gravitymedia,项目名称:commander,代码行数:36,代码来源:TaskEntityRepositoryTest.php

示例6: createWithConfig

 /**
  * {@inheritdoc}
  */
 protected function createWithConfig(ContainerInterface $container, $configKey)
 {
     $config = $this->retrieveConfig($container, $configKey, 'event_manager');
     $eventManager = new EventManager();
     foreach ($config['subscribers'] as $subscriber) {
         if (is_object($subscriber)) {
             $subscriberName = get_class($subscriber);
         } elseif (!is_string($subscriber)) {
             $subscriberName = gettype($subscriber);
         } elseif ($container->has($subscriber)) {
             $subscriber = $container->get($subscriber);
             $subscriberName = $subscriber;
         } elseif (class_exists($subscriber)) {
             $subscriber = new $subscriber();
             $subscriberName = get_class($subscriber);
         } else {
             $subscriberName = $subscriber;
         }
         if (!$subscriber instanceof EventSubscriber) {
             throw new DomainException(sprintf('Invalid event subscriber "%s" given, mut be a dependency name, class name or an instance' . ' implementing %s', $subscriberName, EventSubscriber::class));
         }
         $eventManager->addEventSubscriber($subscriber);
     }
     return $eventManager;
 }
开发者ID:dasprid,项目名称:container-interop-doctrine,代码行数:28,代码来源:EventManagerFactory.php

示例7: setUpEntityManager

 protected static function setUpEntityManager()
 {
     $config = new Configuration();
     $config->setSQLLogger(null);
     $config->setAutoGenerateProxyClasses(true);
     $config->setProxyDir(\sys_get_temp_dir());
     $config->setProxyNamespace('Proxies');
     $config->setMetadataDriverImpl(static::getMetadataDriverImpl());
     $config->setQueryCacheImpl(new ArrayCache());
     $config->setMetadataCacheImpl(new ArrayCache());
     $dbPath = __DIR__ . '/../db.sqlite';
     if (file_exists($dbPath)) {
         unlink($dbPath);
     }
     $connection = ['driver' => 'pdo_sqlite', 'path' => $dbPath];
     // Event listeners
     $interfaces = DoctrineBundleMapping::getDefaultImplementations();
     $evm = new EventManager();
     // Resolve entity target subscriber
     $rtel = new ResolveTargetEntityListener();
     foreach ($interfaces as $model => $implementation) {
         $rtel->addResolveTargetEntity($model, $implementation, []);
     }
     $evm->addEventSubscriber($rtel);
     // Load metadata subscriber
     $lm = new LoadMetadataSubscriber([], $interfaces);
     $evm->addEventSubscriber($lm);
     static::$em = EntityManager::create($connection, $config, $evm);
 }
开发者ID:ekyna,项目名称:commerce,代码行数:29,代码来源:OrmTestCase.php

示例8: create

 /**
  * {@inheritdoc}
  */
 public static function create($conn, Configuration $config, EventManager $eventManager = null)
 {
     if (!$config->getMetadataDriverImpl()) {
         throw ORMException::missingMappingDriverImpl();
     }
     switch (true) {
         case is_array($conn):
             if (!$eventManager) {
                 $eventManager = new EventManager();
             }
             if (isset($conn['prefix']) && $conn['prefix']) {
                 $eventManager->addEventListener(Events::loadClassMetadata, new TablePrefix($conn['prefix']));
             }
             $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
             break;
         case $conn instanceof Connection:
             if ($eventManager !== null && $conn->getEventManager() !== $eventManager) {
                 throw ORMException::mismatchedEventManager();
             }
             break;
         default:
             throw new \InvalidArgumentException("Invalid argument: " . $conn);
     }
     return new self($conn, $config, $conn->getEventManager());
 }
开发者ID:minchal,项目名称:vero,代码行数:28,代码来源:EntityManager.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     $evm = new EventManager();
     $evm->addEventSubscriber(new SluggableListener());
     $this->getMockSqliteEntityManager($evm);
 }
开发者ID:esserj,项目名称:DoctrineExtensions,代码行数:7,代码来源:Issue633Test.php

示例10: setUp

 public function setUp()
 {
     $evm = new EventManager();
     $evm->addEventSubscriber(new DoctrineEncryptSubscriber(new \Doctrine\Common\Annotations\AnnotationReader(), new Rot13Encryptor()));
     $this->getMockSqliteEntityManager($evm);
     $this->populate();
 }
开发者ID:51systems,项目名称:doctrine-encrypt,代码行数:7,代码来源:DoctrineEncryptSubscriberTest.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     $evm = new EventManager();
     $this->listener = new UploadableListenerStub();
     $this->listener->setMimeTypeGuesser(new MimeTypeGuesserStub('text/plain'));
     $evm->addEventSubscriber($this->listener);
     $config = $this->getMockAnnotatedConfig();
     $this->em = $this->getMockSqliteEntityManager($evm, $config);
     $this->testFile = __DIR__ . '/../../data/test.txt';
     $this->testFile2 = __DIR__ . '/../../data/test2.txt';
     $this->testFile3 = __DIR__ . '/../../data/test_3.txt';
     $this->testFileWithoutExt = __DIR__ . '/../../data/test4';
     $this->testFileWithSpaces = __DIR__ . '/../../data/test with spaces.txt';
     $this->destinationTestDir = __DIR__ . '/../../temp/uploadable';
     $this->destinationTestFile = $this->destinationTestDir . '/test.txt';
     $this->destinationTestFile2 = $this->destinationTestDir . '/test2.txt';
     $this->destinationTestFile3 = $this->destinationTestDir . '/test_3.txt';
     $this->destinationTestFileWithoutExt = $this->destinationTestDir . '/test4';
     $this->destinationTestFileWithSpaces = $this->destinationTestDir . '/test with spaces';
     $this->testFilename = substr($this->testFile, strrpos($this->testFile, '/') + 1);
     $this->testFilename2 = substr($this->testFile2, strrpos($this->testFile2, '/') + 1);
     $this->testFilename3 = substr($this->testFile3, strrpos($this->testFile3, '/') + 1);
     $this->testFilenameWithoutExt = substr($this->testFileWithoutExt, strrpos($this->testFileWithoutExt, '/') + 1);
     $this->testFilenameWithSpaces = substr($this->testFileWithSpaces, strrpos($this->testFileWithSpaces, '/') + 1);
     $this->testFileSize = 4;
     $this->testFileMimeType = 'text/plain';
     $this->clearFilesAndDirectories();
     if (!is_dir($this->destinationTestDir)) {
         mkdir($this->destinationTestDir);
     }
 }
开发者ID:erichard,项目名称:DoctrineExtensions,代码行数:32,代码来源:UploadableEntityTest.php

示例12: setUp

 public function setUp()
 {
     $this->evm = m::mock(EventManager::class);
     $this->evm->shouldReceive('addEventSubscriber')->once();
     $this->em = m::mock(EntityManagerInterface::class);
     $this->reader = m::mock(Reader::class);
 }
开发者ID:guiwoda,项目名称:laravel-doctrine-extensions,代码行数:7,代码来源:ExtensionTestCase.php

示例13: createService

 /**
  *
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return object
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $manifest = $serviceLocator->get('manifest');
     $config = new Configuration();
     $config->setProxyDir(__DIR__ . '/../../../../Proxies');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir(__DIR__ . '/../../../../Hydrators');
     $config->setHydratorNamespace('Hydrators');
     $config->setDefaultDB(self::DEFAULT_DB);
     $config->setMetadataCacheImpl(new ArrayCache());
     //create driver chain
     $chain = new MappingDriverChain();
     foreach ($manifest['documents'] as $namespace => $path) {
         $driver = new AnnotationDriver(new AnnotationReader(), $path);
         $chain->addDriver($driver, $namespace);
     }
     $config->setMetadataDriverImpl($chain);
     //register filters
     foreach ($manifest['filters'] as $name => $class) {
         $config->addFilter($name, $class);
     }
     //create event manager
     $eventManager = new EventManager();
     foreach ($manifest['subscribers'] as $subscriber) {
         $eventManager->addEventSubscriber($serviceLocator->get($subscriber));
     }
     //register annotations
     AnnotationRegistry::registerLoader(function ($className) {
         return class_exists($className);
     });
     $conn = new Connection(null, array(), $config);
     return DocumentManager::create($conn, $config, $eventManager);
 }
开发者ID:superdweebie,项目名称:doctrine-extensions,代码行数:38,代码来源:DocumentManagerFactory.php

示例14: addSubscriber

 /**
  * @param MappedEventSubscriber $subscriber
  * @param EventManager          $manager
  * @param Reader|null           $reader
  */
 protected function addSubscriber(MappedEventSubscriber $subscriber, EventManager $manager, Reader $reader = null)
 {
     if ($reader) {
         $subscriber->setAnnotationReader($reader);
     }
     $manager->addEventSubscriber($subscriber);
 }
开发者ID:guiwoda,项目名称:laravel-doctrine-extensions,代码行数:12,代码来源:GedmoExtension.php

示例15: createEntityManager

 /**
  * @return \Doctrine\ORM\EntityManager
  */
 protected function createEntityManager()
 {
     // event manager used to create schema before tests
     $eventManager = new EventManager();
     $eventManager->addEventListener(array("preTestSetUp"), new SchemaSetupListener());
     // doctrine xml configs and namespaces
     $configPathList = array();
     if (is_dir(__DIR__ . '/../Resources/config/doctrine')) {
         $dir = __DIR__ . '/../Resources/config/doctrine';
         $configPathList[] = $dir;
         $prefixList[$dir] = 'Kitpages\\DataGridBundle\\Entities';
     }
     if (is_dir(__DIR__ . '/_doctrine/config')) {
         $dir = __DIR__ . '/_doctrine/config';
         $configPathList[] = $dir;
         $prefixList[$dir] = 'Kitpages\\DataGridBundle\\Tests\\TestEntities';
     }
     // create drivers (that reads xml configs)
     $driver = new \Symfony\Bridge\Doctrine\Mapping\Driver\XmlDriver($configPathList);
     $driver->setNamespacePrefixes($prefixList);
     // create config object
     $config = new Configuration();
     $config->setMetadataCacheImpl(new ArrayCache());
     $config->setMetadataDriverImpl($driver);
     $config->setProxyDir(__DIR__ . '/TestProxies');
     $config->setProxyNamespace('Kitpages\\DataGridBundle\\Tests\\TestProxies');
     $config->setAutoGenerateProxyClasses(true);
     //$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
     // create entity manager
     $em = EntityManager::create(array('driver' => 'pdo_sqlite', 'path' => "/tmp/sqlite-test.db"), $config, $eventManager);
     return $em;
 }
开发者ID:radmar,项目名称:KitpagesDataGridBundle,代码行数:35,代码来源:BundleOrmTestCase.php


注:本文中的Doctrine\Common\EventManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。