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


PHP EntityManager::getEventManager方法代码示例

本文整理汇总了PHP中Doctrine\ORM\EntityManager::getEventManager方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::getEventManager方法的具体用法?PHP EntityManager::getEventManager怎么用?PHP EntityManager::getEventManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\EntityManager的用法示例。


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

示例1: setUp

 protected function setUp()
 {
     AnnotationRegistry::registerLoader('class_exists');
     $conn = DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'memory' => true));
     $this->em = $this->_getTestEntityManager($conn);
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Bazinga\\Bundle\\GeocoderBundle\\Mapping\\Annotations');
     $reader->addNamespace('Doctrine\\ORM\\Mapping');
     $driver = new AnnotationDriver($reader);
     $geocoder = new GoogleMaps(new CurlHttpAdapter());
     $this->listener = new GeocoderListener($geocoder, $driver);
     $this->em->getEventManager()->addEventSubscriber($this->listener);
     $sm = new SchemaTool($this->em);
     $sm->createSchema(array($this->em->getClassMetadata('Bazinga\\Bundle\\GeocoderBundle\\Tests\\Doctrine\\ORM\\Dummy')));
 }
开发者ID:norkunas,项目名称:BazingaGeocoderBundle,代码行数:15,代码来源:GeocoderListenerTest.php

示例2: __construct

 /**
  * Constructs a new dispatcher instance
  *
  * @param EntityManager $em
  * @param array $hints
  */
 public function __construct(EntityManager $em, array $hints = array())
 {
     $this->entityManager = $em;
     $this->metadataFactory = $em->getMetadataFactory();
     $this->eventManager = $this->entityManager->getEventManager();
     $this->hints = $hints;
 }
开发者ID:norzechowicz,项目名称:doctrine-extensions,代码行数:13,代码来源:PostHydrateEventDispatcher.php

示例3: initialize

 /**
  * {@inheritDoc}.
  */
 protected function initialize()
 {
     $this->driver = $this->em->getConfiguration()->getMetadataDriverImpl();
     $this->targetPlatform = $this->em->getConnection()->getDatabasePlatform();
     $this->evm = $this->em->getEventManager();
     $this->initialized = true;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:10,代码来源:ClassMetadataFactory.php

示例4: __construct

 /**
  *
  * @param Environment $environment
  * @param EventManager $eventManager
  * @param string $driver
  * @param string $username
  * @param string $password
  * @param string $dbname
  * @param string $host
  * @param int $port
  */
 public function __construct(Environment $environment, EventManager $eventManager, $driver, $username, $password, $dbname, $host, $port)
 {
     $paths = array();
     $eventHandler = new EventHandler($eventManager);
     $dbParams = array('driver' => $driver, 'user' => $username, 'password' => $password, 'dbname' => $dbname, 'host' => $host, 'charset' => 'utf8');
     $config = Setup::createAnnotationMetadataConfiguration($paths, $environment->isDebug(), $environment->getCachePath());
     $this->entityManager = EntityManager::create($dbParams, $config);
     $this->entityManager->getEventManager()->addEventListener(array('onFlush'), $eventHandler);
     $this->entityManager->getEventManager()->addEventListener(array('postFlush'), $eventHandler);
 }
开发者ID:itephp,项目名称:doctrine-bridge,代码行数:21,代码来源:DoctrineService.php

示例5: setUp

 public function setUp()
 {
     $this->listener = new AttachEntityListenersListener();
     $driver = $this->createAnnotationDriver();
     $this->em = $this->_getTestEntityManager();
     $evm = $this->em->getEventManager();
     $this->factory = new ClassMetadataFactory();
     $evm->addEventListener(Events::loadClassMetadata, $this->listener);
     $this->em->getConfiguration()->setMetadataDriverImpl($driver);
     $this->factory->setEntityManager($this->em);
 }
开发者ID:selimcr,项目名称:servigases,代码行数:11,代码来源:AttachEntityListenersListenerTest.php

示例6: initializeEntityManager

 private function initializeEntityManager()
 {
     if ($this->configuration->get('cache')) {
         $memcached = $this->container->get('memcached');
         $cache = new MemcachedCache();
         $cache->setMemcached($memcached);
     } else {
         $cache = null;
     }
     $config = Setup::createAnnotationMetadataConfiguration([ROOT_DIR . "/src"], true, ROOT_DIR . '/cache/doctrine/proxy', $cache);
     $connection = ['driver' => $this->configuration->get('driver'), 'user' => $this->configuration->get('user'), 'password' => $this->configuration->get('password'), 'dbname' => $this->configuration->get('dbname'), 'host' => $this->configuration->get('host')];
     $this->entityManager = EntityManager::create($connection, $config);
     $eventManager = $this->entityManager->getEventManager();
     $eventManager->addEventSubscriber(new DoctrineSubscriber());
 }
开发者ID:inisire,项目名称:framework,代码行数:15,代码来源:Doctrine.php

示例7: getUpdateQueries

 /**
  * Get update queries.
  *
  * @return string[]
  */
 protected function getUpdateQueries()
 {
     $schema = new SchemaTool($this->em);
     $metadatas = $this->em->getMetadataFactory()->getAllMetadata();
     // Insure the name of altered tables are quoted according to the platform
     $this->em->getEventManager()->addEventListener(Events::onSchemaAlterTable, $this);
     $sqls = $schema->getUpdateSchemaSql($metadatas, true);
     return $sqls;
 }
开发者ID:mickaelsteinberg,项目名称:BackBee,代码行数:14,代码来源:ApplicationUpdateCommand.php

示例8: disableLoggableExtension

 protected function disableLoggableExtension()
 {
     $instance = null;
     foreach ($this->em->getEventManager()->getListeners() as $event => $listeners) {
         foreach ($listeners as $hash => $listener) {
             if ($listener instanceof LoggableListener) {
                 $instance = $listener;
                 break 2;
             }
         }
     }
     if ($instance) {
         $evm = $this->em->getEventManager();
         $evm->removeEventListener(['onFlush'], $instance);
         $evm->removeEventListener(['postPersist'], $instance);
         $evm->removeEventListener(['loadClassMetadata'], $instance);
     }
 }
开发者ID:okulbilisim,项目名称:ojs-tools-bundle,代码行数:18,代码来源:ImportCommand.php

示例9: setUp

 public function setUp()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setProxyDir(__DIR__ . '/Proxy');
     $config->setProxyNamespace('DoctrineExtensions\\Taggable\\Proxies');
     $driverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $driverImpl->addDriver(new \Doctrine\ORM\Mapping\Driver\XmlDriver(__DIR__ . '/../../../../metadata'), 'DoctrineExtensions\\Taggable\\Entity');
     $driverImpl->addDriver($config->newDefaultAnnotationDriver(), 'Tests\\DoctrineExtensions\\Taggable\\Fixtures');
     $config->setMetadataDriverImpl($driverImpl);
     $this->em = \Doctrine\ORM\EntityManager::create(array('driver' => 'pdo_sqlite', 'memory' => true), $config);
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $schemaTool->dropSchema(array());
     $schemaTool->createSchema(array($this->em->getClassMetadata('DoctrineExtensions\\Taggable\\Entity\\Tag'), $this->em->getClassMetadata('DoctrineExtensions\\Taggable\\Entity\\Tagging'), $this->em->getClassMetadata('Tests\\DoctrineExtensions\\Taggable\\Fixtures\\Article')));
     $this->manager = new TagManager($this->em);
     $this->em->getEventManager()->addEventSubscriber(new TagListener($this->manager));
 }
开发者ID:olivier1980,项目名称:DoctrineExtensions-Taggable,代码行数:18,代码来源:TagRepositoryTest.php

示例10: setUp

 public function setUp()
 {
     $this->checkEnviroment();
     $this->manager = DoctrineTestHelper::createTestEntityManager();
     $this->manager->getEventManager()->addEventSubscriber(new TreeListener());
     $this->managerRegistry = $this->createRegistryMock('default', $this->manager);
     $this->formFactory = $this->createFormFactoryBuilder()->getFormFactory();
     $schemaTool = new SchemaTool($this->manager);
     $classes = array($this->manager->getClassMetadata(self::POST_CLASS), $this->manager->getClassMetadata(self::CATEGORY_CLASS), $this->manager->getClassMetadata(self::SECTION_CLASS));
     try {
         $schemaTool->dropSchema($classes);
     } catch (\Exception $e) {
     }
     try {
         $schemaTool->createSchema($classes);
     } catch (\Exception $e) {
     }
 }
开发者ID:yavin,项目名称:symfony-form-tree,代码行数:18,代码来源:TestBase.php

示例11: __construct

 public function __construct(EntityManager $enm, Writer $logger)
 {
     $this->evm = $enm->getEventManager();
     //Unused, for now
     $this->enm = $enm;
     $this->logger = $logger;
     $this->connection = $enm->getConnection();
     $enm->getConnection()->getConfiguration()->setSQLLogger($this);
 }
开发者ID:iamsamitdev,项目名称:modalapp,代码行数:9,代码来源:DoctrineDataSource.php

示例12: iterate

 /**
  * Initiates a row-by-row hydration.
  *
  * @param object $stmt
  * @param object $resultSetMapping
  * @param array  $hints
  *
  * @return IterableResult
  */
 public function iterate($stmt, $resultSetMapping, array $hints = array())
 {
     $this->_stmt = $stmt;
     $this->_rsm = $resultSetMapping;
     $this->_hints = $hints;
     $evm = $this->_em->getEventManager();
     $evm->addEventListener(array(Events::onClear), $this);
     $this->prepare();
     return new IterableResult($this);
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:19,代码来源:AbstractHydrator.php

示例13: let

 function let(UserContext $userContext, EntityManager $em, ClassMetadata $classMetadata, EventManager $eventManager, TreeListener $treeListener, Nested $strategy)
 {
     $classMetadata->name = 'category';
     $userContext->getCurrentLocaleCode()->willReturn('en_US');
     $em->getEventManager()->willReturn($eventManager);
     $eventManager->getListeners()->willReturn([[$treeListener]]);
     $treeListener->getStrategy(Argument::cetera())->willReturn($strategy);
     $treeListener->getConfiguration(Argument::cetera())->willReturn(['parent' => 'parent', 'left' => 'left']);
     $this->beConstructedWith($userContext, $em, $classMetadata);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:10,代码来源:CategoryRepositorySpec.php

示例14: carregar

 public function carregar()
 {
     $dados = \controlador\Facil::$dadosIni['doctrine'];
     $this->obterLoaders($dados);
     $this->obterConfiguracao($dados);
     $this->obterConexao();
     // Create EntityManager
     $this->em = EntityManager::create($this->connection, $this->config);
     if (\controlador\Facil::$dadosIni['l10n']['charset'] == 'UTF-8') {
         $this->em->getEventManager()->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit('utf8', 'utf8_unicode_ci'));
     }
 }
开发者ID:jjaferson,项目名称:ourives,代码行数:12,代码来源:DoctrinePlugin.php

示例15: setUpEntityManager

 public function setUpEntityManager(EntityManager $entityManager, callable $aclLocator)
 {
     if ($this->securityIdentityClass === null) {
         throw new \RuntimeException('The security identity class must be configured: call ->setSecurityIdentityClass("...")');
     }
     $evm = $entityManager->getEventManager();
     // Configure which entity implements the SecurityIdentityInterface
     $rtel = new ResolveTargetEntityListener();
     $rtel->addResolveTargetEntity('MyCLabs\\ACL\\Model\\SecurityIdentityInterface', $this->securityIdentityClass, []);
     $evm->addEventListener(Events::loadClassMetadata, $rtel);
     // Register the metadata loader
     $evm->addEventListener(Events::loadClassMetadata, $this->metadataLoader);
     // Register the listener that looks for new resources
     $evm->addEventSubscriber(new EntityResourcesListener($aclLocator));
 }
开发者ID:gbelmm,项目名称:ACL,代码行数:15,代码来源:ACLSetup.php


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