This project is not covered by Drupal’s security advisory policy.
Introduction
- Unified and centralised helper to recursively traverse an aggregate. Have a nested array of the traversal output as a transformation of the root level aggregate.
- Each aggregate is responsible how it exposes his elements. There are traversal events that are fired from the recursive aggregate iterator trait (for use in the extended SPL recursive iterators).
- Filter to match for « array parents » based subset with wild card capability like « starts with », « ends with », « contains » and « all »
- Implementation for « object to array » transformation with unlimited depth. Sub module for display it that uses the Krumo library and has a copy of the javascript code from the Drupal 7 Search Krumo module.
Documentation
Base aggregate implementaiton
Get an ouput of the recursively traversed elements as nested array.
- Each child aggregate is responsible to define how it is traversable (how it exposes his elements). That said, the traversed nested output can be seen as a transformation of the root level aggregate. It is a read only \ArrayAcces because the focus is on the traversal and on the output as a transform. Traversed elements must remain unchanged
- Store « all levels » traversed information (context attribute) like traversed path (array_parents key), traversed depth, traversed objects. For that the child aggregate context attribute uses the reference to the parent one (passed by reference).
- Store « by level » traversed information (cache attribute)
- The parent nested output (cacheNested attribute) is set (for the current index) just before go back (all elements in the child aggregate have been traversed)
- Have options attribute to change the aggregate behavior (depth limit, iterator class, prefixes for private/protected/public attributes of the casted object)
Recursive aggregate iterator trait implementation
Use for aggregate traversal when extending the SPL recursive iterators.
- Fires traversing events when:
- « before going down » (just before the next level)
- « being down » (into the next level as a new aggregate instance)
- « before going up » (just before go back to the previous level)
- « current » value being traversed (leaf or not)
- « leaf » value being traversed
- Currently used to extend the RecursiveArrayIterator and RecursiveFilterIterator.
- Following the same way it can be used for extending RecursiveRegexIterator, RecursiveCallbackIterator, …
Filtering helpers in the AggregateFilter static class
For performance uses string related functions instead of regex ones.
- The « * » wild card for matches like « starts with », « ends with », « contains », « all »
- Match for a Drupal namesspace group : available groups : « __core__ », « __contrib__ », « __custom__ », « __module__ ». Can be also used for wild card match against the module part of a Drupal namespace - « __block*__ » will output all of the following classes : Drupal\block\*, Drupal\block_content\*, Drupal\block_custom_module\*
- Match for « array parents » based subset. Ex. get « only custom » plugin classes or derivers :
'\*services/plugin.manager.*/\*definitions' => ['*class' => '__custom__', '*deriver' => '__custom__']- « And » conjunction between parents : \*services, plugin.manager.*, \*definitions
- « Or » conjunction between siblings : *class, *deriver
Extended Aggregate implementations
- AggregateObject : traverses objects by casting them to array « (array)$object ». This is an « object to array » transformation with unlimited depth. To avoid an infinite loop for object in multiple places, the last ones are replaced with a reference (as traversed path) to « the first time met » one.
- AggregateEntity (/loopit/entity/classes) : traverses drupal entities definitions to output all their handlers
- AggregateService (/loopit/service/classes) : traverses drupal services definitions to output them with their direct and reverse reference classes and services
- AggregatePlugin (/loopit/plugin/classes) : traverses drupal plugins definitions to output all their handlers as well as to point out the shared ones.
- Extract custom method overrides (drush « method-overrides » command) of core and contrib modules in perpose to be compared with the parent methods. Can be usefull for « no regression » check of the extended classes on each core or contrib code changes. Uses the previous AggregateEntity, AggregateService, AggregatePlugin with the « __custom__ » pattern parameter
- « onCurrent » callbacks are used for filtering (See AggregateFilter > Match « array parents » based subset) or for value adaptation (ex. unserialize not loaded services)
- « onLeaf » callbacks are used to get the transform more readable and more usefull (the traversed output)
- The « transform » method (called in « onDown ») is used for the « object to array » cast in AggregateObject
Loopit Krumo sub module
Sub module for lightweight dumper of array with unlimited depth
- Uses the Krumo library.
composer require kktsvetkov/krumo- Patch for backtrace info from devel dumper context
"extra": { "patches" : { "kktsvetkov/krumo" : { "Backtrace info from devel dumper context": "web/modules/contrib/loopit/dumpers/loopit_krumo/class.krumo.php.backtrace.patch" } } }
- Has a copy of the javascript code from the Drupal 7 module Search Krumo
Project information
Seeking new maintainer
The current maintainers are looking for new people to take ownership.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Developer tools
- Created by alexandre.todorov on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.