* * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ namespace Chill\PersonBundle\Timeline; use Chill\MainBundle\Timeline\TimelineProviderInterface; use Doctrine\ORM\EntityManager; use Chill\PersonBundle\Entity\AccompanyingPeriod; /** * Provide information for opening periods to timeline */ class TimelineAccompanyingPeriodClosing extends AbstractTimelineAccompanyingPeriod { /** * * {@inheritDoc} */ public function supportsType($type) { return $type === 'accompanying_period_closing'; } /** * * {@inheritDoc} */ public function fetchQuery($context, array $args) { $metadata = $this->em ->getClassMetadata(AccompanyingPeriod::class); $query = $this->basicFetchQuery($context, $args); [$where, $parameters] = $this->buildWhereClause($context, $args); $query->setKey('accompanying_period_closing') ->setDate($metadata->getColumnName('closingDate')) ->setWhere($where) ->setParameters($parameters) ; return $query; } protected function buildWhereClause($context, array $args): array { list($query, $params) = parent::buildWhereClause($context, $args); $period = $this->em->getClassMetadata(AccompanyingPeriod::class); $query .= " AND {$period->getColumnName('closingDate')} IS NOT NULL "; return [ $query, $params ]; } /** * * {@inheritDoc} */ public function getEntityTemplate($entity, $context, array $args) { return $this->getBasicEntityTemplate( 'ChillPersonBundle:Timeline:closing_period.html.twig', $entity, $context, $args ); } }