oxonlinemoduleversionnotifier.php

Go to the documentation of this file.
00001 <?php
00002 
00015 class oxOnlineModuleVersionNotifier
00016 {
00017 
00019     private $_oCaller = null;
00020 
00022     private $_oModuleList = null;
00023 
00030     public function __construct(oxOnlineModuleVersionNotifierCaller $oCaller, oxModuleList $oModuleList)
00031     {
00032         $this->_oCaller = $oCaller;
00033         $this->_oModuleList = $oModuleList;
00034     }
00035 
00039     public function versionNotify()
00040     {
00041         $oOMNCaller = $this->_getOnlineModuleNotifierCaller();
00042         $oOMNCaller->doRequest($this->_formRequest());
00043     }
00044 
00050     protected function _prepareModulesInformation()
00051     {
00052         $aPreparedModules = array();
00053         $aModules = $this->_getModules();
00054         foreach ($aModules as $oModule) {
00057             $oPreparedModule = new stdClass();
00058             $oPreparedModule->id = $oModule->getId();
00059             $oPreparedModule->version = $oModule->getInfo('version');
00060 
00061             $oPreparedModule->activeInShops = new stdClass();
00062             $oPreparedModule->activeInShops->activeInShop = array();
00063             if ($oModule->isActive()) {
00064                 $oPreparedModule->activeInShops->activeInShop[] = oxRegistry::getConfig()->getShopUrl();
00065             }
00066             $aPreparedModules[] = $oPreparedModule;
00067         }
00068 
00069         return $aPreparedModules;
00070     }
00071 
00077     protected function _formRequest()
00078     {
00079         $oRequestParams = new oxOnlineModulesNotifierRequest();
00080 
00081         $oRequestParams->modules = new stdClass();
00082         $oRequestParams->modules->module = $this->_prepareModulesInformation();
00083 
00084 
00085         return $oRequestParams;
00086     }
00087 
00093     protected function _getOnlineModuleNotifierCaller()
00094     {
00095         return $this->_oCaller;
00096     }
00097 
00103     protected function _getModules()
00104     {
00105         $aModules = $this->_oModuleList->getList();
00106         ksort($aModules);
00107 
00108         return $aModules;
00109     }
00110 }