public function getUrlPageName()
    {
        if (static::$urlPageName !== null) {
            return static::$urlPageName;
        }

        /*
         * Cache
         */
        $key = 'urlMaker'.$this->urlComponentName.crc32(get_class($this));

        $cached = Cache::get($key, false);
        if ($cached !== false && ($cached = @unserialize($cached)) !== false) {
            $filePath = array_get($cached, 'path');
            $mtime = array_get($cached, 'mtime');
            if (!File::isFile($filePath) || ($mtime != File::lastModified($filePath))) {
                $cached = false;
            }
        }

        if ($cached !== false) {
            return static::$urlPageName = array_get($cached, 'fileName');
        }

        /*
         * Fallback
         */
        $page = null;
        $useProperty = property_exists($this, 'urlComponentProperty');

        if ($useProperty) {
            $page = Page::whereComponent($this->urlComponentName, $this->urlComponentProperty, '1')->first();
        }

        if (!$useProperty || !$page) {
            $page = Page::withComponent($this->urlComponentName)->first();
        }

        if (!$page) {
            throw new ApplicationException(sprintf(
                'Unable to a find a primary component "%s" for generating a URL in %s.',
                $this->urlComponentName,
                get_class($this)
            ));
        }

        $baseFileName = $page->getBaseFileName();
        $filePath = $page->getFilePath();

        $cached = [
            'path'     => $filePath,
            'fileName' => $baseFileName,
            'mtime'    => @File::lastModified($filePath)
        ];

        Cache::put($key, serialize($cached), Config::get('cms.parsedPageCacheTTL', 1440));

        return static::$urlPageName = $baseFileName;
    }
public function getUrlPageName()
    {
        if (static::$urlPageName !== null) {
            return static::$urlPageName;
        }

        /*
         * Cache
         */
        $key = 'urlMaker'.$this->urlComponentName.crc32(get_class($this));

        $cached = Cache::get($key, false);
        if ($cached !== false && ($cached = @unserialize($cached)) !== false) {
            $filePath = array_get($cached, 'path');
            $mtime = array_get($cached, 'mtime');
            if (!File::isFile($filePath) || ($mtime != File::lastModified($filePath))) {
                $cached = false;
            }
        }

        if ($cached !== false) {
            return static::$urlPageName = array_get($cached, 'fileName');
        }

        /*
         * Fallback
         */
        $page = null;
        $useProperty = property_exists($this, 'urlComponentProperty');

        if ($useProperty) {
            $page = Page::whereComponent($this->urlComponentName, $this->urlComponentProperty, '1')->first();
        }

        if (!$useProperty || !$page) {
            $page = Page::withComponent($this->urlComponentName)->first();
        }

        if (!$page) {
            throw new ApplicationException(sprintf(
                'Unable to a find a primary component "%s" for generating a URL in %s.',
                $this->urlComponentName,
                get_class($this)
            ));
        }

        $baseFileName = $page->getBaseFileName();
        $filePath = $page->getFilePath();

        $cached = [
            'path'     => $filePath,
            'fileName' => $baseFileName,
            'mtime'    => @File::lastModified($filePath)
        ];

        Cache::put($key, serialize($cached), Config::get('cms.parsedPageCacheTTL', 1440));

        return static::$urlPageName = $baseFileName;
    }
public function getUrlPageName ( ) { if ( static :: $ urlPageName !== null ) { return static :: $ urlPageName ; } /*
         * Cache
         */ $ key = 'urlMaker' . $ this -> urlComponentName . crc32 ( get_class ( $ this ) ) ; $ cached = Cache :: get ( $ key , false ) ; if ( $ cached !== false && ( $ cached = @ unserialize ( $ cached ) ) !== false ) { $ filePath = array_get ( $ cached , 'path' ) ; $ mtime = array_get ( $ cached , 'mtime' ) ; if ( ! File :: isFile ( $ filePath ) || ( $ mtime != File :: lastModified ( $ filePath ) ) ) { $ cached = false ; } } if ( $ cached !== false ) { return static :: $ urlPageName = array_get ( $ cached , 'fileName' ) ; } /*
         * Fallback
         */ $ page = null ; $ useProperty = property_exists ( $ this , 'urlComponentProperty' ) ; if ( $ useProperty ) { $ page = Page :: whereComponent ( $ this -> urlComponentName , $ this -> urlComponentProperty , '1' ) -> first ( ) ; } if ( ! $ useProperty || ! $ page ) { $ page = Page :: withComponent ( $ this -> urlComponentName ) -> first ( ) ; } if ( ! $ page ) { throw new ApplicationException ( sprintf ( 'Unable to a find a primary component "%s" for generating a URL in %s.' , $ this -> urlComponentName , get_class ( $ this ) ) ) ; } $ baseFileName = $ page -> getBaseFileName ( ) ; $ filePath = $ page -> getFilePath ( ) ; $ cached = [ 'path' => $ filePath , 'fileName' => $ baseFileName , 'mtime' => @ File :: lastModified ( $ filePath ) ] ; Cache :: put ( $ key , serialize ( $ cached ) , Config :: get ( 'cms.parsedPageCacheTTL' , 1440 ) ) ; return static :: $ urlPageName = $ baseFileName ; }
Locates the page name where the detected component is found. This method
uses the Cache service to improve performance.
@return string
Locates the page name where the detected component is found . This method uses the Cache service to improve performance .