mirror of
https://github.com/quentin-g-dev/afup.git
synced 2026-03-26 10:12:16 +01:00
59 lines
1.7 KiB
PHP
59 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace AppBundle\Event\Model\Repository;
|
|
|
|
use AppBundle\Event\Model\Event;
|
|
use AppBundle\Event\Model\Room;
|
|
use CCMBenchmark\Ting\Repository\Metadata;
|
|
use CCMBenchmark\Ting\Repository\MetadataInitializer;
|
|
use CCMBenchmark\Ting\Repository\Repository;
|
|
use CCMBenchmark\Ting\Serializer\SerializerFactoryInterface;
|
|
|
|
class RoomRepository extends Repository implements MetadataInitializer
|
|
{
|
|
/**
|
|
* @param Event $event
|
|
* @return \CCMBenchmark\Ting\Repository\CollectionInterface
|
|
*/
|
|
public function getByEvent(Event $event)
|
|
{
|
|
return $this->getBy(['eventId' => $event->getId()]);
|
|
}
|
|
|
|
/**
|
|
* @param SerializerFactoryInterface $serializerFactory
|
|
* @param array $options
|
|
* @return Metadata
|
|
*/
|
|
public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = [])
|
|
{
|
|
$metadata = new Metadata($serializerFactory);
|
|
$metadata->setEntity(Room::class);
|
|
$metadata->setConnectionName('main');
|
|
$metadata->setDatabase($options['database']);
|
|
$metadata->setTable('afup_forum_salle');
|
|
|
|
$metadata
|
|
->addField([
|
|
'columnName' => 'id',
|
|
'fieldName' => 'id',
|
|
'primary' => true,
|
|
'autoincrement' => true,
|
|
'type' => 'int'
|
|
])
|
|
->addField([
|
|
'columnName' => 'nom',
|
|
'fieldName' => 'name',
|
|
'type' => 'string'
|
|
])
|
|
->addField([
|
|
'columnName' => 'id_forum',
|
|
'fieldName' => 'eventId',
|
|
'type' => 'int'
|
|
])
|
|
;
|
|
|
|
return $metadata;
|
|
}
|
|
}
|