Create or return null if the used element is not valid.

@param string $name
@param int    $n
@param array  $activeElements

@return Counter|null
188608
public static function createByActiveElements(
        string $name,
        int $n,
        array $activeElements
    ): ? self {
        $values = Metadata::fromMetadata($name);

        if (is_null($values)) {
            return null;
        }

        return new self(
            $values,
            in_array($values['id'], $activeElements),
            $n
        );
    }
30678
public function getAction($name, $context = 'bottom'){

		foreach($this->getActions($context) as $element){
			if($element->getName() == $name){
				$returnValue = $element;
				break;
			}
		}
		if (is_null($returnValue)) {
			common_Logger::w('Action with name \''.$name.'\' not found');
		}

		return $returnValue;
	}
374981
public function activate($name = null)
    {
        if (!$this->sieve) {
            return $this->_set_error(self::ERROR_INTERNAL);
        }

        if (!$name) {
            $name = $this->current;
        }

        $result = $this->sieve->setActive($name);

        if (is_a($result, 'PEAR_Error')) {
            return $this->_set_error(self::ERROR_ACTIVATE);
        }

        $this->active = $name;

        return true;
    }
478429
public function setElementInsteadOf($targetName, $element, $name = null) {
		if (! isset($this->_elements[$targetName])) {
			return $this;
		}
		
		$elements = [];
		
		foreach ($this->_elements as $existsName => $existsElement) {
			
			if ($targetName === $existsName) {
				if ($name === null) {
					$elements[] = $element;
				} else {
					$elements[$name] = $element;
				}
			} else {
				$elements[$existsName] = $existsElement;
			}
		}
		
		$this->_elements = $elements;
		
		return $this;
	}
246821
public function addRow($name = NULL)
	{
		/** @noinspection PhpParamsInspection */
		$row = new BootstrapRow($this, $name);
		$this->addComponent($row, $row->name);

		return $row;
	}
1192249
public function hasElement( $name, $prefix = null )
	{
		return isset( $this->elements[ is_null( $prefix ) ? $name : "$prefix:$name" ] );
	}
377882
public function getElement($name)
    {
        $elements = $this->getElements();

        return isset($elements[$name]) ? $elements[$name] : null;
    }
703505
public function getElement($element_name, $modificator_name = null, $modificator_value = null)
	{
		$items = $this->getElements($element_name, $modificator_name, $modificator_value);

		return count($items) ? current($items) : null;
	}
800277
public function sub($name, $attrs = null, $ns = null)
    {
        //@TODO: attrs is ignored
        foreach ($this->subs as $sub) {
            if ($sub->name === $name and ($ns === null or $sub->ns === $ns)) {
                return $sub;
            }
        }
        return null;
    }
1119270
public static function addEntry($name, $link = '', $active = false)
	{
		static::getRoot()->appendButton($name, $link, $active);
	}
786716
protected function createElement($name)
    {
        if (isset($this->elements[$name])) {
            return $this->factory->createInlineElement($this->elements[$name]);
        }

        return $this->factory->createElement($name);
    }
616267
public function getElement($name)
    {
        if ($element = parent::getElement($name)) {
            return $element;
        } else {
            $subforms = $this->getSubForms();
            foreach($subforms as $subform) {
                if ($element = $subform->getElement($name)) {
                    return $element;
                }
            }
            return;
        }
    }
99564
private function addElement($name, $parent = false, $ns = false)
    {
        if ($ns) {
            $el = $parent->ownerDocument->createElementNS($ns, $name);
        } else {
            $el = $parent->ownerDocument->createElement($name);
        }
        if ($parent) {
            $parent->appendChild($el);
        }

        return $el;
    }
101460
static function laraform($title, $name=null) {
        $el = new ElementSubmitTwbs($name, ['value' => $title]);
        $el->addClass('btn');
        return $el;
    }
80699
static function ByCreationMethod($name)
    {
        $enumClass = new \ReflectionClass(get_class());
        $calledClass = get_called_class();
        $reflectionClass = new \ReflectionClass($calledClass);
        $methods = $reflectionClass->getMethods(\ReflectionMethod::IS_STATIC);
        foreach ($methods as $method)
        {
            if ($method->name != $name)
                continue;
            
            if ($method->isPublic() && $method->getNumberOfParameters() == 0)
            {
                if (!$enumClass->hasMethod($method->name))
                {
                    $result = $method->invoke(null);
                    if (get_class($result) == $calledClass)
                        return $result;
                }
            }
        }
        throw new \InvalidArgumentException("'Creation method '$name' not found");
    }
688271
public function has($name, array $options = array())
    {
        $root = $this->builder->hasRootItemByName($name, $this->container->get('request_stack')->getCurrentRequest());

        return null !== $root;
    }
1073427
public function isCurrentMigration($name)
    {
        $current = $this->getCurrentMigration();

        return (!is_null($current) && $current->name == $name);
    }