Issue #2281645 by dawehner, andypost: Make entity annotations use link templates instead of route names
parent
e298180f76
commit
77725b6084
|
@ -164,8 +164,9 @@ abstract class Entity implements EntityInterface {
|
||||||
$link_templates = $this->linkTemplates();
|
$link_templates = $this->linkTemplates();
|
||||||
|
|
||||||
if (isset($link_templates[$rel])) {
|
if (isset($link_templates[$rel])) {
|
||||||
// If there is a template for the given relationship type, generate the path.
|
$route_parameters = $this->urlRouteParameters($rel);
|
||||||
$uri = new Url($link_templates[$rel], $this->urlRouteParameters($rel));
|
$route_name = "entity.{$this->entityTypeId}." . str_replace(array('-', 'drupal:'), array('_', ''), $rel);
|
||||||
|
$uri = new Url($route_name, $route_parameters);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$bundle = $this->bundle();
|
$bundle = $this->bundle();
|
||||||
|
@ -224,7 +225,7 @@ abstract class Entity implements EntityInterface {
|
||||||
* Returns an array link templates.
|
* Returns an array link templates.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* An array of link templates containing route names.
|
* An array of link templates containing paths.
|
||||||
*/
|
*/
|
||||||
protected function linkTemplates() {
|
protected function linkTemplates() {
|
||||||
return $this->getEntityType()->getLinkTemplates();
|
return $this->getEntityType()->getLinkTemplates();
|
||||||
|
|
|
@ -105,9 +105,9 @@ interface EntityInterface extends AccessibleInterface {
|
||||||
* example:
|
* example:
|
||||||
* @code
|
* @code
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.node.canonical",
|
* "canonical" = "/node/{node}",
|
||||||
* "edit-form" = "entity.node.edit_form",
|
* "edit-form" = "/node/{node}/edit",
|
||||||
* "version-history" = "entity.node.version_history"
|
* "version-history" = "/node/{node}/revisions"
|
||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
* or specified in a callback function set like:
|
* or specified in a callback function set like:
|
||||||
|
|
|
@ -546,8 +546,12 @@ class EntityType implements EntityTypeInterface {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setLinkTemplate($key, $route_name) {
|
public function setLinkTemplate($key, $path) {
|
||||||
$this->links[$key] = $route_name;
|
if ($path[0] !== '/') {
|
||||||
|
throw new \InvalidArgumentException('Link templates accepts paths, which have to start with a leading slash.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->links[$key] = $path;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,7 @@ interface EntityTypeInterface {
|
||||||
* The link type.
|
* The link type.
|
||||||
*
|
*
|
||||||
* @return string|bool
|
* @return string|bool
|
||||||
* The route name for this link, or FALSE if it doesn't exist.
|
* The path for this link, or FALSE if it doesn't exist.
|
||||||
*/
|
*/
|
||||||
public function getLinkTemplate($key);
|
public function getLinkTemplate($key);
|
||||||
|
|
||||||
|
@ -475,12 +475,15 @@ interface EntityTypeInterface {
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* The name of a link.
|
* The name of a link.
|
||||||
* @param string $route_name
|
* @param string $path
|
||||||
* The route name to use for the link.
|
* The route path to use for the link.
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
* Thrown when the path does not start with a leading slash.
|
||||||
*/
|
*/
|
||||||
public function setLinkTemplate($key, $route_name);
|
public function setLinkTemplate($key, $path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the callback for the label of the entity.
|
* Gets the callback for the label of the entity.
|
||||||
|
|
|
@ -44,6 +44,6 @@ function action_entity_type_build(array &$entity_types) {
|
||||||
->setFormClass('edit', 'Drupal\action\ActionEditForm')
|
->setFormClass('edit', 'Drupal\action\ActionEditForm')
|
||||||
->setFormClass('delete', 'Drupal\action\Form\ActionDeleteForm')
|
->setFormClass('delete', 'Drupal\action\Form\ActionDeleteForm')
|
||||||
->setListBuilderClass('Drupal\action\ActionListBuilder')
|
->setListBuilderClass('Drupal\action\ActionListBuilder')
|
||||||
->setLinkTemplate('delete-form', 'entity.action.delete_form')
|
->setLinkTemplate('delete-form', '/admin/config/system/actions/configure/{action}/delete')
|
||||||
->setLinkTemplate('edit-form', 'entity.action.edit_form');
|
->setLinkTemplate('edit-form', '/admin/config/system/actions/configure/{action}');
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@ use Drupal\aggregator\FeedInterface;
|
||||||
* }
|
* }
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.aggregator_feed.canonical",
|
* "canonical" = "/aggregator/sources/{aggregator_feed}",
|
||||||
* "edit-form" = "entity.aggregator_feed.edit_form",
|
* "edit-form" = "/aggregator/sources/{aggregator_feed}/configure",
|
||||||
* "delete-form" = "entity.aggregator_feed.delete_form",
|
* "delete-form" = "/aggregator/sources/{aggregator_feed}/delete",
|
||||||
* },
|
* },
|
||||||
* field_ui_base_route = "aggregator.admin_overview",
|
* field_ui_base_route = "aggregator.admin_overview",
|
||||||
* base_table = "aggregator_feed",
|
* base_table = "aggregator_feed",
|
||||||
|
|
|
@ -36,8 +36,8 @@ use Drupal\Core\Entity\EntityStorageInterface;
|
||||||
* "id" = "id"
|
* "id" = "id"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "delete-form" = "entity.block.delete_form",
|
* "delete-form" = "/admin/structure/block/manage/{block}/delete",
|
||||||
* "edit-form" = "entity.block.edit_form"
|
* "edit-form" = "/admin/structure/block/manage/{block}"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -45,6 +45,15 @@ entity.block_content.canonical:
|
||||||
requirements:
|
requirements:
|
||||||
_entity_access: 'block_content.update'
|
_entity_access: 'block_content.update'
|
||||||
|
|
||||||
|
entity.block_content.edit_form:
|
||||||
|
path: '/block/{block_content}'
|
||||||
|
defaults:
|
||||||
|
_entity_form: 'block_content.edit'
|
||||||
|
options:
|
||||||
|
_admin_route: TRUE
|
||||||
|
requirements:
|
||||||
|
_entity_access: 'block_content.update'
|
||||||
|
|
||||||
entity.block_content.delete_form:
|
entity.block_content.delete_form:
|
||||||
path: '/block/{block_content}/delete'
|
path: '/block/{block_content}/delete'
|
||||||
defaults:
|
defaults:
|
||||||
|
|
|
@ -39,9 +39,9 @@ use Drupal\block_content\BlockContentInterface;
|
||||||
* revision_table = "block_content_revision",
|
* revision_table = "block_content_revision",
|
||||||
* data_table = "block_content_field_data",
|
* data_table = "block_content_field_data",
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.block_content.canonical",
|
* "canonical" = "/block/{block_content}",
|
||||||
* "delete-form" = "entity.block_content.delete_form",
|
* "delete-form" = "/block/{block_content}/delete",
|
||||||
* "edit-form" = "entity.block_content.canonical",
|
* "edit-form" = "/block/{block_content}",
|
||||||
* },
|
* },
|
||||||
* translatable = TRUE,
|
* translatable = TRUE,
|
||||||
* entity_keys = {
|
* entity_keys = {
|
||||||
|
|
|
@ -35,8 +35,8 @@ use Drupal\block_content\BlockContentTypeInterface;
|
||||||
* "label" = "label"
|
* "label" = "label"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "delete-form" = "entity.block_content_type.delete_form",
|
* "delete-form" = "/admin/structure/block/block-content/manage/{block_content_type}/delete",
|
||||||
* "edit-form" = "entity.block_content_type.edit_form"
|
* "edit-form" = "/admin/structure/block/block-content/manage/{block_content_type}"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -89,8 +89,8 @@ function book_entity_type_build(array &$entity_types) {
|
||||||
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
|
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
|
||||||
$entity_types['node']
|
$entity_types['node']
|
||||||
->setFormClass('book_outline', 'Drupal\book\Form\BookOutlineForm')
|
->setFormClass('book_outline', 'Drupal\book\Form\BookOutlineForm')
|
||||||
->setLinkTemplate('book-outline-form', 'entity.node.book_outline_form')
|
->setLinkTemplate('book-outline-form', '/node/{node}/outline')
|
||||||
->setLinkTemplate('book-remove-form', 'entity.node.book_remove_form');
|
->setLinkTemplate('book-remove-form', '/node/{node}/outline/remove');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -47,9 +47,9 @@ use Drupal\user\UserInterface;
|
||||||
* "uuid" = "uuid"
|
* "uuid" = "uuid"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.comment.canonical",
|
* "canonical" = "/comment/{comment}",
|
||||||
* "delete-form" = "entity.comment.delete_form",
|
* "delete-form" = "/comment/{comment}/delete",
|
||||||
* "edit-form" = "entity.comment.edit_form",
|
* "edit-form" = "/comment/{comment}/edit",
|
||||||
* },
|
* },
|
||||||
* bundle_entity_type = "comment_type",
|
* bundle_entity_type = "comment_type",
|
||||||
* field_ui_base_route = "entity.comment_type.edit_form",
|
* field_ui_base_route = "entity.comment_type.edit_form",
|
||||||
|
|
|
@ -34,9 +34,9 @@ use Drupal\comment\CommentTypeInterface;
|
||||||
* "label" = "label"
|
* "label" = "label"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "delete-form" = "entity.comment_type.delete_form",
|
* "delete-form" = "/admin/structure/comment/manage/{comment_type}/delete",
|
||||||
* "edit-form" = "entity.comment_type.edit_form",
|
* "edit-form" = "/admin/structure/comment/manage/{comment_type}",
|
||||||
* "add-form" = "entity.comment_type.add_form"
|
* "add-form" = "/admin/structure/comment/types/add"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -224,7 +224,7 @@ class CommentAdminOverview extends FormBase {
|
||||||
if ($this->moduleHandler->moduleExists('content_translation') && $this->moduleHandler->invoke('content_translation', 'translate_access', array($comment))->isAllowed()) {
|
if ($this->moduleHandler->moduleExists('content_translation') && $this->moduleHandler->invoke('content_translation', 'translate_access', array($comment))->isAllowed()) {
|
||||||
$links['translate'] = array(
|
$links['translate'] = array(
|
||||||
'title' => $this->t('Translate'),
|
'title' => $this->t('Translate'),
|
||||||
'url' => Url::fromRoute('content_translation.translation_overview_comment', ['comment' => $comment->id()], $comment_uri_options + ['query' => $destination]),
|
'url' => Url::fromRoute('entity.comment.content_translation_overview', ['comment' => $comment->id()], $comment_uri_options + ['query' => $destination]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$options[$comment->id()]['operations']['data'] = array(
|
$options[$comment->id()]['operations']['data'] = array(
|
||||||
|
|
|
@ -108,7 +108,7 @@ class CommentTypeTest extends CommentTestBase {
|
||||||
$this->drupalGet('admin/structure/comment');
|
$this->drupalGet('admin/structure/comment');
|
||||||
$this->assertRaw('Bar', 'New name was displayed.');
|
$this->assertRaw('Bar', 'New name was displayed.');
|
||||||
$this->clickLink('Manage fields');
|
$this->clickLink('Manage fields');
|
||||||
$this->assertUrl(\Drupal::url('field_ui.overview_comment', array('comment_type' => 'comment'), array('absolute' => TRUE)), [], 'Original machine name was used in URL.');
|
$this->assertUrl(\Drupal::url('entity.comment_type.field_ui_fields', ['comment_type' => 'comment'], ['absolute' => TRUE]), [], 'Original machine name was used in URL.');
|
||||||
$this->assertTrue($this->cssSelect('tr#comment-body'), 'Body field exists.');
|
$this->assertTrue($this->cssSelect('tr#comment-body'), 'Body field exists.');
|
||||||
|
|
||||||
// Remove the body field.
|
// Remove the body field.
|
||||||
|
|
|
@ -50,8 +50,8 @@ function config_test_entity_type_alter(array &$entity_types) {
|
||||||
// Create a clone of config_test that does not have a status.
|
// Create a clone of config_test that does not have a status.
|
||||||
$entity_types['config_test_no_status'] = clone $entity_types['config_test'];
|
$entity_types['config_test_no_status'] = clone $entity_types['config_test'];
|
||||||
$config_test_no_status = &$entity_types['config_test_no_status'];
|
$config_test_no_status = &$entity_types['config_test_no_status'];
|
||||||
$config_test_no_status->setLinkTemplate('edit-form', 'entity.config_test.edit_form_config_test_no_status');
|
$config_test_no_status->setLinkTemplate('edit-form', '/admin/structure/config_test/manage/{config_test_no_status}');
|
||||||
$config_test_no_status->setLinkTemplate('delete-form', 'entity.config_test.delete_form_config_test_no_status');
|
$config_test_no_status->setLinkTemplate('delete-form', '/admin/structure/config_test/manage/{config_test_no_status}/delete');
|
||||||
|
|
||||||
$keys = $config_test_no_status->getKeys();
|
$keys = $config_test_no_status->getKeys();
|
||||||
unset($keys['status']);
|
unset($keys['status']);
|
||||||
|
|
|
@ -34,10 +34,10 @@ use Drupal\Core\Entity\EntityStorageInterface;
|
||||||
* "status" = "status"
|
* "status" = "status"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "edit-form" = "entity.config_test.edit_form",
|
* "edit-form" = "/admin/structure/config_test/manage/{config_test}",
|
||||||
* "delete-form" = "entity.config_test.delete_form",
|
* "delete-form" = "/admin/structure/config_test/manage/{config_test}/delete",
|
||||||
* "enable" = "entity.config_test.enable",
|
* "enable" = "/admin/structure/config_test/manage/{config_test}/enable",
|
||||||
* "disable" = "entity.config_test.disable"
|
* "disable" = "/admin/structure/config_test/manage/{config_test}/disable"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -36,13 +36,13 @@ function hook_config_translation_info(&$info) {
|
||||||
$route_provider = \Drupal::service('router.route_provider');
|
$route_provider = \Drupal::service('router.route_provider');
|
||||||
|
|
||||||
// If field UI is not enabled, the base routes of the type
|
// If field UI is not enabled, the base routes of the type
|
||||||
// "field_ui.field_edit_$entity_type" are not defined.
|
// "entity.field_config.{$entity_type}_field_edit_form" are not defined.
|
||||||
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
|
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
|
||||||
// Add fields entity mappers to all fieldable entity types defined.
|
// Add fields entity mappers to all fieldable entity types defined.
|
||||||
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
|
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||||
$base_route = NULL;
|
$base_route = NULL;
|
||||||
try {
|
try {
|
||||||
$base_route = $route_provider->getRouteByName('field_ui.field_edit_' . $entity_type_id);
|
$base_route = $route_provider->getRouteByName('entity.field_config.' . $entity_type_id . '_field_edit_form');
|
||||||
}
|
}
|
||||||
catch (RouteNotFoundException $e) {
|
catch (RouteNotFoundException $e) {
|
||||||
// Ignore non-existent routes.
|
// Ignore non-existent routes.
|
||||||
|
@ -51,7 +51,7 @@ function hook_config_translation_info(&$info) {
|
||||||
// Make sure entity type has field UI enabled and has a base route.
|
// Make sure entity type has field UI enabled and has a base route.
|
||||||
if ($entity_type->get('field_ui_base_route') && !empty($base_route)) {
|
if ($entity_type->get('field_ui_base_route') && !empty($base_route)) {
|
||||||
$info[$entity_type_id . '_fields'] = array(
|
$info[$entity_type_id . '_fields'] = array(
|
||||||
'base_route_name' => 'field_ui.field_edit_' . $entity_type_id,
|
'base_route_name' => 'entity.field_config.' . $entity_type_id . '_field_edit_form',
|
||||||
'entity_type' => 'field_config',
|
'entity_type' => 'field_config',
|
||||||
'title' => t('!label field'),
|
'title' => t('!label field'),
|
||||||
'class' => '\Drupal\config_translation\ConfigFieldMapper',
|
'class' => '\Drupal\config_translation\ConfigFieldMapper',
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
use Drupal\config_translation\Plugin\Derivative\ConfigTranslationLocalTasks;
|
use Drupal\config_translation\Plugin\Derivative\ConfigTranslationLocalTasks;
|
||||||
use Drupal\Core\Entity\EntityInterface;
|
use Drupal\Core\Entity\EntityInterface;
|
||||||
use Drupal\Core\Routing\RouteMatchInterface;
|
use Drupal\Core\Routing\RouteMatchInterface;
|
||||||
|
use Drupal\field\FieldConfigInterface;
|
||||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +84,7 @@ function config_translation_entity_type_alter(array &$entity_types) {
|
||||||
elseif ($entity_type_id == 'field_config') {
|
elseif ($entity_type_id == 'field_config') {
|
||||||
$class = 'Drupal\config_translation\Controller\ConfigTranslationFieldListBuilder';
|
$class = 'Drupal\config_translation\Controller\ConfigTranslationFieldListBuilder';
|
||||||
// Will be filled in dynamically, see \Drupal\field\Entity\FieldConfig::linkTemplates().
|
// Will be filled in dynamically, see \Drupal\field\Entity\FieldConfig::linkTemplates().
|
||||||
$entity_type->setLinkTemplate('drupal:config-translation-overview', 'config_translation.item.overview.');
|
$entity_type->setLinkTemplate('config-translation-overview', $entity_type->getLinkTemplate('edit-form') . '/translate');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$class = 'Drupal\config_translation\Controller\ConfigTranslationEntityListBuilder';
|
$class = 'Drupal\config_translation\Controller\ConfigTranslationEntityListBuilder';
|
||||||
|
@ -91,7 +92,7 @@ function config_translation_entity_type_alter(array &$entity_types) {
|
||||||
$entity_type->setHandlerClass('config_translation_list', $class);
|
$entity_type->setHandlerClass('config_translation_list', $class);
|
||||||
|
|
||||||
if ($entity_type->hasLinkTemplate('edit-form')) {
|
if ($entity_type->hasLinkTemplate('edit-form')) {
|
||||||
$entity_type->setLinkTemplate('drupal:config-translation-overview', 'config_translation.item.overview.' . $entity_type->getLinkTemplate('edit-form'));
|
$entity_type->setLinkTemplate('config-translation-overview', $entity_type->getLinkTemplate('edit-form') . '/translate');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,14 +106,14 @@ function config_translation_config_translation_info(&$info) {
|
||||||
$route_provider = \Drupal::service('router.route_provider');
|
$route_provider = \Drupal::service('router.route_provider');
|
||||||
|
|
||||||
// If field UI is not enabled, the base routes of the type
|
// If field UI is not enabled, the base routes of the type
|
||||||
// "field_ui.field_edit_$entity_type" are not defined.
|
// "entity.field_config.{$entity_type}_field_edit_form" are not defined.
|
||||||
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
|
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
|
||||||
// Add fields entity mappers to all fieldable entity types defined.
|
// Add fields entity mappers to all fieldable entity types defined.
|
||||||
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
|
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||||
// Make sure entity type has field UI enabled and has a base route.
|
// Make sure entity type has field UI enabled and has a base route.
|
||||||
if ($entity_type->get('field_ui_base_route')) {
|
if ($entity_type->get('field_ui_base_route')) {
|
||||||
$info[$entity_type_id . '_fields'] = array(
|
$info[$entity_type_id . '_fields'] = array(
|
||||||
'base_route_name' => 'field_ui.field_edit_' . $entity_type_id,
|
'base_route_name' => "entity.field_config.{$entity_type_id}_field_edit_form",
|
||||||
'entity_type' => 'field_config',
|
'entity_type' => 'field_config',
|
||||||
'title' => '!label field',
|
'title' => '!label field',
|
||||||
'class' => '\Drupal\config_translation\ConfigFieldMapper',
|
'class' => '\Drupal\config_translation\ConfigFieldMapper',
|
||||||
|
@ -139,9 +140,10 @@ function config_translation_config_translation_info(&$info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the entity type as the plugin ID.
|
// Use the entity type as the plugin ID.
|
||||||
|
$base_route_name = "entity.$entity_type_id.edit_form";
|
||||||
$info[$entity_type_id] = array(
|
$info[$entity_type_id] = array(
|
||||||
'class' => '\Drupal\config_translation\ConfigEntityMapper',
|
'class' => '\Drupal\config_translation\ConfigEntityMapper',
|
||||||
'base_route_name' => $entity_type->getLinkTemplate('edit-form'),
|
'base_route_name' => $base_route_name,
|
||||||
'title' => '!label !entity_type',
|
'title' => '!label !entity_type',
|
||||||
'names' => array(),
|
'names' => array(),
|
||||||
'entity_type' => $entity_type_id,
|
'entity_type' => $entity_type_id,
|
||||||
|
@ -157,12 +159,18 @@ function config_translation_entity_operation(EntityInterface $entity) {
|
||||||
$operations = array();
|
$operations = array();
|
||||||
$entity_type = $entity->getEntityType();
|
$entity_type = $entity->getEntityType();
|
||||||
if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface') &&
|
if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface') &&
|
||||||
$entity->hasLinkTemplate('drupal:config-translation-overview') &&
|
$entity->hasLinkTemplate('config-translation-overview') &&
|
||||||
\Drupal::currentUser()->hasPermission('translate configuration')) {
|
\Drupal::currentUser()->hasPermission('translate configuration')) {
|
||||||
|
|
||||||
|
$link_template = 'config-translation-overview';
|
||||||
|
if ($entity instanceof FieldConfigInterface) {
|
||||||
|
$link_template = "config-translation-overview.{$entity->getTargetEntityTypeId()}";
|
||||||
|
}
|
||||||
|
|
||||||
$operations['translate'] = array(
|
$operations['translate'] = array(
|
||||||
'title' => t('Translate'),
|
'title' => t('Translate'),
|
||||||
'weight' => 50,
|
'weight' => 50,
|
||||||
'url' => $entity->urlInfo('drupal:config-translation-overview'),
|
'url' => $entity->urlInfo($link_template),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,6 +242,13 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getOverviewRouteName() {
|
||||||
|
return 'entity.' . $this->entityType . '.config_translation_overview';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -34,6 +34,13 @@ class ConfigFieldMapper extends ConfigEntityMapper {
|
||||||
return $parameters;
|
return $parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getOverviewRouteName() {
|
||||||
|
return 'entity.field_config.config_translation_overview.' . $this->pluginDefinition['base_entity_type'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,7 +43,7 @@ function contact_help($route_name, RouteMatchInterface $route_match) {
|
||||||
*/
|
*/
|
||||||
function contact_entity_type_alter(array &$entity_types) {
|
function contact_entity_type_alter(array &$entity_types) {
|
||||||
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
|
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
|
||||||
$entity_types['user']->setLinkTemplate('contact-form', 'entity.user.contact_form');
|
$entity_types['user']->setLinkTemplate('contact-form', '/user/{user}/contact');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,8 +34,8 @@ use Drupal\Core\Config\Entity\ThirdPartySettingsTrait;
|
||||||
* "label" = "label"
|
* "label" = "label"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "delete-form" = "entity.contact_form.delete_form",
|
* "delete-form" = "/admin/structure/contact/manage/{contact_form}/delete",
|
||||||
* "edit-form" = "entity.contact_form.edit_form"
|
* "edit-form" = "/admin/structure/contact/manage/{contact_form}"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -114,7 +114,7 @@ function content_translation_entity_type_alter(array &$entity_types) {
|
||||||
if ($entity_type->hasLinkTemplate('canonical')) {
|
if ($entity_type->hasLinkTemplate('canonical')) {
|
||||||
// Provide default route names for the translation paths.
|
// Provide default route names for the translation paths.
|
||||||
if (!$entity_type->hasLinkTemplate('drupal:content-translation-overview')) {
|
if (!$entity_type->hasLinkTemplate('drupal:content-translation-overview')) {
|
||||||
$entity_type->setLinkTemplate('drupal:content-translation-overview', "content_translation.translation_overview_" . $entity_type->id());
|
$entity_type->setLinkTemplate('drupal:content-translation-overview', $entity_type->getLinkTemplate('canonical') . '/translations');
|
||||||
}
|
}
|
||||||
// @todo Remove this as soon as menu access checks rely on the
|
// @todo Remove this as soon as menu access checks rely on the
|
||||||
// controller. See https://drupal.org/node/2155787.
|
// controller. See https://drupal.org/node/2155787.
|
||||||
|
|
|
@ -53,7 +53,7 @@ class ContentTranslationContextualLinks extends DeriverBase implements Container
|
||||||
// Create contextual links for translatable entity types.
|
// Create contextual links for translatable entity types.
|
||||||
foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
|
foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
|
||||||
$this->derivatives[$entity_type_id]['title'] = t('Translate');
|
$this->derivatives[$entity_type_id]['title'] = t('Translate');
|
||||||
$this->derivatives[$entity_type_id]['route_name'] = $entity_type->getLinkTemplate('drupal:content-translation-overview');
|
$this->derivatives[$entity_type_id]['route_name'] = "entity.$entity_type_id.content_translation_overview";
|
||||||
$this->derivatives[$entity_type_id]['group'] = $entity_type_id;
|
$this->derivatives[$entity_type_id]['group'] = $entity_type_id;
|
||||||
}
|
}
|
||||||
return parent::getDerivativeDefinitions($base_plugin_definition);
|
return parent::getDerivativeDefinitions($base_plugin_definition);
|
||||||
|
|
|
@ -61,13 +61,14 @@ class ContentTranslationLocalTasks extends DeriverBase implements ContainerDeriv
|
||||||
// Create tabs for all possible entity types.
|
// Create tabs for all possible entity types.
|
||||||
foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
|
foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
|
||||||
// Find the route name for the translation overview.
|
// Find the route name for the translation overview.
|
||||||
$translation_route_name = $entity_type->getLinkTemplate('drupal:content-translation-overview');
|
$translation_route_name = "entity.$entity_type_id.content_translation_overview";
|
||||||
|
|
||||||
|
$base_route_name = "entity.$entity_type_id.canonical";
|
||||||
$this->derivatives[$translation_route_name] = array(
|
$this->derivatives[$translation_route_name] = array(
|
||||||
'entity_type' => $entity_type_id,
|
'entity_type' => $entity_type_id,
|
||||||
'title' => 'Translate',
|
'title' => 'Translate',
|
||||||
'route_name' => $translation_route_name,
|
'route_name' => $translation_route_name,
|
||||||
'base_route' => $entity_type->getLinkTemplate('canonical'),
|
'base_route' => $base_route_name,
|
||||||
) + $base_plugin_definition;
|
) + $base_plugin_definition;
|
||||||
}
|
}
|
||||||
return parent::getDerivativeDefinitions($base_plugin_definition);
|
return parent::getDerivativeDefinitions($base_plugin_definition);
|
||||||
|
|
|
@ -42,17 +42,26 @@ class ContentTranslationRouteSubscriber extends RouteSubscriberBase {
|
||||||
protected function alterRoutes(RouteCollection $collection) {
|
protected function alterRoutes(RouteCollection $collection) {
|
||||||
foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
|
foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
|
||||||
// Try to get the route from the current collection.
|
// Try to get the route from the current collection.
|
||||||
if (!$entity_route = $collection->get($entity_type->getLinkTemplate('canonical'))) {
|
$link_template = $entity_type->getLinkTemplate('canonical');
|
||||||
|
if (strpos($link_template, '/') !== FALSE) {
|
||||||
|
$base_path = '/' . $link_template;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!$entity_route = $collection->get("entity.$entity_type_id.canonical")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$path = $entity_route->getPath() . '/translations';
|
$base_path = $entity_route->getPath();
|
||||||
|
}
|
||||||
|
|
||||||
// Inherit admin route status from edit route, if exists.
|
// Inherit admin route status from edit route, if exists.
|
||||||
$is_admin = FALSE;
|
$is_admin = FALSE;
|
||||||
if ($edit_route = $collection->get($entity_type->getLinkTemplate('edit-form'))) {
|
$route_name = "entity.$entity_type_id.edit_form";
|
||||||
|
if ($edit_route = $collection->get($route_name)) {
|
||||||
$is_admin = (bool) $edit_route->getOption('_admin_route');
|
$is_admin = (bool) $edit_route->getOption('_admin_route');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$path = $base_path . '/translations';
|
||||||
|
|
||||||
$route = new Route(
|
$route = new Route(
|
||||||
$path,
|
$path,
|
||||||
array(
|
array(
|
||||||
|
@ -71,7 +80,8 @@ class ContentTranslationRouteSubscriber extends RouteSubscriberBase {
|
||||||
'_admin_route' => $is_admin,
|
'_admin_route' => $is_admin,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$collection->add($entity_type->getLinkTemplate('drupal:content-translation-overview'), $route);
|
$route_name = "entity.$entity_type_id.content_translation_overview";
|
||||||
|
$collection->add($route_name, $route);
|
||||||
|
|
||||||
$route = new Route(
|
$route = new Route(
|
||||||
$path . '/add/{source}/{target}',
|
$path . '/add/{source}/{target}',
|
||||||
|
|
|
@ -62,6 +62,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
|
||||||
// Create a translation.
|
// Create a translation.
|
||||||
$this->drupalLogin($this->translator);
|
$this->drupalLogin($this->translator);
|
||||||
$path = $this->entity->getSystemPath('drupal:content-translation-overview');
|
$path = $this->entity->getSystemPath('drupal:content-translation-overview');
|
||||||
|
|
||||||
$add_translation_path = $path . "/add/$default_langcode/{$this->langcodes[2]}";
|
$add_translation_path = $path . "/add/$default_langcode/{$this->langcodes[2]}";
|
||||||
$this->drupalPostForm($add_translation_path, array(), t('Save'));
|
$this->drupalPostForm($add_translation_path, array(), t('Save'));
|
||||||
$this->rebuildContainer();
|
$this->rebuildContainer();
|
||||||
|
|
|
@ -28,7 +28,7 @@ class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTest {
|
||||||
->method('getLinkTemplate')
|
->method('getLinkTemplate')
|
||||||
->will($this->returnValueMap(array(
|
->will($this->returnValueMap(array(
|
||||||
array('canonical', 'entity.node.canonical'),
|
array('canonical', 'entity.node.canonical'),
|
||||||
array('drupal:content-translation-overview', 'content_translation.translation_overview_node'),
|
array('drupal:content-translation-overview', 'entity.node.content_translation_overview'),
|
||||||
)));
|
)));
|
||||||
$content_translation_manager = $this->getMock('Drupal\content_translation\ContentTranslationManagerInterface');
|
$content_translation_manager = $this->getMock('Drupal\content_translation\ContentTranslationManagerInterface');
|
||||||
$content_translation_manager->expects($this->any())
|
$content_translation_manager->expects($this->any())
|
||||||
|
@ -54,14 +54,14 @@ class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTest {
|
||||||
public function providerTestBlockAdminDisplay() {
|
public function providerTestBlockAdminDisplay() {
|
||||||
return array(
|
return array(
|
||||||
array('entity.node.canonical', array(array(
|
array('entity.node.canonical', array(array(
|
||||||
'content_translation.local_tasks:content_translation.translation_overview_node',
|
'content_translation.local_tasks:entity.node.content_translation_overview',
|
||||||
'entity.node.canonical',
|
'entity.node.canonical',
|
||||||
'entity.node.edit_form',
|
'entity.node.edit_form',
|
||||||
'entity.node.delete_form',
|
'entity.node.delete_form',
|
||||||
'entity.node.version_history',
|
'entity.node.version_history',
|
||||||
))),
|
))),
|
||||||
array('content_translation.translation_overview_node', array(array(
|
array('entity.node.content_translation_overview', array(array(
|
||||||
'content_translation.local_tasks:content_translation.translation_overview_node',
|
'content_translation.local_tasks:entity.node.content_translation_overview',
|
||||||
'entity.node.canonical',
|
'entity.node.canonical',
|
||||||
'entity.node.edit_form',
|
'entity.node.edit_form',
|
||||||
'entity.node.delete_form',
|
'entity.node.delete_form',
|
||||||
|
|
|
@ -261,12 +261,12 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
|
||||||
protected function linkTemplates() {
|
protected function linkTemplates() {
|
||||||
$link_templates = parent::linkTemplates();
|
$link_templates = parent::linkTemplates();
|
||||||
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
|
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
|
||||||
$link_templates['edit-form'] = 'field_ui.field_edit_' . $this->entity_type;
|
$link_templates["{$this->entity_type}-field-edit-form"] = 'entity.field_config.' . $this->entity_type . '_field_edit_form';
|
||||||
$link_templates['storage-edit-form'] = 'field_ui.storage_edit_' . $this->entity_type;
|
$link_templates["{$this->entity_type}-storage-edit-form"] = 'entity.field_config.' . $this->entity_type . '_storage_edit_form';
|
||||||
$link_templates['delete-form'] = 'field_ui.delete_' . $this->entity_type;
|
$link_templates["{$this->entity_type}-field-delete-form"] = 'entity.field_config.' . $this->entity_type . '_field_delete_form';
|
||||||
|
|
||||||
if (isset($link_templates['drupal:config-translation-overview'])) {
|
if (isset($link_templates['config-translation-overview'])) {
|
||||||
$link_templates['drupal:config-translation-overview'] .= $link_templates['edit-form'];
|
$link_templates["config-translation-overview.{$this->entity_type}"] = "entity.field_config.config_translation_overview.{$this->entity_type}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $link_templates;
|
return $link_templates;
|
||||||
|
|
|
@ -51,7 +51,7 @@ function field_ui_help($route_name, RouteMatchInterface $route_match) {
|
||||||
$output .= '<dd>' . t('Fields on taxonomy terms are defined at the taxonomy vocabulary level, on the <em>Manage fields</em> tab of the vocabulary edit page (which you can reach from the <a href="@taxonomy">Taxonomy page</a>). When you define a field for a vocabulary, each term in that vocabulary will have that field added to it. For example, you could define an image field for a vocabulary to store an icon with each term.', array('@taxonomy' => \Drupal::url('taxonomy.vocabulary_list'))) . '</dd>';
|
$output .= '<dd>' . t('Fields on taxonomy terms are defined at the taxonomy vocabulary level, on the <em>Manage fields</em> tab of the vocabulary edit page (which you can reach from the <a href="@taxonomy">Taxonomy page</a>). When you define a field for a vocabulary, each term in that vocabulary will have that field added to it. For example, you could define an image field for a vocabulary to store an icon with each term.', array('@taxonomy' => \Drupal::url('taxonomy.vocabulary_list'))) . '</dd>';
|
||||||
}
|
}
|
||||||
$output .= '<dt>' . t('Fields on user accounts') . '</dt>';
|
$output .= '<dt>' . t('Fields on user accounts') . '</dt>';
|
||||||
$output .= '<dd>' . t('Fields on user accounts are defined on a site-wide basis on the <a href="@fields">Manage fields tab</a> of the <a href="@accounts">Account settings</a> page. When you define a field for user accounts, each user account will have that field added to it. For example, you could add a long text field to allow users to include a biography.', array('@fields' => \Drupal::url('field_ui.overview_user'), '@accounts' => \Drupal::url('entity.user.admin_form'))) . '</dd>';
|
$output .= '<dd>' . t('Fields on user accounts are defined on a site-wide basis on the <a href="@fields">Manage fields tab</a> of the <a href="@accounts">Account settings</a> page. When you define a field for user accounts, each user account will have that field added to it. For example, you could add a long text field to allow users to include a biography.', array('@fields' => \Drupal::url('entity.user.field_ui_fields'), '@accounts' => \Drupal::url('entity.user.admin_form'))) . '</dd>';
|
||||||
if ($module_handler->moduleExists('comment')) {
|
if ($module_handler->moduleExists('comment')) {
|
||||||
$output .= '<dt>' . t('Fields on comments') . '</dt>';
|
$output .= '<dt>' . t('Fields on comments') . '</dt>';
|
||||||
$output .= '<dd>' . t('Fields on comments are defined at the comment entity level, on the <em>Manage fields</em> tab of the comment types edit page (which you can reach from the <a href="@types">Comment types page</a>). When you add a field for comments, each comment on an entity with that comment type will have that field added to it. For example, you could add a website field to the comments on forum posts, to allow forum commenters to add a link to their website.', array('@types' => \Drupal::url('comment.type_list'))) . '</dd>';
|
$output .= '<dd>' . t('Fields on comments are defined at the comment entity level, on the <em>Manage fields</em> tab of the comment types edit page (which you can reach from the <a href="@types">Comment types page</a>). When you add a field for comments, each comment on an entity with that comment type will have that field added to it. For example, you could add a website field to the comments on forum posts, to allow forum commenters to add a link to their website.', array('@types' => \Drupal::url('comment.type_list'))) . '</dd>';
|
||||||
|
@ -91,10 +91,14 @@ function field_ui_entity_type_build(array &$entity_types) {
|
||||||
|
|
||||||
foreach ($entity_types as $entity_type) {
|
foreach ($entity_types as $entity_type) {
|
||||||
if ($bundle = $entity_type->getBundleOf()) {
|
if ($bundle = $entity_type->getBundleOf()) {
|
||||||
|
// To generate links in the UI we use the route names, so we don't have to
|
||||||
|
// know the exact required routes.
|
||||||
|
// This allows us to not require route information inside this hook, which
|
||||||
|
// otherwise could result in circular dependencies.
|
||||||
$entity_type
|
$entity_type
|
||||||
->setLinkTemplate('field_ui-fields', "field_ui.overview_$bundle")
|
->setLinkTemplate('field_ui-fields', "/admin/{$entity_type->id()}/fields")
|
||||||
->setLinkTemplate('field_ui-form-display', "field_ui.form_display_overview_$bundle")
|
->setLinkTemplate('field_ui-form-display', "/admin/{$entity_type->id()}/fields-form-display")
|
||||||
->setLinkTemplate('field_ui-display', "field_ui.display_overview_$bundle");
|
->setLinkTemplate('field_ui-display', "/admin/{$entity_type->id()}/fields-display");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,8 +304,8 @@ function field_ui_entity_type_alter(array &$entity_types) {
|
||||||
$form_mode->setFormClass('edit', 'Drupal\field_ui\Form\EntityDisplayModeEditForm');
|
$form_mode->setFormClass('edit', 'Drupal\field_ui\Form\EntityDisplayModeEditForm');
|
||||||
$form_mode->setFormClass('delete', 'Drupal\field_ui\Form\EntityDisplayModeDeleteForm');
|
$form_mode->setFormClass('delete', 'Drupal\field_ui\Form\EntityDisplayModeDeleteForm');
|
||||||
$form_mode->set('admin_permission', 'administer display modes');
|
$form_mode->set('admin_permission', 'administer display modes');
|
||||||
$form_mode->setLinkTemplate('delete-form', 'field_ui.entity_form_mode.delete_form');
|
$form_mode->setLinkTemplate('delete-form', '/admin/structure/display-modes/form/manage/{entity_form_mode}/delete');
|
||||||
$form_mode->setLinkTemplate('edit-form', 'field_ui.entity_form_mode.edit_form');
|
$form_mode->setLinkTemplate('edit-form', '/admin/structure/display-modes/form/manage/{entity_form_mode}');
|
||||||
|
|
||||||
$view_mode = $entity_types['entity_view_mode'];
|
$view_mode = $entity_types['entity_view_mode'];
|
||||||
$view_mode->setListBuilderClass('Drupal\field_ui\EntityDisplayModeListBuilder');
|
$view_mode->setListBuilderClass('Drupal\field_ui\EntityDisplayModeListBuilder');
|
||||||
|
@ -309,6 +313,6 @@ function field_ui_entity_type_alter(array &$entity_types) {
|
||||||
$view_mode->setFormClass('edit', 'Drupal\field_ui\Form\EntityDisplayModeEditForm');
|
$view_mode->setFormClass('edit', 'Drupal\field_ui\Form\EntityDisplayModeEditForm');
|
||||||
$view_mode->setFormClass('delete', 'Drupal\field_ui\Form\EntityDisplayModeDeleteForm');
|
$view_mode->setFormClass('delete', 'Drupal\field_ui\Form\EntityDisplayModeDeleteForm');
|
||||||
$view_mode->set('admin_permission', 'administer display modes');
|
$view_mode->set('admin_permission', 'administer display modes');
|
||||||
$view_mode->setLinkTemplate('delete-form', 'field_ui.entity_view_mode.delete_form');
|
$view_mode->setLinkTemplate('delete-form', '/admin/structure/display-modes/view/manage/{entity_view_mode}/delete');
|
||||||
$view_mode->setLinkTemplate('edit-form', 'field_ui.entity_view_mode.edit_form');
|
$view_mode->setLinkTemplate('edit-form', '/admin/structure/display-modes/view/manage/{entity_view_mode}');
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ field_ui.entity_view_mode_add_type:
|
||||||
requirements:
|
requirements:
|
||||||
_permission: 'administer display modes'
|
_permission: 'administer display modes'
|
||||||
|
|
||||||
field_ui.entity_view_mode.edit_form:
|
entity.entity_view_mode.edit_form:
|
||||||
path: '/admin/structure/display-modes/view/manage/{entity_view_mode}'
|
path: '/admin/structure/display-modes/view/manage/{entity_view_mode}'
|
||||||
defaults:
|
defaults:
|
||||||
_entity_form: 'entity_view_mode.edit'
|
_entity_form: 'entity_view_mode.edit'
|
||||||
|
@ -46,7 +46,7 @@ field_ui.entity_view_mode.edit_form:
|
||||||
requirements:
|
requirements:
|
||||||
_entity_access: 'entity_view_mode.update'
|
_entity_access: 'entity_view_mode.update'
|
||||||
|
|
||||||
field_ui.entity_view_mode.delete_form:
|
entity.entity_view_mode.delete_form:
|
||||||
path: '/admin/structure/display-modes/view/manage/{entity_view_mode}/delete'
|
path: '/admin/structure/display-modes/view/manage/{entity_view_mode}/delete'
|
||||||
defaults:
|
defaults:
|
||||||
_entity_form: 'entity_view_mode.delete'
|
_entity_form: 'entity_view_mode.delete'
|
||||||
|
@ -78,7 +78,7 @@ field_ui.entity_form_mode_add_type:
|
||||||
requirements:
|
requirements:
|
||||||
_permission: 'administer display modes'
|
_permission: 'administer display modes'
|
||||||
|
|
||||||
field_ui.entity_form_mode.edit_form:
|
entity.entity_form_mode.edit_form:
|
||||||
path: '/admin/structure/display-modes/form/manage/{entity_form_mode}'
|
path: '/admin/structure/display-modes/form/manage/{entity_form_mode}'
|
||||||
defaults:
|
defaults:
|
||||||
_entity_form: 'entity_form_mode.edit'
|
_entity_form: 'entity_form_mode.edit'
|
||||||
|
@ -86,7 +86,7 @@ field_ui.entity_form_mode.edit_form:
|
||||||
requirements:
|
requirements:
|
||||||
_entity_access: 'entity_form_mode.update'
|
_entity_access: 'entity_form_mode.update'
|
||||||
|
|
||||||
field_ui.entity_form_mode.delete_form:
|
entity.entity_form_mode.delete_form:
|
||||||
path: '/admin/structure/display-modes/form/manage/{entity_form_mode}/delete'
|
path: '/admin/structure/display-modes/form/manage/{entity_form_mode}/delete'
|
||||||
defaults:
|
defaults:
|
||||||
_entity_form: 'entity_form_mode.delete'
|
_entity_form: 'entity_form_mode.delete'
|
||||||
|
|
|
@ -203,7 +203,9 @@ class DisplayOverview extends DisplayOverviewBase {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getOverviewRoute($mode) {
|
protected function getOverviewRoute($mode) {
|
||||||
return Url::fromRoute('field_ui.display_overview_view_mode_' . $this->entity_type, [
|
$entity_type = $this->entityManager->getDefinition($this->entity_type);
|
||||||
|
$field_entity_type = $entity_type->getBundleEntityType() != 'bundle'? $entity_type->getBundleEntityType() : $entity_type->id();
|
||||||
|
return Url::fromRoute('field_ui.display_overview_view_mode_' . $field_entity_type, [
|
||||||
$this->bundleEntityTypeId => $this->bundle,
|
$this->bundleEntityTypeId => $this->bundle,
|
||||||
'view_mode_name' => $mode,
|
'view_mode_name' => $mode,
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -139,7 +139,7 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
|
||||||
'data' => array(
|
'data' => array(
|
||||||
'#type' => 'link',
|
'#type' => 'link',
|
||||||
'#title' => $this->fieldTypeManager->getDefinitions()[$field_storage->getType()]['label'],
|
'#title' => $this->fieldTypeManager->getDefinitions()[$field_storage->getType()]['label'],
|
||||||
'#url' => Url::fromRoute('field_ui.storage_edit_' . $this->targetEntityTypeId, $route_parameters),
|
'#url' => Url::fromRoute("entity.field_config.{$this->targetEntityTypeId}_storage_edit_form", $route_parameters),
|
||||||
'#options' => array('attributes' => array('title' => $this->t('Edit field settings.'))),
|
'#options' => array('attributes' => array('title' => $this->t('Edit field settings.'))),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -164,11 +164,24 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
|
||||||
/** @var \Drupal\field\FieldConfigInterface $entity */
|
/** @var \Drupal\field\FieldConfigInterface $entity */
|
||||||
$operations = parent::getDefaultOperations($entity);
|
$operations = parent::getDefaultOperations($entity);
|
||||||
|
|
||||||
|
if ($entity->access('update') && $entity->hasLinkTemplate("{$entity->entity_type}-field-edit-form")) {
|
||||||
|
$operations['edit'] = array(
|
||||||
|
'title' => $this->t('Edit'),
|
||||||
|
'weight' => 10,
|
||||||
|
) + $entity->urlInfo("{$entity->entity_type}-field-edit-form")->toArray();
|
||||||
|
}
|
||||||
|
if ($entity->access('delete') && $entity->hasLinkTemplate("{$entity->entity_type}-field-delete-form")) {
|
||||||
|
$operations['delete'] = array(
|
||||||
|
'title' => $this->t('Delete'),
|
||||||
|
'weight' => 100,
|
||||||
|
) + $entity->urlInfo("{$entity->entity_type}-field-delete-form")->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
$operations['storage-settings'] = array(
|
$operations['storage-settings'] = array(
|
||||||
'title' => $this->t('Storage settings'),
|
'title' => $this->t('Storage settings'),
|
||||||
'weight' => 20,
|
'weight' => 20,
|
||||||
'attributes' => array('title' => $this->t('Edit storage settings.')),
|
'attributes' => array('title' => $this->t('Edit storage settings.')),
|
||||||
'url' => $entity->urlInfo('storage-edit-form'),
|
'url' => $entity->urlInfo("{$entity->entity_type}-storage-edit-form"),
|
||||||
);
|
);
|
||||||
$operations['edit']['attributes']['title'] = $this->t('Edit field settings.');
|
$operations['edit']['attributes']['title'] = $this->t('Edit field settings.');
|
||||||
$operations['delete']['attributes']['title'] = $this->t('Delete field.');
|
$operations['delete']['attributes']['title'] = $this->t('Delete field.');
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
namespace Drupal\field_ui;
|
namespace Drupal\field_ui;
|
||||||
|
|
||||||
use Drupal\Component\Utility\UrlHelper;
|
use Drupal\Component\Utility\UrlHelper;
|
||||||
|
use Drupal\Core\Entity\EntityType;
|
||||||
use Drupal\Core\Url;
|
use Drupal\Core\Url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +30,8 @@ class FieldUI {
|
||||||
public static function getOverviewRouteInfo($entity_type_id, $bundle) {
|
public static function getOverviewRouteInfo($entity_type_id, $bundle) {
|
||||||
$entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
|
$entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
|
||||||
if ($entity_type->get('field_ui_base_route')) {
|
if ($entity_type->get('field_ui_base_route')) {
|
||||||
return new Url("field_ui.overview_$entity_type_id", array(
|
$bundle_entity_type = static::getRouteBundleEntityType($entity_type);
|
||||||
|
return new Url("entity.{$bundle_entity_type}.field_ui_fields", array(
|
||||||
$entity_type->getBundleEntityType() => $bundle,
|
$entity_type->getBundleEntityType() => $bundle,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -66,4 +68,18 @@ class FieldUI {
|
||||||
return $next_destination;
|
return $next_destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the bundle entity type used for route names.
|
||||||
|
*
|
||||||
|
* This method returns the bundle entity type, in case there is one.
|
||||||
|
*
|
||||||
|
* @param \Drupal\Core\Entity\EntityType $entity_type
|
||||||
|
* The actual entity type, not the bundle.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* The used entity type ID in the route name.
|
||||||
|
*/
|
||||||
|
public static function getRouteBundleEntityType(EntityType $entity_type) {
|
||||||
|
return $entity_type->getBundleEntityType() != 'bundle' ? $entity_type->getBundleEntityType() : $entity_type->id();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,7 @@ class FieldEditForm extends FormBase {
|
||||||
}
|
}
|
||||||
$entity_type = $this->entityManager->getDefinition($this->field->entity_type);
|
$entity_type = $this->entityManager->getDefinition($this->field->entity_type);
|
||||||
$form_state->setRedirect(
|
$form_state->setRedirect(
|
||||||
'field_ui.delete_' . $this->field->entity_type,
|
'entity.field_config.' . $this->field->entity_type . '_field_delete_form',
|
||||||
array(
|
array(
|
||||||
$entity_type->getBundleEntityType() => $this->field->bundle,
|
$entity_type->getBundleEntityType() => $this->field->bundle,
|
||||||
'field_config' => $this->field->id(),
|
'field_config' => $this->field->id(),
|
||||||
|
|
|
@ -322,6 +322,8 @@ class FieldStorageAddForm extends FormBase {
|
||||||
$error = FALSE;
|
$error = FALSE;
|
||||||
$values = $form_state->getValues();
|
$values = $form_state->getValues();
|
||||||
$destinations = array();
|
$destinations = array();
|
||||||
|
$entity_type = $this->entityManager->getDefinition($this->entityTypeId);
|
||||||
|
$bundle_entity_type = FieldUI::getRouteBundleEntityType($entity_type);
|
||||||
|
|
||||||
// Create new field.
|
// Create new field.
|
||||||
if ($values['new_storage_type']) {
|
if ($values['new_storage_type']) {
|
||||||
|
@ -352,9 +354,9 @@ class FieldStorageAddForm extends FormBase {
|
||||||
$this->bundleEntityTypeId => $this->bundle,
|
$this->bundleEntityTypeId => $this->bundle,
|
||||||
'field_config' => $field->id(),
|
'field_config' => $field->id(),
|
||||||
);
|
);
|
||||||
$destinations[] = array('route_name' => 'field_ui.storage_edit_' . $this->entityTypeId, 'route_parameters' => $route_parameters);
|
$destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_storage_edit_form", 'route_parameters' => $route_parameters);
|
||||||
$destinations[] = array('route_name' => 'field_ui.field_edit_' . $this->entityTypeId, 'route_parameters' => $route_parameters);
|
$destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_field_edit_form", 'route_parameters' => $route_parameters);
|
||||||
$destinations[] = array('route_name' => 'field_ui.overview_' . $this->entityTypeId, 'route_parameters' => $route_parameters);
|
$destinations[] = array('route_name' => "entity.{$bundle_entity_type}.field_ui_fields", 'route_parameters' => $route_parameters);
|
||||||
|
|
||||||
// Store new field information for any additional submit handlers.
|
// Store new field information for any additional submit handlers.
|
||||||
$form_state->set(['fields_added', '_add_new_field'], $values['field_name']);
|
$form_state->set(['fields_added', '_add_new_field'], $values['field_name']);
|
||||||
|
@ -384,8 +386,8 @@ class FieldStorageAddForm extends FormBase {
|
||||||
$this->bundleEntityTypeId => $this->bundle,
|
$this->bundleEntityTypeId => $this->bundle,
|
||||||
'field_config' => $field->id(),
|
'field_config' => $field->id(),
|
||||||
);
|
);
|
||||||
$destinations[] = array('route_name' => 'field_ui.field_edit_' . $this->entityTypeId, 'route_parameters' => $route_parameters);
|
$destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_field_edit_form", 'route_parameters' => $route_parameters);
|
||||||
$destinations[] = array('route_name' => 'field_ui.overview_' . $this->entityTypeId, 'route_parameters' => $route_parameters);
|
$destinations[] = array('route_name' => "entity.{$bundle_entity_type}.field_ui_fields", 'route_parameters' => $route_parameters);
|
||||||
|
|
||||||
// Store new field information for any additional submit handlers.
|
// Store new field information for any additional submit handlers.
|
||||||
$form_state->set(['fields_added', '_add_existing_field'], $field_name);
|
$form_state->set(['fields_added', '_add_existing_field'], $field_name);
|
||||||
|
|
|
@ -168,7 +168,9 @@ class FormDisplayOverview extends DisplayOverviewBase {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getOverviewRoute($mode) {
|
protected function getOverviewRoute($mode) {
|
||||||
return Url::fromRoute('field_ui.form_display_overview_form_mode_' . $this->entity_type, [
|
$entity_type = $this->entityManager->getDefinition($this->entity_type);
|
||||||
|
$field_entity_type = $entity_type->getBundleEntityType() != 'bundle'? $entity_type->getBundleEntityType() : $entity_type->id();
|
||||||
|
return Url::fromRoute('field_ui.form_display_overview_form_mode_' . $field_entity_type, [
|
||||||
$this->bundleEntityTypeId => $this->bundle,
|
$this->bundleEntityTypeId => $this->bundle,
|
||||||
'form_mode_name' => $mode,
|
'form_mode_name' => $mode,
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -12,6 +12,7 @@ use Drupal\Core\Entity\EntityManagerInterface;
|
||||||
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
|
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
|
||||||
use Drupal\Core\Routing\RouteProviderInterface;
|
use Drupal\Core\Routing\RouteProviderInterface;
|
||||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||||
|
use Drupal\field_ui\FieldUI;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,10 +60,11 @@ class FieldUiLocalAction extends DeriverBase implements ContainerDeriverInterfac
|
||||||
|
|
||||||
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
|
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||||
if ($entity_type->get('field_ui_base_route')) {
|
if ($entity_type->get('field_ui_base_route')) {
|
||||||
|
$bundle_entity_type = FieldUI::getRouteBundleEntityType($entity_type);
|
||||||
$this->derivatives["field_storage_config_add_$entity_type_id"] = array(
|
$this->derivatives["field_storage_config_add_$entity_type_id"] = array(
|
||||||
'route_name' => "field_ui.field_storage_config_add_$entity_type_id",
|
'route_name' => "field_ui.field_storage_config_add_$entity_type_id",
|
||||||
'title' => $this->t('Add field'),
|
'title' => $this->t('Add field'),
|
||||||
'appears_on' => array("field_ui.overview_$entity_type_id"),
|
'appears_on' => array("entity.$bundle_entity_type.field_ui_fields"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
|
||||||
use Drupal\Core\Routing\RouteProviderInterface;
|
use Drupal\Core\Routing\RouteProviderInterface;
|
||||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||||
use Drupal\Core\StringTranslation\TranslationInterface;
|
use Drupal\Core\StringTranslation\TranslationInterface;
|
||||||
|
use Drupal\field_ui\FieldUI;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,41 +71,43 @@ class FieldUiLocalTask extends DeriverBase implements ContainerDeriverInterface
|
||||||
|
|
||||||
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
|
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||||
if ($entity_type->get('field_ui_base_route')) {
|
if ($entity_type->get('field_ui_base_route')) {
|
||||||
$this->derivatives["overview_$entity_type_id"] = array(
|
$field_entity_type = FieldUI::getRouteBundleEntityType($entity_type);
|
||||||
'route_name' => "field_ui.overview_$entity_type_id",
|
|
||||||
|
$this->derivatives["overview_$field_entity_type"] = array(
|
||||||
|
'route_name' => "entity.$field_entity_type.field_ui_fields",
|
||||||
'weight' => 1,
|
'weight' => 1,
|
||||||
'title' => $this->t('Manage fields'),
|
'title' => $this->t('Manage fields'),
|
||||||
'base_route' => "field_ui.overview_$entity_type_id",
|
'base_route' => "entity.$field_entity_type.field_ui_fields",
|
||||||
);
|
);
|
||||||
|
|
||||||
// 'Manage form display' tab.
|
// 'Manage form display' tab.
|
||||||
$this->derivatives["form_display_overview_$entity_type_id"] = array(
|
$this->derivatives["form_display_overview_$field_entity_type"] = array(
|
||||||
'route_name' => "field_ui.form_display_overview_$entity_type_id",
|
'route_name' => "entity.{$field_entity_type}.field_ui_form_display",
|
||||||
'weight' => 2,
|
'weight' => 2,
|
||||||
'title' => $this->t('Manage form display'),
|
'title' => $this->t('Manage form display'),
|
||||||
'base_route' => "field_ui.overview_$entity_type_id",
|
'base_route' => "entity.$field_entity_type.field_ui_fields",
|
||||||
);
|
);
|
||||||
|
|
||||||
// 'Manage display' tab.
|
// 'Manage display' tab.
|
||||||
$this->derivatives["display_overview_$entity_type_id"] = array(
|
$this->derivatives["display_overview_$field_entity_type"] = array(
|
||||||
'route_name' => "field_ui.display_overview_$entity_type_id",
|
'route_name' => "entity.{$field_entity_type}.field_ui_display",
|
||||||
'weight' => 3,
|
'weight' => 3,
|
||||||
'title' => $this->t('Manage display'),
|
'title' => $this->t('Manage display'),
|
||||||
'base_route' => "field_ui.overview_$entity_type_id",
|
'base_route' => "entity.$field_entity_type.field_ui_fields",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Field edit tab.
|
// Field edit tab.
|
||||||
$this->derivatives["field_edit_$entity_type_id"] = array(
|
$this->derivatives["field_edit_$entity_type_id"] = array(
|
||||||
'route_name' => "field_ui.field_edit_$entity_type_id",
|
'route_name' => "entity.field_config.{$entity_type_id}_field_edit_form",
|
||||||
'title' => $this->t('Edit'),
|
'title' => $this->t('Edit'),
|
||||||
'base_route' => "field_ui.field_edit_$entity_type_id",
|
'base_route' => "entity.field_config.{$entity_type_id}_field_edit_form",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Field settings tab.
|
// Field settings tab.
|
||||||
$this->derivatives["field_storage_$entity_type_id"] = array(
|
$this->derivatives["field_storage_$entity_type_id"] = array(
|
||||||
'route_name' => "field_ui.storage_edit_$entity_type_id",
|
'route_name' => "entity.field_config.{$entity_type_id}_storage_edit_form",
|
||||||
'title' => $this->t('Field settings'),
|
'title' => $this->t('Field settings'),
|
||||||
'base_route' => "field_ui.field_edit_$entity_type_id",
|
'base_route' => "entity.field_config.{$entity_type_id}_field_edit_form",
|
||||||
);
|
);
|
||||||
|
|
||||||
// View and form modes secondary tabs.
|
// View and form modes secondary tabs.
|
||||||
|
@ -114,29 +117,29 @@ class FieldUiLocalTask extends DeriverBase implements ContainerDeriverInterface
|
||||||
// modes available for customisation. So we define menu items for all
|
// modes available for customisation. So we define menu items for all
|
||||||
// view modes, and use a route requirement to determine which ones are
|
// view modes, and use a route requirement to determine which ones are
|
||||||
// actually visible for a given bundle.
|
// actually visible for a given bundle.
|
||||||
$this->derivatives['field_form_display_default_' . $entity_type_id] = array(
|
$this->derivatives['field_form_display_default_' . $field_entity_type] = array(
|
||||||
'title' => 'Default',
|
'title' => 'Default',
|
||||||
'route_name' => "field_ui.form_display_overview_$entity_type_id",
|
'route_name' => "entity.{$field_entity_type}.field_ui_form_display",
|
||||||
'parent_id' => "field_ui.fields:form_display_overview_$entity_type_id",
|
'parent_id' => "field_ui.fields:form_display_overview_$field_entity_type",
|
||||||
'weight' => -1,
|
'weight' => -1,
|
||||||
);
|
);
|
||||||
$this->derivatives['field_display_default_' . $entity_type_id] = array(
|
$this->derivatives['field_display_default_' . $field_entity_type] = array(
|
||||||
'title' => 'Default',
|
'title' => 'Default',
|
||||||
'route_name' => "field_ui.display_overview_$entity_type_id",
|
'route_name' => "entity.{$field_entity_type}.field_ui_display",
|
||||||
'parent_id' => "field_ui.fields:display_overview_$entity_type_id",
|
'parent_id' => "field_ui.fields:display_overview_$field_entity_type",
|
||||||
'weight' => -1,
|
'weight' => -1,
|
||||||
);
|
);
|
||||||
|
|
||||||
// One local task for each form mode.
|
// One local task for each form mode.
|
||||||
$weight = 0;
|
$weight = 0;
|
||||||
foreach ($this->entityManager->getFormModes($entity_type_id) as $form_mode => $form_mode_info) {
|
foreach ($this->entityManager->getFormModes($entity_type_id) as $form_mode => $form_mode_info) {
|
||||||
$this->derivatives['field_form_display_' . $form_mode . '_' . $entity_type_id] = array(
|
$this->derivatives['field_form_display_' . $form_mode . '_' . $field_entity_type] = array(
|
||||||
'title' => $form_mode_info['label'],
|
'title' => $form_mode_info['label'],
|
||||||
'route_name' => "field_ui.form_display_overview_form_mode_$entity_type_id",
|
'route_name' => "field_ui.form_display_overview_form_mode_$field_entity_type",
|
||||||
'route_parameters' => array(
|
'route_parameters' => array(
|
||||||
'form_mode_name' => $form_mode,
|
'form_mode_name' => $form_mode,
|
||||||
),
|
),
|
||||||
'parent_id' => "field_ui.fields:form_display_overview_$entity_type_id",
|
'parent_id' => "field_ui.fields:form_display_overview_$field_entity_type",
|
||||||
'weight' => $weight++,
|
'weight' => $weight++,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -144,13 +147,13 @@ class FieldUiLocalTask extends DeriverBase implements ContainerDeriverInterface
|
||||||
// One local task for each view mode.
|
// One local task for each view mode.
|
||||||
$weight = 0;
|
$weight = 0;
|
||||||
foreach ($this->entityManager->getViewModes($entity_type_id) as $view_mode => $form_mode_info) {
|
foreach ($this->entityManager->getViewModes($entity_type_id) as $view_mode => $form_mode_info) {
|
||||||
$this->derivatives['field_display_' . $view_mode . '_' . $entity_type_id] = array(
|
$this->derivatives['field_display_' . $view_mode . '_' . $field_entity_type] = array(
|
||||||
'title' => $form_mode_info['label'],
|
'title' => $form_mode_info['label'],
|
||||||
'route_name' => "field_ui.display_overview_view_mode_$entity_type_id",
|
'route_name' => "field_ui.display_overview_view_mode_$field_entity_type",
|
||||||
'route_parameters' => array(
|
'route_parameters' => array(
|
||||||
'view_mode_name' => $view_mode,
|
'view_mode_name' => $view_mode,
|
||||||
),
|
),
|
||||||
'parent_id' => "field_ui.fields:display_overview_$entity_type_id",
|
'parent_id' => "field_ui.fields:display_overview_$field_entity_type",
|
||||||
'weight' => $weight++,
|
'weight' => $weight++,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -172,19 +175,21 @@ class FieldUiLocalTask extends DeriverBase implements ContainerDeriverInterface
|
||||||
*/
|
*/
|
||||||
public function alterLocalTasks(&$local_tasks) {
|
public function alterLocalTasks(&$local_tasks) {
|
||||||
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
|
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
|
||||||
|
$field_entity_type = FieldUI::getRouteBundleEntityType($entity_type);
|
||||||
|
|
||||||
if ($route_name = $entity_type->get('field_ui_base_route')) {
|
if ($route_name = $entity_type->get('field_ui_base_route')) {
|
||||||
$local_tasks["field_ui.fields:overview_$entity_type_id"]['base_route'] = $route_name;
|
$local_tasks["field_ui.fields:overview_$field_entity_type"]['base_route'] = $route_name;
|
||||||
$local_tasks["field_ui.fields:form_display_overview_$entity_type_id"]['base_route'] = $route_name;
|
$local_tasks["field_ui.fields:form_display_overview_$field_entity_type"]['base_route'] = $route_name;
|
||||||
$local_tasks["field_ui.fields:display_overview_$entity_type_id"]['base_route'] = $route_name;
|
$local_tasks["field_ui.fields:display_overview_$field_entity_type"]['base_route'] = $route_name;
|
||||||
$local_tasks["field_ui.fields:field_form_display_default_$entity_type_id"]['base_route'] = $route_name;
|
$local_tasks["field_ui.fields:field_form_display_default_$field_entity_type"]['base_route'] = $route_name;
|
||||||
$local_tasks["field_ui.fields:field_display_default_$entity_type_id"]['base_route'] = $route_name;
|
$local_tasks["field_ui.fields:field_display_default_$field_entity_type"]['base_route'] = $route_name;
|
||||||
|
|
||||||
foreach ($this->entityManager->getFormModes($entity_type_id) as $form_mode => $form_mode_info) {
|
foreach ($this->entityManager->getFormModes($entity_type_id) as $form_mode => $form_mode_info) {
|
||||||
$local_tasks['field_ui.fields:field_form_display_' . $form_mode . '_' . $entity_type_id]['base_route'] = $route_name;
|
$local_tasks['field_ui.fields:field_form_display_' . $form_mode . '_' . $field_entity_type]['base_route'] = $route_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->entityManager->getViewModes($entity_type_id) as $view_mode => $form_mode_info) {
|
foreach ($this->entityManager->getViewModes($entity_type_id) as $view_mode => $form_mode_info) {
|
||||||
$local_tasks['field_ui.fields:field_display_' . $view_mode . '_' . $entity_type_id]['base_route'] = $route_name;
|
$local_tasks['field_ui.fields:field_display_' . $view_mode . '_' . $field_entity_type]['base_route'] = $route_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,9 @@ class RouteSubscriber extends RouteSubscriberBase {
|
||||||
'type' => 'entity:' . $entity_type->getBundleEntityType(),
|
'type' => 'entity:' . $entity_type->getBundleEntityType(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
elseif ($bundle_entity_type == 'bundle') {
|
||||||
|
$bundle_entity_type = $entity_type_id;
|
||||||
|
}
|
||||||
|
|
||||||
$route = new Route(
|
$route = new Route(
|
||||||
"$path/fields/{field_config}",
|
"$path/fields/{field_config}",
|
||||||
|
@ -64,7 +67,7 @@ class RouteSubscriber extends RouteSubscriberBase {
|
||||||
array('_entity_access' => 'field_config.update'),
|
array('_entity_access' => 'field_config.update'),
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
$collection->add("field_ui.field_edit_$entity_type_id", $route);
|
$collection->add("entity.field_config.{$entity_type_id}_field_edit_form", $route);
|
||||||
|
|
||||||
$route = new Route(
|
$route = new Route(
|
||||||
"$path/fields/{field_config}/storage",
|
"$path/fields/{field_config}/storage",
|
||||||
|
@ -72,7 +75,7 @@ class RouteSubscriber extends RouteSubscriberBase {
|
||||||
array('_entity_access' => 'field_config.update'),
|
array('_entity_access' => 'field_config.update'),
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
$collection->add("field_ui.storage_edit_$entity_type_id", $route);
|
$collection->add("entity.field_config.{$entity_type_id}_storage_edit_form", $route);
|
||||||
|
|
||||||
$route = new Route(
|
$route = new Route(
|
||||||
"$path/fields/{field_config}/delete",
|
"$path/fields/{field_config}/delete",
|
||||||
|
@ -80,7 +83,7 @@ class RouteSubscriber extends RouteSubscriberBase {
|
||||||
array('_entity_access' => 'field_config.delete'),
|
array('_entity_access' => 'field_config.delete'),
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
$collection->add("field_ui.delete_$entity_type_id", $route);
|
$collection->add("entity.field_config.{$entity_type_id}_field_delete_form", $route);
|
||||||
|
|
||||||
// If the entity type has no bundles, use the entity type.
|
// If the entity type has no bundles, use the entity type.
|
||||||
$defaults['entity_type_id'] = $entity_type_id;
|
$defaults['entity_type_id'] = $entity_type_id;
|
||||||
|
@ -96,7 +99,7 @@ class RouteSubscriber extends RouteSubscriberBase {
|
||||||
array('_permission' => 'administer ' . $entity_type_id . ' fields'),
|
array('_permission' => 'administer ' . $entity_type_id . ' fields'),
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
$collection->add("field_ui.overview_$entity_type_id", $route);
|
$collection->add("entity.$bundle_entity_type.field_ui_fields", $route);
|
||||||
|
|
||||||
$route = new Route(
|
$route = new Route(
|
||||||
"$path/fields/add-field",
|
"$path/fields/add-field",
|
||||||
|
@ -117,7 +120,7 @@ class RouteSubscriber extends RouteSubscriberBase {
|
||||||
array('_field_ui_form_mode_access' => 'administer ' . $entity_type_id . ' form display'),
|
array('_field_ui_form_mode_access' => 'administer ' . $entity_type_id . ' form display'),
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
$collection->add("field_ui.form_display_overview_$entity_type_id", $route);
|
$collection->add("entity.{$bundle_entity_type}.field_ui_form_display", $route);
|
||||||
|
|
||||||
$route = new Route(
|
$route = new Route(
|
||||||
"$path/form-display/{form_mode_name}",
|
"$path/form-display/{form_mode_name}",
|
||||||
|
@ -128,7 +131,7 @@ class RouteSubscriber extends RouteSubscriberBase {
|
||||||
array('_field_ui_form_mode_access' => 'administer ' . $entity_type_id . ' form display'),
|
array('_field_ui_form_mode_access' => 'administer ' . $entity_type_id . ' form display'),
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
$collection->add("field_ui.form_display_overview_form_mode_$entity_type_id", $route);
|
$collection->add("field_ui.form_display_overview_form_mode_$bundle_entity_type", $route);
|
||||||
|
|
||||||
$route = new Route(
|
$route = new Route(
|
||||||
"$path/display",
|
"$path/display",
|
||||||
|
@ -139,7 +142,7 @@ class RouteSubscriber extends RouteSubscriberBase {
|
||||||
array('_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'),
|
array('_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'),
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
$collection->add("field_ui.display_overview_$entity_type_id", $route);
|
$collection->add("entity.{$bundle_entity_type}.field_ui_display", $route);
|
||||||
|
|
||||||
$route = new Route(
|
$route = new Route(
|
||||||
"$path/display/{view_mode_name}",
|
"$path/display/{view_mode_name}",
|
||||||
|
@ -150,7 +153,7 @@ class RouteSubscriber extends RouteSubscriberBase {
|
||||||
array('_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'),
|
array('_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'),
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
$collection->add("field_ui.display_overview_view_mode_$entity_type_id", $route);
|
$collection->add("field_ui.display_overview_view_mode_$bundle_entity_type", $route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,7 +379,7 @@ class ManageDisplayTest extends WebTestBase {
|
||||||
))->save();
|
))->save();
|
||||||
|
|
||||||
$this->drupalGet('admin/structure/types/manage/no_fields/display');
|
$this->drupalGet('admin/structure/types/manage/no_fields/display');
|
||||||
$this->assertRaw(t('There are no fields yet added. You can add new fields on the <a href="@link">Manage fields</a> page.', array('@link' => \Drupal::url('field_ui.overview_node', array('node_type' => 'no_fields')))));
|
$this->assertRaw(t('There are no fields yet added. You can add new fields on the <a href="@link">Manage fields</a> page.', array('@link' => \Drupal::url('entity.node_type.field_ui_fields', array('node_type' => 'no_fields')))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,8 +39,8 @@ use Drupal\filter\Plugin\FilterInterface;
|
||||||
* "status" = "status"
|
* "status" = "status"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "edit-form" = "entity.filter_format.edit_form",
|
* "edit-form" = "/admin/config/content/formats/manage/{filter_format}",
|
||||||
* "disable" = "entity.filter_format.disable"
|
* "disable" = "/admin/config/content/formats/manage/{filter_format}/disable"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -108,9 +108,9 @@ function forum_entity_type_build(array &$entity_types) {
|
||||||
$entity_types['taxonomy_term']
|
$entity_types['taxonomy_term']
|
||||||
->setFormClass('forum', 'Drupal\forum\Form\ForumForm')
|
->setFormClass('forum', 'Drupal\forum\Form\ForumForm')
|
||||||
->setFormClass('container', 'Drupal\forum\Form\ContainerForm')
|
->setFormClass('container', 'Drupal\forum\Form\ContainerForm')
|
||||||
->setLinkTemplate('forum-delete-form', 'entity.taxonomy_term.forum_delete_form')
|
->setLinkTemplate('forum-edit-container-form', '/admin/structure/forum/edit/container/{taxonomy_term}')
|
||||||
->setLinkTemplate('forum-edit-container-form', 'entity.taxonomy_term.forum_edit_container_form')
|
->setLinkTemplate('forum-delete-form', '/admin/structure/forum/delete/forum/{taxonomy_term}')
|
||||||
->setLinkTemplate('forum-edit-form', 'entity.taxonomy_term.forum_edit_form');
|
->setLinkTemplate('forum-edit-form', '/admin/structure/forum/edit/forum/{taxonomy_term}');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,9 +44,9 @@ use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||||
* "label" = "label"
|
* "label" = "label"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "flush-form" = "entity.image_style.flush_form",
|
* "flush-form" = "/admin/config/media/image-styles/manage/{image_style}/flush",
|
||||||
* "edit-form" = "entity.image_style.edit_form",
|
* "edit-form" = "/admin/config/media/image-styles/manage/{image_style}",
|
||||||
* "delete-form" = "entity.image_style.delete_form"
|
* "delete-form" = "/admin/config/media/image-styles/manage/{image_style}/delete"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -38,8 +38,8 @@ use Drupal\language\ConfigurableLanguageInterface;
|
||||||
* "weight" = "weight"
|
* "weight" = "weight"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "delete-form" = "entity.configurable_language.delete_form",
|
* "delete-form" = "/admin/config/regional/language/delete/{configurable_language}",
|
||||||
* "edit-form" = "entity.configurable_language.edit_form"
|
* "edit-form" = "/admin/config/regional/language/edit/{configurable_language}"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -14,6 +14,14 @@ entity.menu_link_content.canonical:
|
||||||
requirements:
|
requirements:
|
||||||
_entity_access: 'menu_link_content.update'
|
_entity_access: 'menu_link_content.update'
|
||||||
|
|
||||||
|
entity.menu_link_content.edit_form:
|
||||||
|
path: '/admin/structure/menu/item/{menu_link_content}/edit'
|
||||||
|
defaults:
|
||||||
|
_entity_form: 'menu_link_content.default'
|
||||||
|
_title: 'Edit menu link'
|
||||||
|
requirements:
|
||||||
|
_entity_access: 'menu_link_content.update'
|
||||||
|
|
||||||
entity.menu_link_content.delete_form:
|
entity.menu_link_content.delete_form:
|
||||||
path: '/admin/structure/menu/item/{menu_link_content}/delete'
|
path: '/admin/structure/menu/item/{menu_link_content}/delete'
|
||||||
defaults:
|
defaults:
|
||||||
|
|
|
@ -40,9 +40,9 @@ use Drupal\menu_link_content\MenuLinkContentInterface;
|
||||||
* "bundle" = "bundle"
|
* "bundle" = "bundle"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.menu_link_content.canonical",
|
* "canonical" = "/admin/structure/menu/item/{menu_link_content}/edit",
|
||||||
* "edit-form" = "entity.menu_link_content.canonical",
|
* "edit-form" = "/admin/structure/menu/item/{menu_link_content}/edit",
|
||||||
* "delete-form" = "entity.menu_link_content.delete_form",
|
* "delete-form" = "/admin/structure/menu/item/{menu_link_content}/delete",
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -194,7 +194,7 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getTranslateRoute() {
|
public function getTranslateRoute() {
|
||||||
return $this->getEntity()->urlInfo('drupal:content-translation-overview');
|
return $this->getEntity()->urlInfo('content-translation-overview');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -63,10 +63,10 @@ function menu_ui_entity_type_build(array &$entity_types) {
|
||||||
->setFormClass('edit', 'Drupal\menu_ui\MenuForm')
|
->setFormClass('edit', 'Drupal\menu_ui\MenuForm')
|
||||||
->setFormClass('delete', 'Drupal\menu_ui\Form\MenuDeleteForm')
|
->setFormClass('delete', 'Drupal\menu_ui\Form\MenuDeleteForm')
|
||||||
->setListBuilderClass('Drupal\menu_ui\MenuListBuilder')
|
->setListBuilderClass('Drupal\menu_ui\MenuListBuilder')
|
||||||
->setLinkTemplate('add-form', 'entity.menu.add_form')
|
->setLinkTemplate('add-form', '/admin/structure/menu/add')
|
||||||
->setLinkTemplate('delete-form', 'entity.menu.delete_form')
|
->setLinkTemplate('delete-form', '/admin/structure/menu/manage/{menu}/delete')
|
||||||
->setLinkTemplate('edit-form', 'entity.menu.edit_form')
|
->setLinkTemplate('edit-form', '/admin/structure/menu/manage/{menu}')
|
||||||
->setLinkTemplate('add-link-form', 'entity.menu.add_link_form');
|
->setLinkTemplate('add-link-form', '/admin/structure/menu/manage/{menu}/add');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -100,12 +100,12 @@ function node_help($route_name, RouteMatchInterface $route_match) {
|
||||||
case 'node.type_add':
|
case 'node.type_add':
|
||||||
return '<p>' . t('Individual content types can have different fields, behaviors, and permissions assigned to them.') . '</p>';
|
return '<p>' . t('Individual content types can have different fields, behaviors, and permissions assigned to them.') . '</p>';
|
||||||
|
|
||||||
case 'field_ui.form_display_overview_node':
|
case "entity.node.field_ui_form_display":
|
||||||
case 'field_ui.form_display_overview_form_mode_node':
|
case 'field_ui.form_display_overview_form_mode_node':
|
||||||
$type = $route_match->getParameter('node_type');
|
$type = $route_match->getParameter('node_type');
|
||||||
return '<p>' . t('Content items can be edited using different form modes. Here, you can define which fields are shown and hidden when %type content is edited in each form mode, and define how the field form widgets are displayed in each form mode.', array('%type' => $type->label())) . '</p>' ;
|
return '<p>' . t('Content items can be edited using different form modes. Here, you can define which fields are shown and hidden when %type content is edited in each form mode, and define how the field form widgets are displayed in each form mode.', array('%type' => $type->label())) . '</p>' ;
|
||||||
|
|
||||||
case 'field_ui.display_overview_node':
|
case 'entity.node.field_ui_display':
|
||||||
case 'field_ui.display_overview_view_mode_node':
|
case 'field_ui.display_overview_view_mode_node':
|
||||||
$type = $route_match->getParameter('node_type');
|
$type = $route_match->getParameter('node_type');
|
||||||
return '<p>' . t('Content items can be displayed using different view modes: Teaser, Full content, Print, RSS, etc. <em>Teaser</em> is a short format that is typically used in lists of multiple content items. <em>Full content</em> is typically used when the content is displayed on its own page.') . '</p>' .
|
return '<p>' . t('Content items can be displayed using different view modes: Teaser, Full content, Print, RSS, etc. <em>Teaser</em> is a short format that is typically used in lists of multiple content items. <em>Full content</em> is typically used when the content is displayed on its own page.') . '</p>' .
|
||||||
|
|
|
@ -57,10 +57,10 @@ use Drupal\user\UserInterface;
|
||||||
* field_ui_base_route = "entity.node_type.edit_form",
|
* field_ui_base_route = "entity.node_type.edit_form",
|
||||||
* permission_granularity = "bundle",
|
* permission_granularity = "bundle",
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.node.canonical",
|
* "canonical" = "/node/{node}",
|
||||||
* "delete-form" = "entity.node.delete_form",
|
* "delete-form" = "/node/{node}/delete",
|
||||||
* "edit-form" = "entity.node.edit_form",
|
* "edit-form" = "/node/{node}/edit",
|
||||||
* "version-history" = "entity.node.version_history",
|
* "version-history" = "/node/{node}/revisions",
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -35,8 +35,8 @@ use Drupal\node\NodeTypeInterface;
|
||||||
* "label" = "name"
|
* "label" = "name"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "edit-form" = "entity.node_type.edit_form",
|
* "edit-form" = "/admin/structure/types/manage/{node_type}",
|
||||||
* "delete-form" = "entity.node_type.delete_form"
|
* "delete-form" = "/admin/structure/types/manage/{node_type}/delete"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -33,8 +33,8 @@ use Drupal\responsive_image\ResponsiveImageMappingInterface;
|
||||||
* "label" = "label"
|
* "label" = "label"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "edit-form" = "entity.responsive_image_mapping.edit_form",
|
* "edit-form" = "/admin/config/media/responsive-image-mapping/{responsive_image_mapping}",
|
||||||
* "duplicate-form" = "entity.responsive_image_mapping.duplicate_form"
|
* "duplicate-form" = "/admin/config/media/responsive-image-mapping/{responsive_image_mapping}/duplicate"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -110,7 +110,11 @@ class EntityDerivative implements ContainerDeriverInterface {
|
||||||
foreach ($default_uris as $link_relation => $default_uri) {
|
foreach ($default_uris as $link_relation => $default_uri) {
|
||||||
// Check if there are link templates defined for the entity type and
|
// Check if there are link templates defined for the entity type and
|
||||||
// use the path from the route instead of the default.
|
// use the path from the route instead of the default.
|
||||||
if ($route_name = $entity_type->getLinkTemplate($link_relation)) {
|
$link_template = $entity_type->getLinkTemplate($link_relation);
|
||||||
|
if (strpos($link_template, '/') !== FALSE) {
|
||||||
|
$this->derivatives[$entity_type_id]['uri_paths'][$link_relation] = '/' . $link_template;
|
||||||
|
}
|
||||||
|
elseif ($route_name = $link_template) {
|
||||||
// @todo remove the try/catch as part of
|
// @todo remove the try/catch as part of
|
||||||
// http://drupal.org/node/2281645
|
// http://drupal.org/node/2281645
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -35,11 +35,11 @@ use Drupal\search\SearchPageInterface;
|
||||||
* },
|
* },
|
||||||
* admin_permission = "administer search",
|
* admin_permission = "administer search",
|
||||||
* links = {
|
* links = {
|
||||||
* "edit-form" = "entity.search_page.edit_form",
|
* "edit-form" = "/admin/config/search/pages/manage/{search_page}",
|
||||||
* "delete-form" = "entity.search_page.delete_form",
|
* "delete-form" = "/admin/config/search/pages/manage/{search_page}/delete",
|
||||||
* "enable" = "entity.search_page.enable",
|
* "enable" = "/admin/config/search/pages/manage/{search_page}/enable",
|
||||||
* "disable" = "entity.search_page.disable",
|
* "disable" = "/admin/config/search/pages/manage/{search_page}/disable",
|
||||||
* "set-default" = "entity.search_page.set_default"
|
* "set-default" = "/admin/config/search/pages/manage/{search_page}/set-default"
|
||||||
* },
|
* },
|
||||||
* config_prefix = "page",
|
* config_prefix = "page",
|
||||||
* entity_keys = {
|
* entity_keys = {
|
||||||
|
|
|
@ -62,6 +62,14 @@ entity.shortcut.canonical:
|
||||||
requirements:
|
requirements:
|
||||||
_entity_access: 'shortcut.update'
|
_entity_access: 'shortcut.update'
|
||||||
|
|
||||||
|
entity.shortcut.edit_form:
|
||||||
|
path: '/admin/config/user-interface/shortcut/link/{shortcut}'
|
||||||
|
defaults:
|
||||||
|
_entity_form: 'shortcut.default'
|
||||||
|
_title: 'Edit'
|
||||||
|
requirements:
|
||||||
|
_entity_access: 'shortcut.update'
|
||||||
|
|
||||||
entity.shortcut.link_delete_inline:
|
entity.shortcut.link_delete_inline:
|
||||||
path: '/admin/config/user-interface/shortcut/link/{shortcut}/delete-inline'
|
path: '/admin/config/user-interface/shortcut/link/{shortcut}/delete-inline'
|
||||||
defaults:
|
defaults:
|
||||||
|
|
|
@ -43,9 +43,9 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
* "langcode" = "langcode",
|
* "langcode" = "langcode",
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.shortcut.canonical",
|
* "canonical" = "/admin/config/user-interface/shortcut/link/{shortcut}",
|
||||||
* "delete-form" = "entity.shortcut.delete_form",
|
* "delete-form" = "/admin/config/user-interface/shortcut/link/{shortcut}/delete",
|
||||||
* "edit-form" = "entity.shortcut.canonical",
|
* "edit-form" = "/admin/config/user-interface/shortcut/link/{shortcut}",
|
||||||
* },
|
* },
|
||||||
* list_cache_tags = { "shortcut_set_list" },
|
* list_cache_tags = { "shortcut_set_list" },
|
||||||
* bundle_entity_type = "shortcut_set"
|
* bundle_entity_type = "shortcut_set"
|
||||||
|
|
|
@ -36,9 +36,9 @@ use Drupal\shortcut\ShortcutSetInterface;
|
||||||
* "label" = "label"
|
* "label" = "label"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "customize-form" = "entity.shortcut_set.customize_form",
|
* "customize-form" = "/admin/config/user-interface/shortcut/manage/{shortcut_set}/customize",
|
||||||
* "delete-form" = "entity.shortcut_set.delete_form",
|
* "delete-form" = "/admin/config/user-interface/shortcut/manage/{shortcut_set}/delete",
|
||||||
* "edit-form" = "entity.shortcut_set.edit_form"
|
* "edit-form" = "/admin/config/user-interface/shortcut/manage/{shortcut_set}"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -327,11 +327,12 @@ use Drupal\language\Entity\ContentLanguageSettings;
|
||||||
* also need to add a corresponding route to your module's routing.yml file;
|
* also need to add a corresponding route to your module's routing.yml file;
|
||||||
* see the entity.node.canonical route in node.routing.yml for an example, and see
|
* see the entity.node.canonical route in node.routing.yml for an example, and see
|
||||||
* @ref sec_routes below for some notes.
|
* @ref sec_routes below for some notes.
|
||||||
* - Define routing and links for the various URLs associated with the entity.
|
* - Define routes and links for the various URLs associated with the entity.
|
||||||
* These go into the 'links' annotation, with the link type as the key, and
|
* These go into the 'links' annotation, with the link type as the key, and
|
||||||
* the route machine name (defined in your module's routing.yml file) as the
|
* the path of this link template as the value. The corresponding route
|
||||||
* value; see @ref sec_routes below for some routing notes. Typical link
|
* requires the following route name:
|
||||||
* types are:
|
* "entity.$entity_type_id.$link_template_type". See @ref sec_routes below for
|
||||||
|
* some routing notes. Typical link types are:
|
||||||
* - canonical: Default link, either to view (if entities are viewed on their
|
* - canonical: Default link, either to view (if entities are viewed on their
|
||||||
* own pages) or edit the entity.
|
* own pages) or edit the entity.
|
||||||
* - delete-form: Confirmation form to delete the entity.
|
* - delete-form: Confirmation form to delete the entity.
|
||||||
|
|
|
@ -1309,8 +1309,8 @@ function system_entity_type_build(array &$entity_types) {
|
||||||
->setFormClass('edit', 'Drupal\system\Form\DateFormatEditForm')
|
->setFormClass('edit', 'Drupal\system\Form\DateFormatEditForm')
|
||||||
->setFormClass('delete', 'Drupal\system\Form\DateFormatDeleteForm')
|
->setFormClass('delete', 'Drupal\system\Form\DateFormatDeleteForm')
|
||||||
->setListBuilderClass('Drupal\system\DateFormatListBuilder')
|
->setListBuilderClass('Drupal\system\DateFormatListBuilder')
|
||||||
->setLinkTemplate('edit-form', 'entity.date_format.edit_form')
|
->setLinkTemplate('edit-form', '/admin/config/regional/date-time/formats/manage/{date_format}')
|
||||||
->setLinkTemplate('delete-form', 'entity.date_format.delete_form');
|
->setLinkTemplate('delete-form', '/admin/config/regional/date-time/formats/manage/{date_format}/delete');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,6 +26,11 @@ const ENTITY_TEST_TYPES_REVISABLE = 1;
|
||||||
*/
|
*/
|
||||||
const ENTITY_TEST_TYPES_MULTILINGUAL = 2;
|
const ENTITY_TEST_TYPES_MULTILINGUAL = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter that limits test entity list to routeable ones.
|
||||||
|
*/
|
||||||
|
const ENTITY_TEST_TYPES_ROUTING = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of test entity types.
|
* Returns a list of test entity types.
|
||||||
*
|
*
|
||||||
|
@ -47,7 +52,7 @@ const ENTITY_TEST_TYPES_MULTILINGUAL = 2;
|
||||||
*/
|
*/
|
||||||
function entity_test_entity_types($filter = NULL) {
|
function entity_test_entity_types($filter = NULL) {
|
||||||
$types = array();
|
$types = array();
|
||||||
if ($filter == NULL) {
|
if ($filter === NULL || $filter === ENTITY_TEST_TYPES_ROUTING) {
|
||||||
$types[] = 'entity_test';
|
$types[] = 'entity_test';
|
||||||
}
|
}
|
||||||
if ($filter != ENTITY_TEST_TYPES_REVISABLE) {
|
if ($filter != ENTITY_TEST_TYPES_REVISABLE) {
|
||||||
|
@ -57,7 +62,11 @@ function entity_test_entity_types($filter = NULL) {
|
||||||
if ($filter != ENTITY_TEST_TYPES_MULTILINGUAL) {
|
if ($filter != ENTITY_TEST_TYPES_MULTILINGUAL) {
|
||||||
$types[] = 'entity_test_rev';
|
$types[] = 'entity_test_rev';
|
||||||
}
|
}
|
||||||
|
if ($filter === ENTITY_TEST_TYPES_ROUTING) {
|
||||||
|
$types[] = 'entity_test_base_field_display';
|
||||||
|
}
|
||||||
$types[] = 'entity_test_mulrev';
|
$types[] = 'entity_test_mulrev';
|
||||||
|
|
||||||
return array_combine($types, $types);
|
return array_combine($types, $types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,9 @@ use Drupal\user\UserInterface;
|
||||||
* "langcode" = "langcode",
|
* "langcode" = "langcode",
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.entity_test.canonical",
|
* "canonical" = "/entity_test/{entity_test}",
|
||||||
* "edit-form" = "entity.entity_test.edit_form",
|
* "edit-form" = "/entity_test/manage/{entity_test}",
|
||||||
* "delete-form" = "entity.entity_test.delete_form",
|
* "delete-form" = "/entity_test/delete/entity_test/{entity_test}",
|
||||||
* },
|
* },
|
||||||
* field_ui_base_route = "entity.entity_test.admin_form",
|
* field_ui_base_route = "entity.entity_test.admin_form",
|
||||||
* )
|
* )
|
||||||
|
|
|
@ -30,7 +30,7 @@ use Drupal\Core\Field\BaseFieldDefinition;
|
||||||
* "bundle" = "type"
|
* "bundle" = "type"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "edit-form" = "entity.entity_test_base_field_display.edit_form",
|
* "edit-form" = "/entity_test_base_field_display/manage/{entity_test_base_field_display}",
|
||||||
* },
|
* },
|
||||||
* field_ui_base_route = "entity.entity_test_base_field_display.admin_form",
|
* field_ui_base_route = "entity.entity_test_base_field_display.admin_form",
|
||||||
* )
|
* )
|
||||||
|
|
|
@ -38,9 +38,9 @@ use Drupal\entity_test\Entity\EntityTest;
|
||||||
* "langcode" = "langcode",
|
* "langcode" = "langcode",
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.entity_test_mul.edit_form",
|
* "canonical" = "/entity_test_mul/manage/{entity_test_mul}",
|
||||||
* "edit-form" = "entity.entity_test_mul.edit_form",
|
* "edit-form" = "/entity_test_mul/manage/{entity_test_mul}",
|
||||||
* "delete-form" = "entity.entity_test_mul.delete_form",
|
* "delete-form" = "/entity_test/delete/entity_test_mul/{entity_test_mul}",
|
||||||
* },
|
* },
|
||||||
* field_ui_base_route = "entity.entity_test_mul.admin_form",
|
* field_ui_base_route = "entity.entity_test_mul.admin_form",
|
||||||
* )
|
* )
|
||||||
|
|
|
@ -37,9 +37,9 @@ use Drupal\Core\Field\BaseFieldDefinition;
|
||||||
* "langcode" = "langcode"
|
* "langcode" = "langcode"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.entity_test_mul.edit_form",
|
* "canonical" = "/entity_test_mul_default_value/manage/{entity_test_mul_default_value}",
|
||||||
* "edit-form" = "entity.entity_test_mul.edit_form",
|
* "edit-form" = "/entity_test_mul_default_value/manage/{entity_test_mul_default_value}",
|
||||||
* "delete-form" = "entity.entity_test_mul.delete_form",
|
* "delete-form" = "/entity_test/delete/entity_test_mul_default_value/{entity_test_mul_default_value}",
|
||||||
* },
|
* },
|
||||||
* field_ui_base_route = "entity.entity_test_mul.admin_form",
|
* field_ui_base_route = "entity.entity_test_mul.admin_form",
|
||||||
* )
|
* )
|
||||||
|
|
|
@ -36,9 +36,9 @@ use Drupal\Core\Entity\EntityTypeInterface;
|
||||||
* "langcode" = "custom_langcode_key",
|
* "langcode" = "custom_langcode_key",
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.entity_test_mul_langcode_key.edit_form",
|
* "canonical" = "/entity_test_mul_langcode_key/manage/{entity_test_mul_langcode_key}",
|
||||||
* "edit-form" = "entity.entity_test_mul_langcode_key.edit_form",
|
* "edit-form" = "/entity_test_mul_langcode_key/manage/{entity_test_mul_langcode_key}",
|
||||||
* "delete-form" = "entity.entity_test_mul_langcode_key.delete_form",
|
* "delete-form" = "/entity_test/delete/entity_test_mul_langcode_key/{entity_test_mul_langcode_key}",
|
||||||
* },
|
* },
|
||||||
* field_ui_base_route = "entity.entity_test_mul_langcode_key.admin_form",
|
* field_ui_base_route = "entity.entity_test_mul_langcode_key.admin_form",
|
||||||
* )
|
* )
|
||||||
|
|
|
@ -41,9 +41,9 @@ use Drupal\entity_test\Entity\EntityTestRev;
|
||||||
* "langcode" = "langcode",
|
* "langcode" = "langcode",
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.entity_test_mulrev.edit_form",
|
* "canonical" = "/entity_test_mulrev/manage/{entity_test_mulrev}",
|
||||||
* "delete-form" = "entity.entity_test_mulrev.delete_form",
|
* "delete-form" = "/entity_test/delete/entity_test_mulrev/{entity_test_mulrev}",
|
||||||
* "edit-form" = "entity.entity_test_mulrev.edit_form"
|
* "edit-form" = "/entity_test_mulrev/manage/{entity_test_mulrev}",
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -37,9 +37,9 @@ use Drupal\entity_test\Entity\EntityTest;
|
||||||
* "langcode" = "langcode",
|
* "langcode" = "langcode",
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.entity_test_rev.edit_form",
|
* "canonical" = "/entity_test_rev/manage/{entity_test_rev}",
|
||||||
* "delete-form" = "entity.entity_test_rev.delete_form",
|
* "delete-form" = "/entity_test/delete/entity_test_rev/{entity_test_rev}",
|
||||||
* "edit-form" = "entity.entity_test_rev.edit_form"
|
* "edit-form" = "/entity_test_rev/manage/{entity_test_rev}"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,8 +29,8 @@ use Drupal\Core\Entity\EntityTypeInterface;
|
||||||
* "bundle" = "type"
|
* "bundle" = "type"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.entity_test.canonical",
|
* "canonical" = "/entity_test_string_id/manage/{entity_test_string_id}",
|
||||||
* "edit-form" = "entity.entity_test_string_id.edit_form",
|
* "edit-form" = "/entity_test_string_id/manage/{entity_test_string_id}",
|
||||||
* },
|
* },
|
||||||
* field_ui_base_route = "entity.entity_test_string_id.admin_form",
|
* field_ui_base_route = "entity.entity_test_string_id.admin_form",
|
||||||
* )
|
* )
|
||||||
|
|
|
@ -19,13 +19,18 @@ class EntityTestLocalTasks extends DeriverBase {
|
||||||
*/
|
*/
|
||||||
public function getDerivativeDefinitions($base_plugin_definition) {
|
public function getDerivativeDefinitions($base_plugin_definition) {
|
||||||
$this->derivatives = array();
|
$this->derivatives = array();
|
||||||
$types = entity_test_entity_types();
|
$types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING);
|
||||||
|
|
||||||
foreach($types as $entity_type) {
|
foreach($types as $entity_type) {
|
||||||
$this->derivatives[$entity_type] = array();
|
$this->derivatives[$entity_type . '.canonical'] = array();
|
||||||
$this->derivatives[$entity_type]['base_route'] = "entity.$entity_type.edit_form";
|
$this->derivatives[$entity_type . '.canonical']['base_route'] = "entity.$entity_type.canonical";
|
||||||
$this->derivatives[$entity_type]['route_name'] = "entity.$entity_type.edit_form";
|
$this->derivatives[$entity_type . '.canonical']['route_name'] = "entity.$entity_type.canonical";
|
||||||
$this->derivatives[$entity_type]['title'] = 'Edit';
|
$this->derivatives[$entity_type . '.canonical']['title'] = 'View';
|
||||||
|
|
||||||
|
$this->derivatives[$entity_type . '.edit'] = array();
|
||||||
|
$this->derivatives[$entity_type . '.edit']['base_route'] = "entity.$entity_type.canonical";
|
||||||
|
$this->derivatives[$entity_type . '.edit']['route_name'] = "entity.$entity_type.edit_form";
|
||||||
|
$this->derivatives[$entity_type . '.edit']['title'] = 'Edit';
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getDerivativeDefinitions($base_plugin_definition);
|
return parent::getDerivativeDefinitions($base_plugin_definition);
|
||||||
|
|
|
@ -21,7 +21,7 @@ class EntityTestRoutes {
|
||||||
* An array of route objects.
|
* An array of route objects.
|
||||||
*/
|
*/
|
||||||
public function routes() {
|
public function routes() {
|
||||||
$types = entity_test_entity_types();
|
$types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING);
|
||||||
$types[] = 'entity_test_string_id';
|
$types[] = 'entity_test_string_id';
|
||||||
$types[] = 'entity_test_no_id';
|
$types[] = 'entity_test_no_id';
|
||||||
|
|
||||||
|
@ -33,6 +33,15 @@ class EntityTestRoutes {
|
||||||
array('_permission' => 'administer entity_test content')
|
array('_permission' => 'administer entity_test content')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$routes["entity.$entity_type_id.canonical"] = new Route(
|
||||||
|
$entity_type_id . '/manage/{' . $entity_type_id . '}',
|
||||||
|
array('_controller' => '\Drupal\entity_test\Controller\EntityTestController::testEdit', 'entity_type_id' => $entity_type_id),
|
||||||
|
array('_permission' => 'administer entity_test content'),
|
||||||
|
array('parameters' => array(
|
||||||
|
$entity_type_id => array('type' => 'entity:' . $entity_type_id),
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
$routes["entity.$entity_type_id.edit_form"] = new Route(
|
$routes["entity.$entity_type_id.edit_form"] = new Route(
|
||||||
$entity_type_id . '/manage/{' . $entity_type_id . '}',
|
$entity_type_id . '/manage/{' . $entity_type_id . '}',
|
||||||
array('_controller' => '\Drupal\entity_test\Controller\EntityTestController::testEdit', 'entity_type_id' => $entity_type_id),
|
array('_controller' => '\Drupal\entity_test\Controller\EntityTestController::testEdit', 'entity_type_id' => $entity_type_id),
|
||||||
|
|
|
@ -46,9 +46,9 @@ use Drupal\taxonomy\TermInterface;
|
||||||
* bundle_entity_type = "taxonomy_vocabulary",
|
* bundle_entity_type = "taxonomy_vocabulary",
|
||||||
* field_ui_base_route = "entity.taxonomy_vocabulary.overview_form",
|
* field_ui_base_route = "entity.taxonomy_vocabulary.overview_form",
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.taxonomy_term.canonical",
|
* "canonical" = "/taxonomy/term/{taxonomy_term}",
|
||||||
* "delete-form" = "entity.taxonomy_term.delete_form",
|
* "delete-form" = "/taxonomy/term/{taxonomy_term}/delete",
|
||||||
* "edit-form" = "entity.taxonomy_term.edit_form",
|
* "edit-form" = "/taxonomy/term/{taxonomy_term}/edit",
|
||||||
* },
|
* },
|
||||||
* permission_granularity = "bundle"
|
* permission_granularity = "bundle"
|
||||||
* )
|
* )
|
||||||
|
|
|
@ -36,11 +36,11 @@ use Drupal\taxonomy\VocabularyInterface;
|
||||||
* "weight" = "weight"
|
* "weight" = "weight"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "add-form" = "entity.taxonomy_term.add_form",
|
* "add-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/add",
|
||||||
* "delete-form" = "entity.taxonomy_vocabulary.delete_form",
|
* "delete-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/delete",
|
||||||
* "reset-form" = "entity.taxonomy_vocabulary.reset_form",
|
* "reset-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/reset",
|
||||||
* "overview-form" = "entity.taxonomy_vocabulary.overview_form",
|
* "overview-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/overview",
|
||||||
* "edit-form" = "entity.taxonomy_vocabulary.edit_form"
|
* "edit-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -36,9 +36,9 @@ use Drupal\user\RoleInterface;
|
||||||
* "label" = "label"
|
* "label" = "label"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "delete-form" = "entity.user_role.delete_form",
|
* "delete-form" = "/admin/people/roles/manage/{user_role}/delete",
|
||||||
* "edit-form" = "entity.user_role.edit_form",
|
* "edit-form" = "/admin/people/roles/manage/{user_role}",
|
||||||
* "edit-permissions-form" = "entity.user_role.edit_permissions_form"
|
* "edit-permissions-form" = "/admin/people/permissions/{user_role}"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -51,9 +51,9 @@ use Drupal\user\UserInterface;
|
||||||
* "uuid" = "uuid"
|
* "uuid" = "uuid"
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "entity.user.canonical",
|
* "canonical" = "/user/{user}",
|
||||||
* "edit-form" = "entity.user.edit_form",
|
* "edit-form" = "/user/{user}/edit",
|
||||||
* "cancel-form" = "entity.user.cancel_form",
|
* "cancel-form" = "/user/{user}/cancel",
|
||||||
* },
|
* },
|
||||||
* field_ui_base_route = "entity.user.admin_form",
|
* field_ui_base_route = "entity.user.admin_form",
|
||||||
* )
|
* )
|
||||||
|
|
|
@ -81,13 +81,13 @@ function user_help($route_name, RouteMatchInterface $route_match) {
|
||||||
case 'user.role_list':
|
case 'user.role_list':
|
||||||
return '<p>' . t('A role defines a group of users that have certain privileges. These privileges are defined on the <a href="!permissions">Permissions page</a>. Here, you can define the names and the display sort order of the roles on your site. It is recommended to order roles from least permissive (for example, Anonymous user) to most permissive (for example, Administrator user). Users who are not logged in have the Anonymous user role. Users who are logged in have the Authenticated user role, plus any other roles granted to their user account.', array('!permissions' => \Drupal::url('user.admin_permissions'))) . '</p>';
|
return '<p>' . t('A role defines a group of users that have certain privileges. These privileges are defined on the <a href="!permissions">Permissions page</a>. Here, you can define the names and the display sort order of the roles on your site. It is recommended to order roles from least permissive (for example, Anonymous user) to most permissive (for example, Administrator user). Users who are not logged in have the Anonymous user role. Users who are logged in have the Authenticated user role, plus any other roles granted to their user account.', array('!permissions' => \Drupal::url('user.admin_permissions'))) . '</p>';
|
||||||
|
|
||||||
case 'field_ui.overview_user':
|
case 'entity.user.field_ui_fields':
|
||||||
return '<p>' . t('This form lets administrators add and edit fields for storing user data.') . '</p>';
|
return '<p>' . t('This form lets administrators add and edit fields for storing user data.') . '</p>';
|
||||||
|
|
||||||
case 'field_ui.form_display_overview_user':
|
case 'entity.user.field_ui_form_display':
|
||||||
return '<p>' . t('This form lets administrators configure how form fields should be displayed when editing a user profile.') . '</p>';
|
return '<p>' . t('This form lets administrators configure how form fields should be displayed when editing a user profile.') . '</p>';
|
||||||
|
|
||||||
case 'field_ui.display_overview_user':
|
case 'entity.node.field_ui_display':
|
||||||
return '<p>' . t('This form lets administrators configure how fields should be displayed when rendering a user profile page.') . '</p>';
|
return '<p>' . t('This form lets administrators configure how fields should be displayed when rendering a user profile page.') . '</p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,14 +53,14 @@ function views_ui_entity_type_build(array &$entity_types) {
|
||||||
->setFormClass('delete', 'Drupal\views_ui\ViewDeleteForm')
|
->setFormClass('delete', 'Drupal\views_ui\ViewDeleteForm')
|
||||||
->setFormClass('break_lock', 'Drupal\views_ui\Form\BreakLockForm')
|
->setFormClass('break_lock', 'Drupal\views_ui\Form\BreakLockForm')
|
||||||
->setListBuilderClass('Drupal\views_ui\ViewListBuilder')
|
->setListBuilderClass('Drupal\views_ui\ViewListBuilder')
|
||||||
->setLinkTemplate('edit-form', 'entity.view.edit_form')
|
->setLinkTemplate('edit-form', '/admin/structure/views/view/{view}')
|
||||||
->setLinkTemplate('edit-display-form', 'entity.view.edit_display_form')
|
->setLinkTemplate('edit-display-form', '/admin/structure/views/view/{view}/edit/{display_id}')
|
||||||
->setLinkTemplate('preview-form', 'entity.view.preview_form')
|
->setLinkTemplate('preview-form', '/admin/structure/views/view/{view}/preview/{display_id}')
|
||||||
->setLinkTemplate('duplicate-form', 'entity.view.duplicate_form')
|
->setLinkTemplate('duplicate-form', '/admin/structure/views/view/{view}/duplicate')
|
||||||
->setLinkTemplate('delete-form', 'entity.view.delete_form')
|
->setLinkTemplate('delete-form', '/admin/structure/views/view/{view}/delete')
|
||||||
->setLinkTemplate('enable', 'entity.view.enable')
|
->setLinkTemplate('enable', '/admin/structure/views/view/{view}/enable')
|
||||||
->setLinkTemplate('disable', 'entity.view.disable')
|
->setLinkTemplate('disable', '/admin/structure/views/view/{view}/disable')
|
||||||
->setLinkTemplate('break-lock-form', 'entity.view.break_lock_form');
|
->setLinkTemplate('break-lock-form', '/admin/structure/views/view/{view}/break-lock');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -241,4 +241,14 @@ class EntityTypeTest extends UnitTestCase {
|
||||||
return get_class($this->getMockForAbstractClass('Drupal\Core\Entity\EntityHandlerBase'));
|
return get_class($this->getMockForAbstractClass('Drupal\Core\Entity\EntityHandlerBase'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::setLinkTemplate
|
||||||
|
*
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testSetLinkTemplateWithInvalidPath() {
|
||||||
|
$entity_type = $this->setUpEntityType(['id' => $this->randomMachineName()]);
|
||||||
|
$entity_type->setLinkTemplate('test', 'invalid-path');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,10 +65,10 @@ class EntityUrlTest extends UnitTestCase {
|
||||||
*/
|
*/
|
||||||
public function providerTestUrlInfo() {
|
public function providerTestUrlInfo() {
|
||||||
return array(
|
return array(
|
||||||
array('Drupal\Core\Entity\Entity', 'edit-form', 'test_entity_type.edit'),
|
array('Drupal\Core\Entity\Entity', 'edit-form', 'entity.test_entity_type.edit_form'),
|
||||||
array('Drupal\Core\Config\Entity\ConfigEntityBase', 'edit-form', 'test_entity_type.edit'),
|
array('Drupal\Core\Config\Entity\ConfigEntityBase', 'edit-form', 'entity.test_entity_type.edit_form'),
|
||||||
// Test that overriding the default $rel parameter works.
|
// Test that overriding the default $rel parameter works.
|
||||||
array('Drupal\Core\Config\Entity\ConfigEntityBase', FALSE, 'test_entity_type.edit'),
|
array('Drupal\Core\Config\Entity\ConfigEntityBase', FALSE, 'entity.test_entity_type.edit_form'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,13 +181,13 @@ class EntityUrlTest extends UnitTestCase {
|
||||||
->method('generateFromRoute')
|
->method('generateFromRoute')
|
||||||
->will($this->returnValueMap(array(
|
->will($this->returnValueMap(array(
|
||||||
array(
|
array(
|
||||||
'test_entity_type.view',
|
'entity.test_entity_type.canonical',
|
||||||
array('test_entity_type' => 'test_entity_id'),
|
array('test_entity_type' => 'test_entity_id'),
|
||||||
array('entity_type' => 'test_entity_type', 'entity' => $valid_entity),
|
array('entity_type' => 'test_entity_type', 'entity' => $valid_entity),
|
||||||
'/entity/test_entity_type/test_entity_id',
|
'/entity/test_entity_type/test_entity_id',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'test_entity_type.view',
|
'entity.test_entity_type.canonical',
|
||||||
array('test_entity_type' => 'test_entity_id'),
|
array('test_entity_type' => 'test_entity_id'),
|
||||||
array('absolute' => TRUE, 'entity_type' => 'test_entity_type', 'entity' => $valid_entity),
|
array('absolute' => TRUE, 'entity_type' => 'test_entity_type', 'entity' => $valid_entity),
|
||||||
'http://drupal/entity/test_entity_type/test_entity_id',
|
'http://drupal/entity/test_entity_type/test_entity_id',
|
||||||
|
@ -208,7 +208,7 @@ class EntityUrlTest extends UnitTestCase {
|
||||||
$entity_type->expects($this->exactly(3))
|
$entity_type->expects($this->exactly(3))
|
||||||
->method('getLinkTemplates')
|
->method('getLinkTemplates')
|
||||||
->will($this->returnValue(array(
|
->will($this->returnValue(array(
|
||||||
'canonical' => 'test_entity_type.view',
|
'canonical' => 'entity.test_entity_type.canonical',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$this->entityManager
|
$this->entityManager
|
||||||
|
@ -222,7 +222,7 @@ class EntityUrlTest extends UnitTestCase {
|
||||||
|
|
||||||
$this->urlGenerator->expects($this->once())
|
$this->urlGenerator->expects($this->once())
|
||||||
->method('getPathFromRoute')
|
->method('getPathFromRoute')
|
||||||
->with('test_entity_type.view', array('test_entity_type' => 'test_entity_id'))
|
->with('entity.test_entity_type.canonical', array('test_entity_type' => 'test_entity_id'))
|
||||||
->will($this->returnValue('entity/test_entity_type/test_entity_id'));
|
->will($this->returnValue('entity/test_entity_type/test_entity_id'));
|
||||||
|
|
||||||
$valid_entity = $this->getMockForAbstractClass('Drupal\Core\Entity\Entity', array(array('id' => 'test_entity_id'), 'test_entity_type'));
|
$valid_entity = $this->getMockForAbstractClass('Drupal\Core\Entity\Entity', array(array('id' => 'test_entity_id'), 'test_entity_type'));
|
||||||
|
|
Loading…
Reference in New Issue