diff --git a/core/lib/Drupal/Core/Entity/EntityListBuilder.php b/core/lib/Drupal/Core/Entity/EntityListBuilder.php index b7b1347..932a0e6 100644 --- a/core/lib/Drupal/Core/Entity/EntityListBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityListBuilder.php @@ -11,6 +11,7 @@ use Drupal\Core\StringTranslation\TranslationInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Component\Utility\String; +use Drupal\Core\Url; /** * Defines a generic implementation to build a listing of entities. @@ -191,7 +192,7 @@ public function render() { '#header' => $this->buildHeader(), '#title' => $this->getTitle(), '#rows' => array(), - '#empty' => $this->t('There is no @label yet.', array('@label' => $this->entityType->getLabel())), + '#empty' => $this->t('There is no @label yet. !add_link', array('@label' => $this->entityType->getLabel(), '!add_link' => $this->createAddLink())), ); foreach ($this->load() as $entity) { if ($row = $this->buildRow($entity)) { @@ -202,6 +203,24 @@ public function render() { } /** + * Creates link to add entity of current entity type. + * + * @return string HTML anchor element + */ + protected function createAddLink() { + $add_link = ''; + if ($link_template = $this->entityType->getLinkTemplate('add-entity-form')) { + $url = new Url($link_template); + $add_link = \Drupal::linkGenerator()->generateFromUrl( + $this->t('Add @label.', array('@label' => $this->entityType->getLabel())), + $url + ); + } + + return $add_link; + } + + /** * Translates a string to the current language or to a given language. * * See the t() documentation for details. diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php index 71913b7..dab73c6 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php @@ -39,7 +39,8 @@ * "canonical" = "custom_block.edit", * "delete-form" = "custom_block.delete", * "edit-form" = "custom_block.edit", - * "admin-form" = "custom_block.type_edit" + * "admin-form" = "custom_block.type_edit", + * "add-entity-form" = "custom_block.add_page" * }, * fieldable = TRUE, * translatable = TRUE, diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php index a7674d0..013ea95 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php @@ -35,7 +35,8 @@ * }, * links = { * "delete-form" = "custom_block.type_delete", - * "edit-form" = "custom_block.type_edit" + * "edit-form" = "custom_block.type_edit", + * "add-entity-form" = "custom_block.type_add" * } * ) */ diff --git a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php index d6e7d2a..d885d0c 100644 --- a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php @@ -43,7 +43,8 @@ * links = { * "flush-form" = "image.style_flush", * "edit-form" = "image.style_edit", - * "delete-form" = "image.style_delete" + * "delete-form" = "image.style_delete", + * "add-entity-form" = "image.style_add" * } * ) */ diff --git a/core/modules/image/lib/Drupal/image/ImageStyleListBuilder.php b/core/modules/image/lib/Drupal/image/ImageStyleListBuilder.php index 73dfe6c..98f6740 100644 --- a/core/modules/image/lib/Drupal/image/ImageStyleListBuilder.php +++ b/core/modules/image/lib/Drupal/image/ImageStyleListBuilder.php @@ -85,15 +85,4 @@ public function getDefaultOperations(EntityInterface $entity) { ); } - /** - * {@inheritdoc} - */ - public function render() { - $build = parent::render(); - $build['#empty'] = $this->t('There are currently no styles. Add a new one.', array( - '!url' => $this->urlGenerator->generateFromPath('admin/config/media/image-styles/add'), - )); - return $build; - } - } diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php index 1fc6f03..060dcca 100644 --- a/core/modules/node/lib/Drupal/node/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Entity/Node.php @@ -55,7 +55,8 @@ * "delete-form" = "node.delete_confirm", * "edit-form" = "node.page_edit", * "version-history" = "node.revision_overview", - * "admin-form" = "node.type_edit" + * "admin-form" = "node.type_edit", + * "add-entity-form" = "node.add_page" * } * ) */ diff --git a/core/modules/node/lib/Drupal/node/Entity/NodeType.php b/core/modules/node/lib/Drupal/node/Entity/NodeType.php index 1c3a839..3640b5b 100644 --- a/core/modules/node/lib/Drupal/node/Entity/NodeType.php +++ b/core/modules/node/lib/Drupal/node/Entity/NodeType.php @@ -37,7 +37,8 @@ * links = { * "add-form" = "node.add", * "edit-form" = "node.type_edit", - * "delete-form" = "node.type_delete_confirm" + * "delete-form" = "node.type_delete_confirm", + * "add-entity-form" = "node.type_add" * } * ) */ diff --git a/core/modules/node/lib/Drupal/node/NodeTypeListBuilder.php b/core/modules/node/lib/Drupal/node/NodeTypeListBuilder.php index 779672a..c6bcdc4 100644 --- a/core/modules/node/lib/Drupal/node/NodeTypeListBuilder.php +++ b/core/modules/node/lib/Drupal/node/NodeTypeListBuilder.php @@ -93,15 +93,5 @@ public function getDefaultOperations(EntityInterface $entity) { return $operations; } - /** - * {@inheritdoc} - */ - public function render() { - $build = parent::render(); - $build['#empty'] = t('No content types available. Add content type.', array( - '@link' => $this->urlGenerator->generateFromPath('admin/structure/types/add'), - )); - return $build; - } } diff --git a/core/modules/responsive_image/lib/Drupal/responsive_image/Entity/ResponsiveImageMapping.php b/core/modules/responsive_image/lib/Drupal/responsive_image/Entity/ResponsiveImageMapping.php index d94d376..1eb8375 100644 --- a/core/modules/responsive_image/lib/Drupal/responsive_image/Entity/ResponsiveImageMapping.php +++ b/core/modules/responsive_image/lib/Drupal/responsive_image/Entity/ResponsiveImageMapping.php @@ -34,7 +34,8 @@ * }, * links = { * "edit-form" = "responsive_image.mapping_page_edit", - * "duplicate-form" = "responsive_image.mapping_page_duplicate" + * "duplicate-form" = "responsive_image.mapping_page_duplicate", + * "add-entity-form" = "responsive_image.mapping_page_add" * } * ) */ diff --git a/core/modules/system/lib/Drupal/system/Entity/DateFormat.php b/core/modules/system/lib/Drupal/system/Entity/DateFormat.php index a3d6ece..d7d6d35 100644 --- a/core/modules/system/lib/Drupal/system/Entity/DateFormat.php +++ b/core/modules/system/lib/Drupal/system/Entity/DateFormat.php @@ -33,7 +33,8 @@ * admin_permission = "administer site configuration", * links = { * "delete-form" = "system.date_format_delete", - * "edit-form" = "system.date_format_edit" + * "edit-form" = "system.date_format_edit", + * "add-entity-form" = "system.date_format_add" * } * ) */