From a9c4cbbaef5c3367287a6ad31519307dd2bea337 Mon Sep 17 00:00:00 2001 From: gggeek Date: Sat, 11 Nov 2017 16:17:08 +0000 Subject: [PATCH] better error message when trying to generate a migration for the creation of a Role fails --- Core/Executor/RepositoryExecutor.php | 6 +++++- Core/Executor/RoleManager.php | 3 +++ WHATSNEW.md | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Core/Executor/RepositoryExecutor.php b/Core/Executor/RepositoryExecutor.php index 4ef89f28..323aa84b 100644 --- a/Core/Executor/RepositoryExecutor.php +++ b/Core/Executor/RepositoryExecutor.php @@ -135,13 +135,17 @@ protected function getUserContentType($step) return isset($step->dsl['user_content_type']) ? $step->dsl['user_content_type'] : $this->getUserContentTypeFromContext($step->context); } + /** + * @param array $context + * @return string + */ protected function getUserContentTypeFromContext($context) { return isset($context['userContentType']) ? $context['userContentType'] : self::USER_CONTENT_TYPE; } /** - * @param $context we have to return FALSE if that is set as adminUserLogin, whereas if NULL is set, we return the default admin + * @param array $context we have to return FALSE if that is set as adminUserLogin, whereas if NULL is set, we return the default admin * @return int|string|false */ protected function getAdminUserIdentifierFromContext($context) diff --git a/Core/Executor/RoleManager.php b/Core/Executor/RoleManager.php index 897a42cf..2b3a5171 100644 --- a/Core/Executor/RoleManager.php +++ b/Core/Executor/RoleManager.php @@ -246,6 +246,9 @@ public function generateMigration(array $matchCondition, $mode, array $context = $limitations = array(); foreach ($policy->getLimitations() as $limitation) { + if ($limitation === null) { + throw new \Exception("The role contains NULL as limitation for policy {$policy->module}/{$policy->function}, we can not reliably generate its definition."); + } $limitations[] = $this->limitationConverter->getLimitationArrayWithIdentifiers($limitation); } diff --git a/WHATSNEW.md b/WHATSNEW.md index c8464fb8..39477ff4 100644 --- a/WHATSNEW.md +++ b/WHATSNEW.md @@ -13,6 +13,9 @@ Version 4.4 (unreleased) * New: support the value '*' for the `remove_attributes` parameter in ContentType definitions. This allows to remove all the attributes which already exist in the ContentType, except for the ones defined in the `attributes` parameter +* Improved: better error message when trying to generate a migration for the creation of a Role which has Policies with + limitations that can not be exported + Version 4.3 ===========