mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
sf4 deprecated: migrate Doctrine ORM mapping to annotation
This commit is contained in:
parent
3033be78d2
commit
2746d3e003
@ -2,30 +2,45 @@
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* Address
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="chill_main_address")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
class Address
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $streetAddress1 = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $streetAddress2 = '';
|
||||
|
||||
/**
|
||||
* @var \Chill\MainBundle\Entity\PostalCode
|
||||
* @var PostalCode
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
|
||||
*/
|
||||
private $postcode;
|
||||
|
||||
@ -34,6 +49,8 @@ class Address
|
||||
* of address. By default, the current date.
|
||||
*
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(type="date")
|
||||
*/
|
||||
private $validFrom;
|
||||
|
||||
@ -41,15 +58,19 @@ class Address
|
||||
* True if the address is a "no address", aka homeless person, ...
|
||||
*
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $isNoAddress = false;
|
||||
|
||||
|
||||
/**
|
||||
* Address constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->validFrom = new \DateTime();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
@ -111,11 +132,11 @@ class Address
|
||||
/**
|
||||
* Set postcode
|
||||
*
|
||||
* @param \Chill\MainBundle\Entity\PostalCode $postcode
|
||||
* @param PostalCode $postcode
|
||||
*
|
||||
* @return Address
|
||||
*/
|
||||
public function setPostcode(\Chill\MainBundle\Entity\PostalCode $postcode = null)
|
||||
public function setPostcode(PostalCode $postcode = null)
|
||||
{
|
||||
$this->postcode = $postcode;
|
||||
|
||||
@ -125,7 +146,7 @@ class Address
|
||||
/**
|
||||
* Get postcode
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\PostalCode
|
||||
* @return PostalCode
|
||||
*/
|
||||
public function getPostcode()
|
||||
{
|
||||
@ -133,7 +154,6 @@ class Address
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getValidFrom()
|
||||
@ -142,9 +162,8 @@ class Address
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \DateTime $validFrom
|
||||
* @return \Chill\MainBundle\Entity\Address
|
||||
* @return Address
|
||||
*/
|
||||
public function setValidFrom(\DateTime $validFrom)
|
||||
{
|
||||
@ -153,7 +172,7 @@ class Address
|
||||
}
|
||||
|
||||
/**
|
||||
* get "isNoAddress"
|
||||
* Get IsNoAddress
|
||||
*
|
||||
* Indicate true if the address is a fake address (homeless, ...)
|
||||
*
|
||||
@ -164,13 +183,16 @@ class Address
|
||||
return $this->isNoAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNoAddress(): bool
|
||||
{
|
||||
return $this->getIsNoAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* set Is No Address
|
||||
* Set IsNoAddress
|
||||
*
|
||||
* Indicate true if the address is a fake address (homeless, ...)
|
||||
*
|
||||
@ -223,8 +245,11 @@ class Address
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Address $original
|
||||
* @return Address
|
||||
*/
|
||||
public static function createFromAddress(Address $original) : Address
|
||||
{
|
||||
return (new Address())
|
||||
|
@ -20,68 +20,109 @@
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chill\MainBundle\Repository\CenterRepository")
|
||||
* @ORM\Table(name="centers")
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class Center implements HasCenterInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Doctrine\Common\Collections\Collection
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\GroupCenter",
|
||||
* mappedBy="center"
|
||||
* )
|
||||
*/
|
||||
private $groupCenters;
|
||||
|
||||
|
||||
/**
|
||||
* Center constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->groupCenters = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection|Collection
|
||||
*/
|
||||
public function getGroupCenters()
|
||||
{
|
||||
return $this->groupCenters;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param GroupCenter $groupCenter
|
||||
* @return $this
|
||||
*/
|
||||
public function addGroupCenter(GroupCenter $groupCenter)
|
||||
{
|
||||
$this->groupCenters->add($groupCenter);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return $this|Center
|
||||
*/
|
||||
public function getCenter()
|
||||
{
|
||||
return $this;
|
||||
|
@ -2,24 +2,39 @@
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Country
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="country")
|
||||
* sf4 check, in yml table was set to null !?
|
||||
* @ORM\Cache(usage="READ_ONLY", region="country_cache_region")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
class Country
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="json_array")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=3)
|
||||
*/
|
||||
private $countryCode;
|
||||
|
||||
@ -57,9 +72,11 @@ class Country
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function __toString() {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getName();
|
||||
}
|
||||
|
||||
|
@ -20,55 +20,80 @@
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\PermissionsGroup;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="group_centers")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class GroupCenter
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Center
|
||||
*
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\MainBundle\Entity\Center",
|
||||
* inversedBy="groupCenters"
|
||||
* )
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $center;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @var Collection
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\User",
|
||||
* mappedBy="groupCenters"
|
||||
* )
|
||||
*/
|
||||
private $users;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var PermissionsGroup
|
||||
*
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\MainBundle\Entity\PermissionsGroup",
|
||||
* inversedBy="groupCenters")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $permissionsGroup;
|
||||
|
||||
|
||||
/**
|
||||
* GroupCenter constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->permissionsGroup = new ArrayCollection();
|
||||
$this->users = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Center
|
||||
*/
|
||||
public function getCenter()
|
||||
@ -77,7 +102,6 @@ class GroupCenter
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Center $center
|
||||
* @return \Chill\MainBundle\Entity\GroupCenter
|
||||
*/
|
||||
@ -87,13 +111,15 @@ class GroupCenter
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection|Collection
|
||||
*/
|
||||
public function getUsers()
|
||||
{
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return PermissionGroup
|
||||
*/
|
||||
public function getPermissionsGroup()
|
||||
@ -102,7 +128,6 @@ class GroupCenter
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Chill\MainBundle\Entity\PermissionsGroup $permissionGroup
|
||||
* @return \Chill\MainBundle\Entity\GroupCenter
|
||||
*/
|
||||
|
@ -20,18 +20,31 @@
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Language
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="language")
|
||||
* sf4 check, in yml table was set to null !?
|
||||
* @ORM\Cache(usage="READ_ONLY", region="language_cache_region")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
class Language
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Id()
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string array
|
||||
*
|
||||
* @ORM\Column(type="json_array")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
|
@ -20,72 +20,103 @@
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="permission_groups")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class PermissionsGroup
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @var int
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string[]
|
||||
*
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private $flags = [];
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @var \Doctrine\Common\Collections\Collection
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\RoleScope",
|
||||
* inversedBy="permissionsGroups",
|
||||
* cascade={ "persist" })
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $roleScopes;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @var \Doctrine\Common\Collections\Collection
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\GroupCenter",
|
||||
* mappedBy="permissionsGroup"
|
||||
* )
|
||||
*/
|
||||
private $groupCenters;
|
||||
|
||||
|
||||
/**
|
||||
* PermissionsGroup constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->roleScopes = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
$this->groupCenters = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return ArrayCollection|Collection
|
||||
*/
|
||||
public function getRoleScopes()
|
||||
{
|
||||
return $this->roleScopes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
@ -93,7 +124,6 @@ class PermissionsGroup
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param RoleScope $roleScope
|
||||
*/
|
||||
public function addRoleScope(RoleScope $roleScope)
|
||||
@ -102,7 +132,6 @@ class PermissionsGroup
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param RoleScope $roleScope
|
||||
* @throws \RuntimeException if the roleScope could not be removed.
|
||||
*/
|
||||
@ -115,21 +144,28 @@ class PermissionsGroup
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFlags()
|
||||
{
|
||||
return $this->flags;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $flags
|
||||
* @return $this
|
||||
*/
|
||||
public function setFlags(array $flags)
|
||||
{
|
||||
$this->flags = $flags;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test that a role scope is associated only once with the permission group
|
||||
* Test that a role scope is associated only once
|
||||
* with the permission group
|
||||
*
|
||||
* @param ExecutionContextInterface $context
|
||||
*/
|
||||
@ -150,5 +186,4 @@ class PermissionsGroup
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,28 +2,50 @@
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* PostalCode
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chill\MainBundle\Repository\PostalCodeRepository")
|
||||
* @ORM\Table(
|
||||
* name="chill_main_postal_code",
|
||||
* indexes={@ORM\Index(
|
||||
* name="search_name_code",
|
||||
* columns={"code", "label"}
|
||||
* )})
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*
|
||||
*/
|
||||
class PostalCode
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255, name="label")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=100)
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @var \Chill\MainBundle\Entity\Country
|
||||
* @var Country
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
|
||||
*/
|
||||
private $country;
|
||||
|
||||
@ -89,11 +111,11 @@ class PostalCode
|
||||
/**
|
||||
* Set country
|
||||
*
|
||||
* @param \Chill\MainBundle\Entity\Country $country
|
||||
* @param Country $country
|
||||
*
|
||||
* @return PostalCode
|
||||
*/
|
||||
public function setCountry(\Chill\MainBundle\Entity\Country $country = null)
|
||||
public function setCountry(Country $country = null)
|
||||
{
|
||||
$this->country = $country;
|
||||
|
||||
@ -103,7 +125,7 @@ class PostalCode
|
||||
/**
|
||||
* Get country
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\Country
|
||||
* @return Country
|
||||
*/
|
||||
public function getCountry()
|
||||
{
|
||||
|
@ -20,49 +20,73 @@
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="role_scopes")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class RoleScope
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @var int
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $role;
|
||||
|
||||
/**
|
||||
* @var Scope
|
||||
*
|
||||
* @var Scope
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\MainBundle\Entity\Scope",
|
||||
* inversedBy="roleScopes")
|
||||
* @ORM\JoinColumn(nullable=true, name="scope_id")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $scope;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @var \Doctrine\Common\Collections\Collection
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\PermissionsGroup",
|
||||
* mappedBy="roleScopes")
|
||||
*/
|
||||
private $permissionsGroups;
|
||||
|
||||
|
||||
/**
|
||||
* RoleScope constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->new = true;
|
||||
$this->permissionsGroups = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
$this->permissionsGroups = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRole()
|
||||
@ -71,7 +95,6 @@ class RoleScope
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Scope
|
||||
*/
|
||||
public function getScope()
|
||||
@ -80,9 +103,8 @@ class RoleScope
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type $role
|
||||
* @return \Chill\MainBundle\Entity\RoleScope
|
||||
* @return RoleScope
|
||||
*/
|
||||
public function setRole($role)
|
||||
{
|
||||
@ -92,9 +114,8 @@ class RoleScope
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Chill\MainBundle\Entity\Scope $scope
|
||||
* @return \Chill\MainBundle\Entity\RoleScope
|
||||
* @param Scope $scope
|
||||
* @return RoleScope
|
||||
*/
|
||||
public function setScope(Scope $scope = null)
|
||||
{
|
||||
|
@ -20,18 +20,26 @@
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="scopes")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class Scope
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @var int
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
@ -39,22 +47,31 @@ class Scope
|
||||
* translatable names
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json_array")
|
||||
*/
|
||||
private $name = array();
|
||||
private $name = [];
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @var \Doctrine\Common\Collections\Collection
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\RoleScope",
|
||||
* mappedBy="scope")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $roleScopes;
|
||||
|
||||
|
||||
/**
|
||||
* Scope constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->roleScopes = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
$this->roleScopes = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
@ -63,14 +80,17 @@ class Scope
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
@ -78,14 +98,16 @@ class Scope
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
* @return Collection
|
||||
*/
|
||||
public function getRoleScopes()
|
||||
{
|
||||
return $this->roleScopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RoleScope $roleScope
|
||||
*/
|
||||
public function addRoleScope(RoleScope $roleScope)
|
||||
{
|
||||
$this->roleScopes->add($roleScope);
|
||||
|
205
Entity/User.php
205
Entity/User.php
@ -2,85 +2,126 @@
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chill\MainBundle\Repository\UserRepository")
|
||||
* @ORM\Table(name="users")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
*/
|
||||
class User implements AdvancedUserInterface {
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=80)
|
||||
*/
|
||||
private $username;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(
|
||||
* type="string",
|
||||
* length=80,
|
||||
* unique=true)
|
||||
*/
|
||||
private $usernameCanonical;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=150, nullable=true)
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(
|
||||
* type="string",
|
||||
* length=150,
|
||||
* nullable=true,
|
||||
* unique=true)
|
||||
*/
|
||||
private $emailCanonical;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @var string
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
* @internal must be set to null if we use bcrypt
|
||||
* @internal must be set to null if we use bcrypt
|
||||
*
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $salt = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
* sf4 check: in yml was false by default !?
|
||||
*/
|
||||
private $locked = true;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $enabled = true;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @var Collection
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\GroupCenter",
|
||||
* inversedBy="users")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $groupCenters;
|
||||
|
||||
|
||||
/**
|
||||
* User constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->groupCenters = new ArrayCollection();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
@ -100,76 +141,95 @@ class User implements AdvancedUserInterface {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return $this->getUsername();
|
||||
}
|
||||
|
||||
public function eraseCredentials()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function getRoles()
|
||||
{
|
||||
return array('ROLE_USER');
|
||||
}
|
||||
|
||||
public function getSalt()
|
||||
{
|
||||
return $this->salt;
|
||||
}
|
||||
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
public function getUsernameCanonical()
|
||||
/**
|
||||
*/
|
||||
public function eraseCredentials() {}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRoles()
|
||||
{
|
||||
return $this->usernameCanonical;
|
||||
return array('ROLE_USER');
|
||||
}
|
||||
|
||||
public function getEmail()
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getSalt()
|
||||
{
|
||||
return $this->email;
|
||||
return $this->salt;
|
||||
}
|
||||
|
||||
public function getEmailCanonical()
|
||||
{
|
||||
return $this->emailCanonical;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $usernameCanonical
|
||||
* @return $this
|
||||
*/
|
||||
public function setUsernameCanonical($usernameCanonical)
|
||||
{
|
||||
$this->usernameCanonical = $usernameCanonical;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsernameCanonical()
|
||||
{
|
||||
return $this->usernameCanonical;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $email
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $emailCanonical
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmailCanonical($emailCanonical)
|
||||
{
|
||||
$this->emailCanonical = $emailCanonical;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmailCanonical()
|
||||
{
|
||||
return $this->emailCanonical;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $password
|
||||
* @return $this
|
||||
*/
|
||||
function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
@ -177,45 +237,50 @@ class User implements AdvancedUserInterface {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $salt
|
||||
* @return $this
|
||||
*/
|
||||
function setSalt($salt)
|
||||
{
|
||||
$this->salt = $salt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isAccountNonExpired()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAccountNonLocked()
|
||||
{
|
||||
return $this->locked;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isCredentialsNonExpired()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
@ -223,7 +288,6 @@ class User implements AdvancedUserInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bool $enabled
|
||||
*/
|
||||
public function setEnabled($enabled)
|
||||
@ -234,8 +298,7 @@ class User implements AdvancedUserInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return GroupCenter[]
|
||||
* @return GroupCenter
|
||||
*/
|
||||
public function getGroupCenters()
|
||||
{
|
||||
@ -243,7 +306,6 @@ class User implements AdvancedUserInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Chill\MainBundle\Entity\GroupCenter $groupCenter
|
||||
* @return \Chill\MainBundle\Entity\User
|
||||
*/
|
||||
@ -254,7 +316,6 @@ class User implements AdvancedUserInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Chill\MainBundle\Entity\GroupCenter $groupCenter
|
||||
* @throws \RuntimeException if the groupCenter is not in the collection
|
||||
*/
|
||||
|
@ -1,25 +0,0 @@
|
||||
Chill\MainBundle\Entity\Address:
|
||||
type: entity
|
||||
table: chill_main_address
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
streetAddress1:
|
||||
type: string
|
||||
length: 255
|
||||
streetAddress2:
|
||||
type: string
|
||||
length: 255
|
||||
validFrom:
|
||||
type: date
|
||||
isNoAddress:
|
||||
type: boolean
|
||||
default: false
|
||||
manyToOne:
|
||||
postcode:
|
||||
targetEntity: Chill\MainBundle\Entity\PostalCode
|
||||
lifecycleCallbacks: { }
|
@ -1,18 +0,0 @@
|
||||
Chill\MainBundle\Entity\Center:
|
||||
type: entity
|
||||
table: centers
|
||||
repositoryClass: Chill\MainBundle\Repository\CenterRepository
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
name:
|
||||
type: string
|
||||
length: 255
|
||||
oneToMany:
|
||||
groupCenters:
|
||||
targetEntity: Chill\MainBundle\Entity\GroupCenter
|
||||
mappedBy: groupCenters
|
@ -1,18 +0,0 @@
|
||||
Chill\MainBundle\Entity\Country:
|
||||
type: entity
|
||||
table: null
|
||||
cache:
|
||||
usage: READ_ONLY
|
||||
region: country_cache_region
|
||||
fields:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
name:
|
||||
type: json_array
|
||||
countryCode:
|
||||
type: string
|
||||
length: 3
|
||||
lifecycleCallbacks: { }
|
@ -1,26 +0,0 @@
|
||||
Chill\MainBundle\Entity\GroupCenter:
|
||||
type: entity
|
||||
table: group_centers
|
||||
cache:
|
||||
usage: NONSTRICT_READ_WRITE
|
||||
region: acl_cache_region
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
manyToOne:
|
||||
center:
|
||||
targetEntity: Chill\MainBundle\Entity\Center
|
||||
inversedBy: groupCenters
|
||||
cache:
|
||||
usage: NONSTRICT_READ_WRITE
|
||||
permissionsGroup:
|
||||
targetEntity: Chill\MainBundle\Entity\PermissionsGroup
|
||||
cache:
|
||||
usage: NONSTRICT_READ_WRITE
|
||||
manyToMany:
|
||||
users:
|
||||
targetEntity: Chill\MainBundle\Entity\User
|
||||
mappedBy: groupCenters
|
@ -1,13 +0,0 @@
|
||||
Chill\MainBundle\Entity\Language:
|
||||
type: entity
|
||||
table: null
|
||||
cache:
|
||||
usage: READ_ONLY
|
||||
region: language_cache_region
|
||||
id:
|
||||
id:
|
||||
type: string
|
||||
fields:
|
||||
name:
|
||||
type: json_array
|
||||
lifecycleCallbacks: { }
|
@ -1,32 +0,0 @@
|
||||
Chill\MainBundle\Entity\PermissionsGroup:
|
||||
type: entity
|
||||
table: permission_groups
|
||||
cache:
|
||||
usage: NONSTRICT_READ_WRITE
|
||||
region: acl_cache_region
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
name:
|
||||
type: string
|
||||
length: 255
|
||||
flags:
|
||||
type: json
|
||||
options:
|
||||
default: '[]'
|
||||
manyToMany:
|
||||
roleScopes:
|
||||
targetEntity: Chill\MainBundle\Entity\RoleScope
|
||||
inversedBy: permissionsGroups
|
||||
cache:
|
||||
usage: NONSTRICT_READ_WRITE
|
||||
cascade: [ persist ]
|
||||
oneToMany:
|
||||
groupCenters:
|
||||
targetEntity: Chill\MainBundle\Entity\GroupCenter
|
||||
mappedBy: permissionsGroup
|
||||
|
@ -1,24 +0,0 @@
|
||||
Chill\MainBundle\Entity\PostalCode:
|
||||
type: entity
|
||||
table: chill_main_postal_code
|
||||
repositoryClass: Chill\MainBundle\Repository\PostalCodeRepository
|
||||
indexes:
|
||||
- { name: search_name_code, columns: [ "code", "label" ] }
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
name:
|
||||
type: string
|
||||
length: 255
|
||||
column: label
|
||||
code:
|
||||
type: string
|
||||
length: 100
|
||||
manyToOne:
|
||||
country:
|
||||
targetEntity: Chill\MainBundle\Entity\Country
|
||||
lifecycleCallbacks: { }
|
@ -1,28 +0,0 @@
|
||||
Chill\MainBundle\Entity\RoleScope:
|
||||
type: entity
|
||||
table: role_scopes
|
||||
cache:
|
||||
usage: NONSTRICT_READ_WRITE
|
||||
region: acl_cache_region
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
role:
|
||||
type: string
|
||||
length: 255
|
||||
manyToOne:
|
||||
scope:
|
||||
targetEntity: Chill\MainBundle\Entity\Scope
|
||||
inversedBy: roleScopes
|
||||
nullable: true
|
||||
cache:
|
||||
usage: NONSTRICT_READ_WRITE
|
||||
manyToMany:
|
||||
permissionsGroups:
|
||||
targetEntity: Chill\MainBundle\Entity\PermissionsGroup
|
||||
mappedBy: roleScopes
|
||||
|
@ -1,21 +0,0 @@
|
||||
Chill\MainBundle\Entity\Scope:
|
||||
type: entity
|
||||
table: scopes
|
||||
cache:
|
||||
usage: NONSTRICT_READ_WRITE
|
||||
region: acl_cache_region
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
name:
|
||||
type: json_array
|
||||
oneToMany:
|
||||
roleScopes:
|
||||
targetEntity: Chill\MainBundle\Entity\RoleScope
|
||||
mappedBy: scope
|
||||
cache:
|
||||
usage: NONSTRICT_READ_WRITE
|
@ -1,53 +0,0 @@
|
||||
Chill\MainBundle\Entity\User:
|
||||
type: entity
|
||||
table: users
|
||||
repositoryClass: Chill\MainBundle\Repository\UserRepository
|
||||
cache:
|
||||
usage: NONSTRICT_READ_WRITE
|
||||
region: acl_cache_region
|
||||
id:
|
||||
id:
|
||||
type: integer
|
||||
id: true
|
||||
generator:
|
||||
strategy: AUTO
|
||||
fields:
|
||||
username:
|
||||
type: string
|
||||
length: 80
|
||||
usernameCanonical:
|
||||
name: username_canonical
|
||||
type: string
|
||||
length: 80
|
||||
unique: true
|
||||
email:
|
||||
type: string
|
||||
length: 150
|
||||
nullable: true
|
||||
emailCanonical:
|
||||
name: email_canonical
|
||||
type: string
|
||||
length: 150
|
||||
nullable: true
|
||||
unique: true
|
||||
password:
|
||||
type: string
|
||||
length: 255
|
||||
salt:
|
||||
type: string
|
||||
length: 255
|
||||
nullable: true
|
||||
enabled:
|
||||
type: boolean
|
||||
default: true
|
||||
locked:
|
||||
type: boolean
|
||||
default: false
|
||||
manyToMany:
|
||||
groupCenters:
|
||||
targetEntity: Chill\MainBundle\Entity\GroupCenter
|
||||
inversedBy: users
|
||||
cache:
|
||||
usage: NONSTRICT_READ_WRITE
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user