當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityManagerInterface::getEventManager方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\EntityManagerInterface::getEventManager方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityManagerInterface::getEventManager方法的具體用法?PHP EntityManagerInterface::getEventManager怎麽用?PHP EntityManagerInterface::getEventManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\EntityManagerInterface的用法示例。


在下文中一共展示了EntityManagerInterface::getEventManager方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setReferenceRepository

 /** @inheritDoc */
 public function setReferenceRepository(ReferenceRepository $referenceRepository)
 {
     $this->em->getEventManager()->removeEventListener($this->listener->getSubscribedEvents(), $this->listener);
     $this->referenceRepository = $referenceRepository;
     $this->listener = new ORMReferenceListener($this->referenceRepository);
     $this->em->getEventManager()->addEventSubscriber($this->listener);
 }
開發者ID:Dren-x,項目名稱:mobitnew,代碼行數:8,代碼來源:ORMExecutor.php

示例2: boot

 /**
  * Boot the extensions
  */
 public function boot()
 {
     foreach ($this->registry->getManagers() as $em) {
         $this->em = $em;
         $this->evm = $this->em->getEventManager();
         $this->metadata = $this->em->getConfiguration();
         $this->reader = $this->driverChain->getReader();
         foreach ($this->extensions as $extension) {
             $this->bootExtension($extension);
         }
     }
 }
開發者ID:vyolla,項目名稱:orm,代碼行數:15,代碼來源:ExtensionManager.php

示例3: boot

 /**
  * Boot the extensions
  */
 public function boot()
 {
     foreach ($this->registry->getManagers() as $em) {
         $this->em = $em;
         $this->evm = $this->em->getEventManager();
         $this->metadata = $this->em->getConfiguration();
         $this->reader = $this->driverChain->getReader();
         $hash = spl_object_hash($em);
         if (!isset($this->subscribedExtensions[$hash])) {
             $this->subscribedExtensions[$hash] = [];
         }
         foreach ($this->extensions as $extension) {
             $this->bootExtension($extension);
         }
     }
 }
開發者ID:jee7,項目名稱:orm,代碼行數:19,代碼來源:ExtensionManager.php

示例4: boot

 /**
  * Boot the extensions
  */
 public function boot()
 {
     foreach ($this->registry->getManagers() as $em) {
         $this->em = $em;
         $this->chain = new MappingDriverChain();
         $this->evm = $this->em->getEventManager();
         $this->metadata = $this->em->getConfiguration();
         $this->reader = method_exists($this->metadata->getMetadataDriverImpl(), 'getReader') ? $this->metadata->getMetadataDriverImpl()->getReader() : false;
         if ($this->gedmo['enabled']) {
             $this->bootGedmoExtensions($this->gedmo['namespace'], $this->gedmo['all']);
         }
         foreach ($this->extensions as $extenion) {
             $this->bootExtension($extenion);
         }
     }
 }
開發者ID:rosstuck,項目名稱:Laravel-Doctrine,代碼行數:19,代碼來源:ExtensionManager.php

示例5: 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:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:19,代碼來源:AbstractHydrator.php

示例6: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->connection = new MysqlPersistentConnection();
     $params = $this->connection->getConnectionParams();
     $config = Setup::createAnnotationMetadataConfiguration([__DIR__ . '/Entity'], true, null, null, false);
     $this->em = EntityManager::create($params, $config);
     $event_manager = $this->em->getEventManager();
     // create tables in the database
     $metadata = $this->em->getMetadataFactory()->getAllMetadata();
     $schema_tool = new SchemaTool($this->em);
     $schema_tool->createSchema($metadata);
     // default doctrine annotation reader
     $annotation_reader = new AnnotationReader();
     // setup required providers
     $mutation_metadata_provider = new EntityMutationMetadataProvider($annotation_reader);
     $annotation_metadata_provider = new EntityAnnotationMetadataProvider($annotation_reader);
     // pre flush event listener that uses the @Tracked annotation
     $entity_changed_listener = new EntityChangedListener($annotation_metadata_provider, $mutation_metadata_provider);
     $event_manager->addEventListener('preFlush', $entity_changed_listener);
     $event_manager->addEventListener('prePersist', $entity_changed_listener);
     $event_manager->addEventListener('entityChanged', $this);
     $this->events = [];
 }
開發者ID:hostnet,項目名稱:entity-tracker-component,代碼行數:26,代碼來源:EventListenerTest.php

示例7: disableRevisionListener

 /**
  * Removes the RevisionListener from the EventManager
  */
 public function disableRevisionListener()
 {
     foreach ($this->em->getEventManager()->getListeners() as $event => $listeners) {
         foreach ($listeners as $hash => $listener) {
             if ($listener instanceof RevisionListener) {
                 $this->revisionListener = $listener;
                 break 2;
             }
         }
     }
     if ($this->revisionListener) {
         $this->revisionListener->setActive(false);
     }
 }
開發者ID:Opifer,項目名稱:Cms,代碼行數:17,代碼來源:BlockManager.php

示例8: killRevisionListener

 /**
  * Removes the RevisionListener from the EventManager
  */
 public function killRevisionListener()
 {
     $listenerInst = false;
     foreach ($this->em->getEventManager()->getListeners() as $event => $listeners) {
         foreach ($listeners as $hash => $listener) {
             if ($listener instanceof RevisionListener) {
                 $listenerInst = $listener;
                 break 2;
             }
         }
     }
     if ($listenerInst) {
         $this->em->getEventManager()->removeEventListener(array(Events::onFlush, Events::postPersist, Events::postUpdate, Events::postFlush, SoftDeleteableListener::PRE_SOFT_DELETE, SoftDeleteableListener::POST_SOFT_DELETE), $listenerInst);
     }
 }
開發者ID:dylanschoenmakers,項目名稱:Cms,代碼行數:18,代碼來源:BlockManager.php

示例9: __construct

 /**
  * Initializes a new UnitOfWork instance, bound to the given EntityManager.
  *
  * @param EntityManagerInterface $em
  */
 public function __construct(EntityManagerInterface $em)
 {
     $this->em = $em;
     $this->evm = $em->getEventManager();
     $this->listenersInvoker = new ListenersInvoker($em);
     $this->hasCache = $em->getConfiguration()->isSecondLevelCacheEnabled();
     $this->identifierFlattener = new IdentifierFlattener($this, $em->getMetadataFactory());
     $this->hydrationCompleteHandler = new HydrationCompleteHandler($this->listenersInvoker, $em);
     $this->reflectionPropertiesGetter = new ReflectionPropertiesGetter(new RuntimeReflectionService());
 }
開發者ID:SylvainSimon,項目名稱:Metinify,代碼行數:15,代碼來源:UnitOfWork.php

示例10: initialize

 /**
  * {@inheritDoc}
  */
 protected function initialize()
 {
     $this->driver = $this->em->getConfiguration()->getMetadataDriverImpl();
     $this->evm = $this->em->getEventManager();
     $this->initialized = true;
 }
開發者ID:StoshSeb,項目名稱:doctrine2,代碼行數:9,代碼來源:ClassMetadataFactory.php

示例11: getSchemaFromMetadata

 /**
  * Creates a Schema instance from a given set of metadata classes.
  *
  * @param array $classes
  *
  * @return Schema
  *
  * @throws \Doctrine\ORM\ORMException
  */
 public function getSchemaFromMetadata(array $classes)
 {
     // Reminder for processed classes, used for hierarchies
     $processedClasses = array();
     $eventManager = $this->em->getEventManager();
     $schemaManager = $this->em->getConnection()->getSchemaManager();
     $metadataSchemaConfig = $schemaManager->createSchemaConfig();
     $metadataSchemaConfig->setExplicitForeignKeyIndexes(false);
     $schema = new Schema(array(), array(), $metadataSchemaConfig);
     $addedFks = array();
     $blacklistedFks = array();
     foreach ($classes as $class) {
         /** @var \Doctrine\ORM\Mapping\ClassMetadata $class */
         if ($this->processingNotRequired($class, $processedClasses)) {
             continue;
         }
         $table = $schema->createTable($this->quoteStrategy->getTableName($class, $this->platform));
         if ($class->isInheritanceTypeSingleTable()) {
             $this->gatherColumns($class, $table);
             $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks);
             // Add the discriminator column
             $this->addDiscriminatorColumnDefinition($class, $table);
             // Aggregate all the information from all classes in the hierarchy
             foreach ($class->parentClasses as $parentClassName) {
                 // Parent class information is already contained in this class
                 $processedClasses[$parentClassName] = true;
             }
             foreach ($class->subClasses as $subClassName) {
                 $subClass = $this->em->getClassMetadata($subClassName);
                 $this->gatherColumns($subClass, $table);
                 $this->gatherRelationsSql($subClass, $table, $schema, $addedFks, $blacklistedFks);
                 $processedClasses[$subClassName] = true;
             }
         } elseif ($class->isInheritanceTypeJoined()) {
             // Add all non-inherited fields as columns
             $pkColumns = array();
             foreach ($class->fieldMappings as $fieldName => $mapping) {
                 if (!isset($mapping['inherited'])) {
                     $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform);
                     $this->gatherColumn($class, $mapping, $table);
                     if ($class->isIdentifier($fieldName)) {
                         $pkColumns[] = $columnName;
                     }
                 }
             }
             $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks);
             // Add the discriminator column only to the root table
             if ($class->name == $class->rootEntityName) {
                 $this->addDiscriminatorColumnDefinition($class, $table);
             } else {
                 // Add an ID FK column to child tables
                 $inheritedKeyColumns = array();
                 foreach ($class->identifier as $identifierField) {
                     $idMapping = $class->fieldMappings[$identifierField];
                     if (isset($idMapping['inherited'])) {
                         $this->gatherColumn($class, $idMapping, $table);
                         $columnName = $this->quoteStrategy->getColumnName($identifierField, $class, $this->platform);
                         // TODO: This seems rather hackish, can we optimize it?
                         $table->getColumn($columnName)->setAutoincrement(false);
                         $pkColumns[] = $columnName;
                         $inheritedKeyColumns[] = $columnName;
                     }
                 }
                 if (!empty($inheritedKeyColumns)) {
                     // Add a FK constraint on the ID column
                     $table->addForeignKeyConstraint($this->quoteStrategy->getTableName($this->em->getClassMetadata($class->rootEntityName), $this->platform), $inheritedKeyColumns, $inheritedKeyColumns, array('onDelete' => 'CASCADE'));
                 }
             }
             $table->setPrimaryKey($pkColumns);
         } elseif ($class->isInheritanceTypeTablePerClass()) {
             throw ORMException::notSupported();
         } else {
             $this->gatherColumns($class, $table);
             $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks);
         }
         $pkColumns = array();
         foreach ($class->identifier as $identifierField) {
             if (isset($class->fieldMappings[$identifierField])) {
                 $pkColumns[] = $this->quoteStrategy->getColumnName($identifierField, $class, $this->platform);
             } elseif (isset($class->associationMappings[$identifierField])) {
                 /* @var $assoc \Doctrine\ORM\Mapping\OneToOne */
                 $assoc = $class->associationMappings[$identifierField];
                 foreach ($assoc['joinColumns'] as $joinColumn) {
                     $pkColumns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
                 }
             }
         }
         if (!$table->hasIndex('primary')) {
             $table->setPrimaryKey($pkColumns);
         }
         if (isset($class->table['indexes'])) {
//.........這裏部分代碼省略.........
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:101,代碼來源:SchemaTool.php

示例12: registerSubscribers

 /**
  * @param array                  $settings
  * @param EntityManagerInterface $manager
  */
 protected function registerSubscribers(array $settings = [], EntityManagerInterface $manager)
 {
     if (isset($settings['events']['subscribers'])) {
         foreach ($settings['events']['subscribers'] as $subscriber) {
             try {
                 $resolvedSubscriber = $this->container->make($subscriber);
             } catch (ReflectionException $e) {
                 throw new InvalidArgumentException("Listener {$subscriber} could not be resolved: {$e->getMessage()}");
             }
             $manager->getEventManager()->addEventSubscriber($resolvedSubscriber);
         }
     }
 }
開發者ID:shuaijinchao,項目名稱:laravel-doctrine,代碼行數:17,代碼來源:EntityManagerFactory.php

示例13: __construct

 /**
  * Initializes a new ListenersInvoker instance.
  *
  * @param EntityManagerInterface $em
  */
 public function __construct(EntityManagerInterface $em)
 {
     $this->eventManager = $em->getEventManager();
     $this->resolver = $em->getConfiguration()->getEntityListenerResolver();
 }
開發者ID:Dren-x,項目名稱:mobitnew,代碼行數:10,代碼來源:ListenersInvoker.php

示例14: getEventManager

 /**
  * {@inheritdoc}
  */
 public function getEventManager()
 {
     return $this->wrapped->getEventManager();
 }
開發者ID:Dren-x,項目名稱:mobitnew,代碼行數:7,代碼來源:EntityManagerDecorator.php

示例15: registerSubscribers

 /**
  * @param array                  $settings
  * @param EntityManagerInterface $manager
  */
 protected function registerSubscribers($settings = [], EntityManagerInterface $manager)
 {
     if (isset($settings['events']['subscribers'])) {
         foreach ($settings['events']['subscribers'] as $subscriber) {
             if (!class_exists($subscriber, false)) {
                 throw new InvalidArgumentException("Subscriber {$subscriber} does not exist");
             }
             $manager->getEventManager()->addEventSubscriber(new $subscriber());
         }
     }
 }
開發者ID:ryan-senn,項目名稱:orm,代碼行數:15,代碼來源:EntityManagerFactory.php


注:本文中的Doctrine\ORM\EntityManagerInterface::getEventManager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。