From 6b5df2b23a0ecbdf0a63d4d7ab1c0e1f7f3d1d7b Mon Sep 17 00:00:00 2001 From: hxtree Date: Sun, 11 Jul 2021 13:52:50 -0500 Subject: [PATCH] Fix add properties --- src/Configuration.php | 2 +- src/Element/AbstractElement.php | 7 +------ src/Engine.php | 12 +++++++----- src/Processor.php | 4 ++-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Configuration.php b/src/Configuration.php index e5b1768..707a85d 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -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 diff --git a/src/Element/AbstractElement.php b/src/Element/AbstractElement.php index 26e082e..7c450d3 100644 --- a/src/Element/AbstractElement.php +++ b/src/Element/AbstractElement.php @@ -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 */ @@ -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; } } diff --git a/src/Engine.php b/src/Engine.php index acc1dba..81ea9fe 100644 --- a/src/Engine.php +++ b/src/Engine.php @@ -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; @@ -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. @@ -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; } /** @@ -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); diff --git a/src/Processor.php b/src/Processor.php index d18912d..e3d7192 100644 --- a/src/Processor.php +++ b/src/Processor.php @@ -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); } @@ -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); }