public static function photos()
    {
        if (!getConfig('sitemap.photos')) {
            return [];
        }

        $table = TableRegistry::get('MeCms.PhotosAlbums');
        $url = Cache::read('sitemap', $table->getCacheName());

        if (!$url) {
            $alias = $table->Photos->getAlias();

            $albums = $table->find('active')
                ->select(['id', 'slug'])
                ->contain($alias, function (Query $q) use ($alias) {
                    return $q->find('active')
                        ->select(['id', 'album_id', 'modified'])
                        ->order([sprintf('%s.modified', $alias) => 'DESC']);
                });

            if ($albums->isEmpty()) {
                return [];
            }

            $latest = $table->Photos->find('active')
                ->select(['modified'])
                ->order([sprintf('%s.modified', $alias) => 'DESC'])
                ->firstOrFail();

            //Adds albums index
            $url[] = self::parse(['_name' => 'albums'], ['lastmod' => $latest->modified]);

            foreach ($albums as $album) {
                //Adds the album
                $url[] = self::parse(['_name' => 'album', $album->slug], ['lastmod' => array_value_first($album->photos)->modified]);

                //Adds each photo
                foreach ($album->photos as $photo) {
                    $url[] = self::parse(
                        ['_name' => 'photo', 'slug' => $album->slug, 'id' => $photo->id],
                        ['lastmod' => $photo->modified]
                    );
                }
            }

            Cache::write('sitemap', $url, $table->getCacheName());
        }

        return $url;
    }
public static function photos()
    {
        if (!getConfig('sitemap.photos')) {
            return [];
        }

        $table = TableRegistry::get('MeCms.PhotosAlbums');
        $url = Cache::read('sitemap', $table->getCacheName());

        if (!$url) {
            $alias = $table->Photos->getAlias();

            $albums = $table->find('active')
                ->select(['id', 'slug'])
                ->contain($alias, function (Query $q) use ($alias) {
                    return $q->find('active')
                        ->select(['id', 'album_id', 'modified'])
                        ->order([sprintf('%s.modified', $alias) => 'DESC']);
                });

            if ($albums->isEmpty()) {
                return [];
            }

            $latest = $table->Photos->find('active')
                ->select(['modified'])
                ->order([sprintf('%s.modified', $alias) => 'DESC'])
                ->firstOrFail();

            //Adds albums index
            $url[] = self::parse(['_name' => 'albums'], ['lastmod' => $latest->modified]);

            foreach ($albums as $album) {
                //Adds the album
                $url[] = self::parse(['_name' => 'album', $album->slug], ['lastmod' => array_value_first($album->photos)->modified]);

                //Adds each photo
                foreach ($album->photos as $photo) {
                    $url[] = self::parse(
                        ['_name' => 'photo', 'slug' => $album->slug, 'id' => $photo->id],
                        ['lastmod' => $photo->modified]
                    );
                }
            }

            Cache::write('sitemap', $url, $table->getCacheName());
        }

        return $url;
    }
public static function photos ( ) { if ( ! getConfig ( 'sitemap.photos' ) ) { return [ ] ; } $ table = TableRegistry :: get ( 'MeCms.PhotosAlbums' ) ; $ url = Cache :: read ( 'sitemap' , $ table -> getCacheName ( ) ) ; if ( ! $ url ) { $ alias = $ table -> Photos -> getAlias ( ) ; $ albums = $ table -> find ( 'active' ) -> select ( [ 'id' , 'slug' ] ) -> contain ( $ alias , function ( Query $ q ) use ( $ alias ) { return $ q -> find ( 'active' ) -> select ( [ 'id' , 'album_id' , 'modified' ] ) -> order ( [ sprintf ( '%s.modified' , $ alias ) => 'DESC' ] ) ; } ) ; if ( $ albums -> isEmpty ( ) ) { return [ ] ; } $ latest = $ table -> Photos -> find ( 'active' ) -> select ( [ 'modified' ] ) -> order ( [ sprintf ( '%s.modified' , $ alias ) => 'DESC' ] ) -> firstOrFail ( ) ; //Adds albums index $ url [ ] = self :: parse ( [ '_name' => 'albums' ] , [ 'lastmod' => $ latest -> modified ] ) ; foreach ( $ albums as $ album ) { //Adds the album $ url [ ] = self :: parse ( [ '_name' => 'album' , $ album -> slug ] , [ 'lastmod' => array_value_first ( $ album -> photos ) -> modified ] ) ; //Adds each photo foreach ( $ album -> photos as $ photo ) { $ url [ ] = self :: parse ( [ '_name' => 'photo' , 'slug' => $ album -> slug , 'id' => $ photo -> id ] , [ 'lastmod' => $ photo -> modified ] ) ; } } Cache :: write ( 'sitemap' , $ url , $ table -> getCacheName ( ) ) ; } return $ url ; }
Returns photos urls
@return array
@uses MeCms\Utility\SitemapBuilder::parse()
Returns photos urls