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


PHP EntityTypeManagerInterface::alter方法代碼示例

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


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

示例1: getGraphDefinitions

 /**
  * Get the defined graph types for this entity type.
  *
  * A default graph is provided here already because there has to exist at
  * least one available graph for the entities to be saved in.
  *
  * @param string $entity_type_id
  *    The entity type machine name.
  *
  * @return array
  *    A structured array of graph definitions containing a title and a
  *    description. The array keys are the machine names of the graphs.
  */
 public function getGraphDefinitions($entity_type_id)
 {
     $graphs_definition = [];
     $graphs_definition['default'] = ['title' => $this->t('Default'), 'description' => $this->t('The default graph used to store entities of this type.')];
     // @todo Consider turning this into an event. Advantages?
     $this->moduleHandler->alter('rdf_graph_definition', $entity_type_id, $graphs_definition);
     return $graphs_definition;
 }
開發者ID:ec-europa,項目名稱:joinup-dev,代碼行數:21,代碼來源:RdfGraphHandler.php

示例2: getRdfBundleMappedUri

 /**
  * Returns all bundle key mappings of the passed rdf entity type.
  *
  * These mappings are the actual type of the bundle represented by an rdf
  * URI. This is not the predicate but the object.
  *
  * @param string $entity_type_bundle_key
  *    The machine name of the entity type.
  * @param string $bundle
  *    Optionally filter the mappings by bundle.
  *
  * @return array
  *    A list of bundle key mappings from all bundles of the passed entity
  *    type. The returned array is indexed by the bundle key.
  *
  * @throws \Exception
  *    Thrown when the rdf entity bundle has no mapped type uri.
  */
 public function getRdfBundleMappedUri($entity_type_bundle_key, $bundle = NULL)
 {
     $bundle_rdf_bundle_mapping = [];
     $storage = $this->entityManager->getStorage($entity_type_bundle_key);
     $bundle_entities = empty($bundle) ? $storage->loadMultiple() : [$storage->load($bundle)];
     foreach ($bundle_entities as $bundle_entity) {
         // The id of the entity type is 'rdf_type' but the key ('id') is the
         // bundle key.
         $bundle_type = $bundle_entity->getEntityType()->getKey('id');
         $settings = $bundle_entity->getThirdPartySetting('rdf_entity', 'mapping_' . $bundle_type, FALSE);
         if (!is_array($settings)) {
             throw new \Exception('No rdf:type mapping set for bundle ' . $bundle_entity->label());
         }
         $type = array_pop($settings);
         $bundle_rdf_bundle_mapping[$bundle_entity->id()] = $type;
     }
     // Allow modules to interact and tamper with the passed list.
     $this->moduleHandler->alter('bundle_mapping', $bundle_rdf_bundle_mapping);
     return $bundle_rdf_bundle_mapping;
 }
開發者ID:ec-europa,項目名稱:joinup-dev,代碼行數:38,代碼來源:RdfMappingHandler.php


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