diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 7cb84b14d..1621471b8 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -791,48 +791,6 @@ class ChillMainExtension extends Extension implements ], ], ], - /* [ - 'class' => \Chill\MainBundle\Entity\DashboardConfigItem::class, - 'controller' => \Chill\MainBundle\Controller\DashboardApiController::class, - 'name' => 'dashboard-config-item', - 'base_path' => '/api/1.0/main/dashboard-config-item', - 'base_role' => 'ROLE_USER', - 'actions' => [ - '_index' => [ - 'methods' => [ - Request::METHOD_GET => true, - Request::METHOD_HEAD => true, - ], - ], - '_entity' => [ - 'methods' => [ - Request::METHOD_GET => true, - Request::METHOD_HEAD => true, - ], - ], - ], - ], - [ - 'class' => \Chill\MainBundle\Entity\NewsItem::class, - 'controller' => \Chill\MainBundle\Controller\NewsItemApiController::class, - 'name' => 'news-items', - 'base_path' => '/api/1.0/main/news', - 'base_role' => 'ROLE_USER', - 'actions' => [ - '_index' => [ - 'methods' => [ - Request::METHOD_GET => true, - Request::METHOD_HEAD => true, - ], - ], - '_entity' => [ - 'methods' => [ - Request::METHOD_GET => true, - Request::METHOD_HEAD => true, - ], - ], - ], - ],*/ ], ]); } diff --git a/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php b/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php index 122202f96..5ad1107c5 100644 --- a/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php +++ b/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php @@ -54,10 +54,10 @@ class DashboardConfigItem /** * @ORM\ManyToOne(targetEntity=User::class) */ - private User $user; + private ?User $user = null; /** - * @ORM\Column(type="json") + * @ORM\Column(type="json" "jsonb"=true, options={"default": "[]"}) * * @Serializer\Groups({"dashboardConfigItem:read"}) */ diff --git a/src/Bundle/ChillMainBundle/Entity/NewsItem.php b/src/Bundle/ChillMainBundle/Entity/NewsItem.php index 10eca8f54..6ca58afd1 100644 --- a/src/Bundle/ChillMainBundle/Entity/NewsItem.php +++ b/src/Bundle/ChillMainBundle/Entity/NewsItem.php @@ -12,7 +12,9 @@ declare(strict_types=1); namespace Chill\MainBundle\Entity; use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; +use Chill\MainBundle\Doctrine\Model\TrackCreationTrait; use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; +use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; @@ -24,6 +26,10 @@ use Symfony\Component\Validator\Constraints as Assert; */ class NewsItem implements TrackCreationInterface, TrackUpdateInterface { + use TrackCreationTrait; + + use TrackUpdateTrait; + /** * @ORM\Id * @@ -71,78 +77,6 @@ class NewsItem implements TrackCreationInterface, TrackUpdateInterface */ private ?\DateTimeImmutable $endDate = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - */ - private ?\DateTimeInterface $createdAt = null; - - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @ORM\JoinColumn(nullable=true) - */ - private ?User $createdBy = null; - - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - */ - private ?\DateTimeInterface $updatedAt = null; - - /** - * @ORM\ManyToOne(targetEntity=User::class) - * - * @ORM\JoinColumn(nullable=true) - */ - private ?User $updatedBy = null; - - public function getCreatedAt(): ?\DateTimeInterface - { - return $this->createdAt; - } - - public function getCreatedBy(): ?User - { - return $this->createdBy; - } - - public function getUpdatedAt(): ?\DateTimeInterface - { - return $this->updatedAt; - } - - public function getUpdatedBy(): ?User - { - return $this->updatedBy; - } - - public function setCreatedAt(\DateTimeInterface $datetime): self - { - $this->createdAt = $datetime; - - return $this; - } - - public function setCreatedBy(User $user): self - { - $this->createdBy = $user; - - return $this; - } - - public function setUpdatedAt(\DateTimeInterface $datetime): self - { - $this->updatedAt = $datetime; - - return $this; - } - - public function setUpdatedBy(User $user): self - { - $this->updatedBy = $user; - - return $this; - } - public function getTitle(): string { return $this->title; diff --git a/src/Bundle/ChillMainBundle/Repository/NewsItemRepository.php b/src/Bundle/ChillMainBundle/Repository/NewsItemRepository.php index bb2128b25..042c052c5 100644 --- a/src/Bundle/ChillMainBundle/Repository/NewsItemRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/NewsItemRepository.php @@ -16,12 +16,13 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ObjectRepository; +use Symfony\Component\Clock\ClockInterface; class NewsItemRepository implements ObjectRepository { private readonly EntityRepository $repository; - public function __construct(EntityManagerInterface $entityManager) + public function __construct(EntityManagerInterface $entityManager, private ClockInterface $clock) { $this->repository = $entityManager->getRepository(NewsItem::class); } @@ -58,6 +59,9 @@ class NewsItemRepository implements ObjectRepository public function findWithDateFilter() { + dump($this->buildQueryWithDateFilter() + ->getQuery() + ->getResult()); return $this->buildQueryWithDateFilter() ->getQuery() ->getResult(); @@ -73,13 +77,13 @@ class NewsItemRepository implements ObjectRepository public function buildQueryWithDateFilter(): QueryBuilder { - $now = new \DateTime('now'); + $now = $this->clock->now(); $qb = $this->createQueryBuilder('n'); $qb ->where( $qb->expr()->andX( - $qb->expr()->gte('n.startDate', ':now'), + $qb->expr()->lte('n.startDate', ':now'), $qb->expr()->orX( $qb->expr()->lt('n.endDate', ':now'), $qb->expr()->isNull('n.endDate') diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/DashboardWidgets/News.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/DashboardWidgets/News.vue index 272a57e9b..e11338c4a 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/DashboardWidgets/News.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/DashboardWidgets/News.vue @@ -5,8 +5,8 @@