src/EventListener/DcGeneral/Table/FilterSetting/GetPropertyOptionsListener.php
public function handle(GetPropertyOptionsEvent $event)
    {
        $isAllowed = $this->isAllowedContext(
            $event->getEnvironment()->getDataDefinition(),
            $event->getPropertyName(),
            $event->getModel()
        );

        if (!$isAllowed) {
            return;
        }

        $result = [];
        $model  = $event->getModel();

        $metaModel   = $this->getMetaModel($model);
        $typeFactory = $this->filterSettingFactory->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, true))) {
                continue;
            }

            $strSelectVal          = $metaModel->getTableName().'_'.$attribute->getColName();
            $result[$strSelectVal] = $attribute->getName().' ['.$typeName.']';
        }

        $event->setOptions($result);
    }
public function handle(GetPropertyOptionsEvent $event)
    {
        $isAllowed = $this->isAllowedContext(
            $event->getEnvironment()->getDataDefinition(),
            $event->getPropertyName(),
            $event->getModel()
        );

        if (!$isAllowed) {
            return;
        }

        $result = [];
        $model  = $event->getModel();

        $metaModel   = $this->getMetaModel($model);
        $typeFactory = $this->filterSettingFactory->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, true))) {
                continue;
            }

            $strSelectVal          = $metaModel->getTableName().'_'.$attribute->getColName();
            $result[$strSelectVal] = $attribute->getName().' ['.$typeName.']';
        }

        $event->setOptions($result);
    }
public function handle ( GetPropertyOptionsEvent $ event ) { $ isAllowed = $ this -> isAllowedContext ( $ event -> getEnvironment ( ) -> getDataDefinition ( ) , $ event -> getPropertyName ( ) , $ event -> getModel ( ) ) ; if ( ! $ isAllowed ) { return ; } $ result = [ ] ; $ model = $ event -> getModel ( ) ; $ metaModel = $ this -> getMetaModel ( $ model ) ; $ typeFactory = $ this -> filterSettingFactory -> 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 , true ) ) ) { continue ; } $ strSelectVal = $ metaModel -> getTableName ( ) . '_' . $ attribute -> getColName ( ) ; $ result [ $ strSelectVal ] = $ attribute -> getName ( ) . ' [' . $ typeName . ']' ; } $ event -> setOptions ( $ result ) ; }
Prepares a option list with alias => name connection for all attributes.

This is used in the attr_id select box.

@param GetPropertyOptionsEvent $event The event.

@return void

@throws \RuntimeException When the MetaModel can not be determined.
Prepares a option list with alias = > name connection for all attributes .