Core
4 years ago
DemoSites
4 years ago
Config.php
4 years ago
Flags.php
4 years ago
GoogleFontsLocalLoader.php
4 years ago
Migrations.php
4 years ago
NotificationsManager.php
4 years ago
PluginsManager.php
4 years ago
Config.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kubio; |
| 4 | use Kubio\Core\LodashBasic; |
| 5 | use function file_get_contents; |
| 6 | use function json_decode; |
| 7 | use const KUBIO_ROOT_DIR; |
| 8 | |
| 9 | class Config { |
| 10 | public static $name = 'kubio'; |
| 11 | |
| 12 | public static $mainAttributeKey; |
| 13 | public static $elementsKey; |
| 14 | public static $elementsEnum; |
| 15 | public static $statesKey; |
| 16 | |
| 17 | public static $config_types = array(); |
| 18 | |
| 19 | public static function load() { |
| 20 | $types_f = KUBIO_ROOT_DIR . 'build/types.json'; |
| 21 | self::$config_types = apply_filters( 'kubio/style-types', json_decode( file_get_contents( $types_f ), true ) ); |
| 22 | |
| 23 | self::$mainAttributeKey = Config::value( 'constants.support.mainAttributeKey' ); |
| 24 | self::$elementsKey = Config::value( 'constants.support.elementsKey' ); |
| 25 | self::$elementsEnum = Config::value( 'constants.support.elementsEnum' ); |
| 26 | self::$statesKey = Config::value( 'constants.support.statesKey' ); |
| 27 | } |
| 28 | |
| 29 | |
| 30 | public static function value( $path, $fallback = null ) { |
| 31 | return LodashBasic::get( self::$config_types, $path, $fallback ); |
| 32 | } |
| 33 | |
| 34 | public static function mediasById() { |
| 35 | $medias = self::value( 'medias' ); |
| 36 | return LodashBasic::keyBy( $medias, 'id' ); |
| 37 | } |
| 38 | |
| 39 | public static function statesById() { |
| 40 | $states = self::value( 'states', array() ); |
| 41 | return LodashBasic::keyBy( $states, 'id' ); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | |
| 46 | Config::load(); |
| 47 |