get('config'); /** @psalm-var mixed $config */ $config = $config instanceof Traversable ? iterator_to_array($config, true) : $config; $config = is_array($config) ? $config : []; $helperConfig = $this->assertArray('view_helper_config', $config); $helperConfig = $this->assertArray('asset', $helperConfig); /** @psalm-var array $resourceMap */ $resourceMap = $this->assertArray('resource_map', $helperConfig); return new Asset($resourceMap); } /** * Create service * * @deprecated since 2.20.0, this method will be removed in version 3.0.0 of this component. * Compatibility with the 2.x series of Laminas\ServiceManager is no longer supported. * * @param string|null $rName * @param string|null $cName * @return Asset */ public function createService(ServiceLocatorInterface $serviceLocator, $rName = null, $cName = null) { return $this($serviceLocator, $cName); } /** * @param array $array * @return array */ private function assertArray(string $key, array $array): array { $value = $array[$key] ?? []; if (! is_array($value)) { throw new Exception\RuntimeException(sprintf( 'Invalid resource map configuration. ' . 'Expected the key "%s" to contain an array value but received "%s"', $key, gettype($value) )); } return $value; } }