MetaModels\DcGeneral\Events\Table\FilterSetting\Subscriber::getAttributeIdOptions PHP Метод

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

This is used in the attr_id select box.
public getAttributeIdOptions ( ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent $event ) : void
$event ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent The event.
Результат void
    public function getAttributeIdOptions(GetPropertyOptionsEvent $event)
    {
        if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_filtersetting' || $event->getPropertyName() !== 'attr_id') {
            return;
        }
        $result = array();
        $model = $event->getModel();
        $metaModel = $this->getMetaModel($model);
        $typeFactory = $this->getServiceContainer()->getFilterFactory()->getTypeFactory($model->getProperty('type'));
        $typeFilter = null;
        if ($typeFactory) {
            $typeFilter = $typeFactory->getKnownAttributeTypes();
        }
        foreach ($metaModel->getAttributes() as $attribute) {
            $typeName = $attribute->get('type');
            if ($typeFilter && !in_array($typeName, $typeFilter)) {
                continue;
            }
            $strSelectVal = $metaModel->getTableName() . '_' . $attribute->getColName();
            $result[$strSelectVal] = $attribute->getName() . ' [' . $typeName . ']';
        }
        $event->setOptions($result);
    }