From a3f0a62674c19a5eb4a68da690fee3de3bf25fc2 Mon Sep 17 00:00:00 2001 From: Richard Henkenjohann Date: Sun, 12 Feb 2017 00:22:38 +0100 Subject: [PATCH 1/4] Introduce `IItem::getVariantBase()` --- src/MetaModels/IItem.php | 7 +++++++ src/MetaModels/Item.php | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/MetaModels/IItem.php b/src/MetaModels/IItem.php index e48b845aa..ab5e7ddb7 100644 --- a/src/MetaModels/IItem.php +++ b/src/MetaModels/IItem.php @@ -111,6 +111,13 @@ public function isVariantBase(); */ public function getVariants($objFilter); + /** + * Fetch the meta model variant base for this item. For a non-variant item the variant base is the item itself. + * + * @return \MetaModels\IItem The variant base. + */ + public function getVariantBase(); + /** * Save the current data for every attribute to the data sink. * diff --git a/src/MetaModels/Item.php b/src/MetaModels/Item.php index 13755ea7b..4b646356d 100644 --- a/src/MetaModels/Item.php +++ b/src/MetaModels/Item.php @@ -294,6 +294,16 @@ public function getVariants($objFilter) return null; } + /** + * Fetch the meta model variant base for this item. For a non-variant item the variant base is the item itself. + * + * @return \MetaModels\IItem The variant base. + */ + public function getVariantBase() + { + // TODO: Implement getVariantBase() method. + } + /** * Find all Variants including the variant base. * From bcbe3eb4fc1d6b52f24bdcb28e94a893d83db020 Mon Sep 17 00:00:00 2001 From: Richard Henkenjohann Date: Sun, 12 Feb 2017 00:28:18 +0100 Subject: [PATCH 2/4] Implement `Item::getVariantBase()` --- src/MetaModels/Item.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/MetaModels/Item.php b/src/MetaModels/Item.php index 4b646356d..7cc95f446 100644 --- a/src/MetaModels/Item.php +++ b/src/MetaModels/Item.php @@ -301,7 +301,11 @@ public function getVariants($objFilter) */ public function getVariantBase() { - // TODO: Implement getVariantBase() method. + if (!$this->isVariantBase()) { + return $this->getMetaModel()->findById($this->get('vargroup')); + } + + return $this; } /** From 012558528c14dcaf95f65b784e9a49a7d205352d Mon Sep 17 00:00:00 2001 From: Richard Henkenjohann Date: Sun, 12 Feb 2017 00:32:14 +0100 Subject: [PATCH 3/4] Changes in the PHP doc comments --- src/MetaModels/IItem.php | 8 +++++--- src/MetaModels/Item.php | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/MetaModels/IItem.php b/src/MetaModels/IItem.php index ab5e7ddb7..1d250747e 100644 --- a/src/MetaModels/IItem.php +++ b/src/MetaModels/IItem.php @@ -107,14 +107,16 @@ 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. For a non-variant item the variant base is the item itself. + * Fetch the meta model variant base for this item. * - * @return \MetaModels\IItem The variant base. + * Note: For a non-variant item the variant base is the item itself. + * + * @return IItem The variant base. */ public function getVariantBase(); diff --git a/src/MetaModels/Item.php b/src/MetaModels/Item.php index 7cc95f446..74aac09d5 100644 --- a/src/MetaModels/Item.php +++ b/src/MetaModels/Item.php @@ -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) { @@ -295,9 +295,11 @@ public function getVariants($objFilter) } /** - * Fetch the meta model variant base for this item. For a non-variant item the variant base is the item itself. + * Fetch the meta model variant base for this item. * - * @return \MetaModels\IItem The variant base. + * Note: For a non-variant item the variant base is the item itself. + * + * @return IItem The variant base. */ public function getVariantBase() { From 6ef3a24219f1a84faa0c20d40f4ef4e4320e9685 Mon Sep 17 00:00:00 2001 From: Richard Henkenjohann Date: Sun, 12 Feb 2017 00:45:55 +0100 Subject: [PATCH 4/4] Update copyright --- src/MetaModels/IItem.php | 5 +++-- src/MetaModels/Item.php | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/MetaModels/IItem.php b/src/MetaModels/IItem.php index 1d250747e..02e232791 100644 --- a/src/MetaModels/IItem.php +++ b/src/MetaModels/IItem.php @@ -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. @@ -14,7 +14,8 @@ * @subpackage Core * @author Christian Schiffler * @author Stefan Heimes - * @copyright 2012-2015 The MetaModels team. + * @author Richard Henkenjohann + * @copyright 2012-2017 The MetaModels team. * @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0 * @filesource */ diff --git a/src/MetaModels/Item.php b/src/MetaModels/Item.php index 74aac09d5..c904ea9a8 100644 --- a/src/MetaModels/Item.php +++ b/src/MetaModels/Item.php @@ -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. @@ -18,7 +18,7 @@ * @author Oliver Hoff * @author Stefan Heimes * @author Richard Henkenjohann - * @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 */