Comments

bojanz created an issue. See original summary.

czigor’s picture

Status: Active » Needs review
StatusFileSize
new2.99 KB

Not sure what the rule is here, but since "keep purchased" is not an adjective (like "public"), i went with getKeepPurchased() instead of isKeepPurchased().

czigor’s picture

Status: Needs review » Needs work

Update hook missing.

czigor’s picture

Status: Needs work » Needs review
StatusFileSize
new4.41 KB
bojanz’s picture

Status: Needs review » Needs work

There is a wishlist kernel test that we need to extend.

+    $fields['is_public'] = BaseFieldDefinition::create('boolean')
+      ->setLabel(t('Public'))
+      ->setDescription(t('A boolean indicating whether the wishlist is public.'));
+
+    $fields['keep_purchased'] = BaseFieldDefinition::create('boolean')
+      ->setLabel(t('Keep after purchased'))
+      ->setDescription(t('A boolean indicating whether an item should remain in the wishlist once purchased.'));

"Keep after purchased" should be "Keep after purchase".
"A boolean indicating" is too technical, replace with "Indicates"

czigor’s picture

Status: Needs work » Needs review
StatusFileSize
new4.36 KB

Done.

bojanz’s picture

Status: Needs review » Needs work

I don't see the extended wishlist kernel test in #6.

@@ -31,3 +32,22 @@ function commerce_wishlist_update_8301() {
   $definition_update_manager->updateEntityType($entity_type);
   $definition_update_manager->updateFieldStorageDefinition($uid_storage_definition);
 }
+
+/**
+ * Add the 'is_public' and 'keep_purchased' fields.
+ */
+function commerce_wishlist_update_8302() {
+  $storage_definition = BaseFieldDefinition::create('boolean')
+    ->setLabel(t('Public'))
+    ->setDescription(t('A boolean indicating whether the wishlist is public.'));
+
+  $update_manager = \Drupal::entityDefinitionUpdateManager();
+  $update_manager->installFieldStorageDefinition('is_public', 'commerce_wishlist_item', 'commerce_wishlist', $storage_definition);
+
+  $storage_definition = BaseFieldDefinition::create('boolean')
+    ->setLabel(t('Keep after purchased'))
+    ->setDescription(t('A boolean indicating whether an item should remain in the wishlist once purchased.'));
+
+  $update_manager = \Drupal::entityDefinitionUpdateManager();
+  $update_manager->installFieldStorageDefinition('keep_purchased', 'commerce_wishlist_item', 'commerce_wishlist', $storage_definition);
+}

The definitions weren't updated like the base field definitions were (Keep after purchased -> Keep after purchase, the descriptions).
$update_manager is inconsistent with previous update functions ($definition_update_manager).

+  /**
+   * Returns the wishlist "keep after purchased" status indicator.
+   *
+   * @return bool
+   *   TRUE if the items are kept in the wishlist after they are purchased,
+   *   FALSE otherwise.
+   */
+  public function getKeepPurchased();

Returns should be Gets, the verb should match the one in the method name.
I propose "Gets whether items should be kept in the wishlist after puchase."

czigor’s picture

Status: Needs work » Needs review
StatusFileSize
new5.4 KB

Added the test and fixed the above.

czigor’s picture

StatusFileSize
new5.39 KB

Fix typo.

The last submitted patch, 8: commerce_wishlist-3025024-wishlist_booleans-8.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 9: commerce_wishlist-3025024-wishlist_booleans-9.patch, failed testing. View results

czigor’s picture

Status: Needs work » Needs review
StatusFileSize
new5.21 KB
bojanz’s picture

Status: Needs review » Needs work

Almost there.

+    $this->set('keep_purchased', $keep_purchased ? TRUE : FALSE);

It's odd to see a ternary here. Feels unclean. (bool) $keep_purchased was a better option.

+  /**
+   * Returns the wishlist public status indicator.
+   *
+   * @return bool
+   *   TRUE if the wishlist is public, FALSE otherwise.
+   */
+  public function isPublic();

Same feedback from #7 applies to this method. You want "Gets whether the wishlist is public."

czigor’s picture

Status: Needs work » Needs review
StatusFileSize
new4 KB
new5.27 KB

Fixed. Also renamed the field name from keep_purchased to keep_after_purchase.

bojanz’s picture

Title: Add is_public and keep_purchased booleans to the Wishlist entity » Add is_public and keep_purchased_items booleans to the Wishlist entity

We bikeshedded the naming a bit. Updating.

  • bojanz committed f1fc5fb on 8.x-3.x authored by czigor
    Issue #3025024 by czigor, bojanz: Add is_public and keep_purchased_items...
bojanz’s picture

Status: Needs review » Fixed

Forgot to push this. Up now.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.