1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license GPLv3, http://www.gnu.org/copyleft/gpl.html |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2013 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2016 |
7
|
|
|
* @package TYPO3 |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Aimeos\Flexform; |
12
|
|
|
|
13
|
|
|
use Aimeos\Aimeos\Base; |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Aimeos catalog flexform helper. |
18
|
|
|
* |
19
|
|
|
* @package TYPO3 |
20
|
|
|
*/ |
21
|
|
|
class Catalog |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Returns the list of categories with their ID. |
25
|
|
|
* |
26
|
|
|
* @param array $config Associative array of existing configurations |
27
|
|
|
* @param \TYPO3\CMS\Backend\Form\FormEngine|\TYPO3\CMS\Backend\Form\DataPreprocessor $tceForms TCE forms object |
|
|
|
|
28
|
|
|
* @param string $sitecode Unique code of the site to retrieve the categories for |
29
|
|
|
* @return array Associative array with existing and new entries |
30
|
|
|
*/ |
31
|
|
|
public function getCategories(array $config, $tceForms = null, string $sitecode = 'default') : array |
32
|
|
|
{ |
33
|
|
|
try { |
34
|
|
|
if (!isset($config['flexParentDatabaseRow']['pid'])) { |
35
|
|
|
throw new \Exception('No PID found in "flexParentDatabaseRow" array key: ' . print_r($config, true)); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
$pid = $config['flexParentDatabaseRow']['pid']; |
39
|
|
|
$pageTSConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($pid); |
40
|
|
|
|
41
|
|
|
if (isset($pageTSConfig['tx_aimeos.']['mshop.']['locale.']['site'])) { |
42
|
|
|
$sitecode = $pageTSConfig['tx_aimeos.']['mshop.']['locale.']['site']; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
$context = Base::context(Base::config()); |
46
|
|
|
$context->setEditor('flexform'); |
47
|
|
|
|
48
|
|
|
$localeManager = \Aimeos\MShop::create($context, 'locale'); |
49
|
|
|
$context->setLocale($localeManager->bootstrap($sitecode, '', '', false)); |
|
|
|
|
50
|
|
|
|
51
|
|
|
$manager = \Aimeos\MShop::create($context, 'catalog'); |
52
|
|
|
$item = $manager->getTree(null, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE); |
|
|
|
|
53
|
|
|
|
54
|
|
|
|
55
|
|
|
$config['items'] = array_merge($config['items'], $this->getCategoryList($item, $item->getName())); |
56
|
|
|
} catch(\Exception $e) { |
57
|
|
|
error_log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return $config; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Returns the list of category label / ID pairs for the given node and all children |
66
|
|
|
* |
67
|
|
|
* @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item to start from |
68
|
|
|
* @param string $breadcrumb Breadcrumb of the parent nodes |
69
|
|
|
* @return array Associative array of category label / ID pairs |
70
|
|
|
*/ |
71
|
|
|
protected function getCategoryList(\Aimeos\MShop\Catalog\Item\Iface $item, string $breadcrumb) : array |
72
|
|
|
{ |
73
|
|
|
$result = []; |
74
|
|
|
$result[] = [$breadcrumb, $item->getId()]; |
75
|
|
|
|
76
|
|
|
foreach ($item->getChildren() as $child) { |
77
|
|
|
$result = array_merge($result, $this->getCategoryList($child, $breadcrumb . ' > ' . $child->getName())); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
return $result; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths