Skip to content

Commit

Permalink
more phpcs.
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMis committed Aug 4, 2023
1 parent 10a68b7 commit 7583d0a
Showing 1 changed file with 52 additions and 22 deletions.
74 changes: 52 additions & 22 deletions lib/Controller/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,11 @@ public function addForm(Request $request, Response $response, ?string $from, ?in
if (!empty($from) && !empty($id)) {
$formNowData = [
'eventTypeId' => $this->getEventTypeId($from),
'campaign' => (($from == 'Campaign' || $from == 'Layout') ? $this->campaignFactory->getById($id) : null),
'campaign' => (
($from == 'Campaign' || $from == 'Layout')
? $this->campaignFactory->getById($id)
: null
),
'displayGroup' => (($from == 'DisplayGroup') ? [$this->displayGroupFactory->getById($id)] : null),
'displayGroupId' => (($from == 'DisplayGroup') ? (int)$id : 0),
'mediaId' => (($from === 'Library') ? $id : null),
Expand Down Expand Up @@ -908,21 +912,24 @@ public function addForm(Request $request, Response $response, ?string $from, ?in
* @SWG\Parameter(
* name="eventTypeId",
* in="formData",
* description="The Event Type Id to use for this Event. 1=Layout, 2=Command, 3=Overlay, 4=Interrupt, 5=Campaign, 6=Action, 7=Media Library, 8=Playlist",
* description="The Event Type Id to use for this Event.
* 1=Layout, 2=Command, 3=Overlay, 4=Interrupt, 5=Campaign, 6=Action, 7=Media Library, 8=Playlist",
* type="integer",
* required=true
* ),
* @SWG\Parameter(
* name="campaignId",
* in="formData",
* description="The Campaign ID to use for this Event. If a Layout is needed then the Campaign specific ID for that Layout should be used.",
* description="The Campaign ID to use for this Event.
* If a Layout is needed then the Campaign specific ID for that Layout should be used.",
* type="integer",
* required=false
* ),
* @SWG\Parameter(
* name="fullScreenCampaignId",
* in="formData",
* description="For Media or Playlist eventyType. The Layout specific Campaign ID to use for this Event. This needs to be the Layout created with layout/fullscreen function",
* description="For Media or Playlist eventyType. The Layout specific Campaign ID to use for this Event.
* This needs to be the Layout created with layout/fullscreen function",
* type="integer",
* required=false
* ),
Expand Down Expand Up @@ -1172,7 +1179,10 @@ public function add(Request $request, Response $response)
$schedule->recurrenceDetail = $sanitizedParams->getInt('recurrenceDetail');
$recurrenceRepeatsOn = $sanitizedParams->getIntArray('recurrenceRepeatsOn');
$schedule->recurrenceRepeatsOn = (empty($recurrenceRepeatsOn)) ? null : implode(',', $recurrenceRepeatsOn);
$schedule->recurrenceMonthlyRepeatsOn = $sanitizedParams->getInt('recurrenceMonthlyRepeatsOn', ['default' => 0]);
$schedule->recurrenceMonthlyRepeatsOn = $sanitizedParams->getInt(
'recurrenceMonthlyRepeatsOn',
['default' => 0]
);

foreach ($sanitizedParams->getIntArray('displayGroupIds', ['default' => []]) as $displayGroupId) {
$schedule->assignDisplayGroup($this->displayGroupFactory->getById($displayGroupId));
Expand Down Expand Up @@ -1348,14 +1358,20 @@ function editForm(Request $request, Response $response, $id)
$schedule->fromDt = '';
$schedule->toDt = '';
} else {
$schedule->fromDt = Carbon::createFromTimestamp($schedule->fromDt)->format(DateFormatHelper::getSystemFormat());
$schedule->fromDt =
Carbon::createFromTimestamp($schedule->fromDt)
->format(DateFormatHelper::getSystemFormat());
if ($schedule->toDt != null) {
$schedule->toDt = Carbon::createFromTimestamp($schedule->toDt)->format(DateFormatHelper::getSystemFormat());
$schedule->toDt =
Carbon::createFromTimestamp($schedule->toDt)
->format(DateFormatHelper::getSystemFormat());
}
}

if ($schedule->recurrenceRange != null) {
$schedule->recurrenceRange = Carbon::createFromTimestamp($schedule->recurrenceRange)->format(DateFormatHelper::getSystemFormat());
$schedule->recurrenceRange =
Carbon::createFromTimestamp($schedule->recurrenceRange)
->format(DateFormatHelper::getSystemFormat());
}
// Get all reminders
$scheduleReminders = $this->scheduleReminderFactory->query(null, ['eventId' => $id]);
Expand Down Expand Up @@ -1383,19 +1399,22 @@ function editForm(Request $request, Response $response, $id)
$this->getState()->template = 'schedule-form-edit';
$this->getState()->setData([
'event' => $schedule,
'campaigns' => $this->campaignFactory->query(null, ['isLayoutSpecific' => -1, 'retired' => 0, 'includeCampaignId' => $schedule->campaignId]),
'campaigns' => $this->campaignFactory->query(
null,
['isLayoutSpecific' => -1, 'retired' => 0, 'includeCampaignId' => $schedule->campaignId]
),
'commands' => $this->commandFactory->query(),
'dayParts' => $this->dayPartFactory->allWithSystem(),
'displayGroups' => $schedule->displayGroups,
'campaign' => ($schedule->campaignId != '') ? $this->campaignFactory->getById($schedule->campaignId) : null,
'displayGroupIds' => array_map(function($element) {
'displayGroupIds' => array_map(function ($element) {
return $element->displayGroupId;
}, $schedule->displayGroups),
'layoutCodes' => $this->layoutFactory->getLayoutCodes(),
'reminders' => $scheduleReminders,
'defaultLat' => $defaultLat,
'defaultLong' => $defaultLong,
'recurringEvent' => ($schedule->recurrenceType != '') ? true : false,
'recurringEvent' => $schedule->recurrenceType != '',
'eventStart' => $eventStart,
'eventEnd' => $eventEnd,
'eventTypes' => \Xibo\Entity\Schedule::getEventTypesForm(),
Expand All @@ -1415,7 +1434,7 @@ function editForm(Request $request, Response $response, $id)
* @throws NotFoundException
* @throws ControllerNotImplemented
*/
function deleteRecurrenceForm(Request $request, Response $response, $id)
public function deleteRecurrenceForm(Request $request, Response $response, $id)
{
$sanitizedParams = $this->getSanitizer($request->getParams());
// Recurring event start/end
Expand Down Expand Up @@ -1521,14 +1540,16 @@ public function deleteRecurrence(Request $request, Response $response, $id)
* @SWG\Parameter(
* name="eventTypeId",
* in="formData",
* description="The Event Type Id to use for this Event. 1=Layout, 2=Command, 3=Overlay, 4=Interrupt, 5=Campaign, 6=Action",
* description="The Event Type Id to use for this Event.
* 1=Layout, 2=Command, 3=Overlay, 4=Interrupt, 5=Campaign, 6=Action",
* type="integer",
* required=true
* ),
* @SWG\Parameter(
* name="campaignId",
* in="formData",
* description="The Campaign ID to use for this Event. If a Layout is needed then the Campaign specific ID for that Layout should be used.",
* description="The Campaign ID to use for this Event.
* If a Layout is needed then the Campaign specific ID for that Layout should be used.",
* type="integer",
* required=false
* ),
Expand Down Expand Up @@ -1556,7 +1577,8 @@ public function deleteRecurrence(Request $request, Response $response, $id)
* @SWG\Parameter(
* name="displayGroupIds",
* in="formData",
* description="The Display Group IDs for this event. Display specific Group IDs should be used to schedule on single displays.",
* description="The Display Group IDs for this event.
* Display specific Group IDs should be used to schedule on single displays.",
* type="array",
* required=true,
* @SWG\Items(type="integer")
Expand Down Expand Up @@ -1703,16 +1725,19 @@ public function edit(Request $request, Response $response, $id)
? $sanitizedParams->getInt('fullScreenCampaignId')
: $sanitizedParams->getInt('campaignId');
$schedule->commandId = $sanitizedParams->getInt('commandId');
$schedule->displayOrder = $sanitizedParams->getInt('displayOrder',['default' => $schedule->displayOrder]);
$schedule->displayOrder = $sanitizedParams->getInt('displayOrder', ['default' => $schedule->displayOrder]);
$schedule->isPriority = $sanitizedParams->getInt('isPriority', ['default' => $schedule->isPriority]);
$schedule->dayPartId = $sanitizedParams->getInt('dayPartId',['default' => $schedule->dayPartId]);
$schedule->dayPartId = $sanitizedParams->getInt('dayPartId', ['default' => $schedule->dayPartId]);
$schedule->syncTimezone = $sanitizedParams->getCheckbox('syncTimezone');
$schedule->syncEvent = $this->isSyncEvent($schedule->eventTypeId);
$schedule->recurrenceType = $sanitizedParams->getString('recurrenceType');
$schedule->recurrenceDetail = $sanitizedParams->getInt('recurrenceDetail');
$recurrenceRepeatsOn = $sanitizedParams->getIntArray('recurrenceRepeatsOn');
$schedule->recurrenceRepeatsOn = (empty($recurrenceRepeatsOn)) ? null : implode(',', $recurrenceRepeatsOn);
$schedule->recurrenceMonthlyRepeatsOn = $sanitizedParams->getInt('recurrenceMonthlyRepeatsOn', ['default' => 0]);
$schedule->recurrenceMonthlyRepeatsOn = $sanitizedParams->getInt(
'recurrenceMonthlyRepeatsOn',
['default' => 0]
);
$schedule->displayGroups = [];
$schedule->isGeoAware = $sanitizedParams->getCheckbox('isGeoAware');
$schedule->actionType = $sanitizedParams->getString('actionType');
Expand Down Expand Up @@ -1787,9 +1812,12 @@ public function edit(Request $request, Response $response, $id)
throw new InvalidArgumentException(__('Please enter a from date'). 'fromDt');
}

$logToDt = isset($toDt) ? $toDt->format(DateFormatHelper::getSystemFormat()) : null;
$logRecurrenceRange = isset($recurrenceRange) ? $recurrenceRange->format(DateFormatHelper::getSystemFormat()) : null;
$this->getLog()->debug('Times received are: FromDt=' . $fromDt->format(DateFormatHelper::getSystemFormat()) . '. ToDt=' . $logToDt . '. recurrenceRange=' . $logRecurrenceRange);
$logToDt = $toDt?->format(DateFormatHelper::getSystemFormat());
$logRecurrenceRange = $recurrenceRange?->format(DateFormatHelper::getSystemFormat());
$this->getLog()->debug(
'Times received are: FromDt=' . $fromDt->format(DateFormatHelper::getSystemFormat())
. '. ToDt=' . $logToDt . '. recurrenceRange=' . $logRecurrenceRange
);

if (!$schedule->isCustomDayPart() && !$schedule->isAlwaysDayPart()) {
// Daypart selected
Expand All @@ -1810,7 +1838,9 @@ public function edit(Request $request, Response $response, $id)
$schedule->toDt = $toDt->setTime($toDt->hour, $toDt->minute, 0)->format('U');
}

$schedule->recurrenceRange = ($recurrenceRange === null) ? null : $recurrenceRange->setTime($recurrenceRange->hour, $recurrenceRange->minute, 0)->format('U');
$schedule->recurrenceRange = ($recurrenceRange === null)
? null
: $recurrenceRange->setTime($recurrenceRange->hour, $recurrenceRange->minute, 0)->format('U');
} else {
$schedule->fromDt = $fromDt->format('U');

Expand Down

0 comments on commit 7583d0a

Please sign in to comment.