<?php
namespace OfficeBrain\Bundle\SeoBundle\Manager\AbstractManager;
use Symfony\Component\HttpFoundation\Request;

abstract class SeoAbstract
{
	protected $entityManager;
	protected $request;
	protected $productDetailManager;
	protected $knpPaginator;


		/**
	 * @author Employee Id: 5083
	 * OB eCommerce Product - Order
	 * Initialize the required variable on class load
	 */
	public function __construct($entityManager, $request, $productDetailManager, $knpPaginator)
	{
		$this->entityManager = $entityManager;
		$this->request = $request;
		$this->productDetailManager = $productDetailManager;
		$this->knpPaginator = $knpPaginator;
		$this->seoRepositoryManager = $this->entityManager->getRepository('OfficeBrainSeoBundle:SeoDetail');

		$this->seoCategoryRepositoryManager = $this->entityManager->getRepository('OfficeBrainSeoBundle:SeoCategory');

		$this->seoRepositoryManager->setPaginatorService($this->knpPaginator);

		$this->seoCategoryRepositoryManager->setPaginatorService($this->knpPaginator);

	}

	public function __destruct()
	{
		unset($this->entityManager);
		unset($this->request);
		unset($this->productDetailManager);
		unset($this->knpPaginator);
	}
	/**
     * @author Employee Id: 5083
     * OB eCommerce Product - getAdminAllSku
     * Function created to get AllSku
     */
    public function getAdminAllSku($page,$recordsPerPage, $searchParameter='')
    {    
    	$this->paginatorRecordSet = $this->seoRepositoryManager->getAdminAllSku($page,$recordsPerPage,$searchParameter);
        return $this->paginatorRecordSet;
    }

    public function deleteSeoDetailById($seoId)
	{
		if ($seoId > 0) {
			$infoId = $seoId;
		
		$isDeleted['data'] = $this->seoRepositoryManager->deleteSeo($infoId);
		if ($isDeleted) {
			$isDeleted['status'] = "SUCCESS";
			return $isDeleted;
		}
		$isDeleted['status']= 'ERROR_NOT_FOUND';
		return $isDeleted;
	 	} 	
	}
	public function checkDublicateSku($productsku)
    {    
    	$this->paginatorRecordSet = $this->seoRepositoryManager->getSeoDublicateSku($productsku);
        return $this->paginatorRecordSet;
    }

    public function checkDublicateSlug($slug)
    {    
    	$product= $this->seoRepositoryManager->getSeoDetailBySlug($slug);
        return $product;
    }

     public function checkDublicateCategorySlug($slug,$urlType)
    {    
    	$product= $this->seoCategoryRepositoryManager->getSeoCategoryBySlug($slug,$urlType);
        return $product;
    }

    public function getAdminCategoryContent($page,$recordsPerPage, $searchParameter=array())
    {    
    	$this->paginatorRecordSet = $this->seoCategoryRepositoryManager->getAdminCategoryContent($page,$recordsPerPage,$searchParameter);
        return $this->paginatorRecordSet;
    }

	
}