fix cs
This commit is contained in:
@@ -53,10 +53,9 @@ abstract class BaseModule extends ContainerAware
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function activate($moduleModel = null)
|
||||
{
|
||||
if(null === $moduleModel) {
|
||||
if (null === $moduleModel) {
|
||||
$moduleModel = $this->getModuleModel();
|
||||
}
|
||||
|
||||
@@ -64,7 +63,7 @@ abstract class BaseModule extends ContainerAware
|
||||
$con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
try {
|
||||
if($this->preActivation($con)) {
|
||||
if ($this->preActivation($con)) {
|
||||
$moduleModel->setActivate(self::IS_ACTIVATED);
|
||||
$moduleModel->save($con);
|
||||
$this->postActivation($con);
|
||||
@@ -79,14 +78,14 @@ abstract class BaseModule extends ContainerAware
|
||||
|
||||
public function deActivate($moduleModel = null)
|
||||
{
|
||||
if(null === $moduleModel) {
|
||||
if (null === $moduleModel) {
|
||||
$moduleModel = $this->getModuleModel();
|
||||
}
|
||||
if ($moduleModel->getActivate() == self::IS_ACTIVATED) {
|
||||
$con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
try {
|
||||
if($this->preDeactivation($con)) {
|
||||
if ($this->preDeactivation($con)) {
|
||||
$moduleModel->setActivate(self::IS_NOT_ACTIVATED);
|
||||
$moduleModel->save($con);
|
||||
$this->postDeactivation($con);
|
||||
@@ -215,7 +214,6 @@ abstract class BaseModule extends ContainerAware
|
||||
return $moduleModel;
|
||||
}
|
||||
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
if (null === $this->reflected) {
|
||||
@@ -225,8 +223,8 @@ abstract class BaseModule extends ContainerAware
|
||||
return basename(dirname($this->reflected->getFileName()));
|
||||
}
|
||||
|
||||
public function install(){
|
||||
|
||||
public function install()
|
||||
{
|
||||
}
|
||||
|
||||
public function preActivation(ConnectionInterface $con = null)
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace Thelia\Module\Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Class InvalidXmlDocumentException
|
||||
* @package Thelia\Module\Exception
|
||||
@@ -32,4 +31,4 @@ namespace Thelia\Module\Exception;
|
||||
class InvalidXmlDocumentException extends \RuntimeException
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,12 @@
|
||||
namespace Thelia\Module;
|
||||
use Thelia\Module\Exception\InvalidXmlDocumentException;
|
||||
|
||||
|
||||
/**
|
||||
* Class ModuleDescriptorValidator
|
||||
* @package Thelia\Module
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ModuleDescriptorValidator
|
||||
class ModuleDescriptorValidator
|
||||
{
|
||||
private $xsd_file;
|
||||
|
||||
@@ -44,7 +43,7 @@ class ModuleDescriptorValidator
|
||||
$dom = new \DOMDocument();
|
||||
|
||||
if ($dom->load($xml_file)) {
|
||||
if($dom->schemaValidate($this->xsd_file)) {
|
||||
if ($dom->schemaValidate($this->xsd_file)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -52,9 +51,10 @@ class ModuleDescriptorValidator
|
||||
throw new InvalidXmlDocumentException(sprintf("%s file is not a valid file", $xml_file));
|
||||
}
|
||||
|
||||
public function getDescriptor($xml_file) {
|
||||
public function getDescriptor($xml_file)
|
||||
{
|
||||
$this->validate($xml_file);
|
||||
|
||||
return @simplexml_load_file($xml_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,13 +32,12 @@ use Thelia\Model\Module;
|
||||
use Thelia\Model\ModuleI18n;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class ModuleManagement
|
||||
* @package Thelia\Module
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ModuleManagement
|
||||
class ModuleManagement
|
||||
{
|
||||
protected $baseModuleDir;
|
||||
protected $reflected;
|
||||
@@ -59,16 +58,16 @@ class ModuleManagement
|
||||
$descriptorValidator = new ModuleDescriptorValidator();
|
||||
foreach ($finder as $file) {
|
||||
$content = $descriptorValidator->getDescriptor($file->getRealPath());
|
||||
$reflected = new \ReflectionClass((string)$content->fullnamespace);
|
||||
$reflected = new \ReflectionClass((string) $content->fullnamespace);
|
||||
$code = basename(dirname($reflected->getFileName()));
|
||||
if(null === ModuleQuery::create()->filterByCode($code)->findOne()) {
|
||||
if (null === ModuleQuery::create()->filterByCode($code)->findOne()) {
|
||||
$module = new Module();
|
||||
$con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
try {
|
||||
$module
|
||||
->setCode($code)
|
||||
->setFullNamespace((string)$content->fullnamespace)
|
||||
->setFullNamespace((string) $content->fullnamespace)
|
||||
->setType($this->getModuleType($reflected))
|
||||
->setActivate(0)
|
||||
->save($con);
|
||||
@@ -76,7 +75,7 @@ class ModuleManagement
|
||||
$this->saveDescription($module, $content, $con);
|
||||
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
@@ -88,8 +87,7 @@ class ModuleManagement
|
||||
private function saveDescription(Module $module,\SimpleXMLElement $content, ConnectionInterface $con)
|
||||
{
|
||||
|
||||
foreach($content->descriptive as $description)
|
||||
{
|
||||
foreach ($content->descriptive as $description) {
|
||||
$locale = $description->attributes()->locale;
|
||||
|
||||
$moduleI18n = new ModuleI18n();
|
||||
@@ -107,15 +105,14 @@ class ModuleManagement
|
||||
|
||||
private function getModuleType(\ReflectionClass $reflected)
|
||||
{
|
||||
if($reflected->implementsInterface('Thelia\Module\DeliveryModuleInterface')) {
|
||||
if ($reflected->implementsInterface('Thelia\Module\DeliveryModuleInterface')) {
|
||||
return BaseModule::DELIVERY_MODULE_TYPE;
|
||||
} else if($reflected->implementsInterface('Thelia\Module\PaymentModuleInterface')) {
|
||||
} elseif ($reflected->implementsInterface('Thelia\Module\PaymentModuleInterface')) {
|
||||
return BaseModule::PAYMENT_MODULE_TYPE;
|
||||
} else {
|
||||
return BaseModule::CLASSIC_MODULE_TYPE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user