From 54fc386674a383dcb350e451015dd722947e9312 Mon Sep 17 00:00:00 2001 From: chrismichaels84 Date: Sun, 16 Aug 2015 19:46:38 -0500 Subject: [PATCH] bug: initManager() with null properties to ensure repo is setup --- src/Traits/ManagesItemsTrait.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Traits/ManagesItemsTrait.php b/src/Traits/ManagesItemsTrait.php index 66efbc6..44627ed 100644 --- a/src/Traits/ManagesItemsTrait.php +++ b/src/Traits/ManagesItemsTrait.php @@ -34,15 +34,27 @@ trait ManagesItemsTrait * This is an alias for reset() * * @param array $items + * @return $this */ - public function initManager($items = []) + public function initManager($items = null) { if (property_exists($this, 'dataItemsName')) { $this->setItemsName($this->dataItemsName); } $repo = $this->getItemsName(); + + if (!isset($this->$repo)) { + $this->$repo = []; + } + + if (is_null($items)) { + return $this; + } + $this->$repo = is_array($items) ? $items : $this->getArrayableItems($items); + + return $this; } /**