Skip to content
Snippets Groups Projects

3332255: resolve more phpcs issues

Open Kunal Gautam requested to merge issue/autotagger-3332255:phpcs-3332255 into 1.0.x
5 files
+ 66
23
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -6,6 +6,7 @@ use Drupal\autotagger\AutotaggerPluginBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeInterface;
use Drupal\node\Entity\NodeType;
use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Plugin implementation of the autotagger.
@@ -19,6 +20,8 @@ use Drupal\node\Entity\NodeType;
*/
class SearchInTextFields extends AutotaggerPluginBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
@@ -61,13 +64,14 @@ class SearchInTextFields extends AutotaggerPluginBase {
}
// Text fields on node or media references can be used as a source.
if ($field_type == 'entity_reference' && (in_array($field->getSettings()['target_type'], ['node', 'media']))) {
$source_fields[$field->getName()] = t('Text fields on entities referenced by @label', ['@label' => $field->getLabel()])->render();
$target_types = ['node', 'media'];
if ($field_type == 'entity_reference' && (in_array($field->getSettings()['target_type'], $target_types))) {
$source_fields[$field->getName()] = $this->t('Text fields on entities referenced by @label', ['@label' => $field->getLabel()])->render();
}
// Text fields on paragraphs can be used as a source.
if ($field_type == 'entity_reference_revisions') {
$source_fields[$field->getName()] = t('Text fields on paragraphs referenced by @label', ['@label' => $field->getLabel()])->render();
$source_fields[$field->getName()] = $this->t('Text fields on paragraphs referenced by @label', ['@label' => $field->getLabel()])->render();
}
// Taxonomy references can be used as a destination.
@@ -78,8 +82,8 @@ class SearchInTextFields extends AutotaggerPluginBase {
$form['autotagger']['autotagger_source_field'] = [
'#type' => 'checkboxes',
'#title' => t('Source fields'),
'#description' => t('Choose which fields to scan for terms. Checking an entity reference field will cause all text fields on the referenced entity to be scanned.'),
'#title' => $this->t('Source fields'),
'#description' => $this->t('Choose which fields to scan for terms. Checking an entity reference field will cause all text fields on the referenced entity to be scanned.'),
'#default_value' => $default_values['autotagger_source_field'] ?: [],
'#options' => $source_fields,
'#access' => TRUE,
@@ -87,8 +91,8 @@ class SearchInTextFields extends AutotaggerPluginBase {
$form['autotagger']['autotagger_destination_field'] = [
'#type' => 'select',
'#title' => t('Destination fields'),
'#description' => t('Choose the taxonomy reference field to use. The vocabularies enabled on this field will provide the scanned for terms.'),
'#title' => $this->t('Destination fields'),
'#description' => $this->t('Choose the taxonomy reference field to use. The vocabularies enabled on this field will provide the scanned for terms.'),
'#default_value' => $default_values['autotagger_destination_field'] ?: '',
'#options' => $destination_fields,
'#access' => TRUE,
@@ -96,16 +100,16 @@ class SearchInTextFields extends AutotaggerPluginBase {
$form['autotagger']['autotagger_tag_on_create_only'] = [
'#type' => 'checkbox',
'#title' => t('Only assign tags on initial node creation.'),
'#title' => $this->t('Only assign tags on initial node creation.'),
'#default_value' => $default_values['autotagger_tag_on_create_only'] ?: '',
'#access' => TRUE,
];
$form['autotagger']['autotagger_rebuild_on_submit'] = [
'#type' => 'checkboxes',
'#title' => t('Assign tags on save.'),
'#title' => $this->t('Assign tags on save.'),
'#default_value' => $default_values['autotagger_rebuild_on_submit'] ?: '',
'#options' => ['rebuild' => t('Rebuild on this form submission')],
'#options' => ['rebuild' => $this->t('Rebuild on this form submission')],
'#access' => TRUE,
];
@@ -137,8 +141,9 @@ class SearchInTextFields extends AutotaggerPluginBase {
'autotagger_source_field' => $form_state->getValue('autotagger_source_field'),
'autotagger_destination_field' => $form_state->getValue('autotagger_destination_field'),
'autotagger_tag_on_create_only' => $form_state->getValue('autotagger_tag_on_create_only'),
'autotagger_rebuild_on_submit' => $form_state->getValue('autotagger_rebuild_on_submit')
'autotagger_rebuild_on_submit' => $form_state->getValue('autotagger_rebuild_on_submit'),
];
$node_type->setThirdPartySetting('autotagger', 'search_in_text_fields', $autotagger);
}
}
Loading