Example #1
0
 /**
  * Create a new factory with basic settings from the environment.
  *
  * This factory can be used to create a new Container, Environment, DcGeneral with the same base settings as the
  * given environment.
  *
  * @param EnvironmentInterface $environment The environment to use as base.
  *
  * @return DcGeneralFactory
  */
 public static function deriveEmptyFromEnvironment(EnvironmentInterface $environment)
 {
     $factory = new DcGeneralFactory();
     $factory->setEventPropagator($environment->getEventPropagator());
     $factory->setTranslator($environment->getTranslator());
     $factory->setEnvironmentClassName(get_class($environment));
     $factory->setContainerClassName(get_class($environment->getDataDefinition()));
     return $factory;
 }
Example #2
0
 /**
  * Decode a value from native data of the data provider to the widget via event.
  *
  * @param EnvironmentInterface $environment The environment.
  *
  * @param ModelInterface       $model       The model.
  *
  * @param string               $property    The property.
  *
  * @param mixed                $value       The value of the property.
  *
  * @return mixed
  */
 public function decodeValue($environment, $model, $property, $value)
 {
     $event = new DecodePropertyValueForWidgetEvent($environment, $model);
     $event->setProperty($property)->setValue($value);
     $environment->getEventPropagator()->propagate($event::NAME, $event, array($environment->getDataDefinition()->getName(), $property));
     return $event->getValue();
 }
Example #3
0
 /**
  * {@inheritDoc}
  */
 public function setEnvironment(EnvironmentInterface $environment)
 {
     if ($this->environment) {
         $this->environment->getEventPropagator()->removeSubscriber($this);
     }
     $this->environment = $environment;
     $this->environment->getEventPropagator()->addSubscriber($this);
 }