/**
  * Load the values from given MetaModels Item
  *
  * @throws \Exception When an MetaModels Item is missing
  */
 public function loadValues()
 {
     if (is_null($this->mmItem)) {
         throw new \Exception('Trying to load values from empty mmItem - aborting');
         return false;
     }
     /**
      * Set default values to fields
      */
     $this->fields->reset();
     while ($this->fields->next()) {
         $field = $this->fields->current();
         if (!method_exists($field, 'setDefaultValue')) {
             continue;
         }
         $value = $this->mmItem->get($field->getColName());
         $field->setDefaultValue($value);
     }
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function generateFilterUrlFrom(IItem $objItem, IRenderSettings $objRenderSetting)
 {
     $objAttribute = $this->getMetaModel()->getAttributeById($this->get('attr_id'));
     if ($objAttribute) {
         // TODO: shall we omit returning of empty values?
         $strResult = $objAttribute->getFilterUrlValue($objItem->get($objAttribute->getColName()));
         return array($this->getParamName() => $strResult);
     }
     return array();
 }
 /**
  * Apply the path style.
  *
  * @param Item  $item       The MetaModel item.
  * @param mixed $definition The definition.
  *
  * @return void
  */
 protected function applyStyle(Item $item, $definition)
 {
     if ($definition instanceof Path) {
         $style = $this->getStyle($item->get('id'));
         if ($style) {
             $style->apply($definition);
         } elseif ($this->fallbackStyle) {
             $this->fallbackStyle->apply($definition);
         }
     }
 }
Exemple #4
0
 /**
  * {@inheritdoc}
  */
 public function delete(IItem $objItem)
 {
     $arrIds = array($objItem->get('id'));
     // Determine if the model is a variant base and if so, fetch the variants additionally.
     if ($objItem->isVariantBase()) {
         $objVariants = $objItem->getVariants(new Filter($this));
         foreach ($objVariants as $objVariant) {
             /** @var IItem $objVariant */
             $arrIds[] = $objVariant->get('id');
         }
     }
     // Complex attributes shall delete their values first.
     foreach ($this->getAttributes() as $objAttribute) {
         if ($this->isComplexAttribute($objAttribute)) {
             /** @var IComplex $objAttribute */
             $objAttribute->unsetDataFor($arrIds);
         }
     }
     // Now make the real row disappear.
     $this->getDatabase()->prepare(sprintf('DELETE FROM %s WHERE id IN (%s)', $this->getTableName(), $this->buildDatabaseParameterList($arrIds)))->execute($arrIds);
 }