<?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;

use Magento\Framework\View\Element\Template\Context;

/*
 * Webkul Agorae Feedbackcollection
 */
class Feedbackcollection extends \Magento\Framework\View\Element\Template
{
    /**
     * @var \Magento\Framework\Module\Manager
     */
    protected $moduleManager;

    /**
     * @var \Webkul\Marketpalce\Block\FeedBackcollection
     */
    protected $feedbackCollection;

    /**
     * @var \Magento\Framework\App\ObjectManager
     */
    protected $objectManager;

    /**
     * @param Context $context
     * @param \Magento\Framework\Module\Manager $moduleManager
     * @param array $data
     */
    public function __construct(
        Context $context,
        \Magento\Framework\Module\Manager $moduleManager,
        array $data = []
    ) {
        $this->objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $this->moduleManager = $moduleManager;
        if ($this->moduleManager->isOutputEnabled('Webkul_Marketpalce')) {
            $this->feedbackCollection = $this->objectManager->create(
                \Webkul\Marketplace\Block\Feedbackcollection::class
            );
        }
        parent::__construct($context, $data);
    }

    /**
     * [_prepareLayout]
     *
     * @return $this
     */
    protected function _prepareLayout()
    {
        if ($this->moduleManager->getCollection()) {
            $pager = $this->getLayout()->createBlock(
                \Magento\Theme\Block\Html\Pager::class,
                'agoraemp.feedback.pager'
            )
            ->setCollection(
                $this->getCollection()
            );
            $this->setChild('pager', $pager);
            $this->getCollection()->load();
        }
        return $this;
    }

    /**
     * Get Module Manager object
     *
     * @return object
     */
    public function getModuleManager()
    {
        return $this->moduleManager;
    }
}
