FieldTypePluginManager example

    [$module_name$module_dir] = $this->getModuleAndPath();

    $namespaces = new \ArrayObject();
    $namespaces["Drupal\\$module_name"] = $module_dir . '/src';

    $module_handler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
    $module_handler->expects($this->once())
      ->method('moduleExists')
      ->with($module_name)
      ->willReturn(TRUE);
    $typed_data_manager = $this->createMock(TypedDataManagerInterface::class);
    $plugin_manager = new FieldTypePluginManager(
      $namespaces,
      $this->createMock('Drupal\Core\Cache\CacheBackendInterface'),
      $module_handler,
      $typed_data_manager
    );

    $container = new ContainerBuilder();
    $container->set('plugin.manager.field.field_type', $plugin_manager);
    // The 'string_translation' service is used by the @Translation annotation.     $container->set('string_translation', $this->getStringTranslationStub());
    \Drupal::setContainer($container);

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