validateContainer

@param $container
@return array
771039
private function validateContainer($container)
    {
        if ($container === false)
            return $container;
        $resolver = new OptionsResolver();
        $resolver->setDefaults([
            'panel' => false,
            'class' => false,
            'rows' => false,
            'headerRow' => false,
            'collection' => false,
        ]);
        $resolver->setAllowedTypes('class', ['string', 'boolean']);
        $resolver->setAllowedTypes('panel', ['array', 'boolean']);
        $resolver->setAllowedTypes('rows', ['array', 'boolean']);
        $resolver->setAllowedTypes('headerRow', ['array', 'boolean']);
        $resolver->setAllowedTypes('collection', ['array', 'boolean']);
        $container = $resolver->resolve($container);

        $container['panel'] = $this->validatePanel($container['panel']);

        if (($container['panel'] !== false && $container['class'] !== false) || ( $container['panel'] === false && $container['class'] === false))
            trigger_error(sprintf('Containers must specify one of a panel (%s) or a class (%s), but not both.', $container['panel']['colour'], $container['class']), E_USER_ERROR);

        $container['collection'] = $this->validateCollection($container['collection']);

        $container['headerRow'] = $this->validateRow($container['headerRow']);
        $container['rows'] = $this->validateRows($container['rows']);

        return $container;
    }
149355
protected function registerMethods(Container $container)
    {
        $orderedMethods = [];

        foreach ($this->methods as $methodClass) {
            /** @var MethodInterface $method */
            $method = new $methodClass();

            if ($method->isSupported()) {
                $container['method.'.$method->getName()] = function() use ($methodClass) {
                    return new $methodClass();
                };

                $orderedMethods[] = 'method.'.$method->getName();
            }
        }

        // order methods
        usort($orderedMethods, function ($methodName1, $methodName2) use ($container) {
            $value1 = ((int) $container[$methodName1]->isSupported()) + ($container[$methodName1]->getUncompressionSpeedLevel() / 10);
            $value2 = ((int) $container[$methodName2]->isSupported()) + ($container[$methodName2]->getUncompressionSpeedLevel() / 10);

            if ($value1 == $value2) {
                return 0;
            }

            return ($value1 > $value2) ? -1 : 1;
        });

        $container['method.__ordered'] = $orderedMethods;
    }
1066607
public function register(Container $container)
    {
        /**
         * @param  Container $container A container instance.
         * @return LoggerConfig
         */
        $container['logger/config'] = function (Container $container) {
            $appConfig    = isset($container['config']) ? $container['config'] : [];
            $loggerConfig = isset($appConfig['logger']) ? $appConfig['logger'] : null;
            return new LoggerConfig($loggerConfig);
        };

        /**
         * @return FactoryInterface
         */
        $container['logger/processor/factory'] = function () {
            return new Factory([
                'map' => [
                    'memory-usage' => MemoryUsageProcessor::class,
                    'uid'          => UidProcessor::class
                ]
            ]);
        };

        /**
         * @param  Container $container A container instance.
         * @return StreamHandler|null
         */
        $container['logger/handler/stream'] = function (Container $container) {
            $loggerConfig  = $container['logger/config'];
            $handlerConfig = $loggerConfig['handlers.stream'];

            if ($handlerConfig['active'] !== true) {
                return null;
            }

            $level = $handlerConfig['level'] ?: $loggerConfig['level'];
            return new StreamHandler($handlerConfig['stream'], $level);
        };

        /**
         * @param  Container $container A container instance.
         * @return BrowserConsoleHandler|null
         */
        $container['logger/handler/browser-console'] = function (Container $container) {
            $loggerConfig  = $container['logger/config'];
            $handlerConfig = $loggerConfig['handlers.console'];

            if ($handlerConfig['active'] !== true) {
                return null;
            }

            $level = $handlerConfig['level'] ?: $loggerConfig['level'];
            return new BrowserConsoleHandler($level);
        };

        /**
         * @param  Container $container A container instance.
         * @return Container Collection of defined record handlers, in a service container.
         */
        $container['logger/handlers'] = function (Container $container) {
            $loggerConfig   = $container['logger/config'];
            $handlersConfig = $loggerConfig['handlers'];
            $handlerFactory = $container['logger/handler/factory'];

            $handlers = new Container();
            foreach ($handlersConfig as $handler) {
                $handlers[$handler['type']] = function () use ($handler, $handlerFactory) {
                    $type    = $handler['type'];
                    $handler = $handlerFactory->create($type);
                    return $handler;
                };
            }

            return $handlers;
        };

        /**
         * Fulfills the PSR-3 dependency with a Monolog logger.
         *
         * @param  Container $container A container instance.
         * @return LoggerInterface
         */
        $container['logger'] = function (Container $container) {
            $loggerConfig = $container['logger/config'];

            if ($loggerConfig['active'] !== true) {
                return new NullLogger();
            }

            $logger = new Logger($loggerConfig['channel']);

            $memProcessor = new MemoryUsageProcessor();
            $logger->pushProcessor($memProcessor);

            $uidProcessor = new UidProcessor();
            $logger->pushProcessor($uidProcessor);

            $consoleHandler = $container['logger/handler/browser-console'];
            if ($consoleHandler) {
                $logger->pushHandler($consoleHandler);
            }

            $streamHandler = $container['logger/handler/stream'];
            if ($streamHandler) {
                $logger->pushHandler($streamHandler);
            }

            return $logger;
        };
    }
801748
public function inject(Container $container) : array
    {
        $bindings = $this->bind->getBindings();
        foreach ($bindings as &$interceptors) {
            /* @var string[] $interceptors */
            foreach ($interceptors as &$interceptor) {
                if (\is_string($interceptor)) {
                    $interceptor = $container->getInstance($interceptor, Name::ANY);
                }
            }
        }

        return $bindings;
    }
1271088
public function validate()
    {
        foreach ($this as $element) {

            if (
                $element instanceof ValidationAwareInterface ||
                $element instanceof ContainerInterface
            ) {
                $element->validate();
            }
        }
        return $this;
    }
951433
protected function parseContainer(Container $container)
    {
        $map = array();

        foreach ($container->keys() as $name) {
            if (strpos($name, self::DIC_PREFIX) === 0) {
                continue;
            }

            if ($item = $this->parseItem($container, $name)) {
                $map[] = $item;
            }
        }

        return $map;
    }
494789
public function validate($command)
	{
		if ($command instanceof SelfValidating) {
            return $this->container->call([$command, 'validate']);
		}
		
		$validatorClass = $this->getValidatorClass($command);
		if(!$validatorClass) {
			return;
		}
        
		$validator = $this->container->make($validatorClass);
		$method = $this->getValidatorMethod($command);

		call_user_func([$validator, $method], $command);
	}
505815
function validateContainer (container) {
  var err;
  if (!container || container.error) {
    err = Boom.create(504, 'instance is down (no container)', container.error);
  }
  else if (container.inspect.error) {
    err = Boom.create(503, 'instance inspect failed (try again)', container.inspect.error);
  }

  return err;
}
194618
private static function getCsrfSettings(ContainerInterface $container): array
    {
        /** @var SettingsProviderInterface $provider */
        assert($container->has(SettingsProviderInterface::class) === true);
        $provider = $container->get(SettingsProviderInterface::class);

        assert($provider->has(CsrfSettings::class));
        $settings = $provider->get(CsrfSettings::class);

        return $settings;
    }
820870
public function authentication(Container $container)
    {
        $auth = $container->newInstance(Authentication::class);

        foreach ((array) $container->get('config')->get('user.methods') as $name => $method) {
            if ($method !== false) {
                $auth->addMethod($name, $container->newInstance($method));
            }
        }

        /** @var EventDispatcher $dispatcher */
        $this->dispatcher->triggerEvent('onLoadAuthenticationMethods', ['auth' => $auth]);

        return $auth;
    }
696854
protected function registerElfinderServices(Container $container)
    {
        /**
         * Configure the "config.admin.elfinder" dataset.
         *
         * @param  AdminConfig $adminConfig The admin configset.
         * @return AdminConfig
         */
        $container->extend('admin/config', function (AdminConfig $adminConfig) {
            $adminConfig['elfinder'] = new Config($adminConfig['elfinder']);

            return $adminConfig;
        });

        /**
         * The elFinder configset.
         *
         * @param  Container $container The Pimple DI Container.
         * @return ConfigInterface
         */
        $container['elfinder/config'] = function (Container $container) {
            return $container['admin/config']['elfinder'];
        };
    }
176218
protected function getValidatorInstance(): Validator
    {
        $factory = $this->container->make(ValidationFactory::class);

        if (method_exists($this, 'validator')) {
            $validator = $this->container->call([$this, 'validator'], compact('factory'));
        } else {
            $validator = $this->createDefaultValidator($factory);
        }

        if (method_exists($this, 'withValidator')) {
            $this->withValidator($validator);
        }

        return $validator;
    }
35485
protected function containerName($container = null)
    {
        if ($container !== null) {
            return $container;
        }

        $pos = strrpos($this->entity, '\\');
        if ($pos === false) {
            return $this->entity;
        }

        return substr($this->entity, strrpos($this->entity, '\\') + 1);
    }
522939
public static function prepareContainer(Container $container)
    {
        if ( ! isset($container['config'])) {
            $container['config'] = [];
        }
        if ( ! isset($container['files'])) {
            $container['files'] = new Filesystem();
        }
        if ( ! isset($container['providers'])) {
            $container['providers'] = [];
        }
        $providers = $container['providers'];
        $providers[] = 'Consolet\DefaultCommandsProvider';
        $container['providers'] = $providers;
        return $container;
    }
741379
public static function validateUser(ContainerInterface $container, string $userName, string $password)
    {
        /** @var Connection $connection */
        $connection = $container->get(Connection::class);

        $query = $connection->createQueryBuilder();
        $query
            ->select([User::FIELD_ID, User::FIELD_EMAIL, User::FIELD_PASSWORD_HASH])
            ->from(User::TABLE_NAME)
            ->where(User::FIELD_EMAIL . '=' . $query->createPositionalParameter($userName))
            ->setMaxResults(1);
        $user = $query->execute()->fetch(PDO::FETCH_ASSOC);
        if ($user === false) {
            return null;
        }

        /** @var HasherInterface $hasher */
        $hasher = $container->get(HasherInterface::class);
        if ($hasher->verify($password, $user[User::FIELD_PASSWORD_HASH]) === false) {
            return null;
        }

        return (int)$user[User::FIELD_ID];
    }
994685
private function getConfigFromContainer(ContainerInterface $container)
    {
        if (! $container->has('config')) {
            return [];
        }

        $config = $container->get('config');

        if (! isset($config['zf-mvc-auth']['authorization'])) {
            return [];
        }

        return $config['zf-mvc-auth']['authorization'];
    }
800014
public function validateValidatorConfiguration($validatorConfiguration)
    {
        $validationErrors = [];

        if (!is_array($validatorConfiguration)) {
            $validationErrors[] = new ValidationError('Validator configuration must be in form of an array');

            return $validationErrors;
        }

        foreach ($validatorConfiguration as $validatorIdentifier => $constraints) {
            if ($validatorIdentifier !== 'TagsValueValidator') {
                $validationErrors[] = new ValidationError(
                    "Validator '%validator%' is unknown",
                    null,
                    [
                        '%validator%' => $validatorIdentifier,
                    ],
                    "[${validatorIdentifier}]"
                );

                continue;
            }

            if (!is_array($constraints)) {
                $validationErrors[] = new ValidationError('TagsValueValidator constraints must be in form of an array');

                return $validationErrors;
            }

            foreach ($constraints as $name => $value) {
                switch ($name) {
                    case 'subTreeLimit':
                        if (!is_numeric($value)) {
                            $validationErrors[] = new ValidationError(
                                "Validator parameter '%parameter%' value must be of numeric type",
                                null,
                                [
                                    '%parameter%' => $name,
                                ],
                                "[${validatorIdentifier}][${name}]"
                            );
                        }

                        if ($value < 0) {
                            $validationErrors[] = new ValidationError(
                                "Validator parameter '%parameter%' value must be equal or larger than 0",
                                null,
                                [
                                    '%parameter%' => $name,
                                ],
                                "[${validatorIdentifier}][${name}]"
                            );
                        }

                        if ($value > 0 && !$this->tagsService->loadTagList([$value])) {
                            $validationErrors[] = new ValidationError(
                                "Validator parameter '%parameter%' value must be an existing tag ID",
                                null,
                                [
                                    '%parameter%' => $name,
                                ],
                                "[${validatorIdentifier}][${name}]"
                            );
                        }

                        break;
                    case 'maxTags':
                        if (!is_int($value)) {
                            $validationErrors[] = new ValidationError(
                                "Validator parameter '%parameter%' value must be of integer type",
                                null,
                                [
                                    '%parameter%' => $name,
                                ],
                                "[${validatorIdentifier}][${name}]"
                            );
                        }

                        if ($value < 0) {
                            $validationErrors[] = new ValidationError(
                                "Validator parameter '%parameter%' value must be equal or larger than 0",
                                null,
                                [
                                    '%parameter%' => $name,
                                ],
                                "[${validatorIdentifier}][${name}]"
                            );
                        }

                        break;
                    default:
                        $validationErrors[] = new ValidationError(
                            "Validator parameter '%parameter%' is unknown",
                            null,
                            [
                                '%parameter%' => $name,
                            ],
                            "[${validatorIdentifier}][${name}]"
                        );
                }
            }
        }

        return $validationErrors;
    }