@param Configuration $configuration
@param array         $params

@return Parameter
552135
protected function getParameterObject(Configuration $configuration, array $params)
  {
    $parameter = new Parameter($configuration->getKey(), $this->getValue($configuration, $params));
    $this->setDefaultIfNull($configuration, $parameter);
    $this->normalizer->normalize($parameter, $configuration);

    return $parameter;
  }
1274106
public function requireIfAvailableAnd(Configuration $configuration, array $params)
  {
    $requiredIfAvailable = $configuration->getOptions()->getRequiredIfAvailable();
    if (is_array($requiredIfAvailable->getAnd()) && count($requiredIfAvailable->getAnd()) > 0)
    {
      foreach ($requiredIfAvailable->getAnd() as $key)
      {
        if (!array_key_exists(strtolower($key), $params))
        {
          return false;
          break;
        }
      }

      return true;
    }

    return false;
  }
832094
protected function prepareDate(Configuration $configuration, Parameter $parameter)
  {
    $this->dispatcher->dispatch(
      TransformerEvents::PREPARE_DATE,
      new TransformerEvent($configuration, $parameter)
    );

    $date = new \DateTime();
    foreach ($configuration->getOptions()->getExpectedFormat() as $format)
    {
      $date = \DateTime::createFromFormat($format, $parameter->getValue());
      if ($date instanceof \DateTime)
      {
        break;
      }
    }
    if ($configuration->getOptions()->isConvertToObject() === true)
    {
      $parameter->setValue($date);
    }
    elseif ($configuration->getOptions()->getConvertToFormat() !== null)
    {
      $parameter->setValue($date->format($configuration->getOptions()->getConvertToFormat()));
    }

    return $this;
  }
289803
public function apply(Request $request, ParamConverter $configuration)
    {
        if (null === $parameter = $configuration->getName()) {
            throw new InvalidConfigurationException(InvalidConfigurationException::MISSING_NAME);
        }

        $options = $configuration->getOptions();

        if ($options['authenticatedUser'] === true) {
            if (($user = $this->tokenStorage->getToken()->getUser()) instanceof User) {
                $request->attributes->set($parameter, $user);

                return true;
            } else {
                if (array_key_exists('messageEnabled', $options) && $options['messageEnabled'] === true) {
                    $messageType = 'warning';
                    if (array_key_exists('messageType', $options)) {
                        $messageType = $options['messageType'];
                    }

                    $messageTranslationKey = 'this_page_requires_authentication';
                    $messageTranslationDomain = 'platform';
                    if (array_key_exists('messageTranslationKey', $options)) {
                        $messageTranslationKey = $options['messageTranslationKey'];
                        if (array_key_exists('messageTranslationDomain', $options)) {
                            $messageTranslationDomain = $options['messageTranslationDomain'];
                        }
                    }

                    $request->getSession()->getFlashBag()->add(
                        $messageType,
                        $this->translator->trans($messageTranslationKey, [], $messageTranslationDomain)
                    );
                }

                throw new AccessDeniedException();
            }
        } else {
            $request->attributes->set($parameter, $user = $this->tokenStorage->getToken()->getUser());
        }
    }
993710
protected function setDefaultIfNull(Configuration $configuration, Parameter $parameter)
  {
    $this->dispatcher->dispatch(
      TransformerEvents::PREPARE_DEFAULT,
      new TransformerEvent($configuration, $parameter)
    );

    if ($parameter->getValue() === null)
    {
      $value = $configuration->getOptions()->getDefaultValue();
      $parameter->setValue($value);
    }

    return $this;
  }
1070638
public function handle(string $content, array $configuration): string
    {
        $request = $this->requestStack->getCurrentRequest();

        $request->attributes->set('data', $this->cObj->data);
        $request->attributes->set('_controller', $configuration['controller']);

        $request->headers->set('X-Php-Ob-Level', \ob_get_level());

        // request
        $event = new GetResponseEvent($this->kernel, $request, HttpKernel::SUB_REQUEST);
        $this->dispatcher->dispatch(KernelEvents::REQUEST, $event);

        if ($event->hasResponse()) {
            return $this->filterResponse($event->getResponse(), $request, HttpKernel::SUB_REQUEST);
        }

        // load controller
        $controller = $this->resolver->getController($request);
        if (false === $controller) {
            throw new NotFoundHttpException(\sprintf('Unable to find the controller "%s". The content element is wrongly configured.', $request->attributes->get('_controller', $configuration['controller'])));
        }

        $event = new FilterControllerEvent($this->kernel, $controller, $request, HttpKernel::SUB_REQUEST);
        $this->dispatcher->dispatch(KernelEvents::CONTROLLER, $event);
        $controller = $event->getController();

        // controller arguments
        $arguments = $this->argumentResolver->getArguments($request, $controller);

        $event = new FilterControllerArgumentsEvent($this->kernel, $controller, $arguments, $request, HttpKernel::SUB_REQUEST);
        $this->dispatcher->dispatch(KernelEvents::CONTROLLER_ARGUMENTS, $event);
        $controller = $event->getController();
        $arguments = $event->getArguments();

        // call controller
        try {
            $response = $controller(...$arguments);
        } catch (NotFoundHttpException $e) {
            $psrResponse = $this->errorController->pageNotFoundAction(
                $this->psrHttpFactory->createRequest($request),
                $e->getMessage()
            );

            throw new ImmediateResponseException($psrResponse);
        }

        // view
        if (!$response instanceof Response) {
            $event = new GetResponseForControllerResultEvent($this->kernel, $request, HttpKernel::SUB_REQUEST, $response);
            $this->dispatcher->dispatch(KernelEvents::VIEW, $event);

            if ($event->hasResponse()) {
                $response = $event->getResponse();
            } else {
                $msg = \sprintf('The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned %s.', $this->varToString($response));

                // the user may have forgotten to return something
                if (null === $response) {
                    $msg .= ' Did you forget to add a return statement somewhere in your controller?';
                }

                throw new ControllerDoesNotReturnResponseException($msg, $controller, __FILE__, __LINE__ - 23);
            }
        }

        return $this->filterResponse($response, $request, HttpKernel::SUB_REQUEST);
    }
322270
protected static function pluckConfiguration(Configuration $configuration, string $prefix = '') : array
    {
        $extracted = [];

        // ported from
        // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1092
        if ($configuration->hasValue($prefix.'keys')) {
            $extracted['keys'] = $configuration->getArray($prefix.'keys');
        }

        // ported from
        // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1108
        if ($configuration->hasValue($prefix.'certData')) {
            $extracted['certificateData'] = $configuration->getString($prefix.'certData');
        }

        // ported from
        // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1119
        if ($configuration->hasValue($prefix.'certificate')) {
            $extracted['certificateData'] = $configuration->getString($prefix.'certificate');
        }

        $extracted['assertionEncryptionEnabled'] = $configuration->getBoolean('assertion.encryption', false);

        if ($configuration->hasValue('sharedKey')) {
            $extracted['sharedKey'] = $configuration->getString('sharedKey');
        }

        return $extracted;
    }
468472
public function render(Configuration $configuration)
    {
        $output = '';

        foreach ($configuration->getSections() as $name => $section) {
            $output .= $this->renderSection($section);
        }

        return $output;
    }
454759
private function getConfigurationParameters(ConfigurationInterface $configuration)
    {
        $parameters = [];

        $values = $configuration->getValues();

        foreach ($configuration->getModel() as $parameterModel) {
            $parameterName = $parameterModel->getName();
            $parameterType = $parameterModel->getType();
            $parameterDataType = $parameterModel->getDataType();

            if (!array_key_exists($parameterName, $values)) {
                continue;
            }

            $value = $values[$parameterName];

            if ($value == $parameterModel->getDefaultValue()
                && !isset($this->persistedParameters[$configuration->getName()][$parameterName])
            ) {
                continue;
            }
            if (null !== $value && gettype($value) !== $parameterDataType) {
                $message = sprintf(
                    'Parameter "%s" of configuration "%s" must have value of "%s" type, "%s" type value provided.',
                    $parameterName,
                    $configuration->getName(),
                    $parameterDataType,
                    gettype($value)
                );

                throw new ConfigurationException($message);
            }

            $value = $this->parameterValueConverter->toString($value, $parameterType, $parameterModel->getOptions());

            $parameters[] = new Parameter($configuration->getName(), $parameterName, $parameterType, $value);
        }

        return $parameters;
    }
115627
static public function jiraGetIssueList(array $configuration, array $keyList, array $parameterList = [])
    {
        $issueList = [];

        if (empty($keyList)) {
            return $issueList;
        }

        foreach (array_chunk($keyList, 50) as $chunk) {
            $parameterList['jql'] = 'key IN(' . implode(', ', $chunk) . ')';

            $json = self::jiraGet(
                $configuration['host'] . $configuration['endpoint']['search'],
                $configuration['loginHash'],
                $parameterList
            );

            if (!isset($json->issues)) {
                throw new ContextRuntimeException(
                    'No issues found',
                    StatusCode::INTERNAL_SERVER_ERROR,
                    ['response' => $json]
                );
            }

            foreach ($json->issues as $issue) {
                $issueList[] = $issue;
            }
        }

        return $issueList;
    }
892353
protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
    {
        $processor = new Processor();

        return $processor->processConfiguration($configuration, $configs);
    }
1031253
public function setParams($params) {
        if (isset($params['extra'])) {
            if (isset($params['extra']['details'])) {
                throw new ConfigurationException('"details" option is readonly (always true) and cannot be set');
            }
        }
        parent::setParams($params);
    }
1106091
public function executeIfConditionMatch(array $configuration, &$context)
    {
        $condition = $this->confHelper->resolve($configuration[self::CONF_CONDITION], $context);

        if ($condition) {
            return $this->execute($configuration, $context);
        }
    }
76704
public static function createFromConfiguration ($role, array $configuration)
    {
        return new Role(
            $role,
            isset($configuration["title"]) ? $configuration["title"] : null,
            isset($configuration["description"]) ? $configuration["description"] : null,
            isset($configuration["hidden"]) ? $configuration["hidden"] : false,
            isset($configuration["tags"]) ? $configuration["tags"] : [],
            isset($configuration["actions"]) ? $configuration["actions"] : []
        );
    }
1109689
protected function executeAll(array $configuration, &$context)
    {
        $parameters = $this->confHelper->resolve($configuration[self::CONF_PARAMETERS], $context);
        $sql = $this->confHelper->resolve($configuration[self::CONF_SQL], $context);

        $results = [];

        foreach ($parameters as $params) {
            $params = $this->prepareParameters($params);
            $results[] = $this->performQuery($configuration, $context, $params, $sql);
        }

        return $results;
    }
1192685
protected function prepareServiceManager(Configuration $configuration)
    {
        $container      = $this->config->get('services', []);
        $serviceManager = new LeagueAdapter();

        foreach ($container as $className) {

            /** @var ServiceProvider $provider */
            $provider = new $className();

            if ( $provider instanceof ServiceProvider ) {
                throw new \InvalidArgumentException(
                    sprintf('Provider %s must be ServiceProvider', $className)
                );
            }

            $aliases = $provider->alias();
            if ( !is_array($aliases) ) {
                $aliases = [$aliases];
            }

            foreach ($aliases as $alias) {
                if ( $provider->share() ) {
                    $serviceManager->share($alias);
                }

                if ( $provider instanceof ServiceManager\SetterInjectorProvider ) {
                    $serviceManager
                        ->inflector($provider->inflector())
                        ->invokeMethod($provider->method(), [$alias]);
                }

                $provides = $provider->provide();

                if ( !is_callable($provides) ) {
                    $serviceManager->alias($alias, $provides);
                    continue;
                }

                $serviceManager->add(
                    $alias,
                    function () use ($provides, $serviceManager) {
                        return $serviceManager->call($provides);
                    }
                );
            }

        }

        // Add the ServiceManager and the Configuration
        $serviceManager->add(LeagueAdapter::class, $serviceManager);
        $serviceManager->add(ConfigurationContainer::class, $this->config);

        return $serviceManager;
    }
965848
public function requireIfNotAvailableOr(Configuration $configuration, array $params)
  {
    $requiredIfNotAvailable = $configuration->getOptions()->getRequiredIfNotAvailable();
    foreach ($requiredIfNotAvailable->getOr() as $key)
    {
      if (!array_key_exists(strtolower($key), $params))
      {
        return true;
        break;
      }
    }

    return false;
  }