diff --git a/src/Plugin/Derivative/FieldBlock.php b/src/Plugin/Derivative/FieldBlock.php index a2e52d2874194a3436d266956d8fac46875af528..1fe32bd74222c28cee18b6f6ba7b4ed62141a42d 100644 --- a/src/Plugin/Derivative/FieldBlock.php +++ b/src/Plugin/Derivative/FieldBlock.php @@ -9,17 +9,30 @@ namespace Drupal\fieldblock\Plugin\Derivative; use Drupal\Component\Plugin\Derivative\DeriverBase; use Drupal\Core\Entity\Entity\EntityViewDisplay; +use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides block plugin definitions for fieldblock blocks. * * @see \Drupal\fieldblock\Plugin\Block\FieldBlock */ -class FieldBlock extends DeriverBase { +class FieldBlock extends DeriverBase implements ContainerDeriverInterface { use StringTranslationTrait; + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, $base_plugin_id) { + $foo = 'bar'; + return new static( + $base_plugin_id, + $container->get('string_translation') + ); + } + /** * {@inheritdoc} */ @@ -55,7 +68,7 @@ class FieldBlock extends DeriverBase { foreach ($view_display_fieldblocks as $field_name => $field_label) { $fieldblock_id = $display_id . ':' . $field_name; - $fieldblocks[$fieldblock_id] = t('@field field (from @type: @bundle: @mode)', array( + $fieldblocks[$fieldblock_id] = $this->t('@field field (from @type: @bundle: @mode)', array( '@field' => $field_label, '@type' => $entity_type, '@bundle' => $bundle,