Extend Drupal\fluent\Collection to Support whereNotNull Method

Created on 22 October 2023, about 1 year ago
Updated 16 January 2024, 11 months ago

Integrate the whereNotNull method into the Drupal\fluent\Collection class.
Interface with ContentEntityInterface instances in the appropriate manner.
Design tests to ensure its correct operation with collections of paragraphs or nodes.

📌 Task
Status

Active

Version

10.1

Component

Code

Created by

🇲🇽Mexico dmouse Mexico City

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @dmouse
  • First commit to issue fork.
  • 🇦🇷Argentina tguerineau

    Hi,

    I've been working on the issue.
    Here's a summary of the approach and the progress made:

    Implementation Details:

    • Enhanced the filter method in Collection to differentiate between Drupal entities and non-entity items.
    • Added a processEntityFields method to simplify entity fields for consistent handling by the filter method's callback.
    • The whereNotNull method utilizes this updated filter method to check for non-null values in both entities and non-entity items, making it versatile across various types of collections.

    Manual testing that I made (using Devel module):

    • Conducted tests with collections of nodes, ensuring that whereNotNull works as expected, particularly for fields within nodes.
    • Verified the functionality with non-entity items to ensure broad applicability.
    • Tests included various scenarios, including fields with simple values and more complex structures like paragraphs.
    • All tests indicate that the method behaves correctly, filtering items based on the presence of non-null field values.

    I am in the process of designing and implementing tests that will be added to ensure the correct operation of the whereNotNull method with collections of paragraphs or nodes, as per the issue description.

    I look forward to your feedback.

  • 🇦🇷Argentina tguerineau

    Hi,

    I wanted to provide an update on the Merge Request. Based on further review and considerations regarding performance, I have updated the Merge Request with a new approach that enhances performance.

    Here's a summary of the revised implementation:
    1. Revised Approach: The previous implementation involved enhancing the `filter` method and adding a `processEntityFields` method to handle both Drupal entities and non-entity items. However, this approach, while functional, had potential performance implications, especially when dealing with large collections or complex entities.
    2. New Implementation: The new whereNotNull method has been streamlined to directly check the existence and non-nullity of the specified field in the collection items.

Production build 0.71.5 2024