src/Cms/ContextualTemplateTrait.php
protected function createGenericContext()
    {
        if ($this->isCreatingContext) {
            return null;
        }

        $this->isCreatingContext = true;

        $obj = $this->modelFactory()->create($this->genericContextClass());

        $baseUrl = $this->baseUrl();
        if ($this->routeEndpoint) {
            $endpoint = $this->translator()->translation($this->routeEndpoint);
            foreach ($this->translator()->availableLocales() as $lang) {
                $uri = $baseUrl->withPath($endpoint[$lang]);

                if ($this->routeGroup) {
                    $uri = $uri->withBasePath($this->routeGroup[$lang]);
                }

                $base = $uri->getBasePath();
                $path = $uri->getPath();
                $path = $base . '/' . ltrim($path, '/');

                $endpoint[$lang] = $path;
            }
        } else {
            $endpoint = null;
        }

        $obj['url']   = $endpoint;
        $obj['title'] = $this->title();

        $this->isCreatingContext = false;

        return $obj;
    }
protected function createGenericContext()
    {
        if ($this->isCreatingContext) {
            return null;
        }

        $this->isCreatingContext = true;

        $obj = $this->modelFactory()->create($this->genericContextClass());

        $baseUrl = $this->baseUrl();
        if ($this->routeEndpoint) {
            $endpoint = $this->translator()->translation($this->routeEndpoint);
            foreach ($this->translator()->availableLocales() as $lang) {
                $uri = $baseUrl->withPath($endpoint[$lang]);

                if ($this->routeGroup) {
                    $uri = $uri->withBasePath($this->routeGroup[$lang]);
                }

                $base = $uri->getBasePath();
                $path = $uri->getPath();
                $path = $base . '/' . ltrim($path, '/');

                $endpoint[$lang] = $path;
            }
        } else {
            $endpoint = null;
        }

        $obj['url']   = $endpoint;
        $obj['title'] = $this->title();

        $this->isCreatingContext = false;

        return $obj;
    }
protected function createGenericContext ( ) { if ( $ this -> isCreatingContext ) { return null ; } $ this -> isCreatingContext = true ; $ obj = $ this -> modelFactory ( ) -> create ( $ this -> genericContextClass ( ) ) ; $ baseUrl = $ this -> baseUrl ( ) ; if ( $ this -> routeEndpoint ) { $ endpoint = $ this -> translator ( ) -> translation ( $ this -> routeEndpoint ) ; foreach ( $ this -> translator ( ) -> availableLocales ( ) as $ lang ) { $ uri = $ baseUrl -> withPath ( $ endpoint [ $ lang ] ) ; if ( $ this -> routeGroup ) { $ uri = $ uri -> withBasePath ( $ this -> routeGroup [ $ lang ] ) ; } $ base = $ uri -> getBasePath ( ) ; $ path = $ uri -> getPath ( ) ; $ path = $ base . '/' . ltrim ( $ path , '/' ) ; $ endpoint [ $ lang ] = $ path ; } } else { $ endpoint = null ; } $ obj [ 'url' ] = $ endpoint ; $ obj [ 'title' ] = $ this -> title ( ) ; $ this -> isCreatingContext = false ; return $ obj ; }
Create a generic object relative to the context.

@return ModelInterface|null
Create a generic object relative to the context .