mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
create Access Control Model
This commit is contained in:
parent
ec3e08ff79
commit
7fc8b1ca1e
@ -39,21 +39,30 @@ class LoadCenters extends AbstractFixture implements OrderedFixtureInterface
|
|||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static $centers = array(
|
||||||
|
array(
|
||||||
|
'name' => 'Center A',
|
||||||
|
'ref' => 'centerA'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Center B',
|
||||||
|
'ref' => 'centerB'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $refs = array();
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
$centerA = new Center();
|
foreach (static::$centers as $new) {
|
||||||
$centerA->setName('Center A');
|
$centerA = new Center();
|
||||||
|
$centerA->setName($new['name']);
|
||||||
|
|
||||||
$manager->persist($centerA);
|
$manager->persist($centerA);
|
||||||
$this->addReference('centerA', $centerA);
|
$this->addReference($new['ref'], $centerA);
|
||||||
|
static::$refs[] = $new['ref'];
|
||||||
$centerB = new Center();
|
}
|
||||||
$centerB->setName('center B');
|
|
||||||
|
|
||||||
$manager->persist($centerB);
|
|
||||||
$this->addReference('centerB', $centerB);
|
|
||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
63
DataFixtures/ORM/LoadGroupCenters.php
Normal file
63
DataFixtures/ORM/LoadGroupCenters.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a suite of a modules, Chill is a software for social workers
|
||||||
|
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
|
use Chill\MainBundle\Entity\GroupCenter;
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadCenters;
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
|
class LoadGroupCenters extends AbstractFixture implements OrderedFixtureInterface
|
||||||
|
{
|
||||||
|
public function getOrder()
|
||||||
|
{
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static $refs = array();
|
||||||
|
|
||||||
|
public function load(ObjectManager $manager)
|
||||||
|
{
|
||||||
|
foreach (LoadCenters::$refs as $centerRef) {
|
||||||
|
foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) {
|
||||||
|
$GroupCenter = new GroupCenter();
|
||||||
|
$GroupCenter->setCenter($this->getReference($centerRef));
|
||||||
|
$GroupCenter->addPermissionGroup($this->getReference($permissionGroupRef));
|
||||||
|
|
||||||
|
$manager->persist($GroupCenter);
|
||||||
|
|
||||||
|
$reference = $centerRef.'_'.$permissionGroupRef;
|
||||||
|
$this->addReference($reference, $GroupCenter);
|
||||||
|
static::$refs[] = $reference;
|
||||||
|
echo "Creating $reference... \n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
}
|
87
DataFixtures/ORM/LoadPermissionsGroup.php
Normal file
87
DataFixtures/ORM/LoadPermissionsGroup.php
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a suite of a modules, Chill is a software for social workers
|
||||||
|
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
|
use Chill\MainBundle\Entity\PermissionsGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
|
class LoadPermissionsGroup extends AbstractFixture implements OrderedFixtureInterface
|
||||||
|
{
|
||||||
|
public function getOrder()
|
||||||
|
{
|
||||||
|
return 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static $permissionGroup = array(
|
||||||
|
array(
|
||||||
|
'name' => 'social',
|
||||||
|
'role_scopes' => array(
|
||||||
|
'role_scope_CHILL_FOO_EDIT_social',
|
||||||
|
'role_scope_CHILL_FOO_SEE_administrative',
|
||||||
|
"role_scope_CHILL_FOO_EDIT_all"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'administrative',
|
||||||
|
'role_scopes' => array(
|
||||||
|
"role_scope_CHILL_FOO_SEE_social",
|
||||||
|
"role_scope_CHILL_FOO_EDIT_administrative",
|
||||||
|
"role_scope_CHILL_FOO_EDIT_all"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'direction',
|
||||||
|
'role_scopes' => array(
|
||||||
|
"role_scope_CHILL_FOO_EDIT_all",
|
||||||
|
"role_scope_CHILL_FOO_SEE_DETAILS_social",
|
||||||
|
"role_scope_CHILL_FOO_SEE_DETAILS_administrative"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $refs = array();
|
||||||
|
|
||||||
|
public function load(ObjectManager $manager)
|
||||||
|
{
|
||||||
|
foreach (static::$permissionGroup as $new) {
|
||||||
|
$permissionGroup = new PermissionsGroup();
|
||||||
|
$permissionGroup->setName($new['name']);
|
||||||
|
foreach ($new['role_scopes'] as $roleScopeRef) {
|
||||||
|
$permissionGroup->addRoleScope($this->getReference($roleScopeRef));
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->persist($permissionGroup);
|
||||||
|
$reference = 'permission_group_'.$new['name'];
|
||||||
|
echo "Creating $reference \n";
|
||||||
|
$this->setReference($reference, $permissionGroup);
|
||||||
|
static::$refs[] = $reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
}
|
@ -46,6 +46,13 @@ class LoadRoleScopes extends AbstractFixture implements OrderedFixtureInterface
|
|||||||
'nl' => 'zie foo'
|
'nl' => 'zie foo'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
'CHILL_FOO_SEE_DETAILS' => array(
|
||||||
|
'names' => array(
|
||||||
|
'fr' => 'voir foo avec détails',
|
||||||
|
'en' => 'see foo with details',
|
||||||
|
'nl' => 'zie foo in details'
|
||||||
|
)
|
||||||
|
),
|
||||||
'CHILL_FOO_EDIT' => array(
|
'CHILL_FOO_EDIT' => array(
|
||||||
'names' => array(
|
'names' => array(
|
||||||
'fr' => 'modifier foo',
|
'fr' => 'modifier foo',
|
||||||
@ -66,7 +73,7 @@ class LoadRoleScopes extends AbstractFixture implements OrderedFixtureInterface
|
|||||||
->setScope($this->getReference($scopeReference))
|
->setScope($this->getReference($scopeReference))
|
||||||
;
|
;
|
||||||
$reference = 'role_scope_'.$key.'_'.$this->getReference($scopeReference)->getName()['en'];
|
$reference = 'role_scope_'.$key.'_'.$this->getReference($scopeReference)->getName()['en'];
|
||||||
var_dump($reference);
|
echo "Creating $reference \n";
|
||||||
$this->addReference($reference, $roleScope);
|
$this->addReference($reference, $roleScope);
|
||||||
$manager->persist($roleScope);
|
$manager->persist($roleScope);
|
||||||
static::$references[] = $reference;
|
static::$references[] = $reference;
|
||||||
|
@ -7,15 +7,20 @@ use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
|||||||
use Doctrine\Common\Persistence\ObjectManager;
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadCenters;
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load agents into database
|
* Load fixtures users into database
|
||||||
|
*
|
||||||
|
* create a user for each permission_group and center.
|
||||||
|
* username and password are identicals.
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class LoadUsers extends AbstractFixture implements ContainerAwareInterface
|
class LoadUsers extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var ContainerInterface
|
* @var ContainerInterface
|
||||||
@ -27,14 +32,41 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface
|
|||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setContainer(ContainerInterface $container = null)
|
public static $refs = array();
|
||||||
{
|
|
||||||
$this->container = $container;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
|
foreach(LoadCenters::$refs as $centerRef) {
|
||||||
|
foreach(LoadPermissionsGroup::$refs as $permissionGroupRef) {
|
||||||
|
$user = new User();
|
||||||
|
|
||||||
|
$permissionGroup = $this->getReference($permissionGroupRef);
|
||||||
|
$center = $this->getReference($centerRef);
|
||||||
|
$username = $center->getName().'_'.$permissionGroup->getName();
|
||||||
|
|
||||||
|
$user->setUsername($username)
|
||||||
|
->setPassword($this->container->get('security.encoder_factory')
|
||||||
|
->getEncoder($user)
|
||||||
|
->encodePassword($username, $user->getSalt()));
|
||||||
|
$user->addGroupCenter($this->getReference($centerRef.'_'.$permissionGroupRef));
|
||||||
|
|
||||||
|
$manager->persist($user);
|
||||||
|
$this->addReference($username, $user);
|
||||||
|
static::$refs[] = $user->getUsername();
|
||||||
|
echo "Creating user with username ".$user->getUsername()."... \n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setContainer(ContainerInterface $container = null)
|
||||||
|
{
|
||||||
|
if (NULL === $container) {
|
||||||
|
throw new \LogicException('$container should not be null');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->container = $container;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,17 @@ class Center
|
|||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var \Doctrine\Common\Collections\Collection
|
||||||
|
*/
|
||||||
|
private $groupCenters;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->groupCenters = new \Doctrine\Common\Collections\ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
@ -55,5 +66,16 @@ class Center
|
|||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getGroupCenters()
|
||||||
|
{
|
||||||
|
return $this->groupCenters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addGroupCenter(GroupCenter $groupCenter)
|
||||||
|
{
|
||||||
|
$this->groupCenters->add($groupCenter);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
118
Entity/GroupCenter.php
Normal file
118
Entity/GroupCenter.php
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a suite of a modules, Chill is a software for social workers
|
||||||
|
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Entity;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Center;
|
||||||
|
use Chill\MainBundle\Entity\PermissionsGroup;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
|
class GroupCenter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var Center
|
||||||
|
*/
|
||||||
|
private $center;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var Collection
|
||||||
|
*/
|
||||||
|
private $users;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var Collection
|
||||||
|
*/
|
||||||
|
private $permissionGroups;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->permissionGroups = new ArrayCollection();
|
||||||
|
$this->users = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Center
|
||||||
|
*/
|
||||||
|
public function getCenter()
|
||||||
|
{
|
||||||
|
return $this->center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return PermissionGroup[]
|
||||||
|
*/
|
||||||
|
public function getPermissionGroups()
|
||||||
|
{
|
||||||
|
return $this->permissionGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Center $center
|
||||||
|
* @return \Chill\MainBundle\Entity\GroupCenter
|
||||||
|
*/
|
||||||
|
public function setCenter(Center $center)
|
||||||
|
{
|
||||||
|
$this->center = $center;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param PermissionGroup $permission
|
||||||
|
* @return \Chill\MainBundle\Entity\GroupCenter
|
||||||
|
*/
|
||||||
|
public function addPermissionGroup(PermissionsGroup $permission)
|
||||||
|
{
|
||||||
|
$this->permissionGroups->add($permission);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUsers()
|
||||||
|
{
|
||||||
|
return $this->users;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -29,7 +29,7 @@ use Chill\MainBundle\Entity\RoleScope;
|
|||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class PermissionGroup
|
class PermissionsGroup
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -39,7 +39,7 @@ class PermissionGroup
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var array
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
@ -59,6 +59,10 @@ class PermissionGroup
|
|||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
@ -69,7 +73,7 @@ class PermissionGroup
|
|||||||
return $this->roleScopes;
|
return $this->roleScopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setName(array $name)
|
public function setName($name)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
return $this;
|
return $this;
|
112
Entity/User.php
112
Entity/User.php
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
namespace Chill\MainBundle\Entity;
|
namespace Chill\MainBundle\Entity;
|
||||||
|
|
||||||
|
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User
|
* User
|
||||||
*/
|
*/
|
||||||
class User implements UserInterface {
|
class User implements AdvancedUserInterface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var integer
|
* @var integer
|
||||||
@ -21,12 +21,41 @@ class User implements UserInterface {
|
|||||||
*/
|
*/
|
||||||
private $username;
|
private $username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $password;
|
private $password;
|
||||||
|
|
||||||
private $salt;
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @internal must be set to null if we use bcrypt
|
||||||
|
*/
|
||||||
|
private $salt = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $locked = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $enabled = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var Collection
|
||||||
|
*/
|
||||||
|
private $groupCenters;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->groupCenters = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,16 +81,6 @@ class User implements UserInterface {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return $this->username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __toString() {
|
public function __toString() {
|
||||||
return $this->getUsername();
|
return $this->getUsername();
|
||||||
}
|
}
|
||||||
@ -71,6 +90,10 @@ class User implements UserInterface {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getPassword()
|
public function getPassword()
|
||||||
{
|
{
|
||||||
return $this->password;
|
return $this->password;
|
||||||
@ -93,7 +116,7 @@ class User implements UserInterface {
|
|||||||
|
|
||||||
function setPassword($password)
|
function setPassword($password)
|
||||||
{
|
{
|
||||||
$this->password = $password;
|
$this->password = $password;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +126,63 @@ class User implements UserInterface {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function isAccountNonExpired()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function isAccountNonLocked()
|
||||||
|
{
|
||||||
|
return $this->locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function isCredentialsNonExpired()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function isEnabled()
|
||||||
|
{
|
||||||
|
return $this->enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return GroupCenter[]
|
||||||
|
*/
|
||||||
|
public function getGroupCenters()
|
||||||
|
{
|
||||||
|
return $this->groupCenters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param \Chill\MainBundle\Entity\GroupCenter $groupCenter
|
||||||
|
* @return \Chill\MainBundle\Entity\User
|
||||||
|
*/
|
||||||
|
public function addGroupCenter(GroupCenter $groupCenter)
|
||||||
|
{
|
||||||
|
$this->groupCenters->add($groupCenter);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,3 +11,7 @@ Chill\MainBundle\Entity\Center:
|
|||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
length: 255
|
length: 255
|
||||||
|
oneToMany:
|
||||||
|
groupCenters:
|
||||||
|
targetEntity: Chill\MainBundle\Entity\GroupCenter
|
||||||
|
mappedBy: groupCenters
|
16
Resources/config/doctrine/GroupCenter.orm.yml
Normal file
16
Resources/config/doctrine/GroupCenter.orm.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
Chill\MainBundle\Entity\GroupCenter:
|
||||||
|
type: entity
|
||||||
|
table: group_centers
|
||||||
|
id:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
id: true
|
||||||
|
generator:
|
||||||
|
strategy: AUTO
|
||||||
|
manyToOne:
|
||||||
|
center:
|
||||||
|
targetEntity: Chill\MainBundle\Entity\Center
|
||||||
|
inversedBy: groupCenters
|
||||||
|
manyToMany:
|
||||||
|
permissionGroups:
|
||||||
|
targetEntity: Chill\MainBundle\Entity\PermissionsGroup
|
@ -1,4 +1,4 @@
|
|||||||
Chill\MainBundle\Entity\PermissionGroup:
|
Chill\MainBundle\Entity\PermissionsGroup:
|
||||||
type: entity
|
type: entity
|
||||||
table: permission_groups
|
table: permission_groups
|
||||||
id:
|
id:
|
||||||
@ -9,7 +9,8 @@ Chill\MainBundle\Entity\PermissionGroup:
|
|||||||
strategy: AUTO
|
strategy: AUTO
|
||||||
fields:
|
fields:
|
||||||
name:
|
name:
|
||||||
type: json_array
|
type: string
|
||||||
|
length: 255
|
||||||
manyToMany:
|
manyToMany:
|
||||||
roleScopes:
|
roleScopes:
|
||||||
targetEntity: Chill\MainBundle\Entity\RoleScope
|
targetEntity: Chill\MainBundle\Entity\RoleScope
|
@ -11,7 +11,7 @@ Chill\MainBundle\Entity\RoleScope:
|
|||||||
role:
|
role:
|
||||||
type: string
|
type: string
|
||||||
length: 255
|
length: 255
|
||||||
oneToMany:
|
manyToOne:
|
||||||
scope:
|
scope:
|
||||||
targetEntity: Chill\MainBundle\Entity\Scope
|
targetEntity: Chill\MainBundle\Entity\Scope
|
||||||
mappedBy: roleScopes
|
inversedBy: roleScopes
|
@ -17,5 +17,15 @@ Chill\MainBundle\Entity\User:
|
|||||||
salt:
|
salt:
|
||||||
type: string
|
type: string
|
||||||
length: 255
|
length: 255
|
||||||
|
nullable: true
|
||||||
|
enabled:
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
locked:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
manyToMany:
|
||||||
|
groupCenters:
|
||||||
|
targetEntity: Chill\MainBundle\Entity\GroupCenter
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user