/** * @param \Session $session * @return void */ public function doBootstrap(Session $session) { if ($this->container === null) { require_once HEYSTACK_BASE_PATH . '/config/container.php'; $containerClassName = 'HeystackServiceContainer' . \Director::get_environment_type(); $this->container = new $containerClassName(); } \Injector::inst()->setObjectCreator(new HeystackInjectionCreator($this->container)); $this->container->get(Services::BACKEND_SESSION)->setSession($session); $this->eventDispatcher = $this->container->get(Services::EVENT_DISPATCHER); }
/** * @param string $service * @param array $params * @return mixed|object * @throws \InvalidArgumentException */ public function create($service, array $params = array()) { $prefix = substr($service, 0, 9); if ($prefix === 'heystack.' || $prefix === 'heystack?') { $service = substr($service, 9); if ($this->heystackContainer->has($service)) { return $this->heystackContainer->get($service); } elseif ($this->heystackContainer->hasParameter($service)) { return $this->heystackContainer->getParameter($service); } elseif ($prefix === 'heystack?') { return null; } throw new \InvalidArgumentException(sprintf("Requested Heystack service or parameter '%s' doesn't exist", $service)); } else { return parent::create($service, $params); } }