remove some unused variables

This commit is contained in:
Manuel Raynaud
2014-01-22 15:50:40 +01:00
parent 1974d3e3c3
commit 1b2c1d53ac
40 changed files with 82 additions and 182 deletions

View File

@@ -74,7 +74,6 @@ class Attribute extends BaseAction implements EventSubscriberInterface
*/ */
public function update(AttributeUpdateEvent $event) public function update(AttributeUpdateEvent $event)
{ {
$search = AttributeQuery::create();
if (null !== $attribute = AttributeQuery::create()->findPk($event->getAttributeId())) { if (null !== $attribute = AttributeQuery::create()->findPk($event->getAttributeId())) {

View File

@@ -66,7 +66,6 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface
*/ */
public function update(AttributeAvUpdateEvent $event) public function update(AttributeAvUpdateEvent $event)
{ {
$search = AttributeAvQuery::create();
if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId())) { if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId())) {

View File

@@ -42,7 +42,7 @@ class Cache extends BaseAction implements EventSubscriberInterface
$directoryBrowser = new \DirectoryIterator($dir); $directoryBrowser = new \DirectoryIterator($dir);
$fs = new Filesystem(); $fs = new Filesystem();
$fs->remove($dir); $fs->remove($directoryBrowser);
} }

View File

@@ -91,7 +91,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
{ {
if (null !== $cartItemId = $event->getCartItem()) { if (null !== $cartItemId = $event->getCartItem()) {
$cart = $event->getCart(); $cart = $event->getCart();
$cartItem = CartItemQuery::create() CartItemQuery::create()
->filterByCartId($cart->getId()) ->filterByCartId($cart->getId())
->filterById($cartItemId) ->filterById($cartItemId)
->delete(); ->delete();

View File

@@ -58,7 +58,6 @@ class Config extends BaseAction implements EventSubscriberInterface
*/ */
public function setValue(ConfigUpdateEvent $event) public function setValue(ConfigUpdateEvent $event)
{ {
$search = ConfigQuery::create();
if (null !== $config = $search->findPk($event->getConfigId())) { if (null !== $config = $search->findPk($event->getConfigId())) {
@@ -78,7 +77,6 @@ class Config extends BaseAction implements EventSubscriberInterface
*/ */
public function modify(ConfigUpdateEvent $event) public function modify(ConfigUpdateEvent $event)
{ {
$search = ConfigQuery::create();
if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) { if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {

View File

@@ -95,7 +95,6 @@ class Currency extends BaseAction implements EventSubscriberInterface
*/ */
public function setDefault(CurrencyUpdateEvent $event) public function setDefault(CurrencyUpdateEvent $event)
{ {
$search = CurrencyQuery::create();
if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) { if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) {

View File

@@ -74,7 +74,6 @@ class Feature extends BaseAction implements EventSubscriberInterface
*/ */
public function update(FeatureUpdateEvent $event) public function update(FeatureUpdateEvent $event)
{ {
$search = FeatureQuery::create();
if (null !== $feature = FeatureQuery::create()->findPk($event->getFeatureId())) { if (null !== $feature = FeatureQuery::create()->findPk($event->getFeatureId())) {

View File

@@ -66,7 +66,6 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface
*/ */
public function update(FeatureAvUpdateEvent $event) public function update(FeatureAvUpdateEvent $event)
{ {
$search = FeatureAvQuery::create();
if (null !== $feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId())) { if (null !== $feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId())) {

View File

@@ -355,7 +355,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
$delta_x = $delta_y = $border_width = $border_height = 0; $delta_x = $delta_y = $border_width = $border_height = 0;
if ($width_diff > 1 AND $height_diff > 1) { if ($width_diff > 1 && $height_diff > 1) {
$next_width = $width_orig; $next_width = $width_orig;
$next_height = $height_orig; $next_height = $height_orig;

View File

@@ -68,7 +68,6 @@ class Message extends BaseAction implements EventSubscriberInterface
*/ */
public function modify(MessageUpdateEvent $event) public function modify(MessageUpdateEvent $event)
{ {
$search = MessageQuery::create();
if (null !== $message = MessageQuery::create()->findPk($event->getMessageId())) { if (null !== $message = MessageQuery::create()->findPk($event->getMessageId())) {

View File

@@ -334,7 +334,7 @@ class Order extends BaseAction implements EventSubscriberInterface
// Build subject and body // Build subject and body
$message->build($parser, $instance); $message->build($parser, $instance);
$mail = $this->getMailer()->send($instance); $this->getMailer()->send($instance);
} }
} }

View File

@@ -378,7 +378,7 @@ class Product extends BaseAction implements EventSubscriberInterface
*/ */
public function deleteFeatureProductValue(FeatureProductDeleteEvent $event) public function deleteFeatureProductValue(FeatureProductDeleteEvent $event)
{ {
$featureProduct = FeatureProductQuery::create() FeatureProductQuery::create()
->filterByProductId($event->getProductId()) ->filterByProductId($event->getProductId())
->filterByFeatureId($event->getFeatureId()) ->filterByFeatureId($event->getFeatureId())
->delete() ->delete()

View File

@@ -74,7 +74,6 @@ class Template extends BaseAction implements EventSubscriberInterface
*/ */
public function update(TemplateUpdateEvent $event) public function update(TemplateUpdateEvent $event)
{ {
$search = TemplateQuery::create();
if (null !== $template = TemplateQuery::create()->findPk($event->getTemplateId())) { if (null !== $template = TemplateQuery::create()->findPk($event->getTemplateId())) {

View File

@@ -44,7 +44,7 @@ class TheliaConsoleOutput extends ConsoleOutput
foreach ($messages as $message) { foreach ($messages as $message) {
$length = ($strlen($message) > $length) ? $strlen($message) : $length; $length = ($strlen($message) > $length) ? $strlen($message) : $length;
} }
$ouput = array(); $output = array();
foreach ($messages as $message) { foreach ($messages as $message) {
$output[] = "<" . $style . ">" . " " . $message . str_repeat(' ', $length - $strlen($message)) . " </" . $style . ">"; $output[] = "<" . $style . ">" . " " . $message . str_repeat(' ', $length - $strlen($message)) . " </" . $style . ">";
} }

View File

@@ -56,7 +56,7 @@ class UpdateCommand extends ContainerAwareCommand
$update = new Update(); $update = new Update();
try { try {
$updatedVersions = $update->process(); $update->process();
$output->writeln(array( $output->writeln(array(
'', '',
@@ -64,8 +64,6 @@ class UpdateCommand extends ContainerAwareCommand
'' ''
)); ));
} catch (PropelException $e) { } catch (PropelException $e) {
$errorMsg = $e->getMessage();
$output->writeln(array( $output->writeln(array(
'', '',
sprintf('<error>Error during update process with message : %s</error>', $e->getMessage()), sprintf('<error>Error during update process with message : %s</error>', $e->getMessage()),

View File

@@ -40,7 +40,7 @@ class DefinePropel
{ {
$connection = $this->processorConfig["connection"]; $connection = $this->processorConfig["connection"];
return $conf = array( return array(
"dsn" => $connection["dsn"], "dsn" => $connection["dsn"],
"user" => $connection["user"], "user" => $connection["user"],
"password" => $connection["password"], "password" => $connection["password"],

View File

@@ -154,9 +154,6 @@ class BaseAdminController extends BaseController
// Log the problem // Log the problem
$this->adminLogAppend(implode(",", $resources), implode(",", $accesses), "User is not granted for resources %s with accesses %s", implode(", ", $resources), implode(", ", $accesses)); $this->adminLogAppend(implode(",", $resources), implode(",", $accesses), "User is not granted for resources %s with accesses %s", implode(", ", $resources), implode(", ", $accesses));
// Generate the proper response
$response = new Response();
return $this->errorPage($this->getTranslator()->trans("Sorry, you're not allowed to perform this action"), 403); return $this->errorPage($this->getTranslator()->trans("Sorry, you're not allowed to perform this action"), 403);
} }

View File

@@ -278,7 +278,6 @@ class LangController extends BaseAdminController
$data = $form->getData(); $data = $form->getData();
$event = new LangUrlEvent(); $event = new LangUrlEvent();
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$pos= strpos($key, LangUrlForm::LANG_PREFIX);
if (false !== strpos($key, LangUrlForm::LANG_PREFIX)) { if (false !== strpos($key, LangUrlForm::LANG_PREFIX)) {
$event->addUrl(substr($key,strlen(LangUrlForm::LANG_PREFIX)), $value); $event->addUrl(substr($key,strlen(LangUrlForm::LANG_PREFIX)), $value);
} }
@@ -316,8 +315,6 @@ class LangController extends BaseAdminController
{ {
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, array(), AccessManager::UPDATE)) return $response; if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, array(), AccessManager::UPDATE)) return $response;
$error_msg = false;
ConfigQuery::create() ConfigQuery::create()
->filterByName('one_domain_foreach_lang') ->filterByName('one_domain_foreach_lang')
->update(array('Value' => $activate)); ->update(array('Value' => $activate));

View File

@@ -25,6 +25,7 @@ namespace Thelia\Controller\Admin;
use Thelia\Form\AdminLogin; use Thelia\Form\AdminLogin;
use Thelia\Core\Security\Authentication\AdminUsernamePasswordFormAuthenticator; use Thelia\Core\Security\Authentication\AdminUsernamePasswordFormAuthenticator;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\AdminLog; use Thelia\Model\AdminLog;
use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Tools\URL; use Thelia\Tools\URL;
@@ -53,7 +54,7 @@ class SessionController extends BaseAdminController
$this->adminLogAppend("admin", "LOGIN", "Successful token authentication"); $this->adminLogAppend("admin", "LOGIN", "Successful token authentication");
// Update the cookie // Update the cookie
$cookie = $this->createAdminRememberMeCookie($user); $this->createAdminRememberMeCookie($user);
// Render the home page // Render the home page
return $this->render("home"); return $this->render("home");

View File

@@ -38,8 +38,6 @@ class TranslationsController extends BaseAdminController
{ {
protected function renderTemplate() protected function renderTemplate()
{ {
// Find modules
$modules = ModuleQuery::create()->joinI18n($this->getCurrentEditionLocale())->orderByPosition()->find();
// Get related strings, if all input data are here // Get related strings, if all input data are here
$item_to_translate = $this->getRequest()->get('item_to_translate'); $item_to_translate = $this->getRequest()->get('item_to_translate');

View File

@@ -115,7 +115,7 @@ class ViewListener implements EventSubscriberInterface
{ {
$request = $this->container->get('request'); $request = $this->container->get('request');
if (null === $view = $request->attributes->get('_view')) { if (null === $request->attributes->get('_view')) {
$request->attributes->set('_view', $this->findView($request)); $request->attributes->set('_view', $this->findView($request));
} }

View File

@@ -34,11 +34,6 @@ use Symfony\Component\HttpFoundation\Request as BaseRequest;
class Request extends BaseRequest class Request extends BaseRequest
{ {
private $excludeContent = array(
'username',
'password'
);
public function getProductId() public function getProductId()
{ {
return $this->get("product_id"); return $this->get("product_id");

View File

@@ -104,12 +104,8 @@ class SecurityContext
// Check if user's roles matches required roles // Check if user's roles matches required roles
$userRoles = $user->getRoles(); $userRoles = $user->getRoles();
$roleFound = false;
foreach ($userRoles as $role) { foreach ($userRoles as $role) {
if (in_array($role, $roles)) { if (in_array($role, $roles)) {
$roleFound = true;
return true; return true;
} }
} }

View File

@@ -58,8 +58,6 @@ class Argument
public function setValue($value) public function setValue($value)
{ {
$x = $value === null;
if ($value === null) { if ($value === null) {
$this->value = null; $this->value = null;
} else { } else {
@@ -70,7 +68,6 @@ class Argument
$this->value = (string) $value; $this->value = (string) $value;
} }
} }
//$this->value = $value === null ? null : (string) $value;
} }
public static function createAnyTypeArgument($name, $default=null, $mandatory=false, $empty=true) public static function createAnyTypeArgument($name, $default=null, $mandatory=false, $empty=true)

View File

@@ -79,10 +79,6 @@ class Attribute extends BaseI18nLoop implements PropelSearchLoopInterface
{ {
$search = AttributeQuery::create(); $search = AttributeQuery::create();
$backendContext = $this->getBackend_context();
$lang = $this->getLang();
/* manage translations */ /* manage translations */
$this->configureI18nProcessing($search); $this->configureI18nProcessing($search);

View File

@@ -219,9 +219,6 @@ class Document extends BaseI18nLoop implements PropelSearchLoopInterface
if (!is_null($exclude)) if (!is_null($exclude))
$search->filterById($exclude, Criteria::NOT_IN); $search->filterById($exclude, Criteria::NOT_IN);
// Create document processing event
$event = new DocumentEvent($this->request);
return $search; return $search;
} }

View File

@@ -62,12 +62,8 @@ class ProductTemplate extends BaseI18nLoop implements PropelSearchLoopInterface
{ {
$search = TemplateQuery::create(); $search = TemplateQuery::create();
$backendContext = $this->getBackend_context();
$lang = $this->getLang();
/* manage translations */ /* manage translations */
$this->configureI18nProcessing($search, $columns = array('NAME')); $this->configureI18nProcessing($search, array('NAME'));
$id = $this->getId(); $id = $this->getId();

View File

@@ -242,7 +242,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
return $this->dataAccess("Lang", $params, $this->request->getSession()->getLang()); return $this->dataAccess("Lang", $params, $this->request->getSession()->getLang());
} }
public function ConfigDataAccess($params, $smarty) public function configDataAccess($params, $smarty)
{ {
$key = $this->getParam($params, 'key', false); $key = $this->getParam($params, 'key', false);
@@ -253,7 +253,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
return ConfigQuery::read($key, $default); return ConfigQuery::read($key, $default);
} }
public function StatsAccess($params, $smarty) public function statsAccess($params, $smarty)
{ {
if (false === array_key_exists("key", $params)) { if (false === array_key_exists("key", $params)) {
throw new \InvalidArgumentException(sprintf("missing key attribute in stats access function")); throw new \InvalidArgumentException(sprintf("missing key attribute in stats access function"));
@@ -459,8 +459,8 @@ class DataAccessFunctions extends AbstractSmartyPlugin
new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'), new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'),
new SmartyPluginDescriptor('function', 'cart', $this, 'cartDataAccess'), new SmartyPluginDescriptor('function', 'cart', $this, 'cartDataAccess'),
new SmartyPluginDescriptor('function', 'order', $this, 'orderDataAccess'), new SmartyPluginDescriptor('function', 'order', $this, 'orderDataAccess'),
new SmartyPluginDescriptor('function', 'config', $this, 'ConfigDataAccess'), new SmartyPluginDescriptor('function', 'config', $this, 'configDataAccess'),
new SmartyPluginDescriptor('function', 'stats', $this, 'StatsAccess'), new SmartyPluginDescriptor('function', 'stats', $this, 'statsAccess'),
); );
} }

View File

@@ -68,7 +68,7 @@ class Cart extends BaseCart
public function getLastCartItemAdded() public function getLastCartItemAdded()
{ {
$items = CartItemQuery::create() return CartItemQuery::create()
->filterByCartId($this->getId()) ->filterByCartId($this->getId())
->orderByCreatedAt(Criteria::DESC) ->orderByCreatedAt(Criteria::DESC)
->findOne() ->findOne()

View File

@@ -61,7 +61,6 @@ class Order extends BaseOrder
$tax = 0; $tax = 0;
/* browse all products */ /* browse all products */
$orderProductIds = array();
foreach($this->getOrderProducts() as $orderProduct) { foreach($this->getOrderProducts() as $orderProduct) {
$taxAmountQuery = OrderProductTaxQuery::create(); $taxAmountQuery = OrderProductTaxQuery::create();

View File

@@ -284,31 +284,4 @@ class URL
strtolower($clean) : strtolower($clean) :
$clean; $clean;
} }
/**
* Genenerate the file part of a rewritten URL from a given baseString, using a view, a view id and a locale
*
* @param $view
* @param $viewId
* @param $viewLocale
* @param $baseString the string to be converted in a valid URL
*
* @return A valid file part URL.
*/
public function generateRewritenUrl($view, $viewId, $viewLocale, $baseString)
{
// Borrowed from http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-them-url-and-filename-safe
// Replace all weird characters with dashes
$string = preg_replace('/[^\w\-~_\.]+/u', '-', $baseString);
// Only allow one dash separator at a time (and make string lowercase)
$cleanString = mb_strtolower(preg_replace('/--+/u', '-', $string), 'UTF-8');
$urlFilePart = $cleanString . ".html";
// TODO :
// check if URL url already exists, and add a numeric suffix, or the like
// insert the URL in the rewriting table
}
} }

View File

@@ -50,7 +50,6 @@ class IntToCombinedIntsListType extends BaseType
return false; return false;
} }
$x = 3;
return true; return true;
} }

View File

@@ -50,7 +50,6 @@ class IntToCombinedStringsListType extends BaseType
return false; return false;
} }
$x = 3;
return true; return true;
} }

View File

@@ -10,7 +10,6 @@ use Thelia\Condition\ConditionCollection;
use Thelia\Coupon\Type\RemoveXAmount; use Thelia\Coupon\Type\RemoveXAmount;
use Thelia\Coupon\Type\RemoveXPercent; use Thelia\Coupon\Type\RemoveXPercent;
require __DIR__ . '/../core/bootstrap.php'; require __DIR__ . '/../core/bootstrap.php';
$thelia = new Thelia\Core\Thelia("dev", true); $thelia = new Thelia\Core\Thelia("dev", true);
@@ -184,7 +183,7 @@ try {
; ;
} }
for($i = 0; $i < 50; $i++) { for ($i = 0; $i < 50; $i++) {
$customer = new Thelia\Model\Customer(); $customer = new Thelia\Model\Customer();
$customer->createOrUpdate( $customer->createOrUpdate(
rand(1,3), rand(1,3),
@@ -227,7 +226,7 @@ try {
//features and features_av //features and features_av
$featureList = array(); $featureList = array();
for($i=0; $i<4; $i++) { for ($i=0; $i<4; $i++) {
$feature = new Thelia\Model\Feature(); $feature = new Thelia\Model\Feature();
$feature->setVisible(1); $feature->setVisible(1);
$feature->setPosition($i); $feature->setPosition($i);
@@ -237,7 +236,7 @@ try {
$featureId = $feature->getId(); $featureId = $feature->getId();
$featureList[$featureId] = array(); $featureList[$featureId] = array();
for($j=0; $j<rand(-2, 5); $j++) { //let a chance for no av for ($j=0; $j<rand(-2, 5); $j++) { //let a chance for no av
$featureAv = new Thelia\Model\FeatureAv(); $featureAv = new Thelia\Model\FeatureAv();
$featureAv->setFeature($feature); $featureAv->setFeature($feature);
$featureAv->setPosition($j); $featureAv->setPosition($j);
@@ -252,7 +251,7 @@ try {
//attributes and attributes_av //attributes and attributes_av
$attributeList = array(); $attributeList = array();
for($i=0; $i<4; $i++) { for ($i=0; $i<4; $i++) {
$attribute = new Thelia\Model\Attribute(); $attribute = new Thelia\Model\Attribute();
$attribute->setPosition($i); $attribute->setPosition($i);
setI18n($faker, $attribute); setI18n($faker, $attribute);
@@ -261,7 +260,7 @@ try {
$attributeId = $attribute->getId(); $attributeId = $attribute->getId();
$attributeList[$attributeId] = array(); $attributeList[$attributeId] = array();
for($j=0; $j<rand(1, 5); $j++) { for ($j=0; $j<rand(1, 5); $j++) {
$attributeAv = new Thelia\Model\AttributeAv(); $attributeAv = new Thelia\Model\AttributeAv();
$attributeAv->setAttribute($attribute); $attributeAv->setAttribute($attribute);
$attributeAv->setPosition($j); $attributeAv->setPosition($j);
@@ -278,7 +277,7 @@ try {
setI18n($faker, $template, array("Name" => 20)); setI18n($faker, $template, array("Name" => 20));
$template->save(); $template->save();
foreach($attributeList as $attributeId => $attributeAvId) { foreach ($attributeList as $attributeId => $attributeAvId) {
$at = new Thelia\Model\AttributeTemplate(); $at = new Thelia\Model\AttributeTemplate();
$at $at
@@ -287,7 +286,7 @@ try {
->save(); ->save();
} }
foreach($featureList as $featureId => $featureAvId) { foreach ($featureList as $featureId => $featureAvId) {
$ft = new Thelia\Model\FeatureTemplate(); $ft = new Thelia\Model\FeatureTemplate();
$ft $ft
@@ -300,7 +299,7 @@ try {
//folders and contents //folders and contents
$contentIdList = array(); $contentIdList = array();
for($i=0; $i<4; $i++) { for ($i=0; $i<4; $i++) {
$folder = new Thelia\Model\Folder(); $folder = new Thelia\Model\Folder();
$folder->setParent(0); $folder->setParent(0);
$folder->setVisible(1); $folder->setVisible(1);
@@ -311,13 +310,13 @@ try {
$image = new \Thelia\Model\FolderImage(); $image = new \Thelia\Model\FolderImage();
$image->setFolderId($folder->getId()); $image->setFolderId($folder->getId());
generate_image($image, 1, 'folder', $folder->getId()); generate_image($image, 'folder', $folder->getId());
$document = new \Thelia\Model\FolderDocument(); $document = new \Thelia\Model\FolderDocument();
$document->setFolderId($folder->getId()); $document->setFolderId($folder->getId());
generate_document($document, 1, 'folder', $folder->getId()); generate_document($document, 'folder', $folder->getId());
for($j=0; $j<3; $j++) { for ($j=0; $j<3; $j++) {
$subfolder = new Thelia\Model\Folder(); $subfolder = new Thelia\Model\Folder();
$subfolder->setParent($folder->getId()); $subfolder->setParent($folder->getId());
$subfolder->setVisible(1); $subfolder->setVisible(1);
@@ -328,13 +327,13 @@ try {
$image = new \Thelia\Model\FolderImage(); $image = new \Thelia\Model\FolderImage();
$image->setFolderId($subfolder->getId()); $image->setFolderId($subfolder->getId());
generate_image($image, 1, 'folder', $subfolder->getId()); generate_image($image, 'folder', $subfolder->getId());
$document = new \Thelia\Model\FolderDocument(); $document = new \Thelia\Model\FolderDocument();
$document->setFolderId($folder->getId()); $document->setFolderId($folder->getId());
generate_document($document, 1, 'folder', $subfolder->getId()); generate_document($document, 'folder', $subfolder->getId());
for($k=0; $k<4; $k++) { for ($k=0; $k<4; $k++) {
$content = new Thelia\Model\Content(); $content = new Thelia\Model\Content();
$content->addFolder($subfolder); $content->addFolder($subfolder);
@@ -353,11 +352,11 @@ try {
$image = new \Thelia\Model\ContentImage(); $image = new \Thelia\Model\ContentImage();
$image->setContentId($contentId); $image->setContentId($contentId);
generate_image($image, 1, 'content', $contentId); generate_image($image, 'content', $contentId);
$document = new \Thelia\Model\ContentDocument(); $document = new \Thelia\Model\ContentDocument();
$document->setContentId($contentId); $document->setContentId($contentId);
generate_document($document, 1, 'content', $contentId); generate_document($document, 'content', $contentId);
} }
} }
@@ -368,30 +367,30 @@ try {
//categories and products //categories and products
$productIdList = array(); $productIdList = array();
$categoryIdList = array(); $categoryIdList = array();
for($i=1; $i<5; $i++) { for ($i=1; $i<5; $i++) {
$category = createCategory($faker, 0, $i, $categoryIdList, $contentIdList); $category = createCategory($faker, 0, $i, $categoryIdList, $contentIdList);
for($j=1; $j<rand(0, 5); $j++) { for ($j=1; $j<rand(0, 5); $j++) {
$subcategory = createCategory($faker, $category->getId(), $j, $categoryIdList, $contentIdList); $subcategory = createCategory($faker, $category->getId(), $j, $categoryIdList, $contentIdList);
for($k=0; $k<rand(0, 5); $k++) { for ($k=0; $k<rand(0, 5); $k++) {
createProduct($faker, $subcategory, $k, $template, $productIdList); createProduct($faker, $subcategory, $k, $template, $productIdList);
} }
} }
for($k=1; $k<rand(1, 6); $k++) { for ($k=1; $k<rand(1, 6); $k++) {
createProduct($faker, $category, $k, $template, $productIdList); createProduct($faker, $category, $k, $template, $productIdList);
} }
} }
foreach($productIdList as $productId) { foreach ($productIdList as $productId) {
//add random accessories - or not //add random accessories - or not
$alreadyPicked = array(); $alreadyPicked = array();
for($i=1; $i<rand(0, 4); $i++) { for ($i=1; $i<rand(0, 4); $i++) {
$accessory = new Thelia\Model\Accessory(); $accessory = new Thelia\Model\Accessory();
do { do {
$pick = array_rand($productIdList, 1); $pick = array_rand($productIdList, 1);
} while(in_array($pick, $alreadyPicked)); } while (in_array($pick, $alreadyPicked));
$alreadyPicked[] = $pick; $alreadyPicked[] = $pick;
@@ -403,12 +402,12 @@ try {
//add random associated content //add random associated content
$alreadyPicked = array(); $alreadyPicked = array();
for($i=1; $i<rand(0, 3); $i++) { for ($i=1; $i<rand(0, 3); $i++) {
$productAssociatedContent = new Thelia\Model\ProductAssociatedContent(); $productAssociatedContent = new Thelia\Model\ProductAssociatedContent();
do { do {
$pick = array_rand($contentIdList, 1); $pick = array_rand($contentIdList, 1);
\Thelia\Log\Tlog::getInstance()->debug("pick : $pick"); \Thelia\Log\Tlog::getInstance()->debug("pick : $pick");
} while(in_array($pick, $alreadyPicked)); } while (in_array($pick, $alreadyPicked));
$alreadyPicked[] = $pick; $alreadyPicked[] = $pick;
@@ -419,7 +418,7 @@ try {
} }
//associate PSE and stocks to products //associate PSE and stocks to products
for($i=0; $i<rand(1,7); $i++) { for ($i=0; $i<rand(1,7); $i++) {
$stock = new \Thelia\Model\ProductSaleElements(); $stock = new \Thelia\Model\ProductSaleElements();
$stock->setProductId($productId); $stock->setProductId($productId);
$stock->setRef($productId . '_' . $i . '_' . $faker->randomNumber(8)); $stock->setRef($productId . '_' . $i . '_' . $faker->randomNumber(8));
@@ -441,11 +440,11 @@ try {
//associate attributes - or not - to PSE //associate attributes - or not - to PSE
$alreadyPicked = array(); $alreadyPicked = array();
for($i=0; $i<rand(-2,count($attributeList)); $i++) { for ($i=0; $i<rand(-2,count($attributeList)); $i++) {
$featureProduct = new Thelia\Model\AttributeCombination(); $featureProduct = new Thelia\Model\AttributeCombination();
do { do {
$pick = array_rand($attributeList, 1); $pick = array_rand($attributeList, 1);
} while(in_array($pick, $alreadyPicked)); } while (in_array($pick, $alreadyPicked));
$alreadyPicked[] = $pick; $alreadyPicked[] = $pick;
@@ -457,12 +456,12 @@ try {
} }
//associate features to products //associate features to products
foreach($featureList as $featureId => $featureAvId) { foreach ($featureList as $featureId => $featureAvId) {
$featureProduct = new Thelia\Model\FeatureProduct(); $featureProduct = new Thelia\Model\FeatureProduct();
$featureProduct->setProductId($productId) $featureProduct->setProductId($productId)
->setFeatureId($featureId); ->setFeatureId($featureId);
if(count($featureAvId) > 0) { //got some av if (count($featureAvId) > 0) { //got some av
$featureProduct->setFeatureAvId( $featureProduct->setFeatureAvId(
$featureAvId[array_rand($featureAvId, 1)] $featureAvId[array_rand($featureAvId, 1)]
); );
@@ -537,7 +536,7 @@ function createCategory($faker, $parent, $position, &$categoryIdList, $contentId
$categoryAssociatedContent = new Thelia\Model\CategoryAssociatedContent(); $categoryAssociatedContent = new Thelia\Model\CategoryAssociatedContent();
do { do {
$pick = array_rand($contentIdList, 1); $pick = array_rand($contentIdList, 1);
} while(in_array($pick, $alreadyPicked)); } while (in_array($pick, $alreadyPicked));
$alreadyPicked[] = $pick; $alreadyPicked[] = $pick;
@@ -549,17 +548,17 @@ function createCategory($faker, $parent, $position, &$categoryIdList, $contentId
$image = new \Thelia\Model\CategoryImage(); $image = new \Thelia\Model\CategoryImage();
$image->setCategoryId($categoryId); $image->setCategoryId($categoryId);
generate_image($image, 1, 'category', $categoryId); generate_image($image, 'category', $categoryId);
$document = new \Thelia\Model\CategoryDocument(); $document = new \Thelia\Model\CategoryDocument();
$document->setCategoryId($categoryId); $document->setCategoryId($categoryId);
generate_document($document, 1, 'category', $categoryId); generate_document($document, 'category', $categoryId);
return $category; return $category;
} }
function generate_image($image, $position, $typeobj, $id) { function generate_image($image, $typeobj, $id)
{
global $faker; global $faker;
$image $image
@@ -606,8 +605,8 @@ function generate_image($image, $position, $typeobj, $id) {
$image->save($image_file); $image->save($image_file);
} }
function generate_document($document, $position, $typeobj, $id) { function generate_document($document, $typeobj, $id)
{
global $faker; global $faker;
$document $document
@@ -630,10 +629,10 @@ function setI18n($faker, &$object, $fields = array('Title' => 20, 'Description'
{ {
$localeList = $localeList = array('fr_FR', 'en_US', 'es_ES', 'it_IT'); $localeList = $localeList = array('fr_FR', 'en_US', 'es_ES', 'it_IT');
foreach($localeList as $locale) { foreach ($localeList as $locale) {
$object->setLocale($locale); $object->setLocale($locale);
foreach($fields as $name => $length) { foreach ($fields as $name => $length) {
$func = "set".ucfirst(strtolower($name)); $func = "set".ucfirst(strtolower($name));
$object->$func($locale . ' : ' . $faker->text($length)); $object->$func($locale . ' : ' . $faker->text($length));
@@ -709,7 +708,6 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
$coupon1->setIsAvailableOnSpecialOffers(true); $coupon1->setIsAvailableOnSpecialOffers(true);
$coupon1->save(); $coupon1->save();
// Coupons // Coupons
$coupon2 = new Thelia\Model\Coupon(); $coupon2 = new Thelia\Model\Coupon();
$coupon2->setCode('SPRINGBREAK'); $coupon2->setCode('SPRINGBREAK');
@@ -756,7 +754,6 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
$coupon2->setIsAvailableOnSpecialOffers(true); $coupon2->setIsAvailableOnSpecialOffers(true);
$coupon2->save(); $coupon2->save();
// Coupons // Coupons
$coupon3 = new Thelia\Model\Coupon(); $coupon3 = new Thelia\Model\Coupon();
$coupon3->setCode('OLD'); $coupon3->setCode('OLD');

View File

@@ -1,10 +1,4 @@
<?php <?php
use Thelia\Model\ProductImage;
use Thelia\Model\CategoryImage;
use Thelia\Model\FolderImage;
use Thelia\Model\ContentImage;
use Imagine\Image\Color;
use Imagine\Image\Point;
require __DIR__ . '/../core/bootstrap.php'; require __DIR__ . '/../core/bootstrap.php';
@@ -129,7 +123,7 @@ try {
$stmt->execute(); $stmt->execute();
//categories and products //categories and products
for($i=0; $i<100; $i++) { for ($i=0; $i<100; $i++) {
$category = new Thelia\Model\Category(); $category = new Thelia\Model\Category();
$category->setParent(0); $category->setParent(0);
$category->setVisible(1); $category->setVisible(1);
@@ -138,7 +132,7 @@ try {
$category->save(); $category->save();
for($j=0; $j<10; $j++) { for ($j=0; $j<10; $j++) {
$product = new Thelia\Model\Product(); $product = new Thelia\Model\Product();
$product->setRef($category->getId() . '_' . $j . '_' . $faker->randomNumber(8)); $product->setRef($category->getId() . '_' . $j . '_' . $faker->randomNumber(8));
$product->addCategory($category); $product->addCategory($category);
@@ -160,14 +154,13 @@ function setI18n($faker, &$object, $fields = array('Title' => 20, 'Description'
{ {
$localeList = array('fr_FR', 'en_US', 'es_ES', 'it_IT'); $localeList = array('fr_FR', 'en_US', 'es_ES', 'it_IT');
foreach($localeList as $locale) { foreach ($localeList as $locale) {
$object->setLocale($locale); $object->setLocale($locale);
foreach($fields as $name => $length) { foreach ($fields as $name => $length) {
$func = "set$name"; $func = "set$name";
$object->$func($locale . ' : ' . $faker->text($length)); $object->$func($locale . ' : ' . $faker->text($length));
} }
} }
} }

View File

@@ -1,9 +1,4 @@
<?php <?php
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Condition\Implementation\MatchForTotalAmount;
use Thelia\Condition\Implementation\MatchForXArticles;
use Thelia\Condition\Operators;
require __DIR__ . '/../core/bootstrap.php'; require __DIR__ . '/../core/bootstrap.php';
@@ -23,24 +18,24 @@ try {
$options = getopt('f::e::'); $options = getopt('f::e::');
$forceEcotaxFeatureId = $options['f']; $forceEcotaxFeatureId = $options['f'];
if(null !== $forceEcotaxFeatureId && !filter_var($forceEcotaxFeatureId, FILTER_VALIDATE_INT)) { if (null !== $forceEcotaxFeatureId && !filter_var($forceEcotaxFeatureId, FILTER_VALIDATE_INT)) {
exit('[ERROR] bad value for f option\n'); exit('[ERROR] bad value for f option\n');
} }
$forceEcotaxId = $options['e']; $forceEcotaxId = $options['e'];
if(null !== $forceEcotaxId && !filter_var($forceEcotaxId, FILTER_VALIDATE_INT)) { if (null !== $forceEcotaxId && !filter_var($forceEcotaxId, FILTER_VALIDATE_INT)) {
exit('[ERROR] bad value for e option\n'); exit('[ERROR] bad value for e option\n');
} }
echo "Adding Ecotax feature\n"; echo "Adding Ecotax feature\n";
$feature = null; $feature = null;
if(null !== $forceEcotaxFeatureId) { if (null !== $forceEcotaxFeatureId) {
$feature = \Thelia\Model\FeatureQuery::create()->findPk($forceEcotaxFeatureId); $feature = \Thelia\Model\FeatureQuery::create()->findPk($forceEcotaxFeatureId);
if(null === $feature) { if (null === $feature) {
echo "Feature `$forceEcotaxFeatureId` not found\n"; echo "Feature `$forceEcotaxFeatureId` not found\n";
} }
} }
if(null === $feature) { if (null === $feature) {
$feature = new \Thelia\Model\Feature(); $feature = new \Thelia\Model\Feature();
$feature->setVisible(1); $feature->setVisible(1);
$feature->save(); $feature->save();
@@ -51,7 +46,7 @@ try {
->filterByLocale('fr_FR') ->filterByLocale('fr_FR')
->filterByFeature($feature) ->filterByFeature($feature)
->findOne(); ->findOne();
if(null === $fr) { if (null === $fr) {
$fr = new \Thelia\Model\FeatureI18n(); $fr = new \Thelia\Model\FeatureI18n();
$fr->setLocale('fr_FR') $fr->setLocale('fr_FR')
->setFeature($feature); ->setFeature($feature);
@@ -63,7 +58,7 @@ try {
->filterByLocale('en_US') ->filterByLocale('en_US')
->filterByFeature($feature) ->filterByFeature($feature)
->findOne(); ->findOne();
if(null === $us) { if (null === $us) {
$us = new \Thelia\Model\FeatureI18n(); $us = new \Thelia\Model\FeatureI18n();
$us->setLocale('en_US') $us->setLocale('en_US')
->setFeature($feature); ->setFeature($feature);
@@ -74,13 +69,13 @@ try {
echo "Adding ecotax\n"; echo "Adding ecotax\n";
$tax = null; $tax = null;
if(null !== $forceEcotaxId) { if (null !== $forceEcotaxId) {
$tax = \Thelia\Model\TaxQuery::create()->findPk($forceEcotaxId); $tax = \Thelia\Model\TaxQuery::create()->findPk($forceEcotaxId);
if(null === $tax) { if (null === $tax) {
echo "Tax `$forceEcotaxId` not found\n"; echo "Tax `$forceEcotaxId` not found\n";
} }
} }
if(null === $tax) { if (null === $tax) {
$tax = new \Thelia\Model\Tax(); $tax = new \Thelia\Model\Tax();
$tax->setType('FeatureFixAmountTaxType') $tax->setType('FeatureFixAmountTaxType')
->setSerializedRequirements( ->setSerializedRequirements(
@@ -94,7 +89,7 @@ try {
->filterByLocale('fr_FR') ->filterByLocale('fr_FR')
->filterByTax($tax) ->filterByTax($tax)
->findOne(); ->findOne();
if(null === $fr) { if (null === $fr) {
$fr = new \Thelia\Model\TaxI18n(); $fr = new \Thelia\Model\TaxI18n();
$fr->setLocale('fr_FR') $fr->setLocale('fr_FR')
->setTax($tax); ->setTax($tax);
@@ -106,7 +101,7 @@ try {
->filterByLocale('en_US') ->filterByLocale('en_US')
->filterByTax($tax) ->filterByTax($tax)
->findOne(); ->findOne();
if(null === $us) { if (null === $us) {
$us = new \Thelia\Model\TaxI18n(); $us = new \Thelia\Model\TaxI18n();
$us->setLocale('en_US') $us->setLocale('en_US')
->setTax($tax); ->setTax($tax);
@@ -121,4 +116,4 @@ try {
} catch (Exception $e) { } catch (Exception $e) {
echo "error : ".$e->getMessage()."\n"; echo "error : ".$e->getMessage()."\n";
$con->rollBack(); $con->rollBack();
} }

View File

@@ -21,10 +21,6 @@
/* */ /* */
/*************************************************************************************/ /*************************************************************************************/
use Thelia\Condition\Implementation\MatchForTotalAmount;
use Thelia\Condition\Implementation\MatchForXArticles;
require __DIR__ . '/../core/bootstrap.php'; require __DIR__ . '/../core/bootstrap.php';
$thelia = new Thelia\Core\Thelia("dev", true); $thelia = new Thelia\Core\Thelia("dev", true);
@@ -45,7 +41,6 @@ try {
$stmt = $con->prepare("SET foreign_key_checks = 1"); $stmt = $con->prepare("SET foreign_key_checks = 1");
$stmt->execute(); $stmt->execute();
$categories = createCategories($con); $categories = createCategories($con);
$color = createColors($con); $color = createColors($con);
$brand = createBrand($con); $brand = createBrand($con);
@@ -76,8 +71,6 @@ try {
createProduct($faker, $categories, $template, $color, $brand, $con); createProduct($faker, $categories, $template, $color, $brand, $con);
$con->commit(); $con->commit();
} catch (Exception $e) { } catch (Exception $e) {
echo "error : ".$e->getMessage()."\n"; echo "error : ".$e->getMessage()."\n";
@@ -101,15 +94,14 @@ function createProduct($faker, $categories, $template, $attribute, $feature, $co
->setTaxRuleId(1) ->setTaxRuleId(1)
->setTemplate($template) ->setTemplate($template)
; ;
foreach($productCategories as $productCategory) { foreach ($productCategories as $productCategory) {
$productCategory = trim($productCategory); $productCategory = trim($productCategory);
if(array_key_exists($productCategory, $categories)) { if (array_key_exists($productCategory, $categories)) {
$product->addCategory($categories[$productCategory]); $product->addCategory($categories[$productCategory]);
} }
} }
$product $product
->setLocale('en_US') ->setLocale('en_US')
->setTitle($data[1]) ->setTitle($data[1])
@@ -145,14 +137,13 @@ function createProduct($faker, $categories, $template, $attribute, $feature, $co
$pses = explode(";", $data[12]); $pses = explode(";", $data[12]);
foreach ($pses as $pse) { foreach ($pses as $pse) {
if(empty($pse)) continue; if(empty($pse)) continue;
$stock = new \Thelia\Model\ProductSaleElements(); $stock = new \Thelia\Model\ProductSaleElements();
$stock->setProduct($product); $stock->setProduct($product);
$stock->setRef($product->getId() . '_' . uniqid('', true)); $stock->setRef($product->getId() . '_' . uniqid('', true));
$stock->setQuantity($faker->randomNumber(1,50)); $stock->setQuantity($faker->randomNumber(1,50));
if(!empty($data[9])) { if (!empty($data[9])) {
$stock->setPromo(1); $stock->setPromo(1);
} else { } else {
$stock->setPromo(0); $stock->setPromo(0);
@@ -198,8 +189,6 @@ function createProduct($faker, $categories, $template, $attribute, $feature, $co
->save($con) ->save($con)
; ;
} }
} }
echo "end creating products\n"; echo "end creating products\n";
@@ -261,6 +250,7 @@ function createCategories($con)
fclose($handle); fclose($handle);
} }
echo "categories created successfully\n"; echo "categories created successfully\n";
return $categories; return $categories;
} }
@@ -293,6 +283,7 @@ function createColors($con)
fclose($handle); fclose($handle);
} }
echo "colors attributes created with success\n"; echo "colors attributes created with success\n";
return $attribute; return $attribute;
} }
@@ -362,7 +353,6 @@ function clearTables($con)
->find($con); ->find($con);
$product->delete($con); $product->delete($con);
$accessory = Thelia\Model\AccessoryQuery::create() $accessory = Thelia\Model\AccessoryQuery::create()
->find($con); ->find($con);
$accessory->delete($con); $accessory->delete($con);
@@ -376,4 +366,4 @@ function clearTables($con)
$productPrice->delete($con); $productPrice->delete($con);
\Thelia\Model\ProductImageQuery::create()->find($con)->delete($con); \Thelia\Model\ProductImageQuery::create()->find($con)->delete($con);
} }

View File

@@ -1,7 +1,4 @@
<?php <?php
use Thelia\Condition\Implementation\MatchForTotalAmount;
use Thelia\Condition\Implementation\MatchForXArticles;
use Imagine\Image\Point;
require __DIR__ . '/../core/bootstrap.php'; require __DIR__ . '/../core/bootstrap.php';
@@ -93,7 +90,7 @@ try {
->setPosition(3) ->setPosition(3)
->save(); ->save();
foreach(\Thelia\Model\ProductQuery::create()->find() as $productActiveRecord) { foreach (\Thelia\Model\ProductQuery::create()->find() as $productActiveRecord) {
$productActiveRecord->setTaxRule($taxRule) $productActiveRecord->setTaxRule($taxRule)
->save(); ->save();
} }

View File

@@ -1,5 +1,5 @@
<?php <?php
use Thelia\Core\HttpKernel\HttpCache\HttpCache; //use Thelia\Core\HttpKernel\HttpCache\HttpCache;
use Thelia\Core\Thelia; use Thelia\Core\Thelia;
use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Request;

View File

@@ -31,8 +31,7 @@ if($_REQUEST['lang']){
$_SESSION['install']['lang'] = $_REQUEST['lang']; $_SESSION['install']['lang'] = $_REQUEST['lang'];
} }
$trans = new Translator(); $trans = new Translator($_SESSION['install']['lang']);
$trans->setLocale($_SESSION['install']['lang']);
$trans->addLoader("php", new Symfony\Component\Translation\Loader\PhpFileLoader()); $trans->addLoader("php", new Symfony\Component\Translation\Loader\PhpFileLoader());
$trans->addResource('php', __DIR__.'/I18n/'.$_SESSION['install']['lang'].'.php', $_SESSION['install']['lang']); $trans->addResource('php', __DIR__.'/I18n/'.$_SESSION['install']['lang'].'.php', $_SESSION['install']['lang']);