- Status changed to Needs work
about 2 years ago 10:51am 4 March 2023 - 🇮🇹Italy apaderno Brescia, 🇮🇹
- 'name' => $map['versions'][$id], - 'document_name' => $document_version->bundle(), - 'label' => $document_version->label(), - 'acceptance_label' => $document_version->get('acceptance_label'), - 'created' => $document_version->get('created'), - 'changed' => $document_version->get('changed'), + 'name' => $map['versions'][$id], + 'document_name' => $document_version->bundle(), + 'label' => $document_version->label(), + 'acceptance_label' => $document_version->get('acceptance_label'), + 'created' => $document_version->get('created'), + 'changed' => $document_version->get('changed'),
- $entity_manager->getStorage(ENTITY_LEGAL_DOCUMENT_ACCEPTANCE_ENTITY_NAME) + $entity_manager->getStorage(EntityLegalInterface::ENTITY_LEGAL_DOCUMENT_ACCEPTANCE_ENTITY_NAME) ->create([ - 'aid' => $document_acceptance->id(), + 'aid' => $document_acceptance->id(), 'document_version_name' => $map['versions'][$map['acceptances'][$id]], - 'uid' => $document_acceptance->get('uid'), - 'acceptance_date' => $document_acceptance->get('acceptance_date'), - 'data' => isset($document_acceptance->getFields()['data']) ? $document_acceptance->get('data') : '', + 'uid' => $document_acceptance->get('uid'), + 'acceptance_date' => $document_acceptance->get('acceptance_date'), + 'data' => isset($document_acceptance->getFields()['data']) ? $document_acceptance->get('data') : '', ])->save();
The code was already correctly formatted.
- -/** - * Cleanup sensitive data. - */ -function entity_legal_update_9001(array &$sandbox = NULL) { - $storage = \Drupal::entityTypeManager()->getStorage('entity_legal_document_acceptance'); - if (!isset($sandbox['ids'])) { - $sandbox['ids'] = array_keys($storage->getQuery()->execute()); - $sandbox['total'] = count($sandbox['ids']); - $sandbox['current'] = 0; - } - - $ids_to_process = array_splice($sandbox['ids'], 0, 50); - $sandbox['current'] += count($ids_to_process); - /** @var \Drupal\entity_legal\EntityLegalDocumentAcceptanceInterface $entity */ - foreach ($storage->loadMultiple($ids_to_process) as $entity) { - $entity->set('data', serialize([]))->save(); - } - - $sandbox['#finished'] = (int) empty($sandbox['ids']); - - return t('Processed @current out of @total', [ - '@current' => $sandbox['current'], - '@total' => $sandbox['total'], - ]); -}
Removing a hook is not what the Drupal coding standards say to do. If that hook is a problem, a new issue needs to be opened for that. On drupal.org, issues are created with a single purpose, not to fix everything wrong in a module.
+ /** + * The Messenger service. + * + * @var \Drupal\Core\Messenger\MessengerInterface + */ + protected $messenger;
Messenger should be written messenger, since it is not at the beginning of a sentence.
- \Drupal::messenger()->addMessage('You are viewing an unpublished version of this legal document.', 'warning'); + $this->messenger->addMessage('You are viewing an unpublished version of this legal document.', 'warning');
The string passed to
addMessage()
needs to be translatable. Yes, that is the same error done by the existing code, but since the code is being changed, that should be changed too.- $published_version = $storage->load($id); - $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); - - if ($published_version->hasTranslation($current_langcode)) { - $published_version = $published_version->getTranslation($current_langcode); - } - - return $published_version; + return $storage->load($id);
Is there any reason that code is removed? Is that a coding standards issue?
- * Class EntityLegalSubscriber. + * Class of EntityLegalSubscriber.
A documentation comment for a class needs to describe what the class purpose is. Adding of does not make the comment better (and Class of EntityLegalSubscriber does not make sense).
+ /** + * EntityLegalSubscriber constructor. + * + * @param \Drupal\entity_legal\EntityLegalPluginManager $entityLegalPluginManager + * EntityLegalPluginManager service. + */ + public function __construct(EntityLegalPluginManager $entityLegalPluginManager) { + $this->entityLegalPluginManager = $entityLegalPluginManager; + }
The class name must include its namespace.
/** * Builds a new form instance. * * @param \Drupal\Core\TempStore\PrivateTempStoreFactory $private_temp_store_factory * The private temp store factory service. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager + * The entityTypeManager service. */
Constructor documentation comments always say which class is constructed.
- Status changed to Needs review
almost 2 years ago 12:49pm 23 May 2023 - last update
almost 2 years ago Build Successful - @claudiucristea opened merge request.
- last update
almost 2 years ago Build Successful - last update
almost 2 years ago Build Successful - last update
almost 2 years ago Build Successful - last update
almost 2 years ago 14 pass, 2 fail - last update
almost 2 years ago 18 pass - last update
almost 2 years ago 18 pass -
claudiu.cristea →
committed 6628c93e on 4.0.x
Issue #3182161 by claudiu.cristea, imustakim, timotej-pl, mariaisp,...
-
claudiu.cristea →
committed 6628c93e on 4.0.x
- Status changed to Fixed
almost 2 years ago 2:29pm 23 May 2023 Automatically closed - issue fixed for 2 weeks with no activity.