diff --git a/core/lib/Thelia/Module/Exception/InvalidXmlDocumentException.php b/core/lib/Thelia/Module/Exception/InvalidXmlDocumentException.php new file mode 100644 index 000000000..2d679cfd0 --- /dev/null +++ b/core/lib/Thelia/Module/Exception/InvalidXmlDocumentException.php @@ -0,0 +1,35 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Module\Exception; + + +/** + * Class InvalidXmlDocumentException + * @package Thelia\Module\Exception + * @author Manuel Raynaud + */ +class InvalidXmlDocumentException extends \RuntimeException +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Module/Loader/XmlFileLoader.php b/core/lib/Thelia/Module/ModuleDescriptorValidator.php similarity index 64% rename from core/lib/Thelia/Module/Loader/XmlFileLoader.php rename to core/lib/Thelia/Module/ModuleDescriptorValidator.php index dca9129cf..679373e02 100644 --- a/core/lib/Thelia/Module/Loader/XmlFileLoader.php +++ b/core/lib/Thelia/Module/ModuleDescriptorValidator.php @@ -21,51 +21,40 @@ /* */ /*************************************************************************************/ -namespace Thelia\Module\Loader; -use Symfony\Component\Config\Loader\FileLoader; -use Symfony\Component\Config\Util\XmlUtils; +namespace Thelia\Module; +use Thelia\Module\Exception\InvalidXmlDocumentException; /** - * Class XmlFileLoader - * @package Thelia\Module\Loader + * Class ModuleDescriptorValidator + * @package Thelia\Module * @author Manuel Raynaud */ -class XmlFileLoader extends FileLoader +class ModuleDescriptorValidator { + private $xsd_file; - /** - * Loads a resource. - * - * @param mixed $resource The resource - * @param string $type The resource type - */ - public function load($resource, $type = null) + public function __construct() { - $path = $this->locator->locate($resource); - - $xml = $this->parseFile($path); + $this->xsd_file = __DIR__ . '/schema/module/module.xsd'; } - protected function parseFile($file) + public function validate($xml_file) { - $schema = str_replace('\\', '/',__DIR__.'/schema/module-1.0.xsd'); + $dom = new \DOMDocument(); - $dom = XmlUtils::loadFile($file, $schema); + if ($dom->load($xml_file)) { + if($dom->schemaValidate($this->xsd_file)) { + return true; + } + } - return simplexml_import_dom($dom); + throw new InvalidXmlDocumentException(sprintf("%s file is not a valid file", $xml_file)); } - /** - * Returns true if this class supports the given resource. - * - * @param mixed $resource A resource - * @param string $type The resource type - * - * @return Boolean true if this class supports the given resource, false otherwise - */ - public function supports($resource, $type = null) - { - // TODO: Implement supports() method. + public function getDescriptor($xml_file) { + $this->validate($xml_file); + + return @simplexml_load_file($xml_file); } } \ No newline at end of file diff --git a/core/lib/Thelia/Module/Loader/schema/module/module-1.0.xsd b/core/lib/Thelia/Module/schema/module/module.xsd similarity index 100% rename from core/lib/Thelia/Module/Loader/schema/module/module-1.0.xsd rename to core/lib/Thelia/Module/schema/module/module.xsd diff --git a/local/modules/Cheque/Config/module.xml b/local/modules/Cheque/Config/module.xml index 1ef4340ff..5d2e70301 100755 --- a/local/modules/Cheque/Config/module.xml +++ b/local/modules/Cheque/Config/module.xml @@ -2,23 +2,16 @@ - - Produits factices - - Insertion des produits dans votre site Thelia permettant d'avoir un Thelia de test vite opérationnel. - - + + Cheque + + Cheque\\Cheque 1.1 - - Manuel Raynaud - mraynaud@openstudio.fr - - - - - classique - - 1.5.0 - production - README.TXT - + + Manuel Raynaud + mraynaud@openstudio.fr + + payment + 2.0.0 + alpha