-
-
Save hailwood/f0863d195dba5ad501f6 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 | |
class SomeDataObject extends DataObject | |
{ | |
public function updateQuantity($newQuantity) | |
{ | |
$beforeUpdateQuantity = $this->extend('onBeforeUpdateQuantity', $this, $newQuantity); | |
if ($beforeUpdateQuantity !== null) { | |
return $beforeUpdateQuantity; | |
} | |
$oldQuantity = $this->Quantity; | |
$this->extend('onUpdateQuantity', $this, $oldQuantity, $newQuantity); | |
if (!$newQuantity) { | |
return $this; | |
} | |
$this->Quantity = $newQuantity; | |
$this->write(); | |
$this->extend('onAfterUpdateQuantity', $this, $oldQuantity, $newQuantity); | |
return $this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment