/**
  * Create a new group header event.
  *
  * @param EnvironmentInterface $environment   The environment.
  *
  * @param ModelInterface       $model         The model being used as group header.
  *
  * @param string               $propertyName  The name of the property being rendered into the group header.
  *
  * @param mixed                $propertyValue The value of the property being rendered into the group header.
  *
  * @param string               $groupingMode  The grouping mode currently active.
  */
 public function __construct(EnvironmentInterface $environment, ModelInterface $model, $propertyName, $propertyValue, $groupingMode)
 {
     parent::__construct($environment, $model);
     $this->groupField = $propertyName;
     $this->value = $propertyValue;
     $this->groupingMode = $groupingMode;
 }
 /**
  * Process the event.
  *
  * @param AbstractModelAwareEvent $event The event.
  *
  * @return void
  */
 private function handleFallback(AbstractModelAwareEvent $event)
 {
     $model = $event->getModel();
     $dataProvider = $event->getEnvironment()->getDataProvider($model->getProviderName());
     $properties = $event->getEnvironment()->getDataDefinition()->getPropertiesDefinition();
     foreach (array_keys($model->getPropertiesAsArray()) as $propertyName) {
         if (!$properties->hasProperty($propertyName)) {
             continue;
         }
         $extra = (array) $properties->getProperty($propertyName)->getExtra();
         if (array_key_exists('fallback', $extra) && true === $extra['fallback']) {
             if (!$dataProvider->isUniqueValue($propertyName, $model->getProperty($propertyName), $model->getId())) {
                 // Reset fallback and save model again to have the correct value.
                 $dataProvider->resetFallback($propertyName);
                 $dataProvider->save($model);
             }
         }
     }
 }
 /**
  * Create a new instance.
  *
  * @param EnvironmentInterface $environment The environment.
  *
  * @param ModelInterface       $model       The new model.
  *
  * @param ModelInterface       $sourceModel The source model.
  */
 public function __construct(EnvironmentInterface $environment, ModelInterface $model, ModelInterface $sourceModel)
 {
     parent::__construct($environment, $model);
     $this->sourceModel = $sourceModel;
 }
 /**
  * Create a new instance.
  *
  * @param EnvironmentInterface $environment The environment in use.
  *
  * @param ModelInterface       $model       The model the value originates from.
  *
  * @param PropertyInterface    $property    The property to transform.
  *
  * @param mixed                $value       The value to transform.
  */
 public function __construct(EnvironmentInterface $environment, ModelInterface $model, PropertyInterface $property, $value)
 {
     parent::__construct($environment, $model);
     $this->property = $property;
     $this->value = $value;
 }
 /**
  * Create a new event.
  *
  * @param EnvironmentInterface $environment The environment in use.
  *
  * @param ModelInterface       $model       The model for which the widget is created.
  *
  * @param PropertyInterface    $property    The property information for which the widget is created.
  *
  * @param \Widget              $widget      The widget instance to manipulate.
  */
 public function __construct(EnvironmentInterface $environment, ModelInterface $model, PropertyInterface $property, \Widget $widget)
 {
     parent::__construct($environment, $model);
     $this->property = $property;
     $this->widget = $widget;
 }
 /**
  * Create a new model aware event.
  *
  * @param EnvironmentInterface      $environment    The environment.
  *
  * @param ModelInterface            $model          The model attached to the event.
  *
  * @param PropertyValueBagInterface $propertyValues The property value bag the property value originates from.
  */
 public function __construct(EnvironmentInterface $environment, ModelInterface $model, PropertyValueBagInterface $propertyValues)
 {
     parent::__construct($environment, $model);
     $this->propertyValues = $propertyValues;
 }
 /**
  * Create a new event.
  *
  * @param EnvironmentInterface $environment The environment instance in use.
  *
  * @param ModelInterface       $model       The model holding the data for the widget that shall be instantiated.
  *
  * @param string               $buttonName  The button that caused the submit.
  */
 public function __construct(EnvironmentInterface $environment, ModelInterface $model, $buttonName)
 {
     parent::__construct($environment, $model);
     $this->buttonName = $buttonName;
 }
 /**
  * Create a new model aware event.
  *
  * @param EnvironmentInterface $environment The environment.
  *
  * @param ModelInterface       $model       The model attached to the event.
  *
  * @param ModelInterface       $parentModel The parent model (if model is parented).
  *
  * @param ModelInterface       $rootModel   The root model (if model is in a tree).
  */
 public function __construct(EnvironmentInterface $environment, ModelInterface $model, ModelInterface $parentModel = null, ModelInterface $rootModel = null)
 {
     parent::__construct($environment, $model);
     $this->parentModel = $parentModel;
     $this->rootModel = $rootModel;
 }
 /**
  * Create a new model aware event.
  *
  * @param EnvironmentInterface $environment   The environment.
  *
  * @param ModelInterface       $model         The model attached to the event.
  *
  * @param ModelInterface|null  $originalModel The original state of the model (persistent in the data provider).
  */
 public function __construct(EnvironmentInterface $environment, ModelInterface $model, ModelInterface $originalModel = null)
 {
     parent::__construct($environment, $model);
     $this->originalModel = $originalModel;
 }
Beispiel #10
0
 /**
  * Check if we have to purge the MetaModels cache.
  *
  * @param AbstractModelAwareEvent $event The event holding the model being manipulated.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function checkPurge(AbstractModelAwareEvent $event)
 {
     $table = $event->getModel()->getProviderName();
     if ($table == 'tl_metamodel' || $table == 'tl_metamodel_dca' || $table == 'tl_metamodel_dca_sortgroup' || $table == 'tl_metamodel_dcasetting' || $table == 'tl_metamodel_dcasetting_condition' || $table == 'tl_metamodel_attribute' || $table == 'tl_metamodel_filter' || $table == 'tl_metamodel_filtersetting' || $table == 'tl_metamodel_rendersettings' || $table == 'tl_metamodel_rendersetting' || $table == 'tl_metamodel_dca_combine') {
         $purger = new PurgeCache();
         $purger->purge();
     }
 }