fix folder name

This commit is contained in:
2021-03-18 13:37:13 +01:00
parent a2f6773f5a
commit eaa0ad925f
1578 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,290 @@
<?php
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 PostalCode
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
*/
private $postcode;
/**
* Indicates when the address starts validation. Used to build an history
* of address. By default, the current date.
*
* @var \DateTime
*
* @ORM\Column(type="date")
*/
private $validFrom;
/**
* True if the address is a "no address", aka homeless person, ...
*
* @var bool
*/
private $isNoAddress = false;
/**
* A list of metadata, added by customizable fields
*
* @var array
*/
private $customs = [];
public function __construct()
{
$this->validFrom = new \DateTime();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set streetAddress1
*
* @param string $streetAddress1
*
* @return Address
*/
public function setStreetAddress1($streetAddress1)
{
$this->streetAddress1 = $streetAddress1 === NULL ? '' : $streetAddress1;
return $this;
}
/**
* Get streetAddress1
*
* @return string
*/
public function getStreetAddress1()
{
return $this->streetAddress1;
}
/**
* Set streetAddress2
*
* @param string $streetAddress2
*
* @return Address
*/
public function setStreetAddress2($streetAddress2)
{
$this->streetAddress2 = $streetAddress2 === NULL ? '' : $streetAddress2;
return $this;
}
/**
* Get streetAddress2
*
* @return string
*/
public function getStreetAddress2()
{
return $this->streetAddress2;
}
/**
* Set postcode
*
* @param PostalCode $postcode
*
* @return Address
*/
public function setPostcode(PostalCode $postcode = null)
{
$this->postcode = $postcode;
return $this;
}
/**
* Get postcode
*
* @return PostalCode
*/
public function getPostcode()
{
return $this->postcode;
}
/**
* @return \DateTime
*/
public function getValidFrom()
{
return $this->validFrom;
}
/**
* @param \DateTime $validFrom
* @return Address
*/
public function setValidFrom(\DateTime $validFrom)
{
$this->validFrom = $validFrom;
return $this;
}
/**
* Get IsNoAddress
*
* Indicate true if the address is a fake address (homeless, ...)
*
* @return bool
*/
public function getIsNoAddress(): bool
{
return $this->isNoAddress;
}
/**
* @return bool
*/
public function isNoAddress(): bool
{
return $this->getIsNoAddress();
}
/**
* Set IsNoAddress
*
* Indicate true if the address is a fake address (homeless, ...)
*
* @param bool $isNoAddress
* @return $this
*/
public function setIsNoAddress(bool $isNoAddress)
{
$this->isNoAddress = $isNoAddress;
return $this;
}
/**
* Get customs informations in the address
*
* @return array
*/
public function getCustoms(): array
{
return $this->customs;
}
/**
* Store custom informations in the address
*
* @param array $customs
* @return $this
*/
public function setCustoms(array $customs): self
{
$this->customs = $customs;
return $this;
}
/**
* Validate the address.
*
* Check that:
*
* * if the address is not home address:
* * the postal code is present
* * the valid from is not null
* * the address street 1 is greater than 2
*
* @param ExecutionContextInterface $context
* @param array $payload
*/
public function validate(ExecutionContextInterface $context, $payload)
{
if (!$this->getValidFrom() instanceof \DateTime) {
$context
->buildViolation("address.date-should-be-set")
->atPath('validFrom')
->addViolation();
}
if ($this->isNoAddress()) {
return;
}
if (empty($this->getStreetAddress1())) {
$context
->buildViolation("address.street1-should-be-set")
->atPath('streetAddress1')
->addViolation();
}
if (!$this->getPostcode() instanceof PostalCode) {
$context
->buildViolation("address.postcode-should-be-set")
->atPath('postCode')
->addViolation();
}
}
/**
* @param Address $original
* @return Address
*/
public static function createFromAddress(Address $original) : Address
{
return (new Address())
->setPostcode($original->getPostcode())
->setStreetAddress1($original->getStreetAddress1())
->setStreetAddress2($original->getStreetAddress2())
->setValidFrom($original->getValidFrom())
;
}
}

View File

@@ -0,0 +1,131 @@
<?php
/*
*
* 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 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
*
* @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;
}
}

View File

@@ -0,0 +1,101 @@
<?php
namespace Chill\MainBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Country
*
* @ORM\Entity()
* @ORM\Table(name="country")
* @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;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Country
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return string
*/
public function __toString()
{
return $this->getName();
}
/**
*
* @return the string
*/
public function getCountryCode()
{
return $this->countryCode;
}
/**
*
* @param string $countryCode
*/
public function setCountryCode($countryCode)
{
$this->countryCode = $countryCode;
return $this;
}
}

View File

@@ -0,0 +1,79 @@
<?php
namespace Chill\MainBundle\Entity\Embeddable;
use Chill\MainBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Embeddable()
*/
class CommentEmbeddable
{
/**
* @var string
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* Embeddable does not support associations
* @var integer
* @ORM\Column(type="integer", nullable=true)
*/
private $userId;
/**
* @var \DateTime
* @ORM\Column(type="datetime", nullable=true)
*/
private $date;
/**
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* @param string $comment
*/
public function setComment(?string $comment)
{
$this->comment = $comment;
}
/**
* @return interger $userId
*/
public function getUserId()
{
return $this->userId;
}
/**
* @param integer $userId
*/
public function setUserId($userId)
{
$this->userId = $userId;
}
/**
* @return \DateTime
*/
public function getDate()
{
return $this->date;
}
/**
* @param \DateTime $date
*/
public function setDate(?\DateTime $date)
{
$this->date = $date;
}
}

View File

@@ -0,0 +1,144 @@
<?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 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
*
* @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()
{
return $this->center;
}
/**
* @param Center $center
* @return \Chill\MainBundle\Entity\GroupCenter
*/
public function setCenter(Center $center)
{
$this->center = $center;
return $this;
}
/**
* @return ArrayCollection|Collection
*/
public function getUsers()
{
return $this->users;
}
/**
* @return PermissionGroup
*/
public function getPermissionsGroup()
{
return $this->permissionsGroup;
}
/**
* @param \Chill\MainBundle\Entity\PermissionsGroup $permissionGroup
* @return \Chill\MainBundle\Entity\GroupCenter
*/
public function setPermissionsGroup(PermissionsGroup $permissionsGroup)
{
$this->permissionsGroup = $permissionsGroup;
return $this;
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* Copyright (C) 2015 Julien Fastré <julien.fastre@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;
/**
* Interface for entities which may be linked to a center
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
interface HasCenterInterface
{
/**
* the linked center
*
* @return Center
*/
public function getCenter();
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* Copyright (C) 2015 Julien Fastré <julien.fastre@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;
/**
* Interface for entities which have a scop
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
interface HasScopeInterface
{
/**
* Return the linked scope
*
* @return Scope
*/
public function getScope();
}

View File

@@ -0,0 +1,94 @@
<?php
/*
*
* 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 Doctrine\ORM\Mapping as ORM;
/**
* Language
*
* @ORM\Entity()
* @ORM\Table(name="language")
* @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;
/**
* Get id
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Set id
*
* @param string $id
* @return Language
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Set name
*
* @param string array $name
* @return Language
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string array
*/
public function getName()
{
return $this->name;
}
}

View File

@@ -0,0 +1,189 @@
<?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 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
*
* @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
*
* @ORM\ManyToMany(
* targetEntity="Chill\MainBundle\Entity\RoleScope",
* inversedBy="permissionsGroups",
* cascade={ "persist" })
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
private $roleScopes;
/**
* @var 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;
return $this;
}
/**
* @param RoleScope $roleScope
*/
public function addRoleScope(RoleScope $roleScope)
{
$this->roleScopes->add($roleScope);
}
/**
* @param RoleScope $roleScope
* @throws \RuntimeException if the roleScope could not be removed.
*/
public function removeRoleScope(RoleScope $roleScope)
{
$result = $this->roleScopes->removeElement($roleScope);
if ($result === FALSE) {
throw new \RuntimeException(sprintf("The roleScope '%s' could not be removed, "
. "aborting.", spl_object_hash($roleScope)));
}
}
/**
* @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
*
* @param ExecutionContextInterface $context
*/
public function isRoleScopePresentOnce(ExecutionContextInterface $context)
{
$roleScopesId = array_map(function(RoleScope $roleScope) {
return $roleScope->getId();
},
$this->getRoleScopes()->toArray());
$countedIds = array_count_values($roleScopesId);
foreach ($countedIds as $id => $nb) {
if ($nb > 1) {
$context->buildViolation("A permission is already present "
. "for the same role and scope")
->addViolation();
}
}
}
}

View File

@@ -0,0 +1,135 @@
<?php
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 Country
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
*/
private $country;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return PostalCode
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set code
*
* @param string $code
*
* @return PostalCode
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* Get code
*
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* Set country
*
* @param Country $country
*
* @return PostalCode
*/
public function setCountry(Country $country = null)
{
$this->country = $country;
return $this;
}
/**
* Get country
*
* @return Country
*/
public function getCountry()
{
return $this->country;
}
}

View File

@@ -0,0 +1,126 @@
<?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 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
*
* @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
*
* @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
*
* @ORM\ManyToMany(
* targetEntity="Chill\MainBundle\Entity\PermissionsGroup",
* mappedBy="roleScopes")
*/
private $permissionsGroups;
/**
* RoleScope constructor.
*/
public function __construct() {
$this->new = true;
$this->permissionsGroups = new ArrayCollection();
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getRole()
{
return $this->role;
}
/**
* @return Scope
*/
public function getScope()
{
return $this->scope;
}
/**
* @param type $role
* @return RoleScope
*/
public function setRole($role)
{
$this->role = $role;
return $this;
}
/**
* @param Scope $scope
* @return RoleScope
*/
public function setScope(Scope $scope = null)
{
$this->scope = $scope;
return $this;
}
}

View File

@@ -0,0 +1,115 @@
<?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 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
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* translatable names
*
* @var array
*
* @ORM\Column(type="json_array")
*/
private $name = [];
/**
* @var 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 ArrayCollection();
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return array
*/
public function getName()
{
return $this->name;
}
/**
* @param $name
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @return Collection
*/
public function getRoleScopes()
{
return $this->roleScopes;
}
/**
* @param RoleScope $roleScope
*/
public function addRoleScope(RoleScope $roleScope)
{
$this->roleScopes->add($roleScope);
}
}

View File

@@ -0,0 +1,383 @@
<?php
namespace Chill\MainBundle\Entity;
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
*
* @ORM\Column(type="string", length=255)
*/
private $password;
/**
* @var string
* @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
*
* @ORM\ManyToMany(
* targetEntity="Chill\MainBundle\Entity\GroupCenter",
* inversedBy="users")
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
private $groupCenters;
/**
* Array where SAML attributes's data are stored
* @var array
*
* @ORM\Column(type="json_array", nullable=true)
*/
private $attributes;
/**
* User constructor.
*/
public function __construct()
{
$this->groupCenters = new ArrayCollection();
}
/**
* @return string
*/
public function __toString()
{
return $this->getUsername();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set username
*
* @param string $name
* @return Agent
*/
public function setUsername($name)
{
$this->username = $name;
return $this;
}
/**
* @return string
*/
public function getUsername()
{
return $this->username;
}
/**
*/
public function eraseCredentials() {}
/**
* @return array
*/
public function getRoles()
{
return array('ROLE_USER');
}
/**
* @return null|string
*/
public function getSalt()
{
return $this->salt;
}
/**
* @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;
return $this;
}
/**
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* @param $salt
* @return $this
*/
function setSalt($salt)
{
$this->salt = $salt;
return $this;
}
/**
* @return bool
*/
public function isAccountNonExpired()
{
return true;
}
/**
* @return bool
*/
public function isAccountNonLocked()
{
return $this->locked;
}
/**
* @return bool
*/
public function isCredentialsNonExpired()
{
return true;
}
/**
* @return bool
*/
public function isEnabled()
{
return $this->enabled;
}
/**
* @param bool $enabled
*/
public function setEnabled($enabled)
{
$this->enabled = $enabled;
return $this;
}
/**
* @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;
}
/**
* @param \Chill\MainBundle\Entity\GroupCenter $groupCenter
* @throws \RuntimeException if the groupCenter is not in the collection
*/
public function removeGroupCenter(GroupCenter $groupCenter)
{
if ($this->groupCenters->removeElement($groupCenter) === FALSE) {
throw new \RuntimeException(sprintf("The groupCenter could not be removed, "
. "it seems not to be associated with the user. Aborting."));
}
}
/**
* This function check that groupCenter are present only once. The validator
* use this function to avoid a user to be associated to the same groupCenter
* more than once.
*/
public function isGroupCenterPresentOnce(ExecutionContextInterface $context)
{
$groupCentersIds = array();
foreach ($this->getGroupCenters() as $groupCenter) {
if (in_array($groupCenter->getId(), $groupCentersIds)) {
$context->buildViolation("The user has already those permissions")
->addViolation();
} else {
$groupCentersIds[] = $groupCenter->getId();
}
}
}
/**
* Set attributes
*
* @param array $attributes
*
* @return Report
*/
public function setAttributes($attributes)
{
$this->attributes = $attributes;
return $this;
}
/**
* Get attributes
*
* @return array
*/
public function getAttributes()
{
if ($this->attributes === null) {
$this->attributes = [];
}
return $this->attributes;
}
}