MetaModels\DcGeneral\Events\MetaModel\PropertyOptionsProvider::getPropertyOptions PHP Method

getPropertyOptions() public static method

Retrieve the property options.
public static getPropertyOptions ( ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent $event ) : void
$event ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent The event.
return void
    public static function getPropertyOptions(GetPropertyOptionsEvent $event)
    {
        if (null !== $event->getOptions()) {
            return;
        }
        $model = $event->getModel();
        if (!$model instanceof Model) {
            return;
        }
        $attribute = $model->getItem()->getAttribute($event->getPropertyName());
        if (!$attribute instanceof IAttribute) {
            return;
        }
        try {
            $options = $attribute->getFilterOptions(null, false);
        } catch (\Exception $exception) {
            $options = array('Error: ' . $exception->getMessage());
        }
        $event->setOptions($options);
    }
PropertyOptionsProvider