Get the controller class string from a model class string

@param  string $controller ex: "App\Person"
@return string ex: "App\Http\Controllers\Admin\People"
964319
public function controllerForModel($model)
    {
        // Swap out the namespace if decoy
        $controller = str_replace('Bkwld\Decoy\Models', 'Bkwld\Decoy\Controllers', $model, $is_decoy);

        // Replace non-decoy controller's with the standard model namespace
        if (!$is_decoy) {
            $namespace = ucfirst(Config::get('decoy.core.dir'));
            $controller = str_replace('App\\', 'App\Http\Controllers\\'.$namespace.'\\', $controller);
        }

        // Make it plural
        $offset = strrpos($controller, '\\') + 1;
        return substr($controller, 0, $offset).Str::plural(substr($controller, $offset));
    }
926280
protected function controllerPath($s)
    {
        $s = strtr($s, ':', '.');
        $s = preg_replace('#([^.])(?=[A-Z])#', '$1-', $s);
        $s = strtolower($s);
        $s = rawurlencode($s);

        return $s;
    }
630271
final protected function getPagesControllerClassName()
    {
        $modules = modules()->getArrayCopy();

        foreach($modules as $module) {
            $controllerClassName = $module->getNamespace() . 'Controllers\Pages';
            if ($module->getNamespace() === 'O2System\Framework\\') {
                $controllerClassName = 'O2System\Framework\Http\Controllers\Pages';
            }

            if(class_exists($controllerClassName)) {
                return $controllerClassName;
                break;
            }
        }

        if(class_exists('O2System\Framework\Http\Controllers\Pages')) {
            return 'O2System\Framework\Http\Controllers\Pages';
        }

        return false;
    }
378099
protected function getControllerActionMetadata($controller)
    {
        $controllerClass = get_class($controller[0]);

        $metadata = $this->metadataFactory->getMetadataForClass($controllerClass);

        $controllerMetadata = $metadata->getOutsideClassMetadata();

        $action_metadatas = null;
        if (array_key_exists($controller[1], $controllerMetadata->methodMetadata)) {
            $action_metadatas = $controllerMetadata->methodMetadata[$controller[1]];
        }

        return $action_metadatas;
    }
1314316
public function implicitController($controller)
    {
        $container = $this->getContainer();
        $reflection = $container->getReflection()->setClass($controller);
        $methods = $reflection->getMethods('public', false, null);

        foreach ($methods as $key => $method) {
            if ($method !== '__construct') {
                list($uri, $verb, $method, $plain) = $this->getRoutesParameters($method, $controller, $reflection);
                $args = $this->getUriArguments($plain);

                if (!in_array($verb, $this->verbs)) {
                    throw new \RuntimeException("Invalid HTTP verb ($verb) exception.");
                }

                $classParam = ['controller' => $controller, 'method' => $method, 'args' => $args];

                $this->handleRoute($container, $classParam, $verb, $uri);
            }
        }
    }
258020
private function getReflectionMethod($controller)
    {
        if (preg_match('#(.+)::([\w]+)#', $controller, $matches)) {
            $class = $matches[1];
            $method = $matches[2];
        } elseif (preg_match('#(.+):([\w]+)#', $controller, $matches)) {
            $controller = $matches[1];
            $method = $matches[2];
            if ($this->container->has($controller)) {
                $this->container->enterScope('request');
                $this->container->set('request', new Request);
                $class = get_class($this->container->get($controller));
                $this->container->leaveScope('request');
            }
        }

        if (isset($class) && isset($method)) {
            try {
                return new \ReflectionMethod($class, $method);
            } catch (\ReflectionException $e) {
            }
        }

        return null;
    }
1197684
public static function getCorrectControllerName($controller)
		{
			$controller = strtolower($controller);
			$controller = str_replace(array('-','.'),' ',$controller);
			$controller = ucwords($controller);
			$controller = str_replace(' ','',$controller);

			return $controller;
		}
1142310
private function getControllerLocator($controller)
    {
        $class = null;
        $prefix = null;

        if (0 === strpos($controller, '@')) {
            $file = $this->locator->locate($controller);
            $controllerClass = ClassUtils::findClassInFile($file);

            if (false === $controllerClass) {
                throw new \InvalidArgumentException(sprintf('Can\'t find class for controller "%s"', $controller));
            }

            $controller = $controllerClass;
        }

        if ($this->container->has($controller)) {
            // service_id
            $prefix = $controller.':';

            if (Kernel::VERSION_ID >= 40100) {
                $prefix .= ':';
            }

            $useScope = method_exists($this->container, 'enterScope') && $this->container->hasScope('request');
            if ($useScope) {
                $this->container->enterScope('request');
                $this->container->set('request', new Request());
            }
            $class = get_class($this->container->get($controller));
            if ($useScope) {
                $this->container->leaveScope('request');
            }
        } elseif (class_exists($controller)) {
            // full class name
            $class = $controller;
            $prefix = $class.'::';
        } elseif (false !== strpos($controller, ':')) {
            // bundle:controller notation
            try {
                $notation = $this->controllerParser->parse($controller.':method');
                list($class) = explode('::', $notation);
                $prefix = $class.'::';
            } catch (\Exception $e) {
                throw new \InvalidArgumentException(
                    sprintf('Can\'t locate "%s" controller.', $controller)
                );
            }
        }

        if (empty($class)) {
            throw new \InvalidArgumentException(sprintf(
                'Class could not be determined for Controller identified by "%s".', $controller
            ));
        }

        return [$prefix, $class];
    }
607456
protected function findNamespaceInController(&$controller)
    {
        if (strstr($controller, '\\')) {
            $namespace = explode('\\', $controller);
            $controller = end($namespace);
            $namespace = rtrim(join('\\', array_slice($namespace, 0, count($namespace) - 1)), '\\');
        } else {
            $namespace = isset($this->group['_namespace']) ? $this->group['namespace'] : null;
        }

        return $namespace;
    }
126933
protected function callController($controller)
    {
        if (is_string($controller) && strpos($controller, self::SEPARATOR) !== false) {
            list($controller, $action) = explode(self::SEPARATOR, $controller);
            $response = $this->callClassController($controller, $action);
        } elseif (is_callable($controller)) {
            $response = $this->callCallableController($controller);
        } else {
            throw new AppException(sprintf('Invalid controller type, got "%s"', $this->getType($controller)));
        }

        if (!$response) {
            throw new AppException(sprintf('There was no response returned from the controller handling "%s"', $this->request()->uri(true)));
        }

        if (!$response instanceof ResponseInterface) {
            throw new AppException(sprintf('Invalid response returned from handling "%s", expected ResponseInterface, got "%s"', $this->request()->uri(true), $this->getType($response)));
        }

        return $response;
    }
1128197
protected function uses(String & $controller)
    {
        if( ! empty($this->settings['use']) )
        {
            foreach( $this->settings['use'] as $key => $use )
            {
                if( is_numeric($key) )
                {
                    $controller .= "use {$use};".EOL;
                }
                else
                {
                    $controller .= "use {$key} as {$use};".EOL;
                }
            }

            $controller .= EOL;
        }
    }
93047
public function setController($controller) {
        $controller = Str::studly($controller);
        if('Controller' != substr($controller, -10)) {
            $controller = $controller . 'Controller';
        }

        $this->controller = $controller;

        return $this;
    }
789829
private function getAttributeName(array $controller)
    {
        list($controllerObject, $methodName) = $controller;

        $method = new \ReflectionMethod($controllerObject, $methodName);
        foreach ($method->getParameters() as $param) {
            if ($this->isScopeFetcherType($param)) {
                return $param->getName();
            }
        }

        // If there is no typehint, inject the ScopeFetcher using a default name.
        return 'scopeFetcher';
    }
758345
protected function getControllerTargetModel($controller)
    {
        switch ($controller) {
            case 'respondent':
                $model = $this->loader->getModels()->getRespondentModel(true);
                $model->applyEditSettings();
                return $model;

            case 'calendar':
                $model = $this->loader->getModels()->createAppointmentModel();
                $this->applySource($model);
                $model->applyEditSettings();
                return $model;

            default:
                return null;
        }
    }
1178063
protected function getActions($controller)
    {
        $actions = array_keys($controller->actions());
        $class = new \ReflectionClass($controller);
        foreach ($class->getMethods() as $method) {
            $name = $method->getName();
            if ($name !== 'actions' && $method->isPublic() && !$method->isStatic() && strpos($name, 'action') === 0) {
                $actions[] = Inflector::camel2id(substr($name, 6), '-', true);
            }
        }
        sort($actions);

        return array_unique($actions);
    }
343823
public function handleController($controller, $method)
    {
        if($this->app->findController($controller)) {
            $controllerClass = "App\\Controller\\".$controller;
            $this->controller = new $controllerClass();
        }
        if($this->app->hasMethod($this->controller, $method)) {
            self::$instance = $this;
            ob_start();
            $return = $this->controller->$method();
            $output = ob_get_clean();
            self::$instance = null;
        }
        if($return !== null) {
            //handle returned value
        }
        $output = $output ?: null;
        return $output;
    }
1242960
private function getPartsFromControllerName($controller)
    {
        if (3 != count($parts = explode(':', $controller))) {
            throw new \InvalidArgumentException(sprintf('The "%s" controller is not a valid a:b:c controller string.', $controller));
        }

        list($moduleName, $controller, $action) = $parts;
        $controller = str_replace('/', '\\', $controller);
        $module     = $this->moduleManager->getModule($moduleName);

        if (!is_object($module)) {
            throw new \RuntimeException(sprintf(
                'Unable to locate module: %s, when parsing controller: %s',
                $moduleName, $controller
            ));
        }

        $moduleName = $module->getName();

        return [$module, $moduleName, $controller, $action];
    }