From 42608f6644b24d3377f37c8f4311a012501e83ba Mon Sep 17 00:00:00 2001 From: Christian Seel Date: Thu, 21 Jul 2016 18:21:07 +0200 Subject: [PATCH 1/2] Support OR conditions for content extract --- src/Command/ExtractCommand.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Command/ExtractCommand.php b/src/Command/ExtractCommand.php index c0d1400..d630902 100644 --- a/src/Command/ExtractCommand.php +++ b/src/Command/ExtractCommand.php @@ -109,7 +109,15 @@ public function extractContent($folder, $options) // Prepare the criteria for this context $contextCriteria = ($criteria) ? $criteria : array(); - $contextCriteria['context_key'] = $contextKey; + if (count(array_filter(array_keys($contextCriteria), 'is_string')) > 0) { + // associative array => and conditions + $contextCriteria['context_key'] = $contextKey; + } else { + // sequential array => or conidtions + foreach ($contextCriteria as $i => $orCondition) { + $contextCriteria[$i]['context_key'] = $contextKey; + } + } // Grab the count $count = $this->modx->getCount('modResource', $contextCriteria); From 4a61dd83eade830114f4518808d81f9d28827409 Mon Sep 17 00:00:00 2001 From: Christian Seel Date: Fri, 2 Sep 2016 12:52:04 +0200 Subject: [PATCH 2/2] fix issue with empty context criteria --- src/Command/ExtractCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command/ExtractCommand.php b/src/Command/ExtractCommand.php index d630902..4372451 100644 --- a/src/Command/ExtractCommand.php +++ b/src/Command/ExtractCommand.php @@ -109,7 +109,7 @@ public function extractContent($folder, $options) // Prepare the criteria for this context $contextCriteria = ($criteria) ? $criteria : array(); - if (count(array_filter(array_keys($contextCriteria), 'is_string')) > 0) { + if (empty($contextCriteria) || count(array_filter(array_keys($contextCriteria), 'is_string')) > 0) { // associative array => and conditions $contextCriteria['context_key'] = $contextKey; } else {