Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
instancemap.php
1<?php
2
4
7
8class InstanceMap extends Map
9{
10 public const DATE_FORMAT_FOR_KEY = 'Ymd';
11
16 public static function getKeyByDate(Date $originalDate): string
17 {
18 return $originalDate->format(self::DATE_FORMAT_FOR_KEY);
19 }
20
27 public function add($item, $key = null): self
28 {
30 if ($key === null)
31 {
32 if ($date = $item->getEvent()->getOriginalDateFrom())
33 {
34 $key = self::getKeyByDate($date);
35 }
36 else
37 {
38 $key = self::getKeyByDate($item->getEvent()->getStart());
39 }
40 }
41
42 parent::add($item, $key);
43
44 return $this;
45 }
46
50 public function addItems(array $items): self
51 {
52 foreach ($items as $item)
53 {
54 $this->add($item);
55 }
56
57 return $this;
58 }
59}
format(string $format=null)
Definition date.php:107
add($item, $key=null)
Definition map.php:20
static getKeyByDate(Date $originalDate)