diff --git a/modules/schemadotorg_entity_reference_override/config/install/schemadotorg_entity_reference_override.settings.yml b/modules/schemadotorg_entity_reference_override/config/install/schemadotorg_entity_reference_override.settings.yml index 51fa99f88bff97390266b3aa5d5ccfb8b47813d4..8bbf78c85866ee3f0890022c08af39bf761705ec 100644 --- a/modules/schemadotorg_entity_reference_override/config/install/schemadotorg_entity_reference_override.settings.yml +++ b/modules/schemadotorg_entity_reference_override/config/install/schemadotorg_entity_reference_override.settings.yml @@ -1,6 +1,10 @@ schema_properties: actor: placeholder: 'Enter role' + performer: + placeholder: 'Enter role' + organizer: + placeholder: 'Enter role' member: placeholder: 'Enter role' employee: diff --git a/modules/schemadotorg_pathauto/README.md b/modules/schemadotorg_pathauto/README.md index 6efcd2aa094a1eefc95201ea4c41b27199a29686..fcbd221f8d68b5067fbdc8e9da56eab066862546 100644 --- a/modules/schemadotorg_pathauto/README.md +++ b/modules/schemadotorg_pathauto/README.md @@ -23,6 +23,8 @@ Features - Creates Pathauto patterns for Schema.org types. - Provides custom Schema.org type (and subtype) base path token. (i.e., \[node:schemadotorg:base-path\]) +- Provides a report displaying the pathauto patterns and base paths for + all Schema.org mappings. (/admin/reports/schemadotorg/docs/paths) Requirements diff --git a/modules/schemadotorg_pathauto/schemadotorg_pathauto.links.menu.yml b/modules/schemadotorg_pathauto/schemadotorg_pathauto.links.menu.yml new file mode 100644 index 0000000000000000000000000000000000000000..267f849daa92c9a9e70ac00f86677a2ea0a9a251 --- /dev/null +++ b/modules/schemadotorg_pathauto/schemadotorg_pathauto.links.menu.yml @@ -0,0 +1,6 @@ +schemadotorg_pathauto.report: + title: Paths + parent: schemadotorg_report + description: 'Overview of Schema.org paths.' + route_name: schemadotorg_pathauto.report + weight: 21 diff --git a/modules/schemadotorg_pathauto/schemadotorg_pathauto.links.task.yml b/modules/schemadotorg_pathauto/schemadotorg_pathauto.links.task.yml new file mode 100644 index 0000000000000000000000000000000000000000..aca762b8a461f31ad21d8a7b764f0d4e561284dd --- /dev/null +++ b/modules/schemadotorg_pathauto/schemadotorg_pathauto.links.task.yml @@ -0,0 +1,5 @@ +schemadotorg_pathauto.report: + title: Paths + route_name: schemadotorg_pathauto.report + base_route: schemadotorg_report + weight: 21 diff --git a/modules/schemadotorg_pathauto/schemadotorg_pathauto.module b/modules/schemadotorg_pathauto/schemadotorg_pathauto.module index cf9fc9c98ba172cc41d02532e5f5f6d4eb7a4ba3..f08d9d691e6e11b4af7be8abfd1d575c62eaa977 100644 --- a/modules/schemadotorg_pathauto/schemadotorg_pathauto.module +++ b/modules/schemadotorg_pathauto/schemadotorg_pathauto.module @@ -8,74 +8,27 @@ declare(strict_types=1); use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; -use Drupal\pathauto\Entity\PathautoPattern; use Drupal\schemadotorg\SchemaDotOrgMappingInterface; /** - * Implements hook_schemadotorg_mapping_insert(). + * Implements hook_help(). */ -function schemadotorg_pathauto_schemadotorg_mapping_insert(SchemaDotOrgMappingInterface $mapping): void { - if ($mapping->isSyncing()) { - return; +function schemadotorg_pathauto_help(string $route_name, RouteMatchInterface $route_match): string|NULL { + if ($route_name === 'schemadotorg_pathauto.report') { + return '<p>' . t("The <strong>Schema.org: Paths</strong> report summarizes the URL aliases generate via pathauto for Schema.org mappings.") . '</p>'; } + return NULL; +} - $entity_type_id = $mapping->getTargetEntityTypeId(); - $bundle = $mapping->getTargetBundle(); - $schema_type = $mapping->getSchemaType(); - - /** @var \Drupal\schemadotorg\SchemaDotOrgSchemaTypeManagerInterface $schema_type_manager */ - $schema_type_manager = \Drupal::service('schemadotorg.schema_type_manager'); - - $patterns = \Drupal::config('schemadotorg_pathauto.settings')->get('patterns'); - $weight = -10; - foreach ($patterns as $pattern_name => $pattern) { - [$pattern_entity_type_id, $pattern_schema_type] = explode('--', $pattern_name); - - if ($pattern_entity_type_id !== $entity_type_id - || !$schema_type_manager->isSubTypeOf($schema_type, $pattern_schema_type)) { - continue; - } - - // Define pathauto pattern id and label. - $entity_type_definition = $mapping->getTargetEntityTypeDefinition(); - $schema_type_definition = $schema_type_manager->getType($pattern_schema_type); - $pathauto_pattern_id = 'schema_' . $entity_type_id . '_' . $schema_type_definition['drupal_name']; - $pathauto_pattern_label = 'Schema.org: ' . $entity_type_definition->getCollectionLabel() . ' - ' . $schema_type_definition['drupal_label']; - - // Load or create initial pathauto pattern with a selection condition. - $pathauto_pattern = PathautoPattern::load($pathauto_pattern_id); - if (!$pathauto_pattern) { - $pathauto_pattern = PathautoPattern::create([ - 'id' => $pathauto_pattern_id, - 'label' => $pathauto_pattern_label, - 'type' => 'canonical_entities:' . $entity_type_id, - 'pattern' => $pattern, - 'weight' => $weight, - ]); - $weight--; - $pathauto_pattern->addSelectionCondition([ - 'id' => 'entity_bundle:' . $entity_type_id, - 'negate' => FALSE, - 'context_mapping' => [ - $entity_type_id => $entity_type_id, - ], - ]); - } - - // Get the default selection condition. - $selection_conditions_configuration = $pathauto_pattern->getSelectionConditions()->getConfiguration(); - $selection_condition_id = array_key_first($selection_conditions_configuration); - $selection_condition = $pathauto_pattern->getSelectionConditions()->get($selection_condition_id); - - // Append the Schema.org mapping bundle to the selection condition. - $configuration = $selection_condition->getConfiguration(); - $configuration['bundles'][$bundle] = $bundle; - ksort($configuration['bundles']); - $selection_condition->setConfiguration($configuration); - - $pathauto_pattern->save(); - } +/** + * Implements hook_schemadotorg_mapping_insert(). + */ +function schemadotorg_pathauto_schemadotorg_mapping_insert(SchemaDotOrgMappingInterface $mapping): void { + /** @var \Drupal\schemadotorg_pathauto\SchemaDotOrgPathautoManagerInterface $schema_pathauto_manager */ + $schema_pathauto_manager = \Drupal::service('schemadotorg_pathauto.manager'); + $schema_pathauto_manager->mappingInsert($mapping); } /* ************************************************************************** */ @@ -114,14 +67,9 @@ node--Thing: '[node:schemadotorg:base-path]/[node:title]' '#description_link' => 'types', '#token_link' => TRUE, '#example' => " -Restaurants: restaurants -Physician: doctors -MedicalCondition: medical/conditions -MedicalEntity: medical -Event: events -Person: profiles -LocalBusiness: businesses -Organization: organizations +SchemaType: base-path +SchemaType--bundle: base-path +entity_type_id--SchemaType--bundle: base-path ", ]; $form['schemadotorg_pathauto']['apply_paragraph_types'] = [ diff --git a/modules/schemadotorg_pathauto/schemadotorg_pathauto.routing.yml b/modules/schemadotorg_pathauto/schemadotorg_pathauto.routing.yml new file mode 100644 index 0000000000000000000000000000000000000000..0e17aa5283676cb4a39711d6c7424f9831863443 --- /dev/null +++ b/modules/schemadotorg_pathauto/schemadotorg_pathauto.routing.yml @@ -0,0 +1,7 @@ +schemadotorg_pathauto.report: + path: '/admin/reports/schemadotorg/docs/paths' + defaults: + _title: 'Schema.org: Paths' + _controller: '\Drupal\schemadotorg_pathauto\Controller\SchemaDotOrgPathautoReportController::index' + requirements: + _permission: 'access site reports' diff --git a/modules/schemadotorg_pathauto/schemadotorg_pathauto.services.yml b/modules/schemadotorg_pathauto/schemadotorg_pathauto.services.yml new file mode 100644 index 0000000000000000000000000000000000000000..8bfd853594a8db19478baa4980a459d4ab75f35b --- /dev/null +++ b/modules/schemadotorg_pathauto/schemadotorg_pathauto.services.yml @@ -0,0 +1,4 @@ +services: + schemadotorg_pathauto.manager: + class: Drupal\schemadotorg_pathauto\SchemaDotOrgPathautoManager + arguments: ['@config.factory', '@token', '@entity_type.manager', '@schemadotorg.schema_type_manager'] diff --git a/modules/schemadotorg_pathauto/schemadotorg_pathauto.tokens.inc b/modules/schemadotorg_pathauto/schemadotorg_pathauto.tokens.inc index c8b80b0b865f9468aef5967bb9ce979b0e93952c..a6adc6276b10589ea0714d0dae9a4089b1ee6b99 100644 --- a/modules/schemadotorg_pathauto/schemadotorg_pathauto.tokens.inc +++ b/modules/schemadotorg_pathauto/schemadotorg_pathauto.tokens.inc @@ -13,70 +13,16 @@ use Drupal\Core\Render\BubbleableMetadata; * Implements hook_token_info_alter(). */ function schemadotorg_pathauto_token_info_alter(array &$info): void { - /** @var \Drupal\schemadotorg\SchemaDotOrgMappingTypeInterface[] $mapping_types */ - $mapping_types = Drupal::entityTypeManager() - ->getStorage('schemadotorg_mapping_type') - ->loadMultiple(); - - $entity_definitions = \Drupal::entityTypeManager()->getDefinitions(); - foreach ($mapping_types as $mapping_type) { - $entity_type_id = $mapping_type->get('target_entity_type_id'); - $entity_info = $entity_definitions[$entity_type_id] ?? NULL; - if (!$entity_info || !$entity_info->get('token_type')) { - continue; - } - - $token_type = $entity_info->get('token_type'); - $info['tokens'][$token_type]['schemadotorg']['base-path'] = [ - 'name' => t('Schema.org type base path'), - 'description' => t('The Schema.org type base path of the @entity.', ['@entity' => mb_strtolower((string) $entity_info->getLabel())]), - ]; - } + /** @var \Drupal\schemadotorg_pathauto\SchemaDotOrgPathautoManagerInterface $schema_pathauto_manager */ + $schema_pathauto_manager = \Drupal::service('schemadotorg_pathauto.manager'); + $schema_pathauto_manager->tokenInfoAlter($info); } /** * Implements hook_tokens(). */ function schemadotorg_pathauto_tokens(string $type, array $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata): ?array { - $mapping = _schemadotorg_tokens_get_mapping($type, $data); - if (!$mapping) { - return NULL; - } - - /** @var \Drupal\schemadotorg\SchemaDotOrgSchemaTypeManagerInterface $schema_type_manager */ - $schema_type_manager = \Drupal::service('schemadotorg.schema_type_manager'); - - $schema_type = $mapping->getSchemaType(); - /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ - $entity = $data[$type]; - - // Get additionalType and replace the schema type, if it is valid subtype. - // @see schemadotorg_additional_type.module. - $additional_type = NULL; - $additional_type_field_name = $mapping->getSchemaPropertyFieldName('additionalType'); - if ($additional_type_field_name && $entity->hasField($additional_type_field_name)) { - $additional_type = $entity->{$additional_type_field_name}->value; - if ($additional_type && $schema_type_manager->isType($additional_type)) { - $schema_type = $additional_type; - } - } - - $replacements = []; - foreach ($tokens as $name => $original) { - switch ($name) { - case 'schemadotorg:base-path': - $paths = \Drupal::config('schemadotorg_pathauto.settings')->get('base_paths'); - foreach ($paths as $path_schema_type => $path) { - // Allows custom subtypes to have base paths. - if ($path_schema_type === $additional_type - || $schema_type_manager->isSubTypeOf($schema_type, $path_schema_type)) { - $replacements[$original] = \Drupal::token()->replace($path, $data, $options, $bubbleable_metadata); - break; - } - } - break; - } - } - - return $replacements; + /** @var \Drupal\schemadotorg_pathauto\SchemaDotOrgPathautoManagerInterface $schema_pathauto_manager */ + $schema_pathauto_manager = \Drupal::service('schemadotorg_pathauto.manager'); + return $schema_pathauto_manager->tokens($type, $tokens, $data, $options, $bubbleable_metadata); } diff --git a/modules/schemadotorg_pathauto/src/Controller/SchemaDotOrgPathautoReportController.php b/modules/schemadotorg_pathauto/src/Controller/SchemaDotOrgPathautoReportController.php new file mode 100644 index 0000000000000000000000000000000000000000..12ba0b86938b7e9561684a1e1e95375c69a6751f --- /dev/null +++ b/modules/schemadotorg_pathauto/src/Controller/SchemaDotOrgPathautoReportController.php @@ -0,0 +1,103 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\schemadotorg_pathauto\Controller; + +use Drupal\Core\Controller\ControllerBase; +use Drupal\schemadotorg\SchemaDotOrgSchemaTypeManagerInterface; +use Drupal\schemadotorg\Traits\SchemaDotOrgMappingStorageTrait; +use Drupal\schemadotorg_pathauto\SchemaDotOrgPathautoManagerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Returns responses for Schema.org Blueprints Pathauto routes. + */ +class SchemaDotOrgPathautoReportController extends ControllerBase { + use SchemaDotOrgMappingStorageTrait; + + /** + * The Schema.org schema type manager. + */ + protected SchemaDotOrgSchemaTypeManagerInterface $schemaTypeManager; + + /** + * The Schema.org pathauto manager. + */ + protected SchemaDotOrgPathautoManagerInterface $schemaPathAutoManager; + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container): static { + $instance = parent::create($container); + $instance->schemaTypeManager = $container->get('schemadotorg.schema_type_manager'); + $instance->schemaPathAutoManager = $container->get('schemadotorg_pathauto.manager'); + return $instance; + } + + /** + * Builds the response. + */ + public function index(): array { + // Header. + $header = []; + $header['entity_type'] = [ + 'data' => $this->t('Entity type'), + ]; + $header['bundle'] = [ + 'data' => $this->t('Bundle'), + ]; + $header['schema_type'] = [ + 'data' => $this->t('Schema.org type'), + ]; + $header['schema_pattern'] = [ + 'data' => $this->t('Schema.org pattern'), + ]; + $header['schema_base_path'] = [ + 'data' => $this->t('Schema.org base path'), + ]; + + $patterns = $this->config('schemadotorg_pathauto.settings')->get('patterns'); + $base_paths = $this->config('schemadotorg_pathauto.settings')->get('base_paths'); + + // Rows. + $rows = []; + /** @var \Drupal\schemadotorg\SchemaDotOrgMappingInterface[] $mappings */ + $mappings = $this->getMappingStorage()->loadMultiple(); + foreach ($mappings as $mapping) { + $pattern = $this->schemaTypeManager->getSetting($patterns, $mapping); + if (!$pattern) { + continue; + } + + $row = []; + $row['entity_type'] = $mapping->getTargetEntityTypeDefinition()->getLabel(); + $bundle_entity = $mapping->getTargetEntityBundleEntity(); + $row['bundle'] = [ + 'data' => ($bundle_entity) + ? $bundle_entity->toLink($bundle_entity->label(), 'edit-form')->toRenderable() + : $mapping->getTargetBundle(), + ]; + $row['schema_type'] = $mapping->getSchemaType(); + $row['schema_pattern'] = $pattern; + $row['schema_base_path'] = $this->schemaTypeManager->getSetting($base_paths, $mapping); + + $rows[$mapping->id()] = $row; + } + ksort($rows); + + $build = []; + $build['table'] = [ + '#type' => 'table', + '#header' => $header, + '#rows' => $rows, + '#sticky' => TRUE, + '#empty' => $this->t('No Schema.org mappings found.'), + '#attributes' => ['class' => ['schemadotorg-report-table']], + ]; + $build['#attached']['library'][] = 'schemadotorg_report/schemadotorg_report'; + return $build; + } + +} diff --git a/modules/schemadotorg_pathauto/src/SchemaDotOrgPathautoManager.php b/modules/schemadotorg_pathauto/src/SchemaDotOrgPathautoManager.php new file mode 100644 index 0000000000000000000000000000000000000000..f23e70506af3e4c01a53d2a1f7601bc717a06291 --- /dev/null +++ b/modules/schemadotorg_pathauto/src/SchemaDotOrgPathautoManager.php @@ -0,0 +1,174 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\schemadotorg_pathauto; + +use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Render\BubbleableMetadata; +use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\pathauto\Entity\PathautoPattern; +use Drupal\schemadotorg\SchemaDotOrgMappingInterface; +use Drupal\schemadotorg\SchemaDotOrgSchemaTypeManagerInterface; +use Drupal\schemadotorg\Traits\SchemaDotOrgMappingStorageTrait; +use Drupal\token\Token; + +/** + * Schema.org pathauto manager. + */ +class SchemaDotOrgPathautoManager implements SchemaDotOrgPathautoManagerInterface { + use StringTranslationTrait; + use SchemaDotOrgMappingStorageTrait; + + /** + * Constructs a SchemaDotOrgPathautoManager object. + */ + public function __construct( + protected ConfigFactoryInterface $configFactory, + protected Token $token, + protected EntityTypeManagerInterface $entityTypeManager, + protected SchemaDotOrgSchemaTypeManagerInterface $schemaTypeManager, + ) {} + + /** + * {@inheritdoc} + */ + public function mappingInsert(SchemaDotOrgMappingInterface $mapping): void { + if ($mapping->isSyncing()) { + return; + } + + $entity_type_id = $mapping->getTargetEntityTypeId(); + $bundle = $mapping->getTargetBundle(); + $schema_type = $mapping->getSchemaType(); + + $patterns = $this->configFactory->get('schemadotorg_pathauto.settings')->get('patterns'); + $parts = ['entity_type_id' => $entity_type_id, 'schema_type' => $schema_type]; + $pattern = $this->schemaTypeManager->getSetting($patterns, $parts); + $pattern_name = array_search($pattern, $patterns); + [, $pattern_schema_type] = explode('--', $pattern_name); + + // Define pathauto pattern id and label. + $entity_type_definition = $mapping->getTargetEntityTypeDefinition(); + $schema_type_definition = $this->schemaTypeManager->getType($pattern_schema_type); + $pathauto_pattern_id = 'schema_' . $entity_type_id . '_' . $schema_type_definition['drupal_name']; + $pathauto_pattern_label = 'Schema.org: ' . $entity_type_definition->getCollectionLabel() . ' - ' . $schema_type_definition['drupal_label']; + + // Load or create initial pathauto pattern with a selection condition. + $pathauto_pattern = PathautoPattern::load($pathauto_pattern_id); + if (!$pathauto_pattern) { + $pathauto_pattern = PathautoPattern::create([ + 'id' => $pathauto_pattern_id, + 'label' => $pathauto_pattern_label, + 'type' => 'canonical_entities:' . $entity_type_id, + 'pattern' => $pattern, + 'weight' => -10, + ]); + $pathauto_pattern->addSelectionCondition([ + 'id' => 'entity_bundle:' . $entity_type_id, + 'negate' => FALSE, + 'context_mapping' => [ + $entity_type_id => $entity_type_id, + ], + ]); + } + + // Get the default selection condition. + $selection_conditions_configuration = $pathauto_pattern->getSelectionConditions()->getConfiguration(); + $selection_condition_id = array_key_first($selection_conditions_configuration); + $selection_condition = $pathauto_pattern->getSelectionConditions()->get($selection_condition_id); + + // Append the Schema.org mapping bundle to the selection condition. + $configuration = $selection_condition->getConfiguration(); + $configuration['bundles'][$bundle] = $bundle; + ksort($configuration['bundles']); + $selection_condition->setConfiguration($configuration); + + $pathauto_pattern->save(); + } + + /** + * Alter the metadata about available placeholder tokens and token types. + * + * @param array $info + * The associative array of token definitions from hook_token_info(). + */ + public function tokenInfoAlter(array &$info): void { + /** @var \Drupal\schemadotorg\SchemaDotOrgMappingTypeInterface[] $mapping_types */ + $mapping_types = $this->getMappingTypeStorage()->loadMultiple(); + + $entity_definitions = $this->entityTypeManager->getDefinitions(); + foreach ($mapping_types as $mapping_type) { + $entity_type_id = $mapping_type->get('target_entity_type_id'); + $entity_info = $entity_definitions[$entity_type_id] ?? NULL; + if (!$entity_info || !$entity_info->get('token_type')) { + continue; + } + + $token_type = $entity_info->get('token_type'); + $info['tokens'][$token_type]['schemadotorg']['base-path'] = [ + 'name' => $this->t('Schema.org type base path'), + 'description' => $this->t('The Schema.org type base path of the @entity.', ['@entity' => mb_strtolower((string) $entity_info->getLabel())]), + ]; + } + } + + /** + * {@inheritdoc} + */ + public function tokens(string $type, array $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata): ?array { + $base_path_token = $tokens['schemadotorg:base-path'] ?? NULL; + if (!$base_path_token) { + return NULL; + } + + $entity = $data[$type] ?? NULL; + if (!$entity instanceof ContentEntityInterface) { + return NULL; + } + + $base_path = $this->getBasePath($entity); + if (!$base_path) { + return NULL; + } + + return [ + $base_path_token => $this->token->replace($base_path, $data, $options, $bubbleable_metadata), + ]; + } + + /** + * Get the base path for a content entity. + * + * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * The content entity. + * + * @return string|null + * The base path for a content entity. + */ + protected function getBasePath(ContentEntityInterface $entity): ?string { + // Check that the content entity is mapped to a Schema.org type. + $mapping = $this->getMappingStorage()->loadByEntity($entity); + if (!$mapping) { + return NULL; + } + + $parts = [ + 'entity_type_id' => $mapping->getEntityTypeId(), + 'bundle' => $mapping->getTargetBundle(), + 'schema_type' => $mapping->getSchemaType(), + ]; + + // Get the additional Schema.org type. + // @see schemadotorg_additional_type.module. + $additional_type_field_name = $mapping->getSchemaPropertyFieldName('additionalType'); + $additional_type = $entity->{$additional_type_field_name}->value ?? NULL; + + $base_paths = $this->configFactory->get('schemadotorg_pathauto.settings')->get('base_paths'); + return $this->schemaTypeManager->getSetting($base_paths, ['schema_type' => $additional_type] + $parts) + ?? $this->schemaTypeManager->getSetting($base_paths, $parts); + } + +} diff --git a/modules/schemadotorg_pathauto/src/SchemaDotOrgPathautoManagerInterface.php b/modules/schemadotorg_pathauto/src/SchemaDotOrgPathautoManagerInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..e1e5e4196adce6f9651b219c1beec85665dea3b1 --- /dev/null +++ b/modules/schemadotorg_pathauto/src/SchemaDotOrgPathautoManagerInterface.php @@ -0,0 +1,58 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\schemadotorg_pathauto; + +use Drupal\Core\Render\BubbleableMetadata; +use Drupal\schemadotorg\SchemaDotOrgMappingInterface; + +/** + * Schema.org pathauto manager interface. + */ +interface SchemaDotOrgPathautoManagerInterface { + + /** + * Create an initial pathauto pattern when a mapping is inserted. + * + * @param \Drupal\schemadotorg\SchemaDotOrgMappingInterface $mapping + * The Schema.org mapping. + */ + public function mappingInsert(SchemaDotOrgMappingInterface $mapping): void; + + /** + * Alter the metadata about available placeholder tokens and token types. + * + * @param array $info + * The associative array of token definitions from hook_token_info(). + */ + public function tokenInfoAlter(array &$info): void; + + /** + * Provide replacement values for placeholder tokens. + * + * @param string $type + * The machine-readable name of the type (group) of token being replaced, such + * as 'node', 'user', or another type defined by a hook_token_info() + * implementation. + * @param array $tokens + * An array of tokens to be replaced. The keys are the machine-readable token + * names, and the values are the raw [type:token] strings that appeared in the + * original text. + * @param array $data + * An associative array of data objects to be used when generating replacement + * values, as supplied in the $data parameter to + * \Drupal\Core\Utility\Token::replace(). + * @param array $options + * An associative array of options for token replacement; see + * \Drupal\Core\Utility\Token::replace() for possible values. + * @param \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata + * The bubbleable metadata. + * + * @return ?array + * An associative array of replacement values, keyed by the raw [type:token] + * strings from the original text. + */ + public function tokens(string $type, array $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata): ?array; + +} diff --git a/modules/schemadotorg_report/schemadotorg_report.links.menu.yml b/modules/schemadotorg_report/schemadotorg_report.links.menu.yml index 69d2d3b211f3285adc2df5e560a3e86ee2dd63db..f83812c947a29904958faa945cc49f49b15b2b3f 100644 --- a/modules/schemadotorg_report/schemadotorg_report.links.menu.yml +++ b/modules/schemadotorg_report/schemadotorg_report.links.menu.yml @@ -14,22 +14,22 @@ schemadotorg_report.properties: parent: schemadotorg_report description: 'Overview of Schema.org properties.' route_name: schemadotorg_report.properties - weight: 1 + weight: 10 schemadotorg_report.relationships: title: Relationships parent: schemadotorg_report description: 'Overview of Schema.org content type relationships.' route_name: schemadotorg_report.relationships - weight: 2 + weight: 20 schemadotorg_report.names: title: Names parent: schemadotorg_report description: 'Summarizes the abbreviations used to convert Schema.org type and property names to Drupal entity type and field names.' route_name: schemadotorg_report.names - weight: 3 + weight: 30 schemadotorg_report.references: title: References parent: schemadotorg_report description: 'Lists Schema.org references and issues.' route_name: schemadotorg_report.references - weight: 4 + weight: 40 diff --git a/modules/schemadotorg_report/schemadotorg_report.links.task.yml b/modules/schemadotorg_report/schemadotorg_report.links.task.yml index 0a1b1ed45cde54c7430cdf9391daf8287f0a3825..bcdd02d6036079203ba8f2e31f8c9becb374e49f 100644 --- a/modules/schemadotorg_report/schemadotorg_report.links.task.yml +++ b/modules/schemadotorg_report/schemadotorg_report.links.task.yml @@ -11,6 +11,7 @@ schemadotorg_report.types: title: Types route_name: schemadotorg_report.types base_route: schemadotorg_report + weight: 0 schemadotorg_report.types.table: title: All route_name: schemadotorg_report.types @@ -46,6 +47,7 @@ schemadotorg_report.properties: title: Properties route_name: schemadotorg_report.properties base_route: schemadotorg_report + weight: 10 schemadotorg_report.properties.table: title: All route_name: schemadotorg_report.properties @@ -69,6 +71,7 @@ schemadotorg_report.relationships: title: Relationships route_name: schemadotorg_report.relationships base_route: schemadotorg_report + weight: 20 schemadotorg_report.relationships.overview: title: Overview route_name: schemadotorg_report.relationships @@ -88,6 +91,7 @@ schemadotorg_report.names: title: Names route_name: schemadotorg_report.names base_route: schemadotorg_report + weight: 30 schemadotorg_report.names.overview: title: Overview route_name: schemadotorg_report.names @@ -115,6 +119,7 @@ schemadotorg_report.references: title: References route_name: schemadotorg_report.references base_route: schemadotorg_report + weight: 40 schemadotorg_report.overview: title: View route_name: schemadotorg_report.references diff --git a/src/SchemaDotOrgSchemaTypeManager.php b/src/SchemaDotOrgSchemaTypeManager.php index a5f86bffd919f97036655953cb3fd7eef8b26d87..9e58c5cf9239f205ccacd984255f3f47c49583f8 100644 --- a/src/SchemaDotOrgSchemaTypeManager.php +++ b/src/SchemaDotOrgSchemaTypeManager.php @@ -43,6 +43,7 @@ class SchemaDotOrgSchemaTypeManager implements SchemaDotOrgSchemaTypeManagerInte ['bundle', 'schema_property'], ['schema_type', 'field_name'], + ['schema_type', 'bundle'], ['schema_type', 'schema_property'], ['schema_property'],