private function getFileContents($path)
 {
     if (filter_var($path, FILTER_VALIDATE_URL)) {
         return $this->fileSystem->getRemoteFileContents($path);
     }
     return $this->fileSystem->getFileContents($path);
 }
Example #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $html = $input->getArgument('html-file');
     $output = $input->getOption('output-file');
     $css = $input->getOption('css-file');
     $disableLinkNodeProcessing = $input->getOption('disable-link-node-processing');
     $removeHiddenNodes = $input->getOption('remove-hidden-nodes');
     $backupNode = $input->getOption('disable-backup-node');
     $inlineStyleAttributes = $input->getOption('disable-inline-style-attributes');
     $appendStyleToHead = $input->getOption('append-styles-to-head');
     $htmlContent = $this->fileSystem->getFileContents($html, 'Could not find HTML file \'%s\'');
     $cssContent = '';
     if ($css) {
         $cssContent = $this->fileSystem->getFileContents($css, 'Could not find CSS file \'%s\'');
     }
     if ($output) {
         $output = $this->fileSystem->getFilePath($output);
     } else {
         $output = $html;
     }
     if (!$disableLinkNodeProcessing) {
         $cssReader = new LinkedCssImporter($htmlContent, $html, $this->fileSystem);
         $htmlContent = $cssReader->getHtmlWithoutCssLinks();
         $cssContent .= $cssReader->getCssFromLinkedStyleSheets();
     }
     $inlineProcessor = new InlineProcessor();
     $inlinedHtml = $inlineProcessor->process($htmlContent, $cssContent, !$removeHiddenNodes, $backupNode, $inlineStyleAttributes, $appendStyleToHead);
     $this->fileSystem->saveFile($output, $inlinedHtml);
 }