private function findMostSuitablePropertyRepresentation(DIProperty $property, DIProperty $nonInverseProperty, &$namespaces) { $redirectByVariable = $this->compoundConditionBuilder->tryToFindRedirectVariableForDataItem($nonInverseProperty->getDiWikiPage()); // If the property is represented by a redirect then use the variable instead if ($redirectByVariable !== null) { return $redirectByVariable; } // Use helper properties in encoding values, refer to this helper property: if ($this->exporter->hasHelperExpElement($property)) { $propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty, true); } elseif (!$property->isUserDefined()) { $propertyExpElement = $this->exporter->getSpecialPropertyResource($nonInverseProperty->getKey(), SMW_NS_PROPERTY); } else { $propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty); } if ($propertyExpElement instanceof ExpNsResource) { $namespaces[$propertyExpElement->getNamespaceId()] = $propertyExpElement->getNamespace(); } return TurtleSerializer::getTurtleNameForExpElement($propertyExpElement); }
private function createConditionForRegexComparator($dataItem, $joinVariable, $orderByProperty, $comparator) { if (!$dataItem instanceof DIBlob && !$dataItem instanceof DIWikiPage && !$dataItem instanceof DIUri) { return $this->compoundConditionBuilder->newTrueCondition($joinVariable, $orderByProperty); } if ($dataItem instanceof DIBlob) { $search = $dataItem->getString(); } else { $search = $dataItem->getSortKey(); } // @codingStandardsIgnoreStart phpcs, ignore --sniffs=Generic.Files.LineLength $pattern = '^' . str_replace(array('https://', 'http://', '%2A', '.', '+', '{', '}', '(', ')', '|', '^', '$', '[', ']', '*', '?', "'", '\\\\.', '\\', '"', '\\\\\\\\"'), array('', '', '*', '\\.', '\\+', '\\{', '\\}', '\\(', '\\)', '\\|', '\\^', '\\$', '\\[', '\\]', '.*', '.', "\\'", '\\\\\\.', '\\\\', '\\\\\\"', '\\\\\\\\\\\\"'), $search) . '$'; // @codingStandardsIgnoreEnd $condition = $this->createFilterConditionToMatchRegexPattern($dataItem, $joinVariable, $comparator, $pattern); $redirectByVariable = $this->compoundConditionBuilder->tryToFindRedirectVariableForDataItem($dataItem); if ($redirectByVariable !== null) { $condition->matchElement = $redirectByVariable; } $this->compoundConditionBuilder->addOrderByDataForProperty($condition, $joinVariable, $orderByProperty, $dataItem->getDIType()); return $condition; }
public function testTryToFindRedirectVariableForNonWpgDataItem() { $instance = new CompoundConditionBuilder(); $this->assertNull($instance->tryToFindRedirectVariableForDataItem(new DINumber(1))); }