Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
action.php
1<?php
9
13
14
15Loc::loadMessages(__FILE__);
16
17class Action extends Base
18{
20 protected $name;
21
23 protected $contentType;
24
26 protected $handler;
27
30
36 public static function create($name)
37 {
38 return new static($name);
39 }
40
46 public function __construct($name, $handler = null)
47 {
48 $this->name = $name;
49 if ($handler)
50 {
51 $this->setHandler($handler);
52 }
53 }
54
60 public function getName()
61 {
62 return $this->name;
63 }
64
72 public function setHandler($handler)
73 {
74 if (!is_callable($handler))
75 {
76 throw new ArgumentException("Argument 'handler' should be callabe.");
77 }
78
79 $this->handler = $handler;
80 return $this;
81 }
82
88 public function getRequestMethod()
89 {
91 }
92
98 public function setRequestMethodGet()
99 {
100 $this->requestMethod = Listener::REQUEST_METHOD_GET;
101 return $this;
102 }
103
111 public function run(HttpRequest $request, Response $response)
112 {
113 if (!$this->handler)
114 {
115 return;
116 }
117
118 static::call($this->handler, array($request, $response));
119 }
120}
static loadMessages($file)
Definition loc.php:64
run(HttpRequest $request, Response $response)
Definition action.php:111