src/AdminSections/ShopsCategories/ShopsCategoriesVoter.php line 10

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace PPAdmin\AdminSections\ShopsCategories;
  3. use PlnaPenezenka\PPSDKBundle\Doctrine\Entity\Administrator;
  4. use PlnaPenezenka\PPSDKBundle\Doctrine\Entity\ShopsCategory;
  5. use PlnaPenezenka\PPSDKBundle\Doctrine\Entity\Common\DefaultEntity;
  6. use PPAdmin\AdminSections\AdminSectionsList;
  7. use PPAdmin\Security\AbstractAdminGridSectionVoter;
  8. class ShopsCategoriesVoter extends AbstractAdminGridSectionVoter
  9. {
  10.     function canDeleteRecord(Administrator $adminDefaultEntity $record): bool
  11.     {
  12.         if(!parent::canDeleteRecord($admin$record)){
  13.             return false;
  14.         }
  15.         /** @var $record ShopsCategory */
  16.         return
  17.             isset($record->id) &&
  18.             $record->children->isEmpty() &&
  19.             $record->parents->isEmpty() &&
  20.             $record->shops->isEmpty();
  21.     }
  22.     public static function getSectionIdentifier(): string
  23.     {
  24.         return AdminSectionsList::SHOPS_CATEGORIES;
  25.     }
  26. }