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


PHP EntityManagerInterface::loadEntityByConfigTarget方法代码示例

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


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

示例1: calculateDependencies

 /**
  * {@inheritdoc}
  */
 public function calculateDependencies()
 {
     $dependencies = parent::calculateDependencies();
     // Ensure that we don't add dependencies for placeholders.
     // @todo Use a method to check for tokens in
     //   https://www.drupal.org/node/2396607.
     if (strpos($this->options['target'], '{{') === FALSE) {
         if ($entity = $this->entityManager->loadEntityByConfigTarget($this->entityType, $this->options['target'])) {
             $dependencies[$this->entityManager->getDefinition($this->entityType)->getConfigDependencyKey()][] = $entity->getConfigDependencyName();
         }
     }
     return $dependencies;
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:16,代码来源:Entity.php

示例2: callOnDependencyRemoval

 /**
  * Calls an entity's onDependencyRemoval() method.
  *
  * A helper method to call onDependencyRemoval() with the correct list of
  * affected entities. This list should only contain dependencies on the
  * entity. Configuration and content entity dependencies will be converted
  * into entity objects.
  *
  * @param \Drupal\Core\Config\Entity\ConfigEntityInterface $entity
  *   The entity to call onDependencyRemoval() on.
  * @param \Drupal\Core\Config\Entity\ConfigEntityInterface[] $dependent_entities
  *   The list of dependent configuration entities.
  * @param string $type
  *   The type of dependency being checked. Either 'module', 'theme', 'config'
  *   or 'content'.
  * @param array $names
  *   The specific names to check. If $type equals 'module' or 'theme' then it
  *   should be a list of module names or theme names. In the case of 'config'
  *   or 'content' it should be a list of configuration dependency names.
  *
  * @return bool
  *   TRUE if the entity has changed as a result of calling the
  *   onDependencyRemoval() method, FALSE if not.
  */
 protected function callOnDependencyRemoval(ConfigEntityInterface $entity, array $dependent_entities, $type, array $names)
 {
     $entity_dependencies = $entity->getDependencies();
     if (empty($entity_dependencies)) {
         // No dependent entities nothing to do.
         return FALSE;
     }
     $affected_dependencies = array('config' => array(), 'content' => array(), 'module' => array(), 'theme' => array());
     // Work out if any of the entity's dependencies are going to be affected.
     if (isset($entity_dependencies[$type])) {
         // Work out which dependencies the entity has in common with the provided
         // $type and $names.
         $affected_dependencies[$type] = array_intersect($entity_dependencies[$type], $names);
         // If the dependencies are entities we need to convert them into objects.
         if ($type == 'config' || $type == 'content') {
             $affected_dependencies[$type] = array_map(function ($name) use($type) {
                 if ($type == 'config') {
                     return $this->loadConfigEntityByName($name);
                 } else {
                     // Ignore the bundle.
                     list($entity_type_id, , $uuid) = explode(':', $name);
                     return $this->entityManager->loadEntityByConfigTarget($entity_type_id, $uuid);
                 }
             }, $affected_dependencies[$type]);
         }
     }
     // Merge any other configuration entities into the list of affected
     // dependencies if necessary.
     if (isset($entity_dependencies['config'])) {
         foreach ($dependent_entities as $dependent_entity) {
             if (in_array($dependent_entity->getConfigDependencyName(), $entity_dependencies['config'])) {
                 $affected_dependencies['config'][] = $dependent_entity;
             }
         }
     }
     // Key the entity arrays by config dependency name to make searching easy.
     foreach (['config', 'content'] as $dependency_type) {
         $affected_dependencies[$dependency_type] = array_combine(array_map(function ($entity) {
             return $entity->getConfigDependencyName();
         }, $affected_dependencies[$dependency_type]), $affected_dependencies[$dependency_type]);
     }
     // Inform the entity.
     return $entity->onDependencyRemoval($affected_dependencies);
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:68,代码来源:ConfigManager.php

示例3: loadEntityByConfigTarget

 /**
  * {@inheritdoc}
  */
 public function loadEntityByConfigTarget($entity_type_id, $target)
 {
     return $this->entityManager->loadEntityByConfigTarget($entity_type_id, $target);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:7,代码来源:EntityManagerWrapper.php


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