Adding method getActiveCustomFields

This commit is contained in:
Marc Ducobu 2015-09-30 13:31:09 +02:00
parent 5583fbcc6c
commit 9f98c4e7e6

View File

@ -21,6 +21,8 @@
namespace Chill\CustomFieldsBundle\Entity; namespace Chill\CustomFieldsBundle\Entity;
use \Doctrine\Common\Collections\Collection;
/** /**
* CustomFieldGroup * CustomFieldGroup
*/ */
@ -42,9 +44,18 @@ class CustomFieldsGroup
private $entity; private $entity;
/** /**
* @var \Doctrine\Common\Collections\Collection * @var \Doctrine\Common\Collections\Collection $customFields: The custom
* fields of the group. The custom fields are asc-ordered regarding to their
* property "ordering".
*/ */
private $customFields; private $customFields;
/**
* @var array(customField) | null $activeCustomFields: The custom fields
* of the group that are active. This variable if null, if this
* informations has not been computed.
*/
private $activeCustomFields = null;
/** /**
* *
@ -52,7 +63,7 @@ class CustomFieldsGroup
*/ */
private $options = array(); private $options = array();
/** /**
* Constructor * Constructor
*/ */
public function __construct() public function __construct()
@ -93,6 +104,25 @@ class CustomFieldsGroup
return $this->customFields; return $this->customFields;
} }
/**
* Get all the custom
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getActiveCustomFields()
{
if($this->activeCustomFields === null) {
$this->activeCustomFields = array();
foreach ($this->customFields as $cf) {
if($cf->isActive()) {
array_push($this->activeCustomFields, $cf);
}
}
}
return $this->activeCustomFields;
}
/** /**
* Get id * Get id
@ -189,7 +219,4 @@ class CustomFieldsGroup
$this->options = $options; $this->options = $options;
return $this; return $this;
} }
} }