Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/mageworx/module-seobase/Plugin/NextPrev/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/mageworx/module-seobase/Plugin/NextPrev/ResponseHttpBefore.php
<?php
/**
 * Copyright © 2015 MageWorx. All rights reserved.
 * See LICENSE.txt for license details.
 */

namespace MageWorx\SeoBase\Plugin\NextPrev;

use MageWorx\SeoBase\Helper\Data as HelperData;
use Magento\Framework\Registry;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\UrlInterface;
use MageWorx\SeoBase\Model\NextPrevFactory;

class ResponseHttpBefore
{
    /**
     * @var  \MageWorx\SeoBase\Helper\Data
     */
    protected $helperData;

    /**
     * @var \Magento\Framework\Registry
     */
    protected $registry;

    /**
     * Request object
     *
     * @var \Magento\Framework\App\RequestInterface
     */
    protected $request;

    /**
     * @var \Magento\Framework\UrlInterface
     */
    protected $url;

    /**
     * @var NextPrevFactory
     */
    protected $nextPrevFactory;

    /**
     * @param HelperData $helperData
     * @param Registry $registry
     * @param RequestInterface $request
     * @param UrlInterface $url
     * @param NextPrevFactory $nextPrevFactory
     */
    public function __construct(
        HelperData $helperData,
        Registry $registry,
        RequestInterface $request,
        UrlInterface $url,
        NextPrevFactory $nextPrevFactory
    ) {
        $this->helperData      = $helperData;
        $this->registry        = $registry;
        $this->request         = $request;
        $this->url             = $url;
        $this->nextPrevFactory = $nextPrevFactory;
    }

    /**
     * Add next/prev link relations
     *
     * @param \Magento\Framework\App\Response\Http $subject
     * @param string $value
     * @return array
     */
    public function beforeAppendBody($subject, $value)
    {
        if (!$this->helperData->useNextPrev()) {
            return [$value];
        }
        if (is_callable([$subject, 'isAjax']) && $subject->isAjax()) {
            return [$value];
        }
        $fullActionName = $this->request->getFullActionName();
        /** @var \MageWorx\SeoBase\Model\NextPrev */
        $nextPrevInstance = $this->nextPrevFactory->create($fullActionName, $arguments = []);
        if ($nextPrevInstance) {
            $nextUrl = $nextPrevInstance->getNextUrl();
            $prevUrl = $nextPrevInstance->getPrevUrl();

            if (!empty($prevUrl)) {
                $prevStr = '<link rel="prev" href="' . $prevUrl . '" />';
                $value = str_ireplace('</head>', "\n" . $prevStr . '</head>', $value);
            }

            if (!empty($nextUrl)) {
                $nextStr = '<link rel="next" href="' . $nextUrl . '" /> ';
                $value = str_ireplace('</head>', "\n" . $nextStr . '</head>', $value);
            }
        }
        return [$value];
    }
}

Spamworldpro Mini