Skip to content
Snippets Groups Projects

Fixed t() calls.

1 file
+ 15
7
Compare changes
  • Side-by-side
  • Inline
@@ -10,6 +10,8 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\user\Entity\User;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface;
/**
* Plugin implementation of the 'hide_revision_field_log_widget' widget.
@@ -23,8 +25,10 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* )
*/
class RevisionLogWidget extends StringTextareaWidget implements ContainerFactoryPluginInterface {
use StringTranslationTrait;
protected $user;
protected $entityManager;
/**
* Create the widget instance.
@@ -48,7 +52,8 @@ class RevisionLogWidget extends StringTextareaWidget implements ContainerFactory
$configuration['field_definition'],
$configuration['settings'],
$configuration['third_party_settings'],
$container->get('current_user')
$container->get('current_user'),
$container->get('entity_type.manager')
);
}
@@ -67,10 +72,13 @@ class RevisionLogWidget extends StringTextareaWidget implements ContainerFactory
* Any third party settings.
* @param \Drupal\Core\Session\AccountProxyInterface $user
* The current user.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, AccountProxyInterface $user) {
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, AccountProxyInterface $user, EntityTypeManagerInterface $entityTypeManager) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
$this->user = $user;
$this->entityManager = $entityTypeManager;
}
/**
@@ -93,19 +101,19 @@ class RevisionLogWidget extends StringTextareaWidget implements ContainerFactory
$settings = $this->getSettings();
$element['show'] = [
'#type' => 'checkbox',
'#title' => t('Show'),
'#title' => $this->t('Show'),
'#default_value' => $settings['show'],
'#description' => $this->t('Show field by default.'),
];
$element['allow_user_settings'] = [
'#type' => 'checkbox',
'#title' => t('Allow user specific configuration.'),
'#title' => $this->t('Allow user specific configuration.'),
'#default_value' => $settings['allow_user_settings'],
'#description' => $this->t('Allow users to configure their own default value/display of the revision log field on their profile pages.'),
];
$element['permission_based'] = [
'#type' => 'checkbox',
'#title' => t('Display Based on Permissions'),
'#title' => $this->t('Display Based on Permissions'),
'#default_value' => $settings['permission_based'],
'#description' => $this->t('Show field if user has permission "%perm: Customize revision logs".', [
'%perm' => $this->fieldDefinition->getTargetEntityTypeId(),
@@ -113,7 +121,7 @@ class RevisionLogWidget extends StringTextareaWidget implements ContainerFactory
];
$element['default'] = [
'#type' => 'textfield',
'#title' => t('Default'),
'#title' => $this->t('Default'),
'#default_value' => $settings['default'],
'#description' => $this->t('Default value for revision log.'),
];
@@ -195,7 +203,7 @@ class RevisionLogWidget extends StringTextareaWidget implements ContainerFactory
if (empty($form_state->get('langcode'))) {
$form_state->set('langcode', $entity->language()->getId());
}
$user = User::load($this->user->id());
$user = $this->entityManager->getStorage('user')->load($this->user->id());
$user_settings = [];
$user_settings_raw = $user->get('revision_log_settings')->value;
if ($user_settings_raw) {
Loading