1: | <?php
2: | namespace Opencart\Admin\Controller\Event;
3: | /**
4: | * Class Language
5: | *
6: | * @package Opencart\Admin\Controller\Event
7: | */
8: | class Language extends \Opencart\System\Engine\Controller {
9: | /**
10: | * Index
11: | *
12: | * Dump all the language vars into the template.
13: | *
14: | * view/ * /before
15: | *
16: | * @param string $route
17: | * @param array<string, string> $args
18: | *
19: | * @return void
20: | */
21: | public function index(string &$route, array &$args): void {
22: | foreach ($this->language->all() as $key => $value) {
23: | if (!isset($args[$key])) {
24: | $args[$key] = $value;
25: | }
26: | }
27: | }
28: |
29: | /**
30: | * Before
31: | *
32: | * 1. Before controller load store all current loaded language data.
33: | *
34: | * controller/ * /before
35: | *
36: | * @param string $route
37: | * @param array<mixed> $args
38: | *
39: | * @return void
40: | */
41: | public function before(string &$route, array &$args): void {
42: | $data = $this->language->all();
43: |
44: | if ($data) {
45: | $this->language->set('backup', json_encode($data));
46: | }
47: | }
48: |
49: | /**
50: | * After
51: | *
52: | * // 2. After controller load restore old language data.
53: | *
54: | * // controller/ * / * /after
55: | *
56: | * @param string $route
57: | * @param array<mixed> $args
58: | * @param mixed $output
59: | *
60: | * @return void
61: | */
62: | public function after(string &$route, array &$args, &$output): void {
63: | $data = json_decode($this->language->get('backup'), true);
64: |
65: | if (is_array($data)) {
66: | $this->language->clear();
67: |
68: | foreach ($data as $key => $value) {
69: | $this->language->set($key, $value);
70: | }
71: | }
72: | }
73: | }
74: |

OpenCart API API documentation generated by ApiGen dev-master