Sindbad~EG File Manager

Current Path : /opt/nginxhttpd_/vendor/symfony/maker-bundle/src/Resources/skeleton/security/
Upload File :
Current File : //opt/nginxhttpd_/vendor/symfony/maker-bundle/src/Resources/skeleton/security/Voter.tpl.php

<?= "<?php\n" ?>

namespace <?= $namespace; ?>;

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\User\UserInterface;

class <?= $class_name ?> extends Voter
{
    public const EDIT = 'POST_EDIT';
    public const VIEW = 'POST_VIEW';

    protected function supports(<?= $use_type_hints ? 'string ' : null ?>$attribute, $subject): bool
    {
        // replace with your own logic
        // https://symfony.com/doc/current/security/voters.html
        return in_array($attribute, [self::EDIT, self::VIEW])
            && $subject instanceof \App\Entity\<?= str_replace('Voter', null, $class_name) ?>;
    }

    protected function voteOnAttribute(<?= $use_type_hints ? 'string ' : null ?>$attribute, $subject, TokenInterface $token): bool
    {
        $user = $token->getUser();
        // if the user is anonymous, do not grant access
        if (!$user instanceof UserInterface) {
            return false;
        }

        // ... (check conditions and return true to grant permission) ...
        switch ($attribute) {
            case self::EDIT:
                // logic to determine if the user can EDIT
                // return true or false
                break;
            case self::VIEW:
                // logic to determine if the user can VIEW
                // return true or false
                break;
        }

        return false;
    }
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists