getPrivateServiceCall example

      $private_definition = [
        'class' => '\stdClass',
        'public' => FALSE,
        'arguments_count' => 0,
      ];

      $service_definitions[] = [
        'arguments' => ['foo', new Reference('private_definition')],
        'arguments_count' => 2,
        'arguments_expected' => static::getCollection([
          'foo',
          static::getPrivateServiceCall('private_definition', $private_definition, TRUE),
        ]),
      ] + $base_service_definition;

      // Test a private non-shared service, denoted by having a Definition.       $private_definition_object = new Definition('\stdClass');
      $private_definition_object->setPublic(FALSE);

      $service_definitions[] = [
        'arguments' => ['foo', $private_definition_object],
        'arguments_count' => 2,
        'arguments_expected' => static::getCollection([
          
$code = [];
      foreach ($value as $k => $v) {
        $code[$k] = $this->dumpValue($v);
      }

      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]);
        };
'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
      'arguments' => $this->getCollection([
        $this->getServiceCall('other.service'),
        $this->getParameterCall('some_private_config'),
      ]),
      'public' => FALSE,
    ];

    $services['service_using_private'] = [
      'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
      'arguments' => $this->getCollection([
        $this->getPrivateServiceCall(NULL, $private_service),
        $this->getParameterCall('some_config'),
      ]),
    ];
    $services['another_service_using_private'] = [
      'class' => '\Drupal\Tests\Component\DependencyInjection\MockService',
      'arguments' => $this->getCollection([
        $this->getPrivateServiceCall(NULL, $private_service),
        $this->getParameterCall('some_config'),
      ]),
    ];

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