Skip to content

Commit

Permalink
bug: initManager() with null properties to ensure repo is setup
Browse files Browse the repository at this point in the history
  • Loading branch information
electricjones committed Aug 17, 2015
1 parent 22f1d60 commit 54fc386
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Traits/ManagesItemsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 54fc386

Please sign in to comment.