mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 04:53:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user