Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
SortBlockAction.php
1<?php
2
4
6
8{
9 protected const JS_COMMAND = 'sortBlock';
10
11 public function execute(bool $undo = true): bool
12 {
13 $up = (bool)$this->params['up'];
14 $blockId = (int)$this->params['block'];
15 $landing = Landing::createInstance($this->params['lid']);
16 if ($landing->exist())
17 {
18 return ($up === $undo)
19 ? $landing->downBlock($blockId)
20 : $landing->upBlock($blockId)
21 ;
22 }
23
24 return false;
25 }
26
27 public static function enrichParams(array $params): array
28 {
29 return [
30 'block' => (int)$params['block'],
31 'lid' => (int)$params['lid'],
32 'up' => (bool)$params['up'],
33 ];
34 }
35
40 public function getJsCommand(bool $undo = true): array
41 {
42 $params = parent::getJsCommand($undo);
43 $params['params']['direction'] =
44 ($params['params']['up'] === $undo)
45 ? 'moveDown'
46 : 'moveUp'
47 ;
48 unset(
49 $params['params']['lid'],
50 $params['params']['up'],
51 );
52
53 return $params;
54 }
55}
static createInstance($id, array $params=array())
Definition landing.php:534