本文整理汇总了PHP中EntityManager::getEventManager方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::getEventManager方法的具体用法?PHP EntityManager::getEventManager怎么用?PHP EntityManager::getEventManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::getEventManager方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testconfiguration
public function testconfiguration()
{
$config = new Configuration();
$config->setCurrentUser($this->ZfcUserMock);
$prefix = "prefix";
$config->setTablePrefix($prefix);
$suffix = "suffix";
$config->setTableSuffix($suffix);
$fieldName = "fieldName";
$config->setRevisionFieldName($fieldName);
$revisionIdFieldType = "string";
$config->setRevisionIdFieldType($revisionIdFieldType);
$tableName = "tableName";
$config->setRevisionTableName($tableName);
$revisionTypeFieldName = "string";
$config->setRevisionTypeFieldName($revisionTypeFieldName);
$ipaddress = $config->getIpAddress();
$config->setAuditedEntityClasses(array('ZF2EntityAuditTest\\Entity\\Article', 'ZF2EntityAuditTest\\Entity\\Writer'));
$config->setNote("default note");
$this->auditManager = new Manager($config);
$this->auditManager->registerEvents($this->em->getEventManager());
/// creating the tables
$this->schemaTool = $this->getSchemaTool();
$this->schemaTool->createSchema(array($this->em->getClassMetadata('ZF2EntityAuditTest\\Entity\\Article'), $this->em->getClassMetadata('ZF2EntityAuditTest\\Entity\\Writer')));
$this->assertInstanceOf("ZfcUser\\Entity\\User", $this->ZfcUserMock);
$this->assertEquals($prefix, $config->getTablePrefix());
$this->assertEquals($suffix, $config->getTableSuffix());
$this->assertEquals($fieldName, $config->getRevisionFieldName());
$this->assertEquals($tableName, $config->getRevisionTableName());
$this->assertEquals($revisionIdFieldType, $config->getRevisionIdFieldType());
$this->assertEquals($revisionTypeFieldName, $config->getRevisionIdFieldType());
$this->assertEquals($ipaddress, "1.1.1.9");
}
示例2: testAssertTableColumnsAreNotAddedInManyToMany
/**
* @group DDC-2109
*/
public function testAssertTableColumnsAreNotAddedInManyToMany()
{
$evm = $this->em->getEventManager();
$this->listener->addResolveTargetEntity('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetInterface', 'Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity', array());
$this->listener->addResolveTargetEntity('Doctrine\\Tests\\ORM\\Tools\\TargetInterface', 'Doctrine\\Tests\\ORM\\Tools\\TargetEntity', array());
$evm->addEventListener(Events::loadClassMetadata, $this->listener);
$cm = $this->factory->getMetadataFor('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity');
$meta = $cm->associationMappings['manyToMany'];
$this->assertSame('Doctrine\\Tests\\ORM\\Tools\\TargetEntity', $meta['targetEntity']);
$this->assertEquals(array('resolvetargetentity_id', 'targetinterface_id'), $meta['joinTableColumns']);
}
示例3: testResolveTargetEntityListenerCanResolveTargetEntity
/**
* @group DDC-1544
*/
public function testResolveTargetEntityListenerCanResolveTargetEntity()
{
$evm = $this->em->getEventManager();
$this->listener->addResolveTargetEntity('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetInterface', 'Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity', array());
$this->listener->addResolveTargetEntity('Doctrine\\Tests\\ORM\\Tools\\TargetInterface', 'Doctrine\\Tests\\ORM\\Tools\\TargetEntity', array());
$evm->addEventListener(Events::loadClassMetadata, $this->listener);
$cm = $this->factory->getMetadataFor('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity');
$meta = $cm->associationMappings;
$this->assertSame('Doctrine\\Tests\\ORM\\Tools\\TargetEntity', $meta['manyToMany']['targetEntity']);
$this->assertSame('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity', $meta['manyToOne']['targetEntity']);
$this->assertSame('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity', $meta['oneToMany']['targetEntity']);
$this->assertSame('Doctrine\\Tests\\ORM\\Tools\\TargetEntity', $meta['oneToOne']['targetEntity']);
}
示例4: setUp
public function setUp()
{
$this->Bootstrap = new Bootstrap();
$this->em = $this->Bootstrap->getServiceManager()->get("doctrine.entitymanager.orm_default");
/// echo sql logger
//$this->em->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());;
/// let's create the default user
$this->ZfcUserMock = $this->createUser();
$auditConfig = new Configuration();
$auditConfig->setCurrentUser($this->ZfcUserMock);
$auditConfig->setAuditedEntityClasses(array('ZF2EntityAuditTest\\Entity\\Article', 'ZF2EntityAuditTest\\Entity\\Writer'));
$auditConfig->setNote("default note");
$this->auditManager = new Manager($auditConfig);
$this->auditManager->registerEvents($this->em->getEventManager());
/// creating the tables
$this->schemaTool = $this->getSchemaTool();
$this->schemaTool->createSchema(array($this->em->getClassMetadata('ZF2EntityAuditTest\\Entity\\Article'), $this->em->getClassMetadata('ZF2EntityAuditTest\\Entity\\Writer')));
}
示例5: killSoftDeletableListener
/**
* Removes the SoftDeleteableListener from the EventManager
*/
public function killSoftDeletableListener()
{
foreach ($this->em->getEventManager()->getListeners() as $event => $listeners) {
foreach ($listeners as $hash => $listener) {
if ($listener instanceof SoftDeleteableListener) {
$listenerInst = $listener;
break 2;
}
}
}
$this->em->getEventManager()->removeEventListener(array('onFlush'), $listenerInst);
}