$options]; } if (! $this->has($name)) { if (! $this->autoAddInvokableClass || ! class_exists($name)) { throw new Exception\InvalidElementException(sprintf( 'A plugin by the name "%s" was not found in the plugin manager %s', $name, get_class($this) )); } $this->setInvokableClass($name, $name); } return parent::get($name, $options, $usePeeringServiceManagers); } /** * Try to pull hydrator from the creation context, or instantiates it from its name * * @param string $hydratorName * @return mixed * @throws Exception\DomainException */ public function getHydratorFromName($hydratorName) { $services = isset($this->creationContext) ? $this->creationContext // v3 : $this->serviceLocator; // v2 if ($services && $services->has('HydratorManager')) { $hydrators = $services->get('HydratorManager'); if ($hydrators->has($hydratorName)) { return $hydrators->get($hydratorName); } } if ($services && $services->has($hydratorName)) { return $services->get($hydratorName); } if (! class_exists($hydratorName)) { throw new Exception\DomainException(sprintf( 'Expects string hydrator name to be a valid class name; received "%s"', $hydratorName )); } $hydrator = new $hydratorName; return $hydrator; } /** * Try to pull factory from the creation context, or instantiates it from its name * * @param string $factoryName * @return mixed * @throws Exception\DomainException */ public function getFactoryFromName($factoryName) { $services = isset($this->creationContext) ? $this->creationContext // v3 : $this->serviceLocator; // v2 if ($services && $services->has($factoryName)) { return $services->get($factoryName); } if (! class_exists($factoryName)) { throw new Exception\DomainException(sprintf( 'Expects string factory name to be a valid class name; received "%s"', $factoryName )); } $factory = new $factoryName; return $factory; } }