Commit 34d3c8c7 authored by alexpott's avatar alexpott

Issue #2473215 by smccabe, joshi.rohit100, googletorp, drubb, sumitmadan,...

Issue #2473215 by smccabe, joshi.rohit100, googletorp, drubb, sumitmadan, m4olivei, jmolivas, darol100, meramo: Wrong text if no content types are available
parent 24c73b42
......@@ -8,10 +8,7 @@
namespace Drupal\node;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityTypeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Core\Url;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Component\Utility\Xss;
......@@ -22,39 +19,6 @@
*/
class NodeTypeListBuilder extends ConfigEntityListBuilder {
/**
* The url generator service.
*
* @var \Drupal\Core\Routing\UrlGeneratorInterface
*/
protected $urlGenerator;
/**
* Constructs a NodeTypeListBuilder object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage class.
* @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
* The url generator service.
*/
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, UrlGeneratorInterface $url_generator) {
parent::__construct($entity_type, $storage);
$this->urlGenerator = $url_generator;
}
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('url_generator')
);
}
/**
* {@inheritdoc}
*/
......@@ -97,9 +61,9 @@ public function getDefaultOperations(EntityInterface $entity) {
*/
public function render() {
$build = parent::render();
$build['#empty'] = t('No content types available. <a href="@link">Add content type</a>.', array(
'@link' => $this->urlGenerator->generateFromPath('admin/structure/types/add'),
));
$build['table']['#empty'] = $this->t('No content types available. <a href="@link">Add content type</a>.', [
'@link' => Url::fromRoute('node.type_add')->toString()
]);
return $build;
}
......
......@@ -9,6 +9,7 @@
use Drupal\field\Entity\FieldConfig;
use Drupal\node\Entity\NodeType;
use Drupal\Core\Url;
/**
* Ensures that node type functions work correctly.
......@@ -22,7 +23,7 @@ class NodeTypeTest extends NodeTestBase {
*
* @var array
*/
public static $modules = array('field_ui');
public static $modules = ['field_ui'];
/**
* Ensures that node type functions (node_type_get_*) work correctly.
......@@ -204,4 +205,23 @@ public function testNodeTypeFieldUiPermissions() {
$this->assertLinkByHref('admin/structure/types/manage/article/display');
}
/**
* Tests for when there are no content types defined.
*/
public function testNodeTypeNoContentType() {
$web_user = $this->drupalCreateUser(['administer content types']);
$this->drupalLogin($web_user);
// Delete 'article' bundle.
$this->drupalPostForm('admin/structure/types/manage/article/delete', [], t('Delete'));
// Delete 'page' bundle.
$this->drupalPostForm('admin/structure/types/manage/page/delete', [], t('Delete'));
// Navigate to content type administration screen
$this->drupalGet('admin/structure/types');
$this->assertRaw(t('No content types available. <a href="@link">Add content type</a>.', [
'@link' => Url::fromRoute('node.type_add')->toString()
]), 'Empty text when there are no content types in the system is correct.');
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment