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());
......
This diff is collapsed.
......@@ -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