MetaModels\DcGeneral\Events\Table\InputScreen\Subscriber::getParentTables PHP Method

getParentTables() public method

Excludes the metamodel table itself in ctable mode, as that one would be "selftree" then and not ctable.
public getParentTables ( ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent $event ) : void
$event ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent The event.
return void
    public function getParentTables(GetPropertyOptionsEvent $event)
    {
        if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_dca' || $event->getPropertyName() !== 'ptable') {
            return;
        }
        $currentTable = '';
        if ($event->getModel()->getProperty('rendertype') == 'ctable') {
            $currentTable = $this->getServiceContainer()->getFactory()->translateIdToMetaModelName($event->getModel()->getProperty('pid'));
        }
        $tables = array();
        foreach ($this->getServiceContainer()->getDatabase()->listTables() as $table) {
            if (!($currentTable && $currentTable == $table)) {
                $tables[$table] = $table;
            }
        }
        $event->setOptions($tables);
    }