Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 1.07 KB

File metadata and controls

39 lines (29 loc) · 1.07 KB

DecideIfRecordShouldBeIgnored

Replaces the \In2code\In2publishCore\Controller\ToolsController / collectSupportPlaces Signal. Replaces the event VoteIfRecordShouldBeIgnored.

When

Every time a new record which is not a PageTreeRootRecord was created.

What

  • record: The record that was just created and should be checked.

Possibilities

You can vote to ignore the record completely. The record will not be attached to the record tree. Your event listener might get asked about the same record multiple times. If an event listener call shouldIgnore no further event listener will be asked.

Example

use In2code\In2publishCore\Component\Core\Record\Model\FileRecord;
use In2code\In2publishCore\Event\DecideIfRecordShouldBeIgnored;

class RecordIgnoreListener
{
    public function __invoke(DecideIfRecordShouldBeIgnored $event)
    {
        $record = $event->getRecord();
        if (
            $record instanceof FileRecord
            && $record->getProp('file_extension') === 'bak'
        ) {
            $event->shouldIgnore();
        }
    }
}