From 2b1c48be6018a65d3324bf285f7da82077af255d Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Fri, 11 Sep 2015 03:35:33 +0900 Subject: [PATCH] set AntiCsrf on post construct --- src/AbstractAuraForm.php | 3 +++ src/AbstractForm.php | 3 +++ src/SetAntiCsrfTrait.php | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/AbstractAuraForm.php b/src/AbstractAuraForm.php index 9890f78..3886744 100644 --- a/src/AbstractAuraForm.php +++ b/src/AbstractAuraForm.php @@ -46,6 +46,9 @@ public function __construct() public function postConstruct() { $this->init(); + if ($this->antiCsrf instanceof AntiCsrfInterface) { + $this->setAntiCsrf($this->antiCsrf); + } } /** diff --git a/src/AbstractForm.php b/src/AbstractForm.php index 212c42e..7ac4998 100644 --- a/src/AbstractForm.php +++ b/src/AbstractForm.php @@ -54,6 +54,9 @@ public function __construct() public function postConstruct() { $this->init(); + if ($this->antiCsrf instanceof AntiCsrfInterface) { + $this->setAntiCsrf($this->antiCsrf); + } } /** diff --git a/src/SetAntiCsrfTrait.php b/src/SetAntiCsrfTrait.php index b70d636..528b0db 100644 --- a/src/SetAntiCsrfTrait.php +++ b/src/SetAntiCsrfTrait.php @@ -10,6 +10,11 @@ trait SetAntiCsrfTrait { + /** + * @var AntiCsrfInterface + */ + protected $antiCsrf; + /** * @param AntiCsrfInterface $antiCsrf * @@ -17,6 +22,6 @@ trait SetAntiCsrfTrait */ public function injectAntiCsrf(AntiCsrfInterface $antiCsrf) { - $this->setAntiCsrf($antiCsrf); + $this->antiCsrf = $antiCsrf; } }