diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3083663 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +sites/default/files/* diff --git a/core/lib/Drupal/Core/Entity/EntityListBuilder.php b/core/lib/Drupal/Core/Entity/EntityListBuilder.php index b7b1347..4cdfe62 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 Add Entity type link + * + * @return string Add link + */ + protected function createAddLink() { + $add_link = ''; + if ($link_template = $this->entityType->getLinkTemplate('add-entity-form')) { + $link_object = new Url($link_template); + $add_link = \Drupal::linkGenerator()->generateFromUrl( + $this->t('Add @label.', array('@label' => $this->entityType->getLabel())), + $link_object + ); + } + + 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/node/lib/Drupal/node/Entity/NodeType.php b/core/modules/node/lib/Drupal/node/Entity/NodeType.php index fde17a2..5b66faa 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 45bac57..4a4cc80 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; - } }