private function isRouteExcluded(RouteMatch $routeMatch) { $controller = $routeMatch->getParam('controller'); $action = $routeMatch->getParam('action'); // todo: evaluate if controller / action are excluded return false; }
/** * @param $component * @return bool */ public function canApply($component, $config = null) { $config = is_null($config) ? $this->config : $config; $include = (array) Arrays::getRecursive($config, (string) $component . ".include"); $exclude = (array) Arrays::getRecursive($config, (string) $component . ".exclude"); $controller = $this->routeMatch->getParam('controller'); $action = $this->routeMatch->getParam('action'); if (in_array($controller, $include)) { return true; } if (in_array($controller, $exclude)) { return false; } return true; }
protected function getParamsFromRouteMatch(RouteMatch $routeMatch) { $params = array(); $controllerClass = $routeMatch->getParam('controller'); $chunks = explode('\\', $controllerClass); $moduleName = strtolower($chunks[0]); $controllerName = strtolower($chunks[sizeof($chunks) - 1]); $actionName = strtolower($routeMatch->getParam('action')); if ($actionName == 'index') { $actionName = 'read'; } $params['module'] = $moduleName; $params['controller'] = $controllerName; $params['action'] = $actionName; return $params; }
/** * Because we are running our auth checks before dispatch most of the time, check to see if the route * is a SM alias of zf-rest or zf-rpc which are the common settings for API routes */ private function isApiRequest(ServiceLocatorInterface $sm, RouteMatch $routeMatch) { $config = $sm->get('config'); // Check to see if we are dealing with an Apigility command, if so dont rate limit // Since Apigility should never be available in anything but dev, dont worry about anything else if (!array_key_exists('APPLICATION_ENV', $_SERVER) || $_SERVER['APPLICATION_ENV'] !== 'development') { return false; } if ($routeMatch->getParam('is_apigility_admin_api') === TRUE) { return false; } $controllerName = $routeMatch->getParam('controller'); $rpcControllers = array_keys($config['zf-rpc']); $restControllers = array_keys($config['zf-rest']); $apiControllers = array_merge($rpcControllers, $restControllers); return in_array($controllerName, $apiControllers); }
/** * @param array $params * @param string $lang * * @return array */ private function prepareLanguageInParams(array $params, $lang) { // when error occurred (404) we don't have routeMatch if ($this->routeMatch) { // we change lang only there when lang parameter exists if ($this->routeMatch->getParam('lang') !== null) { $params['lang'] = $lang; } } else { $params['lang'] = $lang; } // if default app language is the same as lang and shouldRedirect is disabled if ($this->config->getDefaultLanguage() === $lang && !$this->config->shouldRedirectToRecognizedLanguage()) { $params['lang'] = ''; } return $params; }
/** * Asserts that the most recent dispatch did not arrive at the specified controller. * * @param string $controller The controller. * @param string $message (Optional) The message to output on failure. */ public function assertNotController($controller, $message = '') { $actualController = !empty($this->routeMatch) ? $this->routeMatch->getParam('controller') : null; $this->assertNotSame($controller, $actualController, $message); }