Commit 8c196576 authored by spokje's avatar spokje Committed by renatog
Browse files

Issue #3220398 by Spokje, RenatoG: Fix Coding Standard Messages

parent 8d86b44d
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -6,11 +6,11 @@
 */

use Drupal\auto_entitylabel\AutoEntityLabelManager;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Url;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;

/**
 * Implements hook_help().
@@ -21,9 +21,14 @@ function auto_entitylabel_help($route_name, RouteMatchInterface $route_match) {
      $output = '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('This is a small and efficient module that allows hiding of entity label fields. To prevent empty labels it can be configured to generate the label automatically by a given pattern. The module can be used for any entity type that has a label, including e.g. for node titles, comment subjects, taxonomy term names and profile2 labels.') . '</p>';
      $output .= '<p>' . t('Patterns for automatic labels are constructed with the help of tokens. Drupal core provides a basic set of <a href="@url_tokens" target="blank">tokens</a>. For a token selection widget install the token. Some entity types (e.g. profile2) provide tokens via the entity_token, which is part of the entity module.', ['@url_tokens' => 'https://www.drupal.org/project/token']) . '</p>';
      $output .= '<p>' . t('Watch the <a href="@url_daily_dose_of_drupal" target="blank">Daily Dose of Drupal</a> screencast by <a href="@url_shane_thomas" target="blank">Shane Thomas</a> for a short introduction and demonstration of the module and some of its features. Demonstration made in D7 but can help a lot.', ['@url_daily_dose_of_drupal' => 'http://codekarate.com/daily-dose-of-drupal/drupal-7-automatic-entity-label-module', '@url_shane_thomas' => 'https://www.drupal.org/user/506260']) . '</p>';
      $output .= '<p>' . t('Watch the <a href="@url_daily_dose_of_drupal" target="blank">Daily Dose of Drupal</a> screencast by <a href="@url_shane_thomas" target="blank">Shane Thomas</a> for a short introduction and demonstration of the module and some of its features. Demonstration made in D7 but can help a lot.',
          [
            '@url_daily_dose_of_drupal' => 'http://codekarate.com/daily-dose-of-drupal/drupal-7-automatic-entity-label-module',
            '@url_shane_thomas' => 'https://www.drupal.org/user/506260',
          ]) . '</p>';
      $output .= '<h3>' . t('Usage') . '</h3>';
      $output .= '<p>' . t('The configuration can be accessed with the <i>Manage automatic entity labels</i> operation or the <i>Automatic label</i> tab when editing entity types. For example, when configuring a node type, visit <i>Administration</i> » <i>Structure</i> » <i>Content types</i> (/admin/structure/types). You can also configure automatic labels for other entity types such as <i>Media<i>, in which case you would visit <i>Administration</i> » <i>Structure</i> » <i>Media</i> (/admin/structure/media).') . '</p>';

      return $output;
  }
}
@@ -89,6 +94,7 @@ function auto_entitylabel_inline_entity_label_callback($entity, $variables) {
    }

  }

  return $autolabel;
}

@@ -209,7 +215,8 @@ function auto_entitylabel_entity_operation(EntityInterface $entity) {
  $entity_type_id = $entity_type->id();
  $entity_id = $entity->id();
  if ($entity->hasLinkTemplate('auto-label') &&
    \Drupal::currentUser()->hasPermission('administer ' . $entity_type_id . ' labels')) {
    \Drupal::currentUser()
      ->hasPermission('administer ' . $entity_type_id . ' labels')) {

    $operations['auto-label'] = [
      'title' => t('Manage automatic entity labels'),
+34 −5
Original line number Diff line number Diff line
@@ -4,16 +4,16 @@ namespace Drupal\auto_entitylabel\Form;

use Drupal\auto_entitylabel\AutoEntityLabelManager;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Class AutoEntityLabelForm.
 * Administrative form to enable/configure auto_entitylabel on an entity type.
 */
class AutoEntityLabelForm extends ConfigFormBase {

@@ -284,7 +284,15 @@ class AutoEntityLabelForm extends ConfigFormBase {
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $config = $this->configFactory->getEditable($this->getConfigName());
    $form_state->cleanValues();
    foreach (['status', 'pattern', 'escape', 'preserve_titles', 'save', 'chunk'] as $key) {
    foreach (
      [
        'status',
        'pattern',
        'escape',
        'preserve_titles',
        'save',
        'chunk',
      ] as $key) {
      $config->set($key, $form_state->getValue($key));
    }

@@ -305,6 +313,16 @@ class AutoEntityLabelForm extends ConfigFormBase {
    parent::submitForm($form, $form_state);
  }

  /**
   * Prepares a batch for resaving all labels.
   *
   * @param string $entity_type
   *   The entity type.
   * @param string|null $bundle
   *   The bundle.
   * @param int $chunk
   *   The chunk to handle in the batch.
   */
  protected function setBatch($entity_type, $bundle, $chunk) {
    $ids = $this->getIds($entity_type, $bundle);
    $chunks = array_chunk($ids, $chunk);
@@ -323,12 +341,23 @@ class AutoEntityLabelForm extends ConfigFormBase {
      'title' => $this->t('Re-saving labels'),
      'progress_message' => $this->t('Completed @current out of @total chunks.'),
      'finished' => '\Drupal\auto_entitylabel\Batch\ResaveBatch::batchFinished',
      'operations' => $operations
      'operations' => $operations,
    ];

    batch_set($batch);
  }

  /**
   * Get the IDs for for an entity type.
   *
   * @param string $entity_type
   *   The entity type to get the IDs for.
   * @param string|null $bundle
   *   The bundle to get the IDs for.
   *
   * @return array
   *   An array with IDs.
   */
  public function getIds($entity_type, $bundle) {
    $query = $this->entityTypeManager->getStorage($bundle)->getQuery();
    switch ($bundle) {
+2 −2

File changed.

Contains only whitespace changes.