/** * @inheritdoc */ public function set($filePath, IBootstrapperRegistry $registry) { $data = ["eager" => $registry->getEagerBootstrappers(), "lazy" => []]; foreach ($registry->getLazyBootstrapperBindings() as $boundClass => $bindingData) { $data["lazy"][$boundClass] = ["bootstrapper" => $bindingData["bootstrapper"], "target" => $bindingData["target"]]; } file_put_contents($filePath, json_encode($data)); }
/** * @inheritdoc */ public function dispatch(IBootstrapperRegistry $registry) { if ($this->forceEagerLoading) { $eagerBootstrapperClasses = $registry->getEagerBootstrappers(); $lazyBootstrapperClasses = []; foreach (array_values($registry->getLazyBootstrapperBindings()) as $bindingData) { $lazyBootstrapperClasses[] = $bindingData["bootstrapper"]; } $lazyBootstrapperClasses = array_unique($lazyBootstrapperClasses); $bootstrapperClasses = array_merge($eagerBootstrapperClasses, $lazyBootstrapperClasses); $this->dispatchEagerly($registry, $bootstrapperClasses); } else { // We must dispatch lazy bootstrappers first in case their bindings are used by eager bootstrappers $this->dispatchLazily($registry, $registry->getLazyBootstrapperBindings()); $this->dispatchEagerly($registry, $registry->getEagerBootstrappers()); } }