protected function hydrateComponents($collection)
    {
        $componentsLocated = array();

        foreach ($this->components as $model => $components) {
            foreach ($this->locators as $locator) {
                if ($locator->supports($model)) {
                    $locator->locate($model, $components);

                    foreach ($components as $key => $component) {
                        $componentsLocated[$key] = $component;
                    }

                    break;
                }
            }
        }

        foreach ($collection as $key => $action) {
            if ($action instanceof TimelineInterface) {
                $action = $action->getAction();
            }

            foreach ($action->getActionComponents() as $actionComponent) {
                $component = $actionComponent->getComponent();
                if (!$actionComponent->isText() && is_object($component) && null === $component->getData()) {
                    $hash = $component->getHash();

                    if (array_key_exists($hash, $componentsLocated) && !empty($componentsLocated[$hash]) && null !== $componentsLocated[$hash]->getData()) {
                        $actionComponent->setComponent($componentsLocated[$hash]);
                    } else {
                        if ($this->filterUnresolved) {
                            if ($collection instanceof PagerInterface) {
                                $items = iterator_to_array($collection->getIterator());
                                unset($items[$key]);
                                $collection->setItems($items);
                            } elseif (is_array($collection)) {
                                unset($collection[$key]);
                            } else {
                                throw new \Exception('Collection must be an array or a PagerInterface');
                            }
                            break;
                        }
                    }
                }
            }
        }

        return $collection;
    }
protected function hydrateComponents($collection)
    {
        $componentsLocated = array();

        foreach ($this->components as $model => $components) {
            foreach ($this->locators as $locator) {
                if ($locator->supports($model)) {
                    $locator->locate($model, $components);

                    foreach ($components as $key => $component) {
                        $componentsLocated[$key] = $component;
                    }

                    break;
                }
            }
        }

        foreach ($collection as $key => $action) {
            if ($action instanceof TimelineInterface) {
                $action = $action->getAction();
            }

            foreach ($action->getActionComponents() as $actionComponent) {
                $component = $actionComponent->getComponent();
                if (!$actionComponent->isText() && is_object($component) && null === $component->getData()) {
                    $hash = $component->getHash();

                    if (array_key_exists($hash, $componentsLocated) && !empty($componentsLocated[$hash]) && null !== $componentsLocated[$hash]->getData()) {
                        $actionComponent->setComponent($componentsLocated[$hash]);
                    } else {
                        if ($this->filterUnresolved) {
                            if ($collection instanceof PagerInterface) {
                                $items = iterator_to_array($collection->getIterator());
                                unset($items[$key]);
                                $collection->setItems($items);
                            } elseif (is_array($collection)) {
                                unset($collection[$key]);
                            } else {
                                throw new \Exception('Collection must be an array or a PagerInterface');
                            }
                            break;
                        }
                    }
                }
            }
        }

        return $collection;
    }
protected function hydrateComponents ( $ collection ) { $ componentsLocated = array ( ) ; foreach ( $ this -> components as $ model => $ components ) { foreach ( $ this -> locators as $ locator ) { if ( $ locator -> supports ( $ model ) ) { $ locator -> locate ( $ model , $ components ) ; foreach ( $ components as $ key => $ component ) { $ componentsLocated [ $ key ] = $ component ; } break ; } } } foreach ( $ collection as $ key => $ action ) { if ( $ action instanceof TimelineInterface ) { $ action = $ action -> getAction ( ) ; } foreach ( $ action -> getActionComponents ( ) as $ actionComponent ) { $ component = $ actionComponent -> getComponent ( ) ; if ( ! $ actionComponent -> isText ( ) && is_object ( $ component ) && null === $ component -> getData ( ) ) { $ hash = $ component -> getHash ( ) ; if ( array_key_exists ( $ hash , $ componentsLocated ) && ! empty ( $ componentsLocated [ $ hash ] ) && null !== $ componentsLocated [ $ hash ] -> getData ( ) ) { $ actionComponent -> setComponent ( $ componentsLocated [ $ hash ] ) ; } else { if ( $ this -> filterUnresolved ) { if ( $ collection instanceof PagerInterface ) { $ items = iterator_to_array ( $ collection -> getIterator ( ) ) ; unset ( $ items [ $ key ] ) ; $ collection -> setItems ( $ items ) ; } elseif ( is_array ( $ collection ) ) { unset ( $ collection [ $ key ] ) ; } else { throw new \ Exception ( 'Collection must be an array or a PagerInterface' ) ; } break ; } } } } } return $ collection ; }
Use locators to hydrate components.

@param mixed $collection collection

@throws \Exception
@return mixed
Use locators to hydrate components .