本文整理汇总了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;
}
示例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;
}