Skip to content

Commit

Permalink
pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfyWin committed Sep 10, 2024
1 parent a0e5b4f commit 413a0c5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
3 changes: 0 additions & 3 deletions src/main/core/Repository/Planning/PlanningRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@

namespace Claroline\CoreBundle\Repository\Planning;

use Claroline\AppBundle\Repository\UniqueValueFinder;
use Claroline\CoreBundle\Library\Normalizer\DateNormalizer;
use Doctrine\ORM\EntityRepository;

class PlanningRepository extends EntityRepository
{
use UniqueValueFinder;

public function areDatesAvailable(string $objectId, \DateTimeInterface $start, \DateTimeInterface $end): bool
{
$count = (int) $this->getEntityManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,18 @@ public function postDelete(DeleteEvent $event): void

public function preCopy(CopyEvent $event): void
{
/** @var AbstractPlanned $original */
$original = $event->getObject();

/** @var AbstractPlanned $copy */
$copy = $event->getCopy();

$copy->setCreatedAt(new \DateTime());
$copy->setUpdatedAt(new \DateTime());

$plannedObjectRepo = $this->om->getRepository(PlannedObject::class);

$copyName = $plannedObjectRepo->findNextUnique('name', $original->getPlannedObject()->getName());
$copy->getPlannedObject()->setName($copyName);
}
}
4 changes: 3 additions & 1 deletion src/plugin/cursus/Controller/CourseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Claroline\AppBundle\API\Options;
use Claroline\AppBundle\Controller\AbstractCrudController;
use Claroline\AppBundle\Controller\RequestDecoderTrait;
use Claroline\AppBundle\Manager\PdfManager;
use Claroline\CoreBundle\Component\Context\DesktopContext;
use Claroline\CoreBundle\Entity\Organization\Organization;
Expand Down Expand Up @@ -42,6 +43,7 @@
class CourseController extends AbstractCrudController
{
use PermissionCheckerTrait;
use RequestDecoderTrait;

private TokenStorageInterface $tokenStorage;
private RoutingHelper $routing;
Expand Down Expand Up @@ -210,7 +212,7 @@ public function copyAction(Request $request): JsonResponse

$this->om->startFlushSuite();

$data = json_decode($request->getContent(), true);
$data = $this->decodeRequest($request);

/** @var Course[] $courses */
$courses = $this->om->getRepository(Course::class)->findBy([
Expand Down
4 changes: 3 additions & 1 deletion src/plugin/cursus/Controller/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Claroline\CursusBundle\Controller;

use Claroline\AppBundle\Controller\AbstractCrudController;
use Claroline\AppBundle\Controller\RequestDecoderTrait;
use Claroline\AppBundle\Manager\PdfManager;
use Claroline\CoreBundle\Entity\Group;
use Claroline\CoreBundle\Entity\Organization\Organization;
Expand Down Expand Up @@ -41,6 +42,7 @@
class EventController extends AbstractCrudController
{
use PermissionCheckerTrait;
use RequestDecoderTrait;

public function __construct(
AuthorizationCheckerInterface $authorization,
Expand Down Expand Up @@ -96,7 +98,7 @@ public function copyAction(Request $request): JsonResponse

$this->om->startFlushSuite();

$data = json_decode($request->getContent(), true);
$data = $this->decodeRequest($request);

/** @var Event[] $events */
$events = $this->om->getRepository(Event::class)->findBy([
Expand Down
4 changes: 3 additions & 1 deletion src/plugin/cursus/Controller/SessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Claroline\CursusBundle\Controller;

use Claroline\AppBundle\Controller\AbstractCrudController;
use Claroline\AppBundle\Controller\RequestDecoderTrait;
use Claroline\AppBundle\Manager\PdfManager;
use Claroline\CoreBundle\Component\Context\DesktopContext;
use Claroline\CoreBundle\Entity\Group;
Expand Down Expand Up @@ -45,6 +46,7 @@
class SessionController extends AbstractCrudController
{
use PermissionCheckerTrait;
use RequestDecoderTrait;

private TokenStorageInterface $tokenStorage;
private TranslatorInterface $translator;
Expand Down Expand Up @@ -138,7 +140,7 @@ public function copyAction(Request $request): JsonResponse

$this->om->startFlushSuite();

$data = json_decode($request->getContent(), true);
$data = $this->decodeRequest($request);

/** @var Session[] $sessions */
$sessions = $this->om->getRepository(Session::class)->findBy([
Expand Down
1 change: 0 additions & 1 deletion src/plugin/cursus/Subscriber/Crud/CourseSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ public function preCopy(CopyEvent $event): void
$copyCode = $this->om->getRepository(Course::class)->findNextUnique('code', $original->getCode());
$copy->setName($copyName);
$copy->setCode($copyCode);
$copy->setSlug($copyName);
}

public function postCopy(CopyEvent $event): void
Expand Down
4 changes: 0 additions & 4 deletions src/plugin/cursus/Subscriber/Crud/EventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Claroline\AppBundle\Event\Crud\CopyEvent;
use Claroline\AppBundle\Event\Crud\CreateEvent;
use Claroline\CoreBundle\Entity\Planning\PlannedObject;
use Claroline\CoreBundle\Subscriber\Crud\Planning\AbstractPlannedSubscriber;
use Claroline\CursusBundle\Entity\Event;
use Claroline\CursusBundle\Entity\Registration\AbstractRegistration;
Expand Down Expand Up @@ -117,12 +116,9 @@ public function preCopy(CopyEvent $event): void

$copy->setUuid(BaseUuid::uuid4()->toString());

$plannedObjectRepo = $this->om->getRepository(PlannedObject::class);
$copyName = $plannedObjectRepo->findNextUnique('name', $original->getPlannedObject()->getName());
$copyCode = $this->om->getRepository(Event::class)->findNextUnique('code', $original->getCode());

$copy->setCode($copyCode);
$copy->setSession($session);
$copy->getPlannedObject()->setName($copyName);
}
}

0 comments on commit 413a0c5

Please sign in to comment.