Merge branch 'master' into frontend
This commit is contained in:
@@ -15,7 +15,7 @@ define('DS' , DIRECTORY_SEPARATOR);
|
||||
|
||||
$loader = require __DIR__ . "/vendor/autoload.php";
|
||||
|
||||
if (!file_exists(THELIA_ROOT . '/local/config/database.yml') && !defined('THELIA_INSTALL_MODE')) {
|
||||
if (!file_exists(THELIA_CONF_DIR . 'database.yml') && !defined('THELIA_INSTALL_MODE')) {
|
||||
$sapi = php_sapi_name();
|
||||
if (substr($sapi, 0, 3) == 'cli') {
|
||||
define('THELIA_INSTALL_MODE', true);
|
||||
@@ -24,4 +24,4 @@ if (!file_exists(THELIA_ROOT . '/local/config/database.yml') && !defined('THELIA
|
||||
header('location: '.$request->getSchemeAndHttpHost() . '/install');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Thelia\Core\Event\Cache\CacheEvent;
|
||||
use Thelia\Core\Event\Module\ModuleDeleteEvent;
|
||||
use Thelia\Core\Event\Module\ModuleEvent;
|
||||
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Map\ModuleTableMap;
|
||||
@@ -99,6 +100,28 @@ class Module extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ModuleEvent $event
|
||||
*/
|
||||
public function update(ModuleEvent $event)
|
||||
{
|
||||
if (null !== $module = ModuleQuery::create()->findPk($event->getId())) {
|
||||
|
||||
$module
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setChapo($event->getChapo())
|
||||
->setDescription($event->getDescription())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
;
|
||||
|
||||
$module->save();
|
||||
|
||||
$event->setModule($module);
|
||||
}
|
||||
}
|
||||
|
||||
protected function cacheClear()
|
||||
{
|
||||
$cacheEvent = new CacheEvent($this->container->getParameter('kernel.cache_dir'));
|
||||
@@ -130,7 +153,8 @@ class Module extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128),
|
||||
TheliaEvents::MODULE_DELETE => array('delete', 128)
|
||||
TheliaEvents::MODULE_DELETE => array('delete', 128),
|
||||
TheliaEvents::MODULE_UPDATE => array('update', 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,8 +180,8 @@ class Install extends ContainerAwareCommand
|
||||
{
|
||||
$fs = new Filesystem();
|
||||
|
||||
$sampleConfigFile = THELIA_ROOT . "/local/config/database.yml.sample";
|
||||
$configFile = THELIA_ROOT . "/local/config/database.yml";
|
||||
$sampleConfigFile = THELIA_CONF_DIR . "database.yml.sample";
|
||||
$configFile = THELIA_CONF_DIR . "database.yml";
|
||||
|
||||
$fs->copy($sampleConfigFile, $configFile, true);
|
||||
|
||||
|
||||
@@ -122,6 +122,8 @@
|
||||
<form name="thelia.lang.url" class="Thelia\Form\Lang\LangUrlForm"/>
|
||||
|
||||
<form name="thelia.system-logs.configuration" class="Thelia\Form\SystemLogConfigurationForm"/>
|
||||
|
||||
<form name="thelia.admin.module.modification" class="Thelia\Form\ModuleModificationForm"/>
|
||||
</forms>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -925,16 +925,25 @@
|
||||
|
||||
<!-- Modules rule management -->
|
||||
|
||||
<route id="admin.module" path="/admin/configuration/modules">
|
||||
<route id="admin.module" path="/admin/modules">
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.module.toggle-activation" path="/admin/configuration/modules/toggle-activation/{module_id}">
|
||||
<route id="admin.module.update" path="/admin/module/update/{module_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::updateAction</default>
|
||||
<requirement key="module_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.module.save" path="/admin/module/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.module.toggle-activation" path="/admin/modules/toggle-activation/{module_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::toggleActivationAction</default>
|
||||
<requirement key="module_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.module.delete" path="/admin/configuration/modules/delete">
|
||||
<route id="admin.module.delete" path="/admin/modules/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
@@ -23,12 +23,15 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\Module\ModuleEvent;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
|
||||
use Thelia\Core\Event\Module\ModuleDeleteEvent;
|
||||
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Form\ModuleModificationForm;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Module\ModuleManagement;
|
||||
|
||||
/**
|
||||
@@ -36,25 +39,155 @@ use Thelia\Module\ModuleManagement;
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ModuleController extends BaseAdminController
|
||||
class ModuleController extends AbstractCrudController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'module',
|
||||
null,
|
||||
null,
|
||||
|
||||
AdminResources::MODULE,
|
||||
|
||||
null,
|
||||
TheliaEvents::MODULE_UPDATE,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new ModuleModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$event = new ModuleEvent();
|
||||
|
||||
$event->setLocale($formData['locale']);
|
||||
$event->setId($formData['id']);
|
||||
$event->setTitle($formData['title']);
|
||||
$event->setChapo($formData['chapo']);
|
||||
$event->setDescription($formData['description']);
|
||||
$event->setPostscriptum($formData['postscriptum']);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasModule();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
$object->setLocale($this->getCurrentEditionLocale());
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new ModuleModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasModule() ? $event->getModule() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return ModuleQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('module_id'));
|
||||
}
|
||||
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function getViewArguments()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
protected function getRouteArguments($module_id = null)
|
||||
{
|
||||
return array(
|
||||
'module_id' => $module_id === null ? $this->getRequest()->get('module_id') : $module_id,
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render(
|
||||
'modules',
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render('module-edit', array_merge($this->getViewArguments(), $this->getRouteArguments()));
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate($request = null, $country = null)
|
||||
{
|
||||
// We always return to the module edition form
|
||||
$this->redirectToRoute(
|
||||
"admin.module.update",
|
||||
$this->getViewArguments(),
|
||||
$this->getRouteArguments()
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.module"
|
||||
);
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, AccessManager::VIEW)) return $response;
|
||||
|
||||
$modulemanagement = new ModuleManagement();
|
||||
$modulemanagement->updateModules();
|
||||
$moduleManagement = new ModuleManagement();
|
||||
$moduleManagement->updateModules();
|
||||
|
||||
return $this->render("modules");
|
||||
}
|
||||
|
||||
public function updateAction($module_id)
|
||||
{
|
||||
return $this->render("module-edit", array(
|
||||
"module_id" => $module_id
|
||||
));
|
||||
}
|
||||
|
||||
public function toggleActivationAction($module_id)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
@@ -37,6 +37,109 @@ class ModuleEvent extends ActionEvent
|
||||
*/
|
||||
protected $module;
|
||||
|
||||
protected $id;
|
||||
protected $locale;
|
||||
protected $title;
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
|
||||
/**
|
||||
* @param mixed $chapo
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $description
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $postscriptum
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function __construct(Module $module = null)
|
||||
{
|
||||
$this->module = $module;
|
||||
|
||||
@@ -693,8 +693,9 @@ final class TheliaEvents
|
||||
const MODULE_TOGGLE_ACTIVATION = 'thelia.module.toggleActivation';
|
||||
|
||||
/**
|
||||
* sent when a module is deleted
|
||||
* module
|
||||
*/
|
||||
const MODULE_UPDATE = 'thelia.module.update';
|
||||
const MODULE_DELETE = 'thelia.module.delete';
|
||||
|
||||
/**
|
||||
|
||||
@@ -84,7 +84,7 @@ final class AdminResources
|
||||
|
||||
const MESSAGE = "admin.configuration.message";
|
||||
|
||||
const MODULE = "admin.configuration.module";
|
||||
const MODULE = "admin.module";
|
||||
|
||||
const ORDER = "admin.order";
|
||||
|
||||
|
||||
@@ -102,9 +102,9 @@ class FolderPath extends BaseI18nLoop implements ArraySearchLoopInterface
|
||||
if ($folder != null) {
|
||||
|
||||
$results[] = array(
|
||||
"ID" => $result->getId(),
|
||||
"TITLE" => $result->getVirtualColumn('i18n_TITLE'),
|
||||
"URL" => $result->getUrl($this->locale),
|
||||
"ID" => $folder->getId(),
|
||||
"TITLE" => $folder->getVirtualColumn('i18n_TITLE'),
|
||||
"URL" => $folder->getUrl($this->locale),
|
||||
"LOCALE" => $this->locale,
|
||||
);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class TemplateHelper
|
||||
|
||||
public function getActiveFrontTemplate() {
|
||||
return new TemplateDefinition(
|
||||
ConfigQuery::read('active-admin-template', 'default'),
|
||||
ConfigQuery::read('active-front-template', 'default'),
|
||||
TemplateDefinition::FRONT_OFFICE
|
||||
);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ class TemplateHelper
|
||||
*/
|
||||
public function walkDir($directory, $walkMode, Translator $translator, $currentLocale, &$strings) {
|
||||
|
||||
$num_files = 0;
|
||||
$num_texts = 0;
|
||||
|
||||
if ($walkMode == self::WALK_MODE_PHP) {
|
||||
$prefix = '\-\>[\s]*trans[\s]*\(';
|
||||
@@ -155,7 +155,7 @@ class TemplateHelper
|
||||
|
||||
if ($fileInfo->isDot()) continue;
|
||||
|
||||
if ($fileInfo->isDir()) $num_files += $this->walkDir($fileInfo->getPathName(), $walkMode, $translator, $currentLocale, $strings);
|
||||
if ($fileInfo->isDir()) $num_texts += $this->walkDir($fileInfo->getPathName(), $walkMode, $translator, $currentLocale, $strings);
|
||||
|
||||
if ($fileInfo->isFile()) {
|
||||
|
||||
@@ -186,18 +186,19 @@ class TemplateHelper
|
||||
$strings[$hash]['files'][] = $short_path;
|
||||
}
|
||||
}
|
||||
else
|
||||
$num_files++;
|
||||
else {
|
||||
$num_texts++;
|
||||
|
||||
// remove \'
|
||||
$match = str_replace("\\'", "'", $match);
|
||||
// remove \'
|
||||
$match = str_replace("\\'", "'", $match);
|
||||
|
||||
$strings[$hash] = array(
|
||||
'files' => array($short_path),
|
||||
'text' => $match,
|
||||
'translation' => $translator->trans($match, array(), 'messages', $currentLocale, false),
|
||||
'dollar' => strstr($match, '$') !== false
|
||||
);
|
||||
$strings[$hash] = array(
|
||||
'files' => array($short_path),
|
||||
'text' => $match,
|
||||
'translation' => $translator->trans($match, array(), 'messages', $currentLocale, false),
|
||||
'dollar' => strstr($match, '$') !== false
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,7 +206,7 @@ class TemplateHelper
|
||||
}
|
||||
}
|
||||
|
||||
return $num_files;
|
||||
return $num_texts;
|
||||
|
||||
} catch (\UnexpectedValueException $ex) {
|
||||
echo $ex;
|
||||
|
||||
@@ -75,7 +75,7 @@ class Thelia extends Kernel
|
||||
}
|
||||
|
||||
$definePropel = new DefinePropel(new DatabaseConfiguration(),
|
||||
Yaml::parse(THELIA_ROOT . '/local/config/database.yml'));
|
||||
Yaml::parse(THELIA_CONF_DIR . 'database.yml'));
|
||||
$serviceContainer = Propel::getServiceContainer();
|
||||
$serviceContainer->setAdapterClass('thelia', 'mysql');
|
||||
$manager = new ConnectionManagerSingle();
|
||||
|
||||
@@ -215,7 +215,7 @@ class TheliaHttpKernel extends HttpKernel
|
||||
$storage = new Session\Storage\NativeSessionStorage();
|
||||
|
||||
if (Model\ConfigQuery::read("session_config.default")) {
|
||||
$storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_ROOT . '/local/session/')));
|
||||
$storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_LOCAL_DIR . 'session/')));
|
||||
} else {
|
||||
$handlerString = Model\ConfigQuery::read("session_config.handlers", 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler');
|
||||
|
||||
|
||||
75
core/lib/Thelia/Form/ModuleModificationForm.php
Executable file
75
core/lib/Thelia/Form/ModuleModificationForm.php
Executable file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
class ModuleModificationForm extends BaseForm
|
||||
{
|
||||
use StandardDescriptionFieldsTrait;
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->addStandardDescFields();
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array(
|
||||
"required" => true,
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(
|
||||
array(
|
||||
"methods" => array(
|
||||
array($this, "verifyModuleId"),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
"attr" => array(
|
||||
"id" => "module_update_id",
|
||||
),
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_admin_module_modification";
|
||||
}
|
||||
|
||||
public function verifyModuleId($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$module = ModuleQuery::create()
|
||||
->findPk($value);
|
||||
|
||||
if (null === $module) {
|
||||
$context->addViolation("Module ID not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,11 @@ namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Model\Base\Module as BaseModule;
|
||||
use Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
class Module extends BaseModule {
|
||||
class Module extends BaseModule
|
||||
{
|
||||
use ModelEventDispatcherTrait;
|
||||
|
||||
public function postSave(ConnectionInterface $con = null)
|
||||
{
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace Thelia\Module;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Propel;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Model\Map\ModuleTableMap;
|
||||
use Thelia\Model\ModuleI18nQuery;
|
||||
use Thelia\Model\Map\ModuleImageTableMap;
|
||||
@@ -37,7 +39,8 @@ use Thelia\Model\Module;
|
||||
use Thelia\Model\ModuleImage;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
abstract class BaseModule extends ContainerAware
|
||||
|
||||
class BaseModule extends ContainerAware implements BaseModuleInterface
|
||||
{
|
||||
const CLASSIC_MODULE_TYPE = 1;
|
||||
const DELIVERY_MODULE_TYPE = 2;
|
||||
@@ -48,10 +51,8 @@ abstract class BaseModule extends ContainerAware
|
||||
|
||||
protected $reflected;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
protected $dispatcher = null;
|
||||
protected $request = null;
|
||||
|
||||
public function activate($moduleModel = null)
|
||||
{
|
||||
@@ -102,7 +103,7 @@ abstract class BaseModule extends ContainerAware
|
||||
|
||||
public function hasContainer()
|
||||
{
|
||||
return null === $this->container;
|
||||
return null !== $this->container;
|
||||
}
|
||||
|
||||
public function getContainer()
|
||||
@@ -114,6 +115,41 @@ abstract class BaseModule extends ContainerAware
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
|
||||
public function hasRequest() {
|
||||
return null !== $this->request;
|
||||
}
|
||||
|
||||
public function setRequest(Request $request) {
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function getRequest() {
|
||||
if ($this->hasRequest() === false) {
|
||||
throw new \RuntimeException("Sorry, the request is not available in this context");
|
||||
}
|
||||
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
|
||||
public function hasDispatcher() {
|
||||
return null !== $this->dispatcher;
|
||||
}
|
||||
|
||||
public function setDispatcher(EventDispatcherInterface $dispatcher) {
|
||||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
public function getDispatcher() {
|
||||
if ($this->hasDispatcher() === false) {
|
||||
throw new \RuntimeException("Sorry, the dispatcher is not available in this context");
|
||||
}
|
||||
|
||||
return $this->dispatcher;
|
||||
}
|
||||
|
||||
|
||||
public function setTitle(Module $module, $titles)
|
||||
{
|
||||
if (is_array($titles)) {
|
||||
@@ -226,6 +262,7 @@ abstract class BaseModule extends ContainerAware
|
||||
|
||||
public function install(ConnectionInterface $con = null)
|
||||
{
|
||||
// Implement this method to do something useful.
|
||||
}
|
||||
|
||||
public function preActivation(ConnectionInterface $con = null)
|
||||
@@ -235,7 +272,7 @@ abstract class BaseModule extends ContainerAware
|
||||
|
||||
public function postActivation(ConnectionInterface $con = null)
|
||||
{
|
||||
|
||||
// Implement this method to do something useful.
|
||||
}
|
||||
|
||||
public function preDeactivation(ConnectionInterface $con = null)
|
||||
@@ -245,12 +282,11 @@ abstract class BaseModule extends ContainerAware
|
||||
|
||||
public function postDeactivation(ConnectionInterface $con = null)
|
||||
{
|
||||
|
||||
// Implement this method to do something useful.
|
||||
}
|
||||
|
||||
public function destroy(ConnectionInterface $con = null)
|
||||
public function destroy(ConnectionInterface $con = null, $deleteModuleData = false)
|
||||
{
|
||||
|
||||
// Implement this method to do something useful.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,14 +23,21 @@
|
||||
|
||||
namespace Thelia\Module;
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
interface BaseModuleInterface
|
||||
{
|
||||
public function setRequest(Request $request);
|
||||
public function getRequest();
|
||||
public function install(ConnectionInterface $con = null);
|
||||
|
||||
public function setDispatcher(EventDispatcherInterface $dispatcher);
|
||||
public function getDispatcher();
|
||||
public function preActivation(ConnectionInterface $con = null);
|
||||
|
||||
public function postActivation(ConnectionInterface $con = null);
|
||||
|
||||
public function preDeactivation(ConnectionInterface $con = null);
|
||||
|
||||
public function postDeactivation(ConnectionInterface $con = null);
|
||||
|
||||
public function destroy(ConnectionInterface $con = null, $deleteModuleData = false);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ class ModuleActivateCommandTest extends \PHPUnit_Framework_TestCase
|
||||
$module = ModuleQuery::create()->findOne();
|
||||
|
||||
if (null !== $module) {
|
||||
|
||||
$prev_activation_status = $module->getActivate();
|
||||
|
||||
$application = new Application($this->getKernel());
|
||||
|
||||
$module->setActivate(BaseModule::IS_NOT_ACTIVATED);
|
||||
@@ -58,7 +61,12 @@ class ModuleActivateCommandTest extends \PHPUnit_Framework_TestCase
|
||||
"module" => $module->getCode(),
|
||||
));
|
||||
|
||||
$this->assertEquals(BaseModule::IS_ACTIVATED, ModuleQuery::create()->findPk($module->getId())->getActivate());
|
||||
$activated = ModuleQuery::create()->findPk($module->getId())->getActivate();
|
||||
|
||||
// Restore activation status
|
||||
$module->setActivate($prev_activation_status)->save();
|
||||
|
||||
$this->assertEquals(BaseModule::IS_ACTIVATED, $activated);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user