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


PHP ConfigEntityInterface::getDependencies方法代码示例

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


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

示例1: 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


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