Exemple #1
0
 /**
  * Remove invariant attributes from the render setting.
  *
  * This is done by cloning the input collection of render settings and removing any invariant attribute.
  *
  * @param IItem       $nativeItem    The native item.
  *
  * @param ICollection $renderSetting The render setting to be used.
  *
  * @return ICollection
  */
 protected static function removeInvariantAttributes(IItem $nativeItem, ICollection $renderSetting)
 {
     $model = $nativeItem->getMetaModel();
     if ($model->hasVariants() && !$nativeItem->isVariantBase()) {
         // Create a clone to have a separate copy of the object as we are going to manipulate it here.
         $renderSetting = clone $renderSetting;
         // Loop over all attributes and remove those from rendering that are not desired.
         foreach (array_keys($model->getInVariantAttributes()) as $strAttrName) {
             $renderSetting->setSetting($strAttrName, null);
         }
     }
     return $renderSetting;
 }
Exemple #2
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);
 }