Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/MetaModels/IItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/core.
*
* (c) 2012-2015 The MetaModels team.
* (c) 2012-2017 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -14,7 +14,8 @@
* @subpackage Core
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @author Stefan Heimes <stefan_heimes@hotmail.com>
* @copyright 2012-2015 The MetaModels team.
* @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
* @copyright 2012-2017 The MetaModels team.
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -107,10 +108,19 @@ public function isVariantBase();
*
* @param \MetaModels\Filter\IFilter $objFilter The filter settings to be applied.
*
* @return \MetaModels\IItems A list of all variants for this item.
* @return \MetaModels\IItems|null A list of all variants for this item or null if the item cannot handle variants.
*/
public function getVariants($objFilter);

/**
* Fetch the meta model variant base for this item.
*
* Note: For a non-variant item the variant base is the item itself.
*
* @return IItem The variant base.
*/
public function getVariantBase();

/**
* Save the current data for every attribute to the data sink.
*
Expand Down
22 changes: 19 additions & 3 deletions src/MetaModels/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/core.
*
* (c) 2012-2015 The MetaModels team.
* (c) 2012-2017 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -18,7 +18,7 @@
* @author Oliver Hoff <oliver@hofff.com>
* @author Stefan Heimes <stefan_heimes@hotmail.com>
* @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
* @copyright 2012-2015 The MetaModels team.
* @copyright 2012-2017 The MetaModels team.
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -283,7 +283,7 @@ public function isVariantBase()
*
* @param IFilter $objFilter The filter settings to be applied.
*
* @return IItems A list of all variants for this item.
* @return IItems|null A list of all variants for this item.
*/
public function getVariants($objFilter)
{
Expand All @@ -294,6 +294,22 @@ public function getVariants($objFilter)
return null;
}

/**
* Fetch the meta model variant base for this item.
*
* Note: For a non-variant item the variant base is the item itself.
*
* @return IItem The variant base.
*/
public function getVariantBase()
{
if (!$this->isVariantBase()) {
return $this->getMetaModel()->findById($this->get('vargroup'));
}

return $this;
}

/**
* Find all Variants including the variant base.
*
Expand Down