Skip to content

Latest commit

 

History

History
44 lines (33 loc) · 1.18 KB

File metadata and controls

44 lines (33 loc) · 1.18 KB

RecordRelationsWereResolved

When

After the RecordTree was built.

What

  • recordTree: The recordTree that has been built. It contains all records and all children. The child/translation relations have been resolved already.

Possibilities

This is the central event to process the recordTree before it will be displayed in the UI or published. You can:

  • Traverse the record tree to:
    • change record values
    • add/remove records
    • change relations between records
  • Get specific records from the record tree by their classifier and identifier to:
    • Recurse through the record tree to get a specific record
    • ...

... virtually anything you can imagine.

Example

use In2code\In2publishCore\Event\RecordRelationsWereResolved;

class RecordTreeCompletionListener
{
    public function __invoke(RecordRelationsWereResolved $event)
    {
        $recordTree = $event->getRecordTree();
        $page = $recordTree->getChild('pages', 1);
        if (null !== $page) {
            $foreignProperties = $page->getForeignProps();
            $foreignProperties['my_property'] = 'my_value';
            $page->setForeignProps($foreignProperties);
        }
    }
}