BEdita API doc | 4-cactus
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Download

Namespaces

  • BEdita
    • API
      • Auth
      • Controller
        • Admin
        • Component
        • Model
      • Error
      • Event
      • Exception
      • Middleware
      • Model
        • Action
      • Network
        • Exception
      • Shell
      • TestSuite
      • Utility
    • Core
      • Configure
        • Engine
      • Database
        • Type
      • Exception
      • Filesystem
        • Adapter
        • Exception
        • Thumbnail
      • I18n
      • Job
        • Service
      • Mailer
        • Preview
        • Transport
      • Model
        • Action
        • Behavior
        • Entity
        • Table
        • Validation
      • ORM
        • Inheritance
        • Locator
        • Rule
      • Shell
        • Task
      • State
      • TestSuite
        • Fixture
      • Utility

Classes

  • Annotation
  • Application
  • AsyncJob
  • AuthProvider
  • Category
  • DateRange
  • ExternalAuth
  • History
  • Link
  • Location
  • ObjectCategory
  • ObjectEntity
  • ObjectPermission
  • ObjectProperty
  • ObjectRelation
  • Profile
  • Property
  • PropertyType
  • Publication
  • Relation
  • RelationType
  • Role
  • RolesUser
  • Stream
  • Tag
  • Translation
  • Tree
  • UserToken

Traits

  • JsonApiAdminTrait
  • JsonApiModelTrait

Class DateRange

DateRange Entity

Cake\ORM\Entity
Extended by BEdita\Core\Model\Entity\DateRange
Namespace: BEdita\Core\Model\Entity
Located at Core/src/Model/Entity/DateRange.php

Methods summary

public boolean
# isBefore( BEdita\Core\Model\Entity\DateRange $dateRange )

Check if this Date Range is before the passed Date Range.

Check if this Date Range is before the passed Date Range.

A Date Range is "before" another Date Range if its end_date is lower than, or equal, to the other Date Range's start_date. If end_date is null, for this purpose it assumes the same value as start_date.

Warning: this method does not take params into account.

Parameters

$dateRange
Date Range being compared.

Returns

boolean
public boolean
# isAfter( BEdita\Core\Model\Entity\DateRange $dateRange )

Check if this Date Range is after the passed Date Range.

Check if this Date Range is after the passed Date Range.

A Date Range is "after" another Date Range if its start_date is greater than, or equal, to the other Date Range's end_date. If end_date is null, for this purpose it assumes the same value as start_date.

Warning: this method does not take params into account.

Parameters

$dateRange
Date Range being compared.

Returns

boolean
public static BEdita\Core\Model\Entity\DateRange[]
# normalize( array $dateRanges )

Normalize an array of Date Ranges by sorting and joining overlapping Date Ranges.

Normalize an array of Date Ranges by sorting and joining overlapping Date Ranges.

Normalization sorts Date Ranges in a set by start_date in ascending order. Also, if two or more Date Ranges do overlap, or are adjacent (i.e. $d1->end_date === $d2->start_date), they are merged in one Date Range. Duplicate Date Ranges are removed.

Warning: this method does not take params into account.

Parameters

$dateRanges
Set of Date Ranges.

Returns

BEdita\Core\Model\Entity\DateRange[]
public static BEdita\Core\Model\Entity\DateRange[]
# union( ... $dateRanges )

Compute union of multiple sets of Date Ranges.

Compute union of multiple sets of Date Ranges.

This method computes union of multiple sets of Date Ranges. The result is returned in normalized form.

Warning: this method does not take params into account.

Parameters

$dateRanges
$dateRanges Set of Date Ranges.

Returns

BEdita\Core\Model\Entity\DateRange[]
public static BEdita\Core\Model\Entity\DateRange[]
# diff( array $array1, array $array2 )

Compute difference between two sets of Date Ranges.

Compute difference between two sets of Date Ranges.

When computing complement of $array1 with respect to $array2: - Date Ranges with end_date = null are treated as unit sets, all other Date Ranges are considered intervals. - complement of an interval with respect to another interval results in the difference of the two sets. - complement of an interval with respect to a unit set results in the interval unmodified. - complement of a unit sets with respect to an interval results in either the unit set unmodified if they are not overlapping, or in the empty set otherwise. - complement of a unit sets with respect to another unit set results in either the unit set unmodified if they are not the same, or in the empty set otherwise.

Warning: this method does not take params into account.

Example

$array1 = [new DateRange(['start_date' => new Time('2017-01-01 00:00:00'), 'end_date' => new Time('2017-01-31 12:59:59')])];
$array2 = [new DateRange(['start_date' => new Time('2017-01-10 00:00:00'), 'end_date' => new Time('2017-01-19 12:59:59')])];

$diff = DateRange::diff($array1, $array2);

// $diff will now be equivalent to:
$diff = [
    new DateRange(['start_date' => new Time('2017-01-10 00:00:00'), 'end_date' => new Time('2017-01-10 00:00:00')]),
    new DateRange(['start_date' => new Time('2017-01-19 12:59:59'), 'end_date' => new Time('2017-01-19 12:59:59')]),
];

Parameters

$array1
First set of Date Ranges.
$array2
Second set of Date Ranges.

Returns

BEdita\Core\Model\Entity\DateRange[]
public static
# checkWellFormed( ... $dateRanges )

Check that all the Date Ranges passed as arguments are actually well formed.

Check that all the Date Ranges passed as arguments are actually well formed.

A "well formed" Date Range is an instance of class BEdita\Core\Model\Entity\DateRange whose field start_date is an instance of Cake\I18n\Time and field end_date is either null or an instance of Cake\I18n\Time.

Parameters

$dateRanges
$dateRanges Date Ranges to check.

Throws

LogicException
Throws an exception if a malformed Date Range is encountered.

Properties summary

protected array $_accessible
# [ '*' => true, 'id' => false ]
protected array $_hidden
# [ 'id', 'object_id', ]

Magic properties

public integer $id
public integer $object_id
public DateTimeInterface $start_date
public DateTimeInterface|null $end_date
public array $params
public BEdita\Core\Model\Entity\ObjectEntity $object
BEdita API doc | 4-cactus API documentation generated by ApiGen