Exemplo n.º 1
0
 /**
  * @param Tx_Asdis_Content_Replacement_Map $replacementMap
  * @param string $content
  * @return string
  */
 public function replace(Tx_Asdis_Content_Replacement_Map $replacementMap, $content)
 {
     $result = preg_replace($replacementMap->getSources(), $replacementMap->getTargets(), $content);
     if (NULL === $result) {
         return $content;
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * @return Tx_Asdis_Content_Replacement_Map
  */
 public function getReplacementMap()
 {
     $map = new Tx_Asdis_Content_Replacement_Map();
     foreach ($this as $asset) {
         /** @var Tx_Asdis_Domain_Model_Asset $asset */
         $map->addMapping($asset->getMaskedPregQuotedOriginalPath(), $asset->getMask() . $asset->getUri() . $asset->getMask());
     }
     return $map;
 }
Exemplo n.º 3
0
 /**
  * @test
  */
 public function replace()
 {
     $content = '<script type="text/css" src="typo3temp/js_css_optimizer/js_css_optimizer808ed94db016bc2941aa4b6de7f281664e40509f_b11ce65960acc0970b4bd1b7dc2292c85b9d4b4e_bundled_cssFiles.css" /><script type="text/css" src="/typo3temp/js_css_optimizer/_compressed_b8556e54a9173d519e2bf8851b6ec9778fc21495_js_css_optimizer3e8d68f9771f88ee7239129f8ffb85eb0e257769_e720b5b16198fa7190b9c5d8d49e717a98e79a7e_bundled_cssFiles.css" />';
     $result = '<script type="text/css" src="http://media9.dev.myproject.com/typo3temp/js_css_optimizer/js_css_optimizer808ed94db016bc2941aa4b6de7f281664e40509f_b11ce65960acc0970b4bd1b7dc2292c85b9d4b4e_bundled_cssFiles.css" /><script type="text/css" src="http://media4.dev.myproject.com/typo3temp/js_css_optimizer/_compressed_b8556e54a9173d519e2bf8851b6ec9778fc21495_js_css_optimizer3e8d68f9771f88ee7239129f8ffb85eb0e257769_e720b5b16198fa7190b9c5d8d49e717a98e79a7e_bundled_cssFiles.css" />';
     $source1 = '~/?typo3temp/js_css_optimizer/js_css_optimizer808ed94db016bc2941aa4b6de7f281664e40509f_b11ce65960acc0970b4bd1b7dc2292c85b9d4b4e_bundled_cssFiles\\.css~is';
     $target1 = 'http://media9.dev.myproject.com/typo3temp/js_css_optimizer/js_css_optimizer808ed94db016bc2941aa4b6de7f281664e40509f_b11ce65960acc0970b4bd1b7dc2292c85b9d4b4e_bundled_cssFiles.css';
     $source2 = '~/?typo3temp/js_css_optimizer/_compressed_b8556e54a9173d519e2bf8851b6ec9778fc21495_js_css_optimizer3e8d68f9771f88ee7239129f8ffb85eb0e257769_e720b5b16198fa7190b9c5d8d49e717a98e79a7e_bundled_cssFiles\\.css~is';
     $target2 = 'http://media4.dev.myproject.com/typo3temp/js_css_optimizer/_compressed_b8556e54a9173d519e2bf8851b6ec9778fc21495_js_css_optimizer3e8d68f9771f88ee7239129f8ffb85eb0e257769_e720b5b16198fa7190b9c5d8d49e717a98e79a7e_bundled_cssFiles.css';
     $map = new Tx_Asdis_Content_Replacement_Map();
     $map->addMapping($source1, $target1);
     $map->addMapping($source2, $target2);
     $this->assertEquals($result, $this->processor->replace($map, $content));
 }
Exemplo n.º 4
0
 /**
  * @test
  */
 public function testAll()
 {
     $source1 = 'AAA';
     $target1 = 'BBB';
     $source2 = 'XXX';
     $target2 = 'YYY';
     $this->map->addMapping($source1, $target1);
     $this->map->addMapping($source2, $target2);
     $sources = $this->map->getSources();
     $targets = $this->map->getTargets();
     $this->assertInternalType('array', $sources);
     $this->assertInternalType('array', $targets);
     $this->assertEquals(2, sizeof($sources));
     $this->assertEquals(2, sizeof($targets));
     $this->assertEquals($source1, $sources[0]);
     $this->assertEquals($source2, $sources[1]);
     $this->assertEquals($target1, $targets[0]);
     $this->assertEquals($target2, $targets[1]);
 }