openstackid-resources/app/Repositories/Summit/DoctrineSummitRepository.php
Sebastian Marcet 18bf5bfa04 added endpoint update summit
PUT /api/v1/summits/{id}

Payload

* name (sometimes|string|max:50)
* start_date (sometimes|date_format:U)
* end_date (required_with:start_date|date_format:U|after:start_date)
* submission_begin_date (sometimes|date_format:U)
* submission_end_date (required_with:submission_begin_date|date_format:U|after:submission_begin_date)
* voting_begin_date (sometimes|date_format:U)
* voting_end_date (required_with:voting_begin_date|date_format:U|after:voting_begin_date)
* selection_begin_date (sometimes|date_format:U)
* selection_end_date (required_with:selection_begin_date|date_format:U|after:selection_begin_date)
* registration_begin_date (sometimes|date_format:U)
* registration_end_date (required_with:registration_begin_date|date_format:U|after:registration_begin_date)
* start_showing_venues_date (sometimes|date_format:U|before:start_date)
* schedule_start_date (sometimes|date_format:U)
* active (sometimes|boolean)
* dates_label (sometimes|string)
* time_zone_id (sometimes|timezone) check http://php.net/manual/en/timezones.php
* external_summit_id (sometimes|string)
* available_on_api (sometimes|boolean)
* calendar_sync_name (sometimes|string|max:255)
* calendar_sync_desc  (sometimes|string)
* link (sometimes|url)
* registration_link (sometimes|url)
* max_submission_allowed_per_user (sometimes|integer|min:1)

Required scopes

'%s/summits/write'

Change-Id: Ib50c64994f9de5e8cfba0aaf2a990708a3c6afb9
2018-04-04 18:08:33 -03:00

108 lines
3.0 KiB
PHP

<?php namespace App\Repositories\Summit;
/**
* Copyright 2016 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use models\summit\ISummitRepository;
use models\summit\Summit;
use App\Repositories\SilverStripeDoctrineRepository;
/**
* Class DoctrineSummitRepository
* @package App\Repositories\Summit
*/
final class DoctrineSummitRepository
extends SilverStripeDoctrineRepository
implements ISummitRepository
{
/**
* @return Summit
*/
public function getCurrent()
{
$res = $this->getEntityManager()->createQueryBuilder()
->select("s")
->from(\models\summit\Summit::class, "s")
->where('s.active = 1')
->andWhere('s.available_on_api = 1')
->orderBy('s.begin_date', 'DESC')
->getQuery()
->getResult();
if (count($res) == 0) return null;
return $res[0];
}
/**
* @return Summit[]
*/
public function getAvailables()
{
return $this->getEntityManager()->createQueryBuilder()
->select("s")
->from(\models\summit\Summit::class, "s")
->where('s.available_on_api = 1')
->orderBy('s.begin_date', 'ASC')
->getQuery()
->getResult();
}
/**
* @return Summit[]
*/
public function getAllOrderedByBeginDate()
{
return $this->getEntityManager()->createQueryBuilder()
->select("s")
->from(\models\summit\Summit::class, "s")
->orderBy('s.begin_date', 'ASC')
->getQuery()
->getResult();
}
/**
* @return string
*/
protected function getBaseEntity()
{
return Summit::class;
}
/**
* @param string $name
* @return Summit
*/
public function getByName($name)
{
return $this->getEntityManager()->createQueryBuilder()
->select("s")
->from(\models\summit\Summit::class, "s")
->where('s.name = :name')
->setParameter('name', $name)
->getQuery()
->getOneOrNullResult();
}
/**
* @return Summit
*/
public function getActive()
{
$res = $this->getEntityManager()->createQueryBuilder()
->select("s")
->from(\models\summit\Summit::class, "s")
->where('s.active = 1')
->orderBy('s.begin_date', 'DESC')
->getQuery()
->getResult();
if (count($res) == 0) return null;
return $res[0];
}
}