<?php
/**
 * Webkul Software.
 *
 * @category  Webkul
 * @package   Webkul_Agorae
 * @author    Webkul
 * @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html
 */
namespace Webkul\Agorae\Block\View\Element\Html;

/**
 * Agorae Block View Element Html Followlinks
 */
class Followlinks extends \Magento\Framework\View\Element\Html\Links
{
    /**
     * Render block HTML
     *
     * @return string
     */
    protected function _toHtml()
    {
        $helper = \Magento\Framework\App\ObjectManager::getInstance()->get(
            \Webkul\Agorae\Helper\Data::class
        );

        if (false != $this->getTemplate()) {
            return parent::_toHtml();
        }

        $html = '';
        if ($this->getLinks()) {
            $html = '<div' . ($this->hasCssClass() ? ' class="' . $this->escapeHtml(
                $this->getCssClass()
            ) . '"' : '') . '>';
            $html .= '<div class="block-title"><strong><span>'
                .($this->hasDivClass() ?
                    $this->escapeHtml(
                        $this->getDivClass()
                    ) : __('Company'))
                .'</span></strong></div>';

            $html .= '<ul' . ($this->hasCssClass() ? ' class="' . $this->escapeHtml(
                $this->getCssClass()
            ) . '"' : '') . '>';
            foreach ($this->getLinks() as $link) {
                if (isset($link['agorae_follow'])) {
                    if ($link['agorae_follow']=="agorae_blog") {
                        $link['path'] = $helper->getAgoraeFooterBlogLink();
                    } elseif ($link['agorae_follow']=="agorae_twitter") {
                        $link['path'] = $helper->getAgoraeFooterTwitterLink();
                    } elseif ($link['agorae_follow']=="agorae_facebook") {
                        $link['path'] = $helper->getAgoraeFooterFacebookLink();
                    } elseif ($link['agorae_follow']=="agorae_google") {
                        $link['path'] = $helper->getAgoraeFooterGoogleLink();
                    } elseif ($link['agorae_follow']=="agorae_rss") {
                        $link['path'] = $helper->getAgoraeFooterRssLink();
                    }
                    $html .= $this->renderLink($link);
                }
            }
            $html .= '</ul></div>';
        }
        return $html;
    }
}
