Function to resolve constroller from the Controllers
directory based on resource name request.
556629
private function getController()
        {
            $expected = $this->request['resource'];
            foreach(glob(APPLICATION_PATH . '/Controllers/*.php', GLOB_NOSORT) as $controller) {
                $controller = basename($controller, '.php');
                if(strnatcasecmp($expected, $controller) == 0) {
                    return 'Controllers_' . $controller;
                }
            }
            return null;
        }
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;
            }
        }
    }
636026
function(controller, callback) {

            // Allow configure-method less controllers
            if ('function' !== typeof controller.configure) {
                return callback(null, controller);
            }

            controller.configure(
                self.worker.app,
                self.worker.server,
            function(err) {
                callback(err, controller);
            });
        }
1162493
function getComposed(uri, locals) {
  return controller.get(uri, locals).then(data => {
    // TODO: Check that we can't just reference the composer
    // require here because otherwise it's a circular dependency (via html-composer)
    return require('../services/composer').resolveComponentReferences(data, locals);
  });
}
1082901
protected function prefixedResource( $name, $controller, array $options )
	{
		list( $name, $prefix ) = $this->getResourcePrefix( $name );

		// We need to extract the base resource from the resource name. Nested resources
		// are supported in the framework, but we need to know what name to use for a
		// place-holder on the route parameters, which should be the base resources.
		$callback = function ( $me ) use ( $name, $controller, $options )
		{
			$me->resource( $name, $controller, $options );
		};

		$this->router->group( compact( 'prefix' ), $callback );
	}
200305
private void registerControllerFactories() {
		graphicsService.registerControllerFactory(new ResizeControllerFactory());
		graphicsService.registerControllerFactory(new DragControllerFactory());
		graphicsService.registerControllerFactory(new DeleteControllerFactory());
		graphicsService.registerControllerFactory(new LabelControllerFactory());
		graphicsService.registerControllerFactory(new AnchoredDragControllerFactory());
	}
761597
function Controller(name, options) {
	if (typeof name === "function") {
		var _constructor = name;name = null;
		return register(_constructor, options);
	}

	return register;
	function register(constructor, opts) {
		registerLock(constructor);
		var meta = (0, _utils.funcMeta)(constructor);

		name = name || opts && opts.name || meta.name;
		meta.controller.name = name;

		_app.app.controller(name, constructor);
	}
}
1025749
final public static function load_controller($restoreid = false) {
        // Get the restore id optional param.
        if ($restoreid) {
            try {
                // Try to load the controller with it.
                // If it fails at this point it is likely because this is the first load.
                $controller = restore_controller::load_controller($restoreid);
                return $controller;
            } catch (Exception $e) {
                return false;
            }
        }
        return $restoreid;
    }
51099
function resolve( dir ) {
	var udir = dir || configdir();
	if ( udir === null ) {
		debug( 'Unable to resolve user configuration directory.' );
	} else {
		udir = path.resolve( root, udir );
		debug( 'User configuration directory: %s', udir );
	}
	return udir;
}
213471
def derive_resource_name(name):
    """"""
    if name.startswith("Anon"):
        name = name[4:]
    if name.endswith("Handler"):
        name = name[:-7]
    if name == "Maas":
        name = "MAAS"
    return name
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();
						}
					});
				});
			});
		}
	}
1372272
def _find_controller(self, class_):
        
        for controller, classes in self.request_controllers.items():
            if class_ in classes:
                return controller
        else:
            raise ValueError('Unknown request class {!r}'.format(class_))
885641
protected function _resolveRequest(DispatcherContext $context)
    {
        //Resolve the controller
        if($context->request->query->has('view')) {
            $this->setController($context->request->query->get('view', 'cmd'));
        }

        //Resolve the controller action
        if($context->request->data->has('_action')) {
            $this->setControllerAction($context->request->data->get('_action', 'cmd'));
        }
    }
191133
function Request__resolveRoute(routeRule) {
        var route;
        this.route = routeRule.shift();
        this.params = routeRule.shift();
        route = this.route.split('/');
        if (route.length === 3) {
            this.module = route.shift();
        }
        this.controller = route.shift();
        this.action = route.shift();

        if (!!this.module) {
            return this._handleModule(di.getAlias('modulesPath'));
        }

        return this._handleController(di.getAlias('controllersPath'), di.getAlias('viewsPath'));
    }
841946
protected Supplier<DataSource<IMAGE>> getDataSourceSupplierForRequest(
      final DraweeController controller, String controllerId, REQUEST imageRequest) {
    return getDataSourceSupplierForRequest(
        controller, controllerId, imageRequest, CacheLevel.FULL_FETCH);
  }
1199915
def make_controller(cls, config, session, left_menu_items=None):
        """"""
        m = config.model
        Controller = config.defaultCrudRestController

        class ModelController(Controller):
            model        = m
            table        = config.table_type(session)
            table_filler = config.table_filler_type(session)
            new_form     = config.new_form_type(session)
            new_filler   = config.new_filler_type(session)
            edit_form    = config.edit_form_type(session)
            edit_filler  = config.edit_filler_type(session)
            allow_only   = config.allow_only

            if hasattr(config.layout, 'crud_resources'):
                resources = config.layout.crud_resources

            def _before(self, *args, **kw):
                super(self.__class__, self)._before(*args, **kw)

                tmpl_context.make_pager_args = make_pager_args

                if request.response_type not in ('application/json',):
                    default_renderer = AdminController._get_default_renderer()
                    for action in ('get_all', 'new', 'edit'):
                        for template in config.layout.crud_templates.get(action, []):
                            if template.startswith(default_renderer):
                                override_template(getattr(self, action), template)

        return ModelController(session, left_menu_items)
1015370
private function _searchInControllerDir($base_dir, $file_name)
    {
        $dirs = $this->application->getControllerDirectories();
        foreach ($dirs as $dir) {
            $filter = $this->finder->path($dir . $base_dir)->name($file_name)->find()->first();
            if ($filter) return $filter;
        }
    }