<?php declare(strict_types=1);
namespace PPAdmin\AdminSections\AffiliatePortNetworkAccounts;
use PlnaPenezenka\PPSDKBundle\Doctrine\Entity\Administrator;
use PlnaPenezenka\PPSDKBundle\Doctrine\Entity\Common\DefaultEntity;
use PlnaPenezenka\PPSDKBundle\Service\AffiliatePortClient\Models\V1\Affiliate\AffiliatePortNetworkAccount;
use PPAdmin\AdminSections\AdminSectionsList;
use PPAdmin\Security\AbstractAdminGridSectionVoter;
class AffiliatePortNetworkAccountsVoter extends AbstractAdminGridSectionVoter
{
public static function getSectionIdentifier(): string
{
return AdminSectionsList::AFFILIATE_PORT_NETWORK_ACCOUNTS;
}
protected static function getSupportedSectionPermissions(): array
{
$permissions = parent::getSupportedSectionPermissions();
$idx = array_search(self::SECTION_PERMISSION_VIEW_AUDIT, $permissions);
unset($permissions[$idx]);
return array_values($permissions);
}
function canViewSectionRecord(Administrator $admin, AffiliatePortNetworkAccount|DefaultEntity $record): bool
{
$current_web = $this->webs_resolver->getCurrentManagedWeb();
return
$this->canAccessSection($admin, $current_web) &&
$admin->hasPermission(static::getViewDetailPermission(), $current_web);
}
function canEditRecord(Administrator $admin, AffiliatePortNetworkAccount|DefaultEntity $record): bool
{
$current_web = $this->webs_resolver->getCurrentManagedWeb();
return
$this->canAccessSection($admin, $current_web) &&
$admin->hasPermission(static::getEditPermission(), $current_web);
}
function canDeleteRecord(Administrator $admin, AffiliatePortNetworkAccount|DefaultEntity $record): bool
{
$current_web = $this->webs_resolver->getCurrentManagedWeb();
return
$this->canAccessSection($admin, $current_web) &&
$admin->hasPermission(static::getDeletePermission(), $current_web);
}
function canViewRecordAudit(Administrator $admin, AffiliatePortNetworkAccount|DefaultEntity $record): bool
{
return false;
}
}