예제 #1
0
 /**
  * Fetch the options for a certain property.
  *
  * @param EnvironmentInterface $environment The environment.
  *
  * @param ModelInterface       $model       The model.
  *
  * @param PropertyInterface    $property    The property.
  *
  * @return array
  */
 protected function getOptions($environment, $model, $property)
 {
     $options = $property->getOptions();
     $event = new GetPropertyOptionsEvent($environment, $model);
     $event->setPropertyName($property->getName());
     $event->setOptions($options);
     $environment->getEventPropagator()->propagate($event::NAME, $event, $environment->getDataDefinition()->getName(), $property->getName());
     if ($event->getOptions() !== $options) {
         $options = $event->getOptions();
     }
     return $options;
 }
예제 #2
0
 /**
  * Fetch the options for a certain property.
  *
  * @param EnvironmentInterface $environment The environment.
  *
  * @param ModelInterface       $model       The model.
  *
  * @param PropertyInterface    $property    The property.
  *
  * @return array
  */
 protected static function getOptions($environment, $model, $property)
 {
     $options = $property->getOptions();
     $event = new GetPropertyOptionsEvent($environment, $model);
     $event->setPropertyName($property->getName());
     $event->setOptions($options);
     $environment->getEventDispatcher()->dispatch(sprintf('%s', $event::NAME), $event);
     if ($event->getOptions() !== $options) {
         $options = $event->getOptions();
     }
     return $options;
 }
예제 #3
0
 /**
  * Get special labels.
  *
  * @param PropertyInterface $propInfo The property for which the X label shall be generated.
  *
  * @param ModelInterface    $model    The model.
  *
  * @return string
  */
 protected function getOptionsForWidget($propInfo, $model)
 {
     $environment = $this->getEnvironment();
     $dispatcher = $environment->getEventDispatcher();
     $options = $propInfo->getOptions();
     $event = new GetPropertyOptionsEvent($environment, $model);
     $event->setPropertyName($propInfo->getName());
     $event->setOptions($options);
     $dispatcher->dispatch(GetPropertyOptionsEvent::NAME, $event);
     if ($event->getOptions() !== $options) {
         return $event->getOptions();
     }
     return $options;
 }
예제 #4
0
 /**
  * Render a property option.
  *
  * @param RenderReadablePropertyValueEvent $event    The event to store the value to.
  * @param PropertyInterface                $property The property holding the options.
  * @param mixed                            $value    The value to format.
  *
  * @return void
  */
 private static function renderOptionValueReadable(RenderReadablePropertyValueEvent $event, $property, $value)
 {
     $options = $property->getOptions();
     if (!$options) {
         $options = self::getOptions($event->getEnvironment(), $event->getModel(), $event->getProperty());
         if ($options) {
             $property->setOptions($options);
         }
     }
     if (array_is_assoc($options)) {
         $event->setRendered($options[$value]);
     }
 }
 /**
  * Get special labels.
  *
  * @param EnvironmentInterface $environment The environment.
  *
  * @param PropertyInterface    $propInfo    The property for which the options shall be retrieved.
  *
  * @param ModelInterface       $model       The model.
  *
  * @return string
  */
 private function getOptionsForWidget(EnvironmentInterface $environment, PropertyInterface $propInfo, ModelInterface $model)
 {
     $dispatcher = $environment->getEventDispatcher();
     $options = $propInfo->getOptions();
     $event = new GetPropertyOptionsEvent($environment, $model);
     $event->setPropertyName($propInfo->getName());
     $event->setOptions($options);
     $dispatcher->dispatch(GetPropertyOptionsEvent::NAME, $event);
     if ($event->getOptions() !== $options) {
         return $event->getOptions();
     }
     return $options;
 }