Created
July 23, 2014 05:16
-
-
Save cergey-obr/2d8fb7b7491f18052c3a to your computer and use it in GitHub Desktop.
Получить доступ к старому значению поля после того как оно отредактировано
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function onPaymentWaiting(iUmiEventPoint $event) { | |
$object = $event->getRef("object"); | |
// выполняем действия только для определённого типа объектов | |
if($object->getTypeId() == umiObjectTypesCollection::getInstance()->getBaseType('emarket', 'order')) { | |
// объяввим переменную, в которую будем запоминать значение поля до его изменения | |
static $old_status_id = 0; | |
switch ($event->getMode()) { | |
case 'before' : { | |
// запомним старое значение | |
$old_status_id = $object->getValue("status_id"); | |
break; | |
} | |
case 'after' : { | |
// проверим новое значение со старым, которое мы запомнили ранее | |
if ($old_status_id != $object->status_id and $object->status_id == order::getStatusByCode('payment_waiting')) { | |
$object->setValue('payment_choose_token',md5($object->getId().mktime())); | |
$object->commit(); | |
} | |
break; | |
} | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment