create() публичный статический Метод

public static create ( Order $order ) : OrderEmailNotifier
$order Order
Результат OrderEmailNotifier
 public function setUp()
 {
     parent::setUp();
     Config::inst()->update('Email', 'admin_email', '*****@*****.**');
     $this->order = $this->objFromFixture('Order', 'paid');
     $this->notifier = OrderEmailNotifier::create($this->order);
 }
 /**
  * @param SS_HTTPRequest $request
  */
 public function run($request)
 {
     $email = $request->remaining();
     $params = $request->allParams();
     $url = Director::absoluteURL("dev/{$params['Action']}/{$params['TaskName']}", true);
     echo '<h2>Choose Email</h2>';
     echo '<ul>';
     foreach ($this->previewableEmails as $key => $method) {
         echo '<li><a href="' . $url . '/' . $method . '">' . $method . '</a></li>';
     }
     echo '</ul><hr>';
     if ($email && in_array($email, $this->previewableEmails)) {
         $order = Order::get()->first();
         $notifier = OrderEmailNotifier::create($order)->setDebugMode(true);
         $method = "send{$email}";
         echo $notifier->{$method}();
     } else {
     }
     //this is a little hardcore way of ending the party,
     //but as it's only used for styling, it works for now
     die;
 }
 /**
  * Assign the order to a local variable
  *
  * @param Order $order
  */
 public function __construct(Order $order)
 {
     $this->order = $order;
     $this->notifier = OrderEmailNotifier::create($order);
 }
Пример #4
0
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     //create an OrderStatusLog
     if ($this->flagOrderStatusWrite) {
         $this->flagOrderStatusWrite = false;
         $log = OrderStatusLog::create();
         // populate OrderStatusLog
         $log->Title = _t('ShopEmail.StatusChanged', 'Status for order #{OrderNo} changed to "{OrderStatus}"', '', array('OrderNo' => $this->Reference, 'OrderStatus' => $this->getStatusI18N()));
         $log->Note = _t('ShopEmail.StatusChange' . $this->Status . 'Note');
         $log->OrderID = $this->ID;
         OrderEmailNotifier::create($this)->sendStatusChange($log->Title, $log->Note);
         $log->SentToCustomer = true;
         $this->extend('updateOrderStatusLog', $log);
         $log->write();
     }
 }
 /**
  * Form action handler for CancelOrderForm.
  *
  * Take the order that this was to be change on,
  * and set the status that was requested from
  * the form request data.
  *
  * @param array $data The form request data submitted
  * @param Form  $form The {@link Form} this was submitted on
  */
 public function docancel($data, $form)
 {
     if (self::config()->allow_cancelling && $this->order->canCancel()) {
         $this->order->Status = 'MemberCancelled';
         $this->order->write();
         if (self::config()->email_notification) {
             OrderEmailNotifier::create($this->order)->sendCancelNotification();
         }
         $this->controller->sessionMessage(_t("OrderForm.OrderCancelled", "Order sucessfully cancelled"), 'warning');
         if (Member::currentUser() && ($link = $this->order->Link())) {
             $this->controller->redirect($link);
         } else {
             $this->controller->redirectBack();
         }
     }
 }