Merge branch 'master' of github.com:thelia/thelia
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -104,6 +104,24 @@ class CustomerController extends BaseFrontController
|
||||
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent);
|
||||
|
||||
$newCustomer = $customerCreateEvent->getCustomer();
|
||||
|
||||
// Newsletter
|
||||
if (true === $form->get('newsletter')->getData()) {
|
||||
$newsletterEmail = $newCustomer->getEmail();
|
||||
$nlEvent = new NewsletterEvent($newsletterEmail, $this->getRequest()->getSession()->getLang()->getLocale());
|
||||
$nlEvent->setFirstname($newCustomer->getFirstname());
|
||||
$nlEvent->setLastname($newCustomer->getLastname());
|
||||
|
||||
// Security : Check if this new Email address already exist
|
||||
if (null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterEmail)) {
|
||||
$nlEvent->setId($newsletter->getId());
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_UPDATE, $nlEvent);
|
||||
} else {
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $nlEvent);
|
||||
}
|
||||
}
|
||||
|
||||
$this->processLogin($customerCreateEvent->getCustomer());
|
||||
|
||||
$cart = $this->getCart($this->getRequest());
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -89,6 +89,14 @@ class CustomerCreateForm extends AddressCreateForm
|
||||
"for" => "password_confirmation"
|
||||
)
|
||||
))
|
||||
// Add Newsletter
|
||||
->add("newsletter", "checkbox", array(
|
||||
"label" => Translator::getInstance()->trans('I would like to receive the newsletter or the latest news.'),
|
||||
"label_attr" => array(
|
||||
"for" => "newsletter"
|
||||
),
|
||||
"required" => false
|
||||
))
|
||||
// Add terms & conditions
|
||||
->add("agreed", "checkbox", array(
|
||||
"constraints" => array(
|
||||
|
||||
@@ -55,16 +55,7 @@ class CustomerProfileUpdateForm extends CustomerCreateForm
|
||||
->remove("password")
|
||||
->remove("password_confirm")
|
||||
// Remove Terms & conditions
|
||||
->remove("agreed")
|
||||
|
||||
// Add Newsletter
|
||||
->add("newsletter", "checkbox", array(
|
||||
"label" => Translator::getInstance()->trans('I would like to receive the newsletter or the latest news.'),
|
||||
"label_attr" => array(
|
||||
"for" => "newsletter"
|
||||
),
|
||||
"required" => false
|
||||
));
|
||||
->remove("agreed");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,7 +83,7 @@ class NewsletterForm extends BaseForm
|
||||
{
|
||||
$customer = NewsletterQuery::create()->findOneByEmail($value);
|
||||
if ($customer) {
|
||||
$context->addViolation("You are already subscribed!");
|
||||
$context->addViolation("You are already registered!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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