Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Element.php
1<?php
10
16
24final class Element extends Controller implements FallbackActionInterface
25{
26 protected $iblock;
27
28 protected function getDefaultPreFilters()
29 {
30 return [];
31 }
32
42 public function fallbackAction($actionName)
43 {
44 $this->setSourceParametersList(array_merge(
45 $this->getSourceParametersList(), [['iblock' => $this->getIblock()]]
46 ));
47
48 return $this->forward($this->getController(), $actionName);
49 }
50
55 protected function getController()
56 {
57 $iblock = $this->getIblock();
58
59 $serviceLocator = ServiceLocator::getInstance();
60 $serviceId = "iblock.element.{$iblock->getApiCode()}.rest.controller";
61
62 if ($serviceLocator->has($serviceId))
63 {
64 // get from service locator
65 $controller = $serviceLocator->get($serviceId);
66 }
67 else
68 {
69 $controller = DefaultElement::class;
70 }
71
72 return $controller;
73 }
74
75 protected function getIblock()
76 {
77 if ($this->iblock === null)
78 {
79 $iblockId = Application::getInstance()->getContext()->getRequest()->get('iblockId');
80
81 $this->iblock = IblockTable::getByPrimary($iblockId, [
82 'select' => ['ID', 'API_CODE']
83 ])->fetchObject();
84 }
85
86 return $this->iblock;
87 }
88}
setSourceParametersList($sourceParametersList)
forward($controller, string $actionName, array $parameters=null)
static getByPrimary($primary, array $parameters=array())