Delete file(s)
@param \gplcart\core\Controller $controller
@return array
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)
        );
    }
644295
public function controllerWithoutPrefix($controller)
    {
        $controller = new ReflectionClass($controller);
        $methods = $controller->getMethods(ReflectionMethod::IS_PUBLIC);
        return $this->collectControllerRoutes($controller, $methods, "/");
    }
1267718
protected function parseController($controller)
    {
        if (\is_string($controller) && false !== strpos($controller, '::')) {
            $controller = explode('::', $controller);
        }

        if (\is_array($controller)) {
            try {
                $r = new \ReflectionMethod($controller[0], $controller[1]);

                return [
                    'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0],
                    'method' => $controller[1],
                    'file' => $r->getFileName(),
                    'line' => $r->getStartLine(),
                ];
            } catch (\ReflectionException $e) {
                if (\is_callable($controller)) {
                    // using __call or  __callStatic
                    return [
                        'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0],
                        'method' => $controller[1],
                        'file' => 'n/a',
                        'line' => 'n/a',
                    ];
                }
            }
        }

        if ($controller instanceof \Closure) {
            $r = new \ReflectionFunction($controller);

            $controller = [
                'class' => $r->getName(),
                'method' => null,
                'file' => $r->getFileName(),
                'line' => $r->getStartLine(),
            ];

            if (false !== strpos($r->name, '{closure}')) {
                return $controller;
            }
            $controller['method'] = $r->name;

            if ($class = $r->getClosureScopeClass()) {
                $controller['class'] = $class->name;
            } else {
                return $r->name;
            }

            return $controller;
        }

        if (\is_object($controller)) {
            $r = new \ReflectionClass($controller);

            return [
                'class' => $r->getName(),
                'method' => null,
                'file' => $r->getFileName(),
                'line' => $r->getStartLine(),
            ];
        }

        return \is_string($controller) ? $controller : 'n/a';
    }
1289462
protected function setModuleAssets(Controller $controller)
    {
        $controller->addAssetLibrary('jquery_mobile');
        $controller->setJs(__DIR__ . '/js/common.js');
        $controller->setCss(__DIR__ . '/css/common.css');
    }
528060
public static function clear()
    {
        $path = root().'resources/controllers/*.php';

        $files = File::glob($path);
        //
        foreach ($files as $file) {
            File::delete($file);
        }
        //
        return true;
    }
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;
    }
4118
public function getActions($controller)
    {
        $actions = [];
        foreach (get_class_methods($controller) as $method) {
            if (preg_match('#^(.*)Action$#', $method, $match)) {
                $actions[] = $match[1];
            }
        }

        return $actions;
    }
642906
protected function forward($controller)
    {
        $path['_controller'] = $controller;
        $subRequest = $this->container->get('request_stack')->getCurrentRequest()->duplicate(null, null, $path);

        return $this->container->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
    }
1178063
protected function getActions($controller)
    {
        $actions = array_keys($controller->actions());
        $class = new \ReflectionClass($controller);
        foreach ($class->getMethods() as $method) {
            $name = $method->getName();
            if ($name !== 'actions' && $method->isPublic() && !$method->isStatic() && strpos($name, 'action') === 0) {
                $actions[] = Inflector::camel2id(substr($name, 6), '-', true);
            }
        }
        sort($actions);

        return array_unique($actions);
    }
574460
protected function makeController($controller)
	{
		Controller::setFilterer($this->filterer);

		return $this->container->make($controller);
	}
228741
public function submit($controller)
    {
        $submitted = $controller->getSubmitted();

        /* @var $file \SplFileInfo */
        $file = reset($submitted['files']);

        $directory = $submitted['destination'];
        $pathinfo = pathinfo($submitted['destination']);

        if (!empty($pathinfo['extension'])) {
            $directory = trim($pathinfo['dirname'], '.');
        }

        $result = true;

        if ($directory && !file_exists($directory)) {
            $result = mkdir($directory, 0777, true);
        }

        if ($result && !empty($pathinfo['basename'])) {
            $result = touch($submitted['destination']);
        }

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

        if ($result) {
            return array(
                'severity' => 'success',
                'redirect' => $controller->url('', $query),
                'message' => $this->translation->text('File has been created')
            );
        }

        return array(
            'severity' => 'warning',
            'redirect' => $controller->url('', $query),
            'message' => $this->translation->text('File has not been created')
        );
    }
178948
public function submit($controller)
    {
        set_time_limit(0);

        $submitted = $controller->getSubmitted();
        $file = reset($submitted['files']);

        $path = $file->getRealPath();
        $destination = $controller->getSubmitted('destination');

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

        $errors = $success = 0;
        $this->move($path, $destination, $errors, $success);

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

        return array(
            'redirect' => $controller->url('', $query),
            'severity' => empty($errors) ? 'success' : 'warning',
            'message' => $this->translation->text('Renamed @num_success, errors: @num_errors', $vars)
        );
    }
1144860
public function initialize(Controller $controller) {
		$this->_controller = $controller;
		if (!$this->_controller->Components->loaded('RequestHandler')) {
			$this->_controller->RequestHandler = $this->_controller->Components->load('RequestHandler');
			$this->_controller->RequestHandler->initialize($this->_controller);
		}
		if (!$this->_controller->Components->loaded('Session')) {
			$this->_controller->Session = $this->_controller->Components->load('Session');
			$this->_controller->Session->initialize($this->_controller);
		}
		if ($this->_controller->Auth->loggedIn() ||
			$this->_controller->RequestHandler->prefers('json')) {
			return;
		}

		$isAuthCfg = $this->_modelSetting->isAuthGroupConfigured();
		if ($isAuthCfg) {
			if ($this->_controller->Session->read('Settings.FirstLogon')) {
				$this->_controller->Session->delete('Settings.FirstLogon');

				return $this->_controller->redirect($this->_controller->Auth->logout());
			}

			return;
		}

		$pluginName = $this->_controller->request->param('plugin');
		$controllerName = $this->_controller->request->param('controller');
		$actionName = $this->_controller->request->param('action');
		if (($pluginName !== 'cake_settings_app') ||
			($controllerName !== 'settings') ||
			($actionName !== 'index')) {
			return;
		}

		$this->_controller->Auth->allow('index');
		$this->_controller->Session->write('Settings.FirstLogon', true);
	}
1251207
public static function resource($url, $controller)
    {
        $route = new self($url);

        $route->targets = ['index', 'show', 'insert', 'add', 'update', 'edit', 'delete'];

        $route->setResourceMethods($url, $controller);

        return $route;
    }
315885
public function setController(Controller $controller)
    {
        $this->links->controller = $controller;
        $this->twig->addGlobal('controller', $this->links->controller);
    }
343823
public function handleController($controller, $method)
    {
        if($this->app->findController($controller)) {
            $controllerClass = "App\\Controller\\".$controller;
            $this->controller = new $controllerClass();
        }
        if($this->app->hasMethod($this->controller, $method)) {
            self::$instance = $this;
            ob_start();
            $return = $this->controller->$method();
            $output = ob_get_clean();
            self::$instance = null;
        }
        if($return !== null) {
            //handle returned value
        }
        $output = $output ?: null;
        return $output;
    }
637874
public static function registerController($controller)
    {
        $uri = '/';

        $routable = (new ControllerInspector)
                            ->getRoutable($controller, $uri);

        // When a controller is routed using this method, we use Reflection to parse
        // out all of the routable methods for the controller, then register each
        // route explicitly for the developers, so reverse routing is possible.
        foreach ($routable as $method => $routes) {
            foreach ($routes as $route) {
                $action = ['uses' => $controller.'@'.$method];

                \Route::{$route['verb']}($route['uri'], $action);
            }
        }

        \Route::any($uri.'/{_missing}', $controller.'@missingMethod');
    }