/** * 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; }
/** * 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; }