How to use checkMethod method of controller class

Best Atoum code snippet using controller.checkMethod

BaseController.php

Source:BaseController.php Github

copy

Full Screen

...69 throw $ex;70 }71 /**72 * Добавить обработчик перед вызовом основного метода контроллера73 * @param string $checkMethod - название метода проверки74 * @throws75 *76 * ПРИМЕЧАНИЕ:77 * Если метод возвращает тип bool, то учитывается его результат.78 * В противном случае, результат игнорируется.79 */80 final protected function appendBeforeAction(string $checkMethod) {81 if (empty($checkMethod) || !method_exists($this, $checkMethod))82 throw new ErrorController($this->controllerName(), __FUNCTION__, "", "Not found check method (name: $checkMethod)!", "before-action");83 if (!in_array($checkMethod, $this->_beforeActions))84 $this->_beforeActions[] = $checkMethod;85 }86 /**87 * Добавить обработчик в начало очереди перед вызовом основного метода контроллера88 * @param string $checkMethod - название метода проверки89 * @throws90 *91 * ПРИМЕЧАНИЕ:92 * Если метод возвращает тип bool, то учитывается его результат.93 * В противном случае, результат игнорируется.94 */95 final protected function prependBeforeAction(string $checkMethod) {96 if (empty($checkMethod) || !method_exists($this, $checkMethod))97 throw new ErrorController($this->controllerName(), __FUNCTION__, "", "Not found check method (name: $checkMethod)!", "before-action");98 if (!in_array($checkMethod, $this->_beforeActions))99 array_unshift($this->_beforeActions, $checkMethod);100 }101 /**102 * Исключить обработчик перед вызовом основного метода контроллера103 * @param string $checkMethod - название метода проверки104 * @param string|array $action - метод (список методов), который будет игнорироваться обработчиком105 * @throws106 */107 final protected function skipBeforeAction(string $checkMethod, /*string|array*/ $action) {108 if (empty($checkMethod) || !method_exists($this, $checkMethod))109 throw new ErrorController($this->controllerName(), __FUNCTION__, "", "Not found check method (name: $checkMethod)!", "before-action");110 if (!is_string($action) && !is_array($action))111 throw new ErrorController($this->controllerName(), __FUNCTION__, "", "Invalid action type (only string or array[string])!", "before-action");112 if (is_string($action)) {113 $this->skipBeforeActionPr($checkMethod, $action);114 } else {115 foreach ($action as $act)116 $this->skipBeforeActionPr($checkMethod, strval($act));117 }118 }119 /**120 * Добавить обработчик после вызова основного метода контроллера121 * @param string $checkMethod - название метода проверки122 * @throws123 *124 * ПРИМЕЧАНИЕ:125 * Если метод возвращает тип bool, то учитывается его результат.126 * В противном случае, результат игнорируется.127 */128 final protected function appendAfterAction(string $checkMethod) {129 if (empty($checkMethod) || !method_exists($this, $checkMethod))130 throw new ErrorController($this->controllerName(), __FUNCTION__, "", "Not found check method (name: $checkMethod)!", "after-action");131 if (!in_array($checkMethod, $this->_afterActions))132 $this->_afterActions[] = $checkMethod;133 }134 /**135 * Добавить обработчик в начало очереди после вызова основного метода контроллера136 * @param string $checkMethod - название метода проверки137 * @throws138 *139 * ПРИМЕЧАНИЕ:140 * Если метод возвращает тип bool, то учитывается его результат.141 * В противном случае, результат игнорируется.142 */143 final protected function prependAfterAction(string $checkMethod) {144 if (empty($checkMethod) || !method_exists($this, $checkMethod))145 throw new ErrorController($this->controllerName(), __FUNCTION__, "", "Not found check method (name: $checkMethod)!", "after-action");146 if (!in_array($checkMethod, $this->_afterActions))147 array_unshift($this->_afterActions, $checkMethod);148 }149 /**150 * Исключить обработчик после вызова основного метода контроллера151 * @param string $checkMethod - название метода проверки152 * @param string|array $action - метод (список методов), который будет игнорироваться обработчиком153 * @throws154 */155 final protected function skipAfterAction(string $checkMethod, /*string|array*/ $action) {156 if (empty($checkMethod) || !method_exists($this, $checkMethod))157 throw new ErrorController($this->controllerName(), __FUNCTION__, "", "Not found check method (name: $checkMethod)!", "after-action");158 if (!is_string($action) && !is_array($action))159 throw new ErrorController($this->controllerName(), __FUNCTION__, "", "Invalid action type (only string or array[string])!", "after-action");160 if (is_string($action)) {161 $this->skipAfterActionPr($checkMethod, $action);162 } else {163 foreach ($action as $act)164 $this->skipAfterActionPr($checkMethod, strval($act));165 }166 }167 /**168 * Вызов обработчиков проверок перед основным методом контроллера169 * @param string $action - название текущего экшена контроллера170 * @return bool171 */172 final protected function processingBeforeAction(string $action): bool {173 $tmpSkip = array();174 if (isset($this->_skipBeforeActions[$action]))175 $tmpSkip = $this->_skipBeforeActions[$action];176 foreach ($this->_beforeActions as $item) {177 if (in_array($item, $tmpSkip))178 continue;179 $res = $this->$item();180 if (is_bool($res) && $res === false)181 return false;182 }183 return true;184 }185 /**186 * Вызов обработчиков проверок после основного метода контроллера187 * @param string $action - название текущего экшена контроллера188 * @return bool189 */190 final protected function processingAfterAction(string $action): bool {191 $tmpSkip = array();192 if (isset($this->_skipAfterActions[$action]))193 $tmpSkip = $this->_skipAfterActions[$action];194 foreach ($this->_afterActions as $item) {195 if (in_array($item, $tmpSkip))196 continue;197 $res = $this->$item();198 if (is_bool($res) && $res === false)199 return false;200 }201 return true;202 }203 /**204 * Имя текущего контроллера205 * @return string206 * @throws207 */208 final protected function controllerName(): string {209 $tmpName = $this->controllerClassName();210 if (preg_match("/.*Controller$/", $tmpName))211 $tmpName = substr($tmpName, 0, strlen($tmpName) - 10);212 return $tmpName;213 }214 /**215 * Имя класса текущего контроллера216 * @return string217 * @throws218 */219 final protected function controllerClassName(): string {220 $tmpRef = null;221 try {222 $tmpRef = new \ReflectionClass($this);223 } catch (\Exception $e) {224 throw new ErrorController("BaseController", __FUNCTION__, "", $e->getMessage(), "controller-base");225 }226 $tmpName = $tmpRef->getName();227 unset($tmpRef);228 return $tmpName;229 }230 /**231 * Каталог текущего контроллера232 * @return string233 * @throws234 */235 final protected function controllerDirectory(): string {236 $tmpRef = null;237 try {238 $tmpRef = new \ReflectionClass($this);239 } catch (\Exception $e) {240 throw new ErrorController("BaseController", __FUNCTION__, "", $e->getMessage(), "controller-base");241 }242 $tmpPathLst = explode(DIRECTORY_SEPARATOR, $tmpRef->getFilename());243 unset($tmpRef);244 if (count($tmpPathLst) >= 2) {245 array_pop($tmpPathLst); // remove file-name246 array_pop($tmpPathLst); // remove controllers-dir-name247 }248 return CoreHelper::buildAppPath($tmpPathLst);249 }250 /**251 * Метод верификации токена аутентификации252 * @throws253 * @private254 */255 final private function verifyAuthenticityToken() {256 try {257 $isSuccess = RequestForgeryProtection::instance()->isVerifiedRequest();258 } catch (\Exception $e) {259 throw new ErrorController($this->controllerName(), __FUNCTION__, "", $e->getMessage(), "verify-authenticity-token");260 }261 if (!$isSuccess) {262 $curRoute = RouteCollector::instance()->currentRoute();263 throw new ErrorController($this->controllerName(), __FUNCTION__, $curRoute->action(), "Invalid Authenticity Token!", "verify-authenticity-token");264 }265 }266 /**267 * Исключить обработчик перед вызовом основного метода контроллера268 * @param string $checkMethod - название метода проверки269 * @param string $action - метод, который будет игнорироваться обработчиком270 * @throws271 * @private272 */273 final private function skipBeforeActionPr(string $checkMethod, string $action) {274 if (empty($action) || !method_exists($this, $action))275 throw ErrorController::makeError([276 'tag' => "before-action",277 'controller' => $this->controllerName(),278 'method' => __FUNCTION__,279 'action' => "",280 'message' => "Not found action (name: $action)!",281 'backtrace-shift' => 2282 ]);283 $tmpSkip = array();284 if (isset($this->_skipBeforeActions[$action]))285 $tmpSkip = $this->_skipBeforeActions[$action];286 if (!in_array($checkMethod, $tmpSkip))287 $tmpSkip[] = $checkMethod;288 $this->_skipBeforeActions[$action] = $tmpSkip;289 }290 /**291 * Исключить обработчик после вызова основного метода контроллера292 * @param string $checkMethod - название метода проверки293 * @param string $action - метод, который будет игнорироваться обработчиком294 * @throws295 * @private296 */297 final private function skipAfterActionPr(string $checkMethod, string $action) {298 if (empty($action) || !method_exists($this, $action))299 throw ErrorController::makeError([300 'tag' => "after-action",301 'controller' => $this->controllerName(),302 'method' => __FUNCTION__,303 'action' => "",304 'message' => "Not found action (name: $action)!",305 'backtrace-shift' => 2306 ]);307 $tmpSkip = array();308 if (isset($this->_skipAfterActions[$action]))309 $tmpSkip = $this->_skipAfterActions[$action];310 if (!in_array($checkMethod, $tmpSkip))311 $tmpSkip[] = $checkMethod;312 $this->_skipAfterActions[$action] = $tmpSkip;313 }314}...

Full Screen

Full Screen

controller.php

Source:controller.php Github

copy

Full Screen

...33 }34 }35 public function __set($method, $mixed)36 {37 $this->checkMethod($method);38 return parent::__set($method, $mixed);39 }40 public function __get($method)41 {42 $this->checkMethod($method);43 return parent::__get($method);44 }45 public function __isset($method)46 {47 $this->checkMethod($method);48 return parent::__isset($method);49 }50 public function __unset($method)51 {52 $this->checkMethod($method);53 parent::__unset($method);54 return $this->setInvoker($method);55 }56 public function setIterator(controller\iterator $iterator = null)57 {58 $this->iterator = $iterator ?: new controller\iterator();59 $this->iterator->setMockController($this);60 return $this;61 }62 public function getIterator()63 {64 return $this->iterator;65 }66 public function disableMethodChecking()67 {68 $this->disableMethodChecking = true;69 return $this;70 }71 public function getMockClass()72 {73 return $this->mockClass;74 }75 public function getMethods()76 {77 return $this->mockMethods;78 }79 public function methods(\closure $filter = null)80 {81 $this->iterator->resetFilters();82 if ($filter !== null)83 {84 $this->iterator->addFilter($filter);85 }86 return $this->iterator;87 }88 public function methodsMatching($regex)89 {90 return $this->iterator->resetFilters()->addFilter(function($name) use ($regex) { return preg_match($regex, $name); });91 }92 public function getCalls(test\adapter\call $call = null, $identical = false)93 {94 if ($call !== null)95 {96 $this->checkMethod($call->getFunction());97 }98 return parent::getCalls($call, $identical);99 }100 public function control(mock\aggregator $mock)101 {102 $currentMockController = self::$linker->getController($mock);103 if ($currentMockController !== null && $currentMockController !== $this)104 {105 $currentMockController->reset();106 }107 if ($currentMockController === null || $currentMockController !== $this)108 {109 self::$linker->link($this, $mock);110 }111 $this->mockClass = get_class($mock);112 $this->mockMethods = $mock->getMockedMethods();113 foreach (array_keys($this->invokers) as $method)114 {115 $this->checkMethod($method);116 }117 foreach ($this->mockMethods as $method)118 {119 $this->{$method}->setMock($mock);120 if ($this->autoBind === true)121 {122 $this->{$method}->bindTo($mock);123 }124 }125 return $this126 ->resetCalls()127 ->notControlNextNewMock()128 ;129 }130 public function controlNextNewMock()131 {132 self::$controlNextNewMock = $this;133 return $this;134 }135 public function notControlNextNewMock()136 {137 if (self::$controlNextNewMock === $this)138 {139 self::$controlNextNewMock = null;140 }141 return $this;142 }143 public function enableAutoBind()144 {145 $this->autoBind = true;146 foreach ($this->invokers as $invoker)147 {148 $invoker->bindTo($this->getMock());149 }150 return $this;151 }152 public function disableAutoBind()153 {154 $this->autoBind = false;155 return $this->reset();156 }157 public function autoBindIsEnabled()158 {159 return ($this->autoBind === true);160 }161 public function reset()162 {163 self::$linker->unlink($this);164 $this->mockClass = null;165 $this->mockMethods = array();166 return parent::reset();167 }168 public function getMock()169 {170 return self::$linker->getMock($this);171 }172 public function invoke($method, array $arguments = array())173 {174 $this->checkMethod($method);175 if (isset($this->{$method}) === false)176 {177 throw new exceptions\logic('Method ' . $method . '() is not under control');178 }179 return parent::invoke($method, $arguments);180 }181 public static function enableAutoBindForNewMock()182 {183 self::$autoBindForNewMock = true;184 }185 public static function disableAutoBindForNewMock()186 {187 self::$autoBindForNewMock = false;188 }189 public static function get($unset = true)190 {191 $instance = self::$controlNextNewMock;192 if ($instance !== null && $unset === true)193 {194 self::$controlNextNewMock = null;195 }196 return $instance;197 }198 public static function setLinker(controller\linker $linker = null)199 {200 self::$linker = $linker ?: new controller\linker();201 }202 public static function getForMock(aggregator $mock)203 {204 return self::$linker->getController($mock);205 }206 protected function checkMethod($method)207 {208 if ($this->mockClass !== null && $this->disableMethodChecking === false && in_array(strtolower($method), $this->mockMethods) === false)209 {210 if (in_array('__call', $this->mockMethods) === false)211 {212 throw new exceptions\logic('Method \'' . $this->getMockClass() . '::' . $method . '()\' does not exist');213 }214 if (isset($this->__call) === false)215 {216 $controller = $this;217 parent::__set('__call', function($method, $arguments) use ($controller) {218 return $controller->invoke($method, $arguments);219 }220 );...

Full Screen

Full Screen

route.php

Source:route.php Github

copy

Full Screen

...21 // Чтобы get-запросы работали22 $urlChild = strrpos($routes[2], "?") ? substr($routes[2], 0, strrpos($routes[2], "?")) : $routes[2];23 }24 }25 $checkMethod = self::methodCheck($urlParent, $urlChild);26 if($checkMethod["success"]) {27 self::allowGetResponses($routes, 3);28 $checkMethod["object"] -> {$checkMethod["method"]}();29 } else {30 $checkMethod = self::methodCheck("home", $urlParent);31 if($checkMethod["success"]) {32 self::allowGetResponses($routes, 3);33 $checkMethod["object"] -> {$checkMethod["method"]}();34 } else {35 $checkMethod = self::methodCheck($urlParent, "index");36 if($checkMethod["success"]) {37 self::allowGetResponses($routes, 2);38 $checkMethod["object"] -> {$checkMethod["method"]}();39 } else {40 self::error404();41 }42 }43 }44// if(self::methodCheck("home", $urlParent)["success"])45// self::error404();46 }47 private static function allowGetResponses($routes, $startIndex) {48 for($i = $startIndex; $i < count($routes); $i++) {49 $_GET[$routes[$i]] = $routes[++$i];50 }51 }52 private static function loadModel($model) {...

Full Screen

Full Screen

checkMethod

Using AI Code Generation

copy

Full Screen

1$this->checkMethod('post');2$this->checkMethod('get');3$this->checkMethod('post');4$this->checkMethod('get');5$this->checkMethod('post');6$this->checkMethod('get');7$this->checkMethod('post');8$this->checkMethod('get');9$this->checkMethod('post');10$this->checkMethod('get');11$this->checkMethod('post');12$this->checkMethod('get');13$this->checkMethod('post');14$this->checkMethod('get');15$this->checkMethod('post');16$this->checkMethod('get');17$this->checkMethod('post');18$this->checkMethod('get');19$this->checkMethod('post');20$this->checkMethod('get');

Full Screen

Full Screen

checkMethod

Using AI Code Generation

copy

Full Screen

1$controller = new Controller();2$controller->checkMethod('Controller');3$model = new Model();4$controller->checkMethod('Model');5$view = new View();6$controller->checkMethod('View');7$controller = new Controller();8$controller->checkMethod('Controller');9$model = new Model();10$controller->checkMethod('Model');11$view = new View();12$controller->checkMethod('View');13$controller = new Controller();14$controller->checkMethod('Controller');15$model = new Model();16$controller->checkMethod('Model');17$view = new View();18$controller->checkMethod('View');19$controller = new Controller();20$controller->checkMethod('Controller');21$model = new Model();22$controller->checkMethod('Model');23$view = new View();24$controller->checkMethod('View');25$controller = new Controller();26$controller->checkMethod('Controller');27$model = new Model();28$controller->checkMethod('Model');29$view = new View();30$controller->checkMethod('View');31$controller = new Controller();32$controller->checkMethod('Controller');33$model = new Model();34$controller->checkMethod('Model');35$view = new View();36$controller->checkMethod('View');37$controller = new Controller();38$controller->checkMethod('Controller');

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in controller

Trigger checkMethod code on LambdaTest Cloud Grid

Execute automation tests with checkMethod on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful