16 class Collection implements \ArrayAccess, \IteratorAggregate, \Countable
39 $this->_elements = [];
40 $this->_container = $container;
50 return new \ArrayIterator($this->_elements);
62 $this->_elements[$key] =
$value;
73 return $this->_elements[$key];
84 unset($this->_elements[$key]);
95 return isset($this->_elements[$key]);
109 if ($this->_container->getForm() instanceof
Form) {
110 $element->setContainer($this->_container);
111 $element->setForm($this->_container->getForm());
114 if ($after ===
false) {
116 }
elseif ($after ===
'^') {
117 array_unshift($this->_elements,
$element);
118 }
elseif (is_string($after)) {
119 $newOrderElements = [];
120 foreach ($this->_elements as
$index => $currElement) {
121 if ($currElement->getId() == $after) {
122 $newOrderElements[] = $currElement;
124 $this->_elements = array_merge($newOrderElements, array_slice($this->_elements,
$index + 1));
127 $newOrderElements[] = $currElement;
143 usort($this->_elements, $callback);
153 public function remove($elementId)
156 if ($elementId ==
$element->getId()) {
157 unset($this->_elements[
$index]);
161 $this->_elements = array_merge($this->_elements, []);
172 return count($this->_elements);
183 foreach ($this->_elements as
$element) {
184 if (
$element->getId() == $elementId) {
elseif(isset( $params[ 'redirect_parent']))