mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
The `custom field long choice` aim to provide a way to deal with choices with a big possibilities. The `custom field long choice` allow : - to persist different options in the database ; - each option has a key, a text (translatable string), and eventually a parent, and an internal_key - every key can be activate or not. If the parent is inactivated, all childs are inactivated - the internal key have two purposes : - link to an external csv file, with their own key ; - add a special class to results, to allow custom layout. Currently, the field exists, but some elements are missing : - a script for CSV import - possibility to select multiple items - edition of options - handle of option without parents - tests are missing
154 lines
2.8 KiB
PHP
154 lines
2.8 KiB
PHP
<?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\CustomFieldsBundle\Entity\CustomFieldLongChoice;
|
|
|
|
/**
|
|
*
|
|
*
|
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
*/
|
|
class Option
|
|
{
|
|
/**
|
|
*
|
|
* @var int
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
*
|
|
* @var string
|
|
*/
|
|
private $key;
|
|
|
|
/**
|
|
* a json representation of text (multilingual)
|
|
*
|
|
* @var array
|
|
*/
|
|
private $text;
|
|
|
|
/**
|
|
*
|
|
* @var \Doctrine\Common\Collections\Collection
|
|
*/
|
|
private $children;
|
|
|
|
/**
|
|
*
|
|
* @var Option
|
|
*/
|
|
private $parent;
|
|
|
|
/**
|
|
*
|
|
* @var string
|
|
*/
|
|
private $internalKey = '';
|
|
|
|
/**
|
|
*
|
|
* @var boolean
|
|
*/
|
|
private $active = true;
|
|
|
|
public function getId()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getKey()
|
|
{
|
|
return $this->key;
|
|
}
|
|
|
|
public function getText()
|
|
{
|
|
return $this->text;
|
|
}
|
|
|
|
public function getChildren()
|
|
{
|
|
return $this->children;
|
|
}
|
|
|
|
public function getParent()
|
|
{
|
|
return $this->parent;
|
|
}
|
|
|
|
public function setKey($key)
|
|
{
|
|
$this->key = $key;
|
|
return $this;
|
|
}
|
|
|
|
public function setText(array $text)
|
|
{
|
|
$this->text = $text;
|
|
return $this;
|
|
}
|
|
|
|
public function setParent(Option $parent = null)
|
|
{
|
|
$this->parent = $parent;
|
|
$this->key = $parent->getKey();
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function hasParent()
|
|
{
|
|
return $this->parent === NULL ? false : true;
|
|
}
|
|
|
|
public function getInternalKey()
|
|
{
|
|
return $this->internalKey;
|
|
}
|
|
|
|
public function isActive()
|
|
{
|
|
return $this->active;
|
|
}
|
|
|
|
public function getActive()
|
|
{
|
|
return $this->isActive();
|
|
}
|
|
|
|
public function setInternalKey($internal_key)
|
|
{
|
|
$this->internalKey = $internal_key;
|
|
return $this;
|
|
}
|
|
|
|
public function setActive($active)
|
|
{
|
|
$this->active = $active;
|
|
return $this;
|
|
}
|
|
|
|
|
|
}
|