mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 03:07:58 +00:00 
			
		
		
		
	Optimized CrudAttribut logic
This commit is contained in:
		@@ -2,6 +2,9 @@
 | 
			
		||||
 | 
			
		||||
namespace App\Entity\Attribut;
 | 
			
		||||
 | 
			
		||||
use App\Exception\NoValidChoiceException;
 | 
			
		||||
use App\DBAL\Types\Meta\Right\CRUDType;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @todo Implement a trait for crud which substitute this one.
 | 
			
		||||
 *
 | 
			
		||||
@@ -10,6 +13,8 @@ namespace App\Entity\Attribut;
 | 
			
		||||
trait CrudAttribut
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @see CRUDType
 | 
			
		||||
     *
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $crud;
 | 
			
		||||
@@ -19,6 +24,9 @@ trait CrudAttribut
 | 
			
		||||
     */
 | 
			
		||||
    public function setCrud(string $crud): void
 | 
			
		||||
    {
 | 
			
		||||
        if (!array_key_exists($crud, CRUDType::getChoices())) {
 | 
			
		||||
            throw new NoValidChoiceException();
 | 
			
		||||
        }
 | 
			
		||||
        $this->crud = $crud;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -99,19 +99,6 @@ class Right extends AbstractMeta implements RightInterface
 | 
			
		||||
        $this->priority = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     *
 | 
			
		||||
     * @see \App\Entity\Attribut\CrudAttributInterface::setCrud()
 | 
			
		||||
     */
 | 
			
		||||
    public function setCrud(string $crud): void
 | 
			
		||||
    {
 | 
			
		||||
        if (!array_key_exists($crud, CRUDType::getChoices())) {
 | 
			
		||||
            throw new NoValidChoiceException();
 | 
			
		||||
        }
 | 
			
		||||
        $this->crud = $crud;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user