Add extension to the view string if it don't exists.

@param  string $view

@return string
547501
protected function extension( $view ) {
		$extensions = $this->extensions();

		// Return if a valid extension exists in the template string.
		$ext_reg = '/(' . implode( '|', $extensions ) . ')+$/';
		if ( preg_match( $ext_reg, $view ) ) {
			return $template;
		}

		// Add extension to template string if it don't exists.
		return substr( $view, -strlen( $extensions[0] ) ) === $extensions[0]
			? $view : $view . $extensions[0];
	}
279241
public function setView($view)
    {
        parent::setView($view);

        if (!$this->_view instanceof LibBaseViewAbstract) {
            $view = AnInflector::isPlural($view) ? 'comments' : 'comment';
            $defaults[] = 'ComBaseView'.ucfirst($view).ucfirst($this->_view->name);
            register_default(array(
                'identifier' => $this->_view,
                'default' => $defaults, ));
        }

        return $this;
    }
337972
public function getView(View $view)
    {
        if (($configHash = $this->matcherFactory->match($view)) === null) {
            return null;
        }

        // We can set the collection directly to the view, no need to go through DTO
        $view->addParameters([
            ContentView::QUERY_DEFINITION_COLLECTION_NAME => $this->getQueryDefinitionCollection($configHash, $view),
        ]);

        // Return DTO so that Configurator can set the data back to the $view
        return $this->getDTO($configHash);
    }
455429
public function render( $view, array $data = [] ) {
		if ( in_array( $view, $this->extensions ) ) {
			return '';
		}

		try {
			return $this->instance()->render( $view, $data );
		} catch ( Twig_Error $e ) {
			do_action( 'digster/twig_render_exception', $e );
			$this->render_error( $e );
		}
	}
1050763
public function resolve($template, $view = null)
    {
        if (!$template) {
            return '';
        }

        $segments = explode('/', $template);
        $page = end($segments);

        foreach ($this->baseDirectories as $dirs) {
            foreach ($dirs as $dir) {
                if ($t = $this->tryTemplate($dir, $template, $view)) {
                    return $t;
                }

                if ($t = $this->tryTemplate($dir, $template.$this->extension, $view)) {
                    return $t;
                }
            }
        }

        if ($template[0] !== '_') {

            foreach ($this->baseDirectories as $dirs) {
                foreach ($dirs as $dir) {
                    if ($t = $this->tryTemplate($dir, 'shared'.DIRECTORY_SEPARATOR.$page, $view)) {
                        return $t;
                    }

                    if ($t = $this->tryTemplate($dir, 'shared'.DIRECTORY_SEPARATOR.$page.$this->extension, $view)) {
                        return $t;
                    }
                }
            }

        }

    }
446551
protected function _includeLinksToContents($view)
    {
        $items = [];
        $contents = TableRegistry::get('Content.Contents')
            ->find('all', ['fieldable' => false])
            ->contain(['ContentTypes'])
            ->where(['status' => 1])
            ->order(['sticky' => 'DESC', 'modified' => 'DESC']);

        foreach ($contents as $content) {
            $items[] = ["{$content->type}: " . h($content->title), $view->Url->build($content->url, true)];
        }

        $view->Html->scriptBlock('var linksToContentsItems = ' . json_encode($items) . ';', ['block' => true]);
        $view->Html->scriptBlock('var linksToContentsLabel = "' . __d('wysiwyg', 'Link to content') . '";', ['block' => true]);
        $view->Html->script('Wysiwyg.ckeditor.content.links.js', ['block' => true]);
    }
857280
function hasViewResult( $view = '' )
    {
        if ( $view == '' )
            $view = $this->currentView();
        return isset( $this->ViewResult[$view] );
    }
1022343
public function displayView($view = '', $suffix = '')
    {
        $viewTag = $view . ($suffix ?  '#' . $suffix : '');
        if (!array_key_exists($viewTag, $this->_displayViewCache)) {
            $this->_displayViewCache[$viewTag] = '';
            $viewRootPath = 'themes.' . PageBuilder::getData('theme') . '.blocks.';
            $viewFiles = $view ? array_merge([$view], $this->_displayViewFiles) : $this->_displayViewFiles;
            foreach ($this->_displayViewDirs as $viewDir) {
                foreach ($viewFiles as $viewFile) {
                    $this->_displayViewLog[] = $viewRootPath . $viewDir . '.' . $viewFile . $suffix;
                    if (View::exists(end($this->_displayViewLog))) {
                        $this->_displayViewCache[$viewTag] = end($this->_displayViewLog);
                        break 2;
                    }
                }
            }
        }
        return $this->_displayViewCache[$viewTag];
    }
1113027
private function compile_phptag( $view )
	{
		// I hate this workaround
		$that = $this;

		return preg_replace_callback('/\{\%(.*?)\%\}/s', function( $match ) use( $that )
		{ 
			$expression = trim( $match[1] );

			// repair it 
			$expression = $that->repair_expression( $expression );

			return '<?php '.$expression.' ?>'; 
		}, $view );
	}
794949
public function addView(View $view)
    {
        $name = $view->getName();
        $path = $view->getPath();

        if (!is_object($path)) {
            if ($path) {
                $path = ltrim(str_replace(base_path(), '', realpath($path)), '/');
            }

            if (substr($path, -10) == '.blade.php') {
                $type = 'blade';
            } else {
                $type = pathinfo($path, PATHINFO_EXTENSION);
            }
        } else {
            $type = get_class($view);
            $path = '';
        }

        if (!$this->collect_data) {
            $params = array_keys($view->getData());
        } else {
            $data = [];
            foreach ($view->getData() as $key => $value) {
                $data[$key] = $this->exporter->exportValue($value);
            }
            $params = $data;
        }

        $this->templates[] = [
            'name'        => $path ? sprintf('%s (%s)', $name, $path) : $name,
            'param_count' => count($params),
            'params'      => $params,
            'type'        => $type,
        ];
    }
764597
public static function view(string $view, array $data = [])
  {
    $global = Self::$variables::get();
    $data = array_merge($global, $data);

    return Self::$view->view($view, $data);
  }
312782
public function getExtraTemplates($view)
    {
        if (empty($this->extraTemplates[$view])) {
            $this->extraTemplates[$view] = [];
        }

        return $this->extraTemplates[$view];
    }
939386
protected function stringViewInstance($view, $data)
    {
        return new StringView($this, $this->engines->resolve('stringblade'), $view, null, $data);
    }
49010
protected function initViewContentBlocks($view)
    {
        $view->setBlock(
            'content',
            $this->getRequest()->getControllerName() . '/' . $this->getRequest()->getActionName()
        );

        return $view;
    }
156503
private function guessBestLayoutForView(View $view)
    {
        if (method_exists($view, 'getLayout') && $view->getLayout()) {
            $viewLayout = $view->getLayout();
        } else {
            $viewLayout = $view->getTemplate()->getLayout();
        }

        return $viewLayout;
    }
910001
public function getViewPath($view)
    {
        if ($this->finder) {
            if (file_exists($file = $this->finder->find($view))) {
                return $file;
            }
        }

        if (file_exists($view)) {
            return $view;
        } elseif (file_exists($view . '.' . $this->extension)) {
            return $view . '.' . $this->extension;
        }

        foreach ($this->viewPaths as $viewPath) {
            if (file_exists($viewPath . '/' . $view . '.' . $this->extension)) {
                return $viewPath . '/' . $view . '.' . $this->extension;
            }
        }

        return null;
    }
635300
protected function getSerializationContext(View $view)
    {
        $context = parent::getSerializationContext($view);

        if ($this->serializerEnableMaxDepthChecks) {
            $context->enableMaxDepthChecks();
        }

        return $context;
    }