Commit e2aae3da authored by David Surville's avatar David Surville
Browse files

[Tac] Quelques modifications mineures

parent 397a619e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ CREATE TABLE UNICAEN_PRIVILEGE (
  CATEGORIE_ID INTEGER      NOT NULL,
  CODE         VARCHAR(150) NOT NULL,
  LIBELLE      VARCHAR(200) NOT NULL,
  ORDRE        INTEGER      NOT NULL,
  ORDRE        INTEGER      DEFAULT 0,
  CONSTRAINT FK_UNICAEN_PRIVILEGE_CATEGORIE FOREIGN KEY (CATEGORIE_ID) REFERENCES UNICAEN_PRIVILEGE_CATEGORIE (ID) DEFERRABLE INITIALLY IMMEDIATE
);

+217 −0
Original line number Diff line number Diff line
<?php

namespace UnicaenPrivilege\Entity\Db;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

abstract class AbstractCategorie implements CategorieInterface
{
    /**
     * @var int
     */
    protected $id;

    /**
     * @var string
     */
    protected $code;

    /**
     * @var string
     */
    protected $libelle;

    /**
     * @var string
     */
    protected $namespace;

    /**
     * @var int
     */
    protected $ordre;

    /**
     * @var ArrayCollection
     */
    protected $privileges;


    /**
     * Categorie constructor
     */
    public function __construct()
    {
        $this->privileges = new ArrayCollection();
    }

    /**
     * @return string
     */
    public function __toString()
    {
        return $this->getLibelle();
    }

    /**
     * Get id.
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set id.
     *
     * @param int $id
     * @return CategorieInterface
     */
    public function setId($id)
    {
        $this->id = (int)$id;

        return $this;
    }

    /**
     * Get code.
     *
     * @return string
     */
    public function getCode()
    {
        return $this->code;
    }

    /**
     * Set code.
     *
     * @param string $code
     * @return CategorieInterface
     */
    public function setCode($code)
    {
        $this->code = $code;

        return $this;
    }

    /**
     * Get libelle.
     *
     * @return string
     */
    public function getLibelle()
    {
        return $this->libelle;
    }

    /**
     * Set libelle.
     *
     * @param string $libelle
     * @return CategorieInterface
     */
    public function setLibelle($libelle)
    {
        $this->libelle = $libelle;

        return $this;
    }

    /**
     * Get namespace.
     *
     * @return string
     */
    public function getNamespace()
    {
        return $this->namespace;
    }

    /**
     * Set namespace.
     *
     * @param string $namespace
     * @return CategorieInterface
     */
    public function setNamespace($namespace)
    {
        $this->namespace = $namespace;

        return $this;
    }

    /**
     * Get ordre.
     *
     * @return int
     */
    public function getOrdre()
    {
        return $this->ordre;
    }

    /**
     * Set ordre.
     *
     * @param int $ordre
     * @return CategorieInterface
     */
    public function setOrdre($ordre)
    {
        $this->ordre = (int)$ordre;

        return $this;
    }

    /**
     * Get privileges.
     *
     * @return Collection
     */
    public function getPrivileges()
    {
        return $this->privileges;
    }

    /**
     * Add privilege.
     *
     * @param PrivilegeInterface $privilege
     * @return CategorieInterface
     */
    public function addPrivilege(PrivilegeInterface $privilege)
    {
        $this->privileges->add($privilege);

        return $this;
    }

    /**
     * Remove privilege.
     *
     * @param PrivilegeInterface $privilege
     * @return CategorieInterface
     */
    public function removePrivilege(PrivilegeInterface $privilege)
    {
        $this->privileges->removeElement($privilege);

        return $this;
    }

    /**
     * Get privileges class name
     *
     * @return string
     */
    public function getClassname()
    {
        return ucfirst(strtolower($this->getCode())) . "Privileges";
    }
}
 No newline at end of file
+1 −213
Original line number Diff line number Diff line
@@ -2,216 +2,4 @@

namespace UnicaenPrivilege\Entity\Db;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

class Categorie implements CategorieInterface
{
    /**
     * @var int
     */
    private $id;

    /**
     * @var string
     */
    private $code;

    /**
     * @var string
     */
    private $libelle;

    /**
     * @var string
     */
    private $namespace;

    /**
     * @var int
     */
    private $ordre;

    /**
     * @var ArrayCollection
     */
    private $privileges;


    /**
     * Categorie constructor
     */
    public function __construct()
    {
        $this->privileges = new ArrayCollection();
    }

    /**
     * @return string
     */
    public function __toString()
    {
        return $this->getLibelle();
    }

    /**
     * Get id.
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set id.
     *
     * @param int $id
     * @return CategorieInterface
     */
    public function setId($id)
    {
        $this->id = (int)$id;

        return $this;
    }

    /**
     * Get code.
     *
     * @return string
     */
    public function getCode()
    {
        return $this->code;
    }

    /**
     * Set code.
     *
     * @param string $code
     * @return CategorieInterface
     */
    public function setCode($code)
    {
        $this->code = $code;

        return $this;
    }

    /**
     * Get libelle.
     *
     * @return string
     */
    public function getLibelle()
    {
        return $this->libelle;
    }

    /**
     * Set libelle.
     *
     * @param string $libelle
     * @return CategorieInterface
     */
    public function setLibelle($libelle)
    {
        $this->libelle = $libelle;

        return $this;
    }

    /**
     * Get namespace.
     *
     * @return string
     */
    public function getNamespace()
    {
        return $this->namespace;
    }

    /**
     * Set namespace.
     *
     * @param string $namespace
     * @return CategorieInterface
     */
    public function setNamespace($namespace)
    {
        $this->namespace = $namespace;

        return $this;
    }

    /**
     * Get ordre.
     *
     * @return int
     */
    public function getOrdre()
    {
        return $this->ordre;
    }

    /**
     * Set ordre.
     *
     * @param int $ordre
     * @return CategorieInterface
     */
    public function setOrdre($ordre)
    {
        $this->ordre = (int)$ordre;

        return $this;
    }

    /**
     * Get privileges.
     *
     * @return Collection
     */
    public function getPrivileges()
    {
        return $this->privileges;
    }

    /**
     * Add privilege.
     *
     * @param PrivilegeInterface $privilege
     * @return CategorieInterface
     */
    public function addPrivilege(PrivilegeInterface $privilege)
    {
        $this->privileges->add($privilege);

        return $this;
    }

    /**
     * Remove privilege.
     *
     * @param PrivilegeInterface $privilege
     * @return CategorieInterface
     */
    public function removePrivilege(PrivilegeInterface $privilege)
    {
        $this->privileges->removeElement($privilege);

        return $this;
    }

    /**
     * Get privileges class name
     *
     * @return string
     */
    public function getClassname()
    {
        return ucfirst(strtolower($this->getCode())) . "Privileges";
    }
}
 No newline at end of file
class Categorie extends AbstractCategorie {}
 No newline at end of file
+10 −1
Original line number Diff line number Diff line
@@ -26,7 +26,16 @@
            </join-columns>
        </many-to-one>

        <many-to-many field="roles" target-entity="UnicaenUtilisateur\Entity\Db\Role" mapped-by="privileges" fetch="LAZY"/>
        <many-to-many field="roles" target-entity="UnicaenUtilisateur\Entity\Db\Role" inversed-by="privileges" fetch="LAZY">
            <join-table name="UNICAEN_ROLE_PRIVILEGE_LINKER">
                <join-columns>
                    <join-column name="PRIVILEGE_ID" referenced-column-name="ID"/>
                </join-columns>
                <inverse-join-columns>
                    <join-column name="ROLE_ID" referenced-column-name="ID"/>
                </inverse-join-columns>
            </join-table>
        </many-to-many>

    </entity>
</doctrine-mapping>