Issue #2281645 by dawehner, andypost: Make entity annotations use link templates instead of route names

8.0.x
Alex Pott 2015-01-13 10:32:23 +00:00
parent e298180f76
commit 77725b6084
80 changed files with 396 additions and 242 deletions

View File

@ -164,8 +164,9 @@ abstract class Entity implements EntityInterface {
$link_templates = $this->linkTemplates();
if (isset($link_templates[$rel])) {
// If there is a template for the given relationship type, generate the path.
$uri = new Url($link_templates[$rel], $this->urlRouteParameters($rel));
$route_parameters = $this->urlRouteParameters($rel);
$route_name = "entity.{$this->entityTypeId}." . str_replace(array('-', 'drupal:'), array('_', ''), $rel);
$uri = new Url($route_name, $route_parameters);
}
else {
$bundle = $this->bundle();
@ -224,7 +225,7 @@ abstract class Entity implements EntityInterface {
* Returns an array link templates.
*
* @return array
* An array of link templates containing route names.
* An array of link templates containing paths.
*/
protected function linkTemplates() {
return $this->getEntityType()->getLinkTemplates();

View File

@ -105,9 +105,9 @@ interface EntityInterface extends AccessibleInterface {
* example:
* @code
* links = {
* "canonical" = "entity.node.canonical",
* "edit-form" = "entity.node.edit_form",
* "version-history" = "entity.node.version_history"
* "canonical" = "/node/{node}",
* "edit-form" = "/node/{node}/edit",
* "version-history" = "/node/{node}/revisions"
* }
* @endcode
* or specified in a callback function set like:

View File

@ -546,8 +546,12 @@ class EntityType implements EntityTypeInterface {
/**
* {@inheritdoc}
*/
public function setLinkTemplate($key, $route_name) {
$this->links[$key] = $route_name;
public function setLinkTemplate($key, $path) {
if ($path[0] !== '/') {
throw new \InvalidArgumentException('Link templates accepts paths, which have to start with a leading slash.');
}
$this->links[$key] = $path;
return $this;
}

View File

@ -455,7 +455,7 @@ interface EntityTypeInterface {
* The link type.
*
* @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);
@ -475,12 +475,15 @@ interface EntityTypeInterface {
*
* @param string $key
* The name of a link.
* @param string $route_name
* The route name to use for the link.
* @param string $path
* The route path to use for the link.
*
* @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.

View File

@ -44,6 +44,6 @@ function action_entity_type_build(array &$entity_types) {
->setFormClass('edit', 'Drupal\action\ActionEditForm')
->setFormClass('delete', 'Drupal\action\Form\ActionDeleteForm')
->setListBuilderClass('Drupal\action\ActionListBuilder')
->setLinkTemplate('delete-form', 'entity.action.delete_form')
->setLinkTemplate('edit-form', 'entity.action.edit_form');
->setLinkTemplate('delete-form', '/admin/config/system/actions/configure/{action}/delete')
->setLinkTemplate('edit-form', '/admin/config/system/actions/configure/{action}');
}

View File

@ -33,9 +33,9 @@ use Drupal\aggregator\FeedInterface;
* }
* },
* links = {
* "canonical" = "entity.aggregator_feed.canonical",
* "edit-form" = "entity.aggregator_feed.edit_form",
* "delete-form" = "entity.aggregator_feed.delete_form",
* "canonical" = "/aggregator/sources/{aggregator_feed}",
* "edit-form" = "/aggregator/sources/{aggregator_feed}/configure",
* "delete-form" = "/aggregator/sources/{aggregator_feed}/delete",
* },
* field_ui_base_route = "aggregator.admin_overview",
* base_table = "aggregator_feed",

View File

@ -36,8 +36,8 @@ use Drupal\Core\Entity\EntityStorageInterface;
* "id" = "id"
* },
* links = {
* "delete-form" = "entity.block.delete_form",
* "edit-form" = "entity.block.edit_form"
* "delete-form" = "/admin/structure/block/manage/{block}/delete",
* "edit-form" = "/admin/structure/block/manage/{block}"
* }
* )
*/

View File

@ -45,6 +45,15 @@ entity.block_content.canonical:
requirements:
_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:
path: '/block/{block_content}/delete'
defaults:

View File

@ -39,9 +39,9 @@ use Drupal\block_content\BlockContentInterface;
* revision_table = "block_content_revision",
* data_table = "block_content_field_data",
* links = {
* "canonical" = "entity.block_content.canonical",
* "delete-form" = "entity.block_content.delete_form",
* "edit-form" = "entity.block_content.canonical",
* "canonical" = "/block/{block_content}",
* "delete-form" = "/block/{block_content}/delete",
* "edit-form" = "/block/{block_content}",
* },
* translatable = TRUE,
* entity_keys = {

View File

@ -35,8 +35,8 @@ use Drupal\block_content\BlockContentTypeInterface;
* "label" = "label"
* },
* links = {
* "delete-form" = "entity.block_content_type.delete_form",
* "edit-form" = "entity.block_content_type.edit_form"
* "delete-form" = "/admin/structure/block/block-content/manage/{block_content_type}/delete",
* "edit-form" = "/admin/structure/block/block-content/manage/{block_content_type}"
* }
* )
*/

View File

@ -89,8 +89,8 @@ function book_entity_type_build(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_types['node']
->setFormClass('book_outline', 'Drupal\book\Form\BookOutlineForm')
->setLinkTemplate('book-outline-form', 'entity.node.book_outline_form')
->setLinkTemplate('book-remove-form', 'entity.node.book_remove_form');
->setLinkTemplate('book-outline-form', '/node/{node}/outline')
->setLinkTemplate('book-remove-form', '/node/{node}/outline/remove');
}
/**

View File

@ -47,9 +47,9 @@ use Drupal\user\UserInterface;
* "uuid" = "uuid"
* },
* links = {
* "canonical" = "entity.comment.canonical",
* "delete-form" = "entity.comment.delete_form",
* "edit-form" = "entity.comment.edit_form",
* "canonical" = "/comment/{comment}",
* "delete-form" = "/comment/{comment}/delete",
* "edit-form" = "/comment/{comment}/edit",
* },
* bundle_entity_type = "comment_type",
* field_ui_base_route = "entity.comment_type.edit_form",

View File

@ -34,9 +34,9 @@ use Drupal\comment\CommentTypeInterface;
* "label" = "label"
* },
* links = {
* "delete-form" = "entity.comment_type.delete_form",
* "edit-form" = "entity.comment_type.edit_form",
* "add-form" = "entity.comment_type.add_form"
* "delete-form" = "/admin/structure/comment/manage/{comment_type}/delete",
* "edit-form" = "/admin/structure/comment/manage/{comment_type}",
* "add-form" = "/admin/structure/comment/types/add"
* }
* )
*/

View File

@ -224,7 +224,7 @@ class CommentAdminOverview extends FormBase {
if ($this->moduleHandler->moduleExists('content_translation') && $this->moduleHandler->invoke('content_translation', 'translate_access', array($comment))->isAllowed()) {
$links['translate'] = array(
'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(

View File

@ -108,7 +108,7 @@ class CommentTypeTest extends CommentTestBase {
$this->drupalGet('admin/structure/comment');
$this->assertRaw('Bar', 'New name was displayed.');
$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.');
// Remove the body field.

View File

@ -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.
$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->setLinkTemplate('edit-form', 'entity.config_test.edit_form_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('edit-form', '/admin/structure/config_test/manage/{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();
unset($keys['status']);

View File

@ -34,10 +34,10 @@ use Drupal\Core\Entity\EntityStorageInterface;
* "status" = "status"
* },
* links = {
* "edit-form" = "entity.config_test.edit_form",
* "delete-form" = "entity.config_test.delete_form",
* "enable" = "entity.config_test.enable",
* "disable" = "entity.config_test.disable"
* "edit-form" = "/admin/structure/config_test/manage/{config_test}",
* "delete-form" = "/admin/structure/config_test/manage/{config_test}/delete",
* "enable" = "/admin/structure/config_test/manage/{config_test}/enable",
* "disable" = "/admin/structure/config_test/manage/{config_test}/disable"
* }
* )
*/

View File

@ -36,13 +36,13 @@ function hook_config_translation_info(&$info) {
$route_provider = \Drupal::service('router.route_provider');
// 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')) {
// Add fields entity mappers to all fieldable entity types defined.
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
$base_route = NULL;
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) {
// 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.
if ($entity_type->get('field_ui_base_route') && !empty($base_route)) {
$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',
'title' => t('!label field'),
'class' => '\Drupal\config_translation\ConfigFieldMapper',

View File

@ -8,6 +8,7 @@
use Drupal\config_translation\Plugin\Derivative\ConfigTranslationLocalTasks;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\field\FieldConfigInterface;
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') {
$class = 'Drupal\config_translation\Controller\ConfigTranslationFieldListBuilder';
// 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 {
$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);
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');
// 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')) {
// Add fields entity mappers to all fieldable entity types defined.
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
// Make sure entity type has field UI enabled and has a base route.
if ($entity_type->get('field_ui_base_route')) {
$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',
'title' => '!label field',
'class' => '\Drupal\config_translation\ConfigFieldMapper',
@ -139,9 +140,10 @@ function config_translation_config_translation_info(&$info) {
}
// Use the entity type as the plugin ID.
$base_route_name = "entity.$entity_type_id.edit_form";
$info[$entity_type_id] = array(
'class' => '\Drupal\config_translation\ConfigEntityMapper',
'base_route_name' => $entity_type->getLinkTemplate('edit-form'),
'base_route_name' => $base_route_name,
'title' => '!label !entity_type',
'names' => array(),
'entity_type' => $entity_type_id,
@ -157,12 +159,18 @@ function config_translation_entity_operation(EntityInterface $entity) {
$operations = array();
$entity_type = $entity->getEntityType();
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')) {
$link_template = 'config-translation-overview';
if ($entity instanceof FieldConfigInterface) {
$link_template = "config-translation-overview.{$entity->getTargetEntityTypeId()}";
}
$operations['translate'] = array(
'title' => t('Translate'),
'weight' => 50,
'url' => $entity->urlInfo('drupal:config-translation-overview'),
'url' => $entity->urlInfo($link_template),
);
}

View File

@ -242,6 +242,13 @@ class ConfigEntityMapper extends ConfigNamesMapper {
}
}
/**
* {@inheritdoc}
*/
public function getOverviewRouteName() {
return 'entity.' . $this->entityType . '.config_translation_overview';
}
/**
* {@inheritdoc}
*/

View File

@ -34,6 +34,13 @@ class ConfigFieldMapper extends ConfigEntityMapper {
return $parameters;
}
/**
* {@inheritdoc}
*/
public function getOverviewRouteName() {
return 'entity.field_config.config_translation_overview.' . $this->pluginDefinition['base_entity_type'];
}
/**
* {@inheritdoc}
*/

View File

@ -43,7 +43,7 @@ function contact_help($route_name, RouteMatchInterface $route_match) {
*/
function contact_entity_type_alter(array &$entity_types) {
/** @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');
}
/**

View File

@ -34,8 +34,8 @@ use Drupal\Core\Config\Entity\ThirdPartySettingsTrait;
* "label" = "label"
* },
* links = {
* "delete-form" = "entity.contact_form.delete_form",
* "edit-form" = "entity.contact_form.edit_form"
* "delete-form" = "/admin/structure/contact/manage/{contact_form}/delete",
* "edit-form" = "/admin/structure/contact/manage/{contact_form}"
* }
* )
*/

View File

@ -114,7 +114,7 @@ function content_translation_entity_type_alter(array &$entity_types) {
if ($entity_type->hasLinkTemplate('canonical')) {
// Provide default route names for the translation paths.
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
// controller. See https://drupal.org/node/2155787.

View File

@ -53,7 +53,7 @@ class ContentTranslationContextualLinks extends DeriverBase implements Container
// Create contextual links for translatable entity types.
foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
$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;
}
return parent::getDerivativeDefinitions($base_plugin_definition);

View File

@ -61,13 +61,14 @@ class ContentTranslationLocalTasks extends DeriverBase implements ContainerDeriv
// Create tabs for all possible entity types.
foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
// 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(
'entity_type' => $entity_type_id,
'title' => 'Translate',
'route_name' => $translation_route_name,
'base_route' => $entity_type->getLinkTemplate('canonical'),
'base_route' => $base_route_name,
) + $base_plugin_definition;
}
return parent::getDerivativeDefinitions($base_plugin_definition);

View File

@ -42,17 +42,26 @@ class ContentTranslationRouteSubscriber extends RouteSubscriberBase {
protected function alterRoutes(RouteCollection $collection) {
foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
// Try to get the route from the current collection.
if (!$entity_route = $collection->get($entity_type->getLinkTemplate('canonical'))) {
continue;
$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;
}
$base_path = $entity_route->getPath();
}
$path = $entity_route->getPath() . '/translations';
// Inherit admin route status from edit route, if exists.
$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');
}
$path = $base_path . '/translations';
$route = new Route(
$path,
array(
@ -71,7 +80,8 @@ class ContentTranslationRouteSubscriber extends RouteSubscriberBase {
'_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(
$path . '/add/{source}/{target}',

View File

@ -62,6 +62,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
// Create a translation.
$this->drupalLogin($this->translator);
$path = $this->entity->getSystemPath('drupal:content-translation-overview');
$add_translation_path = $path . "/add/$default_langcode/{$this->langcodes[2]}";
$this->drupalPostForm($add_translation_path, array(), t('Save'));
$this->rebuildContainer();

View File

@ -28,7 +28,7 @@ class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTest {
->method('getLinkTemplate')
->will($this->returnValueMap(array(
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->expects($this->any())
@ -54,14 +54,14 @@ class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTest {
public function providerTestBlockAdminDisplay() {
return 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.edit_form',
'entity.node.delete_form',
'entity.node.version_history',
))),
array('content_translation.translation_overview_node', array(array(
'content_translation.local_tasks:content_translation.translation_overview_node',
array('entity.node.content_translation_overview', array(array(
'content_translation.local_tasks:entity.node.content_translation_overview',
'entity.node.canonical',
'entity.node.edit_form',
'entity.node.delete_form',

View File

@ -261,12 +261,12 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
protected function linkTemplates() {
$link_templates = parent::linkTemplates();
if (\Drupal::moduleHandler()->moduleExists('field_ui')) {
$link_templates['edit-form'] = 'field_ui.field_edit_' . $this->entity_type;
$link_templates['storage-edit-form'] = 'field_ui.storage_edit_' . $this->entity_type;
$link_templates['delete-form'] = 'field_ui.delete_' . $this->entity_type;
$link_templates["{$this->entity_type}-field-edit-form"] = 'entity.field_config.' . $this->entity_type . '_field_edit_form';
$link_templates["{$this->entity_type}-storage-edit-form"] = 'entity.field_config.' . $this->entity_type . '_storage_edit_form';
$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'])) {
$link_templates['drupal:config-translation-overview'] .= $link_templates['edit-form'];
if (isset($link_templates['config-translation-overview'])) {
$link_templates["config-translation-overview.{$this->entity_type}"] = "entity.field_config.config_translation_overview.{$this->entity_type}";
}
}
return $link_templates;

View File

@ -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 .= '<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')) {
$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>';
@ -91,10 +91,14 @@ function field_ui_entity_type_build(array &$entity_types) {
foreach ($entity_types as $entity_type) {
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
->setLinkTemplate('field_ui-fields', "field_ui.overview_$bundle")
->setLinkTemplate('field_ui-form-display', "field_ui.form_display_overview_$bundle")
->setLinkTemplate('field_ui-display', "field_ui.display_overview_$bundle");
->setLinkTemplate('field_ui-fields', "/admin/{$entity_type->id()}/fields")
->setLinkTemplate('field_ui-form-display', "/admin/{$entity_type->id()}/fields-form-display")
->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('delete', 'Drupal\field_ui\Form\EntityDisplayModeDeleteForm');
$form_mode->set('admin_permission', 'administer display modes');
$form_mode->setLinkTemplate('delete-form', 'field_ui.entity_form_mode.delete_form');
$form_mode->setLinkTemplate('edit-form', 'field_ui.entity_form_mode.edit_form');
$form_mode->setLinkTemplate('delete-form', '/admin/structure/display-modes/form/manage/{entity_form_mode}/delete');
$form_mode->setLinkTemplate('edit-form', '/admin/structure/display-modes/form/manage/{entity_form_mode}');
$view_mode = $entity_types['entity_view_mode'];
$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('delete', 'Drupal\field_ui\Form\EntityDisplayModeDeleteForm');
$view_mode->set('admin_permission', 'administer display modes');
$view_mode->setLinkTemplate('delete-form', 'field_ui.entity_view_mode.delete_form');
$view_mode->setLinkTemplate('edit-form', 'field_ui.entity_view_mode.edit_form');
$view_mode->setLinkTemplate('delete-form', '/admin/structure/display-modes/view/manage/{entity_view_mode}/delete');
$view_mode->setLinkTemplate('edit-form', '/admin/structure/display-modes/view/manage/{entity_view_mode}');
}

View File

@ -38,7 +38,7 @@ field_ui.entity_view_mode_add_type:
requirements:
_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}'
defaults:
_entity_form: 'entity_view_mode.edit'
@ -46,7 +46,7 @@ field_ui.entity_view_mode.edit_form:
requirements:
_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'
defaults:
_entity_form: 'entity_view_mode.delete'
@ -78,7 +78,7 @@ field_ui.entity_form_mode_add_type:
requirements:
_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}'
defaults:
_entity_form: 'entity_form_mode.edit'
@ -86,7 +86,7 @@ field_ui.entity_form_mode.edit_form:
requirements:
_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'
defaults:
_entity_form: 'entity_form_mode.delete'

View File

@ -203,7 +203,9 @@ class DisplayOverview extends DisplayOverviewBase {
* {@inheritdoc}
*/
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,
'view_mode_name' => $mode,
]);

View File

@ -139,7 +139,7 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
'data' => array(
'#type' => 'link',
'#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.'))),
),
),
@ -164,11 +164,24 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
/** @var \Drupal\field\FieldConfigInterface $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(
'title' => $this->t('Storage settings'),
'weight' => 20,
'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['delete']['attributes']['title'] = $this->t('Delete field.');

View File

@ -8,6 +8,7 @@
namespace Drupal\field_ui;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Entity\EntityType;
use Drupal\Core\Url;
/**
@ -29,7 +30,8 @@ class FieldUI {
public static function getOverviewRouteInfo($entity_type_id, $bundle) {
$entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
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,
));
}
@ -66,4 +68,18 @@ class FieldUI {
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();
}
}

View File

@ -223,7 +223,7 @@ class FieldEditForm extends FormBase {
}
$entity_type = $this->entityManager->getDefinition($this->field->entity_type);
$form_state->setRedirect(
'field_ui.delete_' . $this->field->entity_type,
'entity.field_config.' . $this->field->entity_type . '_field_delete_form',
array(
$entity_type->getBundleEntityType() => $this->field->bundle,
'field_config' => $this->field->id(),

View File

@ -322,6 +322,8 @@ class FieldStorageAddForm extends FormBase {
$error = FALSE;
$values = $form_state->getValues();
$destinations = array();
$entity_type = $this->entityManager->getDefinition($this->entityTypeId);
$bundle_entity_type = FieldUI::getRouteBundleEntityType($entity_type);
// Create new field.
if ($values['new_storage_type']) {
@ -352,9 +354,9 @@ class FieldStorageAddForm extends FormBase {
$this->bundleEntityTypeId => $this->bundle,
'field_config' => $field->id(),
);
$destinations[] = array('route_name' => 'field_ui.storage_edit_' . $this->entityTypeId, 'route_parameters' => $route_parameters);
$destinations[] = array('route_name' => 'field_ui.field_edit_' . $this->entityTypeId, 'route_parameters' => $route_parameters);
$destinations[] = array('route_name' => 'field_ui.overview_' . $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' => "entity.field_config.{$this->entityTypeId}_field_edit_form", '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.
$form_state->set(['fields_added', '_add_new_field'], $values['field_name']);
@ -384,8 +386,8 @@ class FieldStorageAddForm extends FormBase {
$this->bundleEntityTypeId => $this->bundle,
'field_config' => $field->id(),
);
$destinations[] = array('route_name' => 'field_ui.field_edit_' . $this->entityTypeId, 'route_parameters' => $route_parameters);
$destinations[] = array('route_name' => 'field_ui.overview_' . $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' => "entity.{$bundle_entity_type}.field_ui_fields", 'route_parameters' => $route_parameters);
// Store new field information for any additional submit handlers.
$form_state->set(['fields_added', '_add_existing_field'], $field_name);

View File

@ -168,7 +168,9 @@ class FormDisplayOverview extends DisplayOverviewBase {
* {@inheritdoc}
*/
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,
'form_mode_name' => $mode,
]);

View File

@ -12,6 +12,7 @@ use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\Routing\RouteProviderInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\field_ui\FieldUI;
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) {
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(
'route_name' => "field_ui.field_storage_config_add_$entity_type_id",
'title' => $this->t('Add field'),
'appears_on' => array("field_ui.overview_$entity_type_id"),
'appears_on' => array("entity.$bundle_entity_type.field_ui_fields"),
);
}
}

View File

@ -13,6 +13,7 @@ use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\Routing\RouteProviderInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\field_ui\FieldUI;
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) {
if ($entity_type->get('field_ui_base_route')) {
$this->derivatives["overview_$entity_type_id"] = array(
'route_name' => "field_ui.overview_$entity_type_id",
$field_entity_type = FieldUI::getRouteBundleEntityType($entity_type);
$this->derivatives["overview_$field_entity_type"] = array(
'route_name' => "entity.$field_entity_type.field_ui_fields",
'weight' => 1,
'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.
$this->derivatives["form_display_overview_$entity_type_id"] = array(
'route_name' => "field_ui.form_display_overview_$entity_type_id",
$this->derivatives["form_display_overview_$field_entity_type"] = array(
'route_name' => "entity.{$field_entity_type}.field_ui_form_display",
'weight' => 2,
'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.
$this->derivatives["display_overview_$entity_type_id"] = array(
'route_name' => "field_ui.display_overview_$entity_type_id",
$this->derivatives["display_overview_$field_entity_type"] = array(
'route_name' => "entity.{$field_entity_type}.field_ui_display",
'weight' => 3,
'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.
$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'),
'base_route' => "field_ui.field_edit_$entity_type_id",
'base_route' => "entity.field_config.{$entity_type_id}_field_edit_form",
);
// Field settings tab.
$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'),
'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.
@ -114,29 +117,29 @@ class FieldUiLocalTask extends DeriverBase implements ContainerDeriverInterface
// modes available for customisation. So we define menu items for all
// view modes, and use a route requirement to determine which ones are
// 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',
'route_name' => "field_ui.form_display_overview_$entity_type_id",
'parent_id' => "field_ui.fields:form_display_overview_$entity_type_id",
'route_name' => "entity.{$field_entity_type}.field_ui_form_display",
'parent_id' => "field_ui.fields:form_display_overview_$field_entity_type",
'weight' => -1,
);
$this->derivatives['field_display_default_' . $entity_type_id] = array(
$this->derivatives['field_display_default_' . $field_entity_type] = array(
'title' => 'Default',
'route_name' => "field_ui.display_overview_$entity_type_id",
'parent_id' => "field_ui.fields:display_overview_$entity_type_id",
'route_name' => "entity.{$field_entity_type}.field_ui_display",
'parent_id' => "field_ui.fields:display_overview_$field_entity_type",
'weight' => -1,
);
// One local task for each form mode.
$weight = 0;
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'],
'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(
'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++,
);
}
@ -144,13 +147,13 @@ class FieldUiLocalTask extends DeriverBase implements ContainerDeriverInterface
// One local task for each view mode.
$weight = 0;
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'],
'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(
'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++,
);
}
@ -172,19 +175,21 @@ class FieldUiLocalTask extends DeriverBase implements ContainerDeriverInterface
*/
public function alterLocalTasks(&$local_tasks) {
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')) {
$local_tasks["field_ui.fields:overview_$entity_type_id"]['base_route'] = $route_name;
$local_tasks["field_ui.fields:form_display_overview_$entity_type_id"]['base_route'] = $route_name;
$local_tasks["field_ui.fields:display_overview_$entity_type_id"]['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_display_default_$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_$field_entity_type"]['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_$field_entity_type"]['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) {
$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) {
$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;
}
}
}

View File

@ -54,6 +54,9 @@ class RouteSubscriber extends RouteSubscriberBase {
'type' => 'entity:' . $entity_type->getBundleEntityType(),
);
}
elseif ($bundle_entity_type == 'bundle') {
$bundle_entity_type = $entity_type_id;
}
$route = new Route(
"$path/fields/{field_config}",
@ -64,7 +67,7 @@ class RouteSubscriber extends RouteSubscriberBase {
array('_entity_access' => 'field_config.update'),
$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(
"$path/fields/{field_config}/storage",
@ -72,7 +75,7 @@ class RouteSubscriber extends RouteSubscriberBase {
array('_entity_access' => 'field_config.update'),
$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(
"$path/fields/{field_config}/delete",
@ -80,7 +83,7 @@ class RouteSubscriber extends RouteSubscriberBase {
array('_entity_access' => 'field_config.delete'),
$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.
$defaults['entity_type_id'] = $entity_type_id;
@ -96,7 +99,7 @@ class RouteSubscriber extends RouteSubscriberBase {
array('_permission' => 'administer ' . $entity_type_id . ' fields'),
$options
);
$collection->add("field_ui.overview_$entity_type_id", $route);
$collection->add("entity.$bundle_entity_type.field_ui_fields", $route);
$route = new Route(
"$path/fields/add-field",
@ -117,7 +120,7 @@ class RouteSubscriber extends RouteSubscriberBase {
array('_field_ui_form_mode_access' => 'administer ' . $entity_type_id . ' form display'),
$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(
"$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'),
$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(
"$path/display",
@ -139,7 +142,7 @@ class RouteSubscriber extends RouteSubscriberBase {
array('_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'),
$options
);
$collection->add("field_ui.display_overview_$entity_type_id", $route);
$collection->add("entity.{$bundle_entity_type}.field_ui_display", $route);
$route = new Route(
"$path/display/{view_mode_name}",
@ -150,7 +153,7 @@ class RouteSubscriber extends RouteSubscriberBase {
array('_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'),
$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);
}
}
}

View File

@ -379,7 +379,7 @@ class ManageDisplayTest extends WebTestBase {
))->save();
$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')))));
}
/**

View File

@ -39,8 +39,8 @@ use Drupal\filter\Plugin\FilterInterface;
* "status" = "status"
* },
* links = {
* "edit-form" = "entity.filter_format.edit_form",
* "disable" = "entity.filter_format.disable"
* "edit-form" = "/admin/config/content/formats/manage/{filter_format}",
* "disable" = "/admin/config/content/formats/manage/{filter_format}/disable"
* }
* )
*/

View File

@ -108,9 +108,9 @@ function forum_entity_type_build(array &$entity_types) {
$entity_types['taxonomy_term']
->setFormClass('forum', 'Drupal\forum\Form\ForumForm')
->setFormClass('container', 'Drupal\forum\Form\ContainerForm')
->setLinkTemplate('forum-delete-form', 'entity.taxonomy_term.forum_delete_form')
->setLinkTemplate('forum-edit-container-form', 'entity.taxonomy_term.forum_edit_container_form')
->setLinkTemplate('forum-edit-form', 'entity.taxonomy_term.forum_edit_form');
->setLinkTemplate('forum-edit-container-form', '/admin/structure/forum/edit/container/{taxonomy_term}')
->setLinkTemplate('forum-delete-form', '/admin/structure/forum/delete/forum/{taxonomy_term}')
->setLinkTemplate('forum-edit-form', '/admin/structure/forum/edit/forum/{taxonomy_term}');
}
/**

View File

@ -44,9 +44,9 @@ use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
* "label" = "label"
* },
* links = {
* "flush-form" = "entity.image_style.flush_form",
* "edit-form" = "entity.image_style.edit_form",
* "delete-form" = "entity.image_style.delete_form"
* "flush-form" = "/admin/config/media/image-styles/manage/{image_style}/flush",
* "edit-form" = "/admin/config/media/image-styles/manage/{image_style}",
* "delete-form" = "/admin/config/media/image-styles/manage/{image_style}/delete"
* }
* )
*/

View File

@ -38,8 +38,8 @@ use Drupal\language\ConfigurableLanguageInterface;
* "weight" = "weight"
* },
* links = {
* "delete-form" = "entity.configurable_language.delete_form",
* "edit-form" = "entity.configurable_language.edit_form"
* "delete-form" = "/admin/config/regional/language/delete/{configurable_language}",
* "edit-form" = "/admin/config/regional/language/edit/{configurable_language}"
* }
* )
*/

View File

@ -14,6 +14,14 @@ entity.menu_link_content.canonical:
requirements:
_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:
path: '/admin/structure/menu/item/{menu_link_content}/delete'
defaults:

View File

@ -40,9 +40,9 @@ use Drupal\menu_link_content\MenuLinkContentInterface;
* "bundle" = "bundle"
* },
* links = {
* "canonical" = "entity.menu_link_content.canonical",
* "edit-form" = "entity.menu_link_content.canonical",
* "delete-form" = "entity.menu_link_content.delete_form",
* "canonical" = "/admin/structure/menu/item/{menu_link_content}/edit",
* "edit-form" = "/admin/structure/menu/item/{menu_link_content}/edit",
* "delete-form" = "/admin/structure/menu/item/{menu_link_content}/delete",
* }
* )
*/

View File

@ -194,7 +194,7 @@ class MenuLinkContent extends MenuLinkBase implements ContainerFactoryPluginInte
* {@inheritdoc}
*/
public function getTranslateRoute() {
return $this->getEntity()->urlInfo('drupal:content-translation-overview');
return $this->getEntity()->urlInfo('content-translation-overview');
}
/**

View File

@ -63,10 +63,10 @@ function menu_ui_entity_type_build(array &$entity_types) {
->setFormClass('edit', 'Drupal\menu_ui\MenuForm')
->setFormClass('delete', 'Drupal\menu_ui\Form\MenuDeleteForm')
->setListBuilderClass('Drupal\menu_ui\MenuListBuilder')
->setLinkTemplate('add-form', 'entity.menu.add_form')
->setLinkTemplate('delete-form', 'entity.menu.delete_form')
->setLinkTemplate('edit-form', 'entity.menu.edit_form')
->setLinkTemplate('add-link-form', 'entity.menu.add_link_form');
->setLinkTemplate('add-form', '/admin/structure/menu/add')
->setLinkTemplate('delete-form', '/admin/structure/menu/manage/{menu}/delete')
->setLinkTemplate('edit-form', '/admin/structure/menu/manage/{menu}')
->setLinkTemplate('add-link-form', '/admin/structure/menu/manage/{menu}/add');
}
/**

View File

@ -100,12 +100,12 @@ function node_help($route_name, RouteMatchInterface $route_match) {
case 'node.type_add':
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':
$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>' ;
case 'field_ui.display_overview_node':
case 'entity.node.field_ui_display':
case 'field_ui.display_overview_view_mode_node':
$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>' .

View File

@ -57,10 +57,10 @@ use Drupal\user\UserInterface;
* field_ui_base_route = "entity.node_type.edit_form",
* permission_granularity = "bundle",
* links = {
* "canonical" = "entity.node.canonical",
* "delete-form" = "entity.node.delete_form",
* "edit-form" = "entity.node.edit_form",
* "version-history" = "entity.node.version_history",
* "canonical" = "/node/{node}",
* "delete-form" = "/node/{node}/delete",
* "edit-form" = "/node/{node}/edit",
* "version-history" = "/node/{node}/revisions",
* }
* )
*/

View File

@ -35,8 +35,8 @@ use Drupal\node\NodeTypeInterface;
* "label" = "name"
* },
* links = {
* "edit-form" = "entity.node_type.edit_form",
* "delete-form" = "entity.node_type.delete_form"
* "edit-form" = "/admin/structure/types/manage/{node_type}",
* "delete-form" = "/admin/structure/types/manage/{node_type}/delete"
* }
* )
*/

View File

@ -33,8 +33,8 @@ use Drupal\responsive_image\ResponsiveImageMappingInterface;
* "label" = "label"
* },
* links = {
* "edit-form" = "entity.responsive_image_mapping.edit_form",
* "duplicate-form" = "entity.responsive_image_mapping.duplicate_form"
* "edit-form" = "/admin/config/media/responsive-image-mapping/{responsive_image_mapping}",
* "duplicate-form" = "/admin/config/media/responsive-image-mapping/{responsive_image_mapping}/duplicate"
* }
* )
*/

View File

@ -110,7 +110,11 @@ class EntityDerivative implements ContainerDeriverInterface {
foreach ($default_uris as $link_relation => $default_uri) {
// Check if there are link templates defined for the entity type and
// 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
// http://drupal.org/node/2281645
try {

View File

@ -35,11 +35,11 @@ use Drupal\search\SearchPageInterface;
* },
* admin_permission = "administer search",
* links = {
* "edit-form" = "entity.search_page.edit_form",
* "delete-form" = "entity.search_page.delete_form",
* "enable" = "entity.search_page.enable",
* "disable" = "entity.search_page.disable",
* "set-default" = "entity.search_page.set_default"
* "edit-form" = "/admin/config/search/pages/manage/{search_page}",
* "delete-form" = "/admin/config/search/pages/manage/{search_page}/delete",
* "enable" = "/admin/config/search/pages/manage/{search_page}/enable",
* "disable" = "/admin/config/search/pages/manage/{search_page}/disable",
* "set-default" = "/admin/config/search/pages/manage/{search_page}/set-default"
* },
* config_prefix = "page",
* entity_keys = {

View File

@ -62,6 +62,14 @@ entity.shortcut.canonical:
requirements:
_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:
path: '/admin/config/user-interface/shortcut/link/{shortcut}/delete-inline'
defaults:

View File

@ -43,9 +43,9 @@ use Symfony\Component\HttpFoundation\Request;
* "langcode" = "langcode",
* },
* links = {
* "canonical" = "entity.shortcut.canonical",
* "delete-form" = "entity.shortcut.delete_form",
* "edit-form" = "entity.shortcut.canonical",
* "canonical" = "/admin/config/user-interface/shortcut/link/{shortcut}",
* "delete-form" = "/admin/config/user-interface/shortcut/link/{shortcut}/delete",
* "edit-form" = "/admin/config/user-interface/shortcut/link/{shortcut}",
* },
* list_cache_tags = { "shortcut_set_list" },
* bundle_entity_type = "shortcut_set"

View File

@ -36,9 +36,9 @@ use Drupal\shortcut\ShortcutSetInterface;
* "label" = "label"
* },
* links = {
* "customize-form" = "entity.shortcut_set.customize_form",
* "delete-form" = "entity.shortcut_set.delete_form",
* "edit-form" = "entity.shortcut_set.edit_form"
* "customize-form" = "/admin/config/user-interface/shortcut/manage/{shortcut_set}/customize",
* "delete-form" = "/admin/config/user-interface/shortcut/manage/{shortcut_set}/delete",
* "edit-form" = "/admin/config/user-interface/shortcut/manage/{shortcut_set}"
* }
* )
*/

View File

@ -327,11 +327,12 @@ use Drupal\language\Entity\ContentLanguageSettings;
* 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
* @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
* the route machine name (defined in your module's routing.yml file) as the
* value; see @ref sec_routes below for some routing notes. Typical link
* types are:
* the path of this link template as the value. The corresponding route
* requires the following route name:
* "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
* own pages) or edit the entity.
* - delete-form: Confirmation form to delete the entity.

View File

@ -1309,8 +1309,8 @@ function system_entity_type_build(array &$entity_types) {
->setFormClass('edit', 'Drupal\system\Form\DateFormatEditForm')
->setFormClass('delete', 'Drupal\system\Form\DateFormatDeleteForm')
->setListBuilderClass('Drupal\system\DateFormatListBuilder')
->setLinkTemplate('edit-form', 'entity.date_format.edit_form')
->setLinkTemplate('delete-form', 'entity.date_format.delete_form');
->setLinkTemplate('edit-form', '/admin/config/regional/date-time/formats/manage/{date_format}')
->setLinkTemplate('delete-form', '/admin/config/regional/date-time/formats/manage/{date_format}/delete');
}
/**

View File

@ -26,6 +26,11 @@ const ENTITY_TEST_TYPES_REVISABLE = 1;
*/
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.
*
@ -47,7 +52,7 @@ const ENTITY_TEST_TYPES_MULTILINGUAL = 2;
*/
function entity_test_entity_types($filter = NULL) {
$types = array();
if ($filter == NULL) {
if ($filter === NULL || $filter === ENTITY_TEST_TYPES_ROUTING) {
$types[] = 'entity_test';
}
if ($filter != ENTITY_TEST_TYPES_REVISABLE) {
@ -57,7 +62,11 @@ function entity_test_entity_types($filter = NULL) {
if ($filter != ENTITY_TEST_TYPES_MULTILINGUAL) {
$types[] = 'entity_test_rev';
}
if ($filter === ENTITY_TEST_TYPES_ROUTING) {
$types[] = 'entity_test_base_field_display';
}
$types[] = 'entity_test_mulrev';
return array_combine($types, $types);
}

View File

@ -41,9 +41,9 @@ use Drupal\user\UserInterface;
* "langcode" = "langcode",
* },
* links = {
* "canonical" = "entity.entity_test.canonical",
* "edit-form" = "entity.entity_test.edit_form",
* "delete-form" = "entity.entity_test.delete_form",
* "canonical" = "/entity_test/{entity_test}",
* "edit-form" = "/entity_test/manage/{entity_test}",
* "delete-form" = "/entity_test/delete/entity_test/{entity_test}",
* },
* field_ui_base_route = "entity.entity_test.admin_form",
* )

View File

@ -30,7 +30,7 @@ use Drupal\Core\Field\BaseFieldDefinition;
* "bundle" = "type"
* },
* 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",
* )

View File

@ -38,9 +38,9 @@ use Drupal\entity_test\Entity\EntityTest;
* "langcode" = "langcode",
* },
* links = {
* "canonical" = "entity.entity_test_mul.edit_form",
* "edit-form" = "entity.entity_test_mul.edit_form",
* "delete-form" = "entity.entity_test_mul.delete_form",
* "canonical" = "/entity_test_mul/manage/{entity_test_mul}",
* "edit-form" = "/entity_test_mul/manage/{entity_test_mul}",
* "delete-form" = "/entity_test/delete/entity_test_mul/{entity_test_mul}",
* },
* field_ui_base_route = "entity.entity_test_mul.admin_form",
* )

View File

@ -37,9 +37,9 @@ use Drupal\Core\Field\BaseFieldDefinition;
* "langcode" = "langcode"
* },
* links = {
* "canonical" = "entity.entity_test_mul.edit_form",
* "edit-form" = "entity.entity_test_mul.edit_form",
* "delete-form" = "entity.entity_test_mul.delete_form",
* "canonical" = "/entity_test_mul_default_value/manage/{entity_test_mul_default_value}",
* "edit-form" = "/entity_test_mul_default_value/manage/{entity_test_mul_default_value}",
* "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",
* )

View File

@ -36,9 +36,9 @@ use Drupal\Core\Entity\EntityTypeInterface;
* "langcode" = "custom_langcode_key",
* },
* links = {
* "canonical" = "entity.entity_test_mul_langcode_key.edit_form",
* "edit-form" = "entity.entity_test_mul_langcode_key.edit_form",
* "delete-form" = "entity.entity_test_mul_langcode_key.delete_form",
* "canonical" = "/entity_test_mul_langcode_key/manage/{entity_test_mul_langcode_key}",
* "edit-form" = "/entity_test_mul_langcode_key/manage/{entity_test_mul_langcode_key}",
* "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",
* )

View File

@ -41,9 +41,9 @@ use Drupal\entity_test\Entity\EntityTestRev;
* "langcode" = "langcode",
* },
* links = {
* "canonical" = "entity.entity_test_mulrev.edit_form",
* "delete-form" = "entity.entity_test_mulrev.delete_form",
* "edit-form" = "entity.entity_test_mulrev.edit_form"
* "canonical" = "/entity_test_mulrev/manage/{entity_test_mulrev}",
* "delete-form" = "/entity_test/delete/entity_test_mulrev/{entity_test_mulrev}",
* "edit-form" = "/entity_test_mulrev/manage/{entity_test_mulrev}",
* }
* )
*/

View File

@ -37,9 +37,9 @@ use Drupal\entity_test\Entity\EntityTest;
* "langcode" = "langcode",
* },
* links = {
* "canonical" = "entity.entity_test_rev.edit_form",
* "delete-form" = "entity.entity_test_rev.delete_form",
* "edit-form" = "entity.entity_test_rev.edit_form"
* "canonical" = "/entity_test_rev/manage/{entity_test_rev}",
* "delete-form" = "/entity_test/delete/entity_test_rev/{entity_test_rev}",
* "edit-form" = "/entity_test_rev/manage/{entity_test_rev}"
* }
* )
*/

View File

@ -29,8 +29,8 @@ use Drupal\Core\Entity\EntityTypeInterface;
* "bundle" = "type"
* },
* links = {
* "canonical" = "entity.entity_test.canonical",
* "edit-form" = "entity.entity_test_string_id.edit_form",
* "canonical" = "/entity_test_string_id/manage/{entity_test_string_id}",
* "edit-form" = "/entity_test_string_id/manage/{entity_test_string_id}",
* },
* field_ui_base_route = "entity.entity_test_string_id.admin_form",
* )

View File

@ -19,13 +19,18 @@ class EntityTestLocalTasks extends DeriverBase {
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = array();
$types = entity_test_entity_types();
$types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING);
foreach($types as $entity_type) {
$this->derivatives[$entity_type] = array();
$this->derivatives[$entity_type]['base_route'] = "entity.$entity_type.edit_form";
$this->derivatives[$entity_type]['route_name'] = "entity.$entity_type.edit_form";
$this->derivatives[$entity_type]['title'] = 'Edit';
$this->derivatives[$entity_type . '.canonical'] = array();
$this->derivatives[$entity_type . '.canonical']['base_route'] = "entity.$entity_type.canonical";
$this->derivatives[$entity_type . '.canonical']['route_name'] = "entity.$entity_type.canonical";
$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);

View File

@ -21,7 +21,7 @@ class EntityTestRoutes {
* An array of route objects.
*/
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_no_id';
@ -33,6 +33,15 @@ class EntityTestRoutes {
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(
$entity_type_id . '/manage/{' . $entity_type_id . '}',
array('_controller' => '\Drupal\entity_test\Controller\EntityTestController::testEdit', 'entity_type_id' => $entity_type_id),

View File

@ -46,9 +46,9 @@ use Drupal\taxonomy\TermInterface;
* bundle_entity_type = "taxonomy_vocabulary",
* field_ui_base_route = "entity.taxonomy_vocabulary.overview_form",
* links = {
* "canonical" = "entity.taxonomy_term.canonical",
* "delete-form" = "entity.taxonomy_term.delete_form",
* "edit-form" = "entity.taxonomy_term.edit_form",
* "canonical" = "/taxonomy/term/{taxonomy_term}",
* "delete-form" = "/taxonomy/term/{taxonomy_term}/delete",
* "edit-form" = "/taxonomy/term/{taxonomy_term}/edit",
* },
* permission_granularity = "bundle"
* )

View File

@ -36,11 +36,11 @@ use Drupal\taxonomy\VocabularyInterface;
* "weight" = "weight"
* },
* links = {
* "add-form" = "entity.taxonomy_term.add_form",
* "delete-form" = "entity.taxonomy_vocabulary.delete_form",
* "reset-form" = "entity.taxonomy_vocabulary.reset_form",
* "overview-form" = "entity.taxonomy_vocabulary.overview_form",
* "edit-form" = "entity.taxonomy_vocabulary.edit_form"
* "add-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/add",
* "delete-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/delete",
* "reset-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/reset",
* "overview-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/overview",
* "edit-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}"
* }
* )
*/

View File

@ -36,9 +36,9 @@ use Drupal\user\RoleInterface;
* "label" = "label"
* },
* links = {
* "delete-form" = "entity.user_role.delete_form",
* "edit-form" = "entity.user_role.edit_form",
* "edit-permissions-form" = "entity.user_role.edit_permissions_form"
* "delete-form" = "/admin/people/roles/manage/{user_role}/delete",
* "edit-form" = "/admin/people/roles/manage/{user_role}",
* "edit-permissions-form" = "/admin/people/permissions/{user_role}"
* }
* )
*/

View File

@ -51,9 +51,9 @@ use Drupal\user\UserInterface;
* "uuid" = "uuid"
* },
* links = {
* "canonical" = "entity.user.canonical",
* "edit-form" = "entity.user.edit_form",
* "cancel-form" = "entity.user.cancel_form",
* "canonical" = "/user/{user}",
* "edit-form" = "/user/{user}/edit",
* "cancel-form" = "/user/{user}/cancel",
* },
* field_ui_base_route = "entity.user.admin_form",
* )

View File

@ -81,13 +81,13 @@ function user_help($route_name, RouteMatchInterface $route_match) {
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>';
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>';
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>';
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>';
}
}

View File

@ -53,14 +53,14 @@ function views_ui_entity_type_build(array &$entity_types) {
->setFormClass('delete', 'Drupal\views_ui\ViewDeleteForm')
->setFormClass('break_lock', 'Drupal\views_ui\Form\BreakLockForm')
->setListBuilderClass('Drupal\views_ui\ViewListBuilder')
->setLinkTemplate('edit-form', 'entity.view.edit_form')
->setLinkTemplate('edit-display-form', 'entity.view.edit_display_form')
->setLinkTemplate('preview-form', 'entity.view.preview_form')
->setLinkTemplate('duplicate-form', 'entity.view.duplicate_form')
->setLinkTemplate('delete-form', 'entity.view.delete_form')
->setLinkTemplate('enable', 'entity.view.enable')
->setLinkTemplate('disable', 'entity.view.disable')
->setLinkTemplate('break-lock-form', 'entity.view.break_lock_form');
->setLinkTemplate('edit-form', '/admin/structure/views/view/{view}')
->setLinkTemplate('edit-display-form', '/admin/structure/views/view/{view}/edit/{display_id}')
->setLinkTemplate('preview-form', '/admin/structure/views/view/{view}/preview/{display_id}')
->setLinkTemplate('duplicate-form', '/admin/structure/views/view/{view}/duplicate')
->setLinkTemplate('delete-form', '/admin/structure/views/view/{view}/delete')
->setLinkTemplate('enable', '/admin/structure/views/view/{view}/enable')
->setLinkTemplate('disable', '/admin/structure/views/view/{view}/disable')
->setLinkTemplate('break-lock-form', '/admin/structure/views/view/{view}/break-lock');
}
/**

View File

@ -241,4 +241,14 @@ class EntityTypeTest extends UnitTestCase {
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');
}
}

View File

@ -65,10 +65,10 @@ class EntityUrlTest extends UnitTestCase {
*/
public function providerTestUrlInfo() {
return array(
array('Drupal\Core\Entity\Entity', 'edit-form', 'test_entity_type.edit'),
array('Drupal\Core\Config\Entity\ConfigEntityBase', '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', 'entity.test_entity_type.edit_form'),
// 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')
->will($this->returnValueMap(array(
array(
'test_entity_type.view',
'entity.test_entity_type.canonical',
array('test_entity_type' => 'test_entity_id'),
array('entity_type' => 'test_entity_type', 'entity' => $valid_entity),
'/entity/test_entity_type/test_entity_id',
),
array(
'test_entity_type.view',
'entity.test_entity_type.canonical',
array('test_entity_type' => 'test_entity_id'),
array('absolute' => TRUE, 'entity_type' => 'test_entity_type', 'entity' => $valid_entity),
'http://drupal/entity/test_entity_type/test_entity_id',
@ -208,7 +208,7 @@ class EntityUrlTest extends UnitTestCase {
$entity_type->expects($this->exactly(3))
->method('getLinkTemplates')
->will($this->returnValue(array(
'canonical' => 'test_entity_type.view',
'canonical' => 'entity.test_entity_type.canonical',
)));
$this->entityManager
@ -222,7 +222,7 @@ class EntityUrlTest extends UnitTestCase {
$this->urlGenerator->expects($this->once())
->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'));
$valid_entity = $this->getMockForAbstractClass('Drupal\Core\Entity\Entity', array(array('id' => 'test_entity_id'), 'test_entity_type'));