diff --git a/core/modules/node/node.install b/core/modules/node/node.install index d276693292..676e05e2b6 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -8,8 +8,6 @@ use Drupal\Core\Url; use Drupal\Core\Database\Database; use Drupal\user\RoleInterface; -use Drupal\Core\Config\FileStorage; -use Drupal\Core\Config\InstallStorage; /** * Implements hook_requirements(). @@ -162,20 +160,3 @@ function node_uninstall() { function node_update_last_removed() { return 8700; } - -/** - * Update the content view to add the 'Add content' link when there is no content. - */ -function node_update_8707() { - $module_handler = \Drupal::moduleHandler(); - // If Views is not installed, there is nothing to do. - if (!$module_handler->moduleExists('views')) { - return; - } - - // The following snippet updates the content view configuration. - $optional_install_path = $module_handler->getModule('node')->getPath() . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY; - $source = new FileStorage($optional_install_path); - $config_storage = \Drupal::service('config.storage'); - $config_storage->write('views.view.content', $source->read('views.view.content')); -} diff --git a/core/modules/node/node.post_update.php b/core/modules/node/node.post_update.php index 82d1f41fd3..ecbb9b3691 100644 --- a/core/modules/node/node.post_update.php +++ b/core/modules/node/node.post_update.php @@ -14,3 +14,16 @@ function node_removed_post_updates() { 'node_post_update_node_revision_views_data' => '9.0.0', ]; } + +/** + * Adds the 'Add content' link to content listing when there is no content. + */ +function node_post_update_empty_admin_content() { + $module_handler = \Drupal::moduleHandler(); + // If Views is not installed, there is nothing to do. + if (!$module_handler->moduleExists('views')) { + return; + } + + // TODO update 'views.view.content' view. +} diff --git a/core/modules/node/src/NodeViewsData.php b/core/modules/node/src/NodeViewsData.php index e1ac6106c5..aef57411c0 100644 --- a/core/modules/node/src/NodeViewsData.php +++ b/core/modules/node/src/NodeViewsData.php @@ -193,8 +193,8 @@ public function getViewsData() { ]; $data['node_field_data']['node_admin_listing_empty'] = [ - 'title' => t('Empty Node List'), - 'help' => t('Provides a link to the node add overview page for admin.'), + 'title' => $this->t('Empty Node List'), + 'help' => $this->t('Provides a link to the node add overview page for admin.'), 'area' => [ 'id' => 'node_admin_listing_empty', ], diff --git a/core/modules/node/src/Plugin/views/area/AdminListingEmpty.php b/core/modules/node/src/Plugin/views/area/AdminListingEmpty.php index cb5bc1069f..ae5979fd90 100644 --- a/core/modules/node/src/Plugin/views/area/AdminListingEmpty.php +++ b/core/modules/node/src/Plugin/views/area/AdminListingEmpty.php @@ -2,13 +2,10 @@ namespace Drupal\node\Plugin\views\area; -use Drupal\Core\Access\AccessManagerInterface; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Url; use Drupal\views\Plugin\views\area\AreaPluginBase; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Utility\LinkGeneratorInterface; -use Drupal\Core\Session\AccountProxyInterface; /** * Defines an area plugin to display a node/add link. @@ -40,42 +37,20 @@ class AdminListingEmpty extends AreaPluginBase { */ protected $currentUser; - /** - * Constructs a new AdminListingEmpty. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin ID for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Access\AccessManagerInterface $access_manager - * The access manager. - * @param \Drupal\Core\Utility\LinkGeneratorInterface $link_generator - * The link generator. - * @param \Drupal\Core\Session\AccountProxyInterface $current_user - * The current user. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, AccessManagerInterface $access_manager, LinkGeneratorInterface $link_generator, AccountProxyInterface $current_user) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - - $this->accessManager = $access_manager; - $this->linkGenerator = $link_generator; - $this->currentUser = $current_user; - } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( + $instance = new static( $configuration, $plugin_id, - $plugin_definition, - $container->get('access_manager'), - $container->get('link_generator'), - $container->get('current_user') + $plugin_definition ); + $instance->accessManager = $container->get('access_manager'); + $instance->linkGenerator = $container->get('link_generator'); + $instance->currentUser = $container->get('current_user'); + $instance->stringTranslation = $container->get('string_translation'); + return $instance; } /** @@ -83,7 +58,6 @@ public static function create(ContainerInterface $container, array $configuratio */ public function render($empty = FALSE) { if (!$empty || !empty($this->options['empty'])) { - /** @var \Drupal\Core\Access\AccessResultInterface|\Drupal\Core\Cache\CacheableDependencyInterface $access_result */ $access_result = $this->accessManager->checkNamedRoute('node.add_page', [], $this->currentUser, TRUE); $element = [ '#type' => 'link',