/** * `Simple` mapping rules assume that { "patternPath" : "tagType:tagName" } */ public function mapTagsSimple(Metadata $metadata, $inputRules) { $rules = $this->buildAndValidateRules($inputRules); $convertedTags = []; foreach ($rules as $pathPattern => $rule) { $matches = $metadata->matchAndRemoveByKey($pathPattern); foreach ($matches as $key => $value) { $value = $value['value']; // Yap this guy got matched so let's fix convert it to tags $tagTypeRule = $rule['tagTypeRule']; $tagNameRule = $rule['tagNameRule']; // Build the tag name by replacing '{{value}}' at the rule with the actual value $tagName = str_replace('{{value}}', $value, $tagNameRule); // And simply match use the tag type rule as dah` tag type ~ simple :) $tagType = $tagTypeRule; // Let's save it! $convertedTags[$tagType][] = $tagName; $touchedFlatTagsKey[] = $key; } } return [$convertedTags, $metadata]; }
public function mapValueMap(Metadata $metadata, array $rules = []) { $rules = $this->validateRules($rules); $convertedTags = []; foreach ($rules as $patternPath => $rule) { $parameters = $rule['parameters']; $tagTypeRule = $rule['tagType']; $tagNameRule = $rule['tagName']; $matches = $metadata->matchAndRemoveByKey($patternPath); if (!empty($matches)) { $matchesGroups = $this->groupMatches($matches); foreach ($matchesGroups as $matchedGroup) { $matchedParameters = $this->matchParameters($parameters, $matchedGroup); // Now build tag type $tagType = $this->replaceParameters($matchedParameters, $tagTypeRule); // Then build tagname $tagName = $this->replaceParameters($matchedParameters, $tagNameRule); // Then the whole tags $convertedTags[$tagType][] = $tagName; } } } return [$convertedTags, $metadata]; }