设置或者获取当前的控制器名
@access public
@param string $controller 控制器名
@return string|Request
553048
public function controller($controller = null)
    {
        if (!is_null($controller)) {
            $this->controller = $controller;
            return $this;
        } else {
            return $this->controller ?: '';
        }
    }
517083
public function submit($controller)
    {
        set_time_limit(0);

        $path = null;
        $errors = $success = 0;

        /* @var $file \SplFileInfo */
        foreach ($controller->getSubmitted('files', array()) as $file) {
            $path = $file->getRealPath();
            gplcart_file_delete_recursive($path, $errors, $success);
        }

        $query = array(
            'cmd' => 'list',
            'path' => isset($path) ? $this->getRelativeDirectory($path) : ''
        );

        $vars = array('@num_success' => $success, '@num_errors' => $errors);

        return array(
            'redirect' => $controller->url('', $query),
            'severity' => empty($errors) ? 'success' : 'warning',
            'message' => $this->translation->text('Deleted @num_success, errors: @num_errors', $vars)
        );
    }
378099
protected function getControllerActionMetadata($controller)
    {
        $controllerClass = get_class($controller[0]);

        $metadata = $this->metadataFactory->getMetadataForClass($controllerClass);

        $controllerMetadata = $metadata->getOutsideClassMetadata();

        $action_metadatas = null;
        if (array_key_exists($controller[1], $controllerMetadata->methodMetadata)) {
            $action_metadatas = $controllerMetadata->methodMetadata[$controller[1]];
        }

        return $action_metadatas;
    }
1036501
public static function locateController($controller)
    {
        preg_match_all('/^(single|archive)-/i', $controller, $matches);

        $controllers = array(
            str_replace('.blade.php', '', self::camelCase(basename($controller, '.php')))
        );

        if (isset($matches[1][0])) {
            $controllers[] = self::camelCase($matches[1][0]);
        }

        $searchPaths = array(
            get_stylesheet_directory() . '/library/Controller',
            get_template_directory() . '/library/Controller',
        );

        /**
         * Apply filter to $searchPaths
         * @since 0.1.0
         * @var   array
         */
        $searchPaths = apply_filters('Municipio/blade/controllers_search_paths', $searchPaths);

        foreach ($searchPaths as $path) {
            foreach ($controllers as $controller) {
                $file = $path . '/' . $controller . '.php';

                if (!file_exists($file)) {
                    continue;
                }

                return $file;
            }
        }

        return false;
    }
845206
protected function makeController($controller)
    {

        if (!$this->creator) {
            return $this->container->make($controller);
        }

        return $this->creator->createController($controller, $this->getPage());

    }
1307532
public function findUriTemplatesByController($controller)
    {
        $result = array();

        foreach ($this->map as $uriTemplate => $options) {
            if (isset($options['controller']) && $options['controller'] == $controller) {
                array_push($result, $uriTemplate);
            }
        }

        return $result;
    }
385142
public function makeSoftDeletesCondition($controller)
    {
        if (!$controller->withTrashed()) return [];
        return [
            'deleted_at' => [
                'type' => 'select',
                'label' => 'status',
                'options' => [
                    'exists' => 'exists',
                    'deleted' => 'deleted'
                ],
                'query' => function($query, $condition, $input) {

                    // If not deleted...
                    if (($input == 'exists' && $condition == '=') ||
                        ($input == 'deleted' && $condition == '!=')) {
                        $query->whereNull('deleted_at');

                    // If deleted...
                    } else if (($input == 'deleted' && $condition == '=') ||
                        ($input == 'exists' && $condition == '!=')) {
                        $query->whereNotNull('deleted_at');
                    }
                },
            ]
        ];
    }
391637
protected function getController($controller)
	{
		$stub = $this->files->get(__DIR__.'/stubs/controller.stub');

		// We will explode out the controller name on the naemspace delimiter so we
		// are able to replace a namespace in this stub file. If no namespace is
		// provided we'll just clear out the namespace place-holder locations.
		$segments = explode('\\', $controller);

		$stub = $this->replaceNamespace($segments, $stub);

		return str_replace('{{class}}', last($segments), $stub);
	}
20658
public function controllerName() {
        $request = $this->stack->getCurrentRequest();
        if ($request instanceof Request) {
            $string = $request->get('_controller');
            $parts = explode('::', $string);
            $controller = $parts[0];
            $pattern = "#Controller\\\([a-zA-Z\\\]*)Controller#";
            $matches = array();
            preg_match($pattern, $controller, $matches);
            if (isset($matches[1])) {
                return strtolower(str_replace('\\', '_', $matches[1]));
            }

            return '';
        }

        return '';
    }
908898
private function cleanController($controller, $class)
  {
    if ($class == '') {
      if ($this->resource == true) {
        $contents = str_replace('
use Modulus\Http\Request;
use App\Http\Controllers\Controller;
', '
use Modulus\Http\Request;
', file_get_contents($controller));

        return file_put_contents($controller, $contents);
      }

      $contents = str_replace('

use App\Http\Controllers\Controller;', '', file_get_contents($controller));

      return file_put_contents($controller, $contents);
    }
  }
82705
public function guessTemplateName($controller, Request $request)
    {
        if (\is_object($controller) && method_exists($controller, '__invoke')) {
            $controller = [$controller, '__invoke'];
        } elseif (!\is_array($controller)) {
            throw new \InvalidArgumentException(sprintf('First argument of %s must be an array callable or an object defining the magic method __invoke. "%s" given.', __METHOD__, \gettype($controller)));
        }

        $className = $this->getRealClass(\get_class($controller[0]));

        $matchController = null;
        foreach ($this->controllerPatterns as $pattern) {
            if (preg_match($pattern, $className, $tempMatch)) {
                $matchController = str_replace('\\', '/', strtolower(preg_replace('/([a-z\d])([A-Z])/', '\\1_\\2', $tempMatch[1])));
                break;
            }
        }
        if (null === $matchController) {
            throw new \InvalidArgumentException(sprintf('The "%s" class does not look like a controller class (its FQN must match one of the following regexps: "%s")', \get_class($controller[0]), implode('", "', $this->controllerPatterns)));
        }

        if ('__invoke' === $controller[1]) {
            $matchAction = $matchController;
            $matchController = null;
        } else {
            $matchAction = preg_replace('/Action$/', '', $controller[1]);
        }

        $matchAction = strtolower(preg_replace('/([a-z\d])([A-Z])/', '\\1_\\2', $matchAction));
        $bundleName = $this->getBundleForClass($className);

        return sprintf(($bundleName ? '@'.$bundleName.'/' : '').$matchController.($matchController ? '/' : '').$matchAction.'.'.$request->getRequestFormat().'.twig');
    }
573161
public function getControllerName()
    {
        if (empty($this->controller_name)) {
            $controller_class = get_class($this);

            if (($pos = strrpos($controller_class, '\\')) !== false) {
                $this->controller_name = substr($controller_class, $pos + 1);
            } else {
                $this->controller_name = $controller_class;
            }
        }

        return $this->controller_name;
    }
30482
protected function _isLoginAction(Controller $controller)
    {
        $uri = $controller->request->getUri();
        $url = Router::normalize($uri->getPath());
        $loginAction = Router::normalize($this->_config['loginAction']);

        return $loginAction === $url;
    }
1261595
public function routeController($controller): Controller
    {
        $actions = $this->getActions();

        foreach ($actions as $key => $action) {
            $method = ucfirst(Inflector::pathAction($action));

            if (method_exists($this, 'set' . $method . 'Route')) {
                $this->{'set' . $method . 'Route'}(Inflector::deCamelize($controller), $action);
            }
        }

        $this->mapRoute();

        return $this;
    }
134311
public function find($controller, $id)
    {
        $model = $controller->model();
        if ($controller->withTrashed()) {
            return $model::withTrashed()->find($id);
        } else {
            return $model::find($id);
        }
    }
206020
public function getResourceName($controller, $action = null)
    {
        if (isset($action)) {
            return sprintf('controller/%s:%s', $controller, strtolower($action));
        }

        return sprintf('controller/%s', $controller);
    }
609357
public function submit($controller)
    {
        $result = $controller->getSubmitted('uploaded', array());

        $vars = array(
            '@num_errors' => count($result['errors']),
            '@num_success' => count($result['transferred'])
        );

        $files = $controller->getSubmitted('files');

        /* @var $file \SplFileInfo */
        $file = reset($files);

        $query = array(
            'cmd' => 'list',
            'path' => $this->getRelativeFilePath($file->getRealPath())
        );

        return array(
            'redirect' => $controller->url('', $query),
            'severity' => empty($result['errors']) ? 'success' : 'warning',
            'message' => $this->translation->text('Uploaded @num_success, errors: @num_errors', $vars)
        );
    }