Skip to content

Latest commit

 

History

History
126 lines (100 loc) · 4.9 KB

File metadata and controls

126 lines (100 loc) · 4.9 KB

BumbleDocGen / Technical description of the project / Parser / Entities and entities collections


Entities and entities collections

Entities are organized outcomes from parsing source code. They help easily extract details about specific items from templates, allowing users to quickly access and display the information they need.

Entities are always handled through collections. Collections are the result of the project parsing process and are available in both documentation templates and code.

Examples of using collections in twig templates

  • Passing a collection to a function:
 {{ printEntityCollectionAsList(phpClassEntityCollection) }}
  • Filtering a collection and passing it to a function:
 {{ printEntityCollectionAsList(phpClassEntityCollection.filterByInterfaces(['BumbleDocGen\Core\Parser\Entity\EntityInterface'])) }}
  • Saving a filtered collection to a variable:
 {{ {% set filteredCollection = phpClassEntityCollection.getOnlyInstantiable() %} }}
  • Using a collection in a for loop:
 {% for someClassEntity in phpClassEntityCollection %}
     * {{ someClassEntity.getName() }}
 {% endfor %}
  • Output of all methods of all found entities in className::methodName() format:
 {% for someClassEntity in phpClassEntityCollection %}
     {% for methodEntity in someClassEntity.getMethodEntityCollection() %}
         * {{ someClassEntity.getName() }}::{{ methodEntity.getName() }}()
     {% endfor %}
 {% endfor %}

Root entities collections

To further facilitate the handling of these entities, we utilize entity collections. These collections not only group relevant entities together but also provide convenient methods for filtering and manipulating these entities. The root collections (RootEntityCollection), which are directly accessible in your templates, are as follows:

Collection class Name in twig template PL Description
ClassEntityCollection phpClassEntityCollection PHP Collection of PHP class entities

Available entities

Following is the list of available entities that are consistent with EntityInterface and can be created. These classes are a convenient wrapper for accessing data in templates:

Entity name Collection name Is root PL Description
ClassEntity ClassEntityCollection yes PHP Class entity
ConstantEntity ConstantEntityCollection no PHP Class constant entity
DynamicMethodEntity MethodEntityCollection no PHP Method obtained by parsing the "method" annotation
MethodEntity MethodEntityCollection no PHP Class method entity
PropertyEntity PropertyEntityCollection no PHP Class property entity

Last page committer: fshcherbanich <filipp.shcherbanich@team.bumble.com>
Last modified date: Sat Oct 28 11:03:31 2023 +0300
Page content update date: Mon Nov 06 2023
Made with Bumble Documentation Generator