From e6c0d56f57bee023f8e6fee227d1bc926b5bb2cc Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 2 May 2023 23:48:27 +0400 Subject: [PATCH] - `\ddGetDocuments\Outputter\Outputter::includeOutputterByName`: The method has been deleted. `\DDTools\Base\AncestorTrait::createChildInstance` is used instead. --- src/Outputter/Outputter.php | 32 ++---------------------- src/Outputter/Sitemap/Outputter.php | 10 +++++--- src/Outputter/Yandexmarket/Outputter.php | 10 +++++--- 3 files changed, 14 insertions(+), 38 deletions(-) diff --git a/src/Outputter/Outputter.php b/src/Outputter/Outputter.php index 173cb25..8b8d84e 100644 --- a/src/Outputter/Outputter.php +++ b/src/Outputter/Outputter.php @@ -20,42 +20,14 @@ abstract class Outputter extends \DDTools\Base\Base { $templates = [] ; - /** - * includeOutputterByName - * @version 1.0.3 (2019-03-11) - * - * @TODO: Remove it, use `\DDTools\BaseClass::createChildInstance` instead - * - * @param $parserName {string} - * - * @throws \Exception - * - * @return {string} - */ - public final static function includeOutputterByName($parserName){ - $parserName = ucfirst(strtolower($parserName)); - $parserPath = $parserName.DIRECTORY_SEPARATOR . 'Outputter' . '.php'; - - if(is_file(__DIR__.DIRECTORY_SEPARATOR . $parserPath)){ - require_once($parserPath); - - return __NAMESPACE__ . '\\' . $parserName . '\\' . 'Outputter'; - }else{ - throw new \Exception( - 'Outputter “' . $parserName . '” not found.', - 500 - ); - } - } - /** * __construct - * @version 1.5.1 (2021-07-13) + * @version 1.5.2 (2023-05-02) * * @param $params {stdClass|arrayAssociative} * @param $params->dataProvider {\ddGetDocuments\DataProvider\DataProvider} */ - function __construct($params = []){ + public function __construct($params = []){ $params = (object) $params; //Prepare templates diff --git a/src/Outputter/Sitemap/Outputter.php b/src/Outputter/Sitemap/Outputter.php index 67485c6..f465757 100644 --- a/src/Outputter/Sitemap/Outputter.php +++ b/src/Outputter/Sitemap/Outputter.php @@ -20,7 +20,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * __construct - * @version 2.0 (2021-07-13) + * @version 2.0.1 (2023-05-02) * * @param $params {stdClass|arrayAssociative} * @param $params->priorityTVName {stringTvName} — Name of TV which sets the relative priority of the document. Default: 'general_seo_sitemap_priority'. @@ -29,7 +29,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { * @param $params->templates->item {string|stringChunkName} — Available placeholders: [+any field or tv name+], [+any of extender placeholders+]. Default: ''. * @param $params->templates->wrapper {string|stringChunkName} — Available placeholders: [+ddGetDocuments_items+], [+any of extender placeholders+]. Default: '[+ddGetDocuments_items+]'. */ - function __construct($params = []){ + public function __construct($params = []){ //Call base constructor parent::__construct($params); @@ -44,7 +44,6 @@ function __construct($params = []){ ]); //We use the “String” Outputter as base - $outputter_StringClass = \ddGetDocuments\Outputter\Outputter::includeOutputterByName('String'); $outputter_StringParams = (object) [ 'templates' => $this->templates ]; @@ -52,7 +51,10 @@ function __construct($params = []){ if (isset($params->dataProvider)){ $outputter_StringParams->dataProvider = $params->dataProvider; } - $this->outputter_StringInstance = new $outputter_StringClass($outputter_StringParams); + $this->outputter_StringInstance = \ddGetDocuments\Outputter\Outputter::createChildInstance([ + 'name' => 'String', + 'params' => $outputter_StringParams + ]); } /** diff --git a/src/Outputter/Yandexmarket/Outputter.php b/src/Outputter/Yandexmarket/Outputter.php index 125b8f8..f70f34e 100644 --- a/src/Outputter/Yandexmarket/Outputter.php +++ b/src/Outputter/Yandexmarket/Outputter.php @@ -177,7 +177,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * __construct - * @version 2.1.2 (2021-07-12) + * @version 2.1.3 (2023-05-02) * * @note @link https://yandex.ru/support/partnermarket/export/yml.html * @@ -213,7 +213,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { * @param $params->templates->{'offers_item_elem' . $FieldName} {stringChunkName|string} — Можно задать шаблон любого элемента offer, называем в соответствии с параметрами 'offerFields_', например: $params->templates_offers_item_elemCountryOfOrigin. Default: —. * @param $params->categoryIds_last {stringCommaSepareted} — id конечных категорий(parent). Если пусто то выводятся только непосредственный родитель товара. Defalut: —. */ - function __construct($params = []){ + public function __construct($params = []){ $params = (object) $params; @@ -289,7 +289,6 @@ function __construct($params = []){ //We use the “String” Outputter as base - $outputter_StringClass = \ddGetDocuments\Outputter\Outputter::includeOutputterByName('String'); $outputter_StringParams = (object) [ 'templates' => (object) [ 'item' => $this->templates->offers_item, @@ -300,7 +299,10 @@ function __construct($params = []){ if (isset($params->dataProvider)){ $outputter_StringParams->dataProvider = $params->dataProvider; } - $this->outputter_StringInstance = new $outputter_StringClass($outputter_StringParams); + $this->outputter_StringInstance = \ddGetDocuments\Outputter\Outputter::createChildInstance([ + 'name' => 'String', + 'params' => $outputter_StringParams + ]); } /**