Blame view

thread/modules/menu/Menu.php 1.34 KB
d1f8bd40   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  <?php
  
  namespace thread\modules\menu;
  
  use Yii;
  //
  use thread\app\base\module\abstracts\Module as aModule;
  
  /**
   * Class Menu
   *
   * @package thread\modules\menu
   * @author FilamentV <vortex.filament@gmail.com>
   * @copyright (c), Thread
   */
  class Menu extends aModule
  {
      public $name = 'menu';
      public $translationsBasePath = __DIR__ . '/messages';
      public $configPath = __DIR__ . '/config.php';
  
      /**
       * @var array
       */
      public $internal_sources = [];
      public $internal_sources_list = [];
      public $permanent_link = [];
  
  
      /**
       * Db connection
       *
       * @return null|object
       * @throws \yii\base\InvalidConfigException
       */
  
      public static function getDb()
      {
          return Yii::$app->get('db-core');
      }
  
      /**
       *
       */
      public function init()
      {
          parent::init();
          $this->setInternalSource();
      }
  
      /**
       *
       */
      public function setInternalSource()
      {
          if (!empty($this->internal_sources)) {
              foreach ($this->internal_sources as $key => $data) {
                  foreach ($data as $data_key => $item) {
                      $set_key = $key . "_" . $data_key;
                      $this->internal_sources_list[$set_key] = $item;
                      $this->internal_sources_list[$set_key]['key'] = $set_key;
                  }
              }
          }
      }
  
  }