Преглед на файлове

Merge branch 'develop'

master
Guillaume преди 2 години
родител
ревизия
f636343f53
променени са 3 файла, в които са добавени 28 реда и са изтрити 10 реда
  1. +24
    -6
      Component/EntityComponent.php
  2. +2
    -2
      Controller/AbstractAdminController.php
  3. +2
    -2
      Controller/User/UserAdminController.php

+ 24
- 6
Component/EntityComponent.php Целия файл

@@ -3,6 +3,11 @@
namespace Lc\SovBundle\Component;

use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Doctrine\Extension\BlameableInterface;
use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
use Lc\SovBundle\Doctrine\Extension\SeoInterface;
use Lc\SovBundle\Doctrine\Extension\SortableInterface;
use Lc\SovBundle\Doctrine\Extension\TimestampableInterface;
use Lc\SovBundle\Event\EntityComponentEvent;
use Lc\SovBundle\Model\File\FileInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
@@ -30,6 +35,7 @@ class EntityComponent
$newEntity = clone $entity;
$classMetadata = $this->entityManager->getClassMetadata(get_class($newEntity));

//Dupplication de l'image ou du fichier lier
foreach ($classMetadata->getAssociationMappings() as $associationMapping){
if(in_array(FileInterface::class, class_implements($associationMapping['targetEntity']))){
$methodGet = 'get'.ucfirst($associationMapping['fieldName']);
@@ -41,16 +47,28 @@ class EntityComponent
}
}
}
}


if($newEntity instanceof DevAliasInterface){
$newEntity->setDevAlias(null);
}

if($newEntity instanceof SeoInterface) {
$newEntity->setOldUrls(array());
}

//TODO dispatch event duplicate
/* if ($newEntity instanceof ProductFamilyInterface) {
// @TODO : à adapter
//$newEntity = $this->productFamilyUtils->processBeforePersistProductFamily($newEntity, false, true);
if($newEntity instanceof BlameableInterface) {
$newEntity->setUpdatedBy(null);
$newEntity->setCreatedBy(null);
}
*/
$this->entityManager->create($newEntity);

if($newEntity instanceof TimestampableInterface) {
$newEntity->setUpdatedAt(new \DateTime());
$newEntity->setCreatedAt(new \DateTime());
}

$this->entityManager->create($newEntity);
$this->eventDispatcher->dispatch(new EntityComponentEvent($newEntity), EntityComponentEvent::DUPLICATE_EVENT);

return $newEntity;

+ 2
- 2
Controller/AbstractAdminController.php Целия файл

@@ -75,7 +75,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
$this->overrideGlobalActions($responseParameters->get('global_actions'));
}
if ($responseParameters->get('entities')) {
$this->overrideEntitiesActions($responseParameters->get('entities'));
$this->overrideEntitiesActions($responseParameters->get('entities'), $responseParameters->get('pageName'));
}
if (Crud::PAGE_INDEX === $responseParameters->get('pageName')) {
$responseParameters->set('fields', $this->configureFields('index'));
@@ -95,7 +95,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
return $this->getEntityFqcn();
}

public function overrideEntitiesActions(?EntityCollection $entities): void
public function overrideEntitiesActions(?EntityCollection $entities, string $pageName): void
{
}


+ 2
- 2
Controller/User/UserAdminController.php Целия файл

@@ -43,9 +43,9 @@ abstract class UserAdminController extends AbstractAdminController
return $switchAction;
}

public function overrideEntitiesActions(?EntityCollection $entities): void
public function overrideEntitiesActions(?EntityCollection $entities, string $pageName): void
{
parent::overrideEntitiesActions($entities); // TODO: Change the autogenerated stub
parent::overrideEntitiesActions($entities, $pageName); // TODO: Change the autogenerated stub
foreach ($entities as $entity) {
foreach ($entity->getActions() as $action) {
if ($action->getName() == ActionDefinition::SWITCH_USER) {

Loading…
Отказ
Запис