File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 33/**
44 * This file is part of MetaModels/core.
55 *
6- * (c) 2012-2015 The MetaModels team.
6+ * (c) 2012-2017 The MetaModels team.
77 *
88 * For the full copyright and license information, please view the LICENSE
99 * file that was distributed with this source code.
1414 * @subpackage Core
1515 * @author Christian Schiffler <c.schiffler@cyberspectrum.de>
1616 * @author Stefan Heimes <stefan_heimes@hotmail.com>
17- * @copyright 2012-2015 The MetaModels team.
17+ * @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
18+ * @copyright 2012-2017 The MetaModels team.
1819 * @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0
1920 * @filesource
2021 */
@@ -107,10 +108,19 @@ public function isVariantBase();
107108 *
108109 * @param \MetaModels\Filter\IFilter $objFilter The filter settings to be applied.
109110 *
110- * @return \MetaModels\IItems A list of all variants for this item.
111+ * @return \MetaModels\IItems|null A list of all variants for this item or null if the item cannot handle variants .
111112 */
112113 public function getVariants ($ objFilter );
113114
115+ /**
116+ * Fetch the meta model variant base for this item.
117+ *
118+ * Note: For a non-variant item the variant base is the item itself.
119+ *
120+ * @return IItem The variant base.
121+ */
122+ public function getVariantBase ();
123+
114124 /**
115125 * Save the current data for every attribute to the data sink.
116126 *
Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ public function isVariantBase()
285285 *
286286 * @param IFilter $objFilter The filter settings to be applied.
287287 *
288- * @return IItems A list of all variants for this item.
288+ * @return IItems|null A list of all variants for this item.
289289 */
290290 public function getVariants ($ objFilter )
291291 {
@@ -296,6 +296,22 @@ public function getVariants($objFilter)
296296 return null ;
297297 }
298298
299+ /**
300+ * Fetch the meta model variant base for this item.
301+ *
302+ * Note: For a non-variant item the variant base is the item itself.
303+ *
304+ * @return IItem The variant base.
305+ */
306+ public function getVariantBase ()
307+ {
308+ if (!$ this ->isVariantBase ()) {
309+ return $ this ->getMetaModel ()->findById ($ this ->get ('vargroup ' ));
310+ }
311+
312+ return $ this ;
313+ }
314+
299315 /**
300316 * Find all Variants including the variant base.
301317 *
You can’t perform that action at this time.
0 commit comments