Skip to content

Commit

Permalink
Accept OR conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
hugopeek committed Mar 20, 2019
1 parent 45124d3 commit 2f64374
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Command/ExtractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,17 @@ public function extractContent($folder, $options)

// Prepare the criteria for this context
$contextCriteria = ($criteria) ? $criteria : array();
$contextCriteria['context_key'] = $contextKey;

// Accept OR conditions (see: https://github.com/modmore/Gitify/pull/197)
if (empty($contextCriteria) || count(array_filter(array_keys($contextCriteria), 'is_string')) > 0) {
// associative array => and conditions
$contextCriteria['context_key'] = $contextKey;
} else {
// sequential array => or conditions
foreach ($contextCriteria as $i => $orCondition) {
$contextCriteria[$i]['context_key'] = $contextKey;
}
}

// Grab the count
$count = $this->modx->getCount('modResource', $contextCriteria);
Expand Down

0 comments on commit 2f64374

Please sign in to comment.