Skip to content

Commit

Permalink
Issues #4 and #19: Replaced all references to custom node with core's.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambient-Impact committed Sep 26, 2023
1 parent d38b790 commit a777138
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 100 deletions.
2 changes: 1 addition & 1 deletion src/Cache/Context/WikiNodeCacheContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getContext($parameter = null) {
// If there's a 'node' route parameter, attempt to resolve it to a wiki
// node. Note that the 'node' parameter is not upcast into a Node object if
// viewing a (Drupal) revision other than the currently published one.
/** @var \Drupal\omnipedia_core\Entity\NodeInterface|null */
/** @var \Drupal\node\NodeInterface|null */
$node = $this->wikiNodeResolver->resolveNode(
$this->currentRouteMatch->getParameter('node')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function onKernelResponse(ResponseEvent $event): void {
// If there's a 'node' route parameter, attempt to resolve it to a wiki
// node. Note that the 'node' parameter is not upcast into a Node object if
// viewing a (Drupal) revision other than the currently published one.
/** @var \Drupal\omnipedia_core\Entity\NodeInterface|null */
/** @var \Drupal\node\NodeInterface|null */
$node = $this->wikiNodeResolver->resolveNode(
$this->currentRouteMatch->getParameter('node')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function onMenuLocalTaskAlter(MenuLocalTasksAlterEvent $event): void {
// If there's a 'node' route parameter, attempt to resolve it to a wiki
// node. Note that the 'node' parameter is not upcast into a Node object if
// viewing a (Drupal) revision other than the currently published one.
/** @var \Drupal\omnipedia_core\Entity\NodeInterface|null */
/** @var \Drupal\node\NodeInterface|null */
$node = $this->wikiNodeResolver->resolveWikiNode(
$this->currentRouteMatch->getParameter('node'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function onAccessDeniedToNotFound(
// If there's a 'node' route parameter, attempt to resolve it to a wiki
// node. Note that the 'node' parameter is not upcast into a Node object if
// viewing a (Drupal) revision other than the currently published one.
/** @var \Drupal\omnipedia_core\Entity\NodeInterface|null */
/** @var \Drupal\node\NodeInterface|null */
$node = $this->wikiNodeResolver->resolveWikiNode(
$this->currentRouteMatch->getParameter('node'),
);
Expand Down
10 changes: 5 additions & 5 deletions src/Service/WikiNodeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Drupal\omnipedia_core\Service;

use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\omnipedia_core\Entity\NodeInterface;
use Drupal\node\NodeInterface;
use Drupal\omnipedia_core\Entity\WikiNodeInfo;
use Drupal\omnipedia_core\Service\WikiNodeResolverInterface;
use Drupal\omnipedia_core\Service\WikiNodeTrackerInterface;
Expand Down Expand Up @@ -37,7 +37,7 @@ public function resolveNode(mixed $node): ?NodeInterface {
return $node;

} else if (\is_numeric($node)) {
/** @var \Drupal\omnipedia_core\Entity\NodeInterface|null */
/** @var \Drupal\node\NodeInterface|null */
return $this->entityTypeManager->getStorage('node')->load($node);

} else {
Expand All @@ -56,7 +56,7 @@ public function nodeOrTitleToNids(
$title = $nodeOrTitle;

} else {
/** @var \Drupal\omnipedia_core\Entity\NodeInterface|null */
/** @var \Drupal\node\NodeInterface|null */
$node = $this->resolveNode($nodeOrTitle);

if ($node instanceof NodeInterface) {
Expand All @@ -80,7 +80,7 @@ public function nodeOrTitleToNids(
* {@inheritdoc}
*/
public function isWikiNode(mixed $node): bool {
/** @var \Drupal\omnipedia_core\Entity\NodeInterface|null */
/** @var \Drupal\node\NodeInterface|null */
$node = $this->resolveNode($node);

if (\is_object($node) && $node instanceof NodeInterface) {
Expand All @@ -94,7 +94,7 @@ public function isWikiNode(mixed $node): bool {
* {@inheritdoc}
*/
public function resolveWikiNode(mixed $node): ?NodeInterface {
/** @var \Drupal\omnipedia_core\Entity\NodeInterface|null */
/** @var \Drupal\node\NodeInterface|null */
$node = $this->resolveNode($node);

if ($this->isWikiNode($node)) {
Expand Down
10 changes: 5 additions & 5 deletions src/Service/WikiNodeResolverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Drupal\omnipedia_core\Service;

use Drupal\omnipedia_core\Entity\NodeInterface;
use Drupal\node\NodeInterface;

/**
* The Omnipedia wiki node resolver service interface.
Expand All @@ -18,18 +18,18 @@ interface WikiNodeResolverInterface {
* A node entity object or a numeric value (integer or string) that equates
* to an existing node ID (nid) to load. Any other value will return null.
*
* @return \Drupal\omnipedia_core\Entity\NodeInterface|null
* @return \Drupal\node\NodeInterface|null
* Either a node object, or null if one cannot be loaded.
*/
public function resolveNode(mixed $node): ?NodeInterface;

/**
* Resolve a node or title to all nids with the same title.
*
* @param \Drupal\omnipedia_core\Entity\NodeInterface|int|string $nodeOrTitle
* @param \Drupal\node\NodeInterface|int|string $nodeOrTitle
* Must be one of the following:
*
* - An instance of \Drupal\omnipedia_core\Entity\NodeInterface, i.e. a node
* - An instance of \Drupal\node\NodeInterface, i.e. a node
* object.
*
* - An integer or a numeric string that equates to an nid.
Expand Down Expand Up @@ -63,7 +63,7 @@ public function isWikiNode(mixed $node): bool;
* A node entity object or a numeric value (integer or string) that equates
* to an existing node ID (nid) to load. Any other value will return null.
*
* @return \Drupal\omnipedia_core\Entity\NodeInterface|null
* @return \Drupal\node\NodeInterface|null
* Returns the node object if $node is a wiki node; if $node is a node but
* not a wiki node, returns null; if $node is a numeric value that doesn't
* equate to a wiki node's ID, returns null.
Expand Down
2 changes: 1 addition & 1 deletion src/Service/WikiNodeRevision.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Drupal\omnipedia_core\Service;

use Drupal\omnipedia_core\Entity\NodeInterface;
use Drupal\node\NodeInterface;
use Drupal\omnipedia_core\Service\WikiNodeResolverInterface;
use Drupal\omnipedia_core\Service\WikiNodeRevisionInterface;
use Drupal\omnipedia_core\Service\WikiNodeTrackerInterface;
Expand Down
18 changes: 9 additions & 9 deletions src/Service/WikiNodeRevisionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Drupal\omnipedia_core\Service;

use Drupal\omnipedia_core\Entity\NodeInterface;
use Drupal\node\NodeInterface;

/**
* The Omnipedia wiki node revision service interface.
Expand All @@ -19,10 +19,10 @@ interface WikiNodeRevisionInterface {
* have access to. For an example of how to accomplish this, see
* \Drupal\omnipedia_block\Plugin\Block\PageRevisionHistory::build().
*
* @param \Drupal\omnipedia_core\Entity\NodeInterface|int|string $nodeOrTitle
* @param \Drupal\node\NodeInterface|int|string $nodeOrTitle
* Must be one of the following:
*
* - An instance of \Drupal\omnipedia_core\Entity\NodeInterface, i.e. a node
* - An instance of \Drupal\node\NodeInterface, i.e. a node
* object.
*
* - An integer or a numeric string that equates to a node ID (nid).
Expand Down Expand Up @@ -64,10 +64,10 @@ public function getWikiNodeRevisions(
* have access to. For an example of how to accomplish this, see
* \Drupal\omnipedia_block\Plugin\Block\PageRevisionHistory::build().
*
* @param \Drupal\omnipedia_core\Entity\NodeInterface|int|string $nodeOrTitle
* @param \Drupal\node\NodeInterface|int|string $nodeOrTitle
* Must be one of the following:
*
* - An instance of \Drupal\omnipedia_core\Entity\NodeInterface, i.e. a node
* - An instance of \Drupal\node\NodeInterface, i.e. a node
* object.
*
* - An integer or a numeric string that equates to an node ID (nid).
Expand All @@ -77,7 +77,7 @@ public function getWikiNodeRevisions(
* @param string $date
* A date string in the format stored in a wiki node's date field.
*
* @return \Drupal\omnipedia_core\Entity\NodeInterface|null
* @return \Drupal\node\NodeInterface|null
* Returns the node object if $nodeOrTitle can be resolved to a wiki node;
* if $nodeOrTitle cannot be resolved to a wiki node, returns null; if
* $nodeOrTitle is a numeric value that doesn't equate to a wiki node's ID,
Expand All @@ -99,18 +99,18 @@ public function getWikiNodeRevision(
* have access to. For an example of how to accomplish this, see
* \Drupal\omnipedia_block\Plugin\Block\PageRevisionHistory::build().
*
* @param \Drupal\omnipedia_core\Entity\NodeInterface $node
* @param \Drupal\node\NodeInterface $node
* A node object.
*
* @return \Drupal\omnipedia_core\Entity\NodeInterface|null
* @return \Drupal\node\NodeInterface|null
* The node object of the previous revision if it exists or null otherwise.
*/
public function getPreviousRevision(NodeInterface $node): ?NodeInterface;

/**
* Whether a provided wiki node has a previous revision.
*
* @param \Drupal\omnipedia_core\Entity\NodeInterface $node
* @param \Drupal\node\NodeInterface $node
* A node object.
*
* @return boolean
Expand Down
2 changes: 1 addition & 1 deletion src/Service/WikiNodeTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\State\StateInterface;
use Drupal\omnipedia_core\Entity\NodeInterface;
use Drupal\node\NodeInterface;
use Drupal\omnipedia_core\Service\WikiNodeTrackerInterface;
use Drupal\typed_entity\EntityWrapperInterface;

Expand Down
6 changes: 3 additions & 3 deletions src/Service/WikiNodeTrackerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Drupal\omnipedia_core\Service;

use Drupal\omnipedia_core\Entity\NodeInterface;
use Drupal\node\NodeInterface;

/**
* The Omnipedia wiki node tracker service interface.
Expand Down Expand Up @@ -48,7 +48,7 @@ public function getTrackedWikiNodeData(): array;
*
* This should be called when a wiki node is created or updated.
*
* @param \Drupal\omnipedia_core\Entity\NodeInterface $node
* @param \Drupal\node\NodeInterface $node
* A node object.
*
* @see \Drupal\omnipedia_core\Service\WikiNodeTrackerInterface::getTrackedWikiNodeData()
Expand All @@ -68,7 +68,7 @@ public function trackWikiNode(NodeInterface $node): void;
*
* This should be called when a wiki node is deleted.
*
* @param \Drupal\omnipedia_core\Entity\NodeInterface $node
* @param \Drupal\node\NodeInterface $node
* A node object.
*
* @see \Drupal\omnipedia_core\Service\WikiNodeTrackerInterface::getTrackedWikiNodeData()
Expand Down
4 changes: 2 additions & 2 deletions src/Service/WikiNodeViewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Drupal\omnipedia_core\Service;

use Drupal\omnipedia_core\Entity\NodeInterface;
use Drupal\node\NodeInterface;
use Drupal\omnipedia_core\Service\WikiNodeResolverInterface;
use Drupal\omnipedia_core\Service\WikiNodeViewedInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
Expand Down Expand Up @@ -46,7 +46,7 @@ public function __construct(
* {@inheritdoc}
*/
public function addNode(NodeInterface|int|string $node): void {
/** @var \Drupal\omnipedia_core\Entity\NodeInterface|null */
/** @var \Drupal\node\NodeInterface|null */
$node = $this->wikiNodeResolver->resolveWikiNode($node);

// Return if this is not a wiki node.
Expand Down
4 changes: 2 additions & 2 deletions src/Service/WikiNodeViewedInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Drupal\omnipedia_core\Service;

use Drupal\omnipedia_core\Entity\NodeInterface;
use Drupal\node\NodeInterface;

/**
* The Omnipedia wiki node viewed service interface.
Expand All @@ -14,7 +14,7 @@ interface WikiNodeViewedInterface {
/**
* Add a wiki node to a user's recently viewed session.
*
* @param \Drupal\omnipedia_core\Entity\NodeInterface|int|string $node
* @param \Drupal\node\NodeInterface|int|string $node
* Either a node object or a numeric value (integer or string) that equates
* to an existing node ID (nid) to load.
*
Expand Down
6 changes: 3 additions & 3 deletions tests/src/Kernel/WikiNodeKernelTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Drupal\Tests\omnipedia_core\Kernel;

use Drupal\KernelTests\KernelTestBase;
use Drupal\omnipedia_core\Entity\NodeInterface as WikiNodeInterface;
use Drupal\omnipedia_core\Entity\Node as WikiNode;
use Drupal\node\NodeInterface;
use Drupal\omnipedia_core\Entity\WikiNodeInfo;
use Drupal\omnipedia_core\Storage\NodeStorage as WikiNodeStorage;
use Drupal\Tests\node\Traits\NodeCreationTrait;
Expand Down Expand Up @@ -76,14 +76,14 @@ protected function setUp(): void {
* @param string $date
* An optional wiki date.
*
* @return \Drupal\omnipedia_core\Entity\NodeInterface
* @return \Drupal\node\NodeInterface
*
* @see \Drupal\Tests\node\Traits\NodeCreationTrait::createNode()
* We wrap this, setting the node type and date field value.
*/
protected function drupalCreateWikiNode(
array $values, string $date = ''
): WikiNodeInterface {
): NodeInterface {

if (!empty($date)) {
$values[WikiNodeInfo::DATE_FIELD] = $date;
Expand Down
11 changes: 5 additions & 6 deletions tests/src/Kernel/WikiNodeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Drupal\Tests\omnipedia_core\Kernel;

use Drupal\omnipedia_core\Entity\NodeInterface as WikiNodeInterface;
use Drupal\omnipedia_core\Service\WikiNodeResolverInterface;
use Drupal\omnipedia_core\Service\WikiNodeTrackerInterface;
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
Expand Down Expand Up @@ -102,7 +101,7 @@ public function testResolveNodeValid(
string $methodName, array $arguments,
): void {

/** @var \Drupal\omnipedia_core\Entity\NodeInterface */
/** @var \Drupal\node\NodeInterface */
$node = \call_user_func_array([$this, $methodName], $arguments);

$this->assertSame(
Expand Down Expand Up @@ -163,7 +162,7 @@ public function testResolveWikiNodeValid(
string $methodName, array $arguments,
): void {

/** @var \Drupal\omnipedia_core\Entity\NodeInterface */
/** @var \Drupal\node\NodeInterface */
$node = \call_user_func_array([$this, $methodName], $arguments);

// Split asserts based on whether this is a wiki node or a different content
Expand Down Expand Up @@ -222,7 +221,7 @@ public function testIsWikiNodeValid(
string $methodName, array $arguments,
): void {

/** @var \Drupal\omnipedia_core\Entity\NodeInterface */
/** @var \Drupal\node\NodeInterface */
$node = \call_user_func_array([$this, $methodName], $arguments);

/** @var bool True if a wiki node and false otherwise. */
Expand Down Expand Up @@ -315,12 +314,12 @@ public function testNodeOrTitleToNids(
array $nodesInfo, array $queries,
): void {

/** @var \Drupal\omnipedia_core\Entity\NodeInterface[] The created node objects, keyed by their integer node IDs. */
/** @var \Drupal\node\NodeInterface[] The created node objects, keyed by their integer node IDs. */
$nodes = [];

foreach ($nodesInfo as $nodeInfo) {

/** @var \Drupal\omnipedia_core\Entity\NodeInterface */
/** @var \Drupal\node\NodeInterface */
$node = \call_user_func_array(
[$this, $nodeInfo['method']], $nodeInfo['arguments'],
);
Expand Down
Loading

0 comments on commit a777138

Please sign in to comment.