103 lines
2.5 KiB
PHP
103 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace KupShop\SellerBundle\View;
|
|
|
|
use KupShop\ComponentsBundle\View\ComponentsViewInterface;
|
|
use KupShop\KupShopBundle\Views\View;
|
|
use KupShop\SellerBundle\Twig\ComponentsTemplateOverride;
|
|
use KupShop\SellerBundle\Utils\SellerUtil;
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
class DetailView extends View implements ComponentsViewInterface
|
|
{
|
|
use ComponentsTemplateOverride;
|
|
|
|
protected $template = 'seller/seller.detail.tpl';
|
|
|
|
/** @var int ID of seller */
|
|
protected $id_seller;
|
|
|
|
private $seller;
|
|
|
|
/** @var SellerUtil */
|
|
private $sellerUtil;
|
|
|
|
/**
|
|
* @required
|
|
*/
|
|
public function setSellerUtil(SellerUtil $sellerUtil): void
|
|
{
|
|
$this->sellerUtil = $sellerUtil;
|
|
}
|
|
|
|
public function getTitle()
|
|
{
|
|
return $this->getSeller()['title'] ?? '';
|
|
}
|
|
|
|
public function getBreadcrumbs()
|
|
{
|
|
return [
|
|
[
|
|
[
|
|
'text' => translate('getSections', 'functions')['home'],
|
|
'link' => path('home'),
|
|
],
|
|
[
|
|
'text' => translate('title', 'sellers'),
|
|
'link' => path('shop_seller_seller_map'),
|
|
],
|
|
[
|
|
'text' => $this->getSeller()['title'],
|
|
],
|
|
],
|
|
];
|
|
}
|
|
|
|
public function getWpjToolbar()
|
|
{
|
|
return array_merge(parent::getWpjToolbar(), [
|
|
'url' => getAdminUrl('sellers', ['ID' => $this->id_seller]),
|
|
'title' => 'Úprava prodejce',
|
|
]);
|
|
}
|
|
|
|
public function getBodyVariables()
|
|
{
|
|
$body = parent::getBodyVariables();
|
|
|
|
$body['dealers'] = $this->getSeller();
|
|
$body['blocks'] = $this->getSeller()['blocks'];
|
|
|
|
if (findModule(\Modules::COMPONENTS) && !findModule(\Modules::SELLERS, \Modules::SUB_SMARTY_SELLERS)) {
|
|
// rozbiji encode sellera a tim padem i live komponentu
|
|
unset($body['dealers']['position']);
|
|
}
|
|
|
|
return $body;
|
|
}
|
|
|
|
/**
|
|
* @param int $id_seller
|
|
*
|
|
* @return DetailView
|
|
*/
|
|
public function setIdSeller($id_seller)
|
|
{
|
|
$this->id_seller = $id_seller;
|
|
|
|
return $this;
|
|
}
|
|
|
|
private function getSeller(): array
|
|
{
|
|
if (!$this->seller) {
|
|
if (!($this->seller = $this->sellerUtil->getSeller((int) $this->id_seller))) {
|
|
throw new NotFoundHttpException('Seller not found');
|
|
}
|
|
}
|
|
|
|
return $this->seller;
|
|
}
|
|
}
|