/** * Retrieve the options for the attributes. * * @param GetOptionsEvent $event The event. * * @return void */ public function getOptions(GetOptionsEvent $event) { if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute' || $event->getPropertyName() !== 'combinedvalues_fields' || $event->getSubPropertyName() !== 'field_attribute') { return; } $model = $event->getModel(); $metaModel = $this->getMetaModelById($model->getProperty('pid')); if (!$metaModel) { return; } $result = array(); // Add meta fields. $result['meta'] = self::getMetaModelsSystemColumns(); // Fetch all attributes except for the current attribute. foreach ($metaModel->getAttributes() as $attribute) { if ($attribute->get('id') === $model->getId()) { continue; } $type = $event->getEnvironment()->getTranslator()->translate('typeOptions.' . $attribute->get('type'), 'tl_metamodel_attribute'); if ($type == 'typeOptions.' . $attribute->get('type')) { $type = $attribute->get('type'); } $result['attributes'][$attribute->getColName()] = sprintf('%s [%s]', $attribute->getName(), $type); } $event->setOptions($result); }
/** * @param GetOptionsEvent $event */ public function bypassCreateRecipientPropertiesOptions(GetOptionsEvent $event) { if ($event->getModel()->getProviderName() === 'orm_avisota_recipient_source' && $event->getPropertyName() != 'membersPropertyFilter' || $event->getSubPropertyName() != 'membersPropertyFilter_property') { return; } $options = $event->getOptions(); $options = $this->getRecipientPropertiesOptions($event->getEnvironment(), $options); $event->setOptions($options); }
/** * Check if the event is intended for us. * * @param GetOptionsEvent $event The event to test. * * @return bool */ private function isEventForMe(GetOptionsEvent $event) { $input = $event->getEnvironment()->getInputProvider(); if ($input->hasValue('type')) { $type = $input->getValue('type'); } if (empty($type)) { $type = $event->getModel()->getProperty('type'); } return $event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute' || $type !== 'translatedalias' || $event->getPropertyName() !== 'talias_fields' || $event->getSubPropertyName() !== 'field_attribute'; }
/** * Check if the event is intended for us. * * @param GetOptionsEvent $event The event to test. * * @return bool */ private function isEventForMe(GetOptionsEvent $event) { $input = $event->getEnvironment()->getInputProvider(); $type = $event->getModel()->getProperty('type'); if ($input->hasValue('type')) { $type = $input->getValue('type'); } if (empty($type)) { $type = $event->getModel()->getProperty('type'); } return $event->getEnvironment()->getDataDefinition()->getName() === 'tl_metamodel_attribute' && $type === 'combinedvalues' && $event->getPropertyName() === 'combinedvalues_fields' && $event->getSubPropertyName() === 'field_attribute'; }
/** * Get all options for the render settings. * * @param GetOptionsEvent $event The event. * * @return void */ public function getRenderSettingsOptions(GetOptionsEvent $event) { if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_dca_combine' || $event->getPropertyName() !== 'rows' || $event->getSubPropertyName() !== 'view_id') { return; } $inputScreens = $this->getDatabase()->prepare('SELECT id,name FROM tl_metamodel_rendersettings WHERE pid=?')->execute($event->getModel()->getProperty('id')); $result = array(); while ($inputScreens->next()) { $result[$inputScreens->id] = $inputScreens->name; } $event->setOptions($result); }
/** * Provide options for additional javascript files. * * @param GetOptionsEvent $event The event. * * @return void * * @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public static function getJsFilesOptions(GetOptionsEvent $event) { if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_rendersettings' || $event->getPropertyName() !== 'additionalJs' || $event->getSubPropertyName() !== 'file') { return; } $options = Helper::searchFiles($GLOBALS['TL_CONFIG']['uploadPath'], '.js'); $event->setOptions($options); }
/** * @param GetOptionsEvent $event */ public function bypassCreateMailingListOptions(GetOptionsEvent $event) { if (!in_array($event->getSubPropertyName(), array('mailingList', 'channel'))) { return; } global $container; /** @var OptionsBuilder $optionsBuilder */ $optionsBuilder = $container['avisota.core.options-builder']; $options = $optionsBuilder->getMailingListOptions(); $event->setOptions($options); }