Returns the controller object for initialization and dispatching the
 request.

 ==== Returns
 Class:: The controller class matching the routed request,
   e.g. Posts.

 :api: private
496963
def controller
      unless params[:controller]
        raise ControllerExceptions::NotFound,
          "Route matched, but route did not specify a controller.\n" +
          "Did you forgot to add :controller => \"people\" or :controller " +
          "segment to route definition?\nHere is what's specified:\n" +
          route.inspect
      end
      path = [params[:namespace], params[:controller]].compact.join(Merb::Const::SLASH)
      controller = path.snake_case.to_const_string

      begin
        Object.full_const_get(controller)
      rescue NameError => e
        msg = "Controller class not found for controller `#{path}'"
        Merb.logger.warn!(msg)
        raise ControllerExceptions::NotFound, msg
      end
    end
1295811
def _find_sub_controllers(self, remainder, request):
        '''
        
        '''
        # need either a get_one or get to parse args
        method = None
        for name in ('get_one', 'get'):
            if hasattr(self, name):
                method = name
                break
        if not method:
            return

        # get the args to figure out how much to chop off
        args = self._get_args_for_controller(getattr(self, method))
        fixed_args = len(args) - len(
            request.pecan.get('routing_args', [])
        )
        var_args = getargspec(getattr(self, method)).varargs

        # attempt to locate a sub-controller
        if var_args:
            for i, item in enumerate(remainder):
                controller = self._lookup_child(item)
                if controller and not ismethod(controller):
                    self._set_routing_args(request, remainder[:i])
                    return lookup_controller(controller, remainder[i + 1:],
                                             request)
        elif fixed_args < len(remainder) and hasattr(
            self, remainder[fixed_args]
        ):
            controller = self._lookup_child(remainder[fixed_args])
            if not ismethod(controller):
                self._set_routing_args(request, remainder[:fixed_args])
                return lookup_controller(
                    controller,
                    remainder[fixed_args + 1:],
                    request
                )
876983
public function getController() {
        $router = new Router($this);
        $router->setCurrentRoute();
        $controllerObject = $this->GetControllerObject($router);
        $this->controller = $controllerObject;
        return $controllerObject;
    }
12434
def get_response_handler(self):
        
        assert self.response_handler is not None, \
            'Please define a response_handler ' \
            ' for Endpoint: %s' % self.__class__.__name__

        return self.response_handler(self, **self.get_response_handler_params())
406057
def reload!(controller)
      return controller unless defined?(Rails) and !Rails.configuration.cache_classes
      # we don't reload our own controller as we assume it provide as 'library'
      unless controller.name == "WebsocketRails::InternalController"
        class_name = controller.name
        filename = class_name.underscore
        load "#{filename}.rb"
        return class_name.constantize
      end

      return controller
    end
136299
def build
      controller_name = @klass.name.gsub(/Controller$/, '').underscore
      Rails.application.routes.routes.each_with_object({}) do |route, comments|
        if route.defaults[:controller] == controller_name
          verb_match = route.verb.to_s.match(/\^(.*)\$/)
          verbs = verb_match.nil? ? '*' : verb_match[1]
          (comments[route.defaults[:action]] ||= []) << "#{verbs} #{route.ast}"
        end
      end
    end
862395
def _handle_post(self, method, remainder, request=None):
        '''
        
        '''
        if request is None:
            self._raise_method_deprecation_warning(self._handle_post)

        # check for custom POST/PUT requests
        if remainder:
            match = self._handle_custom_action(method, remainder, request)
            if match:
                return match

            controller = self._lookup_child(remainder[0])
            if controller and not ismethod(controller):
                return lookup_controller(controller, remainder[1:], request)

        # check for regular POST/PUT requests
        controller = self._find_controller(method)
        if controller:
            return controller, remainder

        abort(405)
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)
560864
public static function dispatch()
    {
        $vars = [];

        $request = Request::createFromGlobals();

        $dispatcher = new Dispatcher(static::instance()->getData());
        $routeInfo = $dispatcher->dispatch(
            $request->getMethod(),
            $request->getUri()->getPath()
        );

        $controller = "\\Barebone\\Controller";
        $action = "index";

        switch ($routeInfo[0]) {
        case Dispatcher::NOT_FOUND:
            $action = 'routerError';
            $vars['error'] = static::ERR_NOT_FOUND;
            $vars['subject'] = $request->getUri()->getPath();
            break;

        case Dispatcher::METHOD_NOT_ALLOWED:
            $action = 'routerError';
            $vars['error'] = static::ERR_BAD_METHOD;
            $vars['subject'] = $routeInfo[1];
            break;

        case Dispatcher::FOUND:
            $handler = $routeInfo[1];
            $vars = $routeInfo[2];

            if (!class_exists($handler[0])) {
                $action = 'routerError';
                $vars['error'] = static::ERR_MISSING_CONTROLLER;
                $vars['subject'] = $handler[0];
            } elseif (!method_exists($handler[0], $handler[1])) {
                $action = 'routerError';
                $vars['error'] = static::ERR_MISSING_ACTION;
                $vars['subject'] = $handler[0] . '::' . $handler[1];
            } else {
                $controller = $handler[0];
                $action = $handler[1];
            }
            break;
        }

        // Start with an empty response
        $response = new Response();
        $request->setAction($action);

        // @var Controller $instance
        $instance = new $controller($request, $response);
        $instance->initController();

        // Get Middleware stacks
        $before = $instance->getMiddlewareBefore();
        $after = $instance->getMiddlewareAfter();

        // Append the action call to the middleware stack
        $before[] = function (Request $request, Response $response,
            callable $next = null
        ) use ($instance, $action, $vars) {

            // assigned updated objects
            $instance->setRequest($request);
            $instance->setResponse($response);

            // get updated response from action
            $response = call_user_func_array([$instance, $action], $vars);

            // continue
            return $next($instance->getRequest(), $response);
        };

        // Run the middleware stack and return the Response
        $middlewares = array_reverse(array_merge($before, $after));
        $runner = \Sirius\Middleware\Runner::factory($middlewares);

        return $runner($request, $response);
    }
148126
function() {

        if ( typeof(SuperController.initialized) != 'undefined' ) {
            return getInstance()
        } else {
            SuperController.initialized = true;
            SuperController.instance = self;
            if (local.options) {
                SuperController.instance._options = local.options
            }
        }
    }
1361309
public function getController() {
        $module = $this->getModule();
        $namespace = $module->getController($this->getParam('controller'));

        /** @type \Titon\Controller\Controller $controller */
        $controller = new $namespace($this->getParams());
        $controller->setRequest($this->getRequest());
        $controller->setResponse($this->getResponse());

        if ($controller instanceof UseApplication) {
            $controller->setApplication($this->getApplication());
        }

        if ($controller instanceof UseModule) {
            $controller->setModule($module);
        }

        if (method_exists($controller, 'initialize')) {
            $controller->initialize();
        }

        return $controller;
    }
881928
public function getController()
    {
        if (isset($this->uris[0]) && '' !== $this->uris[0]) {
            $_controller = $this->uris[0];
        } else {
            throw new NotFoundException('Cannot dispatch controller name.');
        }

        return strip_tags($_controller);
    }
1122859
public function getController()
    {
        if (!is_null(self::$controller)) {
            return self::$controller;
        }
        $controllerParam = array_get($this->routeParams, 'controller');
        $match           = null;

        preg_match("'Foundation\\\Http\\\Controllers\\\(.*?)@'si", $controllerParam, $match);

        if (!isset($match[1]) && !preg_match("'Admin\\\(.*?)@'si", $controllerParam, $match)) {
            return;
        }
        self::$controller = str_replace('controller', '', strtolower($match[1]));
        return self::$controller;
    }
1187933
protected function _getController()
    {
        if (!$this->_controller instanceof KControllerInterface) {
            $this->_controller = $this->getObject($this->_controller);
        }

        return $this->_controller;
    }
161922
@Nullable
    public final Controller getTargetController() {
        if (targetInstanceId != null) {
            return router.getRootRouter().getControllerWithInstanceId(targetInstanceId);
        }
        return null;
    }
66744
public function setController(){

		//check if the $urlComponentsArray has more than one value
		if(count($this->urlComponentsArray) > 0){

			//set the value of the controller
			$this->controller = $this->urlComponentsArray[0];

			//return this class instance
			return $this;

		}

		//there are no url params, set controller to null
		else{

			//there are no components in the url string set null for infered controller
			$this->controller = null;

			//return this class instance
			return $this;

		}


	}
1220952
public function getControllerClass()
    {
        $controller = array_get($this->routeParams, 'controller');
        $match      = null;
        if (!preg_match('/(.*?)(?=@|$)/', $controller, $match)) {
            return;
        }
        return $match[0];
    }