backports murph-skeleton
This commit is contained in:
parent
249622485a
commit
e69a44151d
|
@ -10,6 +10,7 @@ use App\Core\Factory\Site\NodeFactory;
|
||||||
use App\Core\Manager\EntityManager;
|
use App\Core\Manager\EntityManager;
|
||||||
use App\Core\Repository\Site\NodeRepository;
|
use App\Core\Repository\Site\NodeRepository;
|
||||||
use App\Core\Slugify\CodeSlugify;
|
use App\Core\Slugify\CodeSlugify;
|
||||||
|
use App\Core\Cache\SymfonyCacheManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class MenuEventSubscriber.
|
* class MenuEventSubscriber.
|
||||||
|
@ -22,17 +23,20 @@ class MenuEventSubscriber extends EntityManagerEventSubscriber
|
||||||
protected NodeRepository $nodeRepository;
|
protected NodeRepository $nodeRepository;
|
||||||
protected EntityManager $entityManager;
|
protected EntityManager $entityManager;
|
||||||
protected CodeSlugify $slugify;
|
protected CodeSlugify $slugify;
|
||||||
|
protected SymfonyCacheManager $cacheManager;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
NodeFactory $nodeFactory,
|
NodeFactory $nodeFactory,
|
||||||
NodeRepository $nodeRepository,
|
NodeRepository $nodeRepository,
|
||||||
EntityManager $entityManager,
|
EntityManager $entityManager,
|
||||||
CodeSlugify $slugify
|
CodeSlugify $slugify,
|
||||||
|
SymfonyCacheManager $cacheManager
|
||||||
) {
|
) {
|
||||||
$this->nodeFactory = $nodeFactory;
|
$this->nodeFactory = $nodeFactory;
|
||||||
$this->nodeRepository = $nodeRepository;
|
$this->nodeRepository = $nodeRepository;
|
||||||
$this->entityManager = $entityManager;
|
$this->entityManager = $entityManager;
|
||||||
$this->slugify = $slugify;
|
$this->slugify = $slugify;
|
||||||
|
$this->cacheManager = $cacheManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function support(EntityInterface $entity)
|
public function support(EntityInterface $entity)
|
||||||
|
@ -58,11 +62,16 @@ class MenuEventSubscriber extends EntityManagerEventSubscriber
|
||||||
|
|
||||||
$menu = $event->getEntity();
|
$menu = $event->getEntity();
|
||||||
|
|
||||||
if (0 !== count($menu->getNodes())) {
|
if (count($menu->getNodes()) > 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rootNode = $this->nodeFactory->create($menu);
|
$rootNode = $menu->getRootNode();
|
||||||
|
|
||||||
|
if (!$rootNode) {
|
||||||
|
$rootNode = $this->nodeFactory->create($menu);
|
||||||
|
}
|
||||||
|
|
||||||
$childNode = $this->nodeFactory->create($menu, '/');
|
$childNode = $this->nodeFactory->create($menu, '/');
|
||||||
$childNode
|
$childNode
|
||||||
->setParent($rootNode)
|
->setParent($rootNode)
|
||||||
|
@ -78,6 +87,8 @@ class MenuEventSubscriber extends EntityManagerEventSubscriber
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
$this->nodeRepository->persistAsFirstChild($childNode, $rootNode);
|
$this->nodeRepository->persistAsFirstChild($childNode, $rootNode);
|
||||||
|
|
||||||
|
$this->cacheManager->cleanAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate(EntityManagerEvent $event)
|
public function onUpdate(EntityManagerEvent $event)
|
||||||
|
|
|
@ -8,10 +8,9 @@ use App\Core\Entity\Site\Navigation;
|
||||||
use App\Core\Entity\Site\Node;
|
use App\Core\Entity\Site\Node;
|
||||||
use App\Core\Event\EntityManager\EntityManagerEvent;
|
use App\Core\Event\EntityManager\EntityManagerEvent;
|
||||||
use App\Core\EventSuscriber\EntityManagerEventSubscriber;
|
use App\Core\EventSuscriber\EntityManagerEventSubscriber;
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
use Symfony\Component\Finder\Finder;
|
||||||
use Symfony\Component\Console\Input\ArrayInput;
|
|
||||||
use Symfony\Component\Console\Output\BufferedOutput;
|
|
||||||
use Symfony\Component\HttpKernel\KernelInterface;
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
use App\Core\Cache\SymfonyCacheManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class SiteEventSubscriber.
|
* class SiteEventSubscriber.
|
||||||
|
@ -21,10 +20,12 @@ use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
class SiteEventSubscriber extends EntityManagerEventSubscriber
|
class SiteEventSubscriber extends EntityManagerEventSubscriber
|
||||||
{
|
{
|
||||||
protected KernelInterface $kernel;
|
protected KernelInterface $kernel;
|
||||||
|
protected SymfonyCacheManager $cacheManager;
|
||||||
|
|
||||||
public function __construct(KernelInterface $kernel)
|
public function __construct(KernelInterface $kernel, SymfonyCacheManager $cacheManager)
|
||||||
{
|
{
|
||||||
$this->kernel = $kernel;
|
$this->kernel = $kernel;
|
||||||
|
$this->cacheManager = $cacheManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function support(EntityInterface $entity)
|
public function support(EntityInterface $entity)
|
||||||
|
@ -38,7 +39,11 @@ class SiteEventSubscriber extends EntityManagerEventSubscriber
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cleanCache();
|
if ($event->getEntity() instanceof Node) {
|
||||||
|
$this->cacheManager->cleanRouting();
|
||||||
|
} else {
|
||||||
|
$this->cacheManager->cleanAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCreate(EntityManagerEvent $event)
|
public function onCreate(EntityManagerEvent $event)
|
||||||
|
@ -50,17 +55,4 @@ class SiteEventSubscriber extends EntityManagerEventSubscriber
|
||||||
{
|
{
|
||||||
return $this->onUpdate($event);
|
return $this->onUpdate($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function cleanCache()
|
|
||||||
{
|
|
||||||
$application = new Application($this->kernel);
|
|
||||||
$application->setAutoExit(false);
|
|
||||||
|
|
||||||
$input = new ArrayInput([
|
|
||||||
'command' => 'cache:clear',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$output = new BufferedOutput();
|
|
||||||
$application->run($input, $output);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,3 +120,4 @@
|
||||||
"Enter your account username or email address. An e-mail will be sent to you to initiate the password change procedure. ": "Saisissez le nom d'utilisateur ou l'adresse e-mail de votre compte. Un e-mail vous sera envoyé pour enclancher la procédure de changement de mot de passe."
|
"Enter your account username or email address. An e-mail will be sent to you to initiate the password change procedure. ": "Saisissez le nom d'utilisateur ou l'adresse e-mail de votre compte. Un e-mail vous sera envoyé pour enclancher la procédure de changement de mot de passe."
|
||||||
"Show the login page": "Afficher la page de connexion"
|
"Show the login page": "Afficher la page de connexion"
|
||||||
"A password reset request has been made. If you are the source of this request, click on the link below or copy and paste the address if the link does not work.": "Une demande de réinitialisation de mot de passe a été réalisée. Si vous êtes à l'origine de cette demande, cliquer sur le lien ci-dessous ou copier et coller l'adresse si le lien ne fonctionne pas."
|
"A password reset request has been made. If you are the source of this request, click on the link below or copy and paste the address if the link does not work.": "Une demande de réinitialisation de mot de passe a été réalisée. Si vous êtes à l'origine de cette demande, cliquer sur le lien ci-dessous ou copier et coller l'adresse si le lien ne fonctionne pas."
|
||||||
|
"Edit the routing": "Éditez le routage"
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
|
|
||||||
<span class="ml-3 btn-group">
|
<span class="ml-3 btn-group">
|
||||||
{% if node.hasExternalUrl %}
|
{% if node.hasExternalUrl %}
|
||||||
<a href="{{ node.url }}" class="btn btn-sm border border-secondary btn-light">
|
<a href="{{ safe_node_url(node) }}" class="btn btn-sm border border-secondary btn-light">
|
||||||
<span class="fa fa-sign-out-alt text-muted"></span>
|
<span class="fa fa-sign-out-alt text-muted"></span>
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -122,9 +122,19 @@
|
||||||
{{ node.url }}
|
{{ node.url }}
|
||||||
</span>
|
</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ url(node.routeName) }}" target="_blank" class="btn btn-sm border border-secondary btn-light">
|
{% set url = safe_node_url(node) %}
|
||||||
{{ node.url }}
|
|
||||||
</a>
|
{% if url %}
|
||||||
|
<a href="{{ url ? url : '#' }}" target="_blank" class="btn btn-sm border border-secondary btn-light">
|
||||||
|
{{ node.url }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if url is same as(null) %}
|
||||||
|
<span class="btn btn-sm border border-secondary btn-light" title="{{ 'Edit the routing'|trans }}">
|
||||||
|
<span class="fa fa-exclamation"></span>
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if node.controller %}
|
{% if node.controller %}
|
||||||
|
|
|
@ -39,6 +39,10 @@ class SiteRouteLoader extends Loader
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $node->getUrl()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($node->hasExternalUrl()) {
|
if ($node->hasExternalUrl()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue