本文整理汇总了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')));
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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);
}
}
示例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));
}
示例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) {
}
}
示例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);
}
示例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);
}
示例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);
}
示例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'));
}
}
示例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));
}