Attempts to find a controller class for the given view template path.

@param string $viewName A view template absolute file path.
@return null|string null if no controller was found.
@throws \Electro\Exceptions\Fatal\FileNotFoundException
542230
function findControllerForView ($viewName)
  {
    /** @var DocumentContext $this */
    $path = $this->viewService->resolveTemplatePath ($viewName, $base);
//    inspect ($viewName, $base, $path);
    if (isset($this->controllers[$path]))
      return $this->controllers[$path];

    foreach ($this->controllerNamespaces as $nsPath => $ns) {
//      inspect ($nsPath, $ns);
      if (str_beginsWith ($path, $nsPath)) {
        $remaining = substr ($path, strlen ($nsPath) + 1);
        $a         = PS ($remaining)->split ('/');
        $file      = $a->pop ();
        $nsPrefix  = $a->map ('ucfirst', false)->join ('\\')->S;
        $class     = ($p = strpos ($file, '.')) !== false
          ? ucfirst (substr ($file, 0, $p))
          : ucfirst ($file);
        $FQN       = PA ([$ns, $nsPrefix, $class])->prune ()->join ('\\')->S;
//        inspect ("CLASS $FQN");
        if (class_exists ($FQN))
          return $FQN;
      }
    }
//    inspect ("CLASS NOT FOUND FOR VIEW $viewName");
    return null;
  }
978439
protected function controllerMethod($controllername)
    {
        if (str_contains($controller = $controllername, '@')) {
            return substr($controllername, strpos($controllername, '@')+1, strlen($controllername));
        }
        return 'index';
    }
112127
public function getOption($optionName)
    {
        if (!array_key_exists($optionName, $this->supportedOptions)) {
            throw new Exception(sprintf('The view option "%s" you\'re trying to get doesn\'t exist in class "%s".', $optionName, get_class($this)), 1359625876);
        }

        return $this->options[$optionName];
    }
1038856
protected function getViewLayout( PhpView $view ) {
		$layout_headers = array_filter( get_file_data(
			$view->getFilepath(),
			['App Layout']
		) );

		if ( empty( $layout_headers ) ) {
			return null;
		}

		$layout_file = trim( $layout_headers[0] );

		if ( ! $this->exists( $layout_file ) ) {
			throw new ViewNotFoundException( 'View layout not found for "' . $layout_file . '"' );
		}

		return $this->makeView( $this->canonical( $layout_file ), $this->resolveFilepath( $layout_file ) );
	}
729144
public function findChildByRouteName($routeName)
    {
        if ($this->hasChildren()) {
            if (array_key_exists($routeName, $this->children)) {
                return $this->children[$routeName];
            }
            /** @var RouteDefinition $definition */
            foreach ($this->children as $definition) {
                if (null !== $child = $definition->findChildByRouteName($routeName)) {
                    return $child;
                }
            }
        }
        return null;
    }
1105815
public function actionView($name = '')
    {
        if ($name == '') {
            $name = yii::$app->getRequest()->getPathInfo();
        }
        $model = Article::findOne(['type' => Article::SINGLE_PAGE, 'sub_title' => $name]);
        if (empty($model)) {
            throw new NotFoundHttpException('None page named ' . $name);
        }
        return $this->render('view', [
            'model' => $model,
        ]);
    }
347631
protected function controller($controllername)
    {
        if (str_contains($controllername, '/')) {
            $controllername = str_replace('/', '\\', $controllername);
        }

        if (str_contains($controllername, '@')) {
            return ucfirst($controllername);
        }
        return ucfirst($controllername . '@index');
    }
528920
protected function render($viewName)
    {
        $this->viewParams =
            [
                'model' => $this->controller->model
            ];

        return $this->controller->render("@skeeks/cms/reviews2/actions/views/messages", (array)$this->viewParams);
    }
904864
public function setTemplateFileName($templateFileName)
    {
        if (!file_exists($this->getPathToTemplateFileName($templateFileName))) {
            throw new TemplateNotFoundException($templateFileName);
        }

        $this->templateFileName = $templateFileName;
    }
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);
    }
  }
55022
private function getViewStructureView($viewName)
    {
        if (!$this->dumpSettings['skip-comments']) {
            $ret = "--".PHP_EOL.
                "-- View structure for view `${viewName}`".PHP_EOL.
                "--".PHP_EOL.PHP_EOL;
            $this->compressManager->write($ret);
        }
        $stmt = $this->typeAdapter->show_create_view($viewName);

        // create views, to resolve dependencies
        // replacing tables with views
        foreach ($this->dbHandler->query($stmt) as $r) {
            // because we must replace table with view, we should delete it
            $this->compressManager->write(
                $this->typeAdapter->drop_view($viewName)
            );
            $this->compressManager->write(
                $this->typeAdapter->create_view($r)
            );
            break;
        }
    }
834963
public function make( $views ) {
		foreach ( $views as $view ) {
			if ( $this->exists( $view ) ) {
				$engine_key = $this->getBindingForFile( $view );
				$engine = Application::resolve( $engine_key );
				return $engine->make( [$view] );
			}
		}

		throw new ViewNotFoundException( 'View not found for "' . implode( ', ', $views ) . '"' );
	}
163778
public function getTemplateFilePath($templateName)
    {
        $templateList = array_merge(
            [ $this ],
            $this->getParentList()
        );

        /** @var TemplateDefinition $templateDefinition */
        foreach ($templateList as $templateDefinition) {
            $templateFilePath = sprintf(
                '%s%s/%s',
                THELIA_TEMPLATE_DIR,
                $templateDefinition->getPath(),
                $templateName
            );

            if (file_exists($templateFilePath)) {
                return $templateFilePath;
            }
        }

        throw new TemplateException("Template file not found: $templateName");
    }
1276540
public function getFilePath($filename)
    {
        if (!strpos($filename, '.')) {
            $filename .= ".phtml";
        }

        foreach ($this->config->getPaths() as $path) {
            $file = "$path/$filename";

            if (file_exists($file)) {
                return $file;
            }
        }

        throw new FileNotFoundException(
            'File \'' . $filename . '\' was not found.'
        );
    }
597044
private function getMappedTemplateName(string $templateName): ?string
    {
        if (isset($this->mapping['mandatory'][$templateName])) {
            return $this->mapping['mandatory'][$templateName];
        }

        if (isset($this->mapping['optional'][$templateName])) {
            return $this->mapping['optional'][$templateName];
        }

        return null;
    }
30029
public function getController($method)
    {
        if (is_null($this->_controller)) {
            $className = $this->_routeInfo->getController();
            if (!class_exists($className)) {
                throw new Exception\ControllerNotFoundException(
                    "Controller '{$className}' not found"
                );
            }

            $options = array(
                'request' => $this->_application->getRequest(),
                'response' => $this->_application->getResponse(),
            );

            /** @var Controller $instance */
            $instance = new $className($options);
            $methodExists = method_exists($instance,$method);
            $this->_controller = $instance;
            if (!$methodExists && $instance->isScaffold()) {
                $this->_controller = Scaffold::getScaffoldController(
                    $instance
                );
            }
        }
        return $this->_controller;
    }
842289
public function getView($filename, $data = null)
    {
        // $data = ($data === null) ? $this->_data : $data;
        return $this->getTemplateFile($this->getTemplateFolder().$filename, $data);
    }