1: <?php
2: namespace Opencart\Catalog\Controller\Startup;
3: /**
4: * Class Extension
5: *
6: * @package Opencart\Catalog\Controller\Startup
7: */
8: class Extension extends \Opencart\System\Engine\Controller {
9: /**
10: * @return void
11: */
12: public function index(): void {
13: // Add extension paths from the DB
14: $this->load->model('setting/extension');
15:
16: $results = $this->model_setting_extension->getExtensions();
17:
18: foreach ($results as $result) {
19: $extension = str_replace(['_', '/'], ['', '\\'], ucwords($result['extension'], '_/'));
20:
21: // Register controllers, models and system extension folders
22: $this->autoloader->register('Opencart\Catalog\Controller\Extension\\' . $extension, DIR_EXTENSION . $result['extension'] . '/catalog/controller/');
23: $this->autoloader->register('Opencart\Catalog\Model\Extension\\' . $extension, DIR_EXTENSION . $result['extension'] . '/catalog/model/');
24: $this->autoloader->register('Opencart\System\Library\Extension\\' . $extension, DIR_EXTENSION . $result['extension'] . '/system/library/');
25:
26: // Template directory
27: $this->template->addPath('extension/' . $result['extension'], DIR_EXTENSION . $result['extension'] . '/catalog/view/template/');
28:
29: // Language directory
30: $this->language->addPath('extension/' . $result['extension'], DIR_EXTENSION . $result['extension'] . '/catalog/language/');
31:
32: // Config directory
33: $this->config->addPath('extension/' . $result['extension'], DIR_EXTENSION . $result['extension'] . '/system/config/');
34: }
35:
36: // Register OCMOD
37: $this->autoloader->register('Opencart\Catalog\Controller\Extension\Ocmod', DIR_EXTENSION . 'ocmod/catalog/controller/');
38: $this->autoloader->register('Opencart\Catalog\Model\Extension\Ocmod', DIR_EXTENSION . 'ocmod/catalog/model/');
39: $this->autoloader->register('Opencart\System\Library\Extension\Ocmod', DIR_EXTENSION . 'ocmod/system/library/');
40: $this->template->addPath('extension/ocmod', DIR_EXTENSION . 'ocmod/catalog/view/template/');
41: $this->language->addPath('extension/ocmod', DIR_EXTENSION . 'ocmod/catalog/language/');
42: $this->config->addPath('extension/ocmod', DIR_EXTENSION . 'ocmod/system/config/');
43: }
44: }
45: