-
-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5375886
commit 6e4be34
Showing
11 changed files
with
31 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,33 +13,46 @@ | |
|
||
namespace Sonata\PageBundle\Entity; | ||
|
||
use Cocur\Slugify\SlugifyInterface; | ||
use Doctrine\Persistence\ManagerRegistry; | ||
use Sonata\Doctrine\Entity\BaseEntityManager; | ||
use Sonata\PageBundle\Model\Page; | ||
use Sonata\PageBundle\Model\PageInterface; | ||
use Sonata\PageBundle\Model\PageManagerInterface; | ||
use Sonata\PageBundle\Model\SiteInterface; | ||
|
||
/** | ||
* This class manages PageInterface persistency with the Doctrine ORM. | ||
* | ||
* @extends BaseEntityManager<PageInterface> | ||
* | ||
* @author Thomas Rabaix <[email protected]> | ||
*/ | ||
final class PageManager extends BaseEntityManager implements PageManagerInterface | ||
{ | ||
private SlugifyInterface $slugify; | ||
|
||
/** | ||
* @var array<string, mixed> | ||
*/ | ||
private array $pageDefaults; | ||
|
||
/** | ||
* @var array<string, mixed> | ||
*/ | ||
private array $defaults; | ||
|
||
/** | ||
* @param string $class | ||
* @param array<string, mixed> $defaults | ||
* @param array<string, mixed> $pageDefaults | ||
*/ | ||
public function __construct($class, ManagerRegistry $registry, array $defaults = [], array $pageDefaults = []) | ||
{ | ||
public function __construct( | ||
string $class, | ||
ManagerRegistry $registry, | ||
SlugifyInterface $slugify, | ||
array $defaults = [], | ||
array $pageDefaults = [] | ||
) { | ||
parent::__construct($class, $registry); | ||
|
||
$this->slugify = $slugify; | ||
$this->defaults = $defaults; | ||
$this->pageDefaults = $pageDefaults; | ||
} | ||
|
@@ -86,7 +99,7 @@ public function fixUrl(PageInterface $page): void | |
// make sure Page has a valid url | ||
if ($page->getParent()) { | ||
if (!$page->getSlug()) { | ||
$page->setSlug(Page::slugify($page->getName())); | ||
$page->setSlug($this->slugify->slugify($page->getName())); | ||
} | ||
|
||
if ('/' === $page->getParent()->getUrl()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters