Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
prevnext-3433980
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
prevnext-3433980
Commits
3d57b15e
Commit
3d57b15e
authored
1 year ago
by
Viktor Holovachek
Committed by
Adriano Cori
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3398333
by AstonVictor: Replace Node with NodeInterface
3398333 - Fix Node class
parent
161d8129
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
prevnext.module
+3
-3
3 additions, 3 deletions
prevnext.module
src/PrevNextService.php
+3
-4
3 additions, 4 deletions
src/PrevNextService.php
src/PrevNextServiceInterface.php
+3
-3
3 additions, 3 deletions
src/PrevNextServiceInterface.php
with
9 additions
and
10 deletions
prevnext.module
+
3
−
3
View file @
3d57b15e
...
@@ -10,7 +10,7 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
...
@@ -10,7 +10,7 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Core\Routing\RouteMatchInterface
;
use
Drupal\Core\Routing\RouteMatchInterface
;
use
Drupal\Core\Url
;
use
Drupal\Core\Url
;
use
Drupal\node\
Entity\Nod
e
;
use
Drupal\node\
NodeInterfac
e
;
/**
/**
* Implements hook_help().
* Implements hook_help().
...
@@ -79,7 +79,7 @@ function prevnext_entity_extra_field_info() {
...
@@ -79,7 +79,7 @@ function prevnext_entity_extra_field_info() {
/**
/**
* Implements hook_ENTITY_TYPE_view().
* Implements hook_ENTITY_TYPE_view().
*/
*/
function
prevnext_node_view
(
array
&
$build
,
Node
$node
,
EntityViewDisplayInterface
$display
,
$view_mode
)
{
function
prevnext_node_view
(
array
&
$build
,
Node
Interface
$node
,
EntityViewDisplayInterface
$display
,
$view_mode
)
{
// Checking if current node is configured for prevnext or not.
// Checking if current node is configured for prevnext or not.
$config
=
\Drupal
::
config
(
'prevnext.settings'
);
$config
=
\Drupal
::
config
(
'prevnext.settings'
);
...
@@ -137,7 +137,7 @@ function prevnext_node_view(array &$build, Node $node, EntityViewDisplayInterfac
...
@@ -137,7 +137,7 @@ function prevnext_node_view(array &$build, Node $node, EntityViewDisplayInterfac
/**
/**
* Implements hook_ENTITY_TYPE_presave().
* Implements hook_ENTITY_TYPE_presave().
*/
*/
function
prevnext_node_presave
(
Entity
Interface
$entity
)
{
function
prevnext_node_presave
(
Node
Interface
$entity
)
{
$config
=
\Drupal
::
config
(
'prevnext.settings'
);
$config
=
\Drupal
::
config
(
'prevnext.settings'
);
$enabled_nodetypes
=
$config
->
get
(
'prevnext_enabled_nodetypes'
);
$enabled_nodetypes
=
$config
->
get
(
'prevnext_enabled_nodetypes'
);
if
(
is_array
(
$enabled_nodetypes
)
&&
in_array
(
$entity
->
bundle
(),
$enabled_nodetypes
))
{
if
(
is_array
(
$enabled_nodetypes
)
&&
in_array
(
$entity
->
bundle
(),
$enabled_nodetypes
))
{
...
...
This diff is collapsed.
Click to expand it.
src/PrevNextService.php
+
3
−
4
View file @
3d57b15e
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
namespace
Drupal\prevnext
;
namespace
Drupal\prevnext
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\node\Entity\Node
;
use
Drupal\node\NodeInterface
;
use
Drupal\node\NodeInterface
;
/**
/**
...
@@ -40,7 +39,7 @@ class PrevNextService implements PrevNextServiceInterface {
...
@@ -40,7 +39,7 @@ class PrevNextService implements PrevNextServiceInterface {
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
getPreviousNext
(
Node
$node
)
{
public
function
getPreviousNext
(
Node
Interface
$node
)
{
$nodes
=
$this
->
getNodesOfType
(
$node
);
$nodes
=
$this
->
getNodesOfType
(
$node
);
$current_nid
=
$node
->
id
();
$current_nid
=
$node
->
id
();
...
@@ -54,13 +53,13 @@ class PrevNextService implements PrevNextServiceInterface {
...
@@ -54,13 +53,13 @@ class PrevNextService implements PrevNextServiceInterface {
/**
/**
* Retrieves all nodes of the same type and language of given.
* Retrieves all nodes of the same type and language of given.
*
*
* @param \Drupal\node\
Entity\Nod
e $node
* @param \Drupal\node\
NodeInterfac
e $node
* The node entity.
* The node entity.
*
*
* @return array
* @return array
* An array of nodes filtered by type, status and language.
* An array of nodes filtered by type, status and language.
*/
*/
protected
function
getNodesOfType
(
Node
$node
)
{
protected
function
getNodesOfType
(
Node
Interface
$node
)
{
$query
=
$this
->
entityTypeManager
->
getStorage
(
'node'
)
->
getQuery
();
$query
=
$this
->
entityTypeManager
->
getStorage
(
'node'
)
->
getQuery
();
$bundle
=
$node
->
bundle
();
$bundle
=
$node
->
bundle
();
$langcode
=
$node
->
language
()
->
getId
();
$langcode
=
$node
->
language
()
->
getId
();
...
...
This diff is collapsed.
Click to expand it.
src/PrevNextServiceInterface.php
+
3
−
3
View file @
3d57b15e
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
namespace
Drupal\prevnext
;
namespace
Drupal\prevnext
;
use
Drupal\node\
Entity\Nod
e
;
use
Drupal\node\
NodeInterfac
e
;
/**
/**
* Interface for the main service file.
* Interface for the main service file.
...
@@ -14,12 +14,12 @@ interface PrevNextServiceInterface {
...
@@ -14,12 +14,12 @@ interface PrevNextServiceInterface {
/**
/**
* Retrieves previous and next nids of a given node, if they exist.
* Retrieves previous and next nids of a given node, if they exist.
*
*
* @param \Drupal\node\
Entity\Nod
e $node
* @param \Drupal\node\
NodeInterfac
e $node
* The node entity.
* The node entity.
*
*
* @return array
* @return array
* An array of prev/next nids of given node.
* An array of prev/next nids of given node.
*/
*/
public
function
getPreviousNext
(
Node
$node
);
public
function
getPreviousNext
(
Node
Interface
$node
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment