MetaModels\DcGeneral\Events\Table\InputScreenCondition\Subscriber::getAttributeOptions PHP Метод

getAttributeOptions() публичный Метод

This is used in the attr_id select box.
public getAttributeOptions ( ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent $event ) : void
$event ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent The event.
Результат void
    public function getAttributeOptions(GetPropertyOptionsEvent $event)
    {
        if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_dcasetting_condition' || $event->getPropertyName() !== 'attr_id') {
            return;
        }
        $result = array();
        $metaModel = $this->getMetaModel($event->getEnvironment());
        $conditionType = $event->getModel()->getProperty('type');
        $allowedAttributes = $GLOBALS['METAMODELS']['inputscreen_conditions'][$conditionType]['attributes'];
        foreach ($metaModel->getAttributes() as $attribute) {
            if (is_array($allowedAttributes) && !in_array($attribute->get('type'), $allowedAttributes)) {
                continue;
            }
            $typeName = $attribute->get('type');
            $strSelectVal = $metaModel->getTableName() . '_' . $attribute->getColName();
            $result[$strSelectVal] = $attribute->getName() . ' [' . $typeName . ']';
        }
        $event->setOptions($result);
    }