Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -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.'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue