<?php declare(strict_types=1);
namespace PPAdmin\AdminSections\ShopsCategories;
use PlnaPenezenka\PPSDKBundle\Doctrine\Entity\Administrator;
use PlnaPenezenka\PPSDKBundle\Doctrine\Entity\ShopsCategory;
use PlnaPenezenka\PPSDKBundle\Doctrine\Entity\Common\DefaultEntity;
use PPAdmin\AdminSections\AdminSectionsList;
use PPAdmin\Security\AbstractAdminGridSectionVoter;
class ShopsCategoriesVoter extends AbstractAdminGridSectionVoter
{
function canDeleteRecord(Administrator $admin, DefaultEntity $record): bool
{
if(!parent::canDeleteRecord($admin, $record)){
return false;
}
/** @var $record ShopsCategory */
return
isset($record->id) &&
$record->children->isEmpty() &&
$record->parents->isEmpty() &&
$record->shops->isEmpty();
}
public static function getSectionIdentifier(): string
{
return AdminSectionsList::SHOPS_CATEGORIES;
}
}