<?php

namespace Diamond\Repositories;

use Core\Repository\CrudInterface;
use Core\Repository\PropelQueryAbstract;
use Diamond\Infrastructure\Models\Page\Page as PageEntity;
use \Diamond\Infrastructure\Models\Page\PageQuery;
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;

/**
 * Description of Page
 *
 * @author Admin
 */
class Page extends PropelQueryAbstract implements CrudInterface#,
        #\Shop\Contracts\ShopCurrentInterface
        {
    
   # use \Shop\Concrete\ShopAuthUserTrait;
    
    public function buildEntity() {
        return new PageEntity();
    }

    public function buildQuery() {

        /**
         * @todo Реализовать работу с поддоменами на уровне новых CRUD репозиторий и критерий выборки
         */
        #$id = is_a($this->curShop,ActiveRecordInterface::class) ? $this->curShop->getId() : 0;
        $id = 0;
        return PageQuery::create()
                ->_if( $id > 0 )
                    ->addJoin("_pages.domain_id","`shop_shops`.`domain_id` ")
                    ->where("`shop_shops`.`id` = " .  $id)
                ->_endif()
                ;
    }
}