Skip to content

Commit

Permalink
Fix add properties
Browse files Browse the repository at this point in the history
  • Loading branch information
hxtree committed Jul 11, 2021
1 parent 3ea5fb9 commit 6b5df2b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Configuration implements ConfigurationInterface
/**
* @var array references to external elemental properties that are set as references
*/
protected $properties = [];
public $properties = [];

/**
* @var array methods that are automatically invoked within all elements that feature method
Expand Down
7 changes: 1 addition & 6 deletions src/Element/AbstractElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ abstract class AbstractElement
*/
public $search_index = true;

/**
* @var string maximum results of data pulled
*/
public $max_results = '240';

/**
* @var array ancestor public variable updated live
*/
Expand Down Expand Up @@ -88,7 +83,7 @@ final public function __construct(ArgumentArray $args = null, array &$dynamic_pr
if(property_exists($this, $property_name)){
throw Exception('Property already exists.');
}
$this->$property_name &= $property_value;
$this->$property_name = &$property_value;
}
}

Expand Down
12 changes: 7 additions & 5 deletions src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use DOMElement;
use DOMNodeList;
use DOMXPath;
use Ouxsoft\PHPMarkup\Contract\ConfigurationInterface;
use Ouxsoft\PHPMarkup\Contract\DocumentInterface;
use Ouxsoft\PHPMarkup\Contract\ElementPoolInterface;
use Ouxsoft\PHPMarkup\Contract\EngineInterface;
Expand Down Expand Up @@ -48,9 +49,10 @@ class Engine implements EngineInterface
public $element_pool;

/**
* @var array contains additional Element construction parameters that are loaded as properties
* @var ConfigurationInterface
* contains array with dditional Element construction parameters that are loaded as properties
*/
private $element_properties = [];
private $config;

/**
* EngineInterface constructor.
Expand All @@ -61,13 +63,13 @@ class Engine implements EngineInterface
public function __construct(
DocumentInterface &$document,
ElementPoolInterface &$element_pool,
Configuration &$config
ConfigurationInterface &$config
){
$this->dom = &$document;

$this->element_pool = &$element_pool;

$this->element_properties = $config->getProperties();
$this->config = &$config;
}

/**
Expand Down Expand Up @@ -325,7 +327,7 @@ private function instantiateElement(DOMElement $element, string $class_name): bo
$element_args = $this->getElementArgs($element);

// instantiate element
$element_object = new $class_name($element_args, $this->element_properties);
$element_object = new $class_name($element_args, $this->config->properties);

// set element object placeholder
$element->setAttribute(self::INDEX_ATTRIBUTE, $element_object->element_id);
Expand Down
4 changes: 2 additions & 2 deletions src/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function addElements(array $elements): void
* @param string $property_name
* @param $property_value
*/
public function addProperty(string $property_name, $property_value): void
public function addProperty(string $property_name, &$property_value): void
{
$this->config->addProperty($property_name, $property_value);
}
Expand All @@ -152,7 +152,7 @@ public function addProperty(string $property_name, $property_value): void
*
* @param array $properties
*/
public function addProperties(array $properties) : void
public function addProperties(array &$properties) : void
{
$this->config->addProperties($properties);
}
Expand Down

0 comments on commit 6b5df2b

Please sign in to comment.