Esempio n. 1
0
 /**
  * Replaces the assets of the page.
  * To force any replacement, you have to call "scrapeAssets" before.
  *
  * @return void
  */
 public function replaceAssets()
 {
     if (FALSE === $this->configurationProvider->isReplacementEnabled()) {
         return;
     }
     $distributionAlgorithmKey = '';
     try {
         $distributionAlgorithmKey = $this->configurationProvider->getDistributionAlgorithmKey();
     } catch (Exception $e) {
     }
     $distributionAlgorithm = $this->distributionAlgorithmFactory->buildDistributionAlgorithmFromKey($distributionAlgorithmKey);
     $distributionAlgorithm->distribute($this->getAssets(), $this->serverRepository->findAllByPage($this));
     $this->pageObject->content = $this->replacementProcessor->replace($this->assets->getReplacementMap(), $this->pageObject->content);
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function getReplacementMap()
 {
     $collection = new Tx_Asdis_Domain_Model_Asset_Collection();
     $asset1 = new Tx_Asdis_Domain_Model_Asset();
     $asset2 = new Tx_Asdis_Domain_Model_Asset();
     $path1 = 'typo3temp/pics/foo.gif';
     $path2 = 'typo3temp/pics/bar.jpg';
     $asset1->setOriginalPath($path1);
     $asset1->setNormalizedPath($path1);
     $asset2->setOriginalPath($path2);
     $asset2->setNormalizedPath($path2);
     $collection->append($asset1);
     $collection->append($asset2);
     $map = $collection->getReplacementMap();
     $this->assertEquals(2, sizeof($map->getSources()));
     $this->assertEquals(2, sizeof($map->getTargets()));
 }