├── .editorconfig ├── .github ├── bundle.json ├── bundle.php └── bundle.yaml ├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── build.xml ├── bundle.php ├── composer.json ├── composer.lock ├── dist ├── autoload.php ├── composer │ ├── ClassLoader.php │ ├── autoload_classmap.php │ ├── autoload_files.php │ ├── autoload_namespaces.php │ ├── autoload_psr4.php │ ├── autoload_real.php │ └── autoload_static.php ├── hassankhan │ └── config │ │ └── src │ │ ├── AbstractConfig.php │ │ ├── Config.php │ │ ├── ConfigInterface.php │ │ ├── ErrorException.php │ │ ├── Exception.php │ │ ├── Exception │ │ ├── EmptyDirectoryException.php │ │ ├── FileNotFoundException.php │ │ ├── ParseException.php │ │ └── UnsupportedFormatException.php │ │ └── FileParser │ │ ├── AbstractFileParser.php │ │ ├── FileParserInterface.php │ │ ├── Ini.php │ │ ├── Json.php │ │ ├── Php.php │ │ ├── Xml.php │ │ └── Yaml.php └── tgmpa │ └── tgm-plugin-activation │ ├── class-tgm-plugin-activation.php │ └── example.php ├── phpcs.xml └── src ├── Bundle.php ├── ConfigNoFile.php └── Loader.php /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | 3 | root = true 4 | 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /.github/bundle.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Disable Comments", 4 | "slug": "disable-comments", 5 | "required": false, 6 | "force_activation": true 7 | }, 8 | { 9 | "name": "Models", 10 | "slug": "models", 11 | "source": "https://github.com/soberwp/models/archive/master.zip", 12 | "external_url": "https://github.com/models/intervention", 13 | "required": true, 14 | "force_activation": true, 15 | "force_deactivation": false 16 | } 17 | ] -------------------------------------------------------------------------------- /.github/bundle.php: -------------------------------------------------------------------------------- 1 | 'Disable Comments', 5 | 'slug' => 'disable-comments', 6 | 'required' => false, 7 | 'force_activation' => true 8 | ], 9 | [ 10 | 'name' => 'Models', 11 | 'slug' => 'models', 12 | 'source' => 'https://github.com/soberwp/models/archive/master.zip', 13 | 'external_url' => 'https://github.com/models/intervention', 14 | 'required' => true, 15 | 'force_activation' => true, 16 | 'force_deactivation' => false 17 | ] 18 | ]; 19 | -------------------------------------------------------------------------------- /.github/bundle.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Disable Comments 3 | slug: disable-comments 4 | required: false 5 | force_activation: true 6 | - name: Models 7 | slug: models 8 | source: https://github.com/soberwp/models/archive/master.zip 9 | external_url: https://github.com/models/intervention 10 | required: true 11 | force_activation: true 12 | force_deactivation: false 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 1.0.2: 21st August 2018 2 | * Update dependencies 3 | 4 | ### 1.0.1: 11th February 2017 5 | * Add YAML and PHP file support 6 | 7 | ### 1.0.0: 07th January 2017 8 | * Release Bundle 9 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) Darren Jacoby 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bundle 2 | 3 | WordPress plugin to enable plugin activation using a JSON, YAML or PHP file. 4 | 5 | ## Installation 6 | 7 | #### Composer: 8 | 9 | Recommended method/s; 10 | 11 | [Roots Bedrock](https://roots.io/bedrock/) and [WP-CLI](http://wp-cli.org/) 12 | ```shell 13 | $ composer require soberwp/bundle 14 | $ wp plugin activate bundle 15 | ``` 16 | 17 | [Roots Sage](https://roots.io/sage/) 18 | ```shell 19 | $ composer require soberwp/bundle:1.0.2-p 20 | ``` 21 | 22 | #### Manual: 23 | 24 | * Download the [zip file](https://github.com/soberwp/themer/archive/master.zip) 25 | * Unzip to your sites plugin folder 26 | * Activate via WordPress 27 | 28 | #### Requirements: 29 | 30 | * [PHP](http://php.net/manual/en/install.php) >= 5.6.x 31 | 32 | ## Setup 33 | 34 | By default either `bundle.json`, `bundle.yaml` or `bundle.php` is used. 35 | 36 | You can use a custom file for each using the filters below within your themes `functions.php` file; 37 | ```php 38 | add_filter('sober/bundle/file', function () { 39 | return get_stylesheet_directory() . '/plugin-dependencies.yaml'; 40 | }); 41 | ``` 42 | 43 | ## Usage 44 | 45 | Themes often require plugins in order to work — bundle leverages the popular [tgmpa](http://tgmpluginactivation.com/) class to achieve plugin activation nags and actions. 46 | 47 | #### Examples: 48 | 49 | [bundle.json](.github/bundle.json) 50 | 51 | ```json 52 | [ 53 | { 54 | "name": "Disable Comments", 55 | "slug": "disable-comments", 56 | "required": false, 57 | "force_activation": true 58 | }, 59 | { 60 | "name": "Models", 61 | "slug": "models", 62 | "source": "https://github.com/soberwp/models/archive/master.zip", 63 | "external_url": "https://github.com/models/intervention", 64 | "required": true, 65 | "force_activation": true, 66 | "force_deactivation": false 67 | } 68 | ] 69 | ``` 70 | 71 | [bundle.yaml](.github/bundle.yaml) 72 | 73 | ```yaml 74 | --- 75 | - name: Disable Comments 76 | slug: disable-comments 77 | required: false 78 | force_activation: true 79 | - name: Models 80 | slug: models 81 | source: https://github.com/soberwp/models/archive/master.zip 82 | external_url: https://github.com/models/intervention 83 | required: true 84 | force_activation: true 85 | force_deactivation: false 86 | 87 | ``` 88 | 89 | [bundle.php](.github/bundle.php) 90 | 91 | ```php 92 | 'Disable Comments', 96 | 'slug' => 'disable-comments', 97 | 'required' => false, 98 | 'force_activation' => true 99 | ], 100 | [ 101 | 'name' => 'Models', 102 | 'slug' => 'models', 103 | 'source' => 'https://github.com/soberwp/models/archive/master.zip', 104 | 'external_url' => 'https://github.com/models/intervention', 105 | 'required' => true, 106 | 'force_activation' => true, 107 | 'force_deactivation' => false 108 | ] 109 | ]; 110 | ``` 111 | 112 | You can read [tgmpa documentation](http://tgmpluginactivation.com/configuration/) for plugin activation options. 113 | 114 | ## Updates 115 | 116 | #### Composer: 117 | 118 | * Change the composer.json version to ^1.0.2** 119 | * Check [CHANGELOG.md](CHANGELOG.md) for any breaking changes before updating. 120 | 121 | ```shell 122 | $ composer update 123 | ``` 124 | 125 | #### WordPress: 126 | 127 | Includes support for [github-updater](https://github.com/afragen/github-updater) to keep track on updates through the WordPress backend. 128 | * Download [github-updater](https://github.com/afragen/github-updater) 129 | * Clone [github-updater](https://github.com/afragen/github-updater) to your sites plugins/ folder 130 | * Activate via WordPress 131 | 132 | ## Other 133 | 134 | * For updates follow [@withjacoby](https://twitter.com/withjacoby) 135 | * You can also [hire me](mailto:darren@jacoby.co.za) for WordPress or frontend work 136 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /bundle.php: -------------------------------------------------------------------------------- 1 | =5.4.0", 22 | "composer/installers": "^1.5", 23 | "hassankhan/config": "^1.0", 24 | "tgmpa/tgm-plugin-activation": "^2.6.1" 25 | }, 26 | "require-dev": { 27 | "squizlabs/php_codesniffer": "2.*" 28 | }, 29 | "autoload": { 30 | "psr-4": { 31 | "Sober\\Bundle\\": "src/" 32 | } 33 | }, 34 | "scripts": { 35 | "test": [ 36 | "vendor/bin/phpcs --extensions=php --ignore=vendor/ ." 37 | ] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "c222210a7653a12b4ed1a78244c4d07a", 8 | "packages": [ 9 | { 10 | "name": "composer/installers", 11 | "version": "v1.4.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/composer/installers.git", 15 | "reference": "9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/composer/installers/zipball/9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b", 20 | "reference": "9ce17fb70e9a38dd8acff0636a29f5cf4d575c1b", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "composer-plugin-api": "^1.0" 25 | }, 26 | "replace": { 27 | "roundcube/plugin-installer": "*", 28 | "shama/baton": "*" 29 | }, 30 | "require-dev": { 31 | "composer/composer": "1.0.*@dev", 32 | "phpunit/phpunit": "4.1.*" 33 | }, 34 | "type": "composer-plugin", 35 | "extra": { 36 | "class": "Composer\\Installers\\Plugin", 37 | "branch-alias": { 38 | "dev-master": "1.0-dev" 39 | } 40 | }, 41 | "autoload": { 42 | "psr-4": { 43 | "Composer\\Installers\\": "src/Composer/Installers" 44 | } 45 | }, 46 | "notification-url": "https://packagist.org/downloads/", 47 | "license": [ 48 | "MIT" 49 | ], 50 | "authors": [ 51 | { 52 | "name": "Kyle Robinson Young", 53 | "email": "kyle@dontkry.com", 54 | "homepage": "https://github.com/shama" 55 | } 56 | ], 57 | "description": "A multi-framework Composer library installer", 58 | "homepage": "https://composer.github.io/installers/", 59 | "keywords": [ 60 | "Craft", 61 | "Dolibarr", 62 | "Eliasis", 63 | "Hurad", 64 | "ImageCMS", 65 | "Kanboard", 66 | "Lan Management System", 67 | "MODX Evo", 68 | "Mautic", 69 | "Maya", 70 | "OXID", 71 | "Plentymarkets", 72 | "Porto", 73 | "RadPHP", 74 | "SMF", 75 | "Thelia", 76 | "WolfCMS", 77 | "agl", 78 | "aimeos", 79 | "annotatecms", 80 | "attogram", 81 | "bitrix", 82 | "cakephp", 83 | "chef", 84 | "cockpit", 85 | "codeigniter", 86 | "concrete5", 87 | "croogo", 88 | "dokuwiki", 89 | "drupal", 90 | "eZ Platform", 91 | "elgg", 92 | "expressionengine", 93 | "fuelphp", 94 | "grav", 95 | "installer", 96 | "itop", 97 | "joomla", 98 | "kohana", 99 | "laravel", 100 | "lavalite", 101 | "lithium", 102 | "magento", 103 | "mako", 104 | "mediawiki", 105 | "modulework", 106 | "moodle", 107 | "osclass", 108 | "phpbb", 109 | "piwik", 110 | "ppi", 111 | "puppet", 112 | "reindex", 113 | "roundcube", 114 | "shopware", 115 | "silverstripe", 116 | "sydes", 117 | "symfony", 118 | "typo3", 119 | "wordpress", 120 | "yawik", 121 | "zend", 122 | "zikula" 123 | ], 124 | "time": "2017-08-09T07:53:48+00:00" 125 | }, 126 | { 127 | "name": "hassankhan/config", 128 | "version": "0.10.0", 129 | "source": { 130 | "type": "git", 131 | "url": "https://github.com/hassankhan/config.git", 132 | "reference": "06ac500348af033f1a2e44dc357ca86282626d4a" 133 | }, 134 | "dist": { 135 | "type": "zip", 136 | "url": "https://api.github.com/repos/hassankhan/config/zipball/06ac500348af033f1a2e44dc357ca86282626d4a", 137 | "reference": "06ac500348af033f1a2e44dc357ca86282626d4a", 138 | "shasum": "" 139 | }, 140 | "require": { 141 | "php": ">=5.3.0" 142 | }, 143 | "require-dev": { 144 | "phpunit/phpunit": "~4.0", 145 | "scrutinizer/ocular": "~1.1", 146 | "squizlabs/php_codesniffer": "~2.2" 147 | }, 148 | "suggest": { 149 | "symfony/yaml": "~2.5" 150 | }, 151 | "type": "library", 152 | "autoload": { 153 | "psr-4": { 154 | "Noodlehaus\\": "src" 155 | } 156 | }, 157 | "notification-url": "https://packagist.org/downloads/", 158 | "license": [ 159 | "MIT" 160 | ], 161 | "authors": [ 162 | { 163 | "name": "Hassan Khan", 164 | "homepage": "http://hassankhan.me/", 165 | "role": "Developer" 166 | } 167 | ], 168 | "description": "Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files", 169 | "homepage": "http://hassankhan.me/config/", 170 | "keywords": [ 171 | "config", 172 | "configuration", 173 | "ini", 174 | "json", 175 | "microphp", 176 | "unframework", 177 | "xml", 178 | "yaml", 179 | "yml" 180 | ], 181 | "time": "2016-02-11T16:21:17+00:00" 182 | }, 183 | { 184 | "name": "tgmpa/tgm-plugin-activation", 185 | "version": "2.6.1", 186 | "source": { 187 | "type": "git", 188 | "url": "https://github.com/TGMPA/TGM-Plugin-Activation.git", 189 | "reference": "c626d0d91fc8ef24916e809c7b79eeafab1c1cac" 190 | }, 191 | "dist": { 192 | "type": "zip", 193 | "url": "https://api.github.com/repos/TGMPA/TGM-Plugin-Activation/zipball/c626d0d91fc8ef24916e809c7b79eeafab1c1cac", 194 | "reference": "c626d0d91fc8ef24916e809c7b79eeafab1c1cac", 195 | "shasum": "" 196 | }, 197 | "require": { 198 | "php": ">=5.2" 199 | }, 200 | "type": "library", 201 | "autoload": { 202 | "files": [ 203 | "class-tgm-plugin-activation.php" 204 | ] 205 | }, 206 | "notification-url": "https://packagist.org/downloads/", 207 | "license": [ 208 | "GPL-2.0+" 209 | ], 210 | "authors": [ 211 | { 212 | "name": "Thomas Griffin", 213 | "homepage": "http://thomasgriffinmedia.com", 214 | "role": "Developer" 215 | }, 216 | { 217 | "name": "Gary Jones", 218 | "homepage": "https://github.com/GaryJones", 219 | "role": "Developer" 220 | }, 221 | { 222 | "name": "Juliette Reinders Folmer", 223 | "homepage": "https://github.com/jrfnl", 224 | "role": "Developer" 225 | } 226 | ], 227 | "description": "TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins).", 228 | "homepage": "http://tgmpluginactivation.com", 229 | "keywords": [ 230 | "activation", 231 | "library", 232 | "plugins", 233 | "theme", 234 | "wordpress" 235 | ], 236 | "time": "2016-05-19T15:46:51+00:00" 237 | } 238 | ], 239 | "packages-dev": [ 240 | { 241 | "name": "squizlabs/php_codesniffer", 242 | "version": "2.9.1", 243 | "source": { 244 | "type": "git", 245 | "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", 246 | "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62" 247 | }, 248 | "dist": { 249 | "type": "zip", 250 | "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62", 251 | "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62", 252 | "shasum": "" 253 | }, 254 | "require": { 255 | "ext-simplexml": "*", 256 | "ext-tokenizer": "*", 257 | "ext-xmlwriter": "*", 258 | "php": ">=5.1.2" 259 | }, 260 | "require-dev": { 261 | "phpunit/phpunit": "~4.0" 262 | }, 263 | "bin": [ 264 | "scripts/phpcs", 265 | "scripts/phpcbf" 266 | ], 267 | "type": "library", 268 | "extra": { 269 | "branch-alias": { 270 | "dev-master": "2.x-dev" 271 | } 272 | }, 273 | "autoload": { 274 | "classmap": [ 275 | "CodeSniffer.php", 276 | "CodeSniffer/CLI.php", 277 | "CodeSniffer/Exception.php", 278 | "CodeSniffer/File.php", 279 | "CodeSniffer/Fixer.php", 280 | "CodeSniffer/Report.php", 281 | "CodeSniffer/Reporting.php", 282 | "CodeSniffer/Sniff.php", 283 | "CodeSniffer/Tokens.php", 284 | "CodeSniffer/Reports/", 285 | "CodeSniffer/Tokenizers/", 286 | "CodeSniffer/DocGenerators/", 287 | "CodeSniffer/Standards/AbstractPatternSniff.php", 288 | "CodeSniffer/Standards/AbstractScopeSniff.php", 289 | "CodeSniffer/Standards/AbstractVariableSniff.php", 290 | "CodeSniffer/Standards/IncorrectPatternException.php", 291 | "CodeSniffer/Standards/Generic/Sniffs/", 292 | "CodeSniffer/Standards/MySource/Sniffs/", 293 | "CodeSniffer/Standards/PEAR/Sniffs/", 294 | "CodeSniffer/Standards/PSR1/Sniffs/", 295 | "CodeSniffer/Standards/PSR2/Sniffs/", 296 | "CodeSniffer/Standards/Squiz/Sniffs/", 297 | "CodeSniffer/Standards/Zend/Sniffs/" 298 | ] 299 | }, 300 | "notification-url": "https://packagist.org/downloads/", 301 | "license": [ 302 | "BSD-3-Clause" 303 | ], 304 | "authors": [ 305 | { 306 | "name": "Greg Sherwood", 307 | "role": "lead" 308 | } 309 | ], 310 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", 311 | "homepage": "http://www.squizlabs.com/php-codesniffer", 312 | "keywords": [ 313 | "phpcs", 314 | "standards" 315 | ], 316 | "time": "2017-05-22T02:43:20+00:00" 317 | } 318 | ], 319 | "aliases": [], 320 | "minimum-stability": "stable", 321 | "stability-flags": [], 322 | "prefer-stable": false, 323 | "prefer-lowest": false, 324 | "platform": { 325 | "php": ">=5.4.0" 326 | }, 327 | "platform-dev": [] 328 | } 329 | -------------------------------------------------------------------------------- /dist/autoload.php: -------------------------------------------------------------------------------- 1 | 7 | * Jordi Boggiano 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace Composer\Autoload; 14 | 15 | /** 16 | * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. 17 | * 18 | * $loader = new \Composer\Autoload\ClassLoader(); 19 | * 20 | * // register classes with namespaces 21 | * $loader->add('Symfony\Component', __DIR__.'/component'); 22 | * $loader->add('Symfony', __DIR__.'/framework'); 23 | * 24 | * // activate the autoloader 25 | * $loader->register(); 26 | * 27 | * // to enable searching the include path (eg. for PEAR packages) 28 | * $loader->setUseIncludePath(true); 29 | * 30 | * In this example, if you try to use a class in the Symfony\Component 31 | * namespace or one of its children (Symfony\Component\Console for instance), 32 | * the autoloader will first look for the class under the component/ 33 | * directory, and it will then fallback to the framework/ directory if not 34 | * found before giving up. 35 | * 36 | * This class is loosely based on the Symfony UniversalClassLoader. 37 | * 38 | * @author Fabien Potencier 39 | * @author Jordi Boggiano 40 | * @see http://www.php-fig.org/psr/psr-0/ 41 | * @see http://www.php-fig.org/psr/psr-4/ 42 | */ 43 | class ClassLoader 44 | { 45 | // PSR-4 46 | private $prefixLengthsPsr4 = array(); 47 | private $prefixDirsPsr4 = array(); 48 | private $fallbackDirsPsr4 = array(); 49 | 50 | // PSR-0 51 | private $prefixesPsr0 = array(); 52 | private $fallbackDirsPsr0 = array(); 53 | 54 | private $useIncludePath = false; 55 | private $classMap = array(); 56 | private $classMapAuthoritative = false; 57 | private $missingClasses = array(); 58 | private $apcuPrefix; 59 | 60 | public function getPrefixes() 61 | { 62 | if (!empty($this->prefixesPsr0)) { 63 | return call_user_func_array('array_merge', $this->prefixesPsr0); 64 | } 65 | 66 | return array(); 67 | } 68 | 69 | public function getPrefixesPsr4() 70 | { 71 | return $this->prefixDirsPsr4; 72 | } 73 | 74 | public function getFallbackDirs() 75 | { 76 | return $this->fallbackDirsPsr0; 77 | } 78 | 79 | public function getFallbackDirsPsr4() 80 | { 81 | return $this->fallbackDirsPsr4; 82 | } 83 | 84 | public function getClassMap() 85 | { 86 | return $this->classMap; 87 | } 88 | 89 | /** 90 | * @param array $classMap Class to filename map 91 | */ 92 | public function addClassMap(array $classMap) 93 | { 94 | if ($this->classMap) { 95 | $this->classMap = array_merge($this->classMap, $classMap); 96 | } else { 97 | $this->classMap = $classMap; 98 | } 99 | } 100 | 101 | /** 102 | * Registers a set of PSR-0 directories for a given prefix, either 103 | * appending or prepending to the ones previously set for this prefix. 104 | * 105 | * @param string $prefix The prefix 106 | * @param array|string $paths The PSR-0 root directories 107 | * @param bool $prepend Whether to prepend the directories 108 | */ 109 | public function add($prefix, $paths, $prepend = false) 110 | { 111 | if (!$prefix) { 112 | if ($prepend) { 113 | $this->fallbackDirsPsr0 = array_merge( 114 | (array) $paths, 115 | $this->fallbackDirsPsr0 116 | ); 117 | } else { 118 | $this->fallbackDirsPsr0 = array_merge( 119 | $this->fallbackDirsPsr0, 120 | (array) $paths 121 | ); 122 | } 123 | 124 | return; 125 | } 126 | 127 | $first = $prefix[0]; 128 | if (!isset($this->prefixesPsr0[$first][$prefix])) { 129 | $this->prefixesPsr0[$first][$prefix] = (array) $paths; 130 | 131 | return; 132 | } 133 | if ($prepend) { 134 | $this->prefixesPsr0[$first][$prefix] = array_merge( 135 | (array) $paths, 136 | $this->prefixesPsr0[$first][$prefix] 137 | ); 138 | } else { 139 | $this->prefixesPsr0[$first][$prefix] = array_merge( 140 | $this->prefixesPsr0[$first][$prefix], 141 | (array) $paths 142 | ); 143 | } 144 | } 145 | 146 | /** 147 | * Registers a set of PSR-4 directories for a given namespace, either 148 | * appending or prepending to the ones previously set for this namespace. 149 | * 150 | * @param string $prefix The prefix/namespace, with trailing '\\' 151 | * @param array|string $paths The PSR-4 base directories 152 | * @param bool $prepend Whether to prepend the directories 153 | * 154 | * @throws \InvalidArgumentException 155 | */ 156 | public function addPsr4($prefix, $paths, $prepend = false) 157 | { 158 | if (!$prefix) { 159 | // Register directories for the root namespace. 160 | if ($prepend) { 161 | $this->fallbackDirsPsr4 = array_merge( 162 | (array) $paths, 163 | $this->fallbackDirsPsr4 164 | ); 165 | } else { 166 | $this->fallbackDirsPsr4 = array_merge( 167 | $this->fallbackDirsPsr4, 168 | (array) $paths 169 | ); 170 | } 171 | } elseif (!isset($this->prefixDirsPsr4[$prefix])) { 172 | // Register directories for a new namespace. 173 | $length = strlen($prefix); 174 | if ('\\' !== $prefix[$length - 1]) { 175 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); 176 | } 177 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 178 | $this->prefixDirsPsr4[$prefix] = (array) $paths; 179 | } elseif ($prepend) { 180 | // Prepend directories for an already registered namespace. 181 | $this->prefixDirsPsr4[$prefix] = array_merge( 182 | (array) $paths, 183 | $this->prefixDirsPsr4[$prefix] 184 | ); 185 | } else { 186 | // Append directories for an already registered namespace. 187 | $this->prefixDirsPsr4[$prefix] = array_merge( 188 | $this->prefixDirsPsr4[$prefix], 189 | (array) $paths 190 | ); 191 | } 192 | } 193 | 194 | /** 195 | * Registers a set of PSR-0 directories for a given prefix, 196 | * replacing any others previously set for this prefix. 197 | * 198 | * @param string $prefix The prefix 199 | * @param array|string $paths The PSR-0 base directories 200 | */ 201 | public function set($prefix, $paths) 202 | { 203 | if (!$prefix) { 204 | $this->fallbackDirsPsr0 = (array) $paths; 205 | } else { 206 | $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; 207 | } 208 | } 209 | 210 | /** 211 | * Registers a set of PSR-4 directories for a given namespace, 212 | * replacing any others previously set for this namespace. 213 | * 214 | * @param string $prefix The prefix/namespace, with trailing '\\' 215 | * @param array|string $paths The PSR-4 base directories 216 | * 217 | * @throws \InvalidArgumentException 218 | */ 219 | public function setPsr4($prefix, $paths) 220 | { 221 | if (!$prefix) { 222 | $this->fallbackDirsPsr4 = (array) $paths; 223 | } else { 224 | $length = strlen($prefix); 225 | if ('\\' !== $prefix[$length - 1]) { 226 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); 227 | } 228 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 229 | $this->prefixDirsPsr4[$prefix] = (array) $paths; 230 | } 231 | } 232 | 233 | /** 234 | * Turns on searching the include path for class files. 235 | * 236 | * @param bool $useIncludePath 237 | */ 238 | public function setUseIncludePath($useIncludePath) 239 | { 240 | $this->useIncludePath = $useIncludePath; 241 | } 242 | 243 | /** 244 | * Can be used to check if the autoloader uses the include path to check 245 | * for classes. 246 | * 247 | * @return bool 248 | */ 249 | public function getUseIncludePath() 250 | { 251 | return $this->useIncludePath; 252 | } 253 | 254 | /** 255 | * Turns off searching the prefix and fallback directories for classes 256 | * that have not been registered with the class map. 257 | * 258 | * @param bool $classMapAuthoritative 259 | */ 260 | public function setClassMapAuthoritative($classMapAuthoritative) 261 | { 262 | $this->classMapAuthoritative = $classMapAuthoritative; 263 | } 264 | 265 | /** 266 | * Should class lookup fail if not found in the current class map? 267 | * 268 | * @return bool 269 | */ 270 | public function isClassMapAuthoritative() 271 | { 272 | return $this->classMapAuthoritative; 273 | } 274 | 275 | /** 276 | * APCu prefix to use to cache found/not-found classes, if the extension is enabled. 277 | * 278 | * @param string|null $apcuPrefix 279 | */ 280 | public function setApcuPrefix($apcuPrefix) 281 | { 282 | $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; 283 | } 284 | 285 | /** 286 | * The APCu prefix in use, or null if APCu caching is not enabled. 287 | * 288 | * @return string|null 289 | */ 290 | public function getApcuPrefix() 291 | { 292 | return $this->apcuPrefix; 293 | } 294 | 295 | /** 296 | * Registers this instance as an autoloader. 297 | * 298 | * @param bool $prepend Whether to prepend the autoloader or not 299 | */ 300 | public function register($prepend = false) 301 | { 302 | spl_autoload_register(array($this, 'loadClass'), true, $prepend); 303 | } 304 | 305 | /** 306 | * Unregisters this instance as an autoloader. 307 | */ 308 | public function unregister() 309 | { 310 | spl_autoload_unregister(array($this, 'loadClass')); 311 | } 312 | 313 | /** 314 | * Loads the given class or interface. 315 | * 316 | * @param string $class The name of the class 317 | * @return bool|null True if loaded, null otherwise 318 | */ 319 | public function loadClass($class) 320 | { 321 | if ($file = $this->findFile($class)) { 322 | includeFile($file); 323 | 324 | return true; 325 | } 326 | } 327 | 328 | /** 329 | * Finds the path to the file where the class is defined. 330 | * 331 | * @param string $class The name of the class 332 | * 333 | * @return string|false The path if found, false otherwise 334 | */ 335 | public function findFile($class) 336 | { 337 | // class map lookup 338 | if (isset($this->classMap[$class])) { 339 | return $this->classMap[$class]; 340 | } 341 | if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { 342 | return false; 343 | } 344 | if (null !== $this->apcuPrefix) { 345 | $file = apcu_fetch($this->apcuPrefix.$class, $hit); 346 | if ($hit) { 347 | return $file; 348 | } 349 | } 350 | 351 | $file = $this->findFileWithExtension($class, '.php'); 352 | 353 | // Search for Hack files if we are running on HHVM 354 | if (false === $file && defined('HHVM_VERSION')) { 355 | $file = $this->findFileWithExtension($class, '.hh'); 356 | } 357 | 358 | if (null !== $this->apcuPrefix) { 359 | apcu_add($this->apcuPrefix.$class, $file); 360 | } 361 | 362 | if (false === $file) { 363 | // Remember that this class does not exist. 364 | $this->missingClasses[$class] = true; 365 | } 366 | 367 | return $file; 368 | } 369 | 370 | private function findFileWithExtension($class, $ext) 371 | { 372 | // PSR-4 lookup 373 | $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; 374 | 375 | $first = $class[0]; 376 | if (isset($this->prefixLengthsPsr4[$first])) { 377 | foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { 378 | if (0 === strpos($class, $prefix)) { 379 | foreach ($this->prefixDirsPsr4[$prefix] as $dir) { 380 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { 381 | return $file; 382 | } 383 | } 384 | } 385 | } 386 | } 387 | 388 | // PSR-4 fallback dirs 389 | foreach ($this->fallbackDirsPsr4 as $dir) { 390 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { 391 | return $file; 392 | } 393 | } 394 | 395 | // PSR-0 lookup 396 | if (false !== $pos = strrpos($class, '\\')) { 397 | // namespaced class name 398 | $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) 399 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); 400 | } else { 401 | // PEAR-like class name 402 | $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; 403 | } 404 | 405 | if (isset($this->prefixesPsr0[$first])) { 406 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { 407 | if (0 === strpos($class, $prefix)) { 408 | foreach ($dirs as $dir) { 409 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 410 | return $file; 411 | } 412 | } 413 | } 414 | } 415 | } 416 | 417 | // PSR-0 fallback dirs 418 | foreach ($this->fallbackDirsPsr0 as $dir) { 419 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 420 | return $file; 421 | } 422 | } 423 | 424 | // PSR-0 include paths. 425 | if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { 426 | return $file; 427 | } 428 | 429 | return false; 430 | } 431 | } 432 | 433 | /** 434 | * Scope isolated include. 435 | * 436 | * Prevents access to $this/self from included files. 437 | */ 438 | function includeFile($file) 439 | { 440 | include $file; 441 | } 442 | -------------------------------------------------------------------------------- /dist/composer/autoload_classmap.php: -------------------------------------------------------------------------------- 1 | $vendorDir . '/composer/installers/src/Composer/Installers/AglInstaller.php', 10 | 'Composer\\Installers\\AimeosInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AimeosInstaller.php', 11 | 'Composer\\Installers\\AnnotateCmsInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php', 12 | 'Composer\\Installers\\AsgardInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AsgardInstaller.php', 13 | 'Composer\\Installers\\AttogramInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AttogramInstaller.php', 14 | 'Composer\\Installers\\BaseInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/BaseInstaller.php', 15 | 'Composer\\Installers\\BitrixInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/BitrixInstaller.php', 16 | 'Composer\\Installers\\BonefishInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/BonefishInstaller.php', 17 | 'Composer\\Installers\\CakePHPInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CakePHPInstaller.php', 18 | 'Composer\\Installers\\ChefInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ChefInstaller.php', 19 | 'Composer\\Installers\\ClanCatsFrameworkInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php', 20 | 'Composer\\Installers\\CockpitInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CockpitInstaller.php', 21 | 'Composer\\Installers\\CodeIgniterInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php', 22 | 'Composer\\Installers\\Concrete5Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Concrete5Installer.php', 23 | 'Composer\\Installers\\CraftInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CraftInstaller.php', 24 | 'Composer\\Installers\\CroogoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CroogoInstaller.php', 25 | 'Composer\\Installers\\DecibelInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DecibelInstaller.php', 26 | 'Composer\\Installers\\DokuWikiInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DokuWikiInstaller.php', 27 | 'Composer\\Installers\\DolibarrInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DolibarrInstaller.php', 28 | 'Composer\\Installers\\DrupalInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DrupalInstaller.php', 29 | 'Composer\\Installers\\ElggInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ElggInstaller.php', 30 | 'Composer\\Installers\\ExpressionEngineInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php', 31 | 'Composer\\Installers\\FuelInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/FuelInstaller.php', 32 | 'Composer\\Installers\\FuelphpInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/FuelphpInstaller.php', 33 | 'Composer\\Installers\\GravInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/GravInstaller.php', 34 | 'Composer\\Installers\\HuradInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/HuradInstaller.php', 35 | 'Composer\\Installers\\ImageCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ImageCMSInstaller.php', 36 | 'Composer\\Installers\\Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Installer.php', 37 | 'Composer\\Installers\\JoomlaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/JoomlaInstaller.php', 38 | 'Composer\\Installers\\KirbyInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KirbyInstaller.php', 39 | 'Composer\\Installers\\KodiCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KodiCMSInstaller.php', 40 | 'Composer\\Installers\\KohanaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KohanaInstaller.php', 41 | 'Composer\\Installers\\LaravelInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LaravelInstaller.php', 42 | 'Composer\\Installers\\LithiumInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LithiumInstaller.php', 43 | 'Composer\\Installers\\MODULEWorkInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php', 44 | 'Composer\\Installers\\MODXEvoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MODXEvoInstaller.php', 45 | 'Composer\\Installers\\MagentoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MagentoInstaller.php', 46 | 'Composer\\Installers\\MakoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MakoInstaller.php', 47 | 'Composer\\Installers\\MauticInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MauticInstaller.php', 48 | 'Composer\\Installers\\MediaWikiInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MediaWikiInstaller.php', 49 | 'Composer\\Installers\\MicroweberInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MicroweberInstaller.php', 50 | 'Composer\\Installers\\MoodleInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MoodleInstaller.php', 51 | 'Composer\\Installers\\OctoberInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OctoberInstaller.php', 52 | 'Composer\\Installers\\OxidInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OxidInstaller.php', 53 | 'Composer\\Installers\\PPIInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PPIInstaller.php', 54 | 'Composer\\Installers\\PhiftyInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PhiftyInstaller.php', 55 | 'Composer\\Installers\\PhpBBInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PhpBBInstaller.php', 56 | 'Composer\\Installers\\PimcoreInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PimcoreInstaller.php', 57 | 'Composer\\Installers\\PiwikInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PiwikInstaller.php', 58 | 'Composer\\Installers\\PlentymarketsInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php', 59 | 'Composer\\Installers\\Plugin' => $vendorDir . '/composer/installers/src/Composer/Installers/Plugin.php', 60 | 'Composer\\Installers\\PrestashopInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PrestashopInstaller.php', 61 | 'Composer\\Installers\\PuppetInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PuppetInstaller.php', 62 | 'Composer\\Installers\\RadPHPInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/RadPHPInstaller.php', 63 | 'Composer\\Installers\\ReIndexInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ReIndexInstaller.php', 64 | 'Composer\\Installers\\RedaxoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/RedaxoInstaller.php', 65 | 'Composer\\Installers\\RoundcubeInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/RoundcubeInstaller.php', 66 | 'Composer\\Installers\\SMFInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SMFInstaller.php', 67 | 'Composer\\Installers\\ShopwareInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ShopwareInstaller.php', 68 | 'Composer\\Installers\\SilverStripeInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SilverStripeInstaller.php', 69 | 'Composer\\Installers\\Symfony1Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Symfony1Installer.php', 70 | 'Composer\\Installers\\TYPO3CmsInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php', 71 | 'Composer\\Installers\\TYPO3FlowInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php', 72 | 'Composer\\Installers\\TheliaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TheliaInstaller.php', 73 | 'Composer\\Installers\\TuskInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TuskInstaller.php', 74 | 'Composer\\Installers\\VanillaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/VanillaInstaller.php', 75 | 'Composer\\Installers\\WHMCSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WHMCSInstaller.php', 76 | 'Composer\\Installers\\WolfCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WolfCMSInstaller.php', 77 | 'Composer\\Installers\\WordPressInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WordPressInstaller.php', 78 | 'Composer\\Installers\\YawikInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/YawikInstaller.php', 79 | 'Composer\\Installers\\ZendInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZendInstaller.php', 80 | 'Composer\\Installers\\ZikulaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php', 81 | 'Noodlehaus\\AbstractConfig' => $vendorDir . '/hassankhan/config/src/AbstractConfig.php', 82 | 'Noodlehaus\\Config' => $vendorDir . '/hassankhan/config/src/Config.php', 83 | 'Noodlehaus\\ConfigInterface' => $vendorDir . '/hassankhan/config/src/ConfigInterface.php', 84 | 'Noodlehaus\\ErrorException' => $vendorDir . '/hassankhan/config/src/ErrorException.php', 85 | 'Noodlehaus\\Exception' => $vendorDir . '/hassankhan/config/src/Exception.php', 86 | 'Noodlehaus\\Exception\\EmptyDirectoryException' => $vendorDir . '/hassankhan/config/src/Exception/EmptyDirectoryException.php', 87 | 'Noodlehaus\\Exception\\FileNotFoundException' => $vendorDir . '/hassankhan/config/src/Exception/FileNotFoundException.php', 88 | 'Noodlehaus\\Exception\\ParseException' => $vendorDir . '/hassankhan/config/src/Exception/ParseException.php', 89 | 'Noodlehaus\\Exception\\UnsupportedFormatException' => $vendorDir . '/hassankhan/config/src/Exception/UnsupportedFormatException.php', 90 | 'Noodlehaus\\FileParser\\AbstractFileParser' => $vendorDir . '/hassankhan/config/src/FileParser/AbstractFileParser.php', 91 | 'Noodlehaus\\FileParser\\FileParserInterface' => $vendorDir . '/hassankhan/config/src/FileParser/FileParserInterface.php', 92 | 'Noodlehaus\\FileParser\\Ini' => $vendorDir . '/hassankhan/config/src/FileParser/Ini.php', 93 | 'Noodlehaus\\FileParser\\Json' => $vendorDir . '/hassankhan/config/src/FileParser/Json.php', 94 | 'Noodlehaus\\FileParser\\Php' => $vendorDir . '/hassankhan/config/src/FileParser/Php.php', 95 | 'Noodlehaus\\FileParser\\Xml' => $vendorDir . '/hassankhan/config/src/FileParser/Xml.php', 96 | 'Noodlehaus\\FileParser\\Yaml' => $vendorDir . '/hassankhan/config/src/FileParser/Yaml.php', 97 | 'Sober\\Bundle\\Bundle' => $baseDir . '/src/Bundle.php', 98 | 'Sober\\Bundle\\ConfigNoFile' => $baseDir . '/src/ConfigNoFile.php', 99 | 'Sober\\Bundle\\Loader' => $baseDir . '/src/Loader.php', 100 | ); 101 | -------------------------------------------------------------------------------- /dist/composer/autoload_files.php: -------------------------------------------------------------------------------- 1 | $vendorDir . '/tgmpa/tgm-plugin-activation/class-tgm-plugin-activation.php', 10 | ); 11 | -------------------------------------------------------------------------------- /dist/composer/autoload_namespaces.php: -------------------------------------------------------------------------------- 1 | array($baseDir . '/src'), 10 | 'Noodlehaus\\' => array($vendorDir . '/hassankhan/config/src'), 11 | 'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src/Composer/Installers'), 12 | ); 13 | -------------------------------------------------------------------------------- /dist/composer/autoload_real.php: -------------------------------------------------------------------------------- 1 | = 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); 27 | if ($useStaticLoader) { 28 | require_once __DIR__ . '/autoload_static.php'; 29 | 30 | call_user_func(\Composer\Autoload\ComposerStaticInitc2eaa5efacf85b727e01692ca431bea9::getInitializer($loader)); 31 | } else { 32 | $map = require __DIR__ . '/autoload_namespaces.php'; 33 | foreach ($map as $namespace => $path) { 34 | $loader->set($namespace, $path); 35 | } 36 | 37 | $map = require __DIR__ . '/autoload_psr4.php'; 38 | foreach ($map as $namespace => $path) { 39 | $loader->setPsr4($namespace, $path); 40 | } 41 | 42 | $classMap = require __DIR__ . '/autoload_classmap.php'; 43 | if ($classMap) { 44 | $loader->addClassMap($classMap); 45 | } 46 | } 47 | 48 | $loader->register(true); 49 | 50 | if ($useStaticLoader) { 51 | $includeFiles = Composer\Autoload\ComposerStaticInitc2eaa5efacf85b727e01692ca431bea9::$files; 52 | } else { 53 | $includeFiles = require __DIR__ . '/autoload_files.php'; 54 | } 55 | foreach ($includeFiles as $fileIdentifier => $file) { 56 | composerRequirec2eaa5efacf85b727e01692ca431bea9($fileIdentifier, $file); 57 | } 58 | 59 | return $loader; 60 | } 61 | } 62 | 63 | function composerRequirec2eaa5efacf85b727e01692ca431bea9($fileIdentifier, $file) 64 | { 65 | if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { 66 | require $file; 67 | 68 | $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /dist/composer/autoload_static.php: -------------------------------------------------------------------------------- 1 | __DIR__ . '/..' . '/tgmpa/tgm-plugin-activation/class-tgm-plugin-activation.php', 11 | ); 12 | 13 | public static $prefixLengthsPsr4 = array ( 14 | 'S' => 15 | array ( 16 | 'Sober\\Bundle\\' => 13, 17 | ), 18 | 'N' => 19 | array ( 20 | 'Noodlehaus\\' => 11, 21 | ), 22 | 'C' => 23 | array ( 24 | 'Composer\\Installers\\' => 20, 25 | ), 26 | ); 27 | 28 | public static $prefixDirsPsr4 = array ( 29 | 'Sober\\Bundle\\' => 30 | array ( 31 | 0 => __DIR__ . '/../..' . '/src', 32 | ), 33 | 'Noodlehaus\\' => 34 | array ( 35 | 0 => __DIR__ . '/..' . '/hassankhan/config/src', 36 | ), 37 | 'Composer\\Installers\\' => 38 | array ( 39 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', 40 | ), 41 | ); 42 | 43 | public static $classMap = array ( 44 | 'Composer\\Installers\\AglInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AglInstaller.php', 45 | 'Composer\\Installers\\AimeosInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AimeosInstaller.php', 46 | 'Composer\\Installers\\AnnotateCmsInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php', 47 | 'Composer\\Installers\\AsgardInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AsgardInstaller.php', 48 | 'Composer\\Installers\\AttogramInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AttogramInstaller.php', 49 | 'Composer\\Installers\\BaseInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/BaseInstaller.php', 50 | 'Composer\\Installers\\BitrixInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/BitrixInstaller.php', 51 | 'Composer\\Installers\\BonefishInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/BonefishInstaller.php', 52 | 'Composer\\Installers\\CakePHPInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CakePHPInstaller.php', 53 | 'Composer\\Installers\\ChefInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ChefInstaller.php', 54 | 'Composer\\Installers\\ClanCatsFrameworkInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php', 55 | 'Composer\\Installers\\CockpitInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CockpitInstaller.php', 56 | 'Composer\\Installers\\CodeIgniterInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php', 57 | 'Composer\\Installers\\Concrete5Installer' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Concrete5Installer.php', 58 | 'Composer\\Installers\\CraftInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CraftInstaller.php', 59 | 'Composer\\Installers\\CroogoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CroogoInstaller.php', 60 | 'Composer\\Installers\\DecibelInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DecibelInstaller.php', 61 | 'Composer\\Installers\\DokuWikiInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DokuWikiInstaller.php', 62 | 'Composer\\Installers\\DolibarrInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DolibarrInstaller.php', 63 | 'Composer\\Installers\\DrupalInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DrupalInstaller.php', 64 | 'Composer\\Installers\\ElggInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ElggInstaller.php', 65 | 'Composer\\Installers\\ExpressionEngineInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php', 66 | 'Composer\\Installers\\FuelInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/FuelInstaller.php', 67 | 'Composer\\Installers\\FuelphpInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/FuelphpInstaller.php', 68 | 'Composer\\Installers\\GravInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/GravInstaller.php', 69 | 'Composer\\Installers\\HuradInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/HuradInstaller.php', 70 | 'Composer\\Installers\\ImageCMSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ImageCMSInstaller.php', 71 | 'Composer\\Installers\\Installer' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Installer.php', 72 | 'Composer\\Installers\\JoomlaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/JoomlaInstaller.php', 73 | 'Composer\\Installers\\KirbyInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/KirbyInstaller.php', 74 | 'Composer\\Installers\\KodiCMSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/KodiCMSInstaller.php', 75 | 'Composer\\Installers\\KohanaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/KohanaInstaller.php', 76 | 'Composer\\Installers\\LaravelInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/LaravelInstaller.php', 77 | 'Composer\\Installers\\LithiumInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/LithiumInstaller.php', 78 | 'Composer\\Installers\\MODULEWorkInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php', 79 | 'Composer\\Installers\\MODXEvoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MODXEvoInstaller.php', 80 | 'Composer\\Installers\\MagentoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MagentoInstaller.php', 81 | 'Composer\\Installers\\MakoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MakoInstaller.php', 82 | 'Composer\\Installers\\MauticInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MauticInstaller.php', 83 | 'Composer\\Installers\\MediaWikiInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MediaWikiInstaller.php', 84 | 'Composer\\Installers\\MicroweberInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MicroweberInstaller.php', 85 | 'Composer\\Installers\\MoodleInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MoodleInstaller.php', 86 | 'Composer\\Installers\\OctoberInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/OctoberInstaller.php', 87 | 'Composer\\Installers\\OxidInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/OxidInstaller.php', 88 | 'Composer\\Installers\\PPIInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PPIInstaller.php', 89 | 'Composer\\Installers\\PhiftyInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PhiftyInstaller.php', 90 | 'Composer\\Installers\\PhpBBInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PhpBBInstaller.php', 91 | 'Composer\\Installers\\PimcoreInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PimcoreInstaller.php', 92 | 'Composer\\Installers\\PiwikInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PiwikInstaller.php', 93 | 'Composer\\Installers\\PlentymarketsInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php', 94 | 'Composer\\Installers\\Plugin' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Plugin.php', 95 | 'Composer\\Installers\\PrestashopInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PrestashopInstaller.php', 96 | 'Composer\\Installers\\PuppetInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PuppetInstaller.php', 97 | 'Composer\\Installers\\RadPHPInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/RadPHPInstaller.php', 98 | 'Composer\\Installers\\ReIndexInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ReIndexInstaller.php', 99 | 'Composer\\Installers\\RedaxoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/RedaxoInstaller.php', 100 | 'Composer\\Installers\\RoundcubeInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/RoundcubeInstaller.php', 101 | 'Composer\\Installers\\SMFInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/SMFInstaller.php', 102 | 'Composer\\Installers\\ShopwareInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ShopwareInstaller.php', 103 | 'Composer\\Installers\\SilverStripeInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/SilverStripeInstaller.php', 104 | 'Composer\\Installers\\Symfony1Installer' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Symfony1Installer.php', 105 | 'Composer\\Installers\\TYPO3CmsInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php', 106 | 'Composer\\Installers\\TYPO3FlowInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php', 107 | 'Composer\\Installers\\TheliaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TheliaInstaller.php', 108 | 'Composer\\Installers\\TuskInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TuskInstaller.php', 109 | 'Composer\\Installers\\VanillaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/VanillaInstaller.php', 110 | 'Composer\\Installers\\WHMCSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/WHMCSInstaller.php', 111 | 'Composer\\Installers\\WolfCMSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/WolfCMSInstaller.php', 112 | 'Composer\\Installers\\WordPressInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/WordPressInstaller.php', 113 | 'Composer\\Installers\\YawikInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/YawikInstaller.php', 114 | 'Composer\\Installers\\ZendInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZendInstaller.php', 115 | 'Composer\\Installers\\ZikulaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php', 116 | 'Noodlehaus\\AbstractConfig' => __DIR__ . '/..' . '/hassankhan/config/src/AbstractConfig.php', 117 | 'Noodlehaus\\Config' => __DIR__ . '/..' . '/hassankhan/config/src/Config.php', 118 | 'Noodlehaus\\ConfigInterface' => __DIR__ . '/..' . '/hassankhan/config/src/ConfigInterface.php', 119 | 'Noodlehaus\\ErrorException' => __DIR__ . '/..' . '/hassankhan/config/src/ErrorException.php', 120 | 'Noodlehaus\\Exception' => __DIR__ . '/..' . '/hassankhan/config/src/Exception.php', 121 | 'Noodlehaus\\Exception\\EmptyDirectoryException' => __DIR__ . '/..' . '/hassankhan/config/src/Exception/EmptyDirectoryException.php', 122 | 'Noodlehaus\\Exception\\FileNotFoundException' => __DIR__ . '/..' . '/hassankhan/config/src/Exception/FileNotFoundException.php', 123 | 'Noodlehaus\\Exception\\ParseException' => __DIR__ . '/..' . '/hassankhan/config/src/Exception/ParseException.php', 124 | 'Noodlehaus\\Exception\\UnsupportedFormatException' => __DIR__ . '/..' . '/hassankhan/config/src/Exception/UnsupportedFormatException.php', 125 | 'Noodlehaus\\FileParser\\AbstractFileParser' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/AbstractFileParser.php', 126 | 'Noodlehaus\\FileParser\\FileParserInterface' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/FileParserInterface.php', 127 | 'Noodlehaus\\FileParser\\Ini' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/Ini.php', 128 | 'Noodlehaus\\FileParser\\Json' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/Json.php', 129 | 'Noodlehaus\\FileParser\\Php' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/Php.php', 130 | 'Noodlehaus\\FileParser\\Xml' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/Xml.php', 131 | 'Noodlehaus\\FileParser\\Yaml' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/Yaml.php', 132 | 'Sober\\Bundle\\Bundle' => __DIR__ . '/../..' . '/src/Bundle.php', 133 | 'Sober\\Bundle\\ConfigNoFile' => __DIR__ . '/../..' . '/src/ConfigNoFile.php', 134 | 'Sober\\Bundle\\Loader' => __DIR__ . '/../..' . '/src/Loader.php', 135 | ); 136 | 137 | public static function getInitializer(ClassLoader $loader) 138 | { 139 | return \Closure::bind(function () use ($loader) { 140 | $loader->prefixLengthsPsr4 = ComposerStaticInitc2eaa5efacf85b727e01692ca431bea9::$prefixLengthsPsr4; 141 | $loader->prefixDirsPsr4 = ComposerStaticInitc2eaa5efacf85b727e01692ca431bea9::$prefixDirsPsr4; 142 | $loader->classMap = ComposerStaticInitc2eaa5efacf85b727e01692ca431bea9::$classMap; 143 | 144 | }, null, ClassLoader::class); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /dist/hassankhan/config/src/AbstractConfig.php: -------------------------------------------------------------------------------- 1 | 13 | * @author Hassan Khan 14 | * @link https://github.com/noodlehaus/config 15 | * @license MIT 16 | */ 17 | abstract class AbstractConfig implements ArrayAccess, ConfigInterface, Iterator 18 | { 19 | /** 20 | * Stores the configuration data 21 | * 22 | * @var array|null 23 | */ 24 | protected $data = null; 25 | 26 | /** 27 | * Caches the configuration data 28 | * 29 | * @var array 30 | */ 31 | protected $cache = array(); 32 | 33 | /** 34 | * Constructor method and sets default options, if any 35 | * 36 | * @param array $data 37 | */ 38 | public function __construct(array $data) 39 | { 40 | $this->data = array_merge($this->getDefaults(), $data); 41 | } 42 | 43 | /** 44 | * Override this method in your own subclass to provide an array of default 45 | * options and values 46 | * 47 | * @return array 48 | * 49 | * @codeCoverageIgnore 50 | */ 51 | protected function getDefaults() 52 | { 53 | return array(); 54 | } 55 | 56 | /** 57 | * ConfigInterface Methods 58 | */ 59 | 60 | /** 61 | * {@inheritDoc} 62 | */ 63 | public function get($key, $default = null) 64 | { 65 | if ($this->has($key)) { 66 | return $this->cache[$key]; 67 | } 68 | 69 | return $default; 70 | } 71 | 72 | /** 73 | * {@inheritDoc} 74 | */ 75 | public function set($key, $value) 76 | { 77 | $segs = explode('.', $key); 78 | $root = &$this->data; 79 | $cacheKey = ''; 80 | 81 | // Look for the key, creating nested keys if needed 82 | while ($part = array_shift($segs)) { 83 | if ($cacheKey != '') { 84 | $cacheKey .= '.'; 85 | } 86 | $cacheKey .= $part; 87 | if (!isset($root[$part]) && count($segs)) { 88 | $root[$part] = array(); 89 | } 90 | $root = &$root[$part]; 91 | 92 | //Unset all old nested cache 93 | if (isset($this->cache[$cacheKey])) { 94 | unset($this->cache[$cacheKey]); 95 | } 96 | 97 | //Unset all old nested cache in case of array 98 | if (count($segs) == 0) { 99 | foreach ($this->cache as $cacheLocalKey => $cacheValue) { 100 | if (substr($cacheLocalKey, 0, strlen($cacheKey)) === $cacheKey) { 101 | unset($this->cache[$cacheLocalKey]); 102 | } 103 | } 104 | } 105 | } 106 | 107 | // Assign value at target node 108 | $this->cache[$key] = $root = $value; 109 | } 110 | 111 | /** 112 | * {@inheritDoc} 113 | */ 114 | public function has($key) 115 | { 116 | // Check if already cached 117 | if (isset($this->cache[$key])) { 118 | return true; 119 | } 120 | 121 | $segments = explode('.', $key); 122 | $root = $this->data; 123 | 124 | // nested case 125 | foreach ($segments as $segment) { 126 | if (array_key_exists($segment, $root)) { 127 | $root = $root[$segment]; 128 | continue; 129 | } else { 130 | return false; 131 | } 132 | } 133 | 134 | // Set cache for the given key 135 | $this->cache[$key] = $root; 136 | 137 | return true; 138 | } 139 | 140 | /** 141 | * {@inheritDoc} 142 | */ 143 | public function all() 144 | { 145 | return $this->data; 146 | } 147 | 148 | /** 149 | * ArrayAccess Methods 150 | */ 151 | 152 | /** 153 | * Gets a value using the offset as a key 154 | * 155 | * @param string $offset 156 | * 157 | * @return mixed 158 | */ 159 | public function offsetGet($offset) 160 | { 161 | return $this->get($offset); 162 | } 163 | 164 | /** 165 | * Checks if a key exists 166 | * 167 | * @param string $offset 168 | * 169 | * @return bool 170 | */ 171 | public function offsetExists($offset) 172 | { 173 | return $this->has($offset); 174 | } 175 | 176 | /** 177 | * Sets a value using the offset as a key 178 | * 179 | * @param string $offset 180 | * @param mixed $value 181 | * 182 | * @return void 183 | */ 184 | public function offsetSet($offset, $value) 185 | { 186 | $this->set($offset, $value); 187 | } 188 | 189 | /** 190 | * Deletes a key and its value 191 | * 192 | * @param string $offset 193 | * 194 | * @return void 195 | */ 196 | public function offsetUnset($offset) 197 | { 198 | $this->set($offset, null); 199 | } 200 | 201 | /** 202 | * Iterator Methods 203 | */ 204 | 205 | /** 206 | * Returns the data array element referenced by its internal cursor 207 | * 208 | * @return mixed The element referenced by the data array's internal cursor. 209 | * If the array is empty or there is no element at the cursor, the 210 | * function returns false. If the array is undefined, the function 211 | * returns null 212 | */ 213 | public function current() 214 | { 215 | return (is_array($this->data) ? current($this->data) : null); 216 | } 217 | 218 | /** 219 | * Returns the data array index referenced by its internal cursor 220 | * 221 | * @return mixed The index referenced by the data array's internal cursor. 222 | * If the array is empty or undefined or there is no element at the 223 | * cursor, the function returns null 224 | */ 225 | public function key() 226 | { 227 | return (is_array($this->data) ? key($this->data) : null); 228 | } 229 | 230 | /** 231 | * Moves the data array's internal cursor forward one element 232 | * 233 | * @return mixed The element referenced by the data array's internal cursor 234 | * after the move is completed. If there are no more elements in the 235 | * array after the move, the function returns false. If the data array 236 | * is undefined, the function returns null 237 | */ 238 | public function next() 239 | { 240 | return (is_array($this->data) ? next($this->data) : null); 241 | } 242 | 243 | /** 244 | * Moves the data array's internal cursor to the first element 245 | * 246 | * @return mixed The element referenced by the data array's internal cursor 247 | * after the move is completed. If the data array is empty, the function 248 | * returns false. If the data array is undefined, the function returns 249 | * null 250 | */ 251 | public function rewind() 252 | { 253 | return (is_array($this->data) ? reset($this->data) : null); 254 | } 255 | 256 | /** 257 | * Tests whether the iterator's current index is valid 258 | * 259 | * @return bool True if the current index is valid; false otherwise 260 | */ 261 | public function valid() 262 | { 263 | return (is_array($this->data) ? key($this->data) !== null : false); 264 | } 265 | } 266 | -------------------------------------------------------------------------------- /dist/hassankhan/config/src/Config.php: -------------------------------------------------------------------------------- 1 | 14 | * @author Hassan Khan 15 | * @link https://github.com/noodlehaus/config 16 | * @license MIT 17 | */ 18 | class Config extends AbstractConfig 19 | { 20 | /** 21 | * All file formats supported by Config 22 | * 23 | * @var array 24 | */ 25 | private $supportedFileParsers = array( 26 | 'Noodlehaus\FileParser\Php', 27 | 'Noodlehaus\FileParser\Ini', 28 | 'Noodlehaus\FileParser\Json', 29 | 'Noodlehaus\FileParser\Xml', 30 | 'Noodlehaus\FileParser\Yaml' 31 | ); 32 | 33 | /** 34 | * Static method for loading a Config instance. 35 | * 36 | * @param string|array $path 37 | * 38 | * @return Config 39 | */ 40 | public static function load($path) 41 | { 42 | return new static($path); 43 | } 44 | 45 | /** 46 | * Loads a supported configuration file format. 47 | * 48 | * @param string|array $path 49 | * 50 | * @throws EmptyDirectoryException If `$path` is an empty directory 51 | */ 52 | public function __construct($path) 53 | { 54 | $paths = $this->getValidPath($path); 55 | $this->data = array(); 56 | 57 | foreach ($paths as $path) { 58 | 59 | // Get file information 60 | $info = pathinfo($path); 61 | $parts = explode('.', $info['basename']); 62 | $extension = array_pop($parts); 63 | if ($extension === 'dist') { 64 | $extension = array_pop($parts); 65 | } 66 | $parser = $this->getParser($extension); 67 | 68 | // Try and load file 69 | $this->data = array_replace_recursive($this->data, (array) $parser->parse($path)); 70 | } 71 | 72 | parent::__construct($this->data); 73 | } 74 | 75 | /** 76 | * Gets a parser for a given file extension 77 | * 78 | * @param string $extension 79 | * 80 | * @return Noodlehaus\FileParser\FileParserInterface 81 | * 82 | * @throws UnsupportedFormatException If `$path` is an unsupported file format 83 | */ 84 | private function getParser($extension) 85 | { 86 | $parser = null; 87 | 88 | foreach ($this->supportedFileParsers as $fileParser) { 89 | $tempParser = new $fileParser; 90 | 91 | if (in_array($extension, $tempParser->getSupportedExtensions($extension))) { 92 | $parser = $tempParser; 93 | continue; 94 | } 95 | 96 | } 97 | 98 | // If none exist, then throw an exception 99 | if ($parser === null) { 100 | throw new UnsupportedFormatException('Unsupported configuration format'); 101 | } 102 | 103 | return $parser; 104 | } 105 | 106 | /** 107 | * Gets an array of paths 108 | * 109 | * @param array $path 110 | * 111 | * @return array 112 | * 113 | * @throws FileNotFoundException If a file is not found at `$path` 114 | */ 115 | private function getPathFromArray($path) 116 | { 117 | $paths = array(); 118 | 119 | foreach ($path as $unverifiedPath) { 120 | try { 121 | // Check if `$unverifiedPath` is optional 122 | // If it exists, then it's added to the list 123 | // If it doesn't, it throws an exception which we catch 124 | if ($unverifiedPath[0] !== '?') { 125 | $paths = array_merge($paths, $this->getValidPath($unverifiedPath)); 126 | continue; 127 | } 128 | $optionalPath = ltrim($unverifiedPath, '?'); 129 | $paths = array_merge($paths, $this->getValidPath($optionalPath)); 130 | 131 | } catch (FileNotFoundException $e) { 132 | // If `$unverifiedPath` is optional, then skip it 133 | if ($unverifiedPath[0] === '?') { 134 | continue; 135 | } 136 | // Otherwise rethrow the exception 137 | throw $e; 138 | } 139 | } 140 | 141 | return $paths; 142 | } 143 | 144 | /** 145 | * Checks `$path` to see if it is either an array, a directory, or a file 146 | * 147 | * @param string|array $path 148 | * 149 | * @return array 150 | * 151 | * @throws EmptyDirectoryException If `$path` is an empty directory 152 | * 153 | * @throws FileNotFoundException If a file is not found at `$path` 154 | */ 155 | private function getValidPath($path) 156 | { 157 | // If `$path` is array 158 | if (is_array($path)) { 159 | return $this->getPathFromArray($path); 160 | } 161 | 162 | // If `$path` is a directory 163 | if (is_dir($path)) { 164 | $paths = glob($path . '/*.*'); 165 | if (empty($paths)) { 166 | throw new EmptyDirectoryException("Configuration directory: [$path] is empty"); 167 | } 168 | return $paths; 169 | } 170 | 171 | // If `$path` is not a file, throw an exception 172 | if (!file_exists($path)) { 173 | throw new FileNotFoundException("Configuration file: [$path] cannot be found"); 174 | } 175 | return array($path); 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /dist/hassankhan/config/src/ConfigInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @author Hassan Khan 11 | * @link https://github.com/noodlehaus/config 12 | * @license MIT 13 | */ 14 | interface ConfigInterface 15 | { 16 | /** 17 | * Gets a configuration setting using a simple or nested key. 18 | * Nested keys are similar to JSON paths that use the dot 19 | * dot notation. 20 | * 21 | * @param string $key 22 | * @param mixed $default 23 | * 24 | * @return mixed 25 | */ 26 | public function get($key, $default = null); 27 | 28 | /** 29 | * Function for setting configuration values, using 30 | * either simple or nested keys. 31 | * 32 | * @param string $key 33 | * @param mixed $value 34 | * 35 | * @return void 36 | */ 37 | public function set($key, $value); 38 | 39 | /** 40 | * Function for checking if configuration values exist, using 41 | * either simple or nested keys. 42 | * 43 | * @param string $key 44 | * 45 | * @return boolean 46 | */ 47 | public function has($key); 48 | 49 | /** 50 | * Get all of the configuration items 51 | * 52 | * @return array 53 | */ 54 | public function all(); 55 | } 56 | -------------------------------------------------------------------------------- /dist/hassankhan/config/src/ErrorException.php: -------------------------------------------------------------------------------- 1 | 10 | * @author Hassan Khan 11 | * @link https://github.com/noodlehaus/config 12 | * @license MIT 13 | */ 14 | abstract class AbstractFileParser implements FileParserInterface 15 | { 16 | 17 | /** 18 | * Path to the config file 19 | * 20 | * @var string 21 | */ 22 | protected $path; 23 | 24 | /** 25 | * Sets the path to the config file 26 | * 27 | * @param string $path 28 | * 29 | * @codeCoverageIgnore 30 | */ 31 | public function __construct($path) 32 | { 33 | $this->path = $path; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /dist/hassankhan/config/src/FileParser/FileParserInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @author Hassan Khan 11 | * @link https://github.com/noodlehaus/config 12 | * @license MIT 13 | */ 14 | interface FileParserInterface 15 | { 16 | /** 17 | * Parses a file from `$path` and gets its contents as an array 18 | * 19 | * @param string $path 20 | * 21 | * @return array 22 | */ 23 | public function parse($path); 24 | 25 | /** 26 | * Returns an array of allowed file extensions for this parser 27 | * 28 | * @return array 29 | */ 30 | public function getSupportedExtensions(); 31 | } 32 | -------------------------------------------------------------------------------- /dist/hassankhan/config/src/FileParser/Ini.php: -------------------------------------------------------------------------------- 1 | 12 | * @author Hassan Khan 13 | * @link https://github.com/noodlehaus/config 14 | * @license MIT 15 | */ 16 | class Ini implements FileParserInterface 17 | { 18 | /** 19 | * {@inheritDoc} 20 | * Parses an INI file as an array 21 | * 22 | * @throws ParseException If there is an error parsing the INI file 23 | */ 24 | public function parse($path) 25 | { 26 | $data = @parse_ini_file($path, true); 27 | 28 | if (!$data) { 29 | $error = error_get_last(); 30 | throw new ParseException($error); 31 | } 32 | 33 | return $data; 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | public function getSupportedExtensions() 40 | { 41 | return array('ini'); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /dist/hassankhan/config/src/FileParser/Json.php: -------------------------------------------------------------------------------- 1 | 12 | * @author Hassan Khan 13 | * @link https://github.com/noodlehaus/config 14 | * @license MIT 15 | */ 16 | class Json implements FileParserInterface 17 | { 18 | /** 19 | * {@inheritDoc} 20 | * Loads a JSON file as an array 21 | * 22 | * @throws ParseException If there is an error parsing the JSON file 23 | */ 24 | public function parse($path) 25 | { 26 | $data = json_decode(file_get_contents($path), true); 27 | 28 | if (json_last_error() !== JSON_ERROR_NONE) { 29 | $error_message = 'Syntax error'; 30 | if (function_exists('json_last_error_msg')) { 31 | $error_message = json_last_error_msg(); 32 | } 33 | 34 | $error = array( 35 | 'message' => $error_message, 36 | 'type' => json_last_error(), 37 | 'file' => $path, 38 | ); 39 | throw new ParseException($error); 40 | } 41 | 42 | return $data; 43 | } 44 | 45 | /** 46 | * {@inheritDoc} 47 | */ 48 | public function getSupportedExtensions() 49 | { 50 | return array('json'); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /dist/hassankhan/config/src/FileParser/Php.php: -------------------------------------------------------------------------------- 1 | 14 | * @author Hassan Khan 15 | * @link https://github.com/noodlehaus/config 16 | * @license MIT 17 | */ 18 | class Php implements FileParserInterface 19 | { 20 | /** 21 | * {@inheritDoc} 22 | * Loads a PHP file and gets its' contents as an array 23 | * 24 | * @throws ParseException If the PHP file throws an exception 25 | * @throws UnsupportedFormatException If the PHP file does not return an array 26 | */ 27 | public function parse($path) 28 | { 29 | // Require the file, if it throws an exception, rethrow it 30 | try { 31 | $temp = require $path; 32 | } catch (Exception $exception) { 33 | throw new ParseException( 34 | array( 35 | 'message' => 'PHP file threw an exception', 36 | 'exception' => $exception, 37 | ) 38 | ); 39 | } 40 | 41 | // If we have a callable, run it and expect an array back 42 | if (is_callable($temp)) { 43 | $temp = call_user_func($temp); 44 | } 45 | 46 | // Check for array, if its anything else, throw an exception 47 | if (!is_array($temp)) { 48 | throw new UnsupportedFormatException('PHP file does not return an array'); 49 | } 50 | 51 | return $temp; 52 | } 53 | 54 | /** 55 | * {@inheritDoc} 56 | */ 57 | public function getSupportedExtensions() 58 | { 59 | return array('php'); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /dist/hassankhan/config/src/FileParser/Xml.php: -------------------------------------------------------------------------------- 1 | 12 | * @author Hassan Khan 13 | * @link https://github.com/noodlehaus/config 14 | * @license MIT 15 | */ 16 | class Xml implements FileParserInterface 17 | { 18 | /** 19 | * {@inheritDoc} 20 | * Parses an XML file as an array 21 | * 22 | * @throws ParseException If there is an error parsing the XML file 23 | */ 24 | public function parse($path) 25 | { 26 | libxml_use_internal_errors(true); 27 | 28 | $data = simplexml_load_file($path, null, LIBXML_NOERROR); 29 | 30 | if ($data === false) { 31 | $errors = libxml_get_errors(); 32 | $latestError = array_pop($errors); 33 | $error = array( 34 | 'message' => $latestError->message, 35 | 'type' => $latestError->level, 36 | 'code' => $latestError->code, 37 | 'file' => $latestError->file, 38 | 'line' => $latestError->line, 39 | ); 40 | throw new ParseException($error); 41 | } 42 | 43 | $data = json_decode(json_encode($data), true); 44 | 45 | return $data; 46 | } 47 | 48 | /** 49 | * {@inheritDoc} 50 | */ 51 | public function getSupportedExtensions() 52 | { 53 | return array('xml'); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /dist/hassankhan/config/src/FileParser/Yaml.php: -------------------------------------------------------------------------------- 1 | 14 | * @author Hassan Khan 15 | * @link https://github.com/noodlehaus/config 16 | * @license MIT 17 | */ 18 | class Yaml implements FileParserInterface 19 | { 20 | /** 21 | * {@inheritDoc} 22 | * Loads a YAML/YML file as an array 23 | * 24 | * @throws ParseException If If there is an error parsing the YAML file 25 | */ 26 | public function parse($path) 27 | { 28 | try { 29 | $data = YamlParser::parse(file_get_contents($path)); 30 | } catch (Exception $exception) { 31 | throw new ParseException( 32 | array( 33 | 'message' => 'Error parsing YAML file', 34 | 'exception' => $exception, 35 | ) 36 | ); 37 | } 38 | 39 | return $data; 40 | } 41 | 42 | /** 43 | * {@inheritDoc} 44 | */ 45 | public function getSupportedExtensions() 46 | { 47 | return array('yaml', 'yml'); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /dist/tgmpa/tgm-plugin-activation/example.php: -------------------------------------------------------------------------------- 1 | 'TGM Example Plugin', // The plugin name. 65 | 'slug' => 'tgm-example-plugin', // The plugin slug (typically the folder name). 66 | 'source' => get_stylesheet_directory() . '/lib/plugins/tgm-example-plugin.zip', // The plugin source. 67 | 'required' => true, // If false, the plugin is only 'recommended' instead of required. 68 | 'version' => '', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. 69 | 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 70 | 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. 71 | 'external_url' => '', // If set, overrides default API URL and points to an external URL. 72 | 'is_callable' => '', // If set, this callable will be be checked for availability to determine if a plugin is active. 73 | ), 74 | 75 | // This is an example of how to include a plugin from an arbitrary external source in your theme. 76 | array( 77 | 'name' => 'TGM New Media Plugin', // The plugin name. 78 | 'slug' => 'tgm-new-media-plugin', // The plugin slug (typically the folder name). 79 | 'source' => 'https://s3.amazonaws.com/tgm/tgm-new-media-plugin.zip', // The plugin source. 80 | 'required' => true, // If false, the plugin is only 'recommended' instead of required. 81 | 'external_url' => 'https://github.com/thomasgriffin/New-Media-Image-Uploader', // If set, overrides default API URL and points to an external URL. 82 | ), 83 | 84 | // This is an example of how to include a plugin from a GitHub repository in your theme. 85 | // This presumes that the plugin code is based in the root of the GitHub repository 86 | // and not in a subdirectory ('/src') of the repository. 87 | array( 88 | 'name' => 'Adminbar Link Comments to Pending', 89 | 'slug' => 'adminbar-link-comments-to-pending', 90 | 'source' => 'https://github.com/jrfnl/WP-adminbar-comments-to-pending/archive/master.zip', 91 | ), 92 | 93 | // This is an example of how to include a plugin from the WordPress Plugin Repository. 94 | array( 95 | 'name' => 'BuddyPress', 96 | 'slug' => 'buddypress', 97 | 'required' => false, 98 | ), 99 | 100 | // This is an example of the use of 'is_callable' functionality. A user could - for instance - 101 | // have WPSEO installed *or* WPSEO Premium. The slug would in that last case be different, i.e. 102 | // 'wordpress-seo-premium'. 103 | // By setting 'is_callable' to either a function from that plugin or a class method 104 | // `array( 'class', 'method' )` similar to how you hook in to actions and filters, TGMPA can still 105 | // recognize the plugin as being installed. 106 | array( 107 | 'name' => 'WordPress SEO by Yoast', 108 | 'slug' => 'wordpress-seo', 109 | 'is_callable' => 'wpseo_init', 110 | ), 111 | 112 | ); 113 | 114 | /* 115 | * Array of configuration settings. Amend each line as needed. 116 | * 117 | * TGMPA will start providing localized text strings soon. If you already have translations of our standard 118 | * strings available, please help us make TGMPA even better by giving us access to these translations or by 119 | * sending in a pull-request with .po file(s) with the translations. 120 | * 121 | * Only uncomment the strings in the config array if you want to customize the strings. 122 | */ 123 | $config = array( 124 | 'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA. 125 | 'default_path' => '', // Default absolute path to bundled plugins. 126 | 'menu' => 'tgmpa-install-plugins', // Menu slug. 127 | 'parent_slug' => 'themes.php', // Parent menu slug. 128 | 'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used. 129 | 'has_notices' => true, // Show admin notices or not. 130 | 'dismissable' => true, // If false, a user cannot dismiss the nag message. 131 | 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 132 | 'is_automatic' => false, // Automatically activate plugins after installation or not. 133 | 'message' => '', // Message to output right before the plugins table. 134 | 135 | /* 136 | 'strings' => array( 137 | 'page_title' => __( 'Install Required Plugins', 'theme-slug' ), 138 | 'menu_title' => __( 'Install Plugins', 'theme-slug' ), 139 | /* translators: %s: plugin name. * / 140 | 'installing' => __( 'Installing Plugin: %s', 'theme-slug' ), 141 | /* translators: %s: plugin name. * / 142 | 'updating' => __( 'Updating Plugin: %s', 'theme-slug' ), 143 | 'oops' => __( 'Something went wrong with the plugin API.', 'theme-slug' ), 144 | 'notice_can_install_required' => _n_noop( 145 | /* translators: 1: plugin name(s). * / 146 | 'This theme requires the following plugin: %1$s.', 147 | 'This theme requires the following plugins: %1$s.', 148 | 'theme-slug' 149 | ), 150 | 'notice_can_install_recommended' => _n_noop( 151 | /* translators: 1: plugin name(s). * / 152 | 'This theme recommends the following plugin: %1$s.', 153 | 'This theme recommends the following plugins: %1$s.', 154 | 'theme-slug' 155 | ), 156 | 'notice_ask_to_update' => _n_noop( 157 | /* translators: 1: plugin name(s). * / 158 | 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 159 | 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 160 | 'theme-slug' 161 | ), 162 | 'notice_ask_to_update_maybe' => _n_noop( 163 | /* translators: 1: plugin name(s). * / 164 | 'There is an update available for: %1$s.', 165 | 'There are updates available for the following plugins: %1$s.', 166 | 'theme-slug' 167 | ), 168 | 'notice_can_activate_required' => _n_noop( 169 | /* translators: 1: plugin name(s). * / 170 | 'The following required plugin is currently inactive: %1$s.', 171 | 'The following required plugins are currently inactive: %1$s.', 172 | 'theme-slug' 173 | ), 174 | 'notice_can_activate_recommended' => _n_noop( 175 | /* translators: 1: plugin name(s). * / 176 | 'The following recommended plugin is currently inactive: %1$s.', 177 | 'The following recommended plugins are currently inactive: %1$s.', 178 | 'theme-slug' 179 | ), 180 | 'install_link' => _n_noop( 181 | 'Begin installing plugin', 182 | 'Begin installing plugins', 183 | 'theme-slug' 184 | ), 185 | 'update_link' => _n_noop( 186 | 'Begin updating plugin', 187 | 'Begin updating plugins', 188 | 'theme-slug' 189 | ), 190 | 'activate_link' => _n_noop( 191 | 'Begin activating plugin', 192 | 'Begin activating plugins', 193 | 'theme-slug' 194 | ), 195 | 'return' => __( 'Return to Required Plugins Installer', 'theme-slug' ), 196 | 'plugin_activated' => __( 'Plugin activated successfully.', 'theme-slug' ), 197 | 'activated_successfully' => __( 'The following plugin was activated successfully:', 'theme-slug' ), 198 | /* translators: 1: plugin name. * / 199 | 'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'theme-slug' ), 200 | /* translators: 1: plugin name. * / 201 | 'plugin_needs_higher_version' => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'theme-slug' ), 202 | /* translators: 1: dashboard link. * / 203 | 'complete' => __( 'All plugins installed and activated successfully. %1$s', 'theme-slug' ), 204 | 'dismiss' => __( 'Dismiss this notice', 'theme-slug' ), 205 | 'notice_cannot_install_activate' => __( 'There are one or more required or recommended plugins to install, update or activate.', 'theme-slug' ), 206 | 'contact_admin' => __( 'Please contact the administrator of this site for help.', 'theme-slug' ), 207 | 208 | 'nag_type' => '', // Determines admin notice type - can only be one of the typical WP notice classes, such as 'updated', 'update-nag', 'notice-warning', 'notice-info' or 'error'. Some of which may not work as expected in older WP versions. 209 | ), 210 | */ 211 | ); 212 | 213 | tgmpa( $plugins, $config ); 214 | } 215 | -------------------------------------------------------------------------------- /phpcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sober Coding Standards 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Bundle.php: -------------------------------------------------------------------------------- 1 | data = $data; 12 | 13 | if ($this->isDisabled()) { 14 | return; 15 | } 16 | 17 | $this->config(); 18 | $this->register(); 19 | } 20 | 21 | /** 22 | * Check to see if config has been disabled 23 | * 24 | * @return boolean 25 | */ 26 | protected function isDisabled() 27 | { 28 | return (($this->data['active'] === false) ? true : false); 29 | } 30 | 31 | /** 32 | * Config 33 | * 34 | * Required config for tgmpa() 35 | * @return $this 36 | */ 37 | protected function config() 38 | { 39 | $this->config = [ 40 | 'id' => 'sober', 41 | 'menu' => 'install-plugins', 42 | 'parent_slug' => 'plugins.php', 43 | 'is_automatic' => true 44 | ]; 45 | } 46 | 47 | /** 48 | * Register 49 | * 50 | * Hook into tgmpa_register and run function 51 | */ 52 | protected function register() 53 | { 54 | add_action('tgmpa_register', function () { 55 | tgmpa(array($this->data->all()), $this->config); 56 | }); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/ConfigNoFile.php: -------------------------------------------------------------------------------- 1 | getFile(); 18 | $this->load(); 19 | } 20 | 21 | /** 22 | * Get file 23 | */ 24 | protected function getFile() 25 | { 26 | $this->file = (has_filter('sober/bundle/file') ? apply_filters('sober/bundle/file', $this->file) : $this->getDefaultFile()); 27 | } 28 | 29 | /** 30 | * Get default file format 31 | */ 32 | protected function getDefaultFile() 33 | { 34 | $result = glob(get_stylesheet_directory() . '/bundle.*'); 35 | $result = empty($result) ? : $result[0]; 36 | 37 | return $result; 38 | } 39 | 40 | /** 41 | * Load 42 | */ 43 | protected function load() 44 | { 45 | if (!file_exists($this->file)) return; 46 | if (!$this->isFileSupported()) return; 47 | $this->config = new Config($this->file); 48 | ($this->isMultiple() ? $this->loadEach() : $this->run($this->config)); 49 | } 50 | 51 | /** 52 | * Is file supported 53 | * 54 | * @return boolean 55 | */ 56 | protected function isFileSupported() 57 | { 58 | return in_array(pathinfo($this->file, PATHINFO_EXTENSION), ['json', 'yaml', 'yml', 'php']); 59 | } 60 | 61 | /** 62 | * Is multidimensional config 63 | * 64 | * @return boolean 65 | */ 66 | protected function isMultiple() 67 | { 68 | return (is_array(current($this->config->all()))); 69 | } 70 | 71 | /** 72 | * Load each from multidimensional config 73 | */ 74 | protected function loadEach() 75 | { 76 | foreach ($this->config as $config) { 77 | $this->run(new ConfigNoFile($config)); 78 | } 79 | } 80 | 81 | /** 82 | * Run 83 | */ 84 | protected function run($config) 85 | { 86 | (new Bundle($config)); 87 | } 88 | } 89 | --------------------------------------------------------------------------------