|
13 | 13 |
|
14 | 14 | namespace Sonata\PageBundle\Entity;
|
15 | 15 |
|
| 16 | +use Cocur\Slugify\SlugifyInterface; |
16 | 17 | use Doctrine\Persistence\ManagerRegistry;
|
17 | 18 | use Sonata\Doctrine\Entity\BaseEntityManager;
|
18 |
| -use Sonata\PageBundle\Model\Page; |
19 | 19 | use Sonata\PageBundle\Model\PageInterface;
|
20 | 20 | use Sonata\PageBundle\Model\PageManagerInterface;
|
21 | 21 | use Sonata\PageBundle\Model\SiteInterface;
|
22 | 22 |
|
23 | 23 | /**
|
24 |
| - * This class manages PageInterface persistency with the Doctrine ORM. |
25 |
| - * |
26 | 24 | * @extends BaseEntityManager<PageInterface>
|
27 | 25 | *
|
28 | 26 | * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
|
29 | 27 | */
|
30 | 28 | final class PageManager extends BaseEntityManager implements PageManagerInterface
|
31 | 29 | {
|
| 30 | + private SlugifyInterface $slugify; |
| 31 | + |
| 32 | + /** |
| 33 | + * @var array<string, mixed> |
| 34 | + */ |
32 | 35 | private array $pageDefaults;
|
33 | 36 |
|
| 37 | + /** |
| 38 | + * @var array<string, mixed> |
| 39 | + */ |
34 | 40 | private array $defaults;
|
35 | 41 |
|
36 | 42 | /**
|
37 |
| - * @param string $class |
| 43 | + * @param array<string, mixed> $defaults |
| 44 | + * @param array<string, mixed> $pageDefaults |
38 | 45 | */
|
39 |
| - public function __construct($class, ManagerRegistry $registry, array $defaults = [], array $pageDefaults = []) |
40 |
| - { |
| 46 | + public function __construct( |
| 47 | + string $class, |
| 48 | + ManagerRegistry $registry, |
| 49 | + SlugifyInterface $slugify, |
| 50 | + array $defaults = [], |
| 51 | + array $pageDefaults = [] |
| 52 | + ) { |
41 | 53 | parent::__construct($class, $registry);
|
42 | 54 |
|
| 55 | + $this->slugify = $slugify; |
43 | 56 | $this->defaults = $defaults;
|
44 | 57 | $this->pageDefaults = $pageDefaults;
|
45 | 58 | }
|
@@ -86,7 +99,7 @@ public function fixUrl(PageInterface $page): void
|
86 | 99 | // make sure Page has a valid url
|
87 | 100 | if ($page->getParent()) {
|
88 | 101 | if (!$page->getSlug()) {
|
89 |
| - $page->setSlug(Page::slugify($page->getName())); |
| 102 | + $page->setSlug($this->slugify->slugify($page->getName())); |
90 | 103 | }
|
91 | 104 |
|
92 | 105 | if ('/' === $page->getParent()->getUrl()) {
|
|
0 commit comments