Commit d237c6de authored by marcvangend's avatar marcvangend

wip - try to inject string translation into deriver class

parent ed729ba4
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment