/**
  * Receives an html string. It find all images and run them through
  * wfIsBadImage() to determine if the image can be shown.
  *
  * @param DOMNode $node
  * @param Title $title
  * @throws \MWException
  */
 public function apply(DOMNode $node, Title $title)
 {
     if (!$node instanceof DOMElement) {
         return;
     }
     $resource = $node->getAttribute('resource');
     if ($resource === '') {
         return;
     }
     $image = Utils::createRelativeTitle($resource, $title);
     if (!$image) {
         wfDebugLog('Flow', __METHOD__ . ': Could not construct title for node: ' . $node->ownerDocument->saveXML($node));
         return;
     }
     if (!call_user_func($this->isFiltered, $image->getDBkey(), $title)) {
         return;
     }
     // Move up the DOM and remove the typeof="mw:Image" node
     $nodeToRemove = $node->parentNode;
     while ($nodeToRemove instanceof DOMElement && $nodeToRemove->getAttribute('typeof') !== 'mw:Image') {
         $nodeToRemove = $nodeToRemove->parentNode;
     }
     if (!$nodeToRemove) {
         throw new \MWException('Did not find parent mw:Image to remove');
     }
     $nodeToRemove->parentNode->removeChild($nodeToRemove);
 }
 /**
  * @param string $refType
  * @param string $value
  * @return WikiReference|null
  */
 public function createWikiReference($refType, $value)
 {
     $title = Utils::createRelativeTitle($value, $this->title);
     if ($title === null) {
         return null;
     }
     return new WikiReference($this->workflowId, $this->title, $this->objectType, $this->objectId, $refType, $title);
 }
 /**
  * @dataProvider createRelativeTitleProvider
  */
 public function testResolveSubpageTraversal($message, $expect, $text, Title $title)
 {
     $result = Utils::createRelativeTitle($text, $title);
     if ($expect === null) {
         $this->assertNull($expect, $message);
     } elseif ($expect instanceof Title) {
         $this->assertInstanceOf('Title', $result, $message);
         $this->assertEquals($expect->getPrefixedText(), $result->getPrefixedText(), $message);
     } else {
         $this->assertEquals($expect, $result, $message);
     }
 }