PHP code example of spotonlive / sl-entrust-doctrine-orm
1. Go to this page and download the library: Download spotonlive/sl-entrust-doctrine-orm library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spotonlive / sl-entrust-doctrine-orm example snippets
use Doctrine\Common\Collections\ArrayCollection;
class User implements \SpotOnLive\EntrustDoctrineORM\Entities\UserRoleInterface
{
/**
* @var \SpotOnLive\EntrustDoctrineORM\Entities\RoleInterface[]|ArrayCollection
*
* @ORM\ManyToMany(targetEntity="SpotOnLive\EntrustDoctrineORM\Entities\Role")
* @ORM\JoinTable(name="user_role_linker",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")}
* )
**/
protected $roles;
public function __construct()
{
$this->roles = new ArrayCollection();
}
/**
* @return ArrayCollection|\SpotOnLive\EntrustDoctrineORM\Entities\RoleInterface[]
*/
public function getRoles()
{
return $this->roles;
}
/**
* @param ArrayCollection|\SpotOnLive\EntrustDoctrineORM\Entities\RoleInterface[] $roles
*/
public function setRoles($roles)
{
$this->roles = $roles;
}
/**
* @param \SpotOnLive\EntrustDoctrineORM\Entities\RoleInterface[] $roles
*/
public function addRoles($roles)
{
$this->roles->add($roles);
}
/**
* @param \SpotOnLive\EntrustDoctrineORM\Entities\RoleInterface[] $roles
*/
public function removeRoles($roles)
{
$this->roles->remove($roles);
}
(...)
}