Quelques nouveaux fichiers et modules en conf
This commit is contained in:
42
local/modules/OrderComment/Config/config.xml
Normal file
42
local/modules/OrderComment/Config/config.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<config xmlns="http://thelia.net/schema/dic/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
<loops>
|
||||
<loop name="order.comment.comment" class="OrderComment\Loop\OrderCommentLoop"/>
|
||||
<loop name="order.comment.session.comment" class="OrderComment\Loop\SessionOrderCommentLoop"/>
|
||||
</loops>
|
||||
|
||||
<forms>
|
||||
<form name="order.comment.form" class="OrderComment\Form\CommentForm" />
|
||||
</forms>
|
||||
|
||||
<services>
|
||||
<service id="order.comment.order.form" class="OrderComment\EventListeners\OrderFormListener">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
<service id="order.comment.order.event" class="OrderComment\EventListeners\OrderEventListener">
|
||||
<argument type="service" id="request_stack" />
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
<hooks>
|
||||
<hook id="order.comment.hook.back" class="OrderComment\Hook\BackHook" scope="request">
|
||||
<tag name="hook.event_listener" type="back" event="order-edit.after-order-product-list" method="onOrderEditAfterOrderProductList"/>
|
||||
<tag name="hook.event_listener" type="back" event="order-edit.bill-bottom" method="onOrderEditBillBottom"/>
|
||||
<tag name="hook.event_listener" type="back" event="order.tab-content" method="onOrderTabContent"/>
|
||||
</hook>
|
||||
<hook id="order.comment.hook.front" class="OrderComment\Hook\FrontHook" scope="request">
|
||||
<tag name="hook.event_listener" type="front" event="cart.bottom" method="onCartBottom"/>
|
||||
<tag name="hook.event_listener" type="front" event="cart.after-javascript-include" method="onCartIncludeJs"/>
|
||||
<tag name="hook.event_listener" type="front" event="order-delivery.form-bottom" method="onDeliveryFormBottom"/>
|
||||
</hook>
|
||||
<hook id="order.comment.hook.pdf" class="OrderComment\Hook\PdfHook" scope="request">
|
||||
<tag name="hook.event_listener" type="pdf" event="delivery.after-summary" method="onDeliveryAfterSummary"/>
|
||||
</hook>
|
||||
</hooks>
|
||||
|
||||
</config>
|
||||
18
local/modules/OrderComment/Config/module.xml
Normal file
18
local/modules/OrderComment/Config/module.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module>
|
||||
<fullnamespace>OrderComment\OrderComment</fullnamespace>
|
||||
<descriptive locale="en_US">
|
||||
<title>Allow customer to add comment to this order</title>
|
||||
</descriptive>
|
||||
<descriptive locale="fr_FR">
|
||||
<title>Permet au client d'ajouter un commentaire à sa commande</title>
|
||||
</descriptive>
|
||||
<version>1.2.3</version>
|
||||
<author>
|
||||
<name>Vincent Lopes-Vicente</name>
|
||||
<email>vlopes@openstudio.fr</email>
|
||||
</author>
|
||||
<type>classic</type>
|
||||
<thelia>2.1.</thelia>
|
||||
<stability>other</stability>
|
||||
</module>
|
||||
11
local/modules/OrderComment/Config/routing.xml
Normal file
11
local/modules/OrderComment/Config/routing.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="ordercomment.set.comment" path="/ordercomment/set/comment">
|
||||
<default key="_controller">OrderComment\Controller\OrderCommentController::setComment</default>
|
||||
</route>
|
||||
|
||||
</routes>
|
||||
13
local/modules/OrderComment/Config/schema.xml
Normal file
13
local/modules/OrderComment/Config/schema.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<database defaultIdMethod="native" name="thelia" namespace="OrderComment\Model">
|
||||
<table name="order_comment">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="order_id" required="true" type="INTEGER" />
|
||||
<column name="comment" required="true" type="LONGVARCHAR" />
|
||||
|
||||
<foreign-key foreignTable="order" name="fk_order_comment_order_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="order_id" />
|
||||
</foreign-key>
|
||||
</table>
|
||||
<external-schema filename="local/config/schema.xml" referenceOnly="true" />
|
||||
</database>
|
||||
27
local/modules/OrderComment/Config/thelia.sql
Normal file
27
local/modules/OrderComment/Config/thelia.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
# This is a fix for InnoDB in MySQL >= 4.1.x
|
||||
# It "suspends judgement" for fkey relationships until are tables are set.
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- order_comment
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `order_comment`;
|
||||
|
||||
CREATE TABLE `order_comment`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`order_id` INTEGER NOT NULL,
|
||||
`comment` TEXT NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `FI_order_comment_order_id` (`order_id`),
|
||||
CONSTRAINT `fk_order_comment_order_id`
|
||||
FOREIGN KEY (`order_id`)
|
||||
REFERENCES `order` (`id`)
|
||||
ON UPDATE RESTRICT
|
||||
ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
# This restores the fkey checks, after having unset them earlier
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace OrderComment\Controller;
|
||||
|
||||
use Front\Front;
|
||||
use OrderComment\Form\CommentForm;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
|
||||
/**
|
||||
* Class OrderCommentController
|
||||
* @package OrderComment\Controller
|
||||
*/
|
||||
class OrderCommentController extends BaseFrontController
|
||||
{
|
||||
public function setComment()
|
||||
{
|
||||
$message = false;
|
||||
$commentForm = new CommentForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($commentForm);
|
||||
$data = $form->getData();
|
||||
$comment = $data['comment'];
|
||||
|
||||
if (!empty($comment)) {
|
||||
$this->getRequest()->getSession()->set('order-comment', $comment);
|
||||
}
|
||||
|
||||
return $this->generateRedirectFromRoute("order.delivery");
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = Translator::getInstance()->trans("Please check your input: %s", ['%s' => $e->getMessage()], Front::MESSAGE_DOMAIN);
|
||||
} catch (PropelException $e) {
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = Translator::getInstance()->trans("Sorry, an error occurred: %s", ['%s' => $e->getMessage()], Front::MESSAGE_DOMAIN);
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
$commentForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($commentForm)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
|
||||
return $this->generateRedirectFromRoute("cart.view");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace OrderComment\EventListeners;
|
||||
|
||||
use OrderComment\Model\OrderComment;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
class OrderEventListener implements EventSubscriberInterface
|
||||
{
|
||||
/** @var RequestStack */
|
||||
protected $requestStack;
|
||||
|
||||
|
||||
public function __construct(RequestStack $requestStack)
|
||||
{
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::ORDER_AFTER_CREATE => array('onOrderCreate', 128),
|
||||
TheliaEvents::ORDER_SET_DELIVERY_MODULE => array('onOrderSetDeliveryModule', 128),
|
||||
);
|
||||
}
|
||||
|
||||
public function onOrderSetDeliveryModule(OrderEvent $event)
|
||||
{
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
$form = $request->request->get(OrderFormListener::THELIA_ORDER_DELIVERY_FORM_NAME);
|
||||
|
||||
if (is_null($form) or !array_key_exists(OrderFormListener::ORDER_COMMENT_FORM_FIELD_NAME, $form)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$comment = $form[OrderFormListener::ORDER_COMMENT_FORM_FIELD_NAME];
|
||||
|
||||
if (!empty($comment)) {
|
||||
$request->getSession()->set('order-comment', $comment);
|
||||
}
|
||||
}
|
||||
|
||||
public function onOrderCreate(OrderEvent $event)
|
||||
{
|
||||
$session = $this->requestStack->getCurrentRequest()->getSession();
|
||||
$comment = $session->get('order-comment', null);
|
||||
|
||||
$order = $event->getOrder();
|
||||
$orderId = $order->getId();
|
||||
|
||||
if ($orderId != null && !empty($comment)) {
|
||||
$orderComment = new OrderComment();
|
||||
$orderComment->setOrderId($orderId);
|
||||
$orderComment->setComment($comment);
|
||||
$orderComment->save();
|
||||
|
||||
$session->set('order-comment', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace OrderComment\EventListeners;
|
||||
|
||||
use OrderComment\Form\CommentForm;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\TheliaFormEvent;
|
||||
|
||||
class OrderFormListener implements EventSubscriberInterface
|
||||
{
|
||||
/** 'thelia_order_delivery' is the name of the form used to choose delivery (Thelia\Form\OrderDelivery). */
|
||||
const THELIA_ORDER_DELIVERY_FORM_NAME = 'thelia_order_delivery';
|
||||
|
||||
const ORDER_COMMENT_FORM_FIELD_NAME = 'comment';
|
||||
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::FORM_AFTER_BUILD.'.'.self::THELIA_ORDER_DELIVERY_FORM_NAME => array('addCommentFieldForDelivery', 128),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback used to add a comment field to the Thelia's OrderDelivery form.
|
||||
* @param TheliaFormEvent $event
|
||||
*/
|
||||
public function addCommentFieldForDelivery(TheliaFormEvent $event)
|
||||
{
|
||||
CommentForm::addCommentFormField($event->getForm()->getFormBuilder());
|
||||
}
|
||||
}
|
||||
31
local/modules/OrderComment/Form/CommentForm.php
Normal file
31
local/modules/OrderComment/Form/CommentForm.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace OrderComment\Form;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
class CommentForm extends BaseForm
|
||||
{
|
||||
public function buildForm()
|
||||
{
|
||||
self::addCommentFormField($this->formBuilder);
|
||||
}
|
||||
|
||||
public static function addCommentFormField(FormBuilderInterface $formBuilder)
|
||||
{
|
||||
$formBuilder
|
||||
->add(
|
||||
'comment',
|
||||
'textarea',
|
||||
array(
|
||||
'required' => false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "order_comment_form";
|
||||
}
|
||||
}
|
||||
43
local/modules/OrderComment/Hook/BackHook.php
Normal file
43
local/modules/OrderComment/Hook/BackHook.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace OrderComment\Hook;
|
||||
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
|
||||
/**
|
||||
* Class BackHook
|
||||
* @package OrderComment\Hook
|
||||
* @author Etienne Perriere <eperriere@openstudio.fr>
|
||||
*/
|
||||
class BackHook extends BaseHook
|
||||
{
|
||||
public function onOrderEditAfterOrderProductList(HookRenderEvent $event)
|
||||
{
|
||||
$content = $this->render("order-edit.html");
|
||||
$event->add($content);
|
||||
}
|
||||
|
||||
public function onOrderEditBillBottom(HookRenderEvent $event)
|
||||
{
|
||||
$content = $this->render("order-edit.html");
|
||||
$event->add($content);
|
||||
}
|
||||
|
||||
public function onOrderTabContent(HookRenderEvent $event)
|
||||
{
|
||||
$content = $this->render("order-edit.html");
|
||||
$event->add($content);
|
||||
}
|
||||
|
||||
}
|
||||
39
local/modules/OrderComment/Hook/FrontHook.php
Normal file
39
local/modules/OrderComment/Hook/FrontHook.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace OrderComment\Hook;
|
||||
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
|
||||
/**
|
||||
* Class FrontHook
|
||||
* @package OrderComment\Hook
|
||||
* @author Etienne Perriere <eperriere@openstudio.fr>
|
||||
*/
|
||||
class FrontHook extends BaseHook
|
||||
{
|
||||
public function onCartBottom(HookRenderEvent $event)
|
||||
{
|
||||
$event->add($this->render("OrderComment/cart-comment.html"));
|
||||
}
|
||||
|
||||
public function onCartIncludeJs(HookRenderEvent $event)
|
||||
{
|
||||
$event->add(($this->addJS("OrderComment/assets/js/cart-comment-js.js")));
|
||||
}
|
||||
|
||||
public function onDeliveryFormBottom(HookRenderEvent $event)
|
||||
{
|
||||
$event->add($this->render("OrderComment/comment-input.html"));
|
||||
}
|
||||
}
|
||||
35
local/modules/OrderComment/Hook/PdfHook.php
Normal file
35
local/modules/OrderComment/Hook/PdfHook.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace OrderComment\Hook;
|
||||
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
|
||||
/**
|
||||
* Class PdfHook
|
||||
* @package OrderComment\Hook
|
||||
* @author Etienne Perriere <eperriere@openstudio.fr>
|
||||
*/
|
||||
class PdfHook extends BaseHook
|
||||
{
|
||||
|
||||
/**
|
||||
* @param HookRenderEvent $event
|
||||
*/
|
||||
public function onDeliveryAfterSummary(HookRenderEvent $event)
|
||||
{
|
||||
$order_id = intval($event->getArgument('order', null));
|
||||
|
||||
$event->add($this->render('delivery.after-summary.html', ['order_id' => $order_id]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Customer comment' => 'Customer comment',
|
||||
'No comment for this order was defined.' => 'No comment for this order was defined.',
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Customer comment' => 'Commentaire client',
|
||||
'No comment for this order was defined.' => 'Aucun commentaire pour cette commande',
|
||||
);
|
||||
5
local/modules/OrderComment/I18n/en_US.php
Normal file
5
local/modules/OrderComment/I18n/en_US.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return array(
|
||||
'Please check your input: %s' => 'Please check your input: %s',
|
||||
'Sorry, an error occurred: %s' => 'Sorry, an error occurred: %s'
|
||||
);
|
||||
5
local/modules/OrderComment/I18n/fr_FR.php
Normal file
5
local/modules/OrderComment/I18n/fr_FR.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return array(
|
||||
'Please check your input: %s' => 'Veuillez verifier vos données: %s',
|
||||
'Sorry, an error occured: %s' => 'Désolé une erreur est survenue: %s'
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Add your comment' => 'Add your comment',
|
||||
'Continue Shopping' => 'Continue Shopping',
|
||||
'Proceed checkout' => 'Proceed checkout',
|
||||
'Type your message here' => 'Type your message here',
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Add your comment' => 'Ajouter un commentaire',
|
||||
'Continue Shopping' => 'Continuer mes achats',
|
||||
'Proceed checkout' => 'Continuer la commande',
|
||||
'Type your message here' => 'Ecrivez votre commentaire ici',
|
||||
);
|
||||
165
local/modules/OrderComment/LICENSE.txt
Normal file
165
local/modules/OrderComment/LICENSE.txt
Normal file
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
54
local/modules/OrderComment/Loop/OrderCommentLoop.php
Normal file
54
local/modules/OrderComment/Loop/OrderCommentLoop.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace OrderComment\Loop;
|
||||
|
||||
use OrderComment\Model\OrderCommentQuery;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
class OrderCommentLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('order_id', null, true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$orderCommentQuery = OrderCommentQuery::create()->filterByOrderId($this->getOrderId());
|
||||
|
||||
return $orderCommentQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var \OrderComment\Model\OrderComment $orderComment */
|
||||
foreach ($loopResult->getResultDataCollection() as $orderComment) {
|
||||
$loopResultRow = new LoopResultRow($orderComment);
|
||||
|
||||
$loopResultRow->set("ORDER_COMMENT", $orderComment->getComment());
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
36
local/modules/OrderComment/Loop/SessionOrderCommentLoop.php
Normal file
36
local/modules/OrderComment/Loop/SessionOrderCommentLoop.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace OrderComment\Loop;
|
||||
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
class SessionOrderCommentLoop extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
public function buildArray()
|
||||
{
|
||||
$item = ['comment' => $this->request->getSession()->get('order-comment')];
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$item = $loopResult->getResultDataCollection();
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set('ORDER_COMMENT', $item['comment']);
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
public function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection();
|
||||
}
|
||||
}
|
||||
1253
local/modules/OrderComment/Model/Base/OrderComment.php
Normal file
1253
local/modules/OrderComment/Model/Base/OrderComment.php
Normal file
File diff suppressed because it is too large
Load Diff
507
local/modules/OrderComment/Model/Base/OrderCommentQuery.php
Normal file
507
local/modules/OrderComment/Model/Base/OrderCommentQuery.php
Normal file
@@ -0,0 +1,507 @@
|
||||
<?php
|
||||
|
||||
namespace OrderComment\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use OrderComment\Model\OrderComment as ChildOrderComment;
|
||||
use OrderComment\Model\OrderCommentQuery as ChildOrderCommentQuery;
|
||||
use OrderComment\Model\Map\OrderCommentTableMap;
|
||||
use OrderComment\Model\Thelia\Model\Order;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'order_comment' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildOrderCommentQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildOrderCommentQuery orderByOrderId($order = Criteria::ASC) Order by the order_id column
|
||||
* @method ChildOrderCommentQuery orderByComment($order = Criteria::ASC) Order by the comment column
|
||||
*
|
||||
* @method ChildOrderCommentQuery groupById() Group by the id column
|
||||
* @method ChildOrderCommentQuery groupByOrderId() Group by the order_id column
|
||||
* @method ChildOrderCommentQuery groupByComment() Group by the comment column
|
||||
*
|
||||
* @method ChildOrderCommentQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildOrderCommentQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildOrderCommentQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildOrderCommentQuery leftJoinOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the Order relation
|
||||
* @method ChildOrderCommentQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
|
||||
* @method ChildOrderCommentQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
|
||||
*
|
||||
* @method ChildOrderComment findOne(ConnectionInterface $con = null) Return the first ChildOrderComment matching the query
|
||||
* @method ChildOrderComment findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderComment matching the query, or a new ChildOrderComment object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildOrderComment findOneById(int $id) Return the first ChildOrderComment filtered by the id column
|
||||
* @method ChildOrderComment findOneByOrderId(int $order_id) Return the first ChildOrderComment filtered by the order_id column
|
||||
* @method ChildOrderComment findOneByComment(string $comment) Return the first ChildOrderComment filtered by the comment column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildOrderComment objects filtered by the id column
|
||||
* @method array findByOrderId(int $order_id) Return ChildOrderComment objects filtered by the order_id column
|
||||
* @method array findByComment(string $comment) Return ChildOrderComment objects filtered by the comment column
|
||||
*
|
||||
*/
|
||||
abstract class OrderCommentQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \OrderComment\Model\Base\OrderCommentQuery object.
|
||||
*
|
||||
* @param string $dbName The database name
|
||||
* @param string $modelName The phpName of a model, e.g. 'Book'
|
||||
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
|
||||
*/
|
||||
public function __construct($dbName = 'thelia', $modelName = '\\OrderComment\\Model\\OrderComment', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildOrderCommentQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildOrderCommentQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \OrderComment\Model\OrderCommentQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \OrderComment\Model\OrderCommentQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->setModelAlias($modelAlias);
|
||||
}
|
||||
if ($criteria instanceof Criteria) {
|
||||
$query->mergeWith($criteria);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
* Propel uses the instance pool to skip the database if the object exists.
|
||||
* Go fast if the query is untouched.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(12, $con);
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildOrderComment|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = OrderCommentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
if ($con === null) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection(OrderCommentTableMap::DATABASE_NAME);
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|
||||
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|
||||
|| $this->map || $this->having || $this->joins) {
|
||||
return $this->findPkComplex($key, $con);
|
||||
} else {
|
||||
return $this->findPkSimple($key, $con);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key using raw SQL to go fast.
|
||||
* Bypass doSelect() and the object formatter by using generated code.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildOrderComment A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, ORDER_ID, COMMENT FROM order_comment WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
$obj = null;
|
||||
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$obj = new ChildOrderComment();
|
||||
$obj->hydrate($row);
|
||||
OrderCommentTableMap::addInstanceToPool($obj, (string) $key);
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildOrderComment|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
protected function findPkComplex($key, $con)
|
||||
{
|
||||
// As the query uses a PK condition, no limit(1) is necessary.
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKey($key)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find objects by primary key
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(12, 56, 832), $con);
|
||||
* </code>
|
||||
* @param array $keys Primary keys to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
|
||||
*/
|
||||
public function findPks($keys, $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKeys($keys)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by primary key
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
*
|
||||
* @return ChildOrderCommentQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(OrderCommentTableMap::ID, $key, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a list of primary keys
|
||||
*
|
||||
* @param array $keys The list of primary key to use for the query
|
||||
*
|
||||
* @return ChildOrderCommentQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(OrderCommentTableMap::ID, $keys, Criteria::IN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterById(1234); // WHERE id = 1234
|
||||
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
|
||||
* $query->filterById(array('min' => 12)); // WHERE id > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $id The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCommentQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterById($id = null, $comparison = null)
|
||||
{
|
||||
if (is_array($id)) {
|
||||
$useMinMax = false;
|
||||
if (isset($id['min'])) {
|
||||
$this->addUsingAlias(OrderCommentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($id['max'])) {
|
||||
$this->addUsingAlias(OrderCommentTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderCommentTableMap::ID, $id, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the order_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByOrderId(1234); // WHERE order_id = 1234
|
||||
* $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34)
|
||||
* $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByOrder()
|
||||
*
|
||||
* @param mixed $orderId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCommentQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderId($orderId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($orderId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($orderId['min'])) {
|
||||
$this->addUsingAlias(OrderCommentTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($orderId['max'])) {
|
||||
$this->addUsingAlias(OrderCommentTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderCommentTableMap::ORDER_ID, $orderId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the comment column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByComment('fooValue'); // WHERE comment = 'fooValue'
|
||||
* $query->filterByComment('%fooValue%'); // WHERE comment LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $comment The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCommentQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByComment($comment = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($comment)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $comment)) {
|
||||
$comment = str_replace('*', '%', $comment);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderCommentTableMap::COMMENT, $comment, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \OrderComment\Model\Thelia\Model\Order object
|
||||
*
|
||||
* @param \OrderComment\Model\Thelia\Model\Order|ObjectCollection $order The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCommentQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrder($order, $comparison = null)
|
||||
{
|
||||
if ($order instanceof \OrderComment\Model\Thelia\Model\Order) {
|
||||
return $this
|
||||
->addUsingAlias(OrderCommentTableMap::ORDER_ID, $order->getId(), $comparison);
|
||||
} elseif ($order instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(OrderCommentTableMap::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByOrder() only accepts arguments of type \OrderComment\Model\Thelia\Model\Order or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Order relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildOrderCommentQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Order');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Order');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Order relation Order object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \OrderComment\Model\Thelia\Model\OrderQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinOrder($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Order', '\OrderComment\Model\Thelia\Model\OrderQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildOrderComment $orderComment Object to remove from the list of results
|
||||
*
|
||||
* @return ChildOrderCommentQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($orderComment = null)
|
||||
{
|
||||
if ($orderComment) {
|
||||
$this->addUsingAlias(OrderCommentTableMap::ID, $orderComment->getId(), Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the order_comment table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(OrderCommentTableMap::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
$affectedRows += parent::doDeleteAll($con);
|
||||
// Because this db requires some delete cascade/set null emulation, we have to
|
||||
// clear the cached instance *after* the emulation has happened (since
|
||||
// instances get re-added by the select statement contained therein).
|
||||
OrderCommentTableMap::clearInstancePool();
|
||||
OrderCommentTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildOrderComment or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildOrderComment object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public function delete(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(OrderCommentTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(OrderCommentTableMap::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
|
||||
|
||||
OrderCommentTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
OrderCommentTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
} // OrderCommentQuery
|
||||
419
local/modules/OrderComment/Model/Map/OrderCommentTableMap.php
Normal file
419
local/modules/OrderComment/Model/Map/OrderCommentTableMap.php
Normal file
@@ -0,0 +1,419 @@
|
||||
<?php
|
||||
|
||||
namespace OrderComment\Model\Map;
|
||||
|
||||
use OrderComment\Model\OrderComment;
|
||||
use OrderComment\Model\OrderCommentQuery;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\DataFetcher\DataFetcherInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Map\RelationMap;
|
||||
use Propel\Runtime\Map\TableMap;
|
||||
use Propel\Runtime\Map\TableMapTrait;
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the 'order_comment' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* This map class is used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
*/
|
||||
class OrderCommentTableMap extends TableMap
|
||||
{
|
||||
use InstancePoolTrait;
|
||||
use TableMapTrait;
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'OrderComment.Model.Map.OrderCommentTableMap';
|
||||
|
||||
/**
|
||||
* The default database name for this class
|
||||
*/
|
||||
const DATABASE_NAME = 'thelia';
|
||||
|
||||
/**
|
||||
* The table name for this class
|
||||
*/
|
||||
const TABLE_NAME = 'order_comment';
|
||||
|
||||
/**
|
||||
* The related Propel class for this table
|
||||
*/
|
||||
const OM_CLASS = '\\OrderComment\\Model\\OrderComment';
|
||||
|
||||
/**
|
||||
* A class that can be returned by this tableMap
|
||||
*/
|
||||
const CLASS_DEFAULT = 'OrderComment.Model.OrderComment';
|
||||
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 3;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
*/
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 3;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
*/
|
||||
const ID = 'order_comment.ID';
|
||||
|
||||
/**
|
||||
* the column name for the ORDER_ID field
|
||||
*/
|
||||
const ORDER_ID = 'order_comment.ORDER_ID';
|
||||
|
||||
/**
|
||||
* the column name for the COMMENT field
|
||||
*/
|
||||
const COMMENT = 'order_comment.COMMENT';
|
||||
|
||||
/**
|
||||
* The default string format for model objects of the related table
|
||||
*/
|
||||
const DEFAULT_STRING_FORMAT = 'YAML';
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'OrderId', 'Comment', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'comment', ),
|
||||
self::TYPE_COLNAME => array(OrderCommentTableMap::ID, OrderCommentTableMap::ORDER_ID, OrderCommentTableMap::COMMENT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'COMMENT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'order_id', 'comment', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'Comment' => 2, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'comment' => 2, ),
|
||||
self::TYPE_COLNAME => array(OrderCommentTableMap::ID => 0, OrderCommentTableMap::ORDER_ID => 1, OrderCommentTableMap::COMMENT => 2, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'COMMENT' => 2, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'comment' => 2, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, )
|
||||
);
|
||||
|
||||
/**
|
||||
* Initialize the table attributes and columns
|
||||
* Relations are not initialized by this method since they are lazy loaded
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
// attributes
|
||||
$this->setName('order_comment');
|
||||
$this->setPhpName('OrderComment');
|
||||
$this->setClassName('\\OrderComment\\Model\\OrderComment');
|
||||
$this->setPackage('OrderComment.Model');
|
||||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null);
|
||||
$this->addColumn('COMMENT', 'Comment', 'LONGVARCHAR', true, null, null);
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
* Build the RelationMap objects for this table relationships
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('Order', '\\OrderComment\\Model\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT');
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
|
||||
*
|
||||
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
|
||||
* a multi-column primary key, a serialize()d version of the primary key will be returned.
|
||||
*
|
||||
* @param array $row resultset row.
|
||||
* @param int $offset The 0-based offset for reading from the resultset row.
|
||||
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
|
||||
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
|
||||
*/
|
||||
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
// If the PK cannot be derived from the row, return NULL.
|
||||
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the primary key from the DB resultset row
|
||||
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
|
||||
* a multi-column primary key, an array of the primary key columns will be returned.
|
||||
*
|
||||
* @param array $row resultset row.
|
||||
* @param int $offset The 0-based offset for reading from the resultset row.
|
||||
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
|
||||
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
|
||||
*
|
||||
* @return mixed The primary key of the row
|
||||
*/
|
||||
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
|
||||
return (int) $row[
|
||||
$indexType == TableMap::TYPE_NUM
|
||||
? 0 + $offset
|
||||
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the tableMap will make instances of.
|
||||
*
|
||||
* If $withPrefix is true, the returned path
|
||||
* uses a dot-path notation which is translated into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @param boolean $withPrefix Whether or not to return the path with the class name
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass($withPrefix = true)
|
||||
{
|
||||
return $withPrefix ? OrderCommentTableMap::CLASS_DEFAULT : OrderCommentTableMap::OM_CLASS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates an object of the default type or an object that inherit from the default.
|
||||
*
|
||||
* @param array $row row returned by DataFetcher->fetch().
|
||||
* @param int $offset The 0-based offset for reading from the resultset row.
|
||||
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
|
||||
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
|
||||
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return array (OrderComment object, last column rank)
|
||||
*/
|
||||
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
$key = OrderCommentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
|
||||
if (null !== ($obj = OrderCommentTableMap::getInstanceFromPool($key))) {
|
||||
// We no longer rehydrate the object, since this can cause data loss.
|
||||
// See http://www.propelorm.org/ticket/509
|
||||
// $obj->hydrate($row, $offset, true); // rehydrate
|
||||
$col = $offset + OrderCommentTableMap::NUM_HYDRATE_COLUMNS;
|
||||
} else {
|
||||
$cls = OrderCommentTableMap::OM_CLASS;
|
||||
$obj = new $cls();
|
||||
$col = $obj->hydrate($row, $offset, false, $indexType);
|
||||
OrderCommentTableMap::addInstanceToPool($obj, $key);
|
||||
}
|
||||
|
||||
return array($obj, $col);
|
||||
}
|
||||
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @param DataFetcherInterface $dataFetcher
|
||||
* @return array
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(DataFetcherInterface $dataFetcher)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = static::getOMClass(false);
|
||||
// populate the object(s)
|
||||
while ($row = $dataFetcher->fetch()) {
|
||||
$key = OrderCommentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
|
||||
if (null !== ($obj = OrderCommentTableMap::getInstanceFromPool($key))) {
|
||||
// We no longer rehydrate the object, since this can cause data loss.
|
||||
// See http://www.propelorm.org/ticket/509
|
||||
// $obj->hydrate($row, 0, true); // rehydrate
|
||||
$results[] = $obj;
|
||||
} else {
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($row);
|
||||
$results[] = $obj;
|
||||
OrderCommentTableMap::addInstanceToPool($obj, $key);
|
||||
} // if key exists
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param Criteria $criteria object containing the columns to add.
|
||||
* @param string $alias optional table alias
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria, $alias = null)
|
||||
{
|
||||
if (null === $alias) {
|
||||
$criteria->addSelectColumn(OrderCommentTableMap::ID);
|
||||
$criteria->addSelectColumn(OrderCommentTableMap::ORDER_ID);
|
||||
$criteria->addSelectColumn(OrderCommentTableMap::COMMENT);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.ORDER_ID');
|
||||
$criteria->addSelectColumn($alias . '.COMMENT');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this object.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getServiceContainer()->getDatabaseMap(OrderCommentTableMap::DATABASE_NAME)->getTable(OrderCommentTableMap::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TableMap instance to the database for this tableMap class.
|
||||
*/
|
||||
public static function buildTableMap()
|
||||
{
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderCommentTableMap::DATABASE_NAME);
|
||||
if (!$dbMap->hasTable(OrderCommentTableMap::TABLE_NAME)) {
|
||||
$dbMap->addTableObject(new OrderCommentTableMap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a OrderComment or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or OrderComment object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(OrderCommentTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
// rename for clarity
|
||||
$criteria = $values;
|
||||
} elseif ($values instanceof \OrderComment\Model\OrderComment) { // it's a model object
|
||||
// create criteria based on pk values
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else { // it's a primary key, or an array of pks
|
||||
$criteria = new Criteria(OrderCommentTableMap::DATABASE_NAME);
|
||||
$criteria->add(OrderCommentTableMap::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
$query = OrderCommentQuery::create()->mergeWith($criteria);
|
||||
|
||||
if ($values instanceof Criteria) { OrderCommentTableMap::clearInstancePool();
|
||||
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
|
||||
foreach ((array) $values as $singleval) { OrderCommentTableMap::removeInstanceFromPool($singleval);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->delete($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the order_comment table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
return OrderCommentQuery::create()->doDeleteAll($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an INSERT on the database, given a OrderComment or Criteria object.
|
||||
*
|
||||
* @param mixed $criteria Criteria or OrderComment object containing data that is used to create the INSERT statement.
|
||||
* @param ConnectionInterface $con the ConnectionInterface connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($criteria, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(OrderCommentTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($criteria instanceof Criteria) {
|
||||
$criteria = clone $criteria; // rename for clarity
|
||||
} else {
|
||||
$criteria = $criteria->buildCriteria(); // build Criteria from OrderComment object
|
||||
}
|
||||
|
||||
if ($criteria->containsKey(OrderCommentTableMap::ID) && $criteria->keyContainsValue(OrderCommentTableMap::ID) ) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderCommentTableMap::ID.')');
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$query = OrderCommentQuery::create()->mergeWith($criteria);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->beginTransaction();
|
||||
$pk = $query->doInsert($con);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
} // OrderCommentTableMap
|
||||
// This is the static code needed to register the TableMap for this table with the main Propel class.
|
||||
//
|
||||
OrderCommentTableMap::buildTableMap();
|
||||
10
local/modules/OrderComment/Model/OrderComment.php
Normal file
10
local/modules/OrderComment/Model/OrderComment.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace OrderComment\Model;
|
||||
|
||||
use OrderComment\Model\Base\OrderComment as BaseOrderComment;
|
||||
|
||||
class OrderComment extends BaseOrderComment
|
||||
{
|
||||
|
||||
}
|
||||
21
local/modules/OrderComment/Model/OrderCommentQuery.php
Normal file
21
local/modules/OrderComment/Model/OrderCommentQuery.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace OrderComment\Model;
|
||||
|
||||
use OrderComment\Model\Base\OrderCommentQuery as BaseOrderCommentQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'order_comment' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* You should add additional methods to this class to meet the
|
||||
* application requirements. This class will only be generated as
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
*/
|
||||
class OrderCommentQuery extends BaseOrderCommentQuery
|
||||
{
|
||||
|
||||
} // OrderCommentQuery
|
||||
31
local/modules/OrderComment/OrderComment.php
Normal file
31
local/modules/OrderComment/OrderComment.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace OrderComment;
|
||||
|
||||
use OrderComment\Model\OrderCommentQuery;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Install\Database;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
class OrderComment extends BaseModule
|
||||
{
|
||||
public function postActivation(ConnectionInterface $con = null)
|
||||
{
|
||||
try {
|
||||
OrderCommentQuery::create()->findOne();
|
||||
} catch (\Exception $e) {
|
||||
$database = new Database($con->getWrappedConnection());
|
||||
$database->insertSql(null, array(THELIA_ROOT . '/local/modules/OrderComment/Config/thelia.sql'));
|
||||
}
|
||||
}
|
||||
}
|
||||
58
local/modules/OrderComment/Readme.md
Normal file
58
local/modules/OrderComment/Readme.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# OrderComment
|
||||
|
||||
This module allows your customers to write a comment for an order. Then you can find this comment in the order detail page of the backoffice.
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
### Manually
|
||||
|
||||
* Copy the module into ```<thelia_root>/local/modules/``` directory and be sure that the name of the module is OrderComment.
|
||||
* Activate it in your thelia administration panel
|
||||
|
||||
### Composer
|
||||
|
||||
Add it in your main thelia composer.json file
|
||||
|
||||
```
|
||||
composer require thelia/order-comment-module:~1.2
|
||||
```
|
||||
|
||||
## Loop
|
||||
|
||||
OrderCommentLoop : order.comment.comment
|
||||
|
||||
This loop return the comment of an order.
|
||||
|
||||
### Input arguments
|
||||
|
||||
|Argument |Description |
|
||||
|--- |--- |
|
||||
|**order_id** | Unique ID of the order (eg. order_id=5) |
|
||||
|
||||
### Output arguments
|
||||
|
||||
|Variable |Description |
|
||||
|--- |--- |
|
||||
|$ORDER_COMMENT | Content of the comment |
|
||||
|
||||
### Example
|
||||
|
||||
```
|
||||
{ifloop rel="order_comment_loop"}
|
||||
{loop name="order_comment_loop" type="order.comment.comment" order_id="$order_id" }
|
||||
{$ORDER_COMMENT}
|
||||
{/loop}
|
||||
{/ifloop}
|
||||
{elseloop rel="order_comment_loop"}
|
||||
<p class="alert alert-warning">
|
||||
{intl l="No comment for this order was defined." d="ordercomment"}
|
||||
</p>
|
||||
{/elseloop}
|
||||
```
|
||||
|
||||
## Other ?
|
||||
|
||||
It may be convenient to display the comment on the detail page of the customer's order.
|
||||
To do that, uses the loop described previously.
|
||||
11
local/modules/OrderComment/composer.json
Normal file
11
local/modules/OrderComment/composer.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "thelia/order-comment-module",
|
||||
"license": "LGPL-3.0+",
|
||||
"type": "thelia-module",
|
||||
"require": {
|
||||
"thelia/installer": "~1.1"
|
||||
},
|
||||
"extra": {
|
||||
"installer-name": "OrderComment"
|
||||
}
|
||||
}
|
||||
BIN
local/modules/OrderComment/preview.png
Normal file
BIN
local/modules/OrderComment/preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 KiB |
@@ -0,0 +1,19 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">
|
||||
{intl l="Customer comment" d="ordercomment.bo.default"}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{$comment = ''}
|
||||
{loop type="order.comment.comment" name="order_comment_loop" order_id=$order_id}
|
||||
{$comment = $ORDER_COMMENT}
|
||||
{/loop}
|
||||
|
||||
{if $comment}
|
||||
{$comment|nl2br nofilter}
|
||||
{else}
|
||||
{intl l="No comment for this order was defined." d="ordercomment.bo.default"}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
$('#cart > a').slice(-2).remove();
|
||||
@@ -0,0 +1,10 @@
|
||||
{form name="order.comment.form"}
|
||||
<form id="order-comment-form" action="{url path='/ordercomment/set/comment'}" method="post">
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{include file="OrderComment/comment-input.html"}
|
||||
|
||||
<a href="{navigate to="index"}" role="button" class="btn btn-default"><i class="fa fa-chevron-left"></i> {intl l="Continue Shopping"}</a>
|
||||
<button type="submit" class="btn btn-primary pull-right"><i class="fa fa-chevron-right"></i> {intl l="Proceed checkout"}</button>
|
||||
</form>
|
||||
{/form}
|
||||
@@ -0,0 +1,13 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{intl l="Add your comment" d="ordercomment.fo.default"}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
<div id="alert-comment"></div>
|
||||
{form_field form=$form field='comment'}
|
||||
<textarea class="form-control" name="{$name}" placeholder="{intl l='Type your message here' d='ordercomment.fo.default'}">{loop type="order.comment.session.comment" name="session-order-comment" }{ifloop rel="session-order-comment"}{$ORDER_COMMENT}{/ifloop}{/loop}</textarea>
|
||||
{/form_field}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,11 @@
|
||||
{loop type="order.comment.comment" name="order_comment_loop" order_id="$order_id" }
|
||||
<table style="border:1px solid #333; margin:0; padding:0;">
|
||||
<col style="padding: 0mm 3mm;" />
|
||||
<tr>
|
||||
<td class="table-3-module" style="border-left:solid 3px #f6993c;">
|
||||
<strong>{intl l="Message" d="ordercomment.bo.default"}</strong> :<br />
|
||||
{$ORDER_COMMENT|nl2br nofilter}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{/loop}
|
||||
Reference in New Issue
Block a user