コード例 #1
0
 /**
  * Setup scripts.
  *
  * @param ReportRouting $reportRouting
  */
 protected function setScripts(ReportRouting $reportRouting)
 {
     $report = $reportRouting->getReport();
     $scripts = $report->getScripts();
     $content = $report->getResponse();
     $doc = new \DOMDocument();
     $doc->loadHTML($content);
     $heads = $doc->getElementsByTagName('head');
     if ($heads->length == 0) {
         /* If no head is created, add it at the top of HTML */
         $head = $doc->createElement('head');
         $html = $doc->getElementsByTagName('html');
         $html->item(0)->insertBefore($head, $html->item(0)->firstChild);
     } else {
         $head = $heads->item(0);
     }
     foreach ($scripts as $script) {
         $url = $reportRouting->getUrl($script);
         $element = $doc->createElement('script');
         $element->setAttribute('type', 'text/javascript');
         $element->setAttribute('src', $url);
         $head->appendChild($element);
     }
     $report->setResponse($doc->saveHTML());
 }
コード例 #2
0
ファイル: RenderEngine.php プロジェクト: angelog4/sdk-php
 /**
  * @param \DOMElement $element
  * @param string $attribute
  * @param ReportRouting $reportRouting
  */
 protected function prepareAsset(\DOMElement $element, $attribute, ReportRouting $reportRouting)
 {
     $asset = $element->getAttribute($attribute);
     if ($asset) {
         $asset = $this->sanitizeAsset($asset);
         if ($this->assetNeedsTransform($asset)) {
             $asset = $reportRouting->getPath($asset);
         }
         $element->setAttribute($attribute, $asset);
     }
 }
コード例 #3
0
 /**
  * Find and registers all available extensions.
  */
 protected function findExtensions()
 {
     /* TODO: Automate extension addition */
     $routingExtension = new ReportRouting($this->templatingHelper, $this->report);
     $this->extensions[$routingExtension->getName()] = $routingExtension;
 }