Builds the specified controller.
965583
@Override
  public AbstractDraweeController build() {
    validate();

    // if only a low-res request is specified, treat it as a final request.
    if (mImageRequest == null && mMultiImageRequests == null && mLowResImageRequest != null) {
      mImageRequest = mLowResImageRequest;
      mLowResImageRequest = null;
    }

    return buildController();
  }
663495
private function createController(): void
    {
        $aFields  = $this->getArguments();
        $aCreated = [];

        try {

            $aControllers = array_filter(
                array_map(function ($sController) {
                    return implode('/', array_map('ucfirst', explode('/', ucfirst(trim($sController)))));
                }, explode(',', $aFields['CONTROLLER_NAME']))
            );
            $aMethods     = array_filter(
                array_map(function ($sMethod) {
                    return lcfirst(trim($sMethod));
                }, explode(',', $aFields['METHODS']))
            );

            sort($aControllers);

            foreach ($aControllers as $sController) {

                $aControllerBits = explode('/', $sController);
                $aControllerBits = array_map('ucfirst', $aControllerBits);

                if (count($aControllerBits) > 2) {
                    throw new ConsoleException('Controllers cannot be deeper than one directory');
                }

                $aFields['MODULE_NAME']     = getFromArray(0, $aControllerBits);
                $aFields['CONTROLLER_NAME'] = getFromArray(1, $aControllerBits, $aFields['MODULE_NAME']);
                $this->oOutput->write('Creating controller <comment>' . $sController . '</comment>... ');


                if (count($aControllerBits) == 2) {
                    //  A path has been specified, splice in the correct folder structure
                    $aLastControllerBits = array_splice($aControllerBits, -1, 1);
                    $aControllerBits     = array_merge(
                        array_map('lcfirst', $aControllerBits),
                        ['controllers'],
                        array_map('ucfirst', $aLastControllerBits)
                    );
                } else {
                    //  The controller should be in a folder called itself
                    $aControllerBits = array_merge(
                        array_map('lcfirst', $aControllerBits),
                        ['controllers'],
                        array_map('ucfirst', $aControllerBits)
                    );
                }

                $aViewBits = $aControllerBits;
                array_splice($aViewBits, -2, 1, ['views']);

                $sControllerPath     = self::CONTROLLER_PATH . implode('/', array_slice($aControllerBits, 0, -1)) . '/';
                $sViewPath           = self::CONTROLLER_PATH . implode('/', array_slice($aViewBits, 0, -1)) . '/';
                $sControllerFilename = end($aControllerBits) . '.php';
                $sClassName          = ucfirst(underscoreToCamelcase(end($aControllerBits)));

                $aFields['CONTROLLER_PATH']     = $sControllerPath;
                $aFields['CONTROLLER_FILENAME'] = $sControllerFilename;
                $aFields['CONTROLLER_CLASS']    = $sClassName;
                $aFields['VIEW_PATH']           = $sViewPath;

                //  Check if the controller already exists
                if (file_exists($sControllerPath . $sControllerFilename)) {
                    throw new ConsoleException(
                        'Controller "' . $sController . '" already exists at "' . $sControllerPath . $sControllerFilename . '"'
                    );
                }

                //  Generate methods
                if ($aFields['MODULE_NAME'] === $aFields['CONTROLLER_NAME']) {
                    $sViewPathPrefix = '';
                    $sViewPrefix     = lcfirst($aFields['CONTROLLER_NAME']) . '/';
                } else {
                    $sViewPathPrefix = $aFields['CONTROLLER_NAME'] . '/';
                    $sViewPrefix     = lcfirst($aFields['MODULE_NAME']) . '/' . $aFields['CONTROLLER_NAME'] . '/';
                }

                $aMethodStrings = [];
                $aViews         = [];
                reset($aMethods);
                foreach ($aMethods as $sMethod) {

                    $aViews[]         = $sViewPathPrefix . $sMethod;
                    $aMethodStrings[] = '';
                    $aMethodStrings[] = $this->getResource(
                        'template/controller_method.php',
                        [
                            'METHOD_NAME' => $sMethod,
                            'METHOD_VIEW' => $sViewPrefix . $sMethod,
                        ]
                    );
                    $aMethodStrings[] = '';
                    $aMethodStrings[] = '// --------------------------------------------------------------------------';
                }

                //  Remove the first item (blank string) and the last two (separators)
                $aMethodStrings = array_slice($aMethodStrings, 1, -2);

                //  Add leading tabs
                array_walk(
                    $aMethodStrings,
                    function (&$sLine) {
                        $sLine = trim($sLine);
                        if (!empty($sLine)) {
                            $aLines = explode("\n", $sLine);
                            foreach ($aLines as &$sSingleLine) {
                                $sSingleLine = $this->tabs(1) . $sSingleLine;
                            }
                            $sLine = implode("\n", $aLines);
                        }
                    }
                );

                $aFields['METHODS'] = implode("\n", $aMethodStrings);

                //  Ensure the path exists
                $this->createPath($aFields['CONTROLLER_PATH']);

                //  Create the controller and write to it
                $this->createFile(
                    $aFields['CONTROLLER_PATH'] . $aFields['CONTROLLER_FILENAME'],
                    $this->getResource('template/controller.php', $aFields)
                );
                $aCreated[] = $aFields['CONTROLLER_PATH'] . $aFields['CONTROLLER_FILENAME'];
                $this->oOutput->writeln('<info>done!</info>');

                //  Create the views
                $this->oOutput->write('Creating views for controller <comment>' . $sController . '</comment>... ');
                $this->createPath($aFields['VIEW_PATH']);

                foreach ($aViews as $sView) {
                    $sViewPath    = $aFields['VIEW_PATH'] . $sView . '.php';
                    $sViewSubPath = dirname($sView);
                    if ($sViewSubPath !== '.') {
                        $this->createPath($aFields['VIEW_PATH'] . $sViewSubPath);
                    }
                    $this->createFile(
                        $sViewPath,
                        $this->getResource(
                            'template/view.php',
                            [
                                'VIEW' => preg_replace('#^' . NAILS_APP_PATH . '#', '', $sViewPath),
                            ]
                        )
                    );
                    $aCreated[] = $sView;

                }
                $this->oOutput->writeln('<info>done!</info>');
            }

        } catch (ConsoleException $e) {
            $this->oOutput->writeln('<error>failed!</error>');
            //  Clean up created models
            if (!empty($aCreated)) {
                $this->oOutput->writeln('<error>Cleaning up - removing newly created files</error>');
                foreach ($aCreated as $sPath) {
                    @unlink($sPath);
                }
            }
            throw new ConsoleException($e->getMessage());
        }
    }
411842
protected function createController()
    {
        $controller = Str::studly(class_basename($this->argument('name')));
        $modelName = $this->qualifyClass($this->getNameInput());

        $this->call('make:controller', [
            'name' => "{$controller}Controller",
            '--model' => $this->option('resource') ? $modelName : null
        ]);
    }
297367
public function build()
    {
        $this->filesystem->put(

            sprintf('/%s/_blog/%s', KATANA_CONTENT_DIR, $this->nameFile()),

            $this->buildTemplate()

        );
    }
550761
static public function build_plan($controller) {

        $plan = $controller->get_plan();

        // Add the root task, responsible for
        // preparing everything, creating the
        // needed structures (users, roles),
        // preloading information to temp table
        // and other init tasks
        $plan->add_task(new restore_root_task('root_task'));
        $controller->get_progress()->progress();

        switch ($controller->get_type()) {
            case backup::TYPE_1ACTIVITY:
                self::build_activity_plan($controller, key($controller->get_info()->activities));
                break;
            case backup::TYPE_1SECTION:
                self::build_section_plan($controller, key($controller->get_info()->sections));
                break;
            case backup::TYPE_1COURSE:
                self::build_course_plan($controller, $controller->get_courseid());
                break;
        }

        // Add the final task, responsible for closing
        // all the pending bits (remapings, inter-links
        // conversion...)
        // and perform other various final actions.
        $plan->add_task(new restore_final_task('final_task'));
        $controller->get_progress()->progress();
    }
504487
protected function makeController($controller)
    {
        Controller::setRouter($this->router);

        $controller = $this->container->make($controller);

        if ( ! $controller instanceof AdminPageController)
        {
            if ($this->container->isShared('post'))
            {
                $controller->setPost($this->container['post']);
            }

            $controller->setQuery($this->container['query']);
        }

        if (method_exists($controller, 'boot'))
        {
            $this->container->call([$controller, 'boot']);
        }

        return $controller;
    }
572783
public function generateController()
    {
        if (!$this->confirm('Do you want to generate a controller?')) {
            return;
        }

        $this->console->call('generate:controller', [
            'name' => $this->getControllerName(),
            '--force' => $this->console->option('force'),
            '--scaffold' => true,
        ]);
    }
798935
function(controller, callback) {

            // Add the given name to the controller
            controller.name = name;
            controller.module = module;

            // Set default value on the controller instance
            controller.basePath = self.getBasePath(
                controller, path, module
            );

            // Add the canonical path
            controller.canonicalPath = self.getCanonicalPath(
                path, name, module
            );

            callback(null, controller);
        }
351014
public function startup($controller = null)
    {
        if (!$controller) {
            $controller = new Controller(new Request());
        }
        $registry = new ComponentRegistry();
        $this->Acl = new AclComponent($registry, Configure::read('Acl'));
        $this->Aco = $this->Acl->Aco;
        $this->controller = $controller;
        $this->_buildPrefixes();
        $this->_processIgnored();
    }
1088486
private function generateController()
    {
        // Generate Controller class
        $controllerInstance = Controller::instance($this->columns, $this->viewType, $this);

        $controllerTemplateDir =
            dirname(dirname(__FILE__)).DS.'src'.DS.'Apps'.DS.'Controllers'.DS;

        $controllerInstance->setControllerTemplatePath($controllerTemplateDir);
        $controllerInstance->setApplicationDirectory($this->applicationDir);

        $controllerInstance->setControllerName($this->controller);
        $controllerInstance->setModelName($this->model);
        $controllerInstance->updateTemplate();
        $controllerInstance->generateControllerTemplate();

        $controllerInstance->generate();

        $this->info("Controller $this->controller Generated Successfully!");
    }
1265127
public function addCurrentController(): void
    {
        $controllerName = Inflector::camelize($this->_frontendData['request']['controller']);
        $this->addController(
            $controllerName . '.' . Inflector::camelize($this->_frontendData['request']['action'])
        );
        $this->addController($controllerName);
    }
574460
protected function makeController($controller)
	{
		Controller::setFilterer($this->filterer);

		return $this->container->make($controller);
	}
336614
@Bind(aggregate = true, optional = true)
    public synchronized void bindController(Controller controller) {
        LOGGER.info("Adding routes from " + controller);

        List<Route> newRoutes = new ArrayList<>();
        try {

            List<Route> annotatedNewRoutes = RouteUtils.collectRouteFromControllerAnnotations(controller);
            newRoutes.addAll(annotatedNewRoutes);
            newRoutes.addAll(controller.routes());

            //check if these new routes don't pre-exist
            ensureNoConflicts(newRoutes);

        } catch (RoutingException e) {
            LOGGER.error("The controller {} declares routes conflicting with existing routes, " +
                    "the controller is ignored, reason: {}", controller, e.getMessage(), e);
            // remove all new routes as one has failed
            routes.removeAll(newRoutes);  //NOSONAR
        } catch (Exception e) {
            LOGGER.error("The controller {} declares invalid routes, " +
                    "the controller is ignored, reason: {}", controller, e.getMessage(), e);
            // remove all new routes as one has failed
            routes.removeAll(newRoutes); //NOSONAR
        }
    }
149120
function init() {
		config = app.config;

		defaultController = config.defaultControllerFactory(app.models);

		// load controllers
		var controllerDir = path.join(config.rootDir, config.paths.controllers);
		var controllerFiles = fs.readdirSync(controllerDir);
		controllerFiles.forEach(function(controllerFile) {
			var controllerName = controllerFile.substring(0, controllerFile.indexOf('Controller'));
			var controllerDef = require(path.join(controllerDir, controllerFile));
			var controller;
			if (controllerDef.noDefaultActions) {
				controller = controllerDef;
			} else {
				controller = Object.create(defaultController);
				controller = Object.merge(controller, controllerDef);
			}
			app.controllers[controllerName] = controller;
		});

		applyPathPolicies();

		var routes = config.routes,
			parsed = [];

		parseResourceRoutes();

		for (var route in routes) {
			parsed.push(parseRoute(route, routes[route]));
		}

		parsed.forEach(function(route) {
			if(!route.target)
				return;

			if (Object.isString(route.target)) {
				if (route.verbs[0] !== 'static' && route.target.charAt(0) === '/') {
					route.target = {redirect: route.target};
				} else {
					var parts = route.target.split('.');
					if (parts.length === 2) {
						route.target = {controller: parts[0], action: parts[1]};
					}
				}
			}
			if (!Object.isObject(route.target)) {
				route.target = {controller: route.target};
			}

			route.verbs.forEach(function (verb) {
				if (verb === 'resource') {
					addResourceRoute(route.path, route.target.controller);
				} else if (verb === 'static') {
					addStaticRoute(route.path, route.target.controller);
				} else if (route.target.redirect) {
					addRedirectRoute(verb, route.path, route.target.redirect);
				} else {
					addSingleRoute(verb, route.path, route.target.controller, route.target.action);
				}
			});
		});

		if(config.autoRoute) {
			resourceRouting.forEach(function(route) {
				var actionPath = path.join('/', config.autoRoutePath, route.path);
				route.verbs.forEach(function (verb) {
					app[verb](actionPath, function(req, res, next) {
						var controllerName = req.params.controller.singularize();
						var actionName = route.target.action;
						req.controller = controllerName;
						req.action = actionName;

						var action = getAction(controllerName, actionName);
						if (action) {
							var policies = getPolicies(controllerName, actionName);
							if (policies.length > 0) {
								var policyIdx = 0;
								var nextPolicy = function() {
									policyIdx++;
									if (policyIdx < policies.length) {
										policies[policyIdx](req, res, nextPolicy);
									} else {
										action(req, res, next);
									}
								};
								policies[0](req, res, nextPolicy);
							} else {
								action(req, res, next);
							}
						} else {
							next();
						}
					});
				});
			});
		}
	}
851057
protected function createResourceController()
    {
        Artisan::call('make:controller', [
            'name' => $controller = $this->controllerWithoutMethod($this->action()),
            '--resource' => true
        ]);
        $this->info('Resource Controller ' . $controller .' created.');
        $this->createView($this->argument('link'));
    }
1033321
protected function registerController()
    {
        $this->app['generate.controller'] = $this->app->share(function($app)
        {
            $generator = $this->app->make('Way\Generators\Generator');

            return new ControllerGeneratorCommand($generator);
        });

        $this->commands('generate.controller');
    }
932561
public void withControllerClass(Class<?> clazz) {
        Objects.requireNonNull(clazz, Required.CONTROLLER_CLASS.toString());
        this.controllerClass = clazz;
    }