$generalMeetingDate->format('U'), ]; $query = $this->getPreparedQuery($sql)->setParams($params); $collection = $query->query($this->getCollection(new HydratorSingleObject())); if ($collection->count() === 0) { return null; } return $collection->first(); } public function loadClosedQuestions(\DateTimeInterface $generalMeetingDate) { $sql = << $generalMeetingDate->format('U'), ]; return $this->getPreparedQuery($sql)->setParams($params)->query($this->getCollection(new HydratorSingleObject())); } /** * @param \DateTimeInterface $date * * @return \CCMBenchmark\Ting\Repository\CollectionInterface */ public function loadByDate(\DateTimeInterface $generalMeetingDate) { return $this->getBy([ 'date' => $generalMeetingDate->format('U'), ]); } public function open(GeneralMeetingQuestion $question) { $question->setOpenedAt(new \DateTime()); $this->save($question); } public function close(GeneralMeetingQuestion $question) { $question->setClosedAt(new \DateTime()); $this->save($question); } /** * @inheritDoc */ public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) { $metadata = new Metadata($serializerFactory); $metadata->setEntity(GeneralMeetingQuestion::class); $metadata->setConnectionName('main'); $metadata->setDatabase($options['database']); $metadata->setTable('afup_assemblee_generale_question'); $metadata ->addField([ 'columnName' => 'id', 'fieldName' => 'id', 'primary' => true, 'autoincrement' => true, 'type' => 'int', ]) ->addField([ 'columnName' => 'date', 'fieldName' => 'date', 'type' => 'datetime', 'serializer_options' => [ 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'], ], ]) ->addField([ 'columnName' => 'label', 'fieldName' => 'label', 'type' => 'string', ]) ->addField([ 'columnName' => 'opened_at', 'fieldName' => 'openedAt', 'type' => 'datetime', ]) ->addField([ 'columnName' => 'closed_at', 'fieldName' => 'closedAt', 'type' => 'datetime', ]) ->addField([ 'columnName' => 'created_at', 'fieldName' => 'createdAt', 'type' => 'datetime', ]) ; return $metadata; } }