Skip to content

Commit

Permalink
Merge branch 'hotfix-894'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanheimes committed Oct 28, 2015
2 parents b90b896 + c05a125 commit 62b5de3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/MetaModels/IItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @package MetaModels
* @subpackage Core
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @author Stefan Heimes <stefan_heimes@hotmail.com>
* @copyright 2012-2015 The MetaModels team.
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0
* @filesource
Expand Down Expand Up @@ -63,6 +64,26 @@ public function getMetaModel();
*/
public function getAttribute($strAttributeName);

/**
* Check if the given attribute is set. This mean if in the data array
* is the filed set or not. If the attribute is not loaded the function
* will return false.
*
* @param string $strAttributeName The desired attribute.
*
* @return bool True means the data is set, on load of the item or at any time.
* False means the attribute is not set.
*/
public function isAttributeSet($strAttributeName);

/**
* Return a list of the col names from the attributes which are set.
* Including all meta fields as well.
*
* @return array
*/
public function getSetAttributes();

/**
* Determines if this item is a variant of another item.
*
Expand Down
26 changes: 26 additions & 0 deletions src/MetaModels/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,32 @@ public function getAttribute($strAttributeName)
return $this->getMetaModel()->getAttribute($strAttributeName);
}

/**
* Check if the given attribute is set. This mean if in the data array
* is the filed set or not. If the attribute is not loaded the function
* will return false.
*
* @param string $strAttributeName The desired attribute.
*
* @return bool True means the data is set, on load of the item or at any time.
* False means the attribute is not set.
*/
public function isAttributeSet($strAttributeName)
{
return array_key_exists($strAttributeName, $this->arrData);
}

/**
* Return a list of the col names from the attributes which are set.
* Including all meta field as well.
*
* @return array
*/
public function getSetAttributes()
{
return array_keys($this->arrData);
}

/**
* Determines if this item is a variant of another item.
*
Expand Down
4 changes: 3 additions & 1 deletion src/MetaModels/MetaModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,9 @@ public function saveItem($objItem)

// Tell all attributes that the model has been saved. Useful for alias fields, edit counters etc.
foreach ($this->getAttributes() as $objAttribute) {
$objAttribute->modelSaved($objItem);
if ($objItem->isAttributeSet($objAttribute->getColName())) {
$objAttribute->modelSaved($objItem);
}
}
}

Expand Down

0 comments on commit 62b5de3

Please sign in to comment.