Example of transformation of one query (method works with list):
query = some_field: value other_field: other_value
array = ['some_field' => ['value'], 'other_field' => ['other_value']]
public static createRulesFromQueries ( $queries, $allowEmpty = false ) : array | ||
$queries | ||
$allowEmpty | boolean Allow empty values | |
Résultat | array |
/** * @test * @dataProvider queryAndRulesProvider */ public function queryLanguageUtilsCreatesCorrectRules($query, $expectedRules) { $rules = QueryLanguageUtils::createRulesFromQueries($query); // Perform case insensitive match $this->assertEquals($expectedRules, $rules, '', 0, 10, false, true); }
public function shouldUpdate(WP_REST_Request $request) { global $versionPressContainer; /** @var GitRepository $repository */ $repository = $versionPressContainer->resolve(VersionPressServices::GIT_REPOSITORY); $latestCommit = $request['latestCommit']; $query = urldecode(stripslashes($request['query'])); $rules = QueryLanguageUtils::createRulesFromQueries([$query]); $gitLogQuery = !empty($rules) ? QueryLanguageUtils::createGitLogQueryFromRule($rules[0]) : ''; $repoLatestCommit = $repository->getLastCommitHash($gitLogQuery); return new WP_REST_Response(["update" => $repository->wasCreatedAfter($repoLatestCommit, $latestCommit), "cleanWorkingDirectory" => $repository->isCleanWorkingDirectory()]); }
public function getRulesForIgnoredEntities() { return QueryLanguageUtils::createRulesFromQueries($this->ignoredEntities); }