Commit e12261d0 authored by webchick's avatar webchick

Issue #2067345 by Xano, jdillick, InternetDevels, bomoko | Berdir: Change...

Issue #2067345 by Xano, jdillick, InternetDevels, bomoko | Berdir: Change EntityInterface type hints to NodeInterface where appropriate.
parent 836d08a7
......@@ -88,10 +88,11 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account =
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $node, $operation, $langcode, AccountInterface $account) {
// Fetch information from the node object if possible.
$status = $node->getTranslation($langcode)->isPublished();
/** @var \Drupal\node\NodeInterface $node */
/** @var \Drupal\node\NodeInterface $translation */
$translation = $node->getTranslation($langcode);
// Fetch information from the node object if possible.
$status = $translation->isPublished();
$uid = $translation->getOwnerId();
// Check if authors can view their own unpublished nodes.
......
......@@ -39,7 +39,7 @@ public function acquireGrants(NodeInterface $node);
* Note: Don't call this function directly from a contributed module. Call
* node_access_acquire_grants() instead.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node whose grants are being written.
* @param $grants
* A list of grants to write. See hook_node_access_records() for the
......
......@@ -9,7 +9,6 @@
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Session\AccountInterface;
......@@ -53,7 +52,7 @@ public function __construct(Connection $database, ModuleHandlerInterface $module
/**
* {@inheritdoc}
*/
public function access(EntityInterface $node, $operation, $langcode, AccountInterface $account) {
public function access(NodeInterface $node, $operation, $langcode, AccountInterface $account) {
// If no module implements the hook or the node does not have an id there is
// no point in querying the database for access grants.
if (!$this->moduleHandler->getImplementations('node_grants') || !$node->id()) {
......
......@@ -7,7 +7,6 @@
namespace Drupal\node;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
/**
......@@ -96,7 +95,7 @@ public function writeDefault();
/**
* Determines access to nodes based on node grants.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The entity for which to check 'create' access.
* @param string $operation
* The entity operation. Usually one of 'view', 'edit', 'create' or
......@@ -111,7 +110,7 @@ public function writeDefault();
* module implements hook_node_grants(), the node does not (yet) have an id
* or none of the implementing modules explicitly granted or denied access.
*/
public function access(EntityInterface $node, $operation, $langcode, AccountInterface $account);
public function access(NodeInterface $node, $operation, $langcode, AccountInterface $account);
/**
* Counts available node grants.
......
......@@ -10,7 +10,6 @@
use Drupal\Core\Config\Config;
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Query\SelectExtender;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\KeyValueStore\StateInterface;
......@@ -18,6 +17,7 @@
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessibleInterface;
use Drupal\Core\Database\Query\Condition;
use Drupal\node\NodeInterface;
use Drupal\search\Plugin\ConfigurableSearchPluginBase;
use Drupal\search\Plugin\SearchIndexingInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -316,10 +316,10 @@ public function updateIndex() {
/**
* Indexes a single node.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node to index.
*/
protected function indexNode(EntityInterface $node) {
protected function indexNode(NodeInterface $node) {
// Save the changed time of the most recent indexed node, for the search
// results half-life calculation.
$this->state->set('node.cron_last', $node->getChangedTime());
......
<?php
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Entity\NodeInterface;
use Drupal\node\NodeInterface;
use Drupal\Component\Utility\String;
use Drupal\Component\Utility\Xss;
......@@ -245,7 +244,7 @@ function hook_node_grants($account, $op) {
* Also note that a deny all is not written to the database; denies are
* implicit.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node that has just been saved.
*
* @return
......@@ -309,7 +308,7 @@ function hook_node_access_records(\Drupal\node\NodeInterface $node) {
*
* @param $grants
* The $grants array returned by hook_node_access_records().
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node for which the grants were acquired.
*
* The preferred use of this hook is in a module that bridges multiple node
......@@ -321,7 +320,7 @@ function hook_node_access_records(\Drupal\node\NodeInterface $node) {
* @see hook_node_grants_alter()
* @ingroup node_access
*/
function hook_node_access_records_alter(&$grants, Drupal\Core\Entity\EntityInterface $node) {
function hook_node_access_records_alter(&$grants, Drupal\node\NodeInterface $node) {
// Our module allows editors to mark specific articles with the 'is_preview'
// field. If the node being saved has a TRUE value for that field, then only
// our grants are retained, and other grants are removed. Doing so ensures
......@@ -392,14 +391,14 @@ function hook_node_grants_alter(&$grants, $account, $op) {
* hook_entity_predelete() is called and field values are deleted, and before
* the node is removed from the node table in the database.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node that is about to be deleted.
*
* @see hook_node_predelete()
* @see entity_delete_multiple()
* @ingroup node_api_hooks
*/
function hook_node_predelete(\Drupal\Core\Entity\EntityInterface $node) {
function hook_node_predelete(\Drupal\node\NodeInterface $node) {
db_delete('mytable')
->condition('nid', $node->id())
->execute();
......@@ -411,14 +410,14 @@ function hook_node_predelete(\Drupal\Core\Entity\EntityInterface $node) {
* This hook is invoked from entity_delete_multiple() after field values are
* deleted and after the node has been removed from the database.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node that has been deleted.
*
* @see hook_node_predelete()
* @see entity_delete_multiple()
* @ingroup node_api_hooks
*/
function hook_node_delete(\Drupal\Core\Entity\EntityInterface $node) {
function hook_node_delete(\Drupal\node\NodeInterface $node) {
drupal_set_message(t('Node: @title has been deleted', array('@title' => $node->label())));
}
......@@ -428,12 +427,12 @@ function hook_node_delete(\Drupal\Core\Entity\EntityInterface $node) {
* This hook is invoked from node_revision_delete() after the revision has been
* removed from the node_revision table, and before field values are deleted.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node revision (node object) that is being deleted.
*
* @ingroup node_api_hooks
*/
function hook_node_revision_delete(\Drupal\Core\Entity\EntityInterface $node) {
function hook_node_revision_delete(\Drupal\node\NodeInterface $node) {
db_delete('mytable')
->condition('vid', $node->getRevisionId())
->execute();
......@@ -454,12 +453,12 @@ function hook_node_revision_delete(\Drupal\Core\Entity\EntityInterface $node) {
* write/update database queries executed from this hook are also not committed
* immediately. Check $node->save() and db_transaction() for more info.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node that is being created.
*
* @ingroup node_api_hooks
*/
function hook_node_insert(\Drupal\Core\Entity\EntityInterface $node) {
function hook_node_insert(\Drupal\node\NodeInterface $node) {
db_insert('mytable')
->fields(array(
'nid' => $node->id(),
......@@ -474,12 +473,12 @@ function hook_node_insert(\Drupal\Core\Entity\EntityInterface $node) {
* This hook runs after a new node object has just been instantiated. It can be
* used to set initial values, e.g. to provide defaults.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node object.
*
* @ingroup node_api_hooks
*/
function hook_node_create(\Drupal\Core\Entity\EntityInterface $node) {
function hook_node_create(\Drupal\node\NodeInterface $node) {
if (!isset($node->foo)) {
$node->foo = 'some_initial_value';
}
......@@ -546,7 +545,7 @@ function hook_node_load($nodes) {
* the default home page at path 'node', a recent content block, etc.) See
* @link node_access Node access rights @endlink for a full explanation.
*
* @param \Drupal\Core\Entity\EntityInterface|string $node
* @param \Drupal\node\NodeInterface|string $node
* Either a node entity or the machine name of the content type on which to
* perform the access check.
* @param string $op
......@@ -622,7 +621,7 @@ function hook_node_prepare_form(\Drupal\node\NodeInterface $node, $form_display,
* This hook is invoked from the node search plugin during search execution,
* after loading and rendering the node.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node being displayed in a search result.
* @param $langcode
* Language code of result being displayed.
......@@ -638,7 +637,7 @@ function hook_node_prepare_form(\Drupal\node\NodeInterface $node, $form_display,
*
* @ingroup node_api_hooks
*/
function hook_node_search_result(\Drupal\Core\Entity\EntityInterface $node, $langcode) {
function hook_node_search_result(\Drupal\node\NodeInterface $node, $langcode) {
$rating = db_query('SELECT SUM(points) FROM {my_rating} WHERE nid = :nid', array('nid' => $node->id()))->fetchField();
return array('rating' => format_plural($rating, '1 point', '@count points'));
}
......@@ -649,12 +648,12 @@ function hook_node_search_result(\Drupal\Core\Entity\EntityInterface $node, $lan
* This hook is invoked from $node->save() before the node is saved to the
* database.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node that is being inserted or updated.
*
* @ingroup node_api_hooks
*/
function hook_node_presave(\Drupal\Core\Entity\EntityInterface $node) {
function hook_node_presave(\Drupal\node\NodeInterface $node) {
if ($node->id() && $node->moderate) {
// Reset votes when node is updated:
$node->score = 0;
......@@ -678,12 +677,12 @@ function hook_node_presave(\Drupal\Core\Entity\EntityInterface $node) {
* write/update database queries executed from this hook are also not committed
* immediately. Check $node->save() and db_transaction() for more info.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node that is being updated.
*
* @ingroup node_api_hooks
*/
function hook_node_update(\Drupal\Core\Entity\EntityInterface $node) {
function hook_node_update(\Drupal\node\NodeInterface $node) {
db_update('mytable')
->fields(array('extra' => $node->extra))
->condition('nid', $node->id())
......@@ -696,7 +695,7 @@ function hook_node_update(\Drupal\Core\Entity\EntityInterface $node) {
* This hook is invoked during search indexing, after loading, and after the
* result of rendering is added as $node->rendered to the node object.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node being indexed.
* @param $langcode
* Language code of the variant of the node being indexed.
......@@ -706,7 +705,7 @@ function hook_node_update(\Drupal\Core\Entity\EntityInterface $node) {
*
* @ingroup node_api_hooks
*/
function hook_node_update_index(\Drupal\Core\Entity\EntityInterface $node, $langcode) {
function hook_node_update_index(\Drupal\node\NodeInterface $node, $langcode) {
$text = '';
$ratings = db_query('SELECT title, description FROM {my_ratings} WHERE nid = :nid', array(':nid' => $node->id()));
foreach ($ratings as $rating) {
......@@ -729,7 +728,7 @@ function hook_node_update_index(\Drupal\Core\Entity\EntityInterface $node, $lang
* hook_node_presave() instead. If it is really necessary to change the node at
* the validate stage, you can use form_set_value().
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node being validated.
* @param $form
* The form being used to edit the node.
......@@ -738,7 +737,7 @@ function hook_node_update_index(\Drupal\Core\Entity\EntityInterface $node, $lang
*
* @ingroup node_api_hooks
*/
function hook_node_validate(\Drupal\Core\Entity\EntityInterface $node, $form, &$form_state) {
function hook_node_validate(\Drupal\node\NodeInterface $node, $form, &$form_state) {
if (isset($node->end) && isset($node->start)) {
if ($node->start > $node->end) {
form_set_error('time', $form_state, t('An event may not end before it starts.'));
......@@ -757,7 +756,7 @@ function hook_node_validate(\Drupal\Core\Entity\EntityInterface $node, $form, &$
* properties. See hook_field_attach_extract_form_values() for customizing
* field-related properties.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node entity being updated in response to a form submission.
* @param $form
* The form being used to edit the node.
......@@ -766,7 +765,7 @@ function hook_node_validate(\Drupal\Core\Entity\EntityInterface $node, $form, &$
*
* @ingroup node_api_hooks
*/
function hook_node_submit(\Drupal\Core\Entity\EntityInterface $node, $form, &$form_state) {
function hook_node_submit(\Drupal\node\NodeInterface $node, $form, &$form_state) {
// Decompose the selected menu parent option into 'menu_name' and 'plid', if
// the form used the default parent selection widget.
if (!empty($form_state['values']['menu']['parent'])) {
......@@ -786,7 +785,7 @@ function hook_node_submit(\Drupal\Core\Entity\EntityInterface $node, $form, &$fo
* the RSS item generated for this node.
* For details on how this is used, see node_feed().
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node that is being assembled for rendering.
* @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display
* The entity_display object holding the display options configured for the
......@@ -801,7 +800,7 @@ function hook_node_submit(\Drupal\Core\Entity\EntityInterface $node, $form, &$fo
*
* @ingroup node_api_hooks
*/
function hook_node_view(\Drupal\Core\Entity\EntityInterface $node, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode, $langcode) {
function hook_node_view(\Drupal\node\NodeInterface $node, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode, $langcode) {
// Only do the extra work if the component is configured to be displayed.
// This assumes a 'mymodule_addition' extra field has been defined for the
// node type in hook_field_extra_fields().
......@@ -828,7 +827,7 @@ function hook_node_view(\Drupal\Core\Entity\EntityInterface $node, \Drupal\Core\
*
* @param $build
* A renderable array representing the node content.
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node being rendered.
* @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display
* The entity_display object holding the display options configured for the
......@@ -839,7 +838,7 @@ function hook_node_view(\Drupal\Core\Entity\EntityInterface $node, \Drupal\Core\
*
* @ingroup node_api_hooks
*/
function hook_node_view_alter(&$build, \Drupal\Core\Entity\EntityInterface $node, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display) {
function hook_node_view_alter(&$build, \Drupal\node\NodeInterface $node, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display) {
if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
// Change its weight.
$build['an_additional_field']['#weight'] = -10;
......
......@@ -10,12 +10,12 @@
use Drupal\Component\Utility\String;
use Drupal\Core\Language\Language;
use Drupal\node\NodeInterface;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\node\NodeTypeInterface;
use Drupal\node\NodeInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
......@@ -218,13 +218,13 @@ function node_entity_form_display_alter(EntityFormDisplayInterface $form_display
/**
* Entity URI callback.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* A node entity.
*
* @return array
* An array with 'path' as the key and the path to the node as its value.
*/
function node_uri(EntityInterface $node) {
function node_uri(NodeInterface $node) {
return array(
'route_name' => 'node.view',
'route_parameters' => array(
......@@ -356,7 +356,7 @@ function node_type_get_names() {
/**
* Returns the node type label for the passed node.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* A node entity to return the node type's label for.
*
* @return string|false
......@@ -365,7 +365,7 @@ function node_type_get_names() {
* @todo Add this as generic helper method for config entities representing
* entity bundles.
*/
function node_get_type_label(EntityInterface $node) {
function node_get_type_label(NodeInterface $node) {
$type = entity_load('node_type', $node->bundle());
return $type ? $type->label() : FALSE;
}
......@@ -574,13 +574,13 @@ function node_revision_delete($revision_id) {
/**
* Checks whether the current page is the full page view of the passed-in node.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* A node entity.
*
* @return
* The ID of the node if this is a full page view, otherwise FALSE.
*/
function node_is_page(EntityInterface $node) {
function node_is_page(NodeInterface $node) {
$page_node = menu_get_object();
return (!empty($page_node) ? $page_node->id() == $node->id() : FALSE);
}
......@@ -905,7 +905,7 @@ function theme_node_search_admin($variables) {
/**
* Access callback: Checks node revision access.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node to check.
* @param $op
* (optional) The specific operation being checked. Defaults to 'view.'
......@@ -923,7 +923,7 @@ function theme_node_search_admin($variables) {
*
* @see node_menu()
*/
function _node_revision_access(EntityInterface $node, $op = 'view', $account = NULL, $langcode = NULL) {
function _node_revision_access(NodeInterface $node, $op = 'view', $account = NULL, $langcode = NULL) {
if ($account === NULL) {
$account = \Drupal::currentUser();
}
......@@ -1022,7 +1022,7 @@ function node_menu_local_tasks(&$data, $route_name) {
/**
* Title callback: Displays the node's title.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node entity.
*
* @return
......@@ -1030,7 +1030,7 @@ function node_menu_local_tasks(&$data, $route_name) {
*
* @see node_menu()
*/
function node_page_title(EntityInterface $node) {
function node_page_title(NodeInterface $node) {
return $node->label();
}
......@@ -1059,13 +1059,13 @@ function node_last_changed($nid, $langcode = NULL) {
/**
* Returns a list of all the existing revision numbers for the node passed in.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node entity.
*
* @return
* An associative array keyed by node revision number.
*/
function node_revision_list(EntityInterface $node) {
function node_revision_list(NodeInterface $node) {
$revisions = array();
$result = db_query('SELECT nr.vid, nfr.title, nr.log, nr.revision_uid AS uid, n.vid AS current_vid, nr.revision_timestamp, u.name FROM {node_field_revision} nfr JOIN {node_revision} nr ON nr.vid = nfr.vid LEFT JOIN {node} n ON n.vid = nfr.vid INNER JOIN {users} u ON u.uid = nr.revision_uid WHERE nfr.nid = :nid AND nfr.default_langcode = 1 ORDER BY nfr.vid DESC', array(':nid' => $node->id()));
foreach ($result as $revision) {
......@@ -1282,7 +1282,7 @@ function node_feed($nids = FALSE, $channel = array()) {
/**
* Generates an array for rendering the given node.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* A node entity.
* @param $view_mode
* (optional) View mode, e.g., 'full', 'teaser'... Defaults to 'full.'
......@@ -1293,7 +1293,7 @@ function node_feed($nids = FALSE, $channel = array()) {
* @return
* An array as expected by drupal_render().
*/
function node_view(EntityInterface $node, $view_mode = 'full', $langcode = NULL) {
function node_view(NodeInterface $node, $view_mode = 'full', $langcode = NULL) {
return entity_view($node, $view_mode, $langcode);
}
......
......@@ -9,7 +9,6 @@
* @see node_menu()
*/
use Drupal\Core\Entity\EntityInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\node\NodeInterface;
......@@ -44,7 +43,7 @@ function theme_node_add_list($variables) {
/**
* Generates a node preview.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* @param \Drupal\node\NodeInterface $node
* The node to preview.
*
* @return
......
......@@ -9,7 +9,6 @@
* a special 'node test view' permission.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Field\FieldDefinition;
use Drupal\node\NodeInterface;
......@@ -121,28 +120,28 @@ function node_access_test_node_load($nodes) {
* Implements hook_node_predelete().
*/
function node_access_test_node_predelete(EntityInterface $node) {
function node_access_test_node_predelete(NodeInterface $node) {
db_delete('node_access_test')->condition('nid', $node->id())->execute();
}
/**
* Implements hook_node_insert().
*/
function node_access_test_node_insert(EntityInterface $node) {
function node_access_test_node_insert(NodeInterface $node) {
_node_access_test_node_write($node);
}
/**
* Implements hook_nodeapi_update().
*/
function node_access_test_node_update(EntityInterface $node) {
function node_access_test_node_update(NodeInterface $node) {
_node_access_test_node_write($node);
}
/**
* Helper for node insert/update.
*/
function _node_access_test_node_write(EntityInterface $node) {
function _node_access_test_node_write(NodeInterface $node) {
db_merge('node_access_test')
->key(array('nid' => $node->id()))
->fields(array('private' => (int) $node->private->value))
......
......@@ -8,7 +8,7 @@
* of the node to be marked as private (viewable only by administrators).
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\NodeInterface;
/**
* Implements hook_node_grants().
......@@ -23,7 +23,7 @@ function node_access_test_language_node_grants($account, $op) {
/**
* Implements hook_node_access_records().
*/
function node_access_test_language_node_access_records(EntityInterface $node) {
function node_access_test_language_node_access_records(NodeInterface $node) {
$grants = array();
// Create grants for each translation of the node.
......
......@@ -8,14 +8,13 @@
* interaction with the Node module.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\node\NodeInterface;
/**
* Implements hook_node_view().
*/
function node_test_node_view(EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
function node_test_node_view(NodeInterface $node, EntityViewDisplayInterface $display, $view_mode) {
if ($view_mode == 'rss') {
// Add RSS elements and namespaces when building the RSS feed.
$node->rss_elements[] = array(
......@@ -56,7 +55,7 @@ function node_test_node_grants($account, $op) {
/**
* Implements hook_node_access_records().
*/
function node_test_node_access_records(EntityInterface $node) {
function node_test_node_access_records(NodeInterface $node) {
// Return nothing when testing for empty responses.
if (!empty($node->disable_node_access)) {
return;
......@@ -113,7 +112,7 @@ function node_test_node_grants_alter(&$grants, $account, $op) {
/**
* Implements hook_node_presave().
*/
function node_test_node_presave(EntityInterface $node) {
function node_test_node_presave(NodeInterface $node) {
if ($node->getTitle() == 'testing_node_presave') {
// Sun, 19 Nov 1978 05:00:00 GMT
$node->setCreatedTime(280299600);
......@@ -131,7 +130,7 @@ function node_test_node_presave(EntityInterface $node) {
/**
* Implements hook_node_update().
*/
function node_test_node_update(EntityInterface $node) {
function node_test_node_update(NodeInterface $node) {
// Determine changes on update.
if (!empty($node->original) && $node->original->getTitle() == 'test_changes') {
if ($node->original->getTitle() != $node->getTitle()) {
......@@ -158,7 +157,7 @@ function node_test_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\Entity
*
* @see \Drupal\node\Tests\NodeSaveTest::testNodeSaveOnInsert()
*/
function node_test_node_insert(EntityInterface $node) {
function node_test_node_insert(NodeInterface $node) {
// Set the node title to the node ID and save.
if ($node->getTitle() == 'new') {
$node->setTitle('Node '. $node->id());
......
......@@ -5,12 +5,12 @@
* A module implementing node related hooks to test API interaction.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\NodeInterface;
/**
* Implements hook_node_insert().
*/
function node_test_exception_node_insert(EntityInterface $node) {
function node_test_exception_node_insert(NodeInterface $node) {
if ($node->getTitle() == 'testing_transaction_exception') {
throw new Exception('Test exception for rollback.');
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment