當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。