oxmodulemetadataagainstshopvalidator.php

Go to the documentation of this file.
00001 <?php
00002 
00010 class oxModuleMetadataAgainstShopValidator implements oxIModuleValidator
00011 {
00012 
00022     public function validate(oxModule $oModule)
00023     {
00024 
00025         $blModuleExtensionsMatchShopInformation = $this->_moduleExtensionsInformationExistsInShop($oModule);
00026         $blModuleInformationMatchShopInformation = $blModuleExtensionsMatchShopInformation
00027                                                    && $this->_moduleFilesInformationExistInShop($oModule);
00028         $blModuleInformationMatchShopInformation = $blModuleInformationMatchShopInformation
00029                                                    && $this->_moduleHasAllExtensions($oModule);
00030         $blModuleInformationMatchShopInformation = $blModuleInformationMatchShopInformation
00031                                                    && $this->_moduleHasAllFiles($oModule);
00032 
00033         return $blModuleInformationMatchShopInformation;
00034     }
00035 
00043     private function _moduleExtensionsInformationExistsInShop(oxModule $oModule)
00044     {
00045         $aModuleExtensions = $oModule->getExtensions();
00046 
00048         $oModuleInstaller = oxNew('oxModuleInstaller');
00049         $aShopInformationAboutModulesExtendedClasses = $oModuleInstaller->getModulesWithExtendedClass();
00050 
00051         foreach ($aModuleExtensions as $sExtendedClassName => $sModuleExtendedClassPath) {
00052             $aExtendedClassInfo = $aShopInformationAboutModulesExtendedClasses[$sExtendedClassName];
00053             if (is_null($aExtendedClassInfo) || !is_array($aExtendedClassInfo)) {
00054                 return false;
00055             }
00056             if (!in_array($sModuleExtendedClassPath, $aExtendedClassInfo)) {
00057                 return false;
00058             }
00059         }
00060 
00061         return true;
00062     }
00063 
00071     private function _moduleFilesInformationExistInShop(oxModule $oModule)
00072     {
00073         $aModuleFiles = $oModule->getFiles();
00074 
00076         $oModuleList = oxNew('oxModuleList');
00077         $aShopInformationAboutModulesFiles = $oModuleList->getModuleFiles();
00078 
00079         $aMissingFiles = array_diff($aModuleFiles, $aShopInformationAboutModulesFiles);
00080 
00081         return (count($aMissingFiles)) === 0;
00082     }
00083 
00091     private function _moduleHasAllExtensions(oxModule $oModule)
00092     {
00093         return true;
00094     }
00095 
00103     private function _moduleHasAllFiles(oxModule $oModule)
00104     {
00105         return true;
00106     }
00107 }