Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -17,119 +17,119 @@ function book_uninstall() {
|
|||
* Implements hook_schema().
|
||||
*/
|
||||
function book_schema() {
|
||||
$schema['book'] = array(
|
||||
$schema['book'] = [
|
||||
'description' => 'Stores book outline information. Uniquely defines the location of each node in the book outline',
|
||||
'fields' => array(
|
||||
'nid' => array(
|
||||
'fields' => [
|
||||
'nid' => [
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => "The book page's {node}.nid.",
|
||||
),
|
||||
'bid' => array(
|
||||
],
|
||||
'bid' => [
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => "The book ID is the {book}.nid of the top-level page.",
|
||||
),
|
||||
'pid' => array(
|
||||
],
|
||||
'pid' => [
|
||||
'description' => 'The parent ID (pid) is the id of the node above in the hierarchy, or zero if the node is at the top level in its outline.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'has_children' => array(
|
||||
],
|
||||
'has_children' => [
|
||||
'description' => 'Flag indicating whether any nodes have this node as a parent (1 = children exist, 0 = no children).',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'size' => 'small',
|
||||
),
|
||||
'weight' => array(
|
||||
],
|
||||
'weight' => [
|
||||
'description' => 'Weight among book entries in the same book at the same depth.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'depth' => array(
|
||||
],
|
||||
'depth' => [
|
||||
'description' => 'The depth relative to the top level. A link with pid == 0 will have depth == 1.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'size' => 'small',
|
||||
),
|
||||
'p1' => array(
|
||||
],
|
||||
'p1' => [
|
||||
'description' => 'The first nid in the materialized path. If N = depth, then pN must equal the nid. If depth > 1 then p(N-1) must equal the pid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'p2' => array(
|
||||
],
|
||||
'p2' => [
|
||||
'description' => 'The second nid in the materialized path. See p1.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'p3' => array(
|
||||
],
|
||||
'p3' => [
|
||||
'description' => 'The third nid in the materialized path. See p1.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'p4' => array(
|
||||
],
|
||||
'p4' => [
|
||||
'description' => 'The fourth nid in the materialized path. See p1.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'p5' => array(
|
||||
],
|
||||
'p5' => [
|
||||
'description' => 'The fifth nid in the materialized path. See p1.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'p6' => array(
|
||||
],
|
||||
'p6' => [
|
||||
'description' => 'The sixth nid in the materialized path. See p1.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'p7' => array(
|
||||
],
|
||||
'p7' => [
|
||||
'description' => 'The seventh nid in the materialized path. See p1.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'p8' => array(
|
||||
],
|
||||
'p8' => [
|
||||
'description' => 'The eighth nid in the materialized path. See p1.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'p9' => array(
|
||||
],
|
||||
'p9' => [
|
||||
'description' => 'The ninth nid in the materialized path. See p1.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
),
|
||||
'primary key' => array('nid'),
|
||||
'indexes' => array(
|
||||
'book_parents' => array('bid', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
'primary key' => ['nid'],
|
||||
'indexes' => [
|
||||
'book_parents' => ['bid', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'],
|
||||
],
|
||||
];
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
|
|
@ -25,17 +25,17 @@ function book_help($route_name, RouteMatchInterface $route_match) {
|
|||
switch ($route_name) {
|
||||
case 'help.page.book':
|
||||
$output = '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chapters, sections, subsections, or any similarly-tiered structure. Enabling the module creates a new content type <em>Book page</em>. For more information, see the <a href=":book">online documentation for the Book module</a>.', array(':book' => 'https://www.drupal.org/documentation/modules/book')) . '</p>';
|
||||
$output .= '<p>' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chapters, sections, subsections, or any similarly-tiered structure. Enabling the module creates a new content type <em>Book page</em>. For more information, see the <a href=":book">online documentation for the Book module</a>.', [':book' => 'https://www.drupal.org/documentation/modules/book']) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Adding and managing book content') . '</dt>';
|
||||
$output .= '<dd>' . t('Books have a hierarchical structure, called a <em>book outline</em>. Each book outline can have nested pages up to nine levels deep. Multiple content types can be configured to behave as a book outline. From the content edit form, it is possible to add a page to a book outline or create a new book.') . '</dd>';
|
||||
$output .= '<dd>' . t('You can assign separate permissions for <em>creating new books</em> as well as <em>creating</em>, <em>editing</em> and <em>deleting</em> book content. Users with the <em>Administer book outlines</em> permission can add <em>any</em> type of content to a book by selecting the appropriate book outline while editing the content. They can also view a list of all books, and edit and rearrange section titles on the <a href=":admin-book">Book list page</a>.', array(':admin-book' => \Drupal::url('book.admin'))) . '</dd>';
|
||||
$output .= '<dd>' . t('You can assign separate permissions for <em>creating new books</em> as well as <em>creating</em>, <em>editing</em> and <em>deleting</em> book content. Users with the <em>Administer book outlines</em> permission can add <em>any</em> type of content to a book by selecting the appropriate book outline while editing the content. They can also view a list of all books, and edit and rearrange section titles on the <a href=":admin-book">Book list page</a>.', [':admin-book' => \Drupal::url('book.admin')]) . '</dd>';
|
||||
$output .= '<dt>' . t('Configuring content types for books') . '</dt>';
|
||||
$output .= '<dd>' . t('The <em>Book page</em> content type is the initial content type enabled for book outlines. On the <a href=":admin-settings">Book settings page</a> you can configure content types that can used in book outlines.', array(':admin-settings' => \Drupal::url('book.settings'))) . '</dd>';
|
||||
$output .= '<dd>' . t('Users with the <em>Add content and child pages to books</em> permission will see a link to <em>Add child page</em> when viewing a content item that is part of a book outline. This link will allow users to create a new content item of the content type you select on the <a href=":admin-settings">Book settings page</a>. By default this is the <em>Book page</em> content type.', array(':admin-settings' => \Drupal::url('book.settings'))) . '</dd>';
|
||||
$output .= '<dd>' . t('The <em>Book page</em> content type is the initial content type enabled for book outlines. On the <a href=":admin-settings">Book settings page</a> you can configure content types that can used in book outlines.', [':admin-settings' => \Drupal::url('book.settings')]) . '</dd>';
|
||||
$output .= '<dd>' . t('Users with the <em>Add content and child pages to books</em> permission will see a link to <em>Add child page</em> when viewing a content item that is part of a book outline. This link will allow users to create a new content item of the content type you select on the <a href=":admin-settings">Book settings page</a>. By default this is the <em>Book page</em> content type.', [':admin-settings' => \Drupal::url('book.settings')]) . '</dd>';
|
||||
$output .= '<dt>' . t('Book navigation') . '</dt>';
|
||||
$output .= '<dd>' . t("Book pages have a default book-specific navigation block. This navigation block contains links that lead to the previous and next pages in the book, and to the level above the current page in the book's structure. This block can be enabled on the <a href=':admin-block'>Blocks layout page</a>. For book pages to show up in the book navigation, they must be added to a book outline.", array(':admin-block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';
|
||||
$output .= '<dd>' . t("Book pages have a default book-specific navigation block. This navigation block contains links that lead to the previous and next pages in the book, and to the level above the current page in the book's structure. This block can be enabled on the <a href=':admin-block'>Blocks layout page</a>. For book pages to show up in the book navigation, they must be added to a book outline.", [':admin-block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '</dd>';
|
||||
$output .= '<dt>' . t('Collaboration') . '</dt>';
|
||||
$output .= '<dd>' . t('Books can be created collaboratively, as they allow users with appropriate permissions to add pages into existing books, and add those pages to a custom table of contents.') . '</dd>';
|
||||
$output .= '<dt>' . t('Printing books') . '</dt>';
|
||||
|
@ -47,7 +47,7 @@ function book_help($route_name, RouteMatchInterface $route_match) {
|
|||
return '<p>' . t('The book module offers a means to organize a collection of related content pages, collectively known as a book. When viewed, this content automatically displays links to adjacent book pages, providing a simple navigation system for creating and reviewing structured content.') . '</p>';
|
||||
|
||||
case 'entity.node.book_outline_form':
|
||||
return '<p>' . t('The outline feature allows you to include pages in the <a href=":book">Book hierarchy</a>, as well as move them within the hierarchy or to <a href=":book-admin">reorder an entire book</a>.', array(':book' => \Drupal::url('book.render'), ':book-admin' => \Drupal::url('book.admin'))) . '</p>';
|
||||
return '<p>' . t('The outline feature allows you to include pages in the <a href=":book">Book hierarchy</a>, as well as move them within the hierarchy or to <a href=":book-admin">reorder an entire book</a>.', [':book' => \Drupal::url('book.render'), ':book-admin' => \Drupal::url('book.admin')]) . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,23 +55,23 @@ function book_help($route_name, RouteMatchInterface $route_match) {
|
|||
* Implements hook_theme().
|
||||
*/
|
||||
function book_theme() {
|
||||
return array(
|
||||
'book_navigation' => array(
|
||||
'variables' => array('book_link' => NULL),
|
||||
),
|
||||
'book_tree' => array(
|
||||
'variables' => array('items' => array(), 'attributes' => array()),
|
||||
),
|
||||
'book_export_html' => array(
|
||||
'variables' => array('title' => NULL, 'contents' => NULL, 'depth' => NULL),
|
||||
),
|
||||
'book_all_books_block' => array(
|
||||
return [
|
||||
'book_navigation' => [
|
||||
'variables' => ['book_link' => NULL],
|
||||
],
|
||||
'book_tree' => [
|
||||
'variables' => ['items' => [], 'attributes' => []],
|
||||
],
|
||||
'book_export_html' => [
|
||||
'variables' => ['title' => NULL, 'contents' => NULL, 'depth' => NULL],
|
||||
],
|
||||
'book_all_books_block' => [
|
||||
'render element' => 'book_menus',
|
||||
),
|
||||
'book_node_export_html' => array(
|
||||
'variables' => array('node' => NULL, 'content' => NULL, 'children' => NULL),
|
||||
),
|
||||
);
|
||||
],
|
||||
'book_node_export_html' => [
|
||||
'variables' => ['node' => NULL, 'content' => NULL, 'children' => NULL],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,31 +97,31 @@ function book_node_links_alter(array &$links, NodeInterface $node, array &$conte
|
|||
$child_type = \Drupal::config('book.settings')->get('child_type');
|
||||
$access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node');
|
||||
if (($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines')) && $access_control_handler->createAccess($child_type) && $node->isPublished() && $node->book['depth'] < BookManager::BOOK_MAX_DEPTH) {
|
||||
$book_links['book_add_child'] = array(
|
||||
$book_links['book_add_child'] = [
|
||||
'title' => t('Add child page'),
|
||||
'url' => Url::fromRoute('node.add', ['node_type' => $child_type], ['query' => ['parent' => $node->id()]]),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if ($account->hasPermission('access printer-friendly version')) {
|
||||
$book_links['book_printer'] = array(
|
||||
$book_links['book_printer'] = [
|
||||
'title' => t('Printer-friendly version'),
|
||||
'url' => Url::fromRoute('book.export', [
|
||||
'type' => 'html',
|
||||
'node' => $node->id(),
|
||||
]),
|
||||
'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
|
||||
);
|
||||
'attributes' => ['title' => t('Show a printer-friendly version of this book page and its sub-pages.')]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($book_links)) {
|
||||
$links['book'] = array(
|
||||
$links['book'] = [
|
||||
'#theme' => 'links__node__book',
|
||||
'#links' => $book_links,
|
||||
'#attributes' => array('class' => array('links', 'inline')),
|
||||
);
|
||||
'#attributes' => ['class' => ['links', 'inline']],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,17 +148,17 @@ function book_form_node_form_alter(&$form, FormStateInterface $form_state, $form
|
|||
$collapsed = !($node->isNew() && !empty($node->book['pid']));
|
||||
$form = \Drupal::service('book.manager')->addFormElements($form, $form_state, $node, $account, $collapsed);
|
||||
// The "js-hide" class hides submit button when Javascript is enabled.
|
||||
$form['book']['pick-book'] = array(
|
||||
$form['book']['pick-book'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Change book (update list of parents)'),
|
||||
'#submit' => array('book_pick_book_nojs_submit'),
|
||||
'#submit' => ['book_pick_book_nojs_submit'],
|
||||
'#weight' => 20,
|
||||
'#attributes' => array(
|
||||
'class' => array(
|
||||
'#attributes' => [
|
||||
'class' => [
|
||||
'js-hide',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
$form['#entity_builders'][] = 'book_node_builder';
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayI
|
|||
if (!$book_node->access()) {
|
||||
return;
|
||||
}
|
||||
$build['book_navigation'] = array(
|
||||
$build['book_navigation'] = [
|
||||
'#theme' => 'book_navigation',
|
||||
'#book_link' => $node->book,
|
||||
'#weight' => 100,
|
||||
|
@ -241,7 +241,7 @@ function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayI
|
|||
'#cache' => [
|
||||
'tags' => $node->getEntityType()->getListCacheTags(),
|
||||
],
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ function book_node_prepare_form(NodeInterface $node, $operation, FormStateInterf
|
|||
// Prepare defaults for the add/edit form.
|
||||
$account = \Drupal::currentUser();
|
||||
if (empty($node->book) && ($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines'))) {
|
||||
$node->book = array();
|
||||
$node->book = [];
|
||||
|
||||
$query = \Drupal::request()->query;
|
||||
if ($node->isNew() && !is_null($query->get('parent')) && is_numeric($query->get('parent'))) {
|
||||
|
@ -341,10 +341,10 @@ function book_form_node_confirm_form_alter(&$form, FormStateInterface $form_stat
|
|||
}
|
||||
|
||||
if (isset($node->book) && $node->book['has_children']) {
|
||||
$form['book_warning'] = array(
|
||||
'#markup' => '<p>' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => $node->label())) . '</p>',
|
||||
$form['book_warning'] = [
|
||||
'#markup' => '<p>' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $node->label()]) . '</p>',
|
||||
'#weight' => -10,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,13 +365,13 @@ function book_form_node_confirm_form_alter(&$form, FormStateInterface $form_stat
|
|||
function template_preprocess_book_all_books_block(&$variables) {
|
||||
// Remove all non-renderable elements.
|
||||
$elements = $variables['book_menus'];
|
||||
$variables['book_menus'] = array();
|
||||
$variables['book_menus'] = [];
|
||||
foreach (Element::children($elements) as $index) {
|
||||
$variables['book_menus'][] = array(
|
||||
$variables['book_menus'][] = [
|
||||
'id' => $index,
|
||||
'menu' => $elements[$index],
|
||||
'title' => $elements[$index]['#book_title'],
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ function template_preprocess_book_navigation(&$variables) {
|
|||
// Provide extra variables for themers. Not needed by default.
|
||||
$variables['book_id'] = $book_link['bid'];
|
||||
$variables['book_title'] = $book_link['link_title'];
|
||||
$variables['book_url'] = \Drupal::url('entity.node.canonical', array('node' => $book_link['bid']));
|
||||
$variables['book_url'] = \Drupal::url('entity.node.canonical', ['node' => $book_link['bid']]);
|
||||
$variables['current_depth'] = $book_link['depth'];
|
||||
$variables['tree'] = '';
|
||||
|
||||
|
@ -401,14 +401,14 @@ function template_preprocess_book_navigation(&$variables) {
|
|||
if ($book_link['nid']) {
|
||||
$variables['tree'] = $book_outline->childrenLinks($book_link);
|
||||
|
||||
$build = array();
|
||||
$build = [];
|
||||
|
||||
if ($prev = $book_outline->prevLink($book_link)) {
|
||||
$prev_href = \Drupal::url('entity.node.canonical', array('node' => $prev['nid']));
|
||||
$build['#attached']['html_head_link'][][] = array(
|
||||
$prev_href = \Drupal::url('entity.node.canonical', ['node' => $prev['nid']]);
|
||||
$build['#attached']['html_head_link'][][] = [
|
||||
'rel' => 'prev',
|
||||
'href' => $prev_href,
|
||||
);
|
||||
];
|
||||
$variables['prev_url'] = $prev_href;
|
||||
$variables['prev_title'] = $prev['title'];
|
||||
}
|
||||
|
@ -416,21 +416,21 @@ function template_preprocess_book_navigation(&$variables) {
|
|||
/** @var \Drupal\book\BookManagerInterface $book_manager */
|
||||
$book_manager = \Drupal::service('book.manager');
|
||||
if ($book_link['pid'] && $parent = $book_manager->loadBookLink($book_link['pid'])) {
|
||||
$parent_href = \Drupal::url('entity.node.canonical', array('node' => $book_link['pid']));
|
||||
$build['#attached']['html_head_link'][][] = array(
|
||||
$parent_href = \Drupal::url('entity.node.canonical', ['node' => $book_link['pid']]);
|
||||
$build['#attached']['html_head_link'][][] = [
|
||||
'rel' => 'up',
|
||||
'href' => $parent_href,
|
||||
);
|
||||
];
|
||||
$variables['parent_url'] = $parent_href;
|
||||
$variables['parent_title'] = $parent['title'];
|
||||
}
|
||||
|
||||
if ($next = $book_outline->nextLink($book_link)) {
|
||||
$next_href = \Drupal::url('entity.node.canonical', array('node' => $next['nid']));
|
||||
$build['#attached']['html_head_link'][][] = array(
|
||||
$next_href = \Drupal::url('entity.node.canonical', ['node' => $next['nid']]);
|
||||
$build['#attached']['html_head_link'][][] = [
|
||||
'rel' => 'next',
|
||||
'href' => $next_href,
|
||||
);
|
||||
];
|
||||
$variables['next_url'] = $next_href;
|
||||
$variables['next_title'] = $next['title'];
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ function template_preprocess_book_navigation(&$variables) {
|
|||
|
||||
$variables['has_links'] = FALSE;
|
||||
// Link variables to filter for values and set state of the flag variable.
|
||||
$links = array('prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title');
|
||||
$links = ['prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title'];
|
||||
foreach ($links as $link) {
|
||||
if (isset($variables[$link])) {
|
||||
// Flag when there is a value.
|
||||
|
@ -475,7 +475,7 @@ function template_preprocess_book_export_html(&$variables) {
|
|||
$variables['language_rtl'] = ($language_interface->getDirection() == LanguageInterface::DIRECTION_RTL);
|
||||
|
||||
// HTML element attributes.
|
||||
$attributes = array();
|
||||
$attributes = [];
|
||||
$attributes['lang'] = $language_interface->getId();
|
||||
$attributes['dir'] = $language_interface->getDirection();
|
||||
$variables['html_attributes'] = new Attribute($attributes);
|
||||
|
|
|
@ -35,5 +35,5 @@ services:
|
|||
class: Drupal\book\BookUninstallValidator
|
||||
tags:
|
||||
- { name: module_install.uninstall_validator }
|
||||
arguments: ['@book.outline_storage', '@entity.query', '@string_translation']
|
||||
arguments: ['@book.outline_storage', '@entity_type.manager', '@string_translation']
|
||||
lazy: true
|
||||
|
|
|
@ -14,6 +14,7 @@ content:
|
|||
body:
|
||||
type: text_textarea_with_summary
|
||||
weight: 26
|
||||
region: content
|
||||
settings:
|
||||
rows: 9
|
||||
summary_rows: 3
|
||||
|
@ -22,6 +23,7 @@ content:
|
|||
created:
|
||||
type: datetime_timestamp
|
||||
weight: 10
|
||||
region: content
|
||||
settings: { }
|
||||
third_party_settings: { }
|
||||
promote:
|
||||
|
@ -29,16 +31,19 @@ content:
|
|||
settings:
|
||||
display_label: true
|
||||
weight: 15
|
||||
region: content
|
||||
third_party_settings: { }
|
||||
sticky:
|
||||
type: boolean_checkbox
|
||||
settings:
|
||||
display_label: true
|
||||
weight: 16
|
||||
region: content
|
||||
third_party_settings: { }
|
||||
title:
|
||||
type: string_textfield
|
||||
weight: -5
|
||||
region: content
|
||||
settings:
|
||||
size: 60
|
||||
placeholder: ''
|
||||
|
@ -46,6 +51,7 @@ content:
|
|||
uid:
|
||||
type: entity_reference_autocomplete
|
||||
weight: 5
|
||||
region: content
|
||||
settings:
|
||||
match_operator: CONTAINS
|
||||
size: 60
|
|
@ -16,8 +16,10 @@ content:
|
|||
label: hidden
|
||||
type: text_default
|
||||
weight: 100
|
||||
region: content
|
||||
settings: { }
|
||||
third_party_settings: { }
|
||||
links:
|
||||
weight: 101
|
||||
region: content
|
||||
hidden: { }
|
|
@ -17,9 +17,11 @@ content:
|
|||
label: hidden
|
||||
type: text_summary_or_trimmed
|
||||
weight: 100
|
||||
region: content
|
||||
settings:
|
||||
trim_length: 600
|
||||
third_party_settings: { }
|
||||
links:
|
||||
weight: 101
|
||||
region: content
|
||||
hidden: { }
|
|
@ -56,10 +56,10 @@ class BookBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function build(RouteMatchInterface $route_match) {
|
||||
$book_nids = array();
|
||||
$book_nids = [];
|
||||
$breadcrumb = new Breadcrumb();
|
||||
|
||||
$links = array(Link::createFromRoute($this->t('Home'), '<front>'));
|
||||
$links = [Link::createFromRoute($this->t('Home'), '<front>')];
|
||||
$book = $route_match->getParameter('node')->book;
|
||||
$depth = 1;
|
||||
// We skip the current node.
|
||||
|
@ -76,7 +76,7 @@ class BookBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
|||
$breadcrumb->addCacheableDependency($access);
|
||||
if ($access->isAllowed()) {
|
||||
$breadcrumb->addCacheableDependency($parent_book);
|
||||
$links[] = Link::createFromRoute($parent_book->label(), 'entity.node.canonical', array('node' => $parent_book->id()));
|
||||
$links[] = Link::createFromRoute($parent_book->label(), 'entity.node.canonical', ['node' => $parent_book->id()]);
|
||||
}
|
||||
}
|
||||
$depth++;
|
||||
|
|
|
@ -73,8 +73,8 @@ class BookExport {
|
|||
}
|
||||
|
||||
$tree = $this->bookManager->bookSubtreeData($node->book);
|
||||
$contents = $this->exportTraverse($tree, array($this, 'bookNodeExport'));
|
||||
return array(
|
||||
$contents = $this->exportTraverse($tree, [$this, 'bookNodeExport']);
|
||||
return [
|
||||
'#theme' => 'book_export_html',
|
||||
'#title' => $node->label(),
|
||||
'#contents' => $contents,
|
||||
|
@ -82,7 +82,7 @@ class BookExport {
|
|||
'#cache' => [
|
||||
'tags' => $node->getEntityType()->getListCacheTags(),
|
||||
],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,9 +101,9 @@ class BookExport {
|
|||
*/
|
||||
protected function exportTraverse(array $tree, $callable) {
|
||||
// If there is no valid callable, use the default callback.
|
||||
$callable = !empty($callable) ? $callable : array($this, 'bookNodeExport');
|
||||
$callable = !empty($callable) ? $callable : [$this, 'bookNodeExport'];
|
||||
|
||||
$build = array();
|
||||
$build = [];
|
||||
foreach ($tree as $data) {
|
||||
// Note- access checking is already performed when building the tree.
|
||||
if ($node = $this->nodeStorage->load($data['link']['nid'])) {
|
||||
|
@ -133,12 +133,12 @@ class BookExport {
|
|||
$build = $this->viewBuilder->view($node, 'print', NULL);
|
||||
unset($build['#theme']);
|
||||
|
||||
return array(
|
||||
return [
|
||||
'#theme' => 'book_node_export_html',
|
||||
'#content' => $build,
|
||||
'#node' => $node,
|
||||
'#children' => $children,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class BookManager implements BookManagerInterface {
|
|||
* Loads Books Array.
|
||||
*/
|
||||
protected function loadBooks() {
|
||||
$this->books = array();
|
||||
$this->books = [];
|
||||
$nids = $this->bookOutlineStorage->getBooks();
|
||||
|
||||
if ($nids) {
|
||||
|
@ -117,15 +117,15 @@ class BookManager implements BookManagerInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLinkDefaults($nid) {
|
||||
return array(
|
||||
return [
|
||||
'original_bid' => 0,
|
||||
'nid' => $nid,
|
||||
'bid' => 0,
|
||||
'pid' => 0,
|
||||
'has_children' => 0,
|
||||
'weight' => 0,
|
||||
'options' => array(),
|
||||
);
|
||||
'options' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,40 +159,40 @@ class BookManager implements BookManagerInterface {
|
|||
if ($form_state->hasValue('book')) {
|
||||
$node->book = $form_state->getValue('book');
|
||||
}
|
||||
$form['book'] = array(
|
||||
$form['book'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Book outline'),
|
||||
'#weight' => 10,
|
||||
'#open' => !$collapsed,
|
||||
'#group' => 'advanced',
|
||||
'#attributes' => array(
|
||||
'class' => array('book-outline-form'),
|
||||
),
|
||||
'#attached' => array(
|
||||
'library' => array('book/drupal.book'),
|
||||
),
|
||||
'#attributes' => [
|
||||
'class' => ['book-outline-form'],
|
||||
],
|
||||
'#attached' => [
|
||||
'library' => ['book/drupal.book'],
|
||||
],
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
foreach (array('nid', 'has_children', 'original_bid', 'parent_depth_limit') as $key) {
|
||||
$form['book'][$key] = array(
|
||||
];
|
||||
foreach (['nid', 'has_children', 'original_bid', 'parent_depth_limit'] as $key) {
|
||||
$form['book'][$key] = [
|
||||
'#type' => 'value',
|
||||
'#value' => $node->book[$key],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$form['book']['pid'] = $this->addParentSelectFormElements($node->book);
|
||||
|
||||
// @see \Drupal\book\Form\BookAdminEditForm::bookAdminTableTree(). The
|
||||
// weight may be larger than 15.
|
||||
$form['book']['weight'] = array(
|
||||
$form['book']['weight'] = [
|
||||
'#type' => 'weight',
|
||||
'#title' => $this->t('Weight'),
|
||||
'#default_value' => $node->book['weight'],
|
||||
'#delta' => max(15, abs($node->book['weight'])),
|
||||
'#weight' => 5,
|
||||
'#description' => $this->t('Pages at a given level are ordered first by weight and then by title.'),
|
||||
);
|
||||
$options = array();
|
||||
];
|
||||
$options = [];
|
||||
$nid = !$node->isNew() ? $node->id() : 'new';
|
||||
if ($node->id() && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) {
|
||||
// This is the top level node in a maximum depth book and thus cannot be
|
||||
|
@ -207,15 +207,15 @@ class BookManager implements BookManagerInterface {
|
|||
|
||||
if ($account->hasPermission('create new books') && ($nid == 'new' || ($nid != $node->book['original_bid']))) {
|
||||
// The node can become a new book, if it is not one already.
|
||||
$options = array($nid => $this->t('- Create a new book -')) + $options;
|
||||
$options = [$nid => $this->t('- Create a new book -')] + $options;
|
||||
}
|
||||
if (!$node->book['bid']) {
|
||||
// The node is not currently in the hierarchy.
|
||||
$options = array(0 => $this->t('- None -')) + $options;
|
||||
$options = [0 => $this->t('- None -')] + $options;
|
||||
}
|
||||
|
||||
// Add a drop-down to select the destination book.
|
||||
$form['book']['bid'] = array(
|
||||
$form['book']['bid'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Book'),
|
||||
'#default_value' => $node->book['bid'],
|
||||
|
@ -223,14 +223,14 @@ class BookManager implements BookManagerInterface {
|
|||
'#access' => (bool) $options,
|
||||
'#description' => $this->t('Your page will be a part of the selected book.'),
|
||||
'#weight' => -5,
|
||||
'#attributes' => array('class' => array('book-title-select')),
|
||||
'#ajax' => array(
|
||||
'#attributes' => ['class' => ['book-title-select']],
|
||||
'#ajax' => [
|
||||
'callback' => 'book_form_update',
|
||||
'wrapper' => 'edit-book-plid-wrapper',
|
||||
'effect' => 'fade',
|
||||
'speed' => 'fast',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@ -281,8 +281,8 @@ class BookManager implements BookManagerInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBookParents(array $item, array $parent = array()) {
|
||||
$book = array();
|
||||
public function getBookParents(array $item, array $parent = []) {
|
||||
$book = [];
|
||||
if ($item['pid'] == 0) {
|
||||
$book['p1'] = $item['nid'];
|
||||
for ($i = 2; $i <= static::BOOK_MAX_DEPTH; $i++) {
|
||||
|
@ -325,15 +325,15 @@ class BookManager implements BookManagerInterface {
|
|||
protected function addParentSelectFormElements(array $book_link) {
|
||||
$config = $this->configFactory->get('book.settings');
|
||||
if ($config->get('override_parent_selector')) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
// Offer a message or a drop-down to choose a different parent page.
|
||||
$form = array(
|
||||
$form = [
|
||||
'#type' => 'hidden',
|
||||
'#value' => -1,
|
||||
'#prefix' => '<div id="edit-book-plid-wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
];
|
||||
|
||||
if ($book_link['nid'] === $book_link['bid']) {
|
||||
// This is a book - at the top level.
|
||||
|
@ -348,16 +348,16 @@ class BookManager implements BookManagerInterface {
|
|||
$form['#prefix'] .= '<em>' . $this->t('No book selected.') . '</em>';
|
||||
}
|
||||
else {
|
||||
$form = array(
|
||||
$form = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Parent item'),
|
||||
'#default_value' => $book_link['pid'],
|
||||
'#description' => $this->t('The parent page in the book. The maximum depth for a book and all child pages is @maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', array('@maxdepth' => static::BOOK_MAX_DEPTH)),
|
||||
'#options' => $this->getTableOfContents($book_link['bid'], $book_link['parent_depth_limit'], array($book_link['nid'])),
|
||||
'#attributes' => array('class' => array('book-title-select')),
|
||||
'#description' => $this->t('The parent page in the book. The maximum depth for a book and all child pages is @maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', ['@maxdepth' => static::BOOK_MAX_DEPTH]),
|
||||
'#options' => $this->getTableOfContents($book_link['bid'], $book_link['parent_depth_limit'], [$book_link['nid']]),
|
||||
'#attributes' => ['class' => ['book-title-select']],
|
||||
'#prefix' => '<div id="edit-book-plid-wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
];
|
||||
}
|
||||
$this->renderer->addCacheableDependency($form, $config);
|
||||
|
||||
|
@ -388,7 +388,7 @@ class BookManager implements BookManagerInterface {
|
|||
* children).
|
||||
*/
|
||||
protected function recurseTableOfContents(array $tree, $indent, array &$toc, array $exclude, $depth_limit) {
|
||||
$nids = array();
|
||||
$nids = [];
|
||||
foreach ($tree as $data) {
|
||||
if ($data['link']['depth'] > $depth_limit) {
|
||||
// Don't iterate through any links on this level.
|
||||
|
@ -417,9 +417,9 @@ class BookManager implements BookManagerInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTableOfContents($bid, $depth_limit, array $exclude = array()) {
|
||||
public function getTableOfContents($bid, $depth_limit, array $exclude = []) {
|
||||
$tree = $this->bookTreeAllData($bid);
|
||||
$toc = array();
|
||||
$toc = [];
|
||||
$this->recurseTableOfContents($tree, '', $toc, $exclude, $depth_limit);
|
||||
|
||||
return $toc;
|
||||
|
@ -443,14 +443,14 @@ class BookManager implements BookManagerInterface {
|
|||
}
|
||||
$this->updateOriginalParent($original);
|
||||
$this->books = NULL;
|
||||
Cache::invalidateTags(array('bid:' . $original['bid']));
|
||||
Cache::invalidateTags(['bid:' . $original['bid']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) {
|
||||
$tree = &drupal_static(__METHOD__, array());
|
||||
$tree = &drupal_static(__METHOD__, []);
|
||||
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
|
||||
|
||||
// Use $nid as a flag for whether the data being loaded is for the whole
|
||||
|
@ -462,10 +462,10 @@ class BookManager implements BookManagerInterface {
|
|||
|
||||
if (!isset($tree[$cid])) {
|
||||
// If the tree data was not in the static cache, build $tree_parameters.
|
||||
$tree_parameters = array(
|
||||
$tree_parameters = [
|
||||
'min_depth' => 1,
|
||||
'max_depth' => $max_depth,
|
||||
);
|
||||
];
|
||||
if ($nid) {
|
||||
$active_trail = $this->getActiveTrailIds($bid, $link);
|
||||
$tree_parameters['expanded'] = $active_trail;
|
||||
|
@ -486,7 +486,7 @@ class BookManager implements BookManagerInterface {
|
|||
public function getActiveTrailIds($bid, $link) {
|
||||
// The tree is for a single item, so we need to match the values in its
|
||||
// p columns and 0 (the top level) with the plid values of other links.
|
||||
$active_trail = array(0);
|
||||
$active_trail = [0];
|
||||
for ($i = 1; $i < static::BOOK_MAX_DEPTH; $i++) {
|
||||
if (!empty($link["p$i"])) {
|
||||
$active_trail[] = $link["p$i"];
|
||||
|
@ -600,7 +600,7 @@ class BookManager implements BookManagerInterface {
|
|||
* @return array
|
||||
* A fully built book tree.
|
||||
*/
|
||||
protected function bookTreeBuild($bid, array $parameters = array()) {
|
||||
protected function bookTreeBuild($bid, array $parameters = []) {
|
||||
// Build the book tree.
|
||||
$data = $this->doBookTreeBuild($bid, $parameters);
|
||||
// Check access for the current user to each item in the tree.
|
||||
|
@ -639,9 +639,9 @@ class BookManager implements BookManagerInterface {
|
|||
*
|
||||
* @see \Drupal\book\BookOutlineStorageInterface::getBookMenuTree()
|
||||
*/
|
||||
protected function doBookTreeBuild($bid, array $parameters = array()) {
|
||||
protected function doBookTreeBuild($bid, array $parameters = []) {
|
||||
// Static cache of already built menu trees.
|
||||
$trees = &drupal_static(__METHOD__, array());
|
||||
$trees = &drupal_static(__METHOD__, []);
|
||||
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
|
||||
|
||||
// Build the cache id; sort parents to prevent duplicate storage and remove
|
||||
|
@ -664,18 +664,18 @@ class BookManager implements BookManagerInterface {
|
|||
$result = $this->bookOutlineStorage->getBookMenuTree($bid, $parameters, $min_depth, static::BOOK_MAX_DEPTH);
|
||||
|
||||
// Build an ordered array of links using the query result object.
|
||||
$links = array();
|
||||
$links = [];
|
||||
foreach ($result as $link) {
|
||||
$link = (array) $link;
|
||||
$links[$link['nid']] = $link;
|
||||
}
|
||||
$active_trail = (isset($parameters['active_trail']) ? $parameters['active_trail'] : array());
|
||||
$active_trail = (isset($parameters['active_trail']) ? $parameters['active_trail'] : []);
|
||||
$data['tree'] = $this->buildBookOutlineData($links, $active_trail, $min_depth);
|
||||
$data['node_links'] = array();
|
||||
$data['node_links'] = [];
|
||||
$this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']);
|
||||
|
||||
// Cache the data, if it is not already in the cache.
|
||||
\Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, array('bid:' . $bid));
|
||||
\Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, ['bid:' . $bid]);
|
||||
$trees[$tree_cid] = $data;
|
||||
}
|
||||
|
||||
|
@ -705,7 +705,7 @@ class BookManager implements BookManagerInterface {
|
|||
if (!isset($this->bookTreeFlattened[$book_link['nid']])) {
|
||||
// Call $this->bookTreeAllData() to take advantage of caching.
|
||||
$tree = $this->bookTreeAllData($book_link['bid'], $book_link, $book_link['depth'] + 1);
|
||||
$this->bookTreeFlattened[$book_link['nid']] = array();
|
||||
$this->bookTreeFlattened[$book_link['nid']] = [];
|
||||
$this->flatBookTree($tree, $this->bookTreeFlattened[$book_link['nid']]);
|
||||
}
|
||||
|
||||
|
@ -735,7 +735,7 @@ class BookManager implements BookManagerInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadBookLink($nid, $translate = TRUE) {
|
||||
$links = $this->loadBookLinks(array($nid), $translate);
|
||||
$links = $this->loadBookLinks([$nid], $translate);
|
||||
return isset($links[$nid]) ? $links[$nid] : FALSE;
|
||||
}
|
||||
|
||||
|
@ -744,7 +744,7 @@ class BookManager implements BookManagerInterface {
|
|||
*/
|
||||
public function loadBookLinks($nids, $translate = TRUE) {
|
||||
$result = $this->bookOutlineStorage->loadMultiple($nids, $translate);
|
||||
$links = array();
|
||||
$links = [];
|
||||
foreach ($result as $link) {
|
||||
if ($translate) {
|
||||
$this->bookLinkTranslate($link);
|
||||
|
@ -779,7 +779,7 @@ class BookManager implements BookManagerInterface {
|
|||
// Update the bid for this page and all children.
|
||||
if ($link['pid'] == 0) {
|
||||
$link['depth'] = 1;
|
||||
$parent = array();
|
||||
$parent = [];
|
||||
}
|
||||
// In case the form did not specify a proper PID we use the BID as new
|
||||
// parent.
|
||||
|
@ -801,11 +801,11 @@ class BookManager implements BookManagerInterface {
|
|||
$this->updateParent($link);
|
||||
}
|
||||
// Update the weight and pid.
|
||||
$this->bookOutlineStorage->update($link['nid'], array(
|
||||
$this->bookOutlineStorage->update($link['nid'], [
|
||||
'weight' => $link['weight'],
|
||||
'pid' => $link['pid'],
|
||||
'bid' => $link['bid'],
|
||||
));
|
||||
]);
|
||||
}
|
||||
$cache_tags = [];
|
||||
foreach ($affected_bids as $bid) {
|
||||
|
@ -825,16 +825,16 @@ class BookManager implements BookManagerInterface {
|
|||
*/
|
||||
protected function moveChildren(array $link, array $original) {
|
||||
$p = 'p1';
|
||||
$expressions = array();
|
||||
$expressions = [];
|
||||
for ($i = 1; $i <= $link['depth']; $p = 'p' . ++$i) {
|
||||
$expressions[] = array($p, ":p_$i", array(":p_$i" => $link[$p]));
|
||||
$expressions[] = [$p, ":p_$i", [":p_$i" => $link[$p]]];
|
||||
}
|
||||
$j = $original['depth'] + 1;
|
||||
while ($i <= static::BOOK_MAX_DEPTH && $j <= static::BOOK_MAX_DEPTH) {
|
||||
$expressions[] = array('p' . $i++, 'p' . $j++, array());
|
||||
$expressions[] = ['p' . $i++, 'p' . $j++, []];
|
||||
}
|
||||
while ($i <= static::BOOK_MAX_DEPTH) {
|
||||
$expressions[] = array('p' . $i++, 0, array());
|
||||
$expressions[] = ['p' . $i++, 0, []];
|
||||
}
|
||||
|
||||
$shift = $link['depth'] - $original['depth'];
|
||||
|
@ -868,7 +868,7 @@ class BookManager implements BookManagerInterface {
|
|||
// Nothing to update.
|
||||
return TRUE;
|
||||
}
|
||||
return $this->bookOutlineStorage->update($link['pid'], array('has_children' => 1));
|
||||
return $this->bookOutlineStorage->update($link['pid'], ['has_children' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -897,7 +897,7 @@ class BookManager implements BookManagerInterface {
|
|||
// Update the parent. If the original link did not have children, then the
|
||||
// parent now does not have children. If the original had children, then the
|
||||
// the parent has children now (still).
|
||||
return $this->bookOutlineStorage->update($original['pid'], array('has_children' => $parent_has_children));
|
||||
return $this->bookOutlineStorage->update($original['pid'], ['has_children' => $parent_has_children]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -926,7 +926,7 @@ class BookManager implements BookManagerInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bookTreeCheckAccess(&$tree, $node_links = array()) {
|
||||
public function bookTreeCheckAccess(&$tree, $node_links = []) {
|
||||
if ($node_links) {
|
||||
// @todo Extract that into its own method.
|
||||
$nids = array_keys($node_links);
|
||||
|
@ -954,7 +954,7 @@ class BookManager implements BookManagerInterface {
|
|||
* The book tree to operate on.
|
||||
*/
|
||||
protected function doBookTreeCheckAccess(&$tree) {
|
||||
$new_tree = array();
|
||||
$new_tree = [];
|
||||
foreach ($tree as $key => $v) {
|
||||
$item = &$tree[$key]['link'];
|
||||
$this->bookLinkTranslate($item);
|
||||
|
@ -993,7 +993,7 @@ class BookManager implements BookManagerInterface {
|
|||
}
|
||||
// The node label will be the value for the current user's language.
|
||||
$link['title'] = $node->label();
|
||||
$link['options'] = array();
|
||||
$link['options'] = [];
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ class BookManager implements BookManagerInterface {
|
|||
* array will be empty if the book link has no items in its sub-tree
|
||||
* having a depth greater than or equal to $depth.
|
||||
*/
|
||||
protected function buildBookOutlineData(array $links, array $parents = array(), $depth = 1) {
|
||||
protected function buildBookOutlineData(array $links, array $parents = [], $depth = 1) {
|
||||
// Reverse the array so we can use the more efficient array_pop() function.
|
||||
$links = array_reverse($links);
|
||||
return $this->buildBookOutlineRecursive($links, $parents, $depth);
|
||||
|
@ -1047,16 +1047,16 @@ class BookManager implements BookManagerInterface {
|
|||
* Book tree.
|
||||
*/
|
||||
protected function buildBookOutlineRecursive(&$links, $parents, $depth) {
|
||||
$tree = array();
|
||||
$tree = [];
|
||||
while ($item = array_pop($links)) {
|
||||
// We need to determine if we're on the path to root so we can later build
|
||||
// the correct active trail.
|
||||
$item['in_active_trail'] = in_array($item['nid'], $parents);
|
||||
// Add the current link to the tree.
|
||||
$tree[$item['nid']] = array(
|
||||
$tree[$item['nid']] = [
|
||||
'link' => $item,
|
||||
'below' => array(),
|
||||
);
|
||||
'below' => [],
|
||||
];
|
||||
// Look ahead to the next link, but leave it on the array so it's
|
||||
// available to other recursive function calls if we return or build a
|
||||
// sub-tree.
|
||||
|
@ -1080,7 +1080,7 @@ class BookManager implements BookManagerInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function bookSubtreeData($link) {
|
||||
$tree = &drupal_static(__METHOD__, array());
|
||||
$tree = &drupal_static(__METHOD__, []);
|
||||
|
||||
// Generate a cache ID (cid) specific for this $link.
|
||||
$cid = 'book-links:subtree-cid:' . $link['nid'];
|
||||
|
@ -1101,23 +1101,23 @@ class BookManager implements BookManagerInterface {
|
|||
// If the subtree data was not in the cache, $data will be NULL.
|
||||
if (!isset($data)) {
|
||||
$result = $this->bookOutlineStorage->getBookSubtree($link, static::BOOK_MAX_DEPTH);
|
||||
$links = array();
|
||||
$links = [];
|
||||
foreach ($result as $item) {
|
||||
$links[] = $item;
|
||||
}
|
||||
$data['tree'] = $this->buildBookOutlineData($links, array(), $link['depth']);
|
||||
$data['node_links'] = array();
|
||||
$data['tree'] = $this->buildBookOutlineData($links, [], $link['depth']);
|
||||
$data['node_links'] = [];
|
||||
$this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']);
|
||||
// Compute the real cid for book subtree data.
|
||||
$tree_cid = 'book-links:subtree-data:' . hash('sha256', serialize($data));
|
||||
// Cache the data, if it is not already in the cache.
|
||||
|
||||
if (!\Drupal::cache('data')->get($tree_cid)) {
|
||||
\Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, array('bid:' . $link['bid']));
|
||||
\Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, ['bid:' . $link['bid']]);
|
||||
}
|
||||
// Cache the cid of the (shared) data using the book and item-specific
|
||||
// cid.
|
||||
\Drupal::cache('data')->set($cid, $tree_cid, Cache::PERMANENT, array('bid:' . $link['bid']));
|
||||
\Drupal::cache('data')->set($cid, $tree_cid, Cache::PERMANENT, ['bid:' . $link['bid']]);
|
||||
}
|
||||
// Check access for the current user to each item in the tree.
|
||||
$this->bookTreeCheckAccess($data['tree'], $data['node_links']);
|
||||
|
|
|
@ -108,7 +108,7 @@ interface BookManagerInterface {
|
|||
* An array of (menu link ID, title) pairs for use as options for selecting
|
||||
* a book page.
|
||||
*/
|
||||
public function getTableOfContents($bid, $depth_limit, array $exclude = array());
|
||||
public function getTableOfContents($bid, $depth_limit, array $exclude = []);
|
||||
|
||||
/**
|
||||
* Finds the depth limit for items in the parent select.
|
||||
|
@ -207,7 +207,7 @@ interface BookManagerInterface {
|
|||
*/
|
||||
public function getLinkDefaults($nid);
|
||||
|
||||
public function getBookParents(array $item, array $parent = array());
|
||||
public function getBookParents(array $item, array $parent = []);
|
||||
|
||||
/**
|
||||
* Builds the common elements of the book form for the node and outline forms.
|
||||
|
@ -262,7 +262,7 @@ interface BookManagerInterface {
|
|||
* A collection of node link references generated from $tree by
|
||||
* menu_tree_collect_node_links().
|
||||
*/
|
||||
public function bookTreeCheckAccess(&$tree, $node_links = array());
|
||||
public function bookTreeCheckAccess(&$tree, $node_links = []);
|
||||
|
||||
/**
|
||||
* Gets the data representing a subtree of the book hierarchy.
|
||||
|
|
|
@ -105,7 +105,7 @@ class BookOutline {
|
|||
public function childrenLinks(array $book_link) {
|
||||
$flat = $this->bookManager->bookTreeGetFlat($book_link);
|
||||
|
||||
$children = array();
|
||||
$children = [];
|
||||
|
||||
if ($book_link['has_children']) {
|
||||
// Walk through the array until we find the current page.
|
||||
|
|
|
@ -43,7 +43,7 @@ class BookOutlineStorage implements BookOutlineStorageInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadMultiple($nids, $access = TRUE) {
|
||||
$query = $this->connection->select('book', 'b', array('fetch' => \PDO::FETCH_ASSOC));
|
||||
$query = $this->connection->select('book', 'b', ['fetch' => \PDO::FETCH_ASSOC]);
|
||||
$query->fields('b');
|
||||
$query->condition('b.nid', $nids, 'IN');
|
||||
|
||||
|
@ -89,7 +89,7 @@ class BookOutlineStorage implements BookOutlineStorageInterface {
|
|||
*/
|
||||
public function loadBookChildren($pid) {
|
||||
return $this->connection
|
||||
->query("SELECT * FROM {book} WHERE pid = :pid", array(':pid' => $pid))
|
||||
->query("SELECT * FROM {book} WHERE pid = :pid", [':pid' => $pid])
|
||||
->fetchAllAssoc('nid', \PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
|
@ -128,12 +128,12 @@ class BookOutlineStorage implements BookOutlineStorageInterface {
|
|||
public function insert($link, $parents) {
|
||||
return $this->connection
|
||||
->insert('book')
|
||||
->fields(array(
|
||||
->fields([
|
||||
'nid' => $link['nid'],
|
||||
'bid' => $link['bid'],
|
||||
'pid' => $link['pid'],
|
||||
'weight' => $link['weight'],
|
||||
) + $parents
|
||||
] + $parents
|
||||
)
|
||||
->execute();
|
||||
}
|
||||
|
@ -154,13 +154,13 @@ class BookOutlineStorage implements BookOutlineStorageInterface {
|
|||
*/
|
||||
public function updateMovedChildren($bid, $original, $expressions, $shift) {
|
||||
$query = $this->connection->update('book');
|
||||
$query->fields(array('bid' => $bid));
|
||||
$query->fields(['bid' => $bid]);
|
||||
|
||||
foreach ($expressions as $expression) {
|
||||
$query->expression($expression[0], $expression[1], $expression[2]);
|
||||
}
|
||||
|
||||
$query->expression('depth', 'depth + :depth', array(':depth' => $shift));
|
||||
$query->expression('depth', 'depth + :depth', [':depth' => $shift]);
|
||||
$query->condition('bid', $original['bid']);
|
||||
$p = 'p1';
|
||||
for ($i = 1; !empty($original[$p]); $p = 'p' . ++$i) {
|
||||
|
@ -186,7 +186,7 @@ class BookOutlineStorage implements BookOutlineStorageInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBookSubtree($link, $max_depth) {
|
||||
$query = db_select('book', 'b', array('fetch' => \PDO::FETCH_ASSOC));
|
||||
$query = db_select('book', 'b', ['fetch' => \PDO::FETCH_ASSOC]);
|
||||
$query->fields('b');
|
||||
$query->condition('b.bid', $link['bid']);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\book;
|
||||
|
||||
use Drupal\Core\Entity\Query\QueryFactory;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Extension\ModuleUninstallValidatorInterface;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Drupal\Core\StringTranslation\TranslationInterface;
|
||||
|
@ -23,25 +23,25 @@ class BookUninstallValidator implements ModuleUninstallValidatorInterface {
|
|||
protected $bookOutlineStorage;
|
||||
|
||||
/**
|
||||
* The entity query for node.
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\Query\QueryInterface
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityQuery;
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* Constructs a new BookUninstallValidator.
|
||||
*
|
||||
* @param \Drupal\book\BookOutlineStorageInterface $book_outline_storage
|
||||
* The book outline storage.
|
||||
* @param \Drupal\Core\Entity\Query\QueryFactory $query_factory
|
||||
* The entity query factory.
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager.
|
||||
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
|
||||
* The string translation service.
|
||||
*/
|
||||
public function __construct(BookOutlineStorageInterface $book_outline_storage, QueryFactory $query_factory, TranslationInterface $string_translation) {
|
||||
public function __construct(BookOutlineStorageInterface $book_outline_storage, EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation) {
|
||||
$this->bookOutlineStorage = $book_outline_storage;
|
||||
$this->entityQuery = $query_factory->get('node');
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
$this->stringTranslation = $string_translation;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ class BookUninstallValidator implements ModuleUninstallValidatorInterface {
|
|||
* TRUE if there are book nodes, FALSE otherwise.
|
||||
*/
|
||||
protected function hasBookNodes() {
|
||||
$nodes = $this->entityQuery
|
||||
$nodes = $this->entityTypeManager->getStorage('node')->getQuery()
|
||||
->condition('type', 'book')
|
||||
->accessCheck(FALSE)
|
||||
->range(0, 1)
|
||||
|
|
|
@ -73,9 +73,9 @@ class BookController extends ControllerBase {
|
|||
* A render array representing the administrative page content.
|
||||
*/
|
||||
public function adminOverview() {
|
||||
$rows = array();
|
||||
$rows = [];
|
||||
|
||||
$headers = array(t('Book'), t('Operations'));
|
||||
$headers = [t('Book'), t('Operations')];
|
||||
// Add any recognized books to the table list.
|
||||
foreach ($this->bookManager->getAllBooks() as $book) {
|
||||
/** @var \Drupal\Core\Url $url */
|
||||
|
@ -83,28 +83,28 @@ class BookController extends ControllerBase {
|
|||
if (isset($book['options'])) {
|
||||
$url->setOptions($book['options']);
|
||||
}
|
||||
$row = array(
|
||||
$row = [
|
||||
$this->l($book['title'], $url),
|
||||
);
|
||||
$links = array();
|
||||
$links['edit'] = array(
|
||||
];
|
||||
$links = [];
|
||||
$links['edit'] = [
|
||||
'title' => t('Edit order and titles'),
|
||||
'url' => Url::fromRoute('book.admin_edit', ['node' => $book['nid']]),
|
||||
);
|
||||
$row[] = array(
|
||||
'data' => array(
|
||||
];
|
||||
$row[] = [
|
||||
'data' => [
|
||||
'#type' => 'operations',
|
||||
'#links' => $links,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$rows[] = $row;
|
||||
}
|
||||
return array(
|
||||
return [
|
||||
'#type' => 'table',
|
||||
'#header' => $headers,
|
||||
'#rows' => $rows,
|
||||
'#empty' => t('No books available.'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,17 +114,17 @@ class BookController extends ControllerBase {
|
|||
* A render array representing the listing of all books content.
|
||||
*/
|
||||
public function bookRender() {
|
||||
$book_list = array();
|
||||
$book_list = [];
|
||||
foreach ($this->bookManager->getAllBooks() as $book) {
|
||||
$book_list[] = $this->l($book['title'], $book['url']);
|
||||
}
|
||||
return array(
|
||||
return [
|
||||
'#theme' => 'item_list',
|
||||
'#items' => $book_list,
|
||||
'#cache' => [
|
||||
'tags' => \Drupal::entityManager()->getDefinition('node')->getListCacheTags(),
|
||||
],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,10 +70,10 @@ class BookAdminEditForm extends FormBase {
|
|||
$form['#title'] = $node->label();
|
||||
$form['#node'] = $node;
|
||||
$this->bookAdminTable($node, $form);
|
||||
$form['save'] = array(
|
||||
$form['save'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Save book pages'),
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class BookAdminEditForm extends FormBase {
|
|||
foreach (Element::children($form['table']) as $key) {
|
||||
if ($form['table'][$key]['#item']) {
|
||||
$row = $form['table'][$key];
|
||||
$values = $form_state->getValue(array('table', $key));
|
||||
$values = $form_state->getValue(['table', $key]);
|
||||
|
||||
// Update menu item if moved.
|
||||
if ($row['parent']['pid']['#default_value'] != $values['pid'] || $row['weight']['#default_value'] != $values['weight']) {
|
||||
|
@ -114,18 +114,18 @@ class BookAdminEditForm extends FormBase {
|
|||
// Update the title if changed.
|
||||
if ($row['title']['#default_value'] != $values['title']) {
|
||||
$node = $this->nodeStorage->load($values['nid']);
|
||||
$node->revision_log = $this->t('Title changed from %original to %current.', array('%original' => $node->label(), '%current' => $values['title']));
|
||||
$node->revision_log = $this->t('Title changed from %original to %current.', ['%original' => $node->label(), '%current' => $values['title']]);
|
||||
$node->title = $values['title'];
|
||||
$node->book['link_title'] = $values['title'];
|
||||
$node->setNewRevision();
|
||||
$node->save();
|
||||
$this->logger('content')->notice('book: updated %title.', array('%title' => $node->label(), 'link' => $node->link($this->t('View'))));
|
||||
$this->logger('content')->notice('book: updated %title.', ['%title' => $node->label(), 'link' => $node->link($this->t('View'))]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drupal_set_message($this->t('Updated book %title.', array('%title' => $form['#node']->label())));
|
||||
drupal_set_message($this->t('Updated book %title.', ['%title' => $form['#node']->label()]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,7 +139,7 @@ class BookAdminEditForm extends FormBase {
|
|||
* @see self::buildForm()
|
||||
*/
|
||||
protected function bookAdminTable(NodeInterface $node, array &$form) {
|
||||
$form['table'] = array(
|
||||
$form['table'] = [
|
||||
'#type' => 'table',
|
||||
'#header' => [
|
||||
$this->t('Title'),
|
||||
|
@ -164,7 +164,7 @@ class BookAdminEditForm extends FormBase {
|
|||
'group' => 'book-weight',
|
||||
],
|
||||
],
|
||||
);
|
||||
];
|
||||
|
||||
$tree = $this->bookManager->bookSubtreeData($node->book);
|
||||
// Do not include the book item itself.
|
||||
|
@ -173,14 +173,14 @@ class BookAdminEditForm extends FormBase {
|
|||
$hash = Crypt::hashBase64(serialize($tree['below']));
|
||||
// Store the hash value as a hidden form element so that we can detect
|
||||
// if another user changed the book hierarchy.
|
||||
$form['tree_hash'] = array(
|
||||
$form['tree_hash'] = [
|
||||
'#type' => 'hidden',
|
||||
'#default_value' => $hash,
|
||||
);
|
||||
$form['tree_current_hash'] = array(
|
||||
];
|
||||
$form['tree_current_hash'] = [
|
||||
'#type' => 'value',
|
||||
'#value' => $hash,
|
||||
);
|
||||
];
|
||||
$this->bookAdminTableTree($tree['below'], $form['table']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
namespace Drupal\book\Form;
|
||||
|
||||
use Drupal\book\BookManagerInterface;
|
||||
use Drupal\Component\Datetime\TimeInterface;
|
||||
use Drupal\Core\Entity\ContentEntityForm;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
@ -35,9 +37,13 @@ class BookOutlineForm extends ContentEntityForm {
|
|||
* The entity manager.
|
||||
* @param \Drupal\book\BookManagerInterface $book_manager
|
||||
* The BookManager service.
|
||||
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
|
||||
* The entity type bundle service.
|
||||
* @param \Drupal\Component\Datetime\TimeInterface $time
|
||||
* The time service.
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $entity_manager, BookManagerInterface $book_manager) {
|
||||
parent::__construct($entity_manager);
|
||||
public function __construct(EntityManagerInterface $entity_manager, BookManagerInterface $book_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
|
||||
parent::__construct($entity_manager, $entity_type_bundle_info, $time);
|
||||
$this->bookManager = $book_manager;
|
||||
}
|
||||
|
||||
|
@ -47,7 +53,9 @@ class BookOutlineForm extends ContentEntityForm {
|
|||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('entity.manager'),
|
||||
$container->get('book.manager')
|
||||
$container->get('book.manager'),
|
||||
$container->get('entity_type.bundle.info'),
|
||||
$container->get('datetime.time')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -99,7 +107,7 @@ class BookOutlineForm extends ContentEntityForm {
|
|||
public function save(array $form, FormStateInterface $form_state) {
|
||||
$form_state->setRedirect(
|
||||
'entity.node.canonical',
|
||||
array('node' => $this->entity->id())
|
||||
['node' => $this->entity->id()]
|
||||
);
|
||||
$book_link = $form_state->getValue('book');
|
||||
if (!$book_link['bid']) {
|
||||
|
|
|
@ -65,7 +65,7 @@ class BookRemoveForm extends ConfirmFormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDescription() {
|
||||
$title = array('%title' => $this->node->label());
|
||||
$title = ['%title' => $this->node->label()];
|
||||
if ($this->node->book['has_children']) {
|
||||
return $this->t('%title has associated child pages, which will be relocated automatically to maintain their connection to the book. To recreate the hierarchy (as it was before removing this page), %title may be added again using the Outline tab, and each of its former child pages will need to be relocated manually.', $title);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class BookRemoveForm extends ConfirmFormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getQuestion() {
|
||||
return $this->t('Are you sure you want to remove %title from the book hierarchy?', array('%title' => $this->node->label()));
|
||||
return $this->t('Are you sure you want to remove %title from the book hierarchy?', ['%title' => $this->node->label()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,22 +30,22 @@ class BookSettingsForm extends ConfigFormBase {
|
|||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$types = node_type_get_names();
|
||||
$config = $this->config('book.settings');
|
||||
$form['book_allowed_types'] = array(
|
||||
$form['book_allowed_types'] = [
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => $this->t('Content types allowed in book outlines'),
|
||||
'#default_value' => $config->get('allowed_types'),
|
||||
'#options' => $types,
|
||||
'#description' => $this->t('Users with the %outline-perm permission can add all content types.', array('%outline-perm' => $this->t('Administer book outlines'))),
|
||||
'#description' => $this->t('Users with the %outline-perm permission can add all content types.', ['%outline-perm' => $this->t('Administer book outlines')]),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
$form['book_child_type'] = array(
|
||||
];
|
||||
$form['book_child_type'] = [
|
||||
'#type' => 'radios',
|
||||
'#title' => $this->t('Content type for the <em>Add child page</em> link'),
|
||||
'#default_value' => $config->get('child_type'),
|
||||
'#options' => $types,
|
||||
'#required' => TRUE,
|
||||
);
|
||||
$form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
|
||||
];
|
||||
$form['array_filter'] = ['#type' => 'value', '#value' => TRUE];
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ class BookSettingsForm extends ConfigFormBase {
|
|||
*/
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
$child_type = $form_state->getValue('book_child_type');
|
||||
if ($form_state->isValueEmpty(array('book_allowed_types', $child_type))) {
|
||||
$form_state->setErrorByName('book_child_type', $this->t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => $this->t('Add child page'))));
|
||||
if ($form_state->isValueEmpty(['book_allowed_types', $child_type])) {
|
||||
$form_state->setErrorByName('book_child_type', $this->t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', ['%add-child' => $this->t('Add child page')]));
|
||||
}
|
||||
|
||||
parent::validateForm($form, $form_state);
|
||||
|
|
|
@ -7,6 +7,7 @@ use Drupal\book\BookManagerInterface;
|
|||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
|
@ -85,26 +86,26 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
return [
|
||||
'block_mode' => "all pages",
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function blockForm($form, FormStateInterface $form_state) {
|
||||
$options = array(
|
||||
public function blockForm($form, FormStateInterface $form_state) {
|
||||
$options = [
|
||||
'all pages' => $this->t('Show block on all pages'),
|
||||
'book pages' => $this->t('Show block only on book pages'),
|
||||
);
|
||||
$form['book_block_mode'] = array(
|
||||
];
|
||||
$form['book_block_mode'] = [
|
||||
'#type' => 'radios',
|
||||
'#title' => $this->t('Book navigation block display'),
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->configuration['block_mode'],
|
||||
'#description' => $this->t("If <em>Show block on all pages</em> is selected, the block will contain the automatically generated menus for all of the site's books. If <em>Show block only on book pages</em> is selected, the block will contain only the one menu corresponding to the current page's book. In this case, if the current page is not in a book, no block will be displayed. The <em>Page specific visibility settings</em> or other visibility settings can be used in addition to selectively display this block."),
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
@ -126,8 +127,8 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
|
|||
$current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
|
||||
}
|
||||
if ($this->configuration['block_mode'] == 'all pages') {
|
||||
$book_menus = array();
|
||||
$pseudo_tree = array(0 => array('below' => FALSE));
|
||||
$book_menus = [];
|
||||
$pseudo_tree = [0 => ['below' => FALSE]];
|
||||
foreach ($this->bookManager->getAllBooks() as $book_id => $book) {
|
||||
if ($book['bid'] == $current_bid) {
|
||||
// If the current page is a node associated with a book, the menu
|
||||
|
@ -145,14 +146,14 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
|
|||
$pseudo_tree[0]['link'] = $book;
|
||||
$book_menus[$book_id] = $this->bookManager->bookTreeOutput($pseudo_tree);
|
||||
}
|
||||
$book_menus[$book_id] += array(
|
||||
$book_menus[$book_id] += [
|
||||
'#book_title' => $book['title'],
|
||||
);
|
||||
];
|
||||
}
|
||||
if ($book_menus) {
|
||||
return array(
|
||||
return [
|
||||
'#theme' => 'book_all_books_block',
|
||||
) + $book_menus;
|
||||
] + $book_menus;
|
||||
}
|
||||
}
|
||||
elseif ($current_bid) {
|
||||
|
@ -160,7 +161,7 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
|
|||
// not show unpublished books.
|
||||
$nid = \Drupal::entityQuery('node')
|
||||
->condition('nid', $node->book['bid'], '=')
|
||||
->condition('status', NODE_PUBLISHED)
|
||||
->condition('status', NodeInterface::PUBLISHED)
|
||||
->execute();
|
||||
|
||||
// Only show the block if the user has view access for the top-level node.
|
||||
|
@ -174,7 +175,7 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
|
|||
}
|
||||
}
|
||||
}
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,9 +17,9 @@ class Book extends DrupalSqlBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('book', 'b')->fields('b', array('nid', 'bid'));
|
||||
$query = $this->select('book', 'b')->fields('b', ['nid', 'bid']);
|
||||
$query->join('menu_links', 'ml', 'b.mlid = ml.mlid');
|
||||
$ml_fields = array('mlid', 'plid', 'weight', 'has_children', 'depth');
|
||||
$ml_fields = ['mlid', 'plid', 'weight', 'has_children', 'depth'];
|
||||
for ($i = 1; $i <= 9; $i++) {
|
||||
$field = "p$i";
|
||||
$ml_fields[] = $field;
|
||||
|
@ -42,7 +42,7 @@ class Book extends DrupalSqlBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
return [
|
||||
'nid' => $this->t('Node ID'),
|
||||
'bid' => $this->t('Book ID'),
|
||||
'mlid' => $this->t('Menu link ID'),
|
||||
|
@ -57,7 +57,7 @@ class Book extends DrupalSqlBase {
|
|||
'p7' => $this->t('The seventh mlid in the materialized path. See p1.'),
|
||||
'p8' => $this->t('The eighth mlid in the materialized path. See p1.'),
|
||||
'p9' => $this->t('The ninth mlid in the materialized path. See p1.'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@ class BookRelationshipTest extends ViewTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_book_view');
|
||||
public static $testViews = ['test_book_view'];
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('book_test_views', 'book', 'views');
|
||||
public static $modules = ['book_test_views', 'book', 'views'];
|
||||
|
||||
/**
|
||||
* A book node.
|
||||
|
@ -50,14 +50,14 @@ class BookRelationshipTest extends ViewTestBase {
|
|||
|
||||
// Create users.
|
||||
$this->bookAuthor = $this->drupalCreateUser(
|
||||
array(
|
||||
[
|
||||
'create new books',
|
||||
'create book content',
|
||||
'edit own book content',
|
||||
'add content to books',
|
||||
)
|
||||
]
|
||||
);
|
||||
ViewTestData::createTestViews(get_class($this), array('book_test_views'));
|
||||
ViewTestData::createTestViews(get_class($this), ['book_test_views']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +70,7 @@ class BookRelationshipTest extends ViewTestBase {
|
|||
$this->book = $this->createBookNode('new');
|
||||
$book = $this->book;
|
||||
|
||||
$nodes = array();
|
||||
$nodes = [];
|
||||
// Node 0.
|
||||
$nodes[] = $this->createBookNode($book->id());
|
||||
// Node 1.
|
||||
|
@ -110,7 +110,7 @@ class BookRelationshipTest extends ViewTestBase {
|
|||
// Used to ensure that when sorted nodes stay in same order.
|
||||
static $number = 0;
|
||||
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['title[0][value]'] = $number . ' - SimpleTest test node ' . $this->randomMachineName(10);
|
||||
$edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32);
|
||||
$edit['book[bid]'] = $book_nid;
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\book\Tests;
|
||||
namespace Drupal\Tests\book\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Create a book, add pages, and test book interface.
|
||||
*
|
||||
* @group book
|
||||
*/
|
||||
class BookBreadcrumbTest extends WebTestBase {
|
||||
class BookBreadcrumbTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('book', 'block', 'book_breadcrumb_test');
|
||||
public static $modules = ['book', 'block', 'book_breadcrumb_test'];
|
||||
|
||||
/**
|
||||
* A book node.
|
||||
|
@ -48,8 +48,8 @@ class BookBreadcrumbTest extends WebTestBase {
|
|||
$this->drupalPlaceBlock('page_title_block');
|
||||
|
||||
// Create users.
|
||||
$this->bookAuthor = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books'));
|
||||
$this->adminUser = $this->drupalCreateUser(array('create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'administer content types', 'administer site configuration'));
|
||||
$this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books']);
|
||||
$this->adminUser = $this->drupalCreateUser(['create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'administer content types', 'administer site configuration']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,7 +76,7 @@ class BookBreadcrumbTest extends WebTestBase {
|
|||
* |- Node 5
|
||||
* |- Node 6
|
||||
*/
|
||||
$nodes = array();
|
||||
$nodes = [];
|
||||
$nodes[0] = $this->createBookNode($book->id());
|
||||
$nodes[1] = $this->createBookNode($book->id(), $nodes[0]->id());
|
||||
$nodes[2] = $this->createBookNode($book->id(), $nodes[0]->id());
|
||||
|
@ -107,7 +107,7 @@ class BookBreadcrumbTest extends WebTestBase {
|
|||
// that when sorted nodes stay in same order.
|
||||
static $number = 0;
|
||||
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - SimpleTest test node ' . $this->randomMachineName(10);
|
||||
$edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32);
|
||||
$edit['book[bid]'] = $book_nid;
|
||||
|
@ -146,9 +146,9 @@ class BookBreadcrumbTest extends WebTestBase {
|
|||
$this->drupalGet($nodes[4]->toUrl());
|
||||
// Fetch each node title in the current breadcrumb.
|
||||
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
|
||||
$got_breadcrumb = array();
|
||||
$got_breadcrumb = [];
|
||||
foreach ($links as $link) {
|
||||
$got_breadcrumb[] = (string) $link;
|
||||
$got_breadcrumb[] = $link->getText();
|
||||
}
|
||||
// Home link and four parent book nodes should be in the breadcrumb.
|
||||
$this->assertEqual(5, count($got_breadcrumb));
|
||||
|
@ -160,9 +160,9 @@ class BookBreadcrumbTest extends WebTestBase {
|
|||
$this->drupalGet($nodes[4]->toUrl());
|
||||
// Fetch each node title in the current breadcrumb.
|
||||
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
|
||||
$got_breadcrumb = array();
|
||||
$got_breadcrumb = [];
|
||||
foreach ($links as $link) {
|
||||
$got_breadcrumb[] = (string) $link;
|
||||
$got_breadcrumb[] = $link->getText();
|
||||
}
|
||||
$this->assertEqual(5, count($got_breadcrumb));
|
||||
$this->assertEqual($edit['title[0][value]'], end($got_breadcrumb));
|
||||
|
@ -181,9 +181,9 @@ class BookBreadcrumbTest extends WebTestBase {
|
|||
$this->drupalPostForm($nodes[3]->toUrl('edit-form'), $edit, 'Save');
|
||||
$this->drupalGet($nodes[4]->toUrl());
|
||||
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
|
||||
$got_breadcrumb = array();
|
||||
$got_breadcrumb = [];
|
||||
foreach ($links as $link) {
|
||||
$got_breadcrumb[] = (string) $link;
|
||||
$got_breadcrumb[] = $link->getText();
|
||||
}
|
||||
$this->assertEqual(5, count($got_breadcrumb));
|
||||
$this->assertEqual($edit['title[0][value]'], end($got_breadcrumb));
|
||||
|
@ -191,9 +191,9 @@ class BookBreadcrumbTest extends WebTestBase {
|
|||
$config->set('hide', TRUE)->save();
|
||||
$this->drupalGet($nodes[4]->toUrl());
|
||||
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
|
||||
$got_breadcrumb = array();
|
||||
$got_breadcrumb = [];
|
||||
foreach ($links as $link) {
|
||||
$got_breadcrumb[] = (string) $link;
|
||||
$got_breadcrumb[] = $link->getText();
|
||||
}
|
||||
$this->assertEqual(4, count($got_breadcrumb));
|
||||
$this->assertEqual($nodes[2]->getTitle(), end($got_breadcrumb));
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\book\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\Core\Config\PreExistingConfigException;
|
||||
|
||||
/**
|
||||
* Test installation of Book module.
|
||||
*
|
||||
* @group book
|
||||
*/
|
||||
class BookInstallTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['node'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Book install with pre-existing content type.
|
||||
*
|
||||
* Tests that Book module can be installed if content type with machine name
|
||||
* 'book' already exists.
|
||||
*/
|
||||
public function testBookInstallWithPreexistingContentType() {
|
||||
// Create a 'book' content type.
|
||||
$this->drupalCreateContentType(['type' => 'book']);
|
||||
|
||||
// Install the Book module.
|
||||
try {
|
||||
$this->container->get('module_installer')->install(['book']);
|
||||
}
|
||||
catch (PreExistingConfigException $e) {
|
||||
$this->fail("Expected exception thrown trying to install Book module: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\book\Tests;
|
||||
namespace Drupal\Tests\book\Functional;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\user\RoleInterface;
|
||||
|
||||
/**
|
||||
|
@ -13,14 +13,14 @@ use Drupal\user\RoleInterface;
|
|||
*
|
||||
* @group book
|
||||
*/
|
||||
class BookTest extends WebTestBase {
|
||||
class BookTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('book', 'block', 'node_access_test', 'book_test');
|
||||
public static $modules = ['book', 'block', 'node_access_test', 'book_test'];
|
||||
|
||||
/**
|
||||
* A book node.
|
||||
|
@ -69,10 +69,10 @@ class BookTest extends WebTestBase {
|
|||
node_access_rebuild();
|
||||
|
||||
// Create users.
|
||||
$this->bookAuthor = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books'));
|
||||
$this->webUser = $this->drupalCreateUser(array('access printer-friendly version', 'node test view'));
|
||||
$this->webUserWithoutNodeAccess = $this->drupalCreateUser(array('access printer-friendly version'));
|
||||
$this->adminUser = $this->drupalCreateUser(array('create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'node test view', 'administer content types', 'administer site configuration'));
|
||||
$this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books']);
|
||||
$this->webUser = $this->drupalCreateUser(['access printer-friendly version', 'node test view']);
|
||||
$this->webUserWithoutNodeAccess = $this->drupalCreateUser(['access printer-friendly version']);
|
||||
$this->adminUser = $this->drupalCreateUser(['create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'node test view', 'administer content types', 'administer site configuration']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,7 +80,7 @@ class BookTest extends WebTestBase {
|
|||
*
|
||||
* @return \Drupal\node\NodeInterface[]
|
||||
*/
|
||||
function createBook() {
|
||||
public function createBook() {
|
||||
// Create new book.
|
||||
$this->drupalLogin($this->bookAuthor);
|
||||
|
||||
|
@ -96,7 +96,7 @@ class BookTest extends WebTestBase {
|
|||
* |- Node 3
|
||||
* |- Node 4
|
||||
*/
|
||||
$nodes = array();
|
||||
$nodes = [];
|
||||
$nodes[] = $this->createBookNode($book->id()); // Node 0.
|
||||
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid']); // Node 1.
|
||||
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid']); // Node 2.
|
||||
|
@ -151,7 +151,7 @@ class BookTest extends WebTestBase {
|
|||
/**
|
||||
* Tests saving the book outline on an empty book.
|
||||
*/
|
||||
function testEmptyBook() {
|
||||
public function testEmptyBook() {
|
||||
// Create a new empty book.
|
||||
$this->drupalLogin($this->bookAuthor);
|
||||
$book = $this->createBookNode('new');
|
||||
|
@ -159,14 +159,14 @@ class BookTest extends WebTestBase {
|
|||
|
||||
// Log in as a user with access to the book outline and save the form.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalPostForm('admin/structure/book/' . $book->id(), array(), t('Save book pages'));
|
||||
$this->assertText(t('Updated book @book.', array('@book' => $book->label())));
|
||||
$this->drupalPostForm('admin/structure/book/' . $book->id(), [], t('Save book pages'));
|
||||
$this->assertText(t('Updated book @book.', ['@book' => $book->label()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests book functionality through node interfaces.
|
||||
*/
|
||||
function testBook() {
|
||||
public function testBook() {
|
||||
// Create new book.
|
||||
$nodes = $this->createBook();
|
||||
$book = $this->book;
|
||||
|
@ -175,12 +175,12 @@ class BookTest extends WebTestBase {
|
|||
|
||||
// Check that book pages display along with the correct outlines and
|
||||
// previous/next links.
|
||||
$this->checkBookNode($book, array($nodes[0], $nodes[3], $nodes[4]), FALSE, FALSE, $nodes[0], array());
|
||||
$this->checkBookNode($nodes[0], array($nodes[1], $nodes[2]), $book, $book, $nodes[1], array($book));
|
||||
$this->checkBookNode($nodes[1], NULL, $nodes[0], $nodes[0], $nodes[2], array($book, $nodes[0]));
|
||||
$this->checkBookNode($nodes[2], NULL, $nodes[1], $nodes[0], $nodes[3], array($book, $nodes[0]));
|
||||
$this->checkBookNode($nodes[3], NULL, $nodes[2], $book, $nodes[4], array($book));
|
||||
$this->checkBookNode($nodes[4], NULL, $nodes[3], $book, FALSE, array($book));
|
||||
$this->checkBookNode($book, [$nodes[0], $nodes[3], $nodes[4]], FALSE, FALSE, $nodes[0], []);
|
||||
$this->checkBookNode($nodes[0], [$nodes[1], $nodes[2]], $book, $book, $nodes[1], [$book]);
|
||||
$this->checkBookNode($nodes[1], NULL, $nodes[0], $nodes[0], $nodes[2], [$book, $nodes[0]]);
|
||||
$this->checkBookNode($nodes[2], NULL, $nodes[1], $nodes[0], $nodes[3], [$book, $nodes[0]]);
|
||||
$this->checkBookNode($nodes[3], NULL, $nodes[2], $book, $nodes[4], [$book]);
|
||||
$this->checkBookNode($nodes[4], NULL, $nodes[3], $book, FALSE, [$book]);
|
||||
|
||||
$this->drupalLogout();
|
||||
$this->drupalLogin($this->bookAuthor);
|
||||
|
@ -203,14 +203,14 @@ class BookTest extends WebTestBase {
|
|||
$this->drupalLogout();
|
||||
$this->drupalLogin($this->webUser);
|
||||
// Verify the new outline - make sure we don't get stale cached data.
|
||||
$this->checkBookNode($nodes[3], array($nodes[5]), $nodes[2], $book, $nodes[5], array($book));
|
||||
$this->checkBookNode($nodes[4], NULL, $nodes[5], $book, FALSE, array($book));
|
||||
$this->checkBookNode($nodes[3], [$nodes[5]], $nodes[2], $book, $nodes[5], [$book]);
|
||||
$this->checkBookNode($nodes[4], NULL, $nodes[5], $book, FALSE, [$book]);
|
||||
$this->drupalLogout();
|
||||
// Create a second book, and move an existing book page into it.
|
||||
$this->drupalLogin($this->bookAuthor);
|
||||
$other_book = $this->createBookNode('new');
|
||||
$node = $this->createBookNode($book->id());
|
||||
$edit = array('book[bid]' => $other_book->id());
|
||||
$edit = ['book[bid]' => $other_book->id()];
|
||||
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
|
||||
|
||||
$this->drupalLogout();
|
||||
|
@ -220,8 +220,8 @@ class BookTest extends WebTestBase {
|
|||
// First we must set $this->book to the second book, so that the
|
||||
// correct regex will be generated for testing the outline.
|
||||
$this->book = $other_book;
|
||||
$this->checkBookNode($other_book, array($node), FALSE, FALSE, $node, array());
|
||||
$this->checkBookNode($node, NULL, $other_book, $other_book, FALSE, array($other_book));
|
||||
$this->checkBookNode($other_book, [$node], FALSE, FALSE, $node, []);
|
||||
$this->checkBookNode($node, NULL, $other_book, $other_book, FALSE, [$other_book]);
|
||||
|
||||
// Test that we can save a book programatically.
|
||||
$this->drupalLogin($this->bookAuthor);
|
||||
|
@ -247,7 +247,7 @@ class BookTest extends WebTestBase {
|
|||
* @param array $breadcrumb
|
||||
* The nodes that should be displayed in the breadcrumb.
|
||||
*/
|
||||
function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = FALSE, $next = FALSE, array $breadcrumb) {
|
||||
public function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = FALSE, $next = FALSE, array $breadcrumb) {
|
||||
// $number does not use drupal_static as it should not be reset
|
||||
// since it uniquely identifies each call to checkBookNode().
|
||||
static $number = 0;
|
||||
|
@ -255,38 +255,38 @@ class BookTest extends WebTestBase {
|
|||
|
||||
// Check outline structure.
|
||||
if ($nodes !== NULL) {
|
||||
$this->assertPattern($this->generateOutlinePattern($nodes), format_string('Node @number outline confirmed.', array('@number' => $number)));
|
||||
$this->assertPattern($this->generateOutlinePattern($nodes), format_string('Node @number outline confirmed.', ['@number' => $number]));
|
||||
}
|
||||
else {
|
||||
$this->pass(format_string('Node %number does not have outline.', array('%number' => $number)));
|
||||
$this->pass(format_string('Node %number does not have outline.', ['%number' => $number]));
|
||||
}
|
||||
|
||||
// Check previous, up, and next links.
|
||||
if ($previous) {
|
||||
/** @var \Drupal\Core\Url $url */
|
||||
$url = $previous->urlInfo();
|
||||
$url->setOptions(array('attributes' => array('rel' => array('prev'), 'title' => t('Go to previous page'))));
|
||||
$text = SafeMarkup::format('<b>‹</b> @label', array('@label' => $previous->label()));
|
||||
$url->setOptions(['attributes' => ['rel' => ['prev'], 'title' => t('Go to previous page')]]);
|
||||
$text = SafeMarkup::format('<b>‹</b> @label', ['@label' => $previous->label()]);
|
||||
$this->assertRaw(\Drupal::l($text, $url), 'Previous page link found.');
|
||||
}
|
||||
|
||||
if ($up) {
|
||||
/** @var \Drupal\Core\Url $url */
|
||||
$url = $up->urlInfo();
|
||||
$url->setOptions(array('attributes' => array('title' => t('Go to parent page'))));
|
||||
$url->setOptions(['attributes' => ['title' => t('Go to parent page')]]);
|
||||
$this->assertRaw(\Drupal::l('Up', $url), 'Up page link found.');
|
||||
}
|
||||
|
||||
if ($next) {
|
||||
/** @var \Drupal\Core\Url $url */
|
||||
$url = $next->urlInfo();
|
||||
$url->setOptions(array('attributes' => array('rel' => array('next'), 'title' => t('Go to next page'))));
|
||||
$text = SafeMarkup::format('@label <b>›</b>', array('@label' => $next->label()));
|
||||
$url->setOptions(['attributes' => ['rel' => ['next'], 'title' => t('Go to next page')]]);
|
||||
$text = SafeMarkup::format('@label <b>›</b>', ['@label' => $next->label()]);
|
||||
$this->assertRaw(\Drupal::l($text, $url), 'Next page link found.');
|
||||
}
|
||||
|
||||
// Compute the expected breadcrumb.
|
||||
$expected_breadcrumb = array();
|
||||
$expected_breadcrumb = [];
|
||||
$expected_breadcrumb[] = \Drupal::url('<front>');
|
||||
foreach ($breadcrumb as $a_node) {
|
||||
$expected_breadcrumb[] = $a_node->url();
|
||||
|
@ -294,9 +294,9 @@ class BookTest extends WebTestBase {
|
|||
|
||||
// Fetch links in the current breadcrumb.
|
||||
$links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
|
||||
$got_breadcrumb = array();
|
||||
$got_breadcrumb = [];
|
||||
foreach ($links as $link) {
|
||||
$got_breadcrumb[] = (string) $link['href'];
|
||||
$got_breadcrumb[] = $link->getAttribute('href');
|
||||
}
|
||||
|
||||
// Compare expected and got breadcrumbs.
|
||||
|
@ -319,7 +319,7 @@ class BookTest extends WebTestBase {
|
|||
* @return string
|
||||
* A regular expression that locates sub-nodes of the outline.
|
||||
*/
|
||||
function generateOutlinePattern($nodes) {
|
||||
public function generateOutlinePattern($nodes) {
|
||||
$outline = '';
|
||||
foreach ($nodes as $node) {
|
||||
$outline .= '(node\/' . $node->id() . ')(.*?)(' . $node->label() . ')(.*?)';
|
||||
|
@ -339,12 +339,12 @@ class BookTest extends WebTestBase {
|
|||
* @return \Drupal\node\NodeInterface
|
||||
* The created node.
|
||||
*/
|
||||
function createBookNode($book_nid, $parent = NULL) {
|
||||
public function createBookNode($book_nid, $parent = NULL) {
|
||||
// $number does not use drupal_static as it should not be reset
|
||||
// since it uniquely identifies each call to createBookNode().
|
||||
static $number = 0; // Used to ensure that when sorted nodes stay in same order.
|
||||
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - SimpleTest test node ' . $this->randomMachineName(10);
|
||||
$edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32);
|
||||
$edit['book[bid]'] = $book_nid;
|
||||
|
@ -373,7 +373,7 @@ class BookTest extends WebTestBase {
|
|||
/**
|
||||
* Tests book export ("printer-friendly version") functionality.
|
||||
*/
|
||||
function testBookExport() {
|
||||
public function testBookExport() {
|
||||
// Create a book.
|
||||
$nodes = $this->createBook();
|
||||
|
||||
|
@ -410,7 +410,7 @@ class BookTest extends WebTestBase {
|
|||
// Now grant anonymous users permission to view the printer-friendly
|
||||
// version and verify that node access restrictions still prevent them from
|
||||
// seeing it.
|
||||
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access printer-friendly version'));
|
||||
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access printer-friendly version']);
|
||||
$this->drupalGet('book/export/html/' . $this->book->id());
|
||||
$this->assertResponse('403', 'Anonymous user properly forbidden from seeing the printer-friendly version when denied by node access.');
|
||||
}
|
||||
|
@ -418,14 +418,14 @@ class BookTest extends WebTestBase {
|
|||
/**
|
||||
* Tests the functionality of the book navigation block.
|
||||
*/
|
||||
function testBookNavigationBlock() {
|
||||
public function testBookNavigationBlock() {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Enable the block.
|
||||
$block = $this->drupalPlaceBlock('book_navigation');
|
||||
|
||||
// Give anonymous users the permission 'node test view'.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit[RoleInterface::ANONYMOUS_ID . '[node test view]'] = TRUE;
|
||||
$this->drupalPostForm('admin/people/permissions/' . RoleInterface::ANONYMOUS_ID, $edit, t('Save permissions'));
|
||||
$this->assertText(t('The changes have been saved.'), "Permission 'node test view' successfully assigned to anonymous users.");
|
||||
|
@ -434,7 +434,7 @@ class BookTest extends WebTestBase {
|
|||
$nodes = $this->createBook();
|
||||
$this->drupalGet('<front>');
|
||||
$this->assertText($block->label(), 'Book navigation block is displayed.');
|
||||
$this->assertText($this->book->label(), format_string('Link to book root (@title) is displayed.', array('@title' => $nodes[0]->label())));
|
||||
$this->assertText($this->book->label(), format_string('Link to book root (@title) is displayed.', ['@title' => $nodes[0]->label()]));
|
||||
$this->assertNoText($nodes[0]->label(), 'No links to individual book pages are displayed.');
|
||||
}
|
||||
|
||||
|
@ -485,8 +485,8 @@ class BookTest extends WebTestBase {
|
|||
$diff = array_diff($expected_nids, array_keys($options));
|
||||
$this->assertTrue(empty($diff), 'Found all expected option keys');
|
||||
// Exclude Node 3.
|
||||
$options = $manager->getTableOfContents($book->id(), 3, array($nodes[3]->id()));
|
||||
$expected_nids = array($book->id(), $nodes[0]->id(), $nodes[1]->id(), $nodes[2]->id(), $nodes[4]->id());
|
||||
$options = $manager->getTableOfContents($book->id(), 3, [$nodes[3]->id()]);
|
||||
$expected_nids = [$book->id(), $nodes[0]->id(), $nodes[1]->id(), $nodes[2]->id(), $nodes[4]->id()];
|
||||
$this->assertEqual(count($options), count($expected_nids));
|
||||
$diff = array_diff($expected_nids, array_keys($options));
|
||||
$this->assertTrue(empty($diff), 'Found all expected option keys after excluding Node 3');
|
||||
|
@ -495,12 +495,12 @@ class BookTest extends WebTestBase {
|
|||
/**
|
||||
* Tests the book navigation block when an access module is installed.
|
||||
*/
|
||||
function testNavigationBlockOnAccessModuleInstalled() {
|
||||
public function testNavigationBlockOnAccessModuleInstalled() {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$block = $this->drupalPlaceBlock('book_navigation', array('block_mode' => 'book pages'));
|
||||
$block = $this->drupalPlaceBlock('book_navigation', ['block_mode' => 'book pages']);
|
||||
|
||||
// Give anonymous users the permission 'node test view'.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit[RoleInterface::ANONYMOUS_ID . '[node test view]'] = TRUE;
|
||||
$this->drupalPostForm('admin/people/permissions/' . RoleInterface::ANONYMOUS_ID, $edit, t('Save permissions'));
|
||||
$this->assertText(t('The changes have been saved.'), "Permission 'node test view' successfully assigned to anonymous users.");
|
||||
|
@ -526,17 +526,17 @@ class BookTest extends WebTestBase {
|
|||
/**
|
||||
* Tests the access for deleting top-level book nodes.
|
||||
*/
|
||||
function testBookDelete() {
|
||||
public function testBookDelete() {
|
||||
$node_storage = $this->container->get('entity.manager')->getStorage('node');
|
||||
$nodes = $this->createBook();
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
|
||||
// Test access to delete top-level and child book nodes.
|
||||
$this->drupalGet('node/' . $this->book->id() . '/outline/remove');
|
||||
$this->assertResponse('403', 'Deleting top-level book node properly forbidden.');
|
||||
$this->drupalPostForm('node/' . $nodes[4]->id() . '/outline/remove', $edit, t('Remove'));
|
||||
$node_storage->resetCache(array($nodes[4]->id()));
|
||||
$node_storage->resetCache([$nodes[4]->id()]);
|
||||
$node4 = $node_storage->load($nodes[4]->id());
|
||||
$this->assertTrue(empty($node4->book), 'Deleting child book node properly allowed.');
|
||||
|
||||
|
@ -546,7 +546,7 @@ class BookTest extends WebTestBase {
|
|||
}
|
||||
entity_delete_multiple('node', $nids);
|
||||
$this->drupalPostForm('node/' . $this->book->id() . '/outline/remove', $edit, t('Remove'));
|
||||
$node_storage->resetCache(array($this->book->id()));
|
||||
$node_storage->resetCache([$this->book->id()]);
|
||||
$node = $node_storage->load($this->book->id());
|
||||
$this->assertTrue(empty($node->book), 'Deleting childless top-level book node properly allowed.');
|
||||
|
||||
|
@ -577,7 +577,7 @@ class BookTest extends WebTestBase {
|
|||
$this->drupalLogin($this->bookAuthor);
|
||||
|
||||
// Create new node not yet a book.
|
||||
$empty_book = $this->drupalCreateNode(array('type' => 'book'));
|
||||
$empty_book = $this->drupalCreateNode(['type' => 'book']);
|
||||
$this->drupalGet('node/' . $empty_book->id() . '/outline');
|
||||
$this->assertNoLink(t('Book outline'), 'Book Author is not allowed to outline');
|
||||
|
||||
|
@ -587,7 +587,7 @@ class BookTest extends WebTestBase {
|
|||
$this->assertOptionSelected('edit-book-bid', 0, 'Node does not belong to a book');
|
||||
$this->assertNoLink(t('Remove from book outline'));
|
||||
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['book[bid]'] = '1';
|
||||
$this->drupalPostForm('node/' . $empty_book->id() . '/outline', $edit, t('Add to book outline'));
|
||||
$node = \Drupal::entityManager()->getStorage('node')->load($empty_book->id());
|
||||
|
@ -606,11 +606,11 @@ class BookTest extends WebTestBase {
|
|||
$this->drupalGet('node/' . $book->id() . '/outline');
|
||||
$this->assertRaw(t('Book outline'));
|
||||
$this->clickLink(t('Remove from book outline'));
|
||||
$this->assertRaw(t('Are you sure you want to remove %title from the book hierarchy?', array('%title' => $book->label())));
|
||||
$this->assertRaw(t('Are you sure you want to remove %title from the book hierarchy?', ['%title' => $book->label()]));
|
||||
|
||||
// Create a new node and set the book after the node was created.
|
||||
$node = $this->drupalCreateNode(array('type' => 'book'));
|
||||
$edit = array();
|
||||
$node = $this->drupalCreateNode(['type' => 'book']);
|
||||
$edit = [];
|
||||
$edit['book[bid]'] = $node->id();
|
||||
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
|
||||
$node = \Drupal::entityManager()->getStorage('node')->load($node->id());
|
||||
|
@ -634,7 +634,7 @@ class BookTest extends WebTestBase {
|
|||
$book_manager = \Drupal::service('book.manager');
|
||||
|
||||
// Mock a link for a new book.
|
||||
$link = array('nid' => 1, 'has_children' => 0, 'original_bid' => 0, 'parent_depth_limit' => 8, 'pid' => 0, 'weight' => 0, 'bid' => 1);
|
||||
$link = ['nid' => 1, 'has_children' => 0, 'original_bid' => 0, 'parent_depth_limit' => 8, 'pid' => 0, 'weight' => 0, 'bid' => 1];
|
||||
$new = TRUE;
|
||||
|
||||
// Save the link.
|
||||
|
@ -690,7 +690,7 @@ class BookTest extends WebTestBase {
|
|||
$this->assertText($this->book->label(), 'The book title is displayed on the administrative book listing page.');
|
||||
|
||||
$elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a');
|
||||
$this->assertEqual((string) $elements[0], 'View', 'View link is found from the list.');
|
||||
$this->assertEqual($elements[0]->getText(), 'View', 'View link is found from the list.');
|
||||
}
|
||||
|
||||
/**
|
|
@ -27,11 +27,11 @@ class BookUninstallTest extends KernelTestBase {
|
|||
parent::setUp();
|
||||
$this->installEntitySchema('user');
|
||||
$this->installEntitySchema('node');
|
||||
$this->installSchema('book', array('book'));
|
||||
$this->installSchema('node', array('node_access'));
|
||||
$this->installConfig(array('node', 'book', 'field'));
|
||||
$this->installSchema('book', ['book']);
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->installConfig(['node', 'book', 'field']);
|
||||
// For uninstall to work.
|
||||
$this->installSchema('user', array('users_data'));
|
||||
$this->installSchema('user', ['users_data']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,17 +42,17 @@ class BookUninstallTest extends KernelTestBase {
|
|||
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
|
||||
$this->assertEqual([], $validation_reasons, 'The book module is not required.');
|
||||
|
||||
$content_type = NodeType::create(array(
|
||||
$content_type = NodeType::create([
|
||||
'type' => $this->randomMachineName(),
|
||||
'name' => $this->randomString(),
|
||||
));
|
||||
]);
|
||||
$content_type->save();
|
||||
$book_config = $this->config('book.settings');
|
||||
$allowed_types = $book_config->get('allowed_types');
|
||||
$allowed_types[] = $content_type->id();
|
||||
$book_config->set('allowed_types', $allowed_types)->save();
|
||||
|
||||
$node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id()));
|
||||
$node = Node::create(['title' => $this->randomString(), 'type' => $content_type->id()]);
|
||||
$node->book['bid'] = 'new';
|
||||
$node->save();
|
||||
|
||||
|
@ -60,7 +60,7 @@ class BookUninstallTest extends KernelTestBase {
|
|||
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
|
||||
$this->assertEqual(['To uninstall Book, delete all content that is part of a book'], $validation_reasons['book']);
|
||||
|
||||
$book_node = Node::create(array('title' => $this->randomString(), 'type' => 'book'));
|
||||
$book_node = Node::create(['title' => $this->randomString(), 'type' => 'book']);
|
||||
$book_node->book['bid'] = FALSE;
|
||||
$book_node->save();
|
||||
|
||||
|
@ -79,7 +79,7 @@ class BookUninstallTest extends KernelTestBase {
|
|||
$module_data = _system_rebuild_module_data();
|
||||
$this->assertFalse(isset($module_data['book']->info['required']), 'The book module is not required.');
|
||||
|
||||
$node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id()));
|
||||
$node = Node::create(['title' => $this->randomString(), 'type' => $content_type->id()]);
|
||||
$node->save();
|
||||
// One node exists but is not part of a book therefore the book module is
|
||||
// not required.
|
||||
|
@ -87,7 +87,7 @@ class BookUninstallTest extends KernelTestBase {
|
|||
$this->assertEqual([], $validation_reasons, 'The book module is not required.');
|
||||
|
||||
// Uninstall the Book module and check the node type is deleted.
|
||||
\Drupal::service('module_installer')->uninstall(array('book'));
|
||||
\Drupal::service('module_installer')->uninstall(['book']);
|
||||
$this->assertNull(NodeType::load('book'), "The book node type does not exist.");
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\book\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ class MigrateBookConfigsTest extends MigrateDrupal6TestBase {
|
|||
$config = $this->config('book.settings');
|
||||
$this->assertIdentical('book', $config->get('child_type'));
|
||||
$this->assertIdentical('all pages', $config->get('block.navigation.mode'));
|
||||
$this->assertIdentical(array('book'), $config->get('allowed_types'));
|
||||
$this->assertIdentical(['book'], $config->get('allowed_types'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'book.settings', $config->get());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class MigrateBookTest extends MigrateDrupal6TestBase {
|
|||
* Tests the Drupal 6 book structure to Drupal 8 migration.
|
||||
*/
|
||||
public function testBook() {
|
||||
$nodes = Node::loadMultiple(array(4, 5, 6, 7, 8));
|
||||
$nodes = Node::loadMultiple([4, 5, 6, 7, 8]);
|
||||
$this->assertIdentical('4', $nodes[4]->book['bid']);
|
||||
$this->assertIdentical('0', $nodes[4]->book['pid']);
|
||||
|
||||
|
@ -53,8 +53,8 @@ class MigrateBookTest extends MigrateDrupal6TestBase {
|
|||
$this->assertIdentical('5', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['link']['nid']);
|
||||
$this->assertIdentical('6', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['link']['nid']);
|
||||
$this->assertIdentical('7', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['link']['nid']);
|
||||
$this->assertIdentical(array(), $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['below']);
|
||||
$this->assertIdentical(array(), $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['below']);
|
||||
$this->assertIdentical([], $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['below']);
|
||||
$this->assertIdentical([], $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['below']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class BookManagerTest extends UnitTestCase {
|
|||
protected function setUp() {
|
||||
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
$this->translation = $this->getStringTranslationStub();
|
||||
$this->configFactory = $this->getConfigFactoryStub(array());
|
||||
$this->configFactory = $this->getConfigFactoryStub([]);
|
||||
$this->bookOutlineStorage = $this->getMock('Drupal\book\BookOutlineStorageInterface');
|
||||
$this->renderer = $this->getMock('\Drupal\Core\Render\RendererInterface');
|
||||
$this->bookManager = new BookManager($this->entityManager, $this->translation, $this->configFactory, $this->bookOutlineStorage, $this->renderer);
|
||||
|
@ -81,7 +81,7 @@ class BookManagerTest extends UnitTestCase {
|
|||
* The test data.
|
||||
*/
|
||||
public function providerTestGetBookParents() {
|
||||
$empty = array(
|
||||
$empty = [
|
||||
'p1' => 0,
|
||||
'p2' => 0,
|
||||
'p3' => 0,
|
||||
|
@ -91,27 +91,27 @@ class BookManagerTest extends UnitTestCase {
|
|||
'p7' => 0,
|
||||
'p8' => 0,
|
||||
'p9' => 0,
|
||||
);
|
||||
return array(
|
||||
];
|
||||
return [
|
||||
// Provides a book without an existing parent.
|
||||
array(
|
||||
array('pid' => 0, 'nid' => 12),
|
||||
array(),
|
||||
array('depth' => 1, 'p1' => 12) + $empty,
|
||||
),
|
||||
[
|
||||
['pid' => 0, 'nid' => 12],
|
||||
[],
|
||||
['depth' => 1, 'p1' => 12] + $empty,
|
||||
],
|
||||
// Provides a book with an existing parent.
|
||||
array(
|
||||
array('pid' => 11, 'nid' => 12),
|
||||
array('nid' => 11, 'depth' => 1, 'p1' => 11,),
|
||||
array('depth' => 2, 'p1' => 11, 'p2' => 12) + $empty,
|
||||
),
|
||||
[
|
||||
['pid' => 11, 'nid' => 12],
|
||||
['nid' => 11, 'depth' => 1, 'p1' => 11],
|
||||
['depth' => 2, 'p1' => 11, 'p2' => 12] + $empty,
|
||||
],
|
||||
// Provides a book with two existing parents.
|
||||
array(
|
||||
array('pid' => 11, 'nid' => 12),
|
||||
array('nid' => 11, 'depth' => 2, 'p1' => 10, 'p2' => 11),
|
||||
array('depth' => 3, 'p1' => 10, 'p2' => 11, 'p3' => 12) + $empty,
|
||||
),
|
||||
);
|
||||
[
|
||||
['pid' => 11, 'nid' => 12],
|
||||
['nid' => 11, 'depth' => 2, 'p1' => 10, 'p2' => 11],
|
||||
['depth' => 3, 'p1' => 10, 'p2' => 11, 'p3' => 12] + $empty,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
|
|||
class BookLocalTasksTest extends LocalTaskIntegrationTestBase {
|
||||
|
||||
protected function setUp() {
|
||||
$this->directoryList = array(
|
||||
$this->directoryList = [
|
||||
'book' => 'core/modules/book',
|
||||
'node' => 'core/modules/node',
|
||||
);
|
||||
];
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
|
@ -26,19 +26,19 @@ class BookLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
*/
|
||||
public function testBookAdminLocalTasks($route) {
|
||||
|
||||
$this->assertLocalTasks($route, array(
|
||||
0 => array('book.admin', 'book.settings'),
|
||||
));
|
||||
$this->assertLocalTasks($route, [
|
||||
0 => ['book.admin', 'book.settings'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of routes to test.
|
||||
*/
|
||||
public function getBookAdminRoutes() {
|
||||
return array(
|
||||
array('book.admin'),
|
||||
array('book.settings'),
|
||||
);
|
||||
return [
|
||||
['book.admin'],
|
||||
['book.settings'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,19 +47,19 @@ class BookLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
* @dataProvider getBookNodeRoutes
|
||||
*/
|
||||
public function testBookNodeLocalTasks($route) {
|
||||
$this->assertLocalTasks($route, array(
|
||||
0 => array('entity.node.book_outline_form', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history',),
|
||||
));
|
||||
$this->assertLocalTasks($route, [
|
||||
0 => ['entity.node.book_outline_form', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of routes to test.
|
||||
*/
|
||||
public function getBookNodeRoutes() {
|
||||
return array(
|
||||
array('entity.node.canonical'),
|
||||
array('entity.node.book_outline_form'),
|
||||
);
|
||||
return [
|
||||
['entity.node.canonical'],
|
||||
['entity.node.book_outline_form'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue