cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,22 +1,10 @@
<?php
/*
/**
* 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/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\CustomFieldsBundle\Entity;
@@ -24,16 +12,36 @@ namespace Chill\CustomFieldsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* CustomField
* CustomField.
*
* @ORM\Entity()
* @ORM\Entity
* @ORM\Table(name="customfield")
* @ORM\HasLifecycleCallbacks()
* @ORM\HasLifecycleCallbacks
*/
class CustomField
{
public const ONE_TO_MANY = 2;
public const ONE_TO_ONE = 1;
/**
* @var integer
* @var bool
*
* @ORM\Column(type="boolean")
*/
private $active = true;
/**
* @var CustomFieldsGroup
*
* @ORM\ManyToOne(
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldsGroup",
* inversedBy="customFields")
*/
private $customFieldGroup;
/**
* @var int
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
@@ -41,6 +49,34 @@ class CustomField
*/
private $id;
/**
* @var array
*
* @ORM\Column(type="json")
*/
private $name;
/**
* @var array
*
* @ORM\Column(type="json")
*/
private $options = [];
/**
* @var float
*
* @ORM\Column(type="float")
*/
private $ordering;
/**
* @var bool
*
* @ORM\Column(type="boolean")
*/
private $required = false;
/**
* @var string
*
@@ -56,57 +92,19 @@ class CustomField
private $type;
/**
* @var boolean
* Get customFieldGroup.
*
* @ORM\Column(type="boolean")
* @return CustomFieldsGroup
*/
private $active = true;
public function getCustomFieldsGroup()
{
return $this->customFieldGroup;
}
/**
* @var array
* Get id.
*
* @ORM\Column(type="json")
*/
private $options = array();
/**
* @var array
*
* @ORM\Column(type="json")
*/
private $name;
/**
* @var float
*
* @ORM\Column(type="float")
*/
private $ordering;
/**
* @var boolean
*
* @ORM\Column(type="boolean")
*/
private $required = FALSE;
const ONE_TO_ONE = 1;
const ONE_TO_MANY = 2;
/**
* @var CustomFieldsGroup
*
* @ORM\ManyToOne(
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldsGroup",
* inversedBy="customFields")
*/
private $customFieldGroup;
/**
* Get id
*
* @return integer
* @return int
*/
public function getId()
{
@@ -114,36 +112,69 @@ class CustomField
}
/**
* @return string
* Get name.
*
* @param mixed|null $locale
*
* @return array
*/
function getSlug()
public function getName($locale = null)
{
return $this->slug;
if ($locale) {
if (isset($this->name[$locale])) {
return $this->name[$locale];
}
foreach ($this->name as $name) {
if (!empty($name)) {
return $name;
}
}
return '';
}
return $this->name;
}
/**
* @return array
*/
function getOptions()
public function getOptions()
{
return $this->options;
}
/**
* Set type
* Get order.
*
* @param string $type
* @return CustomField
* @return float
*/
public function setType($type)
public function getOrdering()
{
$this->type = $type;
return $this;
return $this->ordering;
}
/**
* Get type
* alias for isRequired.
*
* @return bool
*/
public function getRequired()
{
return $this->isRequired();
}
/**
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Get type.
*
* @return string
*/
@@ -152,11 +183,31 @@ class CustomField
return $this->type;
}
/**
* Returns true if the custom field is active.
*
* @return bool
*/
public function isActive()
{
return $this->active;
}
/**
* Set active
* return true if the field required.
*
* @return bool
*/
public function isRequired()
{
return $this->required;
}
/**
* Set active.
*
* @param bool $active
*
* @param boolean $active
* @return CustomField
*/
public function setActive($active)
@@ -167,32 +218,13 @@ class CustomField
}
/**
* Returns true if the custom field is active
*
* @return boolean
*/
public function isActive()
{
return $this->active;
}
/**
* Get customFieldGroup
*
* @return CustomFieldsGroup
*/
public function getCustomFieldsGroup()
{
return $this->customFieldGroup;
}
/**
* Set customFieldGroup
* Set customFieldGroup.
*
* @param CustomFieldsGroup $customFieldGroup
*
* @return CustomField
*/
public function setCustomFieldsGroup(CustomFieldsGroup $customFieldGroup = null)
public function setCustomFieldsGroup(?CustomFieldsGroup $customFieldGroup = null)
{
$this->customFieldGroup = $customFieldGroup;
@@ -200,9 +232,10 @@ class CustomField
}
/**
* Set name
* Set name.
*
* @param array $name
*
* @return CustomField
*/
public function setName($name)
@@ -213,57 +246,8 @@ class CustomField
}
/**
* Get name
* Set options.
*
* @return array
*/
public function getName($locale = null)
{
if ($locale) {
if (isset($this->name[$locale])) {
return $this->name[$locale];
} else {
foreach ($this->name as $name) {
if (!empty($name)) {
return $name;
}
}
}
return '';
} else {
return $this->name;
};
}
/**
* Set order
*
* @param float $order
* @return CustomField
*/
public function setOrdering($order)
{
$this->ordering = $order;
return $this;
}
/**
* Get order
*
* @return float
*/
public function getOrdering()
{
return $this->ordering;
}
/**
* Set options
*
* @param array $options
* @return CustomField
*/
public function setOptions(array $options)
@@ -274,39 +258,49 @@ class CustomField
}
/**
* @param $slug
* @return $this
* Set order.
*
* @param float $order
*
* @return CustomField
*/
public function setSlug($slug)
public function setOrdering($order)
{
$this->slug = $slug;
$this->ordering = $order;
return $this;
}
/**
* alias for isRequired
*
* @return boolean
*/
public function getRequired()
{
return $this->isRequired();
}
/**
* return true if the field required
*
* @return boolean
*/
public function isRequired()
{
return $this->required;
}
public function setRequired($required)
{
$this->required = $required;
return $this;
}
/**
* @param $slug
*
* @return $this
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Set type.
*
* @param string $type
*
* @return CustomField
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
}

View File

@@ -1,20 +1,10 @@
<?php
/*
* Copyright (C) 2015 Julien Fastré <julien.fastre@champs-libres.coop>
/**
* Chill is a software for social workers
*
* 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/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice;
@@ -24,15 +14,27 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(
* repositoryClass="Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository")
* repositoryClass="Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository")
* @ORM\Table(name="custom_field_long_choice_options")
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class Option
{
/**
* @var integer
* @var bool
* @ORM\Column(type="boolean")
*/
private $active = true;
/**
* @var Collection
* @ORM\OneToMany(
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option",
* mappedBy="parent")
*/
private $children;
/**
* @var int
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
@@ -40,6 +42,12 @@ class Option
*/
private $id;
/**
* @var string
* @ORM\Column(type="string", length=50, name="internal_key")
*/
private $internalKey = '';
/**
* @var string
* @ORM\Column(type="string", length=15)
@@ -47,7 +55,16 @@ class Option
private $key;
/**
* A json representation of text (multilingual)
* @var Option
* @ORM\ManyToOne(
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option",
* inversedBy="children")
* @ORM\JoinColumn(nullable=true)
*/
private $parent;
/**
* A json representation of text (multilingual).
*
* @var array
* @ORM\Column(type="json")
@@ -55,33 +72,20 @@ class Option
private $text;
/**
* @var Collection
* @ORM\OneToMany(
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option",
* mappedBy="parent")
* @return bool
*/
private $children;
public function getActive()
{
return $this->isActive();
}
/**
* @var Option
* @ORM\ManyToOne(
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option",
* inversedBy="children")
* @ORM\JoinColumn(nullable=true)
* @return Collection
*/
private $parent;
/**
* @var string
* @ORM\Column(type="string", length=50, name="internal_key")
*/
private $internalKey = '';
/**
* @var boolean
* @ORM\Column(type="boolean")
*/
private $active = true;
public function getChildren()
{
return $this->children;
}
/**
* @return int
@@ -91,6 +95,14 @@ class Option
return $this->id;
}
/**
* @return string
*/
public function getInternalKey()
{
return $this->internalKey;
}
/**
* @return string
*/
@@ -99,22 +111,6 @@ class Option
return $this->key;
}
/**
* @return array
*/
public function getText()
{
return $this->text;
}
/**
* @return Collection
*/
public function getChildren()
{
return $this->children;
}
/**
* @return Option
*/
@@ -124,51 +120,19 @@ class Option
}
/**
* @param $key
* @return $this
* @return array
*/
public function setKey($key)
public function getText()
{
$this->key = $key;
return $this;
return $this->text;
}
/**
* @param array $text
* @return $this
*/
public function setText(array $text)
{
$this->text = $text;
return $this;
}
/**
* @param Option|null $parent
* @return $this
*/
public function setParent(Option $parent = null)
{
$this->parent = $parent;
$this->key = $parent->getKey();
return $this;
}
/**
*
* @return boolean
* @return bool
*/
public function hasParent()
{
return $this->parent === NULL ? false : true;
}
/**
* @return string
*/
public function getInternalKey()
{
return $this->internalKey;
return null === $this->parent ? false : true;
}
/**
@@ -179,32 +143,60 @@ class Option
return $this->active;
}
/**
* @return bool
*/
public function getActive()
{
return $this->isActive();
}
/**
* @param $internal_key
* @return $this
*/
public function setInternalKey($internal_key)
{
$this->internalKey = $internal_key;
return $this;
}
/**
* @param $active
*
* @return $this
*/
public function setActive($active)
{
$this->active = $active;
return $this;
}
/**
* @param $internal_key
*
* @return $this
*/
public function setInternalKey($internal_key)
{
$this->internalKey = $internal_key;
return $this;
}
/**
* @param $key
*
* @return $this
*/
public function setKey($key)
{
$this->key = $key;
return $this;
}
/**
* @return $this
*/
public function setParent(?Option $parent = null)
{
$this->parent = $parent;
$this->key = $parent->getKey();
return $this;
}
/**
* @return $this
*/
public function setText(array $text)
{
$this->text = $text;
return $this;
}
}

View File

@@ -1,22 +1,10 @@
<?php
/*
/**
* 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/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\CustomFieldsBundle\Entity;
@@ -24,26 +12,27 @@ namespace Chill\CustomFieldsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* CustomFieldsDefaultGroup
* CustomFieldsDefaultGroup.
*
* @ORM\Entity()
* @ORM\Entity
* @ORM\Table(
* name="customfieldsdefaultgroup",
* uniqueConstraints={@ORM\UniqueConstraint(
* name="unique_entity",
* columns={"entity"}
* )})
* name="unique_entity",
* columns={"entity"}
* )})
*/
class CustomFieldsDefaultGroup
{
/**
* @var integer
* @var CustomFieldsGroup
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\ManyToOne(
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldsGroup")
*
* sf4 check: option inversedBy="customFields" return inconsistent error mapping !!
*/
private $id;
private $customFieldsGroup;
/**
* @var string
@@ -53,40 +42,26 @@ class CustomFieldsDefaultGroup
private $entity;
/**
* @var CustomFieldsGroup
* @var int
*
* @ORM\ManyToOne(
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldsGroup")
*
* sf4 check: option inversedBy="customFields" return inconsistent error mapping !!
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $customFieldsGroup;
private $id;
/**
* Get id
* Get customFieldsGroup.
*
* @return integer
* @return CustomFieldsGroup
*/
public function getId()
public function getCustomFieldsGroup()
{
return $this->id;
return $this->customFieldsGroup;
}
/**
* Set entity
*
* @param string $entity
* @return CustomFieldsDefaultGroup
*/
public function setEntity($entity)
{
$this->entity = $entity;
return $this;
}
/**
* Get entity
* Get entity.
*
* @return string
*/
@@ -96,9 +71,20 @@ class CustomFieldsDefaultGroup
}
/**
* Set customFieldsGroup
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set customFieldsGroup.
*
* @param CustomFieldsGroup $customFieldsGroup *
*
* @return CustomFieldsDefaultGroup
*/
public function setCustomFieldsGroup($customFieldsGroup)
@@ -109,12 +95,16 @@ class CustomFieldsDefaultGroup
}
/**
* Get customFieldsGroup
* Set entity.
*
* @return CustomFieldsGroup
* @param string $entity
*
* @return CustomFieldsDefaultGroup
*/
public function getCustomFieldsGroup()
public function setEntity($entity)
{
return $this->customFieldsGroup;
$this->entity = $entity;
return $this;
}
}

View File

@@ -1,40 +1,56 @@
<?php
/*
/**
* 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/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\CustomFieldsBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* CustomFieldGroup
* CustomFieldGroup.
*
* @ORM\Entity()
* @ORM\Entity
* @ORM\Table(name="customfieldsgroup")
*/
class CustomFieldsGroup
{
/**
* @var integer
* The custom fields of the group that are active.
* This variable if null, if this informations has not been computed.
*
* @var array|null
*/
private $activeCustomFields;
/**
* The custom fields of the group.
* The custom fields are asc-ordered regarding to their property "ordering".
*
* @var Collection
*
* @ORM\OneToMany(
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomField",
* mappedBy="customFieldGroup")
* @ORM\OrderBy({"ordering": "ASC"})
*/
private $customFields;
/**
* @var string
*
* @ORM\Column(type="string", length=255)
*/
private $entity;
/**
* @var int
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
@@ -49,41 +65,12 @@ class CustomFieldsGroup
*/
private $name;
/**
* @var string
*
* @ORM\Column(type="string", length=255)
*/
private $entity;
/**
* The custom fields of the group.
* The custom fields are asc-ordered regarding to their property "ordering".
*
* @var Collection $customFields
*
* @ORM\OneToMany(
* targetEntity="Chill\CustomFieldsBundle\Entity\CustomField",
* mappedBy="customFieldGroup")
* @ORM\OrderBy({"ordering" = "ASC"})
*/
private $customFields;
/**
* The custom fields of the group that are active.
* This variable if null, if this informations has not been computed.
*
* @var array|null
*/
private $activeCustomFields = null;
/**
* @var array
*
* @ORM\Column(type="json")
*/
private $options = array();
private $options = [];
/**
* CustomFieldsGroup constructor.
@@ -94,9 +81,8 @@ class CustomFieldsGroup
}
/**
* Add customField
* Add customField.
*
* @param CustomField $customField
* @return CustomFieldsGroup
*/
public function addCustomField(CustomField $customField)
@@ -107,34 +93,17 @@ class CustomFieldsGroup
}
/**
* Remove customField
*
* @param CustomField $customField
*/
public function removeCustomField(CustomField $customField)
{
$this->customFields->removeElement($customField);
}
/**
* @return Collection
*/
public function getCustomFields()
{
return $this->customFields;
}
/**
* Get all the custom
* Get all the custom.
*
* @return Collection
*/
public function getActiveCustomFields()
{
if($this->activeCustomFields === null) {
$this->activeCustomFields = array();
if (null === $this->activeCustomFields) {
$this->activeCustomFields = [];
foreach ($this->customFields as $cf) {
if($cf->isActive()) {
if ($cf->isActive()) {
array_push($this->activeCustomFields, $cf);
}
}
@@ -144,9 +113,27 @@ class CustomFieldsGroup
}
/**
* Get id
* @return Collection
*/
public function getCustomFields()
{
return $this->customFields;
}
/**
* Get entity.
*
* @return integer
* @return string
*/
public function getEntity()
{
return $this->entity;
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
@@ -154,48 +141,55 @@ class CustomFieldsGroup
}
/**
* Set name
* Get name.
*
* @param array $name
* @return CustomFieldsGroup
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
* @param mixed|null $language
*
* @return array
*/
public function getName($language = null)
{
//TODO set this in a service, PLUS twig function
if ($language) {
if (isset($this->name[$language])) {
return $this->name[$language];
} else {
foreach ($this->name as $name) {
//TODO set this in a service, PLUS twig function
if ($language) {
if (isset($this->name[$language])) {
return $this->name[$language];
}
foreach ($this->name as $name) {
if (!empty($name)) {
return $name;
return $name;
}
}
}
}
return '';
return '';
}
} else {
return $this->name;
}
return $this->name;
}
/**
* Set entity
* get options array.
*
* @return array
*/
public function getOptions()
{
return $this->options;
}
/**
* Remove customField.
*/
public function removeCustomField(CustomField $customField)
{
$this->customFields->removeElement($customField);
}
/**
* Set entity.
*
* @param string $entity
*
* @return CustomFieldsGroup
*/
public function setEntity($entity)
@@ -206,34 +200,28 @@ class CustomFieldsGroup
}
/**
* Get entity
* Set name.
*
* @return string
* @param array $name
*
* @return CustomFieldsGroup
*/
public function getEntity()
public function setName($name)
{
return $this->entity;
$this->name = $name;
return $this;
}
/**
* get options array
* set options array.
*
* @return array
*/
public function getOptions()
{
return $this->options;
}
/**
* set options array
*
* @param array $options
* @return CustomFieldsGroup
*/
public function setOptions(array $options)
{
$this->options = $options;
return $this;
}
}