Commit 3d3581bd authored by Joshua Sedler's avatar Joshua Sedler 🤸🏼 Committed by Julian Pustkuchen
Browse files

Issue #3266906 by Grevil, mrinalini9, akshaydalvi212, urvashi_vora, Anybody:...

Issue #3266906 by Grevil, mrinalini9, akshaydalvi212, urvashi_vora, Anybody: Fix coding standard issues
parent 197ad6a1
Loading
Loading
Loading
Loading
+15 −10
Changes for homebox.install: 15 added lines, 10 removed lines.
Original line number Diff line number Diff line
<?php

use Drupal\Core\Field\BaseFieldDefinition;

/**
 * @file Update scripts for the Homebox module.
 * @file
 * Implements update scripts for the Homebox module.
 */

use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Language\LanguageInterface;

/**
 * Enable the new jQuery UI modules.
 */
@@ -37,7 +39,6 @@ function homebox_update_8101() {

    // Remove "$homebox->options" (without replacement):
    // No action needed. Save with new schema does the deletions for us.

    // Save changed configuraiton:
    $homebox->save();

@@ -48,8 +49,9 @@ function homebox_update_8101() {
}

/**
 * Remove homebox_layout basefield 'settings' with wrong type text_long and
 * replace by 'data' with correct type string_long.
 * Remove homebox_layout basefield 'settings' with wrong type text_long.
 *
 * And replace by 'data' with correct type string_long.
 */
function homebox_update_8102() {
  $entityDefUpdateManager = \Drupal::entityDefinitionUpdateManager();
@@ -69,9 +71,10 @@ function homebox_update_8102() {
    // Tranfer legacy settings. We need to access ->settings directly,
    // as the field was already changed in schema! So no more available by
    // ->get().
    if (!empty($homeboxLayout->settings[Drupal\Core\Language\LanguageInterface::LANGCODE_DEFAULT]['value'])) {
      $legacySettings = $homeboxLayout->settings[Drupal\Core\Language\LanguageInterface::LANGCODE_DEFAULT]['value'];
      // Now is a string_long field:
    if (!empty($homeboxLayout->settings[LanguageInterface::LANGCODE_DEFAULT]['value'])) {
      $legacySettings = $homeboxLayout->settings[LanguageInterface::LANGCODE_DEFAULT]['value'];

      // Now is a string_long field:sss.
      $homeboxLayout->set('data', $legacySettings);
      $homeboxLayout->save();
      $count++;
@@ -84,5 +87,7 @@ function homebox_update_8102() {
    $entityDefUpdateManager->uninstallFieldStorageDefinition($old_field_storage_definition);
  }

  return t('Updated @count of @countof homebox_layout "settings" values to "data" base field values.', ['@count' => $count, '@countof' => count($homeboxLayouts)]);
  return t('Updated @count of @countof homebox_layout "settings"
  values to "data" base field values.',
  ['@count' => $count, '@countof' => count($homeboxLayouts)]);
}
+0 −1
Changes for homebox.links.menu.yml: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -5,4 +5,3 @@ entity.homebox.collection:
  description: 'List Homebox (bundles)'
  parent: system.admin_structure
  weight: 99
+30 −7
Changes for src/Controller/HomeboxLayoutController.php: 30 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ class HomeboxLayoutController extends ControllerBase implements ContainerInjecti
    $homebox_layout = $this->entityTypeManager()->getStorage('homebox_layout')->loadRevision($homebox_layout_revision);
    return $this->t('Revision of %title from %date', [
      '%title' => $homebox_layout->label(),
      '%date' => $this->dateFormatter->format($homebox_layout->getRevisionCreationTime())
      '%date' => $this->dateFormatter->format($homebox_layout->getRevisionCreationTime()),
    ]);
  }

@@ -302,7 +302,9 @@ class HomeboxLayoutController extends ControllerBase implements ContainerInjecti
    /** @var \Drupal\homebox\HomeboxLayoutStorageInterface $homebox_layout_storage */
    $homebox_layout_storage = $this->entityTypeManager()->getStorage('homebox_layout');

    $build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $homebox_layout->label()]) : $this->t('Revisions for %title', ['%title' => $homebox_layout->label()]);
    $build['#title'] = $has_translations ? $this->t('@langname revisions for %title',
    ['@langname' => $langname, '%title' => $homebox_layout->label()]) :
    $this->t('Revisions for %title', ['%title' => $homebox_layout->label()]);
    $header = [$this->t('Revision'), $this->t('Operations')];

    $revert_permission = $account->hasPermission('administer homebox');
@@ -328,7 +330,12 @@ class HomeboxLayoutController extends ControllerBase implements ContainerInjecti
        // Use revision link to link to revisions that are not active.
        $date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
        if ($vid != $homebox_layout->getRevisionId()) {
          $link = $this->linkGenerator->generate($date, new Url('entity.homebox_layout.revision', ['homebox_layout' => $homebox_layout->id(), 'homebox_layout_revision' => $vid]));
          $link = $this->linkGenerator->generate($date,
          new Url('entity.homebox_layout.revision',
          [
            'homebox_layout' => $homebox_layout->id(),
            'homebox_layout_revision' => $vid,
          ]));
        }
        else {
          $link = $homebox_layout->toLink($date)->toString();
@@ -342,7 +349,10 @@ class HomeboxLayoutController extends ControllerBase implements ContainerInjecti
            '#context' => [
              'date' => $link,
              'username' => $this->renderer->renderPlain($username),
              'message' => ['#markup' => $revision->getRevisionLogMessage(), '#allowed_tags' => Xss::getHtmlTagList()],
              'message' => [
                '#markup' => $revision->getRevisionLogMessage(),
                '#allowed_tags' => Xss::getHtmlTagList(),
              ],
            ],
          ],
        ];
@@ -367,15 +377,28 @@ class HomeboxLayoutController extends ControllerBase implements ContainerInjecti
            $links['revert'] = [
              'title' => $this->t('Revert'),
              'url' => $has_translations ?
              Url::fromRoute('entity.homebox_layout.translation_revert', ['homebox_layout' => $homebox_layout->id(), 'homebox_layout_revision' => $vid, 'langcode' => $langcode]) :
              Url::fromRoute('entity.homebox_layout.revision_revert', ['homebox_layout' => $homebox_layout->id(), 'homebox_layout_revision' => $vid]),
              Url::fromRoute('entity.homebox_layout.translation_revert',
              [
                'homebox_layout' => $homebox_layout->id(),
                'homebox_layout_revision' => $vid,
                'langcode' => $langcode,
              ]) :
              Url::fromRoute('entity.homebox_layout.revision_revert',
              [
                'homebox_layout' => $homebox_layout->id(),
                'homebox_layout_revision' => $vid,
              ]),
            ];
          }

          if ($delete_permission) {
            $links['delete'] = [
              'title' => $this->t('Delete'),
              'url' => Url::fromRoute('entity.homebox_layout.revision_delete', ['homebox_layout' => $homebox_layout->id(), 'homebox_layout_revision' => $vid]),
              'url' => Url::fromRoute('entity.homebox_layout.revision_delete',
              [
                'homebox_layout' => $homebox_layout->id(),
                'homebox_layout_revision' => $vid,
              ]),
            ];
          }

+15 −4
Changes for src/Form/HomeboxDashboardForm.php: 15 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * Class HomeboxDashboardForm.
 * Implements HomeboxDashboardForm for dashboard form.
 *
 * @ingroup homebox
 */
@@ -81,6 +81,14 @@ abstract class HomeboxDashboardForm extends FormBase {
   *
   * @param \Symfony\Component\Serializer\Serializer $serializer
   *   Serializer service.
   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
   *   Request Stack.
   * @param \Drupal\Core\Layout\LayoutPluginManagerInterface $plugin_manager_core_layout
   *   Core Layout of Plugin Manager.
   * @param \Drupal\Core\Block\BlockManagerInterface $plugin_manager_block
   *   Plugin manager block.
   * @param \Drupal\Core\Access\CsrfTokenGenerator $csrf
   *   CSRF Token generator.
   */
  public function __construct(
    Serializer $serializer,
@@ -173,7 +181,8 @@ abstract class HomeboxDashboardForm extends FormBase {
    if (!empty($homebox_layout_id)) {
      /** @var \Drupal\Core\Entity\ContentEntityBase $homebox_layout */
      $homebox_layout = $homebox_layout_storage->load(array_shift($homebox_layout_id));
    } else {
    }
    else {
      // Create homebox layout entity for current user.
      $values = [
        'user_id' => $user->id(),
@@ -255,7 +264,8 @@ abstract class HomeboxDashboardForm extends FormBase {
      $serializer = \Drupal::service('serializer');
      $layout_blocks = $homebox_layout->get('data')->value;
      $layout_blocks = $serializer->decode($layout_blocks, 'json');
    } else {
    }
    else {
      $layout_blocks = $blocks;
    }

@@ -327,7 +337,8 @@ abstract class HomeboxDashboardForm extends FormBase {
    if (!empty($homebox_layout) && $is_layout_id && $homebox->getLayoutId() == $homebox_layout->get('layout_id')->value) {
      $blocks = $homebox_layout->get('data')->value;
      $blocks = $this->serializer->decode($blocks, 'json');
    } else {
    }
    else {
      $blocks = $blocks_available_for_adding;
    }

+1 −1
Changes for src/Form/HomeboxDashboardUserTabForm.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
namespace Drupal\homebox\Form;

/**
 * Class HomeboxDashboardUserTabForm.
 * Implements HomeboxDashboardUserTabForm for dashboard user tab form.
 *
 * @ingroup homebox
 */
Loading