[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [friendsofphp/php-cs-fixer](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer) | `<3.51.1` -> `<3.53.1` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>PHP-CS-Fixer/PHP-CS-Fixer (friendsofphp/php-cs-fixer)</summary> ### [`v3.53.0`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3530) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.52.1...v3.53.0) - chore: Use `list` over `array` in more places ([#​7905](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7905)) - CI: allow for self-approvals for maintainers ([#​7921](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7921)) - CI: Improve Infection setup ([#​7913](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7913)) - CI: no need to trigger enable auto-merge when self-approve ([#​7929](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7929)) - DX: reduce `array_filter` function usages ([#​7923](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7923)) - DX: remove duplicated character from `trim` call ([#​7930](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7930)) - DX: update actions producing warnings ([#​7925](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7925)) - DX: update actions producing warnings ([#​7928](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7928)) - DX: update `phpstan/phpstan-strict-rules` ([#​7924](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7924)) - feat: Add trailing comma in multiline to PER-CS 2.0 ([#​7916](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7916)) - feat: Introduce `AttributeAnalysis` ([#​7909](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7909)) - feat: `@PHP84Migration` introduction ([#​7774](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7774)) - fix: Constant invocation detected in typed constants ([#​7892](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7892)) - fix: `PhpdocArrayTypeFixer` - JIT stack limit exhausted ([#​7895](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7895)) - test: Introduce Infection for mutation tests ([#​7874](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7874)) ### [`v3.52.1`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3521) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.52.0...v3.52.1) - fix: StatementIndentationFixer - do not crash on ternary operator in class property ([#​7899](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7899)) - fix: `PhpCsFixer\Tokenizer\Tokens::setSize` return type ([#​7900](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7900)) ### [`v3.52.0`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3520) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.51.0...v3.52.0) - chore: fix PHP 8.4 deprecations ([#​7894](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7894)) - chore: fix PHPStan 1.10.60 issues ([#​7873](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7873)) - chore: list over array in more places ([#​7876](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7876)) - chore: replace template with variable in Preg class ([#​7882](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7882)) - chore: update PHPStan ([#​7871](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7871)) - depr: `nullable_type_declaration_for_default_null_value` - deprecate option that is against `@PHP84Migration` ([#​7872](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7872)) - docs: Fix typo ([#​7889](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7889)) - feat: Add support for callable template in PHPDoc parser ([#​7084](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7084)) - feat: Add `array_indentation` to `PER-CS2.0` ruleset ([#​7881](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7881)) - feat: `@Symfony:risky` - add `no_unreachable_default_argument_value` ([#​7863](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7863)) - feat: `PhpCsFixer` ruleset - enable `nullable_type_declaration_for_default_null_value` ([#​7870](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7870)) - fix: Constant invocation detected in DNF types ([#​7869](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7869)) - fix: Correctly indent multiline constants and properties ([#​7875](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7875)) - fix: `no_useless_concat_operator` - do not break variable ([#​7827](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7827)) - fix: `TokensAnalyzer` - handle unary operator in arrow functions ([#​7862](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7862)) - fix: `TypeExpression` - fix "JIT stack limit exhausted" error ([#​7843](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7843)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/libretime/libretime). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNDUuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: jo <ljonas@riseup.net>
219 lines
7.4 KiB
PHP
219 lines
7.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Skeleton subclass for representing a row from the 'cc_show_instances' table.
|
|
*
|
|
* You should add additional methods to this class to meet the
|
|
* application requirements. This class will only be generated as
|
|
* long as it does not already exist in the output directory.
|
|
*/
|
|
class CcShowInstances extends BaseCcShowInstances
|
|
{
|
|
/**
|
|
* Get the [optionally formatted] temporal [starts] column value.
|
|
*
|
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
|
* If format is NULL, then the raw DateTime object will be returned.
|
|
*
|
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
|
*
|
|
* @throws propelException - if unable to parse/validate the date/time value
|
|
*/
|
|
public function getDbStarts($format = 'Y-m-d H:i:s')
|
|
{
|
|
if ($this->starts === null) {
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
$dt = new DateTime($this->starts, new DateTimeZone('UTC'));
|
|
} catch (Exception $x) {
|
|
throw new PropelException('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->starts, true), $x);
|
|
}
|
|
|
|
if ($format === null) {
|
|
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
|
return $dt;
|
|
}
|
|
if (strpos($format, '%') !== false) {
|
|
return strftime($format, $dt->format('U'));
|
|
}
|
|
|
|
return $dt->format($format);
|
|
}
|
|
|
|
/**
|
|
* Get the [optionally formatted] temporal [ends] column value.
|
|
*
|
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
|
* If format is NULL, then the raw DateTime object will be returned.
|
|
*
|
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
|
*
|
|
* @throws propelException - if unable to parse/validate the date/time value
|
|
*/
|
|
public function getDbEnds($format = 'Y-m-d H:i:s')
|
|
{
|
|
if ($this->ends === null) {
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
$dt = new DateTime($this->ends, new DateTimeZone('UTC'));
|
|
} catch (Exception $x) {
|
|
throw new PropelException('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->ends, true), $x);
|
|
}
|
|
|
|
if ($format === null) {
|
|
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
|
return $dt;
|
|
}
|
|
if (strpos($format, '%') !== false) {
|
|
return strftime($format, $dt->format('U'));
|
|
}
|
|
|
|
return $dt->format($format);
|
|
}
|
|
|
|
/**
|
|
* Get the [optionally formatted] temporal [last_scheduled] column value.
|
|
*
|
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
|
* If format is NULL, then the raw DateTime object will be returned.
|
|
*
|
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
|
*
|
|
* @throws propelException - if unable to parse/validate the date/time value
|
|
*/
|
|
public function getDbLastScheduled($format = 'Y-m-d H:i:s')
|
|
{
|
|
if ($this->last_scheduled === null) {
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
$dt = new DateTime($this->last_scheduled, new DateTimeZone('UTC'));
|
|
} catch (Exception $x) {
|
|
throw new PropelException('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->last_scheduled, true), $x);
|
|
}
|
|
|
|
if ($format === null) {
|
|
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
|
return $dt;
|
|
}
|
|
if (strpos($format, '%') !== false) {
|
|
return strftime($format, $dt->format('U'));
|
|
}
|
|
|
|
return $dt->format($format);
|
|
}
|
|
|
|
// post save hook to update the cc_schedule status column for the tracks in the show.
|
|
public function updateScheduleStatus(PropelPDO $con)
|
|
{
|
|
$this->updateDbTimeFilled($con);
|
|
|
|
// scheduled track is in the show
|
|
CcScheduleQuery::create()
|
|
->filterByDbInstanceId($this->id)
|
|
->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)
|
|
->filterByDbEnds($this->ends, Criteria::LESS_EQUAL)
|
|
->update(['DbPlayoutStatus' => 1], $con);
|
|
|
|
// scheduled track is a boundary track
|
|
CcScheduleQuery::create()
|
|
->filterByDbInstanceId($this->id)
|
|
->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)
|
|
->filterByDbStarts($this->ends, Criteria::LESS_THAN)
|
|
->filterByDbEnds($this->ends, Criteria::GREATER_THAN)
|
|
->update(['DbPlayoutStatus' => 2], $con);
|
|
|
|
// scheduled track is overbooked.
|
|
CcScheduleQuery::create()
|
|
->filterByDbInstanceId($this->id)
|
|
->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)
|
|
->filterByDbStarts($this->ends, Criteria::GREATER_THAN)
|
|
->update(['DbPlayoutStatus' => 0], $con);
|
|
|
|
$this->setDbLastScheduled(gmdate('Y-m-d H:i:s'));
|
|
$this->save($con);
|
|
}
|
|
|
|
/**
|
|
* This function resets the cc_schedule table's position numbers so that
|
|
* tracks for each cc_show_instances start at position 1.
|
|
*
|
|
* The position numbers can become out of sync when the user deletes items
|
|
* from linekd shows filled with dyanmic smart blocks, where each instance
|
|
* has a different amount of scheduled items
|
|
*/
|
|
public function correctSchedulePositions()
|
|
{
|
|
$schedule = CcScheduleQuery::create()
|
|
->filterByDbInstanceId($this->id)
|
|
->orderByDbStarts()
|
|
->find();
|
|
|
|
$pos = 0;
|
|
foreach ($schedule as $item) {
|
|
$item->setDbPosition($pos)->save();
|
|
++$pos;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Computes the value of the aggregate column time_filled.
|
|
*
|
|
* @param PropelPDO $con A connection object
|
|
*
|
|
* @return mixed The scalar result from the aggregate query
|
|
*/
|
|
public function computeDbTimeFilled(PropelPDO $con)
|
|
{
|
|
$stmt = $con->prepare('SELECT SUM(clip_length) FROM "cc_schedule" WHERE cc_schedule.INSTANCE_ID = :p1');
|
|
$stmt->bindValue(':p1', $this->getDbId());
|
|
$stmt->execute();
|
|
|
|
return $stmt->fetchColumn();
|
|
}
|
|
|
|
/**
|
|
* Updates the aggregate column time_filled.
|
|
*
|
|
* @param PropelPDO $con A connection object
|
|
*/
|
|
public function updateDbTimeFilled(PropelPDO $con)
|
|
{
|
|
$timefilled = $this->computeDbTimeFilled($con);
|
|
if (is_null($timefilled)) {
|
|
$timefilled = '00:00:00';
|
|
}
|
|
$this->setDbTimeFilled($timefilled);
|
|
$this->save($con);
|
|
}
|
|
|
|
public function preInsert(?PropelPDO $con = null)
|
|
{
|
|
$now = new DateTime('now', new DateTimeZone('UTC'));
|
|
$this->setDbCreated($now);
|
|
|
|
return true;
|
|
}
|
|
|
|
public function isRecorded()
|
|
{
|
|
return $this->getDbRecord() == 1 ? true : false;
|
|
}
|
|
|
|
public function isRebroadcast()
|
|
{
|
|
return $this->getDbRebroadcast() == 1 ? true : false;
|
|
}
|
|
|
|
public function getLocalStartDateTime()
|
|
{
|
|
$startDT = $this->getDbStarts(null);
|
|
|
|
return $startDT->setTimezone(new DateTimeZone(Application_Model_Preference::GetTimezone()));
|
|
}
|
|
} // CcShowInstances
|