public function getPermalink(ItemInterface $item)
    {
        if ($item->getPath(ItemInterface::SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT) === '') {
            return new Permalink('', '');
        }

        $placeholders = $this->getPlacehoders($item);
        $permalinkStyle = $this->getPermalinkAttribute($item);
        $noHtmlExtension = $this->getNoHtmlExtensionAttribute($item);

        if ($item->isBinary() === true) {
            $urlTemplate = $this::PERMALINK_NONE;
            $path = $this->generatePath($urlTemplate, $placeholders);
            $urlPath = $this->generateUrlPath($urlTemplate, $placeholders);

            return new Permalink($path, $urlPath);
        }

        switch ($permalinkStyle) {
            case 'none':
                $urlTemplate = $this::PERMALINK_NONE;
                break;
            case 'ordinal':
                if ($this->isItemWithDate($item) === true) {
                    $urlTemplate = $this::PERMALINK_ORDINAL;

                    if ($this->isCustomCollection($item)) {
                        $urlTemplate = '/:collection'.$urlTemplate;
                    }
                } else {
                    $urlTemplate = $this::PERMALINK_NONE;
                }
                break;
            case 'pretty':
                $noHtmlExtension = true;
            case 'date':
                if ($this->isItemWithDate($item) === true) {
                    $urlTemplate = $this::PERMALINK_DATE;

                    if ($this->isCustomCollection($item)) {
                        $urlTemplate = '/:collection'.$urlTemplate;
                    }
                } else {
                    $urlTemplate = $this::PERMALINK_NONE;
                }
                break;
            default:
                if ($this->templateNeedsDate($permalinkStyle) === false || $this->isItemWithDate($item) === true) {
                    $urlTemplate = $permalinkStyle;
                } else {
                    $urlTemplate = $this::PERMALINK_NONE;
                }
                break;
        }

        if ($noHtmlExtension && $placeholders[':extension'] === 'html') {
            if ($placeholders[':basename'] === 'index') {
                $placeholders[':basename'] = '';
            }

            $urlTemplate = str_replace(['.:extension', ':extension'], '', $urlTemplate);
            $pathTemplate = $urlTemplate.'/index.html';
        } else {
            $pathTemplate = $urlTemplate;
        }

        $path = $this->generatePath($pathTemplate, $placeholders);
        $urlPath = $this->generateUrlPath($urlTemplate, $placeholders);

        return new Permalink($path, $urlPath);
    }
public function getPermalink(ItemInterface $item)
    {
        if ($item->getPath(ItemInterface::SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT) === '') {
            return new Permalink('', '');
        }

        $placeholders = $this->getPlacehoders($item);
        $permalinkStyle = $this->getPermalinkAttribute($item);
        $noHtmlExtension = $this->getNoHtmlExtensionAttribute($item);

        if ($item->isBinary() === true) {
            $urlTemplate = $this::PERMALINK_NONE;
            $path = $this->generatePath($urlTemplate, $placeholders);
            $urlPath = $this->generateUrlPath($urlTemplate, $placeholders);

            return new Permalink($path, $urlPath);
        }

        switch ($permalinkStyle) {
            case 'none':
                $urlTemplate = $this::PERMALINK_NONE;
                break;
            case 'ordinal':
                if ($this->isItemWithDate($item) === true) {
                    $urlTemplate = $this::PERMALINK_ORDINAL;

                    if ($this->isCustomCollection($item)) {
                        $urlTemplate = '/:collection'.$urlTemplate;
                    }
                } else {
                    $urlTemplate = $this::PERMALINK_NONE;
                }
                break;
            case 'pretty':
                $noHtmlExtension = true;
            case 'date':
                if ($this->isItemWithDate($item) === true) {
                    $urlTemplate = $this::PERMALINK_DATE;

                    if ($this->isCustomCollection($item)) {
                        $urlTemplate = '/:collection'.$urlTemplate;
                    }
                } else {
                    $urlTemplate = $this::PERMALINK_NONE;
                }
                break;
            default:
                if ($this->templateNeedsDate($permalinkStyle) === false || $this->isItemWithDate($item) === true) {
                    $urlTemplate = $permalinkStyle;
                } else {
                    $urlTemplate = $this::PERMALINK_NONE;
                }
                break;
        }

        if ($noHtmlExtension && $placeholders[':extension'] === 'html') {
            if ($placeholders[':basename'] === 'index') {
                $placeholders[':basename'] = '';
            }

            $urlTemplate = str_replace(['.:extension', ':extension'], '', $urlTemplate);
            $pathTemplate = $urlTemplate.'/index.html';
        } else {
            $pathTemplate = $urlTemplate;
        }

        $path = $this->generatePath($pathTemplate, $placeholders);
        $urlPath = $this->generateUrlPath($urlTemplate, $placeholders);

        return new Permalink($path, $urlPath);
    }
public function getPermalink ( ItemInterface $ item ) { if ( $ item -> getPath ( ItemInterface :: SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT ) === '' ) { return new Permalink ( '' , '' ) ; } $ placeholders = $ this -> getPlacehoders ( $ item ) ; $ permalinkStyle = $ this -> getPermalinkAttribute ( $ item ) ; $ noHtmlExtension = $ this -> getNoHtmlExtensionAttribute ( $ item ) ; if ( $ item -> isBinary ( ) === true ) { $ urlTemplate = $ this :: PERMALINK_NONE ; $ path = $ this -> generatePath ( $ urlTemplate , $ placeholders ) ; $ urlPath = $ this -> generateUrlPath ( $ urlTemplate , $ placeholders ) ; return new Permalink ( $ path , $ urlPath ) ; } switch ( $ permalinkStyle ) { case 'none' : $ urlTemplate = $ this :: PERMALINK_NONE ; break ; case 'ordinal' : if ( $ this -> isItemWithDate ( $ item ) === true ) { $ urlTemplate = $ this :: PERMALINK_ORDINAL ; if ( $ this -> isCustomCollection ( $ item ) ) { $ urlTemplate = '/:collection' . $ urlTemplate ; } } else { $ urlTemplate = $ this :: PERMALINK_NONE ; } break ; case 'pretty' : $ noHtmlExtension = true ; case 'date' : if ( $ this -> isItemWithDate ( $ item ) === true ) { $ urlTemplate = $ this :: PERMALINK_DATE ; if ( $ this -> isCustomCollection ( $ item ) ) { $ urlTemplate = '/:collection' . $ urlTemplate ; } } else { $ urlTemplate = $ this :: PERMALINK_NONE ; } break ; default : if ( $ this -> templateNeedsDate ( $ permalinkStyle ) === false || $ this -> isItemWithDate ( $ item ) === true ) { $ urlTemplate = $ permalinkStyle ; } else { $ urlTemplate = $ this :: PERMALINK_NONE ; } break ; } if ( $ noHtmlExtension && $ placeholders [ ':extension' ] === 'html' ) { if ( $ placeholders [ ':basename' ] === 'index' ) { $ placeholders [ ':basename' ] = '' ; } $ urlTemplate = str_replace ( [ '.:extension' , ':extension' ] , '' , $ urlTemplate ) ; $ pathTemplate = $ urlTemplate . '/index.html' ; } else { $ pathTemplate = $ urlTemplate ; } $ path = $ this -> generatePath ( $ pathTemplate , $ placeholders ) ; $ urlPath = $ this -> generateUrlPath ( $ urlTemplate , $ placeholders ) ; return new Permalink ( $ path , $ urlPath ) ; }
Gets a permalink. This method uses the SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT of Item path.

For binary items URL path and path point to SNAPSHOT_PATH_RELATIVE.

Item's attributes with special meaning:
- title: title of the item.
- title_path: title extracted from the date filename pattern.
- preserve_path_title: if true "title_path" instead of "title" will be used with ":title" placeholder.
- date: date of item.
- categories: categories for the item
- permalink: permalink sytle.
- collection: the name of the item's collection.

@param \Yosymfony\Spress\Core\DataSource\ItemInterface $item

@return \Yosymfony\Spress\Core\ContentManager\Permalink\PermalinkInterface
Gets a permalink . This method uses the SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT of Item path .