コード例 #1
0
 /**
  * @param PreEditModelEvent $event
  * @param                   $name
  * @param EventDispatcher   $eventDispatcher
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function parseDefaultValue(PreEditModelEvent $event, $name, EventDispatcher $eventDispatcher)
 {
     $properties = $event->getModel()->getPropertiesAsArray();
     if (!array_key_exists('orderSRC', $properties) || array_key_exists('orderSRC', $properties) && $properties['orderSRC'] != null) {
         return;
     }
     $entity = $event->getModel()->getEntity();
     $entity->setOrderSRC(array());
 }
コード例 #2
0
 /**
  * Check the items before the edit start. If there is a item with variant support and a empty vargroup it must be a
  * base. So set the varbase to 1.
  *
  * @param PreEditModelEvent $event The event with the model.
  *
  * @return void
  */
 public function presetVariantBase(PreEditModelEvent $event)
 {
     $model = $event->getModel();
     // Check of we have the driver from MetaModels. Only these request are from interest.
     if (!$model instanceof Model) {
         return;
     }
     // Get the item and check the context.
     $nativeItem = $model->getItem();
     $metaModel = $nativeItem->getMetaModel();
     if ($metaModel->hasVariants() && !$nativeItem->get('vargroup')) {
         $nativeItem->set('varbase', '1');
     }
 }
コード例 #3
0
 /**
  * By paste after model. Add the cell information from the parent model.
  *
  * @param PreEditModelEvent $event The event.
  *
  * @return void
  */
 public function addCellFromPreviousModel(PreEditModelEvent $event)
 {
     $environment = $event->getEnvironment();
     $dataDefinition = $environment->getDataDefinition();
     $inputProvider = $environment->getInputProvider();
     if ($dataDefinition->getName() !== 'orm_avisota_message_content' || !in_array($inputProvider->getParameter('act'), array('paste', 'create')) || !$inputProvider->hasParameter('after')) {
         return;
     }
     $entity = $event->getModel()->getEntity();
     $dataProvider = $environment->getDataProvider();
     $repository = $dataProvider->getEntityRepository();
     $modelId = ModelId::fromSerialized($inputProvider->getParameter('after'));
     $parentModel = $repository->find($modelId->getId());
     if (!$parentModel) {
         return;
     }
     $entity->setCell($parentModel->getCell());
 }