Skip to content

Commit

Permalink
No need to explicitly bind the method
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jul 14, 2020
1 parent 93b8016 commit 582d9d6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/models/LineItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public function defineRules(): array
$purchasable = Craft::$app->getElements()->getElementById($this->purchasableId);
if ($purchasable && !empty($purchasableRules = $purchasable->getLineItemRules($this))) {
foreach ($purchasableRules as $rule) {
$rules[] = $this->_normalizePurchasableRule($rule, $purchasable);
$rules[] = $this->_normalizePurchasableRule($rule);
}
}
}
Expand All @@ -457,14 +457,12 @@ public function defineRules(): array
* Normalizes a purchasable’s validation rule.
*
* @param mixed $rule
* @param PurchasableInterface $purchasable
* @return mixed
*/
private function _normalizePurchasableRule($rule, PurchasableInterface $purchasable)
private function _normalizePurchasableRule($rule)
{
if (isset($rule[1]) && $rule[1] instanceof \Closure) {
$method = $rule[1];
$method->bindTo($purchasable);
$rule[1] = function($attribute, $params, $validator, $current) use($method) {
$method($attribute, $params, $validator, $current);
};
Expand Down

0 comments on commit 582d9d6

Please sign in to comment.