Extend Fluent Collection to Support "Where" Methods for Drupal Entities

Created on 22 October 2023, about 1 year ago

Enhance the Drupal\fluent\Collection class to integrate and optimize various "where" methods for Drupal entities, primarily those implementing the ContentEntityInterface.

Background

Laravel's Collection offers multiple "where" methods that provide filtering capabilities on the collection. Our aim is to optimize these methods for Drupal entities, ensuring compatibility and efficiency with the Drupal entity system through Fluent's capabilities.

Analysis and Design:

Review the "where" methods in Laravel Collection to understand their core behavior.
Identify the specific nuances and challenges when dealing with Drupal entities.

Method Overrides:

For each "where" method, create an override in the Drupal\fluent\Collection class.
Leverage the custom logic in operatorForWhere to ensure correct handling of Drupal entities. This involves checking if an item belongs to ContentEntityInterface and fetching its values accordingly.

Unit Testing:

Draft unit tests for each newly overridden "where" method, ensuring their correct functionality with Drupal entities and standard data.
Create test cases that encompass both positive and negative outcomes.

Integration Testing:

Incorporate the overridden methods into real-world Drupal scenarios, such as filtering a collection of nodes using Fluent Collection.
Validate that the results align with expectations and that no unexpected behaviors or errors surface.

Future Considerations:

Once the "where" methods are successfully integrated, our long-term vision is to extend support for all methods present in the Laravel Collection library, broadening the capabilities of the Fluent module.

Expected Outcome:

Upon completing this task, the Drupal\fluent\Collection class should proficiently support the "where" methods, ensuring compatibility with Drupal entities. Developers can then effortlessly utilize these methods, reaping the benefits of both Laravel's collection functionality and Drupal's robust entity system.

🌱 Plan
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

Comments & Activities

Production build 0.71.5 2024