Skip to content

Commit

Permalink
- \ddGetDocuments\Outputter\Outputter::includeOutputterByName: The …
Browse files Browse the repository at this point in the history
…method has been deleted. `\DDTools\Base\AncestorTrait::createChildInstance` is used instead.
  • Loading branch information
Ronef committed May 2, 2023
1 parent 1e85b5a commit e6c0d56
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 38 deletions.
32 changes: 2 additions & 30 deletions src/Outputter/Outputter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/Outputter/Sitemap/Outputter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand All @@ -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: '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">[+ddGetDocuments_items+]</urlset>'.
*/
function __construct($params = []){
public function __construct($params = []){
//Call base constructor
parent::__construct($params);

Expand All @@ -44,15 +44,17 @@ function __construct($params = []){
]);

//We use the “String” Outputter as base
$outputter_StringClass = \ddGetDocuments\Outputter\Outputter::includeOutputterByName('String');
$outputter_StringParams = (object) [
'templates' => $this->templates
];
//Transfer provider link
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
]);
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/Outputter/Yandexmarket/Outputter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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;


Expand Down Expand Up @@ -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,
Expand All @@ -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
]);
}

/**
Expand Down

0 comments on commit e6c0d56

Please sign in to comment.