public function handleItem($item, $lang)
    {
        if (is_array($item)) {
            $item = new SitemapArrayItem($item);
            $loc = $item->getSitemapLoc();
            if (empty($loc)) {
                $this->printMessage('Warning: item "' . var_export($item->item, true) .
                    '" does not have a "loc" value');

                return false;
            }
        } elseif (!$item instanceof Basic) {
            $this->printMessage('Warning: item "' . var_export($item, true) .
                '" does not compatible with "demi\sitemap\interfaces\Basic" or Array');

            return false;
        }

        $builder = $this->builder;
        $url = $builder->newUrl();

        // Basic attributes
        $url->loc($item->getSitemapLoc($lang))
            ->lastmod($item->getSitemapLastmod($lang))
            ->changefreq($item->getSitemapChangefreq($lang))
            ->priority($item->getSitemapPriority($lang));

        // Google image attribute
        if ($item instanceof GoogleImage) {
            $images = $item->getSitemapMaterialImages($item, $lang);

            foreach ($images as $image) {
                $url->addImage(
                    $item->getSitemapImageLoc($image, $lang),
                    $item->getSitemapImageGeoLocation($image, $lang),
                    $item->getSitemapImageCaption($image, $lang),
                    $item->getSitemapImageTitle($image, $lang),
                    $item->getSitemapImageLicense($image, $lang)
                );
            }
        }

        // Google alternate links
        if ($item instanceof GoogleAlternateLang || $item instanceof SitemapArrayItem) {
            $links = $item->getSitemapAlternateLinks();

            foreach ($links as $hreflang => $href) {
                $url->addAlternateLink($hreflang, $href);
            }
        }

        return $builder->writeUrl($url);
    }
public function handleItem($item, $lang)
    {
        if (is_array($item)) {
            $item = new SitemapArrayItem($item);
            $loc = $item->getSitemapLoc();
            if (empty($loc)) {
                $this->printMessage('Warning: item "' . var_export($item->item, true) .
                    '" does not have a "loc" value');

                return false;
            }
        } elseif (!$item instanceof Basic) {
            $this->printMessage('Warning: item "' . var_export($item, true) .
                '" does not compatible with "demi\sitemap\interfaces\Basic" or Array');

            return false;
        }

        $builder = $this->builder;
        $url = $builder->newUrl();

        // Basic attributes
        $url->loc($item->getSitemapLoc($lang))
            ->lastmod($item->getSitemapLastmod($lang))
            ->changefreq($item->getSitemapChangefreq($lang))
            ->priority($item->getSitemapPriority($lang));

        // Google image attribute
        if ($item instanceof GoogleImage) {
            $images = $item->getSitemapMaterialImages($item, $lang);

            foreach ($images as $image) {
                $url->addImage(
                    $item->getSitemapImageLoc($image, $lang),
                    $item->getSitemapImageGeoLocation($image, $lang),
                    $item->getSitemapImageCaption($image, $lang),
                    $item->getSitemapImageTitle($image, $lang),
                    $item->getSitemapImageLicense($image, $lang)
                );
            }
        }

        // Google alternate links
        if ($item instanceof GoogleAlternateLang || $item instanceof SitemapArrayItem) {
            $links = $item->getSitemapAlternateLinks();

            foreach ($links as $hreflang => $href) {
                $url->addAlternateLink($hreflang, $href);
            }
        }

        return $builder->writeUrl($url);
    }
public function handleItem ( $ item , $ lang ) { if ( is_array ( $ item ) ) { $ item = new SitemapArrayItem ( $ item ) ; $ loc = $ item -> getSitemapLoc ( ) ; if ( empty ( $ loc ) ) { $ this -> printMessage ( 'Warning: item "' . var_export ( $ item -> item , true ) . '" does not have a "loc" value' ) ; return false ; } } elseif ( ! $ item instanceof Basic ) { $ this -> printMessage ( 'Warning: item "' . var_export ( $ item , true ) . '" does not compatible with "demi\sitemap\interfaces\Basic" or Array' ) ; return false ; } $ builder = $ this -> builder ; $ url = $ builder -> newUrl ( ) ; // Basic attributes $ url -> loc ( $ item -> getSitemapLoc ( $ lang ) ) -> lastmod ( $ item -> getSitemapLastmod ( $ lang ) ) -> changefreq ( $ item -> getSitemapChangefreq ( $ lang ) ) -> priority ( $ item -> getSitemapPriority ( $ lang ) ) ; // Google image attribute if ( $ item instanceof GoogleImage ) { $ images = $ item -> getSitemapMaterialImages ( $ item , $ lang ) ; foreach ( $ images as $ image ) { $ url -> addImage ( $ item -> getSitemapImageLoc ( $ image , $ lang ) , $ item -> getSitemapImageGeoLocation ( $ image , $ lang ) , $ item -> getSitemapImageCaption ( $ image , $ lang ) , $ item -> getSitemapImageTitle ( $ image , $ lang ) , $ item -> getSitemapImageLicense ( $ image , $ lang ) ) ; } } // Google alternate links if ( $ item instanceof GoogleAlternateLang || $ item instanceof SitemapArrayItem ) { $ links = $ item -> getSitemapAlternateLinks ( ) ; foreach ( $ links as $ hreflang => $ href ) { $ url -> addAlternateLink ( $ hreflang , $ href ) ; } } return $ builder -> writeUrl ( $ url ) ; }
Handle sitemap item

@param Basic|GoogleImage|GoogleAlternateLang|ActiveRecord $item
@param string $lang

@return bool
Handle sitemap item