Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -81,10 +81,10 @@ use Drupal\Core\Access\AccessResult;
|
|||
*/
|
||||
function hook_node_grants(\Drupal\Core\Session\AccountInterface $account, $op) {
|
||||
if ($account->hasPermission('access private content')) {
|
||||
$grants['example'] = array(1);
|
||||
$grants['example'] = [1];
|
||||
}
|
||||
if ($account->id()) {
|
||||
$grants['example_author'] = array($account->id());
|
||||
$grants['example_author'] = [$account->id()];
|
||||
}
|
||||
return $grants;
|
||||
}
|
||||
|
@ -158,33 +158,33 @@ function hook_node_access_records(\Drupal\node\NodeInterface $node) {
|
|||
// We only care about the node if it has been marked private. If not, it is
|
||||
// treated just like any other node and we completely ignore it.
|
||||
if ($node->private->value) {
|
||||
$grants = array();
|
||||
$grants = [];
|
||||
// Only published Catalan translations of private nodes should be viewable
|
||||
// to all users. If we fail to check $node->isPublished(), all users would be able
|
||||
// to view an unpublished node.
|
||||
if ($node->isPublished()) {
|
||||
$grants[] = array(
|
||||
$grants[] = [
|
||||
'realm' => 'example',
|
||||
'gid' => 1,
|
||||
'grant_view' => 1,
|
||||
'grant_update' => 0,
|
||||
'grant_delete' => 0,
|
||||
'langcode' => 'ca'
|
||||
);
|
||||
];
|
||||
}
|
||||
// For the example_author array, the GID is equivalent to a UID, which
|
||||
// means there are many groups of just 1 user.
|
||||
// Note that an author can always view his or her nodes, even if they
|
||||
// have status unpublished.
|
||||
if ($node->getOwnerId()) {
|
||||
$grants[] = array(
|
||||
$grants[] = [
|
||||
'realm' => 'example_author',
|
||||
'gid' => $node->getOwnerId(),
|
||||
'grant_view' => 1,
|
||||
'grant_update' => 1,
|
||||
'grant_delete' => 1,
|
||||
'langcode' => 'ca'
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $grants;
|
||||
|
@ -231,7 +231,7 @@ function hook_node_access_records_alter(&$grants, Drupal\node\NodeInterface $nod
|
|||
// Our module grants are set in $grants['example'].
|
||||
$temp = $grants['example'];
|
||||
// Now remove all module grants but our own.
|
||||
$grants = array('example' => $temp);
|
||||
$grants = ['example' => $temp];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ function hook_node_grants_alter(&$grants, \Drupal\Core\Session\AccountInterface
|
|||
// Now check the roles for this account against the restrictions.
|
||||
foreach ($account->getRoles() as $rid) {
|
||||
if (in_array($rid, $restricted)) {
|
||||
$grants = array();
|
||||
$grants = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -374,8 +374,8 @@ function hook_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Se
|
|||
* @ingroup entity_crud
|
||||
*/
|
||||
function hook_node_search_result(\Drupal\node\NodeInterface $node) {
|
||||
$rating = db_query('SELECT SUM(points) FROM {my_rating} WHERE nid = :nid', array('nid' => $node->id()))->fetchField();
|
||||
return array('rating' => \Drupal::translation()->formatPlural($rating, '1 point', '@count points'));
|
||||
$rating = db_query('SELECT SUM(points) FROM {my_rating} WHERE nid = :nid', ['nid' => $node->id()])->fetchField();
|
||||
return ['rating' => \Drupal::translation()->formatPlural($rating, '1 point', '@count points')];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -394,7 +394,7 @@ function hook_node_search_result(\Drupal\node\NodeInterface $node) {
|
|||
*/
|
||||
function hook_node_update_index(\Drupal\node\NodeInterface $node) {
|
||||
$text = '';
|
||||
$ratings = db_query('SELECT title, description FROM {my_ratings} WHERE nid = :nid', array(':nid' => $node->id()));
|
||||
$ratings = db_query('SELECT title, description FROM {my_ratings} WHERE nid = :nid', [':nid' => $node->id()]);
|
||||
foreach ($ratings as $rating) {
|
||||
$text .= '<h2>' . Html::escape($rating->title) . '</h2>' . Xss::filter($rating->description);
|
||||
}
|
||||
|
@ -447,24 +447,24 @@ function hook_node_update_index(\Drupal\node\NodeInterface $node) {
|
|||
function hook_ranking() {
|
||||
// If voting is disabled, we can avoid returning the array, no hard feelings.
|
||||
if (\Drupal::config('vote.settings')->get('node_enabled')) {
|
||||
return array(
|
||||
'vote_average' => array(
|
||||
return [
|
||||
'vote_average' => [
|
||||
'title' => t('Average vote'),
|
||||
// Note that we use i.sid, the search index's search item id, rather than
|
||||
// n.nid.
|
||||
'join' => array(
|
||||
'join' => [
|
||||
'type' => 'LEFT',
|
||||
'table' => 'vote_node_data',
|
||||
'alias' => 'vote_node_data',
|
||||
'on' => 'vote_node_data.nid = i.sid',
|
||||
),
|
||||
],
|
||||
// The highest possible score should be 1, and the lowest possible score,
|
||||
// always 0, should be 0.
|
||||
'score' => 'vote_node_data.average / CAST(%f AS DECIMAL)',
|
||||
// Pass in the highest possible voting score as a decimal argument.
|
||||
'arguments' => array(\Drupal::config('vote.settings')->get('score_max')),
|
||||
),
|
||||
);
|
||||
'arguments' => [\Drupal::config('vote.settings')->get('score_max')],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,16 +486,16 @@ function hook_ranking() {
|
|||
* @see entity_crud
|
||||
*/
|
||||
function hook_node_links_alter(array &$links, NodeInterface $entity, array &$context) {
|
||||
$links['mymodule'] = array(
|
||||
$links['mymodule'] = [
|
||||
'#theme' => 'links__node__mymodule',
|
||||
'#attributes' => array('class' => array('links', 'inline')),
|
||||
'#links' => array(
|
||||
'node-report' => array(
|
||||
'#attributes' => ['class' => ['links', 'inline']],
|
||||
'#links' => [
|
||||
'node-report' => [
|
||||
'title' => t('Report'),
|
||||
'url' => Url::fromRoute('node_test.report', ['node' => $entity->id()], ['query' => ['token' => \Drupal::getContainer()->get('csrf_token')->get("node/{$entity->id()}/report")]]),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Reference in a new issue