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


PHP EventManager::hasListeners方法代码示例

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


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

示例1: getSubscribedSystems

 /**
  * Get the subscribed event systems
  *
  * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata The entity metadata.
  * @param string $eventName                             The entity lifecycle event.
  *
  * @return integer Bitmask of subscribed event systems.
  */
 public function getSubscribedSystems(ClassMetadata $metadata, $eventName)
 {
     $invoke = self::INVOKE_NONE;
     if (isset($metadata->lifecycleCallbacks[$eventName])) {
         $invoke |= self::INVOKE_CALLBACKS;
     }
     if (isset($metadata->entityListeners[$eventName])) {
         $invoke |= self::INVOKE_LISTENERS;
     }
     if ($this->eventManager->hasListeners($eventName)) {
         $invoke |= self::INVOKE_MANAGER;
     }
     return $invoke;
 }
开发者ID:Dren-x,项目名称:mobitnew,代码行数:22,代码来源:ListenersInvoker.php

示例2: dispatchPostHydrate

 /**
  * Dispatches postHydrate event for specified entity or enqueues it for later dispatching
  *
  * @param object $entity
  */
 public function dispatchPostHydrate($entity)
 {
     $className = get_class($entity);
     if (!$this->eventManager->hasListeners(Events::postHydrate)) {
         return;
     }
     if (isset($this->hints[Query::HINT_INTERNAL_ITERATION])) {
         $this->eventManager->dispatchEvent(Events::postHydrate, new LifecycleEventArgs($entity, $this->entityManager));
     } else {
         if (!isset($this->entities[$className])) {
             $this->entities[$className] = array();
         }
         $this->entities[$className][] = $entity;
     }
 }
开发者ID:norzechowicz,项目名称:doctrine-extensions,代码行数:20,代码来源:PostHydrateEventDispatcher.php

示例3: createDatabase

 /**
  * Creates a new database.
  *
  * @param string $name The database name
  *
  * @return Database
  *
  * @throws Exception If the database could not be created.
  */
 public function createDatabase($name)
 {
     if (preg_match('@[^a-z0-9\\_\\$\\(\\)+\\-]@', $name)) {
         throw new InvalidDatabasenameException(sprintf('The database name %s is invalid. The database name must match the following pattern (a-z0-9_$()+-)', $name));
     }
     if ($this->eventManager->hasListeners(Events::PRE_CREATE_DATABASE)) {
         // @codeCoverageIgnoreStart
         $this->eventManager->dispatchEvent(Events::PRE_CREATE_DATABASE, new EventArgs($this, $name));
         // @codeCoverageIgnoreEnd
     }
     $response = $this->client->request('PUT', sprintf('/%s', $name));
     if (412 === $response->getStatusCode()) {
         throw new Exception(sprintf('The database "%s" already exist', $name));
     }
     $json = (string) $response->getBody();
     $value = JSONEncoder::decode($json);
     if (isset($value['error'])) {
         throw new Exception(sprintf('[%s] Failed to create database "%s". (%s)', $value['error'], $name, $value['reason']));
     }
     $database = $this->wrapDatabase($name);
     if ($this->eventManager->hasListeners(Events::POST_CREATE_DATABASE)) {
         // @codeCoverageIgnoreStart
         $this->eventManager->dispatchEvent(Events::POST_CREATE_DATABASE, new EventArgs($database));
         // @codeCoverageIgnoreEnd
     }
     return $database;
 }
开发者ID:h4cc,项目名称:CouchDB,代码行数:36,代码来源:Connection.php

示例4: hydrateEntity

 /**
  * Construct an entity object
  *
  * @param ClassMetadata $class
  * @param object $document
  */
 public function hydrateEntity(ClassMetadata $class, $document)
 {
     // TODO: add support for different result set types from different clients
     // perhaps by wrapping documents in a layer of abstraction
     $data = $document->getData();
     $fields = array_merge($document->hasFields() ? $document->getFields() : array(), array('_version' => $document->getVersion()));
     foreach ($fields as $name => $value) {
         if (isset($class->parameters[$name])) {
             $data[$name] = $value;
         } else {
             foreach ($class->parameters as $param => $mapping) {
                 if ($mapping->name == $name) {
                     $data[$param] = $value;
                     break;
                 }
             }
         }
     }
     $data[$class->getIdentifier()] = $document->getId();
     if (method_exists($document, 'getScore')) {
         $data['score'] = $document->getScore();
     }
     $entity = $this->sm->getSerializer()->deserialize($class->className, json_encode($data));
     if ($this->evm->hasListeners(Events::postLoad)) {
         $this->evm->dispatchEvent(Events::postLoad, new Event\LifecycleEventArgs($entity, $this->sm));
     }
     return $entity;
 }
开发者ID:revinate,项目名称:search-bundle,代码行数:34,代码来源:UnitOfWork.php

示例5: executeRestores

 /**
  * Executes the queued restorations.
  */
 private function executeRestores()
 {
     $deletedFieldName = $this->configuration->getDeletedFieldName();
     $persisters = array();
     foreach ($this->restoreBy as $className => $criterias) {
         $persister = $this->getDocumentPersister($className);
         $persisters[$className] = $persister;
         foreach ($criterias as $criteria) {
             $persister->addRestoreBy($criteria);
         }
     }
     $documentRestores = array();
     foreach ($this->documentRestores as $document) {
         $className = get_class($document);
         $documentRestores[$className][] = $document;
         $persister = $this->getDocumentPersister($className);
         $persisters[$className] = $persister;
         $persister->addRestore($document);
     }
     foreach ($persisters as $className => $persister) {
         $persister->executeRestores();
         $class = $this->dm->getClassMetadata($className);
         if (isset($documentRestores[$className])) {
             $documents = $documentRestores[$className];
             foreach ($documents as $document) {
                 $class->setFieldValue($document, $deletedFieldName, null);
                 if ($this->eventManager->hasListeners(Events::postRestore)) {
                     $this->eventManager->dispatchEvent(Events::postRestore, new Event\LifecycleEventArgs($document, $this));
                 }
             }
         }
     }
 }
开发者ID:doctrine,项目名称:mongodb-odm-softdelete,代码行数:36,代码来源:SoftDeleteManager.php

示例6: doLoadMetadata

 /**
  * {@inheritDoc}
  */
 protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents)
 {
     /* @var $class \Doctrine\OXM\Mapping\ClassMetadata */
     /* @var $parent \Doctrine\OXM\Mapping\ClassMetadata */
     if ($parent) {
         $class->setIdGeneratorType($parent->generatorType);
         $this->addInheritedFields($class, $parent);
         $class->setXmlNamespaces($parent->xmlNamespaces);
         $class->setIdentifier($parent->identifier);
         $class->setLifecycleCallbacks($parent->lifecycleCallbacks);
         $class->setChangeTrackingPolicy($parent->changeTrackingPolicy);
         $class->parent = $parent->getName();
     }
     // Invoke driver
     try {
         $this->driver->loadMetadataForClass($class->getName(), $class);
     } catch (ReflectionException $e) {
         throw MappingException::reflectionFailure($class->getName(), $e);
     }
     $xmlNamespace = empty($class->xmlNamespaces) ? '' : $class->xmlNamespaces[0]['url'];
     foreach ($class->xmlNamespaces as $namespaceData) {
         if (empty($namespaceData['prefix'])) {
             $xmlNamespace = $namespaceData['url'];
         }
     }
     $xmlName = $class->getXmlName();
     // Ignore duplicate binding issues -- at least for now
     /*
     if ( $this->isEntity($class) && array_key_exists($xmlName, $this->xmlToClassMap) && array_key_exists($xmlNamespace, $this->xmlToClassMap[$xmlName])) {
     			if ($this->xmlToClassMap[$xmlName][$xmlNamespace] == $class->getName() || $this->xmlToClassMap[$xmlName][$xmlNamespace] == '\\' . $class->getName()) {
     				// Ignore
     	        } else {
     		throw MappingException::duplicateXmlNameBinding($class->getName(), $class->getXmlName());
     	        }
     }
     */
     // The previous test should be sufficent for us to just assume that the namespace/alternative is fine
     if (!empty($parent)) {
         $this->alternativeClassMap[$parent->getName()][$xmlNamespace] = $class->getName();
     }
     if (!$class->isMappedSuperclass) {
         $this->xmlToClassMap[$xmlName][$xmlNamespace] = $class->getName();
     }
     if ($parent && !$parent->isMappedSuperclass) {
         if ($parent->generatorType) {
             $class->setIdGeneratorType($parent->generatorType);
         }
         if ($parent->idGenerator) {
             $class->setIdGenerator($parent->idGenerator);
         }
     } else {
         $this->completeIdGeneratorMapping($class);
     }
     $class->setParentClasses($nonSuperclassParents);
     // Todo - ensure that root elements have an ID mapped
     if ($this->evm->hasListeners(Events::loadClassMetadata)) {
         $eventArgs = new LoadClassMetadataEventArgs($class, $this);
         $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
     }
 }
开发者ID:illuminadigital,项目名称:php-xml-marshalling,代码行数:63,代码来源:ClassMetadataFactory.php

示例7: hydrate

 /**
  * Hydrate array of MongoDB document data into the given document object.
  *
  * @param object $document  The document object to hydrate the data into.
  * @param array $data The array of document data.
  * @return array $values The array of hydrated values.
  */
 public function hydrate($document, $data)
 {
     $metadata = $this->dm->getClassMetadata(get_class($document));
     // Invoke preLoad lifecycle events and listeners
     if (isset($metadata->lifecycleCallbacks[Events::preLoad])) {
         $args = array(&$data);
         $metadata->invokeLifecycleCallbacks(Events::preLoad, $document, $args);
     }
     if ($this->evm->hasListeners(Events::preLoad)) {
         $this->evm->dispatchEvent(Events::preLoad, new PreLoadEventArgs($document, $this->dm, $data));
     }
     // Use the alsoLoadMethods on the document object to transform the data before hydration
     if (isset($metadata->alsoLoadMethods)) {
         foreach ($metadata->alsoLoadMethods as $fieldName => $method) {
             if (isset($data[$fieldName])) {
                 $document->{$method}($data[$fieldName]);
             }
         }
     }
     if ($this->hydratorFactory !== null) {
         $data = $this->hydratorFactory->getHydratorFor($metadata->name)->hydrate($document, $data);
     } else {
         $data = $this->doGenericHydration($metadata, $document, $data);
     }
     // Invoke the postLoad lifecycle callbacks and listeners
     if (isset($metadata->lifecycleCallbacks[Events::postLoad])) {
         $metadata->invokeLifecycleCallbacks(Events::postLoad, $document);
     }
     if ($this->evm->hasListeners(Events::postLoad)) {
         $this->evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($document, $this->dm));
     }
     return $data;
 }
开发者ID:hirocaster,项目名称:symfony-sandbox,代码行数:40,代码来源:Hydrator.php

示例8: getSubscribedSystems

 /**
  * Get the subscribed event systems
  *
  * @param ClassMetadata $metadata
  * @param string        $eventName The entity lifecycle event.
  *
  * @return integer                 Bitmask of subscribed event systems.
  */
 public function getSubscribedSystems(ClassMetadata $metadata, $eventName)
 {
     $invoke = self::INVOKE_NONE;
     if ($metadata && isset($metadata->lifecycleCallbacks[$eventName])) {
         $invoke |= self::INVOKE_CALLBACKS;
     }
     /*
      * Not implemented for phpcr-odm at the moment.
      *
     if (isset($metadata->documentListeners[$eventName])) {
         $invoke |= self::INVOKE_LISTENERS;
     }
     */
     if ($this->eventManager->hasListeners($eventName)) {
         $invoke |= self::INVOKE_MANAGER;
     }
     return $invoke;
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:26,代码来源:ListenersInvoker.php

示例9: doLoadMetadata

 /**
  * Actually load the metadata from the underlying metadata
  *
  * @param ClassMetadataInterface|ClassMetadata $class
  * @param ClassMetadataInterface|ClassMetadata $parent
  * @param bool $rootEntityFound
  * @param array $nonSuperclassParents
  */
 protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents)
 {
     //Manipulates $classMetadata;
     $this->driver->loadMetadataForClass($class->getName(), $class);
     if ($this->evm->hasListeners(Events::loadClassMetadata)) {
         $eventArgs = new LoadClassMetadataEventArgs($class, $this->sm);
         $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
     }
 }
开发者ID:revinate,项目名称:search,代码行数:17,代码来源:ClassMetadataFactory.php

示例10: save

 public function save(array &$a, array $options = array())
 {
     if ($this->eventManager->hasListeners(Events::preSave)) {
         $this->eventManager->dispatchEvent(Events::preSave, new EventArgs($this, $a));
     }
     $result = $this->doSave($a, $options);
     if ($this->eventManager->hasListeners(Events::postSave)) {
         $this->eventManager->dispatchEvent(Events::postSave, new EventArgs($this, $result));
     }
     return $result;
 }
开发者ID:frogriotcom,项目名称:brusite,代码行数:11,代码来源:Collection.php

示例11: doLoadMetadata

 /**
  * {@inheritdoc}
  */
 protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents)
 {
     if ($this->getDriver()) {
         $this->getDriver()->loadMetadataForClass($class->getName(), $class);
     }
     if ($this->evm->hasListeners(Event::loadClassMetadata)) {
         $eventArgs = new Event\LoadClassMetadataEventArgs($class, $this->objectAdapterManager);
         $this->evm->dispatchEvent(Event::loadClassMetadata, $eventArgs);
     }
     $this->validateRuntimeMetadata($class, $parent);
 }
开发者ID:joschi127,项目名称:DoctrineOrmOdmAdapter,代码行数:14,代码来源:ClassMetadataFactory.php

示例12: selectCollection

 /** @proxy */
 public function selectCollection($name)
 {
     if ($this->eventManager->hasListeners(Events::preSelectCollection)) {
         $this->eventManager->dispatchEvent(Events::preSelectCollection, new EventArgs($this, $name));
     }
     $collection = $this->doSelectCollection($name);
     if ($this->eventManager->hasListeners(Events::postSelectCollection)) {
         $this->eventManager->dispatchEvent(Events::postSelectCollection, new EventArgs($this, $collection));
     }
     return $collection;
 }
开发者ID:ud223,项目名称:yj,代码行数:12,代码来源:Database.php

示例13: getMetadataFactory

 /**
  * @param ObjectManager $om
  *
  * @return MetadataFactory
  */
 protected function getMetadataFactory(ObjectManager $om, EventManager $evm)
 {
     if ($this->metadataFactory === null) {
         $driverFactory = DriverFactory::instance();
         if ($evm->hasListeners(Events::REGISTER_DRIVER_METADATA)) {
             $eventArgs = new RegisterDriverMetadataEventArgs($driverFactory, $om);
             $evm->dispatchEvent(Events::REGISTER_DRIVER_METADATA, $eventArgs);
         }
         $this->metadataFactory = new MetadataFactory($driverFactory->driversFromManager($om));
     }
     return $this->metadataFactory;
 }
开发者ID:cubiche,项目名称:cubiche,代码行数:17,代码来源:MetadataEventListener.php

示例14: selectDatabase

 /** @proxy */
 public function selectDatabase($name)
 {
     if ($this->eventManager->hasListeners(Events::preSelectDatabase)) {
         $this->eventManager->dispatchEvent(Events::preSelectDatabase, new EventArgs($this, $name));
     }
     $this->initialize();
     $database = $this->wrapDatabase($name);
     if ($this->eventManager->hasListeners(Events::postSelectDatabase)) {
         $this->eventManager->dispatchEvent(Events::postSelectDatabase, new EventArgs($this, $database));
     }
     return $database;
 }
开发者ID:ud223,项目名称:yj,代码行数:13,代码来源:Connection.php

示例15: onSchemaAlterTable

 /**
  * @param TableDiff $diff
  * @param array $columnSql
  */
 protected function onSchemaAlterTable(TableDiff $diff, &$sql)
 {
     if (null === $this->_eventManager) {
         return false;
     }
     if (!$this->_eventManager->hasListeners(Events::onSchemaAlterTable)) {
         return false;
     }
     $eventArgs = new SchemaAlterTableEventArgs($diff, $this);
     $this->_eventManager->dispatchEvent(Events::onSchemaAlterTable, $eventArgs);
     $sql = array_merge($sql, $eventArgs->getSql());
     return $eventArgs->isDefaultPrevented();
 }
开发者ID:pollux1er,项目名称:dlawebdev2,代码行数:17,代码来源:AbstractPlatform.php


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