Skip to content
Snippets Groups Projects
Commit 5a3f0fcc authored by Steven Ayers's avatar Steven Ayers
Browse files

Issue #3263328: The service "quick_node_clone.node_finder" has a dependency on...

Issue #3263328: The service "quick_node_clone.node_finder" has a dependency on a non-existent service "path_alias.manager"
parent 5c4898ca
No related branches found
No related tags found
1 merge request!40Issue #3263328 by bluegeek9: The service "quick_node_clone.node_finder" has a...
Pipeline #394856 passed with warnings
......@@ -23,5 +23,5 @@ services:
class: Drupal\quick_node_clone\QuickNodeCloneNodeFinder
arguments:
- '@request_stack'
- '@path_alias.manager'
- '@entity_type.manager'
- '@?path_alias.manager'
......@@ -3,8 +3,7 @@
namespace Drupal\quick_node_clone;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\path_alias\AliasManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\path_alias\AliasManagerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
/**
......@@ -22,7 +21,7 @@ class QuickNodeCloneNodeFinder {
/**
* Path Alias Manager.
*
* @var \Drupal\Core\Path\AliasManager
* @var \Drupal\path_alias\AliasManagerInterface
*/
protected $aliasManager;
/**
......@@ -32,28 +31,17 @@ class QuickNodeCloneNodeFinder {
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('request_stack'),
$container->get('path_alias.manager'),
$container->get('entity_type.manager')
);
}
/**
* QuickNodeCloneNodeFinder constructor.
*
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
* Request stack.
* @param \Drupal\Core\Path\AliasManager $aliasManager
* Alias manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param \Drupal\path_alias\AliasManagerInterface $aliasManager
* Alias manager.
*/
public function __construct(RequestStack $requestStack, AliasManager $aliasManager, EntityTypeManagerInterface $entityTypeManager) {
public function __construct(RequestStack $requestStack, EntityTypeManagerInterface $entityTypeManager, ?AliasManagerInterface $aliasManager) {
$this->requestStack = $requestStack;
$this->aliasManager = $aliasManager;
$this->entityTypeManager = $entityTypeManager;
......@@ -97,18 +85,20 @@ class QuickNodeCloneNodeFinder {
$i = 0;
foreach ($parts as $part) {
if (!empty($part)) {
$i++;
$i += 1;
}
if ($part == $type) {
break;
}
}
$i++;
// Get entity path if alias.
$entity_path = $this->aliasManager->getPathByAlias($path);
$i += 1;
if ($this->aliasManager) {
// Get entity path if alias.
$path = $this->aliasManager->getPathByAlias($path);
}
// Look! We're using arg() in Drupal 8 because we have to.
$args = explode('/', $entity_path);
$args = explode('/', $path);
if (isset($args[$i])) {
$entity = $this->entityTypeManager->getStorage($type)->load($args[$i]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment