BaseEventTypeController::getChildOptionalElements PHP Method

getChildOptionalElements() public method

Get the child optional elements for the given element type.
public getChildOptionalElements ( ElementType $parent_type ) : BaseEventTypeElement[]
$parent_type ElementType
return BaseEventTypeElement[] $optional_elements
    public function getChildOptionalElements($parent_type)
    {
        $open_et = array();
        if (is_array($this->open_elements)) {
            foreach ($this->open_elements as $open) {
                $et = $open->getElementType();
                if ($et && $et->isChild() && $et->parent_element_type->class_name == $parent_type->class_name) {
                    $open_et[] = $et->class_name;
                }
            }
        }
        $optional = array();
        foreach ($parent_type->child_element_types as $child_type) {
            if (!in_array($child_type->class_name, $open_et)) {
                $optional[] = $child_type->getInstance();
            }
        }
        return $optional;
    }

Usage Example

Esempio n. 1
0
 /**
  * extends standard method to filter elements.
  *
  * (non-PHPdoc)
  *
  * @see NestedElementsEventTypeController::getChildOptionalElements()
  */
 public function getChildOptionalElements($parent_type)
 {
     return $this->filterElements(parent::getChildOptionalElements($parent_type));
 }
BaseEventTypeController