allow token to be null in cart table
This commit is contained in:
@@ -234,12 +234,14 @@ class Cart implements EventSubscriberInterface
|
|||||||
|
|
||||||
protected function generateCookie()
|
protected function generateCookie()
|
||||||
{
|
{
|
||||||
|
$id = null;
|
||||||
if (ConfigQuery::read("cart.session_only", 0) == 0) {
|
if (ConfigQuery::read("cart.session_only", 0) == 0) {
|
||||||
$id = uniqid('', true);
|
$id = uniqid('', true);
|
||||||
setcookie("thelia_cart", $id, time()+ConfigQuery::read("cookie.lifetime", 60*60*24*365));
|
setcookie("thelia_cart", $id, time()+ConfigQuery::read("cookie.lifetime", 60*60*24*365));
|
||||||
|
|
||||||
return $id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $id;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class Customer extends BaseCustomer implements UserInterface
|
|||||||
* @param string $phone customer phone number
|
* @param string $phone customer phone number
|
||||||
* @param string $cellphone customer cellphone number
|
* @param string $cellphone customer cellphone number
|
||||||
* @param string $zipcode customer zipcode
|
* @param string $zipcode customer zipcode
|
||||||
|
* @param string $city
|
||||||
* @param int $countryId customer country id (from Country table)
|
* @param int $countryId customer country id (from Country table)
|
||||||
* @param string $email customer email, must be unique
|
* @param string $email customer email, must be unique
|
||||||
* @param string $plainPassword customer plain password, hash is made calling setPassword method. Not mandatory parameter but an exception is thrown if customer is new without password
|
* @param string $plainPassword customer plain password, hash is made calling setPassword method. Not mandatory parameter but an exception is thrown if customer is new without password
|
||||||
@@ -53,7 +54,7 @@ class Customer extends BaseCustomer implements UserInterface
|
|||||||
* @param null $sponsor
|
* @param null $sponsor
|
||||||
* @param int $discount
|
* @param int $discount
|
||||||
*/
|
*/
|
||||||
public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0)
|
public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $countryId, $email, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0)
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setTitleId($titleId)
|
->setTitleId($titleId)
|
||||||
@@ -79,7 +80,7 @@ class Customer extends BaseCustomer implements UserInterface
|
|||||||
$address = new Address();
|
$address = new Address();
|
||||||
|
|
||||||
$address
|
$address
|
||||||
->setCustomerTitleId($titleId)
|
->setTitleId($titleId)
|
||||||
->setFirstname($firstname)
|
->setFirstname($firstname)
|
||||||
->setLastname($lastname)
|
->setLastname($lastname)
|
||||||
->setAddress1($address1)
|
->setAddress1($address1)
|
||||||
@@ -119,9 +120,15 @@ class Customer extends BaseCustomer implements UserInterface
|
|||||||
return uniqid(substr($this->getLastname(), 0, (strlen($this->getLastname()) >= 3) ? 3 : strlen($this->getLastname())), true);
|
return uniqid(substr($this->getLastname(), 0, (strlen($this->getLastname()) >= 3) ? 3 : strlen($this->getLastname())), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create hash for plain password and set it in Customer object
|
||||||
|
*
|
||||||
|
* @param string $password plain password before hashing
|
||||||
|
* @return $this|Customer
|
||||||
|
* @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
|
||||||
|
*/
|
||||||
public function setPassword($password)
|
public function setPassword($password)
|
||||||
{
|
{
|
||||||
\Thelia\Log\Tlog::getInstance()->debug($password);
|
|
||||||
if ($this->isNew() && ($password === null || trim($password) == "")) {
|
if ($this->isNew() && ($password === null || trim($password) == "")) {
|
||||||
throw new InvalidArgumentException("customer password is mandatory on creation");
|
throw new InvalidArgumentException("customer password is mandatory on creation");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,28 @@ try {
|
|||||||
->find();
|
->find();
|
||||||
$product->delete();
|
$product->delete();
|
||||||
|
|
||||||
|
$customer = Thelia\Model\CustomerQuery::create()
|
||||||
|
->find();
|
||||||
|
$customer->delete();
|
||||||
|
|
||||||
|
$customer = new Thelia\Model\Customer();
|
||||||
|
$customer->createOrUpdate(
|
||||||
|
1,
|
||||||
|
"thelia",
|
||||||
|
"thelia",
|
||||||
|
"5 rue rochon",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"0102030405",
|
||||||
|
"0601020304",
|
||||||
|
"63000",
|
||||||
|
"clermont-ferrand",
|
||||||
|
64,
|
||||||
|
"test@thelia.net",
|
||||||
|
"azerty"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//first category
|
//first category
|
||||||
$sweet = new Thelia\Model\Category();
|
$sweet = new Thelia\Model\Category();
|
||||||
$sweet->setParent(0);
|
$sweet->setParent(0);
|
||||||
|
|||||||
@@ -1271,7 +1271,7 @@ DROP TABLE IF EXISTS `cart`;
|
|||||||
CREATE TABLE `cart`
|
CREATE TABLE `cart`
|
||||||
(
|
(
|
||||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||||
`token` VARCHAR(255) NOT NULL,
|
`token` VARCHAR(255),
|
||||||
`customer_id` INTEGER,
|
`customer_id` INTEGER,
|
||||||
`address_delivery_id` INTEGER,
|
`address_delivery_id` INTEGER,
|
||||||
`address_invoice_id` INTEGER,
|
`address_invoice_id` INTEGER,
|
||||||
|
|||||||
@@ -923,7 +923,7 @@
|
|||||||
</table>
|
</table>
|
||||||
<table name="cart" namespace="Thelia\Model">
|
<table name="cart" namespace="Thelia\Model">
|
||||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||||
<column name="token" required="true" size="255" type="VARCHAR" />
|
<column name="token" size="255" type="VARCHAR" />
|
||||||
<column name="customer_id" type="INTEGER" />
|
<column name="customer_id" type="INTEGER" />
|
||||||
<column name="address_delivery_id" type="INTEGER" />
|
<column name="address_delivery_id" type="INTEGER" />
|
||||||
<column name="address_invoice_id" type="INTEGER" />
|
<column name="address_invoice_id" type="INTEGER" />
|
||||||
@@ -940,9 +940,6 @@
|
|||||||
<foreign-key foreignTable="currency" name="fk_cart_currency_id">
|
<foreign-key foreignTable="currency" name="fk_cart_currency_id">
|
||||||
<reference foreign="id" local="currency_id" />
|
<reference foreign="id" local="currency_id" />
|
||||||
</foreign-key>
|
</foreign-key>
|
||||||
<unique name="token_UNIQUE">
|
|
||||||
<unique-column name="token" />
|
|
||||||
</unique>
|
|
||||||
<index name="idx_cart_customer_id">
|
<index name="idx_cart_customer_id">
|
||||||
<index-column name="customer_id" />
|
<index-column name="customer_id" />
|
||||||
</index>
|
</index>
|
||||||
@@ -955,6 +952,9 @@
|
|||||||
<index name="idx_cart_currency_id">
|
<index name="idx_cart_currency_id">
|
||||||
<index-column name="currency_id" />
|
<index-column name="currency_id" />
|
||||||
</index>
|
</index>
|
||||||
|
<unique name="token_UNIQUE">
|
||||||
|
<unique-column name="token" />
|
||||||
|
</unique>
|
||||||
<behavior name="timestampable" />
|
<behavior name="timestampable" />
|
||||||
</table>
|
</table>
|
||||||
<table name="cart_item" namespace="Thelia\Model">
|
<table name="cart_item" namespace="Thelia\Model">
|
||||||
|
|||||||
Reference in New Issue
Block a user