From d8c2f354461f2c37e591af1cca90a8607805ed85 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 26 Apr 2014 16:01:05 +0200 Subject: [PATCH] Added some helper methods --- core/lib/Thelia/Model/Module.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/core/lib/Thelia/Model/Module.php b/core/lib/Thelia/Model/Module.php index eba9b7fbb..7e43912dc 100644 --- a/core/lib/Thelia/Model/Module.php +++ b/core/lib/Thelia/Model/Module.php @@ -162,6 +162,34 @@ class Module extends BaseModule return $this->getAbsoluteTemplateBasePath() .DS. $templateSubdirName; } + /** + * @return true if this module is a delivery module + */ + public function isDeliveryModule() { + $moduleReflection = new \ReflectionClass($this->getFullNamespace()); + + return $moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface"); + } + + /** + * @return true if this module is a payment module + */ + public function isPayementModule() { + $moduleReflection = new \ReflectionClass($this->getFullNamespace()); + + return $moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface"); + } + + + /** + * @return BaseModule a new module instance. + */ + public function createInstance() { + $moduleClass = new \ReflectionClass($this->getFullNamespace()); + + return $moduleClass->newInstance(); + } + /** * Calculate next position relative to module type */