Settings.php
public function load($categories)
    {
        if (is_string($categories)) {
            $categories = [$categories];
        }

        foreach ($categories as $idx => $category) {
            if (isset($this->items[$category])) {
                unset($categories[$idx]);
            } else {
                $this->items[$category] = [];
            }
        }

        if (empty($categories)) {
            return;
        }

        $result = (new Query())->select(['category', 'key', 'value'])->from('setting')->where([
            'category' => $categories
        ])->all();

        foreach ($result as $row) {
            try {
                $this->items[$row['category']][$row['key']] = Json::decode($row['value']);
            } catch (InvalidParamException $ex) {
                $this->items[$row['category']][$row['key']] = $row['value'];
            }
        }
    }
public function load($categories)
    {
        if (is_string($categories)) {
            $categories = [$categories];
        }

        foreach ($categories as $idx => $category) {
            if (isset($this->items[$category])) {
                unset($categories[$idx]);
            } else {
                $this->items[$category] = [];
            }
        }

        if (empty($categories)) {
            return;
        }

        $result = (new Query())->select(['category', 'key', 'value'])->from('setting')->where([
            'category' => $categories
        ])->all();

        foreach ($result as $row) {
            try {
                $this->items[$row['category']][$row['key']] = Json::decode($row['value']);
            } catch (InvalidParamException $ex) {
                $this->items[$row['category']][$row['key']] = $row['value'];
            }
        }
    }
public function load ( $ categories ) { if ( is_string ( $ categories ) ) { $ categories = [ $ categories ] ; } foreach ( $ categories as $ idx => $ category ) { if ( isset ( $ this -> items [ $ category ] ) ) { unset ( $ categories [ $ idx ] ) ; } else { $ this -> items [ $ category ] = [ ] ; } } if ( empty ( $ categories ) ) { return ; } $ result = ( new Query ( ) ) -> select ( [ 'category' , 'key' , 'value' ] ) -> from ( 'setting' ) -> where ( [ 'category' => $ categories ] ) -> all ( ) ; foreach ( $ result as $ row ) { try { $ this -> items [ $ row [ 'category' ] ] [ $ row [ 'key' ] ] = Json :: decode ( $ row [ 'value' ] ) ; } catch ( InvalidParamException $ ex ) { $ this -> items [ $ row [ 'category' ] ] [ $ row [ 'key' ] ] = $ row [ 'value' ] ; } } }
Loads settings from category or multiple categories
@param array|string $categories Category name
Loads settings from category or multiple categories