[Added] trait for generalized method

This commit is contained in:
MaxBUhe 2024-04-12 10:04:04 +02:00
parent efc9aa08e0
commit 681d0932e0
4 changed files with 57 additions and 74 deletions

View File

@ -4,41 +4,5 @@ namespace D3\GoogleAnalytics4\Modules\Application\Model;
class Category extends Category_parent
{
/**
* @param int $indexOfArray
* @return string
*/
public function getSplitCategoryArray(int $indexOfArray = -1, bool $bShallTakeStd = false) :string
{
if ($bShallTakeStd){
$splitCatArray =
array_values(
array_filter(
explode(
'/',
trim(
parse_url(
$this->getLink(),
5
)
)
)
)
);
if (($indexOfArray >= 0) and (false === empty($splitCatArray[$indexOfArray]))){
return $splitCatArray[$indexOfArray];
}else{
return "";
}
}
return
trim(
parse_url(
$this->getLink(),
5
)
);
}
use articleTreeStructure;
}

View File

@ -4,41 +4,5 @@ namespace D3\GoogleAnalytics4\Modules\Application\Model;
class Manufacturer extends Manufacturer_parent
{
/**
* @param int $indexOfArray
* @return string
*/
public function getSplitCategoryArray(int $indexOfArray = -1, bool $bShallTakeStd = false) :string
{
if ($bShallTakeStd){
$splitCatArray =
array_values(
array_filter(
explode(
'/',
trim(
parse_url(
$this->getLink(),
5
)
)
)
)
);
if (($indexOfArray >= 0) and (false === empty($splitCatArray[$indexOfArray]))){
return $splitCatArray[$indexOfArray];
}else{
return "";
}
}
return
trim(
parse_url(
$this->getLink(),
5
)
);
}
use articleTreeStructure;
}

View File

@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace D3\GoogleAnalytics4\Modules\Application\Model;
class Vendor extends \OxidEsales\Eshop\Application\Model\Vendor
{
use articleTreeStructure;
}

View File

@ -0,0 +1,44 @@
<?php
namespace D3\GoogleAnalytics4\Modules\Application\Model;
trait articleTreeStructure
{
/**
* @param int $indexOfArray
* @return string
*/
public function getSplitCategoryArray(int $indexOfArray = -1, bool $bShallTakeStd = false) :string
{
if ($bShallTakeStd){
$splitCatArray =
array_values(
array_filter(
explode(
'/',
trim(
parse_url(
$this->getLink(),
5
)
)
)
)
);
if (($indexOfArray >= 0) and (false === empty($splitCatArray[$indexOfArray]))){
return $splitCatArray[$indexOfArray];
}else{
return "";
}
}
return
trim(
parse_url(
$this->getLink(),
5
)
);
}
}