getParameterCall example



      return $code;
    }
    elseif ($value instanceof Reference) {
      return $this->getReferenceCall((string) $value$value);
    }
    elseif ($value instanceof Definition) {
      return $this->getPrivateServiceCall(NULL, $value);
    }
    elseif ($value instanceof Parameter) {
      return $this->getParameterCall((string) $value);
    }
    elseif (is_string($value) && str_contains($value, '%')) {
      if (preg_match('/^%([^%]+)%$/', $value$matches)) {
        return $this->getParameterCall($matches[1]);
      }
      else {
        $replaceParameters = function D$matches) {
          return $this->getParameterCall($matches[2]);
        };

        // We cannot directly return the string value because it would

    $services['other.service'] = [
      'class' => get_class($fake_service),
    ];

    $services['non_shared_service'] = [
      'class' => get_class($fake_service),
      'shared' => FALSE,
    ];

    $services['other.service_class_from_parameter'] = [
      'class' => $this->getParameterCall('some_parameter_class'),
    ];
    $services['late.service'] = [
      'class' => get_class($fake_service),
    ];
    $services['service.provider'] = [
      'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
      'arguments' => $this->getCollection([
        $this->getServiceCall('other.service'),
        $this->getParameterCall('some_config'),
      ]),
      'properties' => $this->getCollection(['someProperty' => 'foo']),
      
// Test a deep collection with a reference to resolve.       $service_definitions[] = [
        'arguments' => [[new Reference('bar')]],
        'arguments_count' => 1,
        'arguments_expected' => static::getCollection([static::getCollection([static::getServiceCall('bar')])]),
      ] + $base_service_definition;

      // Test a collection with a variable to resolve.       $service_definitions[] = [
        'arguments' => [new Parameter('llama_parameter')],
        'arguments_count' => 1,
        'arguments_expected' => static::getCollection([static::getParameterCall('llama_parameter')]),
      ] + $base_service_definition;

      // Test getMethodCalls.       $calls = [
        ['method', static::getCollection([])],
        ['method2', static::getCollection([])],
      ];
      $service_definitions[] = [
        'calls' => $calls,
      ] + $base_service_definition;

      
if (\is_array($value)) {
            $code = [];
            foreach ($value as $k => $v) {
                $code[$k] = $this->dumpValue($v);
            }

            return $code;
        } elseif ($value instanceof Reference) {
            return $this->getServiceCall((string) $value$value);
        } elseif ($value instanceof Parameter) {
            return $this->getParameterCall((string) $value);
        } elseif ($value instanceof Expression) {
            return $this->getExpressionCall((string) $value);
        } elseif ($value instanceof Definition) {
            return new TaggedValue('service', (new Parser())->parse("_:\n".$this->addService('_', $value), Yaml::PARSE_CUSTOM_TAGS)['_']['_']);
        } elseif ($value instanceof \UnitEnum) {
            return new TaggedValue('php/const', sprintf('%s::%s', $value::class$value->name));
        } elseif ($value instanceof AbstractArgument) {
            return new TaggedValue('abstract', $value->getText());
        } elseif (\is_object($value) || \is_resource($value)) {
            throw new RuntimeException(sprintf('Unable to dump a service container if a parameter is an object or a resource, got "%s".', get_debug_type($value)));
        }

        
if (\is_array($value)) {
            $code = [];
            foreach ($value as $k => $v) {
                $code[$k] = $this->dumpValue($v);
            }

            return $code;
        } elseif ($value instanceof Reference) {
            return $this->getServiceCall((string) $value$value);
        } elseif ($value instanceof Parameter) {
            return $this->getParameterCall((string) $value);
        } elseif ($value instanceof Expression) {
            return $this->getExpressionCall((string) $value);
        } elseif ($value instanceof Definition) {
            return new TaggedValue('service', (new Parser())->parse("_:\n".$this->addService('_', $value), Yaml::PARSE_CUSTOM_TAGS)['_']['_']);
        } elseif ($value instanceof \UnitEnum) {
            return new TaggedValue('php/const', sprintf('%s::%s', $value::class$value->name));
        } elseif ($value instanceof AbstractArgument) {
            return new TaggedValue('abstract', $value->getText());
        } elseif (\is_object($value) || \is_resource($value)) {
            throw new RuntimeException(sprintf('Unable to dump a service container if a parameter is an object or a resource, got "%s".', get_debug_type($value)));
        }

        
Home | Imprint | This part of the site doesn't use cookies.