/** * @param string $type * @return DoctrineRestServiceModel */ public function getModel($type = DoctrineRestServiceModelFactory::TYPE_DEFAULT) { if ($this->model instanceof DoctrineRestServiceModel) { return $this->model; } $moduleName = $this->getModuleName(); $this->model = $this->restFactory->factory($moduleName, $type); return $this->model; }
/** * @param ContainerInterface $container * @return DoctrineRestServiceModelFactory */ public function __invoke(ContainerInterface $container) { if (!$container->has(ModulePathSpec::class) || !$container->has(ModuleModel::class) || !$container->has(ConfigResourceFactory::class) || !$container->has('SharedEventManager')) { throw new ServiceNotCreatedException(sprintf('%s is missing one or more dependencies from ZF\\Configuration', DoctrineRestServiceModelFactory::class)); } $sharedEvents = $container->get('SharedEventManager'); $this->attachSharedListeners($sharedEvents); $instance = new DoctrineRestServiceModelFactory($container->get(ModulePathSpec::class), $container->get(ConfigResourceFactory::class), $sharedEvents, $container->get(ModuleModel::class)); $instance->setServiceManager($container); return $instance; }