Commit 3d14a7d2 authored by alexpott's avatar alexpott
Browse files

Issue #2401505 by Berdir, jibran, larowlan: Add an entity collection template for lists

parent 99377f95
......@@ -274,9 +274,12 @@ public function url($rel = 'canonical', $options = array()) {
* An array of URI placeholders.
*/
protected function urlRouteParameters($rel) {
// The entity ID is needed as a route parameter.
$uri_route_parameters[$this->getEntityTypeId()] = $this->id();
$uri_route_parameters = [];
if ($rel != 'collection') {
// The entity ID is needed as a route parameter.
$uri_route_parameters[$this->getEntityTypeId()] = $this->id();
}
return $uri_route_parameters;
}
......
......@@ -21,7 +21,7 @@ interface LinkGeneratorInterface {
* However, for links enclosed in translatable text you should use t() and
* embed the HTML anchor tag directly in the translated string. For example:
* @code
* t('Visit the <a href="@url">content types</a> page', array('@url' => \Drupal::url('node.overview_types')));
* t('Visit the <a href="@url">content types</a> page', array('@url' => \Drupal::url('entity.node_type.collection')));
* @endcode
* This keeps the context of the link title ('settings' in the example) for
* translators.
......
......@@ -4,4 +4,4 @@ description: 'Perform tasks on specific events triggered within the system.'
package: Core
version: VERSION
core: 8.x
configure: action.admin
configure: entity.action.collection
action.admin:
title: Actions
description: 'Manage the actions defined for your site.'
route_name: action.admin
route_name: entity.action.collection
parent: system.admin_config_system
action.admin:
route_name: action.admin
route_name: entity.action.collection
title: 'Manage actions'
base_route: action.admin
base_route: entity.action.collection
......@@ -19,13 +19,13 @@ function action_help($route_name, RouteMatchInterface $route_match) {
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Using simple actions') . '</dt>';
$output .= '<dd>' . t('<em>Simple actions</em> do not require configuration and are listed automatically as available on the <a href="!actions">Actions page</a>.', array('!actions' => \Drupal::url('action.admin'))) . '</dd>';
$output .= '<dd>' . t('<em>Simple actions</em> do not require configuration and are listed automatically as available on the <a href="!actions">Actions page</a>.', array('!actions' => \Drupal::url('entity.action.collection'))) . '</dd>';
$output .= '<dt>' . t('Creating and configuring advanced actions') . '</dt>';
$output .= '<dd>' . t('<em>Advanced actions</em> are user-created and have to be configured individually. Create an advanced action on the <a href="!actions">Actions page</a> by selecting an action type from the drop-down list. Then configure your action, for example by specifying the recipient of an automated email message.', array('!actions' => \Drupal::url('action.admin'))) . '</dd>';
$output .= '<dd>' . t('<em>Advanced actions</em> are user-created and have to be configured individually. Create an advanced action on the <a href="!actions">Actions page</a> by selecting an action type from the drop-down list. Then configure your action, for example by specifying the recipient of an automated email message.', array('!actions' => \Drupal::url('entity.action.collection'))) . '</dd>';
$output .= '</dl>';
return $output;
case 'action.admin':
case 'entity.action.collection':
$output = '<p>' . t('There are two types of actions: simple and advanced. Simple actions do not require any additional configuration and are listed here automatically. Advanced actions need to be created and configured before they can be used because they have options that need to be specified; for example, sending an email to a specified address or unpublishing content containing certain words. To create an advanced action, select the action from the drop-down list in the advanced action section below and click the <em>Create</em> button.') . '</p>';
return $output;
......@@ -45,5 +45,6 @@ function action_entity_type_build(array &$entity_types) {
->setFormClass('delete', 'Drupal\action\Form\ActionDeleteForm')
->setListBuilderClass('Drupal\action\ActionListBuilder')
->setLinkTemplate('delete-form', '/admin/config/system/actions/configure/{action}/delete')
->setLinkTemplate('edit-form', '/admin/config/system/actions/configure/{action}');
->setLinkTemplate('edit-form', '/admin/config/system/actions/configure/{action}')
->setLinkTemplate('collection', '/admin/config/system/actions');
}
action.admin:
entity.action.collection:
path: '/admin/config/system/actions'
defaults:
_title: 'Actions'
......
......@@ -149,7 +149,7 @@ public function save(array $form, FormStateInterface $form_state) {
$this->entity->save();
drupal_set_message($this->t('The action has been successfully saved.'));
$form_state->setRedirect('action.admin');
$form_state->setRedirect('entity.action.collection');
}
}
......@@ -34,7 +34,7 @@ public function getConfirmText() {
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('action.admin');
return new Url('entity.action.collection');
}
/**
......
......@@ -25,7 +25,7 @@ protected function setUp() {
* Tests local task existence.
*/
public function testActionLocalTasks() {
$this->assertLocalTasks('action.admin', array(array('action.admin')));
$this->assertLocalTasks('entity.action.collection', array(array('action.admin')));
}
}
......@@ -7,4 +7,4 @@ core: 8.x
dependencies:
- block
- text
configure: block_content.list
configure: entity.block_content.collection
......@@ -2,7 +2,7 @@ block_content_type_add:
route_name: block_content.type_add
title: 'Add custom block type'
appears_on:
- block_content.type_list
- entity.block_content_type.collection
block_content_add_action:
route_name: block_content.add_page
......@@ -10,5 +10,5 @@ block_content_add_action:
appears_on:
- block.admin_display
- block.admin_display_theme
- block_content.list
- entity.block_content.collection
class: \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction
block_content.list:
entity.block_content.collection:
title: 'Custom block library'
route_name: block_content.list
route_name: entity.block_content.collection
base_route: block.admin_display
block_content.list_sub:
title: Blocks
route_name: block_content.list
parent_id: block_content.list
block_content.type_list:
route_name: entity.block_content.collection
parent_id: entity.block_content.collection
entity.block_content_type.collection:
title: Types
route_name: block_content.type_list
parent_id: block_content.list
route_name: entity.block_content_type.collection
parent_id: entity.block_content.collection
weight: 1
entity.block_content.canonical:
......
......@@ -17,21 +17,21 @@ function block_content_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.block_content':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Custom Block module allows you to create blocks of content, which can be placed in regions throughout the website. Custom blocks can have fields; see the <a href="!field-help">Field module help</a> for more information. Once created, custom blocks can be placed like blocks provided by other modules; see the <a href="!blocks">Block module help page</a> for details. For more information, see <a href="!online-help">the online documentation for the Custom Block module</a>.', array('!block-content' => \Drupal::url('block_content.list'), '!field-help' => \Drupal::url('help.page', array('name' => 'field')), '!blocks' => \Drupal::url('help.page', array('name' => 'block')), '!online-help' => 'https://drupal.org/documentation/modules/block_content')) . '</p>';
$output .= '<p>' . t('The Custom Block module allows you to create blocks of content, which can be placed in regions throughout the website. Custom blocks can have fields; see the <a href="!field-help">Field module help</a> for more information. Once created, custom blocks can be placed like blocks provided by other modules; see the <a href="!blocks">Block module help page</a> for details. For more information, see <a href="!online-help">the online documentation for the Custom Block module</a>.', array('!block-content' => \Drupal::url('entity.block_content.collection'), '!field-help' => \Drupal::url('help.page', array('name' => 'field')), '!blocks' => \Drupal::url('help.page', array('name' => 'block')), '!online-help' => 'https://drupal.org/documentation/modules/block_content')) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Creating and managing custom block types') . '</dt>';
$output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create different custom block types, each with different fields and display settings, from the <a href="!types">Custom block types</a> page. The Custom block types page lists all of your created custom block types, and allows you to edit and manage them. For more information about managing fields and display settings, see the <a href="!field-ui">Field UI module help</a>.', array('!types' => \Drupal::url('block_content.type_list'), '!field-ui' => \Drupal::url('help.page', array('name' => 'field_ui')))) . '</dd>';
$output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create different custom block types, each with different fields and display settings, from the <a href="!types">Custom block types</a> page. The Custom block types page lists all of your created custom block types, and allows you to edit and manage them. For more information about managing fields and display settings, see the <a href="!field-ui">Field UI module help</a>.', array('!types' => \Drupal::url('entity.block_content_type.collection'), '!field-ui' => \Drupal::url('help.page', array('name' => 'field_ui')))) . '</dd>';
$output .= '<dt>' . t('Creating custom blocks') . '</dt>';
$output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can <a href="!block-add">add custom blocks</a> of each of their defined custom block types. Created custom blocks are then listed on the <a href="!blocks">Blocks administration page</a>.', array('!blocks' => \Drupal::url('block.admin_display'), '!block-add' => \Drupal::url('block_content.add_page'))) . '</dd>';
$output .= '</dl>';
return $output;
case 'block_content.list':
case 'entity.block_content.collection':
$output = '<p>' . t('This page lists user-created blocks. These blocks are derived from block types. A block type can consist of different fields and display settings. From the block types tab you can manage these fields as well as create new block types.') . '</p>';
return $output;
case 'block_content.type_list':
case 'entity.block_content_type.collection':
$output = '<p>' . t('This page lists block types. A block type can consist of different fields and display settings. From here you can manage these fields as well as create new block types.') . '</p>';
return $output;
......
block_content.type_list:
entity.block_content_type.collection:
path: '/admin/structure/block/block-content/types'
defaults:
_entity_list: 'block_content_type'
......@@ -80,7 +80,7 @@ entity.block_content_type.edit_form:
requirements:
_entity_access: 'block_content_type.update'
block_content.list:
entity.block_content.collection:
path: '/admin/structure/block/block-content'
defaults:
_title: 'Custom block library'
......
......@@ -198,7 +198,7 @@ public function save(array $form, FormStateInterface $form_state) {
);
}
else {
$form_state->setRedirect('block_content.list');
$form_state->setRedirectUrl($block->urlInfo('collection'));
}
}
else {
......
......@@ -108,7 +108,7 @@ public function save(array $form, FormStateInterface $form_state) {
$logger->notice('Custom block type %label has been added.', array('%label' => $block_type->label(), 'link' => $edit_link));
}
$form_state->setRedirect('block_content.type_list');
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
}
}
......@@ -42,6 +42,7 @@
* "canonical" = "/block/{block_content}",
* "delete-form" = "/block/{block_content}/delete",
* "edit-form" = "/block/{block_content}",
* "collection" = "/admin/structure/block/block-content",
* },
* translatable = TRUE,
* entity_keys = {
......
......@@ -36,7 +36,8 @@
* },
* links = {
* "delete-form" = "/admin/structure/block/block-content/manage/{block_content_type}/delete",
* "edit-form" = "/admin/structure/block/block-content/manage/{block_content_type}"
* "edit-form" = "/admin/structure/block/block-content/manage/{block_content_type}",
* "collection" = "/admin/structure/block/block-content/types",
* }
* )
*/
......
......@@ -58,7 +58,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->delete();
drupal_set_message($this->t('Custom block %label has been deleted.', array('%label' => $this->entity->label())));
$this->logger('block_content')->notice('Custom block %label has been deleted.', array('%label' => $this->entity->label()));
$form_state->setRedirect('block_content.list');
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
}
}
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