Create controller declaration.
552347
public function perform()
    {
        /** @var DocumentDeclaration $declaration */
        $declaration = $this->createDeclaration();

        foreach ($this->option('field') as $field) {
            if (strpos($field, ':') === false) {
                throw new ScaffolderException("Field definition must in 'name:type' form");
            }

            list($name, $type) = explode(':', $field);
            $declaration->addField($name, $type);
        }

        $declaration->setCollection((string)$this->option('collection'));
        $declaration->setDatabase((string)$this->option('database'));

        $this->writeDeclaration($declaration->normalizeDeclaration());

        if ($this->option('source')) {
            $this->writeDeclaration(
                $this->sourceDeclaration(
                    $this->argument('name'),
                    'document',
                    $this->getNamespace() . '\\' . $this->getClass()
                ),
                'source'
            );
        }
    }
192331
def handle(self):
        """"""
        body = None
        req = self.request
        res = self.response
        rou = self.router
        con = None
        start = time.time()

        try:
            con = self.create_controller()
            con.call = self
            self.controller = con
            if not self.quiet:
                con.log_start(start)

            # the controller handle method will manipulate self.response, it first
            # tries to find a handle_HTTP_METHOD method, if it can't find that it
            # will default to the handle method (which is implemented on Controller).
            # method arguments are passed in so child classes can add decorators
            # just like the HTTP_METHOD that will actually handle the request
            controller_args, controller_kwargs = con.find_method_params()
            controller_method = getattr(con, "handle_{}".format(req.method), None)
            if not controller_method:
                controller_method = getattr(con, "handle")

            if not self.quiet:
                logger.debug("Using handle method: {}.{}".format(
                    con.__class__.__name__,
                    controller_method.__name__
                ))
            controller_method(*controller_args, **controller_kwargs)

        except Exception as e:
            self.handle_error(e) # this will manipulate self.response

        finally:
            if res.code == 204:
                res.headers.pop('Content-Type', None)
                res.body = None # just to be sure since body could've been ""

            if con:
                if not self.quiet:
                    con.log_stop(start)

        return res
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'));
    }
131089
private function generateBasicController()
    {
        $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();
        $content = $this->getIndexStub();
        $content = $this->replaceTemplate('{%methods%}', $content, $controllerContent);

        return $this->writeContentToClass($filePointer, $content);
    }
1265127
public function addCurrentController(): void
    {
        $controllerName = Inflector::camelize($this->_frontendData['request']['controller']);
        $this->addController(
            $controllerName . '.' . Inflector::camelize($this->_frontendData['request']['action'])
        );
        $this->addController($controllerName);
    }
79427
private function registerControllerMakeCommand()
    {
        $this->app->bindShared('command.make.package.controller', function ($app)
        {
            return new ControllerMakeCommand($app['files'], $app['packages']);
        });

        $this->commands('command.make.package.controller');
    }
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!");
    }
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);
        }
1327194
private static ControllerRegistry build(ControllerLookup lookup) {
        List<BaseController> controllers = new LinkedList<>();
        controllers.addAll(lookup.getControllers());
        return new ControllerRegistry(controllers);
    }
927349
def controller(self):
        """"""
        if hasattr(self, 'controllers'):
            if len(self.controllers) > 1:
                # in the future, we should support more controllers
                raise TypeError("Only one controller per account.")
            return self.controllers[0]
        raise AttributeError("There is no controller assigned.")
208801
private function callController()
    {
        $name = $this->getResourceControllerName();

        if ($this->confirm("Create a controller ($name) for the $this->resource resource?")) {
            $arg = $this->getArgumentResource();
            $name = substr_replace($arg, str_plural($this->resource),
                strrpos($arg, $this->resource), strlen($this->resource));

            if ($this->repositoryContract) {
                $this->callCommandFile('controller', $name, 'controller_repository');
            }
            else {
                // if admin - update stub
                if (!str_contains($name, 'admin.')) {
                    $this->callCommandFile('controller', $name, 'controller');
                }
                else {
                    $this->callCommandFile('controller', $name, 'controller_admin');
                }
            }
        }
    }
1150894
def start(controller_class):
    
    args = parser.parse()
    obj = controller_class(args, platform.operating_system())
    if args.foreground:
        try:
            obj.start()
        except KeyboardInterrupt:
            obj.stop()
    else:
        try:
            with platform.Daemon(obj) as daemon:
                daemon.start()
        except (OSError, ValueError) as error:
            sys.stderr.write('\nError starting %s: %s\n\n' %
                             (sys.argv[0], error))
            sys.exit(1)
1350103
function create(controller, boxes) {
  var doc = controller.window.document;
  var maxWidth = doc.documentElement.boxObject.width;
  var maxHeight = doc.documentElement.boxObject.height;
  var rect = [];
  for (var i = 0, j = boxes.length; i < j; ++i) {
    rect = boxes[i];
    if (rect[0] + rect[2] > maxWidth) maxWidth = rect[0] + rect[2];
    if (rect[1] + rect[3] > maxHeight) maxHeight = rect[1] + rect[3];
  }
  var canvas = doc.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
  var width = doc.documentElement.boxObject.width;
  var height = doc.documentElement.boxObject.height;
  canvas.width = maxWidth;
  canvas.height = maxHeight;
  var ctx = canvas.getContext("2d");
  ctx.clearRect(0,0, canvas.width, canvas.height);
  ctx.save();
  ctx.drawWindow(controller.window, 0, 0, width, height, "rgb(0,0,0)");
  ctx.restore();
  ctx.save();
  ctx.fillStyle = "rgba(255,0,0,0.4)";
  for (var i = 0, j = boxes.length; i < j; ++i) {
    rect = boxes[i];
    ctx.fillRect(rect[0], rect[1], rect[2], rect[3]);
  }
  ctx.restore();

  _saveCanvas(canvas);
}
1084768
protected function createCtrl()
    {
        $oView              = ViewFactory::createView(
            $this->ctrlName,
            str_replace('action', '', $this->actionName)
        );
        $aComponentsRootMap = AppHelper::getInstance()->getConfig('componentsRootMap');
        if (!isset($aComponentsRootMap['controllers'])) {
            throw new Exception("The field 'componentsRootMap.controllers' must be "
            ."presented in the main configuration file.");
        }
        $sCtrlNamespace = str_replace(
            \DIRECTORY_SEPARATOR,
            '\\',
            $aComponentsRootMap['controllers']
        );
        $sCtrlNameFull  = $sCtrlNamespace.'\\'.$this->ctrlName;
        if (!is_null($oView)) {
            $sLayoutName = AppHelper::getInstance()->getConfig('defaultLayout');
            if (!is_null($sLayoutName)) {
                $oLayout = ViewFactory::createLayout($sLayoutName, $oView);
                $oCtrl   = new $sCtrlNameFull($this->request, $oLayout);
            } else {
                $oCtrl = new $sCtrlNameFull($this->request, $oView);
            }
        } else {
            $oCtrl = new $sCtrlNameFull($this->request);
        }
        return $oCtrl;
    }
434225
def setup(self):
        
        [c.start() for c in self.controllers]
        [c.wait_to_start() for c in self.controllers]
1330394
def setup(self):
        """"""
        if not isinstance(self.filePath, str):
            raise TypeError("File path is not a string!")
        if self.controller is None:
            raise ValueError("Command controller hasn't been specified!")
1305191
public function makeController($controllerName = null)
  {
    $controllerName = ucwords($_POST['command']);
    $this->controllerName = $controllerName;
    
    if (file_exists("App/Controllers/{$this->controllerName}Controller.php")) {
      $this->errors[] = "The {$this->controllerName}Controller already exists!";
    } elseif (strripos($this->controllerName, '_') == 0) {
      $this->controllerName = ucwords(str_replace('_', '', $this->controllerName));
    }
    
    if (!empty($this->errors)) {
      echo array_shift($this->errors);
    } else {
      $newControllerTemplate = file_get_contents(__DIR__ . '/templates/makeController.txt');
      $newController = str_replace('ControllerName', $this->controllerName, $newControllerTemplate);
      file_put_contents("App/Controllers/{$this->controllerName}Controller.php", $newController);
    }
  }