Beispiel #1
0
 protected function determineClassAndMethod($classMethod)
 {
     try {
         return parent::determineClassAndMethod($classMethod);
     } catch (\InvalidArgumentException $e) {
         $classNamePrefix = $this->config('controller.class_prefix');
         if ($classNamePrefix && substr($classNamePrefix, -strlen($classNamePrefix) !== '\\')) {
             $classNamePrefix .= '\\';
         }
         $classNameSuffix = $this->config('controller.class_suffix') ?: '';
         $methodNameSuffix = $this->config('controller.method_suffix');
         if (is_null($methodNameSuffix)) {
             $methodNameSuffix = 'Action';
         }
         $realClassMethod = $classMethod;
         if (strpos($realClassMethod, '\\') !== 0) {
             $realClassMethod = $classNamePrefix . $classMethod;
         }
         if (preg_match('/^([a-zA-Z0-9\\\\_]+):([a-zA-Z0-9_]+):([a-zA-Z0-9_]+)$/', $realClassMethod, $match)) {
             $className = $match[1] . '\\Controller\\' . $match[2] . $classNameSuffix;
             $methodName = $match[3] . $methodNameSuffix;
         } else {
             throw new \InvalidArgumentException("Malformed class action for '{$classMethod}'. Use 'className:methodName' format.");
         }
         return array($className, $methodName);
     }
 }