/** * @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); } }
/** * 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); }