X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcontent_moderation%2Fsrc%2FRouting%2FEntityModerationRouteProvider.php;fp=web%2Fcore%2Fmodules%2Fcontent_moderation%2Fsrc%2FRouting%2FEntityModerationRouteProvider.php;h=0000000000000000000000000000000000000000;hp=e96f374a9146ceed10407be37aa5edfe2ffa411a;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/content_moderation/src/Routing/EntityModerationRouteProvider.php b/web/core/modules/content_moderation/src/Routing/EntityModerationRouteProvider.php deleted file mode 100644 index e96f374a9..000000000 --- a/web/core/modules/content_moderation/src/Routing/EntityModerationRouteProvider.php +++ /dev/null @@ -1,121 +0,0 @@ -entityFieldManager = $entity_manager; - } - - /** - * {@inheritdoc} - */ - public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $container->get('entity_field.manager') - ); - } - - /** - * {@inheritdoc} - */ - public function getRoutes(EntityTypeInterface $entity_type) { - $collection = new RouteCollection(); - - if ($moderation_route = $this->getLatestVersionRoute($entity_type)) { - $entity_type_id = $entity_type->id(); - $collection->add("entity.{$entity_type_id}.latest_version", $moderation_route); - } - - return $collection; - } - - /** - * Gets the moderation-form route. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type. - * - * @return \Symfony\Component\Routing\Route|null - * The generated route, if available. - */ - protected function getLatestVersionRoute(EntityTypeInterface $entity_type) { - if ($entity_type->hasLinkTemplate('latest-version') && $entity_type->hasViewBuilderClass()) { - $entity_type_id = $entity_type->id(); - $route = new Route($entity_type->getLinkTemplate('latest-version')); - $route - ->addDefaults([ - '_entity_view' => "{$entity_type_id}.full", - '_title_callback' => '\Drupal\Core\Entity\Controller\EntityController::title', - ]) - // If the entity type is a node, unpublished content will be visible - // if the user has the "view all unpublished content" permission. - ->setRequirement('_entity_access', "{$entity_type_id}.view") - ->setRequirement('_content_moderation_latest_version', 'TRUE') - ->setOption('_content_moderation_entity_type', $entity_type_id) - ->setOption('parameters', [ - $entity_type_id => [ - 'type' => 'entity:' . $entity_type_id, - 'load_forward_revision' => 1, - ], - ]); - - // Entity types with serial IDs can specify this in their route - // requirements, improving the matching process. - if ($this->getEntityTypeIdKeyType($entity_type) === 'integer') { - $route->setRequirement($entity_type_id, '\d+'); - } - return $route; - } - } - - /** - * Gets the type of the ID key for a given entity type. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * An entity type. - * - * @return string|null - * The type of the ID key for a given entity type, or NULL if the entity - * type does not support fields. - */ - protected function getEntityTypeIdKeyType(EntityTypeInterface $entity_type) { - if (!$entity_type->entityClassImplements(FieldableEntityInterface::class)) { - return NULL; - } - - $field_storage_definitions = $this->entityFieldManager->getFieldStorageDefinitions($entity_type->id()); - return $field_storage_definitions[$entity_type->getKey('id')]->getType(); - } - -}