/**
  * @see PropertyAnnotatorDecorator::addPropertyValues
  */
 protected function addPropertyValues()
 {
     if (!$this->redirectTargetFinder->hasRedirectTarget()) {
         return;
     }
     $this->getSemanticData()->addPropertyObjectValue(new DIProperty('_REDI'), DIWikiPage::newFromTitle($this->redirectTargetFinder->getRedirectTarget()));
 }
 /**
  * @dataProvider redirectsDataProvider
  */
 public function testAddAnnotation(array $parameter, array $expected)
 {
     $semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
     $redirectTargetFinder = new RedirectTargetFinder();
     $instance = new RedirectPropertyAnnotator(new NullPropertyAnnotator($semanticData), $redirectTargetFinder->findRedirectTargetFromText($parameter['text']));
     $instance->addAnnotation();
     $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $instance->getSemanticData());
 }
 /**
  * @dataProvider redirectTextProvider
  */
 public function testInjectedRedirectTargetOverridesTextFinder($text)
 {
     $directRedirectTarget = Title::newFromText('Foo');
     $instance = new RedirectTargetFinder();
     $instance->setRedirectTarget($directRedirectTarget);
     $instance->findRedirectTargetFromText($text);
     $this->assertTrue($instance->hasRedirectTarget());
     $this->assertEquals($directRedirectTarget, $instance->getRedirectTarget());
 }
Exemplo n.º 4
0
 protected function addRedirectTargetAnnotation($text)
 {
     if ($this->isEnabledNamespace) {
         $this->redirectTargetFinder->findRedirectTargetFromText($text);
         $redirectPropertyAnnotator = $this->applicationFactory->newPropertyAnnotatorFactory()->newRedirectPropertyAnnotator($this->parserData->getSemanticData(), $this->redirectTargetFinder);
         $redirectPropertyAnnotator->addAnnotation();
     }
 }
 protected function addRedirectTargetAnnotationFromText($text)
 {
     if (!$this->isEnabledNamespace) {
         return;
     }
     $this->redirectTargetFinder->findRedirectTargetFromText($text);
     $propertyAnnotatorFactory = $this->applicationFactory->singleton('PropertyAnnotatorFactory');
     $propertyAnnotator = $propertyAnnotatorFactory->newNullPropertyAnnotator($this->parserData->getSemanticData());
     $redirectPropertyAnnotator = $propertyAnnotatorFactory->newRedirectPropertyAnnotator($propertyAnnotator, $this->redirectTargetFinder);
     $redirectPropertyAnnotator->addAnnotation();
 }