コード例 #1
0
ファイル: CollectionTest.php プロジェクト: AOEpeople/asdis
 /**
  * @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()));
 }
コード例 #2
0
 /**
  * @test
  */
 public function distribute()
 {
     $assets = new Tx_Asdis_Domain_Model_Asset_Collection();
     $asset1 = new Tx_Asdis_Domain_Model_Asset();
     $asset2 = new Tx_Asdis_Domain_Model_Asset();
     $asset3 = new Tx_Asdis_Domain_Model_Asset();
     $asset1->setOriginalPath('/typo3temp/1.gif');
     $asset2->setOriginalPath('/typo3temp/2.gif');
     $asset3->setOriginalPath('/typo3temp/3.gif');
     $assets->append($asset1);
     $assets->append($asset2);
     $assets->append($asset3);
     $servers = new Tx_Asdis_Domain_Model_Server_Collection();
     $server1 = new Tx_Asdis_Domain_Model_Server();
     $server2 = new Tx_Asdis_Domain_Model_Server();
     $servers->append($server1);
     $servers->append($server2);
     $this->algorithm->distribute($assets, $servers);
     $this->assertEquals('Tx_Asdis_Domain_Model_Server', get_class($asset1->getServer()));
     $this->assertEquals('Tx_Asdis_Domain_Model_Server', get_class($asset2->getServer()));
     $this->assertEquals('Tx_Asdis_Domain_Model_Server', get_class($asset3->getServer()));
 }
コード例 #3
0
ファイル: Url.php プロジェクト: AOEpeople/asdis
 /**
  * @param Tx_Asdis_Domain_Model_Asset $asset
  * @throws Tx_Asdis_Api_Exception_NotEnabledException
  */
 private function distributeAsset(Tx_Asdis_Domain_Model_Asset $asset)
 {
     try {
         if ($this->configurationProvider->isReplacementEnabled()) {
             $collection = new Tx_Asdis_Domain_Model_Asset_Collection();
             $collection->append($asset);
             $distributionAlgorithm = $this->distributionAlgorithmFactory->buildDistributionAlgorithmFromKey($this->configurationProvider->getDistributionAlgorithmKey());
             $distributionAlgorithm->distribute($collection, $this->getServers());
         } else {
             throw new Tx_Asdis_Api_Exception_NotEnabledException(1452171538);
         }
     } catch (Tx_Asdis_System_Configuration_Exception_TypoScriptSettingNotExists $e) {
         throw new Tx_Asdis_Api_Exception_NotEnabledException(1452171530, $e);
     }
 }