Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
fieldcollection.php
1<?php
2
4
7
14{
16 protected $items = [];
17
24 public function addItem($field): int
25 {
26 if(!($field instanceof Field))
27 {
28 throw new ArgumentTypeException('field must be the instance of Field');
29 }
30
31 $result = parent::addItem($field);
32
33 /*
34 * Sort fields due to sort
35 * @todo: what about performance?
36 */
37 usort(
38 $this->items,
39 function (Field $a, Field $b)
40 {
41 if ($a->getSort() === $b->getSort())
42 {
43 return 0;
44 }
45
46 return ($a->getSort() < $b->getSort()) ? -1 : 1;
47 }
48 );
49
50 return $result;
51 }
52}