src/Contao/Subscriber/DynamicParentTableSubscriber.php
public function handlePrePersistModelEvent(PrePersistModelEvent $event)
    {
        $enviroment     = $event->getEnvironment();
        $dataDefinition = $enviroment->getDataDefinition();

        if (null === ($parentDataDefinition = $enviroment->getParentDataDefinition())
            || (false === $dataDefinition->getPropertiesDefinition()->hasProperty('ptable'))
            || (false === $dataDefinition->getBasicDefinition()->isDynamicParentTable())
        ) {
            return;
        }

        $model = $event->getModel();

        $model->setProperty('ptable', $parentDataDefinition->getName());
    }
public function handlePrePersistModelEvent(PrePersistModelEvent $event)
    {
        $enviroment     = $event->getEnvironment();
        $dataDefinition = $enviroment->getDataDefinition();

        if (null === ($parentDataDefinition = $enviroment->getParentDataDefinition())
            || (false === $dataDefinition->getPropertiesDefinition()->hasProperty('ptable'))
            || (false === $dataDefinition->getBasicDefinition()->isDynamicParentTable())
        ) {
            return;
        }

        $model = $event->getModel();

        $model->setProperty('ptable', $parentDataDefinition->getName());
    }
public function handlePrePersistModelEvent ( PrePersistModelEvent $ event ) { $ enviroment = $ event -> getEnvironment ( ) ; $ dataDefinition = $ enviroment -> getDataDefinition ( ) ; if ( null === ( $ parentDataDefinition = $ enviroment -> getParentDataDefinition ( ) ) || ( false === $ dataDefinition -> getPropertiesDefinition ( ) -> hasProperty ( 'ptable' ) ) || ( false === $ dataDefinition -> getBasicDefinition ( ) -> isDynamicParentTable ( ) ) ) { return ; } $ model = $ event -> getModel ( ) ; $ model -> setProperty ( 'ptable' , $ parentDataDefinition -> getName ( ) ) ; }
Handle the pre persist model event.

@param PrePersistModelEvent $event The event to handle.

@return void
Handle the pre persist model event .