Answer the question
In order to leave comments, you need to log in
How in Symfony2 to automatically update user roles within sessions?
I have a small project that implements a custom system, due to:
<?php
class User extends \FOS\UserBundle\Model\User {
/**
* @ORM\OneToOne(targetEntity="Group")
* @ORM\JoinColumn(name="group_id", referencedColumnName="id")
* @var $group \Cyber\CraftBundle\Entity\Group
*/
protected $group;
//... другие поля
}
/**
* @ORM\Entity(repositoryClass="GroupRepository")
* @ORM\Table(name="cyber_groups")
*/
class Group implements \FOS\UserBundle\Model\GroupInterface
{
/**
* @ORM\ManyToMany(targetEntity="Role")
* @ORM\JoinTable(name="cyber_groups_user_roles")
*/
protected $roles;
/**
* @ORM\OneToOne(targetEntity="Group")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
}
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\Role\RoleInterface;
/**
* Role Entity
*
* @ORM\Entity(repositoryClass="RoleRepository")
* @ORM\Table(name="cyber_roles")
*/
class Role implements RoleInterface {
public static $ROLE_DEFAULT = "VIEW_SITE";
/**
* @ORM\Id
* @ORM\Column(type="integer", name="id")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", name="role", unique=true, length=70)
*/
private $role;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question