Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
Minor fix and improvement to the path builder trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Krämer committed Nov 28, 2015
1 parent 43ce68c commit 400e095
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/Model/Entity/FileStorage.php
Expand Up @@ -18,12 +18,14 @@ class FileStorage extends Entity {
use PathBuilderTrait;

/**
* Path Builder class to be used by this entity.
* Path Builder Class.
*
* @param \Burzum\FileStorage\Storage\PathBuilder\PathBuilderInterface
* This is named $_pathBuilderClass because $_pathBuilder is already used by
* the trait to store the path builder instance.
*
* @param array
*/
protected $_pathBuilder = null;

protected $_pathBuilderClass = null;

/**
* Path Builder options
Expand All @@ -40,12 +42,12 @@ class FileStorage extends Entity {
*/
public function __construct(array $properties = [], array $options = []) {
$options += [
'pathBuilder' => $this->_pathBuilder,
'pathBuilder' => $this->_pathBuilderClass,
'pathBuilderOptions' => $this->_pathBuilderOptions
];
parent::__construct($properties, $options);

if (is_string($options['pathBuilder'])) {
if (!empty($options['pathBuilder'])) {
$this->pathBuilder(
$options['pathBuilder'],
$options['pathBuilderOptions']
Expand Down
8 changes: 6 additions & 2 deletions src/Storage/PathBuilder/PathBuilderTrait.php
Expand Up @@ -42,13 +42,17 @@ public function createPathBuilder($name, array $options = []) {
}

/**
* Getter and set for the local PathBuilderInterface instance.
* Getter and setter for the local PathBuilderInterface instance.
*
* @param string $name
* @param string|\Burzum\FileStorage\Storage\PathBuilder\PathBuilderInterface $name
* @param array $options
* @return \Burzum\FileStorage\Storage\PathBuilder\PathBuilderInterface
*/
public function pathBuilder($name = null, array $options = []) {
if ($name instanceof PathBuilderInterface) {
$this->_pathBuilder = $name;
return $this->_pathBuilder;
}
if ($name !== null) {
$this->_pathBuilder = $this->createPathBuilder($name, $options);
}
Expand Down

0 comments on commit 400e095

Please sign in to comment.