Name of the controller file to be created
972029
def controller_creatr(filename):
    """"""
    if not check():
        click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:controller command')
        return

    path = os.path.abspath('.') + '/controller'
    if not os.path.exists(path):
        os.makedirs(path)

    # if os.path.isfile(path + )

    file_name = str(filename + '.py')
    if os.path.isfile(path+"/" + file_name):
        click.echo(Fore.WHITE + Back.RED + "ERROR: Controller file exists")
        return
    controller_file = open(os.path.abspath('.') + '/controller/' + file_name, 'w+')
    compose = "from bast import Controller\n\nclass " + filename + "(Controller):\n    pass"
    controller_file.write(compose)
    controller_file.close()
    click.echo(Fore.GREEN + "Controller " + filename + " created successfully")
191397
private function createResourceController(
        Generator $generator,
        $prefix,
        $controller,
        $model_namespace = ''
    ) {
        $generator->write('controller/rest', [
            'modelNamespace' => $model_namespace,
            'prefix' => $prefix,
            'baseNamespace' => $this->namespaces['controller']
        ]);

        echo Color::green('The controller Rest was well created.');
    }
536517
protected function correctControllerNamespace()
    {
        $nsList = $this->getNamespaceList();
        $pathList = $this->getBasePathList();
        foreach ($pathList as $i => $path) {
            $controllersPath = $path . '/' . static::$controllersSubdir;
            if (is_dir($controllersPath)) {
                $this->controllerNamespace = $nsList[$i] . "\\" . static::$controllersSubdir;
                break;
            }
        }
    }
731424
protected function _controller() {
        if ($this->_setControllerFile($this->request->src, $this->request->controller) == true) {
            $className = "\\Src\\" . $this->request->src . "\\Controller\\" . ucfirst($this->request->controller);
            /** @var Controller $class */
            $class = new $className();

            if ($this->config->config['user']['security']['firewall'] == false || ($this->request->logged == '*' && $this->request->access == '*') || $class->setFirewall() == true) {
                if ($this->config->config['user']['security']['spam'] == false || $class->setSpam() == true) {
                    if ($this->request->cache > 0) {
                        $cache = new Cache('page_' . preg_replace('#\/#isU', '-slash-', $this->request->env('REQUEST_URI')), $this->request->cache);

                        if ($cache->isDie() == true) {
                            $output = $this->_action($class);
                            $this->response->page($output);

                            $cache->setContent(serialize($this->response));
                            $cache->setCache();
                        }
                        else {
                            $response = unserialize($cache->getCache());

                            $this->response->page($response->page());
                            $this->response->header($response->header());
                            $this->response->contentType($response->contentType());
                        }
                    }
                    else {
                        $output = $this->_action($class);
                        $this->response->page($output);
                    }
                }
                else {
                    $this->addError('The spam filter has detected an error', __FILE__, __LINE__, ERROR_ERROR);
                }
            }
            else {
                $this->addError('The firewall has detected an error', __FILE__, __LINE__, ERROR_ERROR);
            }
        }
        else {
            throw new Exception("Can't include controller from module " . $this->request->src);
        }
    }
612727
def auto_discover():
    
    urls = [
        url(r'^admin/', admin.site.urls),
    ]

    # TODO: we can create python package to have a lot of controllers
    # in separate files
    def get_controllers(module_name):
        """Return list of controllers in a module."""
        module = import_module('app.controllers.{}'.format(module_name))
        controllers = []
        for obj_name in dir(module):
            # we ignore import of Controller and hidden names
            if obj_name.startswith('_') or obj_name == 'Controller':
                continue
            obj = getattr(module, obj_name)
            # include only controllers
            if issubclass(obj, Controller):
                controllers.append(obj)
        return controllers

    def controller_to_path(controller):
        """
        Convert controller's name to a valid path.

        Make url in lower case by replace capital letters to small
        and adding underscore between words.
        """
        words = re.findall('[A-Z][a-z]*', controller.__name__)
        if words[-1] == 'Controller':
            del words[-1]
        # transform words to a url address
        url_path = '_'.join(words).lower()
        # main controller is a root handler
        # TODO: root address inside the file should always come last
        if url_path == 'main':
            url_path = ''
        return url_path

    # load all controllers (excluding main controllers)
    for file_name in listdir('controllers', get_files=True, hide_ignored=True):
        # remove .py extension from file name
        app_name = file_name.split('.', 1)[0]
        # we will include main controller at the end
        if app_name == 'main':
            continue
        # add url for each controller
        for controller in get_controllers(app_name):
            url_path = controller_to_path(controller)
            urls.append(url(
                r'^{}/{}$'.format(app_name, url_path),
                controller.as_view()
            ))

    # add urls for main controllers
    for controller in get_controllers('main'):
        url_path = controller_to_path(controller)
        # map urls to a root path
        urls.append(url(
            r'^{}$'.format(url_path),
            controller.as_view()
        ))

    return urls
1372609
protected function buildControllerFile()
    {
        $stubFiles = $this->getStub('controller');

        $stub = $this->files->get($stubFiles);
        $this->replaceNamespace($stub);

        return $stub;
    }
674587
function generate_routes(dir_name, controller, routes) {
	let route_def = cli.cat(dir_name + '/config/routes.js');
	let lines = [], line;
	let method, path, action;

	routes.forEach((route) => {
		// set parameters
		method = route.method; path = route.path;
		controller = route.controller; action = route.action;
		// create and add line
		line = `		this.${method}('${path}', '${controller}#${action}');`;
		lines.push(line);
	});
	// add lines to config file
	route_def = route_def.replace(/use\s?\(\)\s?{/, `use() {
${lines.join('\n')}${route_def.match(/use\s?\(\)\s?{\s*}/) ? '' : '\n'}`);
	fs.writeFileSync(dir_name + '/config/routes.js', route_def);
}
754263
def create_rails_view
      name = @view.underscore
      Rails.application.eager_load! if ApplicationController.descendants.length == 0
      controllers = ApplicationController.descendants.map { |cont| cont.name.gsub('Controller', '').underscore }
      dirname = controllers.include?(name) ? name : name.pluralize
      empty_directory "app/views/#{dirname}"
      if Gem.loaded_specs.has_key? 'haml-rails'
        file = "app/views/#{dirname}/index.html.haml"
        copy_file "boilerplate/views/rails_view.html.haml", file
        gsub_file file, /placeholder/, name
      else
        file = "app/views/#{dirname}/index.html.erb"
        copy_file "boilerplate/views/rails_view.html.erb", file
        gsub_file file, /placeholder/, name
      end
    end
748984
private function pushControllersInDefinition($alias_namespace, $controllers_directory, &$default_definitions)
    {
        $controller_files = get_files($controllers_directory);
        if (!empty($controller_files))
        {
            $controllers = array_map(function($controller) use($controllers_directory) {
                $new_controller = str_replace("{$controllers_directory}/", "", $controller);
                return basename(str_replace("/", "\\", $new_controller), ".php");
            }, $controller_files);

            $errors = [];

            foreach ($controllers as $controller) {
                if ($alias_namespace === "\\")
                {
                    $controller_definition = $controller;
                    $controller_definition_value = get_app_namespace() . "Controllers\\{$controller}";
                }
                else
                {
                    $module_name = str_replace("App\\", "", $alias_namespace);

                    $controller_sub_namespace = str_replace(app_path() . "/{$module_name}/Controllers", "", $controllers_directory);
                    $controller_sub_namespace = str_replace("/", "\\", $controller_sub_namespace);

                    $controller_definition = "{$alias_namespace}{$controller}";
                    $controller_definition_value = "{$alias_namespace}Controllers\\{$controller}";
                }

                if (!array_key_exists("{$controller_definition}", $default_definitions))
                {
                    $default_definitions["{$controller_definition}"] = function(ContainerInterface $c) use ($controller_definition_value)
                    {
                        return new $controller_definition_value($c);
                    };
                }
                else
                {
                    $errors[] = "{$controller} is already exist inside of definitions.";
                }
            }

            if (!empty($errors))
            {
                exit("Error: Please fix the ff. before run the application: <li>" . implode("</li><li>", $errors));
            }
        }
        else
        {
            exit("Error: No controller found in {$controllers_directory} path.");
        }
    }
237230
private function makeResourceController()
    {
        $stubs = ['index', 'new', 'create', 'show', 'edit', 'update', 'delete'];
        $controllerClass = $this->applicationDir.DS.'Controllers'.DS.$this->controller.'Controller'.EXT;

        if (file_exists($controllerClass)) {
            throw new \Exception("$controllerClass already exists!!");
        }

        /*write operation ->*/
        $filePointer = fopen($controllerClass, 'w') or die('Unable to generate controller');
        $controllerContent = $this->getControllerTemplate();

        $resourceContent = '';
        foreach ($stubs as $key => $template) {
            $resourceContent .= file_get_contents($this->getControllerTemplatePath().$template.'.tpl.stub', true).PHP_EOL;
        }

        $content = $this->replaceTemplate('{%methods%}', $resourceContent, $controllerContent);

        return $this->writeContentToClass($filePointer, $content);
    }
224566
def create_controller_handler(full_path, controller_path)
      # If arguments is nil, then an blank SubContext will be created
      args = [SubContext.new(@arguments, nil, true)]

      # get the controller class and action
      controller_class, action = ControllerHandler.get_controller_and_action(controller_path)

      generated_new = false
      new_controller = proc do
        # Mark that we needed to generate a new controller instance (not reused
        # from the group)
        generated_new = true
        # Setup the controller
        controller_class.new(@volt_app, *args)
      end

      # Fetch grouped controllers if we're grouping
      if @grouped_controller
        # Find the controller in the group, or create it
        controller = @grouped_controller.lookup_or_create(controller_class, &new_controller)
      else
        # Just create the controller
        controller = new_controller.call
      end

      handler = ControllerHandler.fetch(controller, action)

      if generated_new
        # Call the action
        stopped = handler.call_action

        controller.instance_variable_set('@chain_stopped', true) if stopped
      else
        stopped = controller.instance_variable_get('@chain_stopped')
      end

      [handler, generated_new, stopped]
    end
244142
protected function exportControllers()
    {
        foreach ($this->controllers as $pathIn => $pathOut) {
            if ($this->files->exists($controller = app_path('Http/Controllers/'.$pathOut))
                && ! $this->option('force')) {
                if (! $this->confirm("The [{$pathOut}] controller already exists. Do you want to overwrite it?")) {
                    continue;
                }
            }

            $this->files->put(
                $controller,
                $this->compileStub($this->files->get(__DIR__.'/stubs/make/controllers/'.$pathIn))
            );
        }
    }
770906
def _controller_name(self, objtype):
        
        # would be better to use inflect.pluralize here, but would add a dependency
        if objtype.endswith('y'):
            return objtype[:-1] + 'ies'

        if objtype[-1] in 'sx' or objtype[-2:] in ['sh', 'ch']:
            return objtype + 'es'

        if objtype.endswith('an'):
            return objtype[:-2] + 'en'

        return objtype + 's'
1223703
public function createAction()
    {
        $console = $this->getServiceLocator()->get('console');

        if (!$console instanceof ConsoleAdapterInterface) {
            throw new \RuntimeException('Invalid controller invocation');
        }

        $io = new ConsoleIO($console);
        $skeleton = new ProjectSkeleton($io);
        $skeleton->addComponent(new DirectoryLayoutComponent())
            ->addComponent(new BootstrapGeneratorComponent());

        $console->writeLine('Application Skeleton Generator' . PHP_EOL, ColorInterface::LIGHT_CYAN);
        $console->writeLine('Creating application skeleton:' . PHP_EOL, ColorInterface::GREEN);

        $skeleton->create($this->params()->fromRoute());

        $console->writeLine(PHP_EOL . 'Done!' . PHP_EOL, ColorInterface::LIGHT_GREEN);
    }
605768
protected function setupControllerMenus()
    {
        $this->config = Config::getInstance();

        $paths = Config::getInstance()->get('Octo.paths.namespaces');

        foreach ($paths as $namespace => $path) {
            $thisPath = $path . 'Admin/Controller/*.php';
            $files = glob($thisPath);

            foreach ($files as $file) {
                $this->getControllerMenuItems($file, $namespace);
            }
        }
    }
982637
public function getName(): string
	{
		if( !$this->name )
		{
			$name = $this->getModule()->getKey();
			if( preg_match('/Controllers\\\\(.*?)$/', static::class, $e ) )
			{
				$name .= '::' . preg_replace_callback( '/[A-Z]/', static function( $m ) { return '_' . lcfirst( $m[0] ); }, lcfirst( $e[1] ) );
				$name  = str_replace( '\\', ':', $name );
			}
			$this->name = strtolower( $name );
		}

		return $this->name;
	}
1005050
private function generateFileName($controller, $action){
		$extra_params = "";

		foreach($this->extra_params as $extra_param){
			if(isset($controller->$extra_param)){
				$extra_params .= $controller->$extra_param . "_";
			}
		}

		$name = $controller->id . '_' . $action->id . '_' . $extra_params . md5(json_encode(Yii::$app->request->get())) . '.html';

		return $name;
	}