|
@@ -12,100 +12,37 @@ class EventRepository extends BaseApiRepository
|
|
|
CONST URI = BaseApiRepository::BASE_URI . 'public/events';
|
|
CONST URI = BaseApiRepository::BASE_URI . 'public/events';
|
|
|
const HYDRA_TYPE = 'PortailEvent';
|
|
const HYDRA_TYPE = 'PortailEvent';
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Returns an Event object from an Api record
|
|
|
|
|
- * @param array $record A record as returned by $this->getApiRecords
|
|
|
|
|
- * @return Event|null
|
|
|
|
|
- * @throws Exception
|
|
|
|
|
- */
|
|
|
|
|
- private function eventFromJson($record) {
|
|
|
|
|
- if ($record->{'@type'} != $this::HYDRA_TYPE) {
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
- $event = new Event();
|
|
|
|
|
- $a = explode('/', $record->{'@id'});
|
|
|
|
|
- $event->setId(end($a));
|
|
|
|
|
- $event->setOrganizationId($record->{'organizationId'});
|
|
|
|
|
- $event->setSubdomain($record->{'subDomain'});
|
|
|
|
|
- $event->setName($record->{'name'});
|
|
|
|
|
- $event->setDescription($record->{'description'});
|
|
|
|
|
- $event->setUrl($record->{'url'});
|
|
|
|
|
- $event->setRule($record->{'rule'});
|
|
|
|
|
- $dateStart = new \DateTime($record->{'datetimeStart'});
|
|
|
|
|
- $dateStart->setTimezone(new \DateTimeZone('Europe/Paris'));
|
|
|
|
|
- $event->setDatetimeStart($dateStart);
|
|
|
|
|
- $dateEnd = new \DateTime($record->{'datetimeStart'});
|
|
|
|
|
- $dateEnd->setTimezone(new \DateTimeZone('Europe/Paris'));
|
|
|
|
|
- $event->setDatetimeEnd(new \DateTime($record->{'datetimeEnd'}, new DateTimeZone("Europe/Paris")));
|
|
|
|
|
- $event->setDates($record->{'dates'});
|
|
|
|
|
- $event->setPlacename($record->{'placeName'});
|
|
|
|
|
- $event->setPlaceDescription($record->{'placeDescription'});
|
|
|
|
|
- $event->setPlaceFloorSize($record->{'placeFloorSize'});
|
|
|
|
|
- $event->setPlaceCapacity($record->{'placeCapacity'});
|
|
|
|
|
- $event->setCity($record->{'city'});
|
|
|
|
|
- $event->setPostalCode($record->{'postalCode'});
|
|
|
|
|
- $event->setStreetAddress($record->{'streetAddress'});
|
|
|
|
|
- $event->setLongitude($record->{'longitude'});
|
|
|
|
|
- $event->setLatitude($record->{'latitude'});
|
|
|
|
|
- $event->setRoomName($record->{'roomName'});
|
|
|
|
|
- $event->setRoomDescription($record->{'roomDescription'});
|
|
|
|
|
- $event->setRoomLocalisation($record->{'roomLocalisation'});
|
|
|
|
|
- $event->setRoomCapacity($record->{'roomCapacity'});
|
|
|
|
|
- $event->setRoomFloorSize($record->{'roomFloorSize'});
|
|
|
|
|
- $event->setZupId($record->{'zupId'});
|
|
|
|
|
- $event->setDeepLink($record->{'deepLink'});
|
|
|
|
|
- $event->setImage($record->{'image'});
|
|
|
|
|
- $event->setPriceMini($record->{'priceMini'});
|
|
|
|
|
- $event->setMeetingSchedule($record->{'meetingSchedule'});
|
|
|
|
|
- $event->setApi($record->{'api'});
|
|
|
|
|
- $event->setParentName($record->{'parentName'});
|
|
|
|
|
- $event->setParentSubdomain($record->{'parentSubDomain'});
|
|
|
|
|
- return $event;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Returns an array of Event objects from an array of Api records
|
|
|
|
|
- *
|
|
|
|
|
- * @param array $records An array of records as returned by $this->getApiRecords
|
|
|
|
|
- * @return array
|
|
|
|
|
- * @throws Exception
|
|
|
|
|
- */
|
|
|
|
|
- private function eventsFromJson($records) {
|
|
|
|
|
- $events = [];
|
|
|
|
|
- foreach ($records as $record) {
|
|
|
|
|
- $events[] = $this->eventFromJson($record);
|
|
|
|
|
- }
|
|
|
|
|
- return $events;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Get the event matching the given id
|
|
* Get the event matching the given id
|
|
|
*
|
|
*
|
|
|
* @param int $id The id of the event
|
|
* @param int $id The id of the event
|
|
|
- * @return Event Event
|
|
|
|
|
|
|
+ * @return array Event
|
|
|
* @throws ApiRequestException
|
|
* @throws ApiRequestException
|
|
|
- * @throws Exception
|
|
|
|
|
*/
|
|
*/
|
|
|
- public function findById($id) {
|
|
|
|
|
|
|
+ public function findById(int $id) {
|
|
|
$params = [];
|
|
$params = [];
|
|
|
- $record = $this->getApiFirstRecord($this::URI . '/' . $id, $params);
|
|
|
|
|
- return $this->eventFromJson($record);
|
|
|
|
|
|
|
+ return $this->getApiFirstRecord($this::URI . '/' . $id, $params);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Get the events of the organization
|
|
* Get the events of the organization
|
|
|
*
|
|
*
|
|
|
* @param int $organizationId The id of the organization
|
|
* @param int $organizationId The id of the organization
|
|
|
- * @param \Datetime $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
|
|
|
|
|
- * @param \Datetime $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
|
|
|
|
|
|
|
+ * @param null $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
|
|
|
|
|
+ * @param null $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
|
|
|
* @param int $limit Limit the number of results returned (-1 to disable the limitation)
|
|
* @param int $limit Limit the number of results returned (-1 to disable the limitation)
|
|
|
- * @return array Events
|
|
|
|
|
|
|
+ * @param int $page
|
|
|
|
|
+ * @return ApiPagedCollection Events
|
|
|
* @throws ApiRequestException
|
|
* @throws ApiRequestException
|
|
|
- * @throws Exception
|
|
|
|
|
*/
|
|
*/
|
|
|
- public function findByOrganizationId(int $organizationId, $fromDate = null, $toDate = null, $limit = -1) {
|
|
|
|
|
|
|
+ public function findByOrganizationId(int $organizationId,
|
|
|
|
|
+ $fromDate = null,
|
|
|
|
|
+ $toDate = null,
|
|
|
|
|
+ $limit = -1,
|
|
|
|
|
+ $page = 1) {
|
|
|
$params = [];
|
|
$params = [];
|
|
|
$params['organizationId'] = $organizationId;
|
|
$params['organizationId'] = $organizationId;
|
|
|
|
|
+ $params['page'] = $page;
|
|
|
|
|
|
|
|
if ($limit > 0) {
|
|
if ($limit > 0) {
|
|
|
$params['itemsPerPage'] = $limit;
|
|
$params['itemsPerPage'] = $limit;
|
|
@@ -119,24 +56,28 @@ class EventRepository extends BaseApiRepository
|
|
|
}
|
|
}
|
|
|
$params['filter[order][0][datetimeEnd]'] = 'ASC';
|
|
$params['filter[order][0][datetimeEnd]'] = 'ASC';
|
|
|
|
|
|
|
|
- $records = $this->getApiRecords($this::URI, $params);
|
|
|
|
|
- return $this->eventsFromJson($records);
|
|
|
|
|
|
|
+ return $this->getApiRecords($this::URI, $params);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Get the events of the organization's parents
|
|
* Get the events of the organization's parents
|
|
|
*
|
|
*
|
|
|
* @param int $organizationId The id of the organization
|
|
* @param int $organizationId The id of the organization
|
|
|
- * @param \Datetime $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
|
|
|
|
|
- * @param \Datetime $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
|
|
|
|
|
|
|
+ * @param null $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
|
|
|
|
|
+ * @param null $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
|
|
|
* @param int $limit Limit the number of results returned (-1 to disable the limitation)
|
|
* @param int $limit Limit the number of results returned (-1 to disable the limitation)
|
|
|
- * @return array Events
|
|
|
|
|
|
|
+ * @param int $page
|
|
|
|
|
+ * @return ApiPagedCollection Events
|
|
|
* @throws ApiRequestException
|
|
* @throws ApiRequestException
|
|
|
- * @throws Exception
|
|
|
|
|
*/
|
|
*/
|
|
|
- public function findParentsByOrganizationId(int $organizationId, $fromDate = null, $toDate = null, $limit = -1) {
|
|
|
|
|
|
|
+ public function findParentsByOrganizationId(int $organizationId,
|
|
|
|
|
+ $fromDate = null,
|
|
|
|
|
+ $toDate = null,
|
|
|
|
|
+ $limit = -1,
|
|
|
|
|
+ $page = 1) {
|
|
|
$params = [];
|
|
$params = [];
|
|
|
$params['organizationId'] = $organizationId;
|
|
$params['organizationId'] = $organizationId;
|
|
|
|
|
+ $params['page'] = $page;
|
|
|
|
|
|
|
|
if ($limit > 0) {
|
|
if ($limit > 0) {
|
|
|
$params['itemsPerPage'] = $limit;
|
|
$params['itemsPerPage'] = $limit;
|
|
@@ -152,8 +93,7 @@ class EventRepository extends BaseApiRepository
|
|
|
|
|
|
|
|
$params['parent'] = '1';
|
|
$params['parent'] = '1';
|
|
|
|
|
|
|
|
- $records = $this->getApiRecords($this::URI, $params);
|
|
|
|
|
- return $this->eventsFromJson($records);
|
|
|
|
|
|
|
+ return $this->getApiRecords($this::URI, $params);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -163,9 +103,8 @@ class EventRepository extends BaseApiRepository
|
|
|
* @param \Datetime|null $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
|
|
* @param \Datetime|null $fromDate Only return events with ending date posterior or equal to this date (leave null for disable the filter)
|
|
|
* @param \Datetime|null $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
|
|
* @param \Datetime|null $toDate Only return events with starting date anterior or equal to this date (leave null for disable the filter)
|
|
|
* @param int $limit Limit the number of results returned (-1 to disable the limitation)
|
|
* @param int $limit Limit the number of results returned (-1 to disable the limitation)
|
|
|
- * @return array Events
|
|
|
|
|
|
|
+ * @return ApiPagedCollection Events
|
|
|
* @throws ApiRequestException
|
|
* @throws ApiRequestException
|
|
|
- * @throws Exception
|
|
|
|
|
*/
|
|
*/
|
|
|
public function findChildrenByOrganizationId(int $organizationId, $fromDate = null, $toDate = null, $limit = -1) {
|
|
public function findChildrenByOrganizationId(int $organizationId, $fromDate = null, $toDate = null, $limit = -1) {
|
|
|
$params = [];
|
|
$params = [];
|
|
@@ -185,8 +124,7 @@ class EventRepository extends BaseApiRepository
|
|
|
|
|
|
|
|
$params['children'] = '1';
|
|
$params['children'] = '1';
|
|
|
|
|
|
|
|
- $records = $this->getApiRecords($this::URI, $params);
|
|
|
|
|
- return $this->eventsFromJson($records);
|
|
|
|
|
|
|
+ return $this->getApiRecords($this::URI, $params);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -194,7 +132,7 @@ class EventRepository extends BaseApiRepository
|
|
|
*
|
|
*
|
|
|
* @param int $organizationId The id of the organization
|
|
* @param int $organizationId The id of the organization
|
|
|
* @param array $searchParams Search arguments
|
|
* @param array $searchParams Search arguments
|
|
|
- * @return array Events
|
|
|
|
|
|
|
+ * @return ApiPagedCollection Events
|
|
|
* @throws ApiRequestException
|
|
* @throws ApiRequestException
|
|
|
* @throws Exception
|
|
* @throws Exception
|
|
|
*/
|
|
*/
|
|
@@ -204,8 +142,57 @@ class EventRepository extends BaseApiRepository
|
|
|
$params['filter[order][0][datetimeEnd]'] = 'ASC';
|
|
$params['filter[order][0][datetimeEnd]'] = 'ASC';
|
|
|
$params = array_merge($params, $searchParams);
|
|
$params = array_merge($params, $searchParams);
|
|
|
|
|
|
|
|
- $records = $this->getApiRecords($this::URI, $params);
|
|
|
|
|
- return $this->eventsFromJson($records);
|
|
|
|
|
|
|
+ return $this->getApiRecords($this::URI, $params);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns an Event object from an Api record
|
|
|
|
|
+ * @param array $record A record as returned by $this->getApiRecords
|
|
|
|
|
+ * @return Event|null
|
|
|
|
|
+ * @throws Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function memberToObject(array $record) {
|
|
|
|
|
+ if ($record['@type'] != $this::HYDRA_TYPE) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ $event = new Event();
|
|
|
|
|
+ $a = explode('/', $record['@id']);
|
|
|
|
|
+ $event->setId(end($a));
|
|
|
|
|
+ $event->setOrganizationId($record['organizationId']);
|
|
|
|
|
+ $event->setSubdomain($record['subDomain']);
|
|
|
|
|
+ $event->setName($record['name']);
|
|
|
|
|
+ $event->setDescription($record['description']);
|
|
|
|
|
+ $event->setUrl($record['url']);
|
|
|
|
|
+ $event->setRule($record['rule']);
|
|
|
|
|
+ $dateStart = new \DateTime($record['datetimeStart']);
|
|
|
|
|
+ $dateStart->setTimezone(new \DateTimeZone('Europe/Paris'));
|
|
|
|
|
+ $event->setDatetimeStart($dateStart);
|
|
|
|
|
+ $dateEnd = new \DateTime($record['datetimeStart']);
|
|
|
|
|
+ $dateEnd->setTimezone(new \DateTimeZone('Europe/Paris'));
|
|
|
|
|
+ $event->setDatetimeEnd(new \DateTime($record['datetimeEnd'], new DateTimeZone("Europe/Paris")));
|
|
|
|
|
+ $event->setDates($record['dates']);
|
|
|
|
|
+ $event->setPlacename($record['placeName']);
|
|
|
|
|
+ $event->setPlaceDescription($record['placeDescription']);
|
|
|
|
|
+ $event->setPlaceFloorSize($record['placeFloorSize']);
|
|
|
|
|
+ $event->setPlaceCapacity($record['placeCapacity']);
|
|
|
|
|
+ $event->setCity($record['city']);
|
|
|
|
|
+ $event->setPostalCode($record['postalCode']);
|
|
|
|
|
+ $event->setStreetAddress($record['streetAddress']);
|
|
|
|
|
+ $event->setLongitude($record['longitude']);
|
|
|
|
|
+ $event->setLatitude($record['latitude']);
|
|
|
|
|
+ $event->setRoomName($record['roomName']);
|
|
|
|
|
+ $event->setRoomDescription($record['roomDescription']);
|
|
|
|
|
+ $event->setRoomLocalisation($record['roomLocalisation']);
|
|
|
|
|
+ $event->setRoomCapacity($record['roomCapacity']);
|
|
|
|
|
+ $event->setRoomFloorSize($record['roomFloorSize']);
|
|
|
|
|
+ $event->setZupId($record['zupId']);
|
|
|
|
|
+ $event->setDeepLink($record['deepLink']);
|
|
|
|
|
+ $event->setImage($record['image']);
|
|
|
|
|
+ $event->setPriceMini($record['priceMini']);
|
|
|
|
|
+ $event->setMeetingSchedule($record['meetingSchedule']);
|
|
|
|
|
+ $event->setApi($record['api']);
|
|
|
|
|
+ $event->setParentName($record['parentName']);
|
|
|
|
|
+ $event->setParentSubdomain($record['parentSubDomain']);
|
|
|
|
|
+ return $event;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|