├── .editorconfig ├── .github ├── json │ ├── post-type-all.json │ ├── post-type-basic.json │ ├── post-type-multiple.json │ ├── post-type-required.json │ ├── taxonomy-all.json │ ├── taxonomy-basic.json │ ├── taxonomy-multiple.json │ └── taxonomy-required.json ├── php │ ├── post-type-all.php │ ├── post-type-basic.php │ ├── post-type-multiple.php │ ├── post-type-required.php │ ├── taxonomy-all.php │ ├── taxonomy-basic.php │ ├── taxonomy-multiple.php │ └── taxonomy-required.php └── yaml │ ├── post-type-all.yaml │ ├── post-type-basic.yaml │ ├── post-type-multiple.yaml │ ├── post-type-required.yaml │ ├── taxonomy-all.yaml │ ├── taxonomy-basic.yaml │ ├── taxonomy-multiple.yaml │ └── taxonomy-required.yaml ├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── build.xml ├── 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 └── symfony │ └── yaml │ ├── Dumper.php │ ├── Escaper.php │ ├── Inline.php │ ├── Parser.php │ ├── Unescaper.php │ └── Yaml.php ├── models.php ├── phpcs.xml └── src ├── ConfigNoFile.php ├── Loader.php ├── Model.php └── Model ├── PostType.php └── Taxonomy.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/json/post-type-all.json: -------------------------------------------------------------------------------- 1 | { 2 | "active": true, 3 | "type": "cpt", 4 | "name": "book", 5 | "supports": [ 6 | "title", 7 | "editor", 8 | "comments", 9 | "revisions", 10 | "trackbacks", 11 | "author", 12 | "excerpt", 13 | "page-attributes", 14 | "thumbnail", 15 | "custom-fields", 16 | "post-formats" 17 | ], 18 | "labels": { 19 | "has_one": "Book", 20 | "has_many": "Books", 21 | "text_domain": "sage", 22 | "overrides": { 23 | "name": "Books", 24 | "singular_name": "Book", 25 | "menu_name": "Books", 26 | "name_admin_bar": "Book", 27 | "add_new": "Add New", 28 | "add_new_item": "Add New Book", 29 | "edit_item": "Edit Book", 30 | "new_item": "New Book", 31 | "view_item": "View Book", 32 | "view_items": "View Books", 33 | "search_items": "Search Books", 34 | "not_found": "No books found.", 35 | "not_found_in_trash": "No books found in Trash.", 36 | "parent_item-colon": "Parent Books:", 37 | "all_items": "All Books", 38 | "archives": "Book Archives", 39 | "attributes": "Book Attributes", 40 | "insert_into_item": "Insert into book", 41 | "uploaded_to_this_item": "Uploaded to this book", 42 | "featured_image": "Featured Image", 43 | "set_featured_image": "Set featured image", 44 | "remove_featured_image": "Remove featured image", 45 | "use_featured_image": "Use featured image", 46 | "filter_items_list": "Filter books list", 47 | "items_list_navigation": "Books list navigation", 48 | "items_list": "Books list" 49 | } 50 | }, 51 | "config": { 52 | "public": true, 53 | "publicly_queryable": true, 54 | "show_ui": true, 55 | "show_in_menu": true, 56 | "query_var": true, 57 | "has_archive": true, 58 | "hierarchical": false, 59 | "menu_position": null, 60 | "can_export": true, 61 | "capability_type": "post", 62 | "taxonomies": [ 63 | "category", 64 | "post_tag" 65 | ], 66 | "rewrite": { 67 | "slug": "book", 68 | "with_front": true, 69 | "feeds": true, 70 | "pages": true 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /.github/json/post-type-basic.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "cpt", 3 | "name": "book", 4 | "supports": [ 5 | "title", "editor", "thumbnail" 6 | ], 7 | "labels": { 8 | "has_one": "Book", 9 | "has_many": "Books", 10 | "text_domain": "sage" 11 | } 12 | } -------------------------------------------------------------------------------- /.github/json/post-type-multiple.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "cpt", 4 | "name": "book", 5 | "supports": [ 6 | "title", "editor", "thumbnail" 7 | ] 8 | }, 9 | { 10 | "type": "cpt", 11 | "name": "album", 12 | "supports": [ 13 | "title", "editor", "comments" 14 | ] 15 | } 16 | ] -------------------------------------------------------------------------------- /.github/json/post-type-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "post-type", 3 | "name": "book" 4 | } -------------------------------------------------------------------------------- /.github/json/taxonomy-all.json: -------------------------------------------------------------------------------- 1 | { 2 | "active": true, 3 | "type": "tax", 4 | "name": "genre", 5 | "links": [ 6 | "post", "book" 7 | ], 8 | "labels": { 9 | "has_one": "Genre", 10 | "has_many": "Genres", 11 | "text_domain": "sage", 12 | "overrides": { 13 | "name": "Genres", 14 | "singular_name": "Genre", 15 | "search_items": "Search Genres", 16 | "popular_items": "Popular Tags", 17 | "all_items": "All Tags", 18 | "parent_item": "Parent Category", 19 | "parent_item_colon": "Parent Category:", 20 | "edit_item": "Edit Tag", 21 | "view_item": "View Tag", 22 | "update_item": "Update Tag", 23 | "add_new_item": "Update New Tag", 24 | "new_item_name": "New Tag Name", 25 | "separate_items_with_commas": "Separate tags with commass", 26 | "add_or_remove_items": "Add or remove tags", 27 | "choose_from_most_used": "Choose from the most used tags", 28 | "not_found": "No tags found.", 29 | "no_terms": "No tags", 30 | "items_list_navigation": "Tags list navigation", 31 | "items_list": "Tags list" 32 | } 33 | }, 34 | "config": { 35 | "public": true, 36 | "publicly_queryable": true, 37 | "show_ui": true, 38 | "show_in_menu": true, 39 | "show_in_nav_menus": true, 40 | "show_in_rest": true, 41 | "rest_base": "genre", 42 | "rest_controller_class": "WP_REST_Terms_Controller", 43 | "show_tagcloud": true, 44 | "show_in_quick_edit": true, 45 | "show_admin_column": false, 46 | "capabilities": { 47 | "manage_terms": "manage_categories", 48 | "edit_terms": "manage_categories", 49 | "delete_terms": "manage_categories", 50 | "assign_terms": "edit_posts" 51 | }, 52 | "rewrite": { 53 | "slug": "genre", 54 | "hierarchical": false 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /.github/json/taxonomy-basic.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "tax", 3 | "name": "genre", 4 | "links": [ 5 | "post", "book" 6 | ], 7 | "labels": { 8 | "has_one": "Genre", 9 | "has_many": "Genres", 10 | "text_domain": "sage" 11 | } 12 | } -------------------------------------------------------------------------------- /.github/json/taxonomy-multiple.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "category", 4 | "name": "genre", 5 | "links": "book" 6 | }, 7 | { 8 | "type": "tag", 9 | "name": "author", 10 | "links": "book" 11 | } 12 | ] -------------------------------------------------------------------------------- /.github/json/taxonomy-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "taxonomy", 3 | "name": "genre" 4 | } -------------------------------------------------------------------------------- /.github/php/post-type-all.php: -------------------------------------------------------------------------------- 1 | true, 4 | 'type' => 'cpt', 5 | 'name' => 'book', 6 | 'supports' => [ 7 | 'title', 8 | 'editor', 9 | 'comments', 10 | 'revisions', 11 | 'trackbacks', 12 | 'author', 13 | 'excerpt', 14 | 'page-attributes', 15 | 'thumbnail', 16 | 'custom-fields', 17 | 'post-formats', 18 | ], 19 | 'labels' => [ 20 | 'has_one' => 'Book', 21 | 'has_many' => 'Books', 22 | 'text_domain' => 'sage', 23 | 'overrides' => [ 24 | 'name' => 'Books', 25 | 'singular_name' => 'Book', 26 | 'menu_name' => 'Books', 27 | 'name_admin_bar' => 'Book', 28 | 'add_new' => 'Add New', 29 | 'add_new_item' => 'Add New Book', 30 | 'edit_item' => 'Edit Book', 31 | 'new_item' => 'New Book', 32 | 'view_item' => 'View Book', 33 | 'view_items' => 'View Books', 34 | 'search_items' => 'Search Books', 35 | 'not_found' => 'No books found.', 36 | 'not_found_in_trash' => 'No books found in Trash.', 37 | 'parent_item-colon' => 'Parent Books:', 38 | 'all_items' => 'All Books', 39 | 'archives' => 'Book Archives', 40 | 'attributes' => 'Book Attributes', 41 | 'insert_into_item' => 'Insert into book', 42 | 'uploaded_to_this_item' => 'Uploaded to this book', 43 | 'featured_image' => 'Featured Image', 44 | 'set_featured_image' => 'Set featured image', 45 | 'remove_featured_image' => 'Remove featured image', 46 | 'use_featured_image' => 'Use featured image', 47 | 'filter_items_list' => 'Filter books list', 48 | 'items_list_navigation' => 'Books list navigation', 49 | 'items_list' => 'Books list', 50 | ], 51 | ], 52 | 'config' => [ 53 | 'public' => true, 54 | 'publicly_queryable' => true, 55 | 'show_ui' => true, 56 | 'show_in_menu' => true, 57 | 'query_var' => true, 58 | 'has_archive' => true, 59 | 'hierarchical' => false, 60 | 'menu_position' => NULL, 61 | 'can_export' => true, 62 | 'capability_type' => 'post', 63 | 'taxonomies' => [ 64 | 'category', 'post_tag' 65 | ], 66 | 'rewrite' => [ 67 | 'slug' => 'book', 68 | 'with_front' => true, 69 | 'feeds' => true, 70 | 'pages' => true, 71 | ], 72 | ], 73 | ]; -------------------------------------------------------------------------------- /.github/php/post-type-basic.php: -------------------------------------------------------------------------------- 1 | 'cpt', 4 | 'name' => 'book', 5 | 'supports' => [ 6 | 'title', 'editor', 'thumbnail', 7 | ], 8 | 'labels' => [ 9 | 'has_one' => 'Book', 10 | 'has_many' => 'Books', 11 | 'text_domain' => 'sage', 12 | ], 13 | ]; -------------------------------------------------------------------------------- /.github/php/post-type-multiple.php: -------------------------------------------------------------------------------- 1 | 'cpt', 5 | 'name' => 'book', 6 | 'supports' => [ 7 | 'title', 'editor', 'thumbnail', 8 | ], 9 | ], 10 | [ 11 | 'type' => 'cpt', 12 | 'name' => 'album', 13 | 'supports' => [ 14 | 'title', 'editor', 'comments', 15 | ] 16 | ], 17 | ]; -------------------------------------------------------------------------------- /.github/php/post-type-required.php: -------------------------------------------------------------------------------- 1 | 'post-type', 4 | 'name' => 'book', 5 | ]; -------------------------------------------------------------------------------- /.github/php/taxonomy-all.php: -------------------------------------------------------------------------------- 1 | true, 4 | 'type' => 'tax', 5 | 'name' => 'genre', 6 | 'links' => [ 7 | 'post', 'book', 8 | ], 9 | 'labels' => [ 10 | 'has_one' => 'Genre', 11 | 'has_many' => 'Genres', 12 | 'text_domain' => 'sage', 13 | 'overrides' => [ 14 | 'name' => 'Genres', 15 | 'singular_name' => 'Genre', 16 | 'search_items' => 'Search Genres', 17 | 'popular_items' => 'Popular Tags', 18 | 'all_items' => 'All Tags', 19 | 'parent_item' => 'Parent Category', 20 | 'parent_item_colon' => 'Parent Category:', 21 | 'edit_item' => 'Edit Tag', 22 | 'view_item' => 'View Tag', 23 | 'update_item' => 'Update Tag', 24 | 'add_new_item' => 'Update New Tag', 25 | 'new_item_name' => 'New Tag Name', 26 | 'separate_items_with_commas' => 'Separate tags with commass', 27 | 'add_or_remove_items' => 'Add or remove tags', 28 | 'choose_from_most_used' => 'Choose from the most used tags', 29 | 'not_found' => 'No tags found.', 30 | 'no_terms' => 'No tags', 31 | 'items_list_navigation' => 'Tags list navigation', 32 | 'items_list' => 'Tags list', 33 | ], 34 | ], 35 | 'config' => [ 36 | 'public' => true, 37 | 'publicly_queryable' => true, 38 | 'show_ui' => true, 39 | 'show_in_menu' => true, 40 | 'show_in_nav_menus' => true, 41 | 'show_in_rest' => true, 42 | 'rest_base' => 'genre', 43 | 'rest_controller_class' => 'WP_REST_Terms_Controller', 44 | 'show_tagcloud' => true, 45 | 'show_in_quick_edit' => true, 46 | 'show_admin_column' => false, 47 | 'capabilities' => [ 48 | 'manage_terms' => 'manage_categories', 49 | 'edit_terms' => 'manage_categories', 50 | 'delete_terms' => 'manage_categories', 51 | 'assign_terms' => 'edit_posts', 52 | ], 53 | 'rewrite' => [ 54 | 'slug' => 'genre', 55 | 'hierarchical' => false, 56 | ], 57 | ], 58 | ]; -------------------------------------------------------------------------------- /.github/php/taxonomy-basic.php: -------------------------------------------------------------------------------- 1 | 'tax', 4 | 'name' => 'genre', 5 | 'links' => [ 6 | 'post', 'book', 7 | ], 8 | 'labels' => [ 9 | 'has_one' => 'Genre', 10 | 'has_many' => 'Genres', 11 | 'text_domain' => 'sage', 12 | ], 13 | ]; -------------------------------------------------------------------------------- /.github/php/taxonomy-multiple.php: -------------------------------------------------------------------------------- 1 | 'category', 5 | 'name' => 'genre', 6 | 'links' => 'book', 7 | ], 8 | [ 9 | 'type' => 'tag', 10 | 'name' => 'author', 11 | 'links' => 'book', 12 | ], 13 | ]; -------------------------------------------------------------------------------- /.github/php/taxonomy-required.php: -------------------------------------------------------------------------------- 1 | 'taxonomy', 4 | 'name' => 'genre', 5 | ]; -------------------------------------------------------------------------------- /.github/yaml/post-type-all.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | active: true 3 | type: cpt 4 | name: book 5 | supports: 6 | - title 7 | - editor 8 | - comments 9 | - revisions 10 | - trackbacks 11 | - author 12 | - excerpt 13 | - page-attributes 14 | - thumbnail 15 | - custom-fields 16 | - post-formats 17 | labels: 18 | has_one: Book 19 | has_many: Books 20 | text_domain: sage 21 | overrides: 22 | name: Books 23 | singular_name: Book 24 | menu_name: Books 25 | name_admin_bar: Book 26 | add_new: Add New 27 | add_new_item: Add New Book 28 | edit_item: Edit Book 29 | new_item: New Book 30 | view_item: View Book 31 | view_items: View Books 32 | search_items: Search Books 33 | not_found: No books found. 34 | not_found_in_trash: No books found in Trash. 35 | parent_item-colon: 'Parent Books:' 36 | all_items: All Books 37 | archives: Book Archives 38 | attributes: Book Attributes 39 | insert_into_item: Insert into book 40 | uploaded_to_this_item: Uploaded to this book 41 | featured_image: Featured Image 42 | set_featured_image: Set featured image 43 | remove_featured_image: Remove featured image 44 | use_featured_image: Use featured image 45 | filter_items_list: Filter books list 46 | items_list_navigation: Books list navigation 47 | items_list: Books list 48 | config: 49 | public: true 50 | publicly_queryable: true 51 | show_ui: true 52 | show_in_menu: true 53 | query_var: true 54 | has_archive: true 55 | hierarchical: false 56 | menu_position: 57 | can_export: true 58 | capability_type: post 59 | taxonomies: 60 | - category 61 | - post_tag 62 | rewrite: 63 | slug: book 64 | with_front: true 65 | feeds: true 66 | pages: true 67 | -------------------------------------------------------------------------------- /.github/yaml/post-type-basic.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | type: cpt 3 | name: book 4 | supports: 5 | - title 6 | - editor 7 | - thumbnail 8 | labels: 9 | has_one: Book 10 | has_many: Books 11 | text_domain: sage 12 | -------------------------------------------------------------------------------- /.github/yaml/post-type-multiple.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - type: cpt 3 | name: book 4 | supports: 5 | - title 6 | - editor 7 | - thumbnail 8 | - type: cpt 9 | name: album 10 | supports: 11 | - title 12 | - editor 13 | - comments 14 | -------------------------------------------------------------------------------- /.github/yaml/post-type-required.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | type: post-type 3 | name: book 4 | -------------------------------------------------------------------------------- /.github/yaml/taxonomy-all.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | active: true 3 | type: tax 4 | name: genre 5 | links: 6 | - post 7 | - book 8 | labels: 9 | has_one: Genre 10 | has_many: Genres 11 | text_domain: sage 12 | overrides: 13 | name: Genres 14 | singular_name: Genre 15 | search_items: Search Genres 16 | popular_items: Popular Tags 17 | all_items: All Tags 18 | parent_item: Parent Category 19 | parent_item_colon: 'Parent Category:' 20 | edit_item: Edit Tag 21 | view_item: View Tag 22 | update_item: Update Tag 23 | add_new_item: Update New Tag 24 | new_item_name: New Tag Name 25 | separate_items_with_commas: Separate tags with commass 26 | add_or_remove_items: Add or remove tags 27 | choose_from_most_used: Choose from the most used tags 28 | not_found: No tags found. 29 | no_terms: No tags 30 | items_list_navigation: Tags list navigation 31 | items_list: Tags list 32 | config: 33 | public: true 34 | publicly_queryable: true 35 | show_ui: true 36 | show_in_menu: true 37 | show_in_nav_menus: true 38 | show_in_rest: true 39 | rest_base: genre 40 | rest_controller_class: WP_REST_Terms_Controller 41 | show_tagcloud: true 42 | show_in_quick_edit: true 43 | show_admin_column: false 44 | capabilities: 45 | manage_terms: manage_categories 46 | edit_terms: manage_categories 47 | delete_terms: manage_categories 48 | assign_terms: edit_posts 49 | rewrite: 50 | slug: genre 51 | hierarchical: false 52 | -------------------------------------------------------------------------------- /.github/yaml/taxonomy-basic.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | type: tax 3 | name: genre 4 | links: 5 | - post 6 | - book 7 | labels: 8 | has_one: Genre 9 | has_many: Genres 10 | text_domain: sage 11 | -------------------------------------------------------------------------------- /.github/yaml/taxonomy-multiple.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - type: category 3 | name: genre 4 | links: book 5 | - type: tag 6 | name: author 7 | links: book 8 | -------------------------------------------------------------------------------- /.github/yaml/taxonomy-required.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | type: taxonomy 3 | name: genre 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 1.1.0: 04 August 2018 2 | * Add extended-cpts support 3 | * Update dependencies 4 | 5 | ### 1.0.6: 28th Janurary 2018 6 | * Add if function_exists for add_action 7 | 8 | ### 1.0.5: 27th August 2017 9 | * If user is using Sage, default path to be app/models/ 10 | 11 | ### 1.0.4: 06th February 2017 12 | * Add PHP and YML file support 13 | 14 | ### 1.0.2: 05th January 2017 15 | * Fix multiple config per files bug 16 | * Refactor and chain methods 17 | 18 | ### 1.0.1: 03nd January 2017 19 | * Multidimensional array support added for json files 20 | * Include recursive support for $path subfolders 21 | 22 | ### 1.0.0: 02nd January 2017 23 | * Release Models 24 | -------------------------------------------------------------------------------- /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 | # Models 2 | 3 | Models is a WordPress plugin allowing you to create custom post types and taxonomies using JSON, YAML or PHP files. 4 | 5 | **[You can now set post types and taxonomies using Intervention 2.x.x.](https://github.com/soberwp/intervention)** 6 | 7 | ## Installation 8 | 9 | #### Composer: 10 | 11 | Recommended methods: 12 | 13 | [Roots Bedrock](https://roots.io/bedrock/) 14 | ```shell 15 | $ composer require soberwp/models:1.1.0 16 | ``` 17 | **Models** is a mu-plugin so it doesn't have to be activated. 18 | 19 | [Roots Sage](https://roots.io/sage/) 20 | ```shell 21 | $ composer require soberwp/models:1.1.0-p 22 | ``` 23 | 24 | #### Manual: 25 | 26 | * Download the [zip file](https://github.com/soberwp/models/archive/master.zip) 27 | * Unzip to your sites plugin folder 28 | * Activate via WordPress 29 | 30 | #### Requirements: 31 | 32 | * [PHP](http://php.net/manual/en/install.php) >= 5.6.x 33 | 34 | ## Setup 35 | 36 | By default, create folder `models/` within the active theme directory. 37 | 38 | If you are a [Roots Sage](https://roots.io/sage/) the default folder is `app/models/` 39 | 40 | Alternatively, you can define a custom path using the filter below within your themes `functions.php` file: 41 | 42 | ```php 43 | add_filter('sober/models/path', function () { 44 | return get_stylesheet_directory() . '/your-custom-folder'; 45 | }); 46 | ``` 47 | 48 | That's it, now go ahead and add `model-name.json` files, in the folder or subfolders to begin creating your models. Use [Unravel](https://github.com/soberwp/unravel) to automatically move the config files outside of your theme path for better separation of concerns. 49 | 50 | ## Usage 51 | 52 | The data structure follows a similar data structure to WordPress taxonomies and post types arrays, so if an config option is missing from the examples below, follow the developer's reference and place it within `"config": {}` 53 | 54 | If values are not specified, defaults are the same as WordPress defaults. 55 | 56 | Additionally, if the [Extended CPTs](https://github.com/johnbillion/extended-cpts) library is available, Models will use it when registering your post types and taxonomies instead allowing extended functionality within your Models. 57 | 58 | Extracted examples presented below are in JSON format. 59 | 60 | ### Post Types 61 | 62 | Create a custom post type. 63 | 64 | #### Required: 65 | 66 | * [post-type-required.json](.github/json/post-type-required.json) 67 | * [post-type-required.php](.github/php/post-type-required.php) 68 | * [post-type-required.yaml](.github/yaml/post-type-required.yaml) 69 | 70 | ```json 71 | { 72 | "type": "post-type", 73 | "name": "book" 74 | } 75 | ``` 76 | 77 | #### Basic: 78 | 79 | * [post-type-basic.json](.github/json/post-type-basic.json) 80 | * [post-type-basic.php](.github/php/post-type-basic.php) 81 | * [post-type-basic.yaml](.github/yaml/post-type-basic.yaml) 82 | 83 | ```json 84 | { 85 | "type": "cpt", 86 | "name": "book", 87 | "supports": [ 88 | "title", "editor", "thumbnail" 89 | ], 90 | "labels": { 91 | "has_one": "Book", 92 | "has_many": "Books", 93 | "text_domain": "sage" 94 | } 95 | } 96 | ``` 97 | 98 | In the above example, `"labels": {}` are redundant because `"Book"` and `"Books"` would have been generated from `"name"`. 99 | 100 | #### Multiple: 101 | 102 | * [post-type-multiple.json](.github/json/post-type-multiple.json) 103 | * [post-type-multiple.php](.github/php/post-type-multiple.php) 104 | * [post-type-multiple.yaml](.github/yaml/post-type-multiple.yaml) 105 | 106 | ```json 107 | [ 108 | { 109 | "type": "cpt", 110 | "name": "book", 111 | "supports": [ 112 | "title", "editor", "thumbnail" 113 | ] 114 | }, 115 | { 116 | "type": "cpt", 117 | "name": "album", 118 | "supports": [ 119 | "title", "editor", "comments" 120 | ] 121 | } 122 | ] 123 | ``` 124 | 125 | #### All Fields: 126 | 127 | * [post-type-all.json](.github/json/post-type-all.json) 128 | * [post-type-all.php](.github/php/post-type-all.php) 129 | * [post-type-all.yaml](.github/yaml/post-type-all.yaml) 130 | 131 | #### Post Type Tips: 132 | 133 | * `"active": false` stops the post type from being created. Default is set to `true`. 134 | * `"type": "post-type"` also accepts a shorthand `"type": "cpt"`; 135 | 136 | ### Taxonomies 137 | 138 | Create a custom taxonomy. 139 | 140 | #### Required: 141 | 142 | * [taxonomy-required.json](.github/json/taxonomy-required.json) 143 | * [taxonomy-required.php](.github/php/taxonomy-required.php) 144 | * [taxonomy-required.yaml](.github/yaml/taxonomy-required.yaml) 145 | 146 | ```json 147 | { 148 | "type": "taxonomy", 149 | "name": "genre" 150 | } 151 | ``` 152 | 153 | #### Basic: 154 | 155 | * [taxonomy-basic.json](.github/json/taxonomy-basic.json) 156 | * [taxonomy-basic.php](.github/php/taxonomy-basic.php) 157 | * [taxonomy-basic.yaml](.github/yaml/taxonomy-basic.yaml) 158 | 159 | ```json 160 | { 161 | "type": "tax", 162 | "name": "genre", 163 | "links": [ 164 | "post", "book" 165 | ], 166 | "labels": { 167 | "has_one": "Book Genre", 168 | "has_many": "Book Genres", 169 | "text_domain": "sage" 170 | } 171 | } 172 | ``` 173 | 174 | `"links": (string|array)` assigns the taxonomy to post types. Defaults to `"links": "post"` 175 | 176 | #### Multiple: 177 | 178 | * [taxonomy-multiple.json](.github/json/taxonomy-multiple.json) 179 | * [taxonomy-multiple.php](.github/php/taxonomy-multiple.php) 180 | * [taxonomy-multiple.yaml](.github/yaml/taxonomy-multiple.yaml) 181 | 182 | ```json 183 | [ 184 | { 185 | "type": "category", 186 | "name": "genre", 187 | "links": "book" 188 | }, 189 | { 190 | "type": "tag", 191 | "name": "author", 192 | "links": "book" 193 | } 194 | ] 195 | ``` 196 | 197 | `"type": "category"` and `"type": "tag"` shorthands are explained below under Tips. 198 | 199 | #### All Fields: 200 | 201 | * [taxonomy-all.json](.github/json/taxonomy-all.json) 202 | * [taxonomy-all.php](.github/php/taxonomy-all.php) 203 | * [taxonomy-all.yaml](.github/yaml/taxonomy-all.yaml) 204 | 205 | #### Taxonomy Tips: 206 | 207 | * `"active": false` stops the taxonomy from being created. Default is set to `true`. 208 | * `"type": "taxonomy"` also accepts shorthands; 209 | * `"type": "tax"` 210 | * `"type": "category"` or `"type": "cat"` creates a category taxonomy. 211 | * `"type": "tag"` creates a tag taxonomy. 212 | 213 | ## Support 214 | 215 | * Follow [@withjacoby](https://twitter.com/withjacoby) on Twitter 216 | * Buy me a beer or pay my rent, [paypal.me/darrenjacoby](https://paypal.me/darrenjacoby) 217 | 218 | ## Updates 219 | 220 | #### Composer: 221 | 222 | * Change the composer.json version to ^1.0.4** 223 | * Check [CHANGELOG.md](CHANGELOG.md) for any breaking changes before updating. 224 | 225 | ```shell 226 | $ composer update 227 | ``` 228 | 229 | #### WordPress: 230 | 231 | Includes support for [github-updater](https://github.com/afragen/github-updater) to keep track on updates through the WordPress backend. 232 | * Download [github-updater](https://github.com/afragen/github-updater) 233 | * Clone [github-updater](https://github.com/afragen/github-updater) to your sites plugins/ folder 234 | * Activate via WordPress 235 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "soberwp/models", 3 | "type": "wordpress-muplugin", 4 | "license": "MIT", 5 | "description": "WordPress plugin to create custom post types and taxonomies using JSON, YAML or PHP files.", 6 | "homepage": "https://github.com/soberwp", 7 | "authors": [ 8 | { 9 | "name": "Darren Jacoby", 10 | "email": "darren@jacoby.co.za", 11 | "homepage": "https://github.com/darrenjacoby" 12 | } 13 | ], 14 | "keywords": [ 15 | "wordpress" 16 | ], 17 | "support": { 18 | "issues": "https://github.com/soberwp/models/issues" 19 | }, 20 | "require": { 21 | "php": ">=5.6", 22 | "composer/installers": "^1.5", 23 | "hassankhan/config": "^1.0", 24 | "symfony/yaml": "^3.4" 25 | }, 26 | "require-dev": { 27 | "squizlabs/php_codesniffer": "2.*" 28 | }, 29 | "autoload": { 30 | "psr-4": { 31 | "Sober\\Models\\": "src/", 32 | "Sober\\Models\\Model\\": "src/Model/" 33 | } 34 | }, 35 | "scripts": { 36 | "test": [ 37 | "vendor/bin/phpcs --extensions=php --ignore=vendor/ ." 38 | ] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /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": "9a5b53fdd296a7170e9e6a6f93167f18", 8 | "packages": [ 9 | { 10 | "name": "composer/installers", 11 | "version": "v1.6.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/composer/installers.git", 15 | "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/composer/installers/zipball/cfcca6b1b60bc4974324efb5783c13dca6932b5b", 20 | "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b", 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.8.36" 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 | "majima", 104 | "mako", 105 | "mediawiki", 106 | "modulework", 107 | "modx", 108 | "moodle", 109 | "osclass", 110 | "phpbb", 111 | "piwik", 112 | "ppi", 113 | "puppet", 114 | "pxcms", 115 | "reindex", 116 | "roundcube", 117 | "shopware", 118 | "silverstripe", 119 | "sydes", 120 | "symfony", 121 | "typo3", 122 | "wordpress", 123 | "yawik", 124 | "zend", 125 | "zikula" 126 | ], 127 | "time": "2018-08-27T06:10:37+00:00" 128 | }, 129 | { 130 | "name": "hassankhan/config", 131 | "version": "1.1.0", 132 | "source": { 133 | "type": "git", 134 | "url": "https://github.com/hassankhan/config.git", 135 | "reference": "930556337783acfd95bde723354119178db01d10" 136 | }, 137 | "dist": { 138 | "type": "zip", 139 | "url": "https://api.github.com/repos/hassankhan/config/zipball/930556337783acfd95bde723354119178db01d10", 140 | "reference": "930556337783acfd95bde723354119178db01d10", 141 | "shasum": "" 142 | }, 143 | "require": { 144 | "php": ">=5.5.9" 145 | }, 146 | "require-dev": { 147 | "phpunit/phpunit": "~4.0", 148 | "scrutinizer/ocular": "~1.1", 149 | "squizlabs/php_codesniffer": "~2.2", 150 | "symfony/yaml": "~3.4" 151 | }, 152 | "suggest": { 153 | "symfony/yaml": "~3.4" 154 | }, 155 | "type": "library", 156 | "autoload": { 157 | "psr-4": { 158 | "Noodlehaus\\": "src" 159 | } 160 | }, 161 | "notification-url": "https://packagist.org/downloads/", 162 | "license": [ 163 | "MIT" 164 | ], 165 | "authors": [ 166 | { 167 | "name": "Hassan Khan", 168 | "homepage": "http://hassankhan.me/", 169 | "role": "Developer" 170 | } 171 | ], 172 | "description": "Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files", 173 | "homepage": "http://hassankhan.me/config/", 174 | "keywords": [ 175 | "config", 176 | "configuration", 177 | "ini", 178 | "json", 179 | "microphp", 180 | "unframework", 181 | "xml", 182 | "yaml", 183 | "yml" 184 | ], 185 | "time": "2018-08-22T14:18:52+00:00" 186 | }, 187 | { 188 | "name": "symfony/polyfill-ctype", 189 | "version": "v1.9.0", 190 | "source": { 191 | "type": "git", 192 | "url": "https://github.com/symfony/polyfill-ctype.git", 193 | "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" 194 | }, 195 | "dist": { 196 | "type": "zip", 197 | "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", 198 | "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", 199 | "shasum": "" 200 | }, 201 | "require": { 202 | "php": ">=5.3.3" 203 | }, 204 | "suggest": { 205 | "ext-ctype": "For best performance" 206 | }, 207 | "type": "library", 208 | "extra": { 209 | "branch-alias": { 210 | "dev-master": "1.9-dev" 211 | } 212 | }, 213 | "autoload": { 214 | "psr-4": { 215 | "Symfony\\Polyfill\\Ctype\\": "" 216 | }, 217 | "files": [ 218 | "bootstrap.php" 219 | ] 220 | }, 221 | "notification-url": "https://packagist.org/downloads/", 222 | "license": [ 223 | "MIT" 224 | ], 225 | "authors": [ 226 | { 227 | "name": "Symfony Community", 228 | "homepage": "https://symfony.com/contributors" 229 | }, 230 | { 231 | "name": "Gert de Pagter", 232 | "email": "BackEndTea@gmail.com" 233 | } 234 | ], 235 | "description": "Symfony polyfill for ctype functions", 236 | "homepage": "https://symfony.com", 237 | "keywords": [ 238 | "compatibility", 239 | "ctype", 240 | "polyfill", 241 | "portable" 242 | ], 243 | "time": "2018-08-06T14:22:27+00:00" 244 | }, 245 | { 246 | "name": "symfony/yaml", 247 | "version": "v3.4.16", 248 | "source": { 249 | "type": "git", 250 | "url": "https://github.com/symfony/yaml.git", 251 | "reference": "61973ecda60e9f3561e929e19c07d4878b960fc1" 252 | }, 253 | "dist": { 254 | "type": "zip", 255 | "url": "https://api.github.com/repos/symfony/yaml/zipball/61973ecda60e9f3561e929e19c07d4878b960fc1", 256 | "reference": "61973ecda60e9f3561e929e19c07d4878b960fc1", 257 | "shasum": "" 258 | }, 259 | "require": { 260 | "php": "^5.5.9|>=7.0.8", 261 | "symfony/polyfill-ctype": "~1.8" 262 | }, 263 | "conflict": { 264 | "symfony/console": "<3.4" 265 | }, 266 | "require-dev": { 267 | "symfony/console": "~3.4|~4.0" 268 | }, 269 | "suggest": { 270 | "symfony/console": "For validating YAML files using the lint command" 271 | }, 272 | "type": "library", 273 | "extra": { 274 | "branch-alias": { 275 | "dev-master": "3.4-dev" 276 | } 277 | }, 278 | "autoload": { 279 | "psr-4": { 280 | "Symfony\\Component\\Yaml\\": "" 281 | }, 282 | "exclude-from-classmap": [ 283 | "/Tests/" 284 | ] 285 | }, 286 | "notification-url": "https://packagist.org/downloads/", 287 | "license": [ 288 | "MIT" 289 | ], 290 | "authors": [ 291 | { 292 | "name": "Fabien Potencier", 293 | "email": "fabien@symfony.com" 294 | }, 295 | { 296 | "name": "Symfony Community", 297 | "homepage": "https://symfony.com/contributors" 298 | } 299 | ], 300 | "description": "Symfony Yaml Component", 301 | "homepage": "https://symfony.com", 302 | "time": "2018-09-24T08:15:45+00:00" 303 | } 304 | ], 305 | "packages-dev": [ 306 | { 307 | "name": "squizlabs/php_codesniffer", 308 | "version": "2.9.1", 309 | "source": { 310 | "type": "git", 311 | "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", 312 | "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62" 313 | }, 314 | "dist": { 315 | "type": "zip", 316 | "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62", 317 | "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62", 318 | "shasum": "" 319 | }, 320 | "require": { 321 | "ext-simplexml": "*", 322 | "ext-tokenizer": "*", 323 | "ext-xmlwriter": "*", 324 | "php": ">=5.1.2" 325 | }, 326 | "require-dev": { 327 | "phpunit/phpunit": "~4.0" 328 | }, 329 | "bin": [ 330 | "scripts/phpcs", 331 | "scripts/phpcbf" 332 | ], 333 | "type": "library", 334 | "extra": { 335 | "branch-alias": { 336 | "dev-master": "2.x-dev" 337 | } 338 | }, 339 | "autoload": { 340 | "classmap": [ 341 | "CodeSniffer.php", 342 | "CodeSniffer/CLI.php", 343 | "CodeSniffer/Exception.php", 344 | "CodeSniffer/File.php", 345 | "CodeSniffer/Fixer.php", 346 | "CodeSniffer/Report.php", 347 | "CodeSniffer/Reporting.php", 348 | "CodeSniffer/Sniff.php", 349 | "CodeSniffer/Tokens.php", 350 | "CodeSniffer/Reports/", 351 | "CodeSniffer/Tokenizers/", 352 | "CodeSniffer/DocGenerators/", 353 | "CodeSniffer/Standards/AbstractPatternSniff.php", 354 | "CodeSniffer/Standards/AbstractScopeSniff.php", 355 | "CodeSniffer/Standards/AbstractVariableSniff.php", 356 | "CodeSniffer/Standards/IncorrectPatternException.php", 357 | "CodeSniffer/Standards/Generic/Sniffs/", 358 | "CodeSniffer/Standards/MySource/Sniffs/", 359 | "CodeSniffer/Standards/PEAR/Sniffs/", 360 | "CodeSniffer/Standards/PSR1/Sniffs/", 361 | "CodeSniffer/Standards/PSR2/Sniffs/", 362 | "CodeSniffer/Standards/Squiz/Sniffs/", 363 | "CodeSniffer/Standards/Zend/Sniffs/" 364 | ] 365 | }, 366 | "notification-url": "https://packagist.org/downloads/", 367 | "license": [ 368 | "BSD-3-Clause" 369 | ], 370 | "authors": [ 371 | { 372 | "name": "Greg Sherwood", 373 | "role": "lead" 374 | } 375 | ], 376 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", 377 | "homepage": "http://www.squizlabs.com/php-codesniffer", 378 | "keywords": [ 379 | "phpcs", 380 | "standards" 381 | ], 382 | "time": "2017-05-22T02:43:20+00:00" 383 | } 384 | ], 385 | "aliases": [], 386 | "minimum-stability": "stable", 387 | "stability-flags": [], 388 | "prefer-stable": false, 389 | "prefer-lowest": false, 390 | "platform": { 391 | "php": ">=5.6" 392 | }, 393 | "platform-dev": [] 394 | } 395 | -------------------------------------------------------------------------------- /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 | $subPath = $class; 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { 379 | $subPath = substr($subPath, 0, $lastPos); 380 | $search = $subPath.'\\'; 381 | if (isset($this->prefixDirsPsr4[$search])) { 382 | $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { 384 | if (file_exists($file = $dir . $pathEnd)) { 385 | return $file; 386 | } 387 | } 388 | } 389 | } 390 | } 391 | 392 | // PSR-4 fallback dirs 393 | foreach ($this->fallbackDirsPsr4 as $dir) { 394 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { 395 | return $file; 396 | } 397 | } 398 | 399 | // PSR-0 lookup 400 | if (false !== $pos = strrpos($class, '\\')) { 401 | // namespaced class name 402 | $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); 404 | } else { 405 | // PEAR-like class name 406 | $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; 407 | } 408 | 409 | if (isset($this->prefixesPsr0[$first])) { 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { 411 | if (0 === strpos($class, $prefix)) { 412 | foreach ($dirs as $dir) { 413 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 414 | return $file; 415 | } 416 | } 417 | } 418 | } 419 | } 420 | 421 | // PSR-0 fallback dirs 422 | foreach ($this->fallbackDirsPsr0 as $dir) { 423 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 424 | return $file; 425 | } 426 | } 427 | 428 | // PSR-0 include paths. 429 | if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { 430 | return $file; 431 | } 432 | 433 | return false; 434 | } 435 | } 436 | 437 | /** 438 | * Scope isolated include. 439 | * 440 | * Prevents access to $this/self from included files. 441 | */ 442 | function includeFile($file) 443 | { 444 | include $file; 445 | } 446 | -------------------------------------------------------------------------------- /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\\EliasisInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/EliasisInstaller.php', 31 | 'Composer\\Installers\\ExpressionEngineInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php', 32 | 'Composer\\Installers\\EzPlatformInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/EzPlatformInstaller.php', 33 | 'Composer\\Installers\\FuelInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/FuelInstaller.php', 34 | 'Composer\\Installers\\FuelphpInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/FuelphpInstaller.php', 35 | 'Composer\\Installers\\GravInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/GravInstaller.php', 36 | 'Composer\\Installers\\HuradInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/HuradInstaller.php', 37 | 'Composer\\Installers\\ImageCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ImageCMSInstaller.php', 38 | 'Composer\\Installers\\Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Installer.php', 39 | 'Composer\\Installers\\ItopInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ItopInstaller.php', 40 | 'Composer\\Installers\\JoomlaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/JoomlaInstaller.php', 41 | 'Composer\\Installers\\KanboardInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KanboardInstaller.php', 42 | 'Composer\\Installers\\KirbyInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KirbyInstaller.php', 43 | 'Composer\\Installers\\KodiCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KodiCMSInstaller.php', 44 | 'Composer\\Installers\\KohanaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KohanaInstaller.php', 45 | 'Composer\\Installers\\LanManagementSystemInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php', 46 | 'Composer\\Installers\\LaravelInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LaravelInstaller.php', 47 | 'Composer\\Installers\\LavaLiteInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LavaLiteInstaller.php', 48 | 'Composer\\Installers\\LithiumInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LithiumInstaller.php', 49 | 'Composer\\Installers\\MODULEWorkInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php', 50 | 'Composer\\Installers\\MODXEvoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MODXEvoInstaller.php', 51 | 'Composer\\Installers\\MagentoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MagentoInstaller.php', 52 | 'Composer\\Installers\\MajimaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MajimaInstaller.php', 53 | 'Composer\\Installers\\MakoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MakoInstaller.php', 54 | 'Composer\\Installers\\MauticInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MauticInstaller.php', 55 | 'Composer\\Installers\\MayaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MayaInstaller.php', 56 | 'Composer\\Installers\\MediaWikiInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MediaWikiInstaller.php', 57 | 'Composer\\Installers\\MicroweberInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MicroweberInstaller.php', 58 | 'Composer\\Installers\\ModxInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ModxInstaller.php', 59 | 'Composer\\Installers\\MoodleInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MoodleInstaller.php', 60 | 'Composer\\Installers\\OctoberInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OctoberInstaller.php', 61 | 'Composer\\Installers\\OntoWikiInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OntoWikiInstaller.php', 62 | 'Composer\\Installers\\OsclassInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OsclassInstaller.php', 63 | 'Composer\\Installers\\OxidInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OxidInstaller.php', 64 | 'Composer\\Installers\\PPIInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PPIInstaller.php', 65 | 'Composer\\Installers\\PhiftyInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PhiftyInstaller.php', 66 | 'Composer\\Installers\\PhpBBInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PhpBBInstaller.php', 67 | 'Composer\\Installers\\PimcoreInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PimcoreInstaller.php', 68 | 'Composer\\Installers\\PiwikInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PiwikInstaller.php', 69 | 'Composer\\Installers\\PlentymarketsInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php', 70 | 'Composer\\Installers\\Plugin' => $vendorDir . '/composer/installers/src/Composer/Installers/Plugin.php', 71 | 'Composer\\Installers\\PortoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PortoInstaller.php', 72 | 'Composer\\Installers\\PrestashopInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PrestashopInstaller.php', 73 | 'Composer\\Installers\\PuppetInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PuppetInstaller.php', 74 | 'Composer\\Installers\\PxcmsInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PxcmsInstaller.php', 75 | 'Composer\\Installers\\RadPHPInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/RadPHPInstaller.php', 76 | 'Composer\\Installers\\ReIndexInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ReIndexInstaller.php', 77 | 'Composer\\Installers\\RedaxoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/RedaxoInstaller.php', 78 | 'Composer\\Installers\\RoundcubeInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/RoundcubeInstaller.php', 79 | 'Composer\\Installers\\SMFInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SMFInstaller.php', 80 | 'Composer\\Installers\\ShopwareInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ShopwareInstaller.php', 81 | 'Composer\\Installers\\SilverStripeInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SilverStripeInstaller.php', 82 | 'Composer\\Installers\\SiteDirectInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SiteDirectInstaller.php', 83 | 'Composer\\Installers\\SyDESInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SyDESInstaller.php', 84 | 'Composer\\Installers\\Symfony1Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Symfony1Installer.php', 85 | 'Composer\\Installers\\TYPO3CmsInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php', 86 | 'Composer\\Installers\\TYPO3FlowInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php', 87 | 'Composer\\Installers\\TheliaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TheliaInstaller.php', 88 | 'Composer\\Installers\\TuskInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TuskInstaller.php', 89 | 'Composer\\Installers\\UserFrostingInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/UserFrostingInstaller.php', 90 | 'Composer\\Installers\\VanillaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/VanillaInstaller.php', 91 | 'Composer\\Installers\\VgmcpInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/VgmcpInstaller.php', 92 | 'Composer\\Installers\\WHMCSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WHMCSInstaller.php', 93 | 'Composer\\Installers\\WolfCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WolfCMSInstaller.php', 94 | 'Composer\\Installers\\WordPressInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WordPressInstaller.php', 95 | 'Composer\\Installers\\YawikInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/YawikInstaller.php', 96 | 'Composer\\Installers\\ZendInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZendInstaller.php', 97 | 'Composer\\Installers\\ZikulaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php', 98 | 'Noodlehaus\\AbstractConfig' => $vendorDir . '/hassankhan/config/src/AbstractConfig.php', 99 | 'Noodlehaus\\Config' => $vendorDir . '/hassankhan/config/src/Config.php', 100 | 'Noodlehaus\\ConfigInterface' => $vendorDir . '/hassankhan/config/src/ConfigInterface.php', 101 | 'Noodlehaus\\ErrorException' => $vendorDir . '/hassankhan/config/src/ErrorException.php', 102 | 'Noodlehaus\\Exception' => $vendorDir . '/hassankhan/config/src/Exception.php', 103 | 'Noodlehaus\\Exception\\EmptyDirectoryException' => $vendorDir . '/hassankhan/config/src/Exception/EmptyDirectoryException.php', 104 | 'Noodlehaus\\Exception\\FileNotFoundException' => $vendorDir . '/hassankhan/config/src/Exception/FileNotFoundException.php', 105 | 'Noodlehaus\\Exception\\ParseException' => $vendorDir . '/hassankhan/config/src/Exception/ParseException.php', 106 | 'Noodlehaus\\Exception\\UnsupportedFormatException' => $vendorDir . '/hassankhan/config/src/Exception/UnsupportedFormatException.php', 107 | 'Noodlehaus\\FileParser\\AbstractFileParser' => $vendorDir . '/hassankhan/config/src/FileParser/AbstractFileParser.php', 108 | 'Noodlehaus\\FileParser\\FileParserInterface' => $vendorDir . '/hassankhan/config/src/FileParser/FileParserInterface.php', 109 | 'Noodlehaus\\FileParser\\Ini' => $vendorDir . '/hassankhan/config/src/FileParser/Ini.php', 110 | 'Noodlehaus\\FileParser\\Json' => $vendorDir . '/hassankhan/config/src/FileParser/Json.php', 111 | 'Noodlehaus\\FileParser\\Php' => $vendorDir . '/hassankhan/config/src/FileParser/Php.php', 112 | 'Noodlehaus\\FileParser\\Xml' => $vendorDir . '/hassankhan/config/src/FileParser/Xml.php', 113 | 'Noodlehaus\\FileParser\\Yaml' => $vendorDir . '/hassankhan/config/src/FileParser/Yaml.php', 114 | 'Sober\\Models\\ConfigNoFile' => $baseDir . '/src/ConfigNoFile.php', 115 | 'Sober\\Models\\Loader' => $baseDir . '/src/Loader.php', 116 | 'Sober\\Models\\Model' => $baseDir . '/src/Model.php', 117 | 'Sober\\Models\\Model\\PostType' => $baseDir . '/src/Model/PostType.php', 118 | 'Sober\\Models\\Model\\Taxonomy' => $baseDir . '/src/Model/Taxonomy.php', 119 | 'Symfony\\Component\\Yaml\\Command\\LintCommand' => $vendorDir . '/symfony/yaml/Command/LintCommand.php', 120 | 'Symfony\\Component\\Yaml\\Dumper' => $vendorDir . '/symfony/yaml/Dumper.php', 121 | 'Symfony\\Component\\Yaml\\Escaper' => $vendorDir . '/symfony/yaml/Escaper.php', 122 | 'Symfony\\Component\\Yaml\\Exception\\DumpException' => $vendorDir . '/symfony/yaml/Exception/DumpException.php', 123 | 'Symfony\\Component\\Yaml\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/yaml/Exception/ExceptionInterface.php', 124 | 'Symfony\\Component\\Yaml\\Exception\\ParseException' => $vendorDir . '/symfony/yaml/Exception/ParseException.php', 125 | 'Symfony\\Component\\Yaml\\Exception\\RuntimeException' => $vendorDir . '/symfony/yaml/Exception/RuntimeException.php', 126 | 'Symfony\\Component\\Yaml\\Inline' => $vendorDir . '/symfony/yaml/Inline.php', 127 | 'Symfony\\Component\\Yaml\\Parser' => $vendorDir . '/symfony/yaml/Parser.php', 128 | 'Symfony\\Component\\Yaml\\Tag\\TaggedValue' => $vendorDir . '/symfony/yaml/Tag/TaggedValue.php', 129 | 'Symfony\\Component\\Yaml\\Unescaper' => $vendorDir . '/symfony/yaml/Unescaper.php', 130 | 'Symfony\\Component\\Yaml\\Yaml' => $vendorDir . '/symfony/yaml/Yaml.php', 131 | 'Symfony\\Polyfill\\Ctype\\Ctype' => $vendorDir . '/symfony/polyfill-ctype/Ctype.php', 132 | ); 133 | -------------------------------------------------------------------------------- /dist/composer/autoload_files.php: -------------------------------------------------------------------------------- 1 | $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', 10 | ); 11 | -------------------------------------------------------------------------------- /dist/composer/autoload_namespaces.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/symfony/polyfill-ctype'), 10 | 'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'), 11 | 'Sober\\Models\\Model\\' => array($baseDir . '/src/Model'), 12 | 'Sober\\Models\\' => array($baseDir . '/src'), 13 | 'Noodlehaus\\' => array($vendorDir . '/hassankhan/config/src'), 14 | 'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src/Composer/Installers'), 15 | ); 16 | -------------------------------------------------------------------------------- /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\ComposerStaticInitd1e6f52ebe485f122f3b493cfa8c3f5d::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\ComposerStaticInitd1e6f52ebe485f122f3b493cfa8c3f5d::$files; 52 | } else { 53 | $includeFiles = require __DIR__ . '/autoload_files.php'; 54 | } 55 | foreach ($includeFiles as $fileIdentifier => $file) { 56 | composerRequired1e6f52ebe485f122f3b493cfa8c3f5d($fileIdentifier, $file); 57 | } 58 | 59 | return $loader; 60 | } 61 | } 62 | 63 | function composerRequired1e6f52ebe485f122f3b493cfa8c3f5d($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__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', 11 | ); 12 | 13 | public static $prefixLengthsPsr4 = array ( 14 | 'S' => 15 | array ( 16 | 'Symfony\\Polyfill\\Ctype\\' => 23, 17 | 'Symfony\\Component\\Yaml\\' => 23, 18 | 'Sober\\Models\\Model\\' => 19, 19 | 'Sober\\Models\\' => 13, 20 | ), 21 | 'N' => 22 | array ( 23 | 'Noodlehaus\\' => 11, 24 | ), 25 | 'C' => 26 | array ( 27 | 'Composer\\Installers\\' => 20, 28 | ), 29 | ); 30 | 31 | public static $prefixDirsPsr4 = array ( 32 | 'Symfony\\Polyfill\\Ctype\\' => 33 | array ( 34 | 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype', 35 | ), 36 | 'Symfony\\Component\\Yaml\\' => 37 | array ( 38 | 0 => __DIR__ . '/..' . '/symfony/yaml', 39 | ), 40 | 'Sober\\Models\\Model\\' => 41 | array ( 42 | 0 => __DIR__ . '/../..' . '/src/Model', 43 | ), 44 | 'Sober\\Models\\' => 45 | array ( 46 | 0 => __DIR__ . '/../..' . '/src', 47 | ), 48 | 'Noodlehaus\\' => 49 | array ( 50 | 0 => __DIR__ . '/..' . '/hassankhan/config/src', 51 | ), 52 | 'Composer\\Installers\\' => 53 | array ( 54 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', 55 | ), 56 | ); 57 | 58 | public static $classMap = array ( 59 | 'Composer\\Installers\\AglInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AglInstaller.php', 60 | 'Composer\\Installers\\AimeosInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AimeosInstaller.php', 61 | 'Composer\\Installers\\AnnotateCmsInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php', 62 | 'Composer\\Installers\\AsgardInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AsgardInstaller.php', 63 | 'Composer\\Installers\\AttogramInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AttogramInstaller.php', 64 | 'Composer\\Installers\\BaseInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/BaseInstaller.php', 65 | 'Composer\\Installers\\BitrixInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/BitrixInstaller.php', 66 | 'Composer\\Installers\\BonefishInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/BonefishInstaller.php', 67 | 'Composer\\Installers\\CakePHPInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CakePHPInstaller.php', 68 | 'Composer\\Installers\\ChefInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ChefInstaller.php', 69 | 'Composer\\Installers\\ClanCatsFrameworkInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php', 70 | 'Composer\\Installers\\CockpitInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CockpitInstaller.php', 71 | 'Composer\\Installers\\CodeIgniterInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php', 72 | 'Composer\\Installers\\Concrete5Installer' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Concrete5Installer.php', 73 | 'Composer\\Installers\\CraftInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CraftInstaller.php', 74 | 'Composer\\Installers\\CroogoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CroogoInstaller.php', 75 | 'Composer\\Installers\\DecibelInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DecibelInstaller.php', 76 | 'Composer\\Installers\\DokuWikiInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DokuWikiInstaller.php', 77 | 'Composer\\Installers\\DolibarrInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DolibarrInstaller.php', 78 | 'Composer\\Installers\\DrupalInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DrupalInstaller.php', 79 | 'Composer\\Installers\\ElggInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ElggInstaller.php', 80 | 'Composer\\Installers\\EliasisInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/EliasisInstaller.php', 81 | 'Composer\\Installers\\ExpressionEngineInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php', 82 | 'Composer\\Installers\\EzPlatformInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/EzPlatformInstaller.php', 83 | 'Composer\\Installers\\FuelInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/FuelInstaller.php', 84 | 'Composer\\Installers\\FuelphpInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/FuelphpInstaller.php', 85 | 'Composer\\Installers\\GravInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/GravInstaller.php', 86 | 'Composer\\Installers\\HuradInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/HuradInstaller.php', 87 | 'Composer\\Installers\\ImageCMSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ImageCMSInstaller.php', 88 | 'Composer\\Installers\\Installer' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Installer.php', 89 | 'Composer\\Installers\\ItopInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ItopInstaller.php', 90 | 'Composer\\Installers\\JoomlaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/JoomlaInstaller.php', 91 | 'Composer\\Installers\\KanboardInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/KanboardInstaller.php', 92 | 'Composer\\Installers\\KirbyInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/KirbyInstaller.php', 93 | 'Composer\\Installers\\KodiCMSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/KodiCMSInstaller.php', 94 | 'Composer\\Installers\\KohanaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/KohanaInstaller.php', 95 | 'Composer\\Installers\\LanManagementSystemInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php', 96 | 'Composer\\Installers\\LaravelInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/LaravelInstaller.php', 97 | 'Composer\\Installers\\LavaLiteInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/LavaLiteInstaller.php', 98 | 'Composer\\Installers\\LithiumInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/LithiumInstaller.php', 99 | 'Composer\\Installers\\MODULEWorkInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php', 100 | 'Composer\\Installers\\MODXEvoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MODXEvoInstaller.php', 101 | 'Composer\\Installers\\MagentoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MagentoInstaller.php', 102 | 'Composer\\Installers\\MajimaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MajimaInstaller.php', 103 | 'Composer\\Installers\\MakoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MakoInstaller.php', 104 | 'Composer\\Installers\\MauticInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MauticInstaller.php', 105 | 'Composer\\Installers\\MayaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MayaInstaller.php', 106 | 'Composer\\Installers\\MediaWikiInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MediaWikiInstaller.php', 107 | 'Composer\\Installers\\MicroweberInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MicroweberInstaller.php', 108 | 'Composer\\Installers\\ModxInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ModxInstaller.php', 109 | 'Composer\\Installers\\MoodleInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MoodleInstaller.php', 110 | 'Composer\\Installers\\OctoberInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/OctoberInstaller.php', 111 | 'Composer\\Installers\\OntoWikiInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/OntoWikiInstaller.php', 112 | 'Composer\\Installers\\OsclassInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/OsclassInstaller.php', 113 | 'Composer\\Installers\\OxidInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/OxidInstaller.php', 114 | 'Composer\\Installers\\PPIInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PPIInstaller.php', 115 | 'Composer\\Installers\\PhiftyInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PhiftyInstaller.php', 116 | 'Composer\\Installers\\PhpBBInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PhpBBInstaller.php', 117 | 'Composer\\Installers\\PimcoreInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PimcoreInstaller.php', 118 | 'Composer\\Installers\\PiwikInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PiwikInstaller.php', 119 | 'Composer\\Installers\\PlentymarketsInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php', 120 | 'Composer\\Installers\\Plugin' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Plugin.php', 121 | 'Composer\\Installers\\PortoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PortoInstaller.php', 122 | 'Composer\\Installers\\PrestashopInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PrestashopInstaller.php', 123 | 'Composer\\Installers\\PuppetInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PuppetInstaller.php', 124 | 'Composer\\Installers\\PxcmsInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PxcmsInstaller.php', 125 | 'Composer\\Installers\\RadPHPInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/RadPHPInstaller.php', 126 | 'Composer\\Installers\\ReIndexInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ReIndexInstaller.php', 127 | 'Composer\\Installers\\RedaxoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/RedaxoInstaller.php', 128 | 'Composer\\Installers\\RoundcubeInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/RoundcubeInstaller.php', 129 | 'Composer\\Installers\\SMFInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/SMFInstaller.php', 130 | 'Composer\\Installers\\ShopwareInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ShopwareInstaller.php', 131 | 'Composer\\Installers\\SilverStripeInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/SilverStripeInstaller.php', 132 | 'Composer\\Installers\\SiteDirectInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/SiteDirectInstaller.php', 133 | 'Composer\\Installers\\SyDESInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/SyDESInstaller.php', 134 | 'Composer\\Installers\\Symfony1Installer' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Symfony1Installer.php', 135 | 'Composer\\Installers\\TYPO3CmsInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php', 136 | 'Composer\\Installers\\TYPO3FlowInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php', 137 | 'Composer\\Installers\\TheliaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TheliaInstaller.php', 138 | 'Composer\\Installers\\TuskInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TuskInstaller.php', 139 | 'Composer\\Installers\\UserFrostingInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/UserFrostingInstaller.php', 140 | 'Composer\\Installers\\VanillaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/VanillaInstaller.php', 141 | 'Composer\\Installers\\VgmcpInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/VgmcpInstaller.php', 142 | 'Composer\\Installers\\WHMCSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/WHMCSInstaller.php', 143 | 'Composer\\Installers\\WolfCMSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/WolfCMSInstaller.php', 144 | 'Composer\\Installers\\WordPressInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/WordPressInstaller.php', 145 | 'Composer\\Installers\\YawikInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/YawikInstaller.php', 146 | 'Composer\\Installers\\ZendInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZendInstaller.php', 147 | 'Composer\\Installers\\ZikulaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php', 148 | 'Noodlehaus\\AbstractConfig' => __DIR__ . '/..' . '/hassankhan/config/src/AbstractConfig.php', 149 | 'Noodlehaus\\Config' => __DIR__ . '/..' . '/hassankhan/config/src/Config.php', 150 | 'Noodlehaus\\ConfigInterface' => __DIR__ . '/..' . '/hassankhan/config/src/ConfigInterface.php', 151 | 'Noodlehaus\\ErrorException' => __DIR__ . '/..' . '/hassankhan/config/src/ErrorException.php', 152 | 'Noodlehaus\\Exception' => __DIR__ . '/..' . '/hassankhan/config/src/Exception.php', 153 | 'Noodlehaus\\Exception\\EmptyDirectoryException' => __DIR__ . '/..' . '/hassankhan/config/src/Exception/EmptyDirectoryException.php', 154 | 'Noodlehaus\\Exception\\FileNotFoundException' => __DIR__ . '/..' . '/hassankhan/config/src/Exception/FileNotFoundException.php', 155 | 'Noodlehaus\\Exception\\ParseException' => __DIR__ . '/..' . '/hassankhan/config/src/Exception/ParseException.php', 156 | 'Noodlehaus\\Exception\\UnsupportedFormatException' => __DIR__ . '/..' . '/hassankhan/config/src/Exception/UnsupportedFormatException.php', 157 | 'Noodlehaus\\FileParser\\AbstractFileParser' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/AbstractFileParser.php', 158 | 'Noodlehaus\\FileParser\\FileParserInterface' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/FileParserInterface.php', 159 | 'Noodlehaus\\FileParser\\Ini' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/Ini.php', 160 | 'Noodlehaus\\FileParser\\Json' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/Json.php', 161 | 'Noodlehaus\\FileParser\\Php' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/Php.php', 162 | 'Noodlehaus\\FileParser\\Xml' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/Xml.php', 163 | 'Noodlehaus\\FileParser\\Yaml' => __DIR__ . '/..' . '/hassankhan/config/src/FileParser/Yaml.php', 164 | 'Sober\\Models\\ConfigNoFile' => __DIR__ . '/../..' . '/src/ConfigNoFile.php', 165 | 'Sober\\Models\\Loader' => __DIR__ . '/../..' . '/src/Loader.php', 166 | 'Sober\\Models\\Model' => __DIR__ . '/../..' . '/src/Model.php', 167 | 'Sober\\Models\\Model\\PostType' => __DIR__ . '/../..' . '/src/Model/PostType.php', 168 | 'Sober\\Models\\Model\\Taxonomy' => __DIR__ . '/../..' . '/src/Model/Taxonomy.php', 169 | 'Symfony\\Component\\Yaml\\Command\\LintCommand' => __DIR__ . '/..' . '/symfony/yaml/Command/LintCommand.php', 170 | 'Symfony\\Component\\Yaml\\Dumper' => __DIR__ . '/..' . '/symfony/yaml/Dumper.php', 171 | 'Symfony\\Component\\Yaml\\Escaper' => __DIR__ . '/..' . '/symfony/yaml/Escaper.php', 172 | 'Symfony\\Component\\Yaml\\Exception\\DumpException' => __DIR__ . '/..' . '/symfony/yaml/Exception/DumpException.php', 173 | 'Symfony\\Component\\Yaml\\Exception\\ExceptionInterface' => __DIR__ . '/..' . '/symfony/yaml/Exception/ExceptionInterface.php', 174 | 'Symfony\\Component\\Yaml\\Exception\\ParseException' => __DIR__ . '/..' . '/symfony/yaml/Exception/ParseException.php', 175 | 'Symfony\\Component\\Yaml\\Exception\\RuntimeException' => __DIR__ . '/..' . '/symfony/yaml/Exception/RuntimeException.php', 176 | 'Symfony\\Component\\Yaml\\Inline' => __DIR__ . '/..' . '/symfony/yaml/Inline.php', 177 | 'Symfony\\Component\\Yaml\\Parser' => __DIR__ . '/..' . '/symfony/yaml/Parser.php', 178 | 'Symfony\\Component\\Yaml\\Tag\\TaggedValue' => __DIR__ . '/..' . '/symfony/yaml/Tag/TaggedValue.php', 179 | 'Symfony\\Component\\Yaml\\Unescaper' => __DIR__ . '/..' . '/symfony/yaml/Unescaper.php', 180 | 'Symfony\\Component\\Yaml\\Yaml' => __DIR__ . '/..' . '/symfony/yaml/Yaml.php', 181 | 'Symfony\\Polyfill\\Ctype\\Ctype' => __DIR__ . '/..' . '/symfony/polyfill-ctype/Ctype.php', 182 | ); 183 | 184 | public static function getInitializer(ClassLoader $loader) 185 | { 186 | return \Closure::bind(function () use ($loader) { 187 | $loader->prefixLengthsPsr4 = ComposerStaticInitd1e6f52ebe485f122f3b493cfa8c3f5d::$prefixLengthsPsr4; 188 | $loader->prefixDirsPsr4 = ComposerStaticInitd1e6f52ebe485f122f3b493cfa8c3f5d::$prefixDirsPsr4; 189 | $loader->classMap = ComposerStaticInitd1e6f52ebe485f122f3b493cfa8c3f5d::$classMap; 190 | 191 | }, null, ClassLoader::class); 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /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 | * Merge config from another instance 142 | * 143 | * @param ConfigInterface $config 144 | * @return ConfigInterface 145 | */ 146 | public function merge(ConfigInterface $config) 147 | { 148 | $this->data = array_replace_recursive($this->data, $config->all()); 149 | return $this; 150 | } 151 | 152 | /** 153 | * {@inheritDoc} 154 | */ 155 | public function all() 156 | { 157 | return $this->data; 158 | } 159 | 160 | /** 161 | * ArrayAccess Methods 162 | */ 163 | 164 | /** 165 | * Gets a value using the offset as a key 166 | * 167 | * @param string $offset 168 | * 169 | * @return mixed 170 | */ 171 | public function offsetGet($offset) 172 | { 173 | return $this->get($offset); 174 | } 175 | 176 | /** 177 | * Checks if a key exists 178 | * 179 | * @param string $offset 180 | * 181 | * @return bool 182 | */ 183 | public function offsetExists($offset) 184 | { 185 | return $this->has($offset); 186 | } 187 | 188 | /** 189 | * Sets a value using the offset as a key 190 | * 191 | * @param string $offset 192 | * @param mixed $value 193 | * 194 | * @return void 195 | */ 196 | public function offsetSet($offset, $value) 197 | { 198 | $this->set($offset, $value); 199 | } 200 | 201 | /** 202 | * Deletes a key and its value 203 | * 204 | * @param string $offset 205 | * 206 | * @return void 207 | */ 208 | public function offsetUnset($offset) 209 | { 210 | $this->set($offset, null); 211 | } 212 | 213 | /** 214 | * Iterator Methods 215 | */ 216 | 217 | /** 218 | * Returns the data array element referenced by its internal cursor 219 | * 220 | * @return mixed The element referenced by the data array's internal cursor. 221 | * If the array is empty or there is no element at the cursor, the 222 | * function returns false. If the array is undefined, the function 223 | * returns null 224 | */ 225 | public function current() 226 | { 227 | return (is_array($this->data) ? current($this->data) : null); 228 | } 229 | 230 | /** 231 | * Returns the data array index referenced by its internal cursor 232 | * 233 | * @return mixed The index referenced by the data array's internal cursor. 234 | * If the array is empty or undefined or there is no element at the 235 | * cursor, the function returns null 236 | */ 237 | public function key() 238 | { 239 | return (is_array($this->data) ? key($this->data) : null); 240 | } 241 | 242 | /** 243 | * Moves the data array's internal cursor forward one element 244 | * 245 | * @return mixed The element referenced by the data array's internal cursor 246 | * after the move is completed. If there are no more elements in the 247 | * array after the move, the function returns false. If the data array 248 | * is undefined, the function returns null 249 | */ 250 | public function next() 251 | { 252 | return (is_array($this->data) ? next($this->data) : null); 253 | } 254 | 255 | /** 256 | * Moves the data array's internal cursor to the first element 257 | * 258 | * @return mixed The element referenced by the data array's internal cursor 259 | * after the move is completed. If the data array is empty, the function 260 | * returns false. If the data array is undefined, the function returns 261 | * null 262 | */ 263 | public function rewind() 264 | { 265 | return (is_array($this->data) ? reset($this->data) : null); 266 | } 267 | 268 | /** 269 | * Tests whether the iterator's current index is valid 270 | * 271 | * @return bool True if the current index is valid; false otherwise 272 | */ 273 | public function valid() 274 | { 275 | return (is_array($this->data) ? key($this->data) !== null : false); 276 | } 277 | 278 | /** 279 | * Remove a value using the offset as a key 280 | * 281 | * @param string $key 282 | * 283 | * @return void 284 | */ 285 | public function remove($key) 286 | { 287 | $this->offsetUnset($key); 288 | } 289 | } 290 | -------------------------------------------------------------------------------- /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 | protected $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 | foreach ($this->supportedFileParsers as $fileParser) { 87 | if (in_array($extension, $fileParser::getSupportedExtensions($extension))) { 88 | return new $fileParser(); 89 | } 90 | 91 | } 92 | 93 | // If none exist, then throw an exception 94 | throw new UnsupportedFormatException('Unsupported configuration format'); 95 | } 96 | 97 | /** 98 | * Gets an array of paths 99 | * 100 | * @param array $path 101 | * 102 | * @return array 103 | * 104 | * @throws FileNotFoundException If a file is not found at `$path` 105 | */ 106 | private function getPathFromArray($path) 107 | { 108 | $paths = array(); 109 | 110 | foreach ($path as $unverifiedPath) { 111 | try { 112 | // Check if `$unverifiedPath` is optional 113 | // If it exists, then it's added to the list 114 | // If it doesn't, it throws an exception which we catch 115 | if ($unverifiedPath[0] !== '?') { 116 | $paths = array_merge($paths, $this->getValidPath($unverifiedPath)); 117 | continue; 118 | } 119 | $optionalPath = ltrim($unverifiedPath, '?'); 120 | $paths = array_merge($paths, $this->getValidPath($optionalPath)); 121 | 122 | } catch (FileNotFoundException $e) { 123 | // If `$unverifiedPath` is optional, then skip it 124 | if ($unverifiedPath[0] === '?') { 125 | continue; 126 | } 127 | // Otherwise rethrow the exception 128 | throw $e; 129 | } 130 | } 131 | 132 | return $paths; 133 | } 134 | 135 | /** 136 | * Checks `$path` to see if it is either an array, a directory, or a file 137 | * 138 | * @param string|array $path 139 | * 140 | * @return array 141 | * 142 | * @throws EmptyDirectoryException If `$path` is an empty directory 143 | * 144 | * @throws FileNotFoundException If a file is not found at `$path` 145 | */ 146 | private function getValidPath($path) 147 | { 148 | // If `$path` is array 149 | if (is_array($path)) { 150 | return $this->getPathFromArray($path); 151 | } 152 | 153 | // If `$path` is a directory 154 | if (is_dir($path)) { 155 | $paths = glob($path . '/*.*'); 156 | if (empty($paths)) { 157 | throw new EmptyDirectoryException("Configuration directory: [$path] is empty"); 158 | } 159 | return $paths; 160 | } 161 | 162 | // If `$path` is not a file, throw an exception 163 | if (!file_exists($path)) { 164 | throw new FileNotFoundException("Configuration file: [$path] cannot be found"); 165 | } 166 | return array($path); 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /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 static 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 | 20 | /** 21 | * {@inheritDoc} 22 | * Parses an INI file as an array 23 | * 24 | * @throws ParseException If there is an error parsing the INI file 25 | */ 26 | public function parse($path) 27 | { 28 | $data = @parse_ini_file($path, true); 29 | 30 | if (!$data) { 31 | $error = error_get_last(); 32 | 33 | // parse_ini_file() may return NULL but set no error if the file contains no parsable data 34 | if (!is_array($error)) { 35 | $error["message"] = "No parsable content in file."; 36 | } 37 | 38 | // if file contains no parsable data, no error is set, resulting in any previous error 39 | // persisting in error_get_last(). in php 7 this can be addressed with error_clear_last() 40 | if (function_exists("error_clear_last")) { 41 | error_clear_last(); 42 | } 43 | 44 | throw new ParseException($error); 45 | } 46 | 47 | return $this->expandDottedKey($data); 48 | } 49 | 50 | /** 51 | * Expand array with dotted keys to multidimensional array 52 | * 53 | * @param array $data 54 | * 55 | * @return array 56 | */ 57 | protected function expandDottedKey($data) 58 | { 59 | foreach ($data as $key => $value) { 60 | if (($found = strpos($key, '.')) !== false) { 61 | $newKey = substr($key, 0, $found); 62 | $remainder = substr($key, $found + 1); 63 | 64 | $expandedValue = $this->expandDottedKey(array($remainder => $value)); 65 | if (isset($data[$newKey])) { 66 | $data[$newKey] = array_merge_recursive($data[$newKey], $expandedValue); 67 | } else { 68 | $data[$newKey] = $expandedValue; 69 | } 70 | unset($data[$key]); 71 | } 72 | } 73 | return $data; 74 | } 75 | 76 | /** 77 | * {@inheritDoc} 78 | */ 79 | public static function getSupportedExtensions() 80 | { 81 | return array('ini'); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /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 static 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 static 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 static 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), YamlParser::PARSE_CONSTANT); 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 static function getSupportedExtensions() 46 | { 47 | return array('yaml', 'yml'); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /dist/symfony/yaml/Dumper.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Symfony\Component\Yaml; 13 | 14 | /** 15 | * Dumper dumps PHP variables to YAML strings. 16 | * 17 | * @author Fabien Potencier 18 | * 19 | * @final since version 3.4 20 | */ 21 | class Dumper 22 | { 23 | /** 24 | * The amount of spaces to use for indentation of nested nodes. 25 | * 26 | * @var int 27 | */ 28 | protected $indentation; 29 | 30 | /** 31 | * @param int $indentation 32 | */ 33 | public function __construct($indentation = 4) 34 | { 35 | if ($indentation < 1) { 36 | throw new \InvalidArgumentException('The indentation must be greater than zero.'); 37 | } 38 | 39 | $this->indentation = $indentation; 40 | } 41 | 42 | /** 43 | * Sets the indentation. 44 | * 45 | * @param int $num The amount of spaces to use for indentation of nested nodes 46 | * 47 | * @deprecated since version 3.1, to be removed in 4.0. Pass the indentation to the constructor instead. 48 | */ 49 | public function setIndentation($num) 50 | { 51 | @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 3.1 and will be removed in 4.0. Pass the indentation to the constructor instead.', E_USER_DEPRECATED); 52 | 53 | $this->indentation = (int) $num; 54 | } 55 | 56 | /** 57 | * Dumps a PHP value to YAML. 58 | * 59 | * @param mixed $input The PHP value 60 | * @param int $inline The level where you switch to inline YAML 61 | * @param int $indent The level of indentation (used internally) 62 | * @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string 63 | * 64 | * @return string The YAML representation of the PHP value 65 | */ 66 | public function dump($input, $inline = 0, $indent = 0, $flags = 0) 67 | { 68 | if (\is_bool($flags)) { 69 | @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); 70 | 71 | if ($flags) { 72 | $flags = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE; 73 | } else { 74 | $flags = 0; 75 | } 76 | } 77 | 78 | if (\func_num_args() >= 5) { 79 | @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED); 80 | 81 | if (func_get_arg(4)) { 82 | $flags |= Yaml::DUMP_OBJECT; 83 | } 84 | } 85 | 86 | $output = ''; 87 | $prefix = $indent ? str_repeat(' ', $indent) : ''; 88 | $dumpObjectAsInlineMap = true; 89 | 90 | if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($input instanceof \ArrayObject || $input instanceof \stdClass)) { 91 | $dumpObjectAsInlineMap = empty((array) $input); 92 | } 93 | 94 | if ($inline <= 0 || (!\is_array($input) && $dumpObjectAsInlineMap) || empty($input)) { 95 | $output .= $prefix.Inline::dump($input, $flags); 96 | } else { 97 | $dumpAsMap = Inline::isHash($input); 98 | 99 | foreach ($input as $key => $value) { 100 | if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r\n")) { 101 | // If the first line starts with a space character, the spec requires a blockIndicationIndicator 102 | // http://www.yaml.org/spec/1.2/spec.html#id2793979 103 | $blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : ''; 104 | $output .= sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator); 105 | 106 | foreach (preg_split('/\n|\r\n/', $value) as $row) { 107 | $output .= sprintf("%s%s%s\n", $prefix, str_repeat(' ', $this->indentation), $row); 108 | } 109 | 110 | continue; 111 | } 112 | 113 | $dumpObjectAsInlineMap = true; 114 | 115 | if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) { 116 | $dumpObjectAsInlineMap = empty((array) $value); 117 | } 118 | 119 | $willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || empty($value); 120 | 121 | $output .= sprintf('%s%s%s%s', 122 | $prefix, 123 | $dumpAsMap ? Inline::dump($key, $flags).':' : '-', 124 | $willBeInlined ? ' ' : "\n", 125 | $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $flags) 126 | ).($willBeInlined ? "\n" : ''); 127 | } 128 | } 129 | 130 | return $output; 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /dist/symfony/yaml/Escaper.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Symfony\Component\Yaml; 13 | 14 | /** 15 | * Escaper encapsulates escaping rules for single and double-quoted 16 | * YAML strings. 17 | * 18 | * @author Matthew Lewinski 19 | * 20 | * @internal 21 | */ 22 | class Escaper 23 | { 24 | // Characters that would cause a dumped string to require double quoting. 25 | const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9"; 26 | 27 | // Mapping arrays for escaping a double quoted string. The backslash is 28 | // first to ensure proper escaping because str_replace operates iteratively 29 | // on the input arrays. This ordering of the characters avoids the use of strtr, 30 | // which performs more slowly. 31 | private static $escapees = array('\\', '\\\\', '\\"', '"', 32 | "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", 33 | "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", 34 | "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", 35 | "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", 36 | "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9", 37 | ); 38 | private static $escaped = array('\\\\', '\\"', '\\\\', '\\"', 39 | '\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a', 40 | '\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f', 41 | '\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17', 42 | '\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f', 43 | '\\N', '\\_', '\\L', '\\P', 44 | ); 45 | 46 | /** 47 | * Determines if a PHP value would require double quoting in YAML. 48 | * 49 | * @param string $value A PHP value 50 | * 51 | * @return bool True if the value would require double quotes 52 | */ 53 | public static function requiresDoubleQuoting($value) 54 | { 55 | return 0 < preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value); 56 | } 57 | 58 | /** 59 | * Escapes and surrounds a PHP value with double quotes. 60 | * 61 | * @param string $value A PHP value 62 | * 63 | * @return string The quoted, escaped string 64 | */ 65 | public static function escapeWithDoubleQuotes($value) 66 | { 67 | return sprintf('"%s"', str_replace(self::$escapees, self::$escaped, $value)); 68 | } 69 | 70 | /** 71 | * Determines if a PHP value would require single quoting in YAML. 72 | * 73 | * @param string $value A PHP value 74 | * 75 | * @return bool True if the value would require single quotes 76 | */ 77 | public static function requiresSingleQuoting($value) 78 | { 79 | // Determines if a PHP value is entirely composed of a value that would 80 | // require single quoting in YAML. 81 | if (\in_array(strtolower($value), array('null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'))) { 82 | return true; 83 | } 84 | 85 | // Determines if the PHP value contains any single characters that would 86 | // cause it to require single quoting in YAML. 87 | return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value); 88 | } 89 | 90 | /** 91 | * Escapes and surrounds a PHP value with single quotes. 92 | * 93 | * @param string $value A PHP value 94 | * 95 | * @return string The quoted, escaped string 96 | */ 97 | public static function escapeWithSingleQuotes($value) 98 | { 99 | return sprintf("'%s'", str_replace('\'', '\'\'', $value)); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /dist/symfony/yaml/Inline.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Symfony\Component\Yaml; 13 | 14 | use Symfony\Component\Yaml\Exception\DumpException; 15 | use Symfony\Component\Yaml\Exception\ParseException; 16 | use Symfony\Component\Yaml\Tag\TaggedValue; 17 | 18 | /** 19 | * Inline implements a YAML parser/dumper for the YAML inline syntax. 20 | * 21 | * @author Fabien Potencier 22 | * 23 | * @internal 24 | */ 25 | class Inline 26 | { 27 | const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')'; 28 | 29 | public static $parsedLineNumber = -1; 30 | public static $parsedFilename; 31 | 32 | private static $exceptionOnInvalidType = false; 33 | private static $objectSupport = false; 34 | private static $objectForMap = false; 35 | private static $constantSupport = false; 36 | 37 | /** 38 | * @param int $flags 39 | * @param int|null $parsedLineNumber 40 | * @param string|null $parsedFilename 41 | */ 42 | public static function initialize($flags, $parsedLineNumber = null, $parsedFilename = null) 43 | { 44 | self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags); 45 | self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags); 46 | self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags); 47 | self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags); 48 | self::$parsedFilename = $parsedFilename; 49 | 50 | if (null !== $parsedLineNumber) { 51 | self::$parsedLineNumber = $parsedLineNumber; 52 | } 53 | } 54 | 55 | /** 56 | * Converts a YAML string to a PHP value. 57 | * 58 | * @param string $value A YAML string 59 | * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior 60 | * @param array $references Mapping of variable names to values 61 | * 62 | * @return mixed A PHP value 63 | * 64 | * @throws ParseException 65 | */ 66 | public static function parse($value, $flags = 0, $references = array()) 67 | { 68 | if (\is_bool($flags)) { 69 | @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); 70 | 71 | if ($flags) { 72 | $flags = Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE; 73 | } else { 74 | $flags = 0; 75 | } 76 | } 77 | 78 | if (\func_num_args() >= 3 && !\is_array($references)) { 79 | @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED); 80 | 81 | if ($references) { 82 | $flags |= Yaml::PARSE_OBJECT; 83 | } 84 | 85 | if (\func_num_args() >= 4) { 86 | @trigger_error('Passing a boolean flag to toggle object for map support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED); 87 | 88 | if (func_get_arg(3)) { 89 | $flags |= Yaml::PARSE_OBJECT_FOR_MAP; 90 | } 91 | } 92 | 93 | if (\func_num_args() >= 5) { 94 | $references = func_get_arg(4); 95 | } else { 96 | $references = array(); 97 | } 98 | } 99 | 100 | self::initialize($flags); 101 | 102 | $value = trim($value); 103 | 104 | if ('' === $value) { 105 | return ''; 106 | } 107 | 108 | if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) { 109 | $mbEncoding = mb_internal_encoding(); 110 | mb_internal_encoding('ASCII'); 111 | } 112 | 113 | $i = 0; 114 | $tag = self::parseTag($value, $i, $flags); 115 | switch ($value[$i]) { 116 | case '[': 117 | $result = self::parseSequence($value, $flags, $i, $references); 118 | ++$i; 119 | break; 120 | case '{': 121 | $result = self::parseMapping($value, $flags, $i, $references); 122 | ++$i; 123 | break; 124 | default: 125 | $result = self::parseScalar($value, $flags, null, $i, null === $tag, $references); 126 | } 127 | 128 | if (null !== $tag) { 129 | return new TaggedValue($tag, $result); 130 | } 131 | 132 | // some comments are allowed at the end 133 | if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) { 134 | throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename); 135 | } 136 | 137 | if (isset($mbEncoding)) { 138 | mb_internal_encoding($mbEncoding); 139 | } 140 | 141 | return $result; 142 | } 143 | 144 | /** 145 | * Dumps a given PHP variable to a YAML string. 146 | * 147 | * @param mixed $value The PHP variable to convert 148 | * @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string 149 | * 150 | * @return string The YAML string representing the PHP value 151 | * 152 | * @throws DumpException When trying to dump PHP resource 153 | */ 154 | public static function dump($value, $flags = 0) 155 | { 156 | if (\is_bool($flags)) { 157 | @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); 158 | 159 | if ($flags) { 160 | $flags = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE; 161 | } else { 162 | $flags = 0; 163 | } 164 | } 165 | 166 | if (\func_num_args() >= 3) { 167 | @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED); 168 | 169 | if (func_get_arg(2)) { 170 | $flags |= Yaml::DUMP_OBJECT; 171 | } 172 | } 173 | 174 | switch (true) { 175 | case \is_resource($value): 176 | if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) { 177 | throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value))); 178 | } 179 | 180 | return 'null'; 181 | case $value instanceof \DateTimeInterface: 182 | return $value->format('c'); 183 | case \is_object($value): 184 | if ($value instanceof TaggedValue) { 185 | return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags); 186 | } 187 | 188 | if (Yaml::DUMP_OBJECT & $flags) { 189 | return '!php/object '.self::dump(serialize($value)); 190 | } 191 | 192 | if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) { 193 | return self::dumpArray($value, $flags & ~Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE); 194 | } 195 | 196 | if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) { 197 | throw new DumpException('Object support when dumping a YAML file has been disabled.'); 198 | } 199 | 200 | return 'null'; 201 | case \is_array($value): 202 | return self::dumpArray($value, $flags); 203 | case null === $value: 204 | return 'null'; 205 | case true === $value: 206 | return 'true'; 207 | case false === $value: 208 | return 'false'; 209 | case ctype_digit($value): 210 | return \is_string($value) ? "'$value'" : (int) $value; 211 | case is_numeric($value): 212 | $locale = setlocale(LC_NUMERIC, 0); 213 | if (false !== $locale) { 214 | setlocale(LC_NUMERIC, 'C'); 215 | } 216 | if (\is_float($value)) { 217 | $repr = (string) $value; 218 | if (is_infinite($value)) { 219 | $repr = str_ireplace('INF', '.Inf', $repr); 220 | } elseif (floor($value) == $value && $repr == $value) { 221 | // Preserve float data type since storing a whole number will result in integer value. 222 | $repr = '!!float '.$repr; 223 | } 224 | } else { 225 | $repr = \is_string($value) ? "'$value'" : (string) $value; 226 | } 227 | if (false !== $locale) { 228 | setlocale(LC_NUMERIC, $locale); 229 | } 230 | 231 | return $repr; 232 | case '' == $value: 233 | return "''"; 234 | case self::isBinaryString($value): 235 | return '!!binary '.base64_encode($value); 236 | case Escaper::requiresDoubleQuoting($value): 237 | return Escaper::escapeWithDoubleQuotes($value); 238 | case Escaper::requiresSingleQuoting($value): 239 | case Parser::preg_match('{^[0-9]+[_0-9]*$}', $value): 240 | case Parser::preg_match(self::getHexRegex(), $value): 241 | case Parser::preg_match(self::getTimestampRegex(), $value): 242 | return Escaper::escapeWithSingleQuotes($value); 243 | default: 244 | return $value; 245 | } 246 | } 247 | 248 | /** 249 | * Check if given array is hash or just normal indexed array. 250 | * 251 | * @internal 252 | * 253 | * @param array|\ArrayObject|\stdClass $value The PHP array or array-like object to check 254 | * 255 | * @return bool true if value is hash array, false otherwise 256 | */ 257 | public static function isHash($value) 258 | { 259 | if ($value instanceof \stdClass || $value instanceof \ArrayObject) { 260 | return true; 261 | } 262 | 263 | $expectedKey = 0; 264 | 265 | foreach ($value as $key => $val) { 266 | if ($key !== $expectedKey++) { 267 | return true; 268 | } 269 | } 270 | 271 | return false; 272 | } 273 | 274 | /** 275 | * Dumps a PHP array to a YAML string. 276 | * 277 | * @param array $value The PHP array to dump 278 | * @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string 279 | * 280 | * @return string The YAML string representing the PHP array 281 | */ 282 | private static function dumpArray($value, $flags) 283 | { 284 | // array 285 | if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && !self::isHash($value)) { 286 | $output = array(); 287 | foreach ($value as $val) { 288 | $output[] = self::dump($val, $flags); 289 | } 290 | 291 | return sprintf('[%s]', implode(', ', $output)); 292 | } 293 | 294 | // hash 295 | $output = array(); 296 | foreach ($value as $key => $val) { 297 | $output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags)); 298 | } 299 | 300 | return sprintf('{ %s }', implode(', ', $output)); 301 | } 302 | 303 | /** 304 | * Parses a YAML scalar. 305 | * 306 | * @param string $scalar 307 | * @param int $flags 308 | * @param string[] $delimiters 309 | * @param int &$i 310 | * @param bool $evaluate 311 | * @param array $references 312 | * 313 | * @return string 314 | * 315 | * @throws ParseException When malformed inline YAML string is parsed 316 | * 317 | * @internal 318 | */ 319 | public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i = 0, $evaluate = true, $references = array(), $legacyOmittedKeySupport = false) 320 | { 321 | if (\in_array($scalar[$i], array('"', "'"))) { 322 | // quoted scalar 323 | $output = self::parseQuotedScalar($scalar, $i); 324 | 325 | if (null !== $delimiters) { 326 | $tmp = ltrim(substr($scalar, $i), ' '); 327 | if ('' === $tmp) { 328 | throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode($delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 329 | } 330 | if (!\in_array($tmp[0], $delimiters)) { 331 | throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 332 | } 333 | } 334 | } else { 335 | // "normal" string 336 | if (!$delimiters) { 337 | $output = substr($scalar, $i); 338 | $i += \strlen($output); 339 | 340 | // remove comments 341 | if (Parser::preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) { 342 | $output = substr($output, 0, $match[0][1]); 343 | } 344 | } elseif (Parser::preg_match('/^(.'.($legacyOmittedKeySupport ? '+' : '*').'?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) { 345 | $output = $match[1]; 346 | $i += \strlen($output); 347 | } else { 348 | throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename); 349 | } 350 | 351 | // a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >) 352 | if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0])) { 353 | throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0]), self::$parsedLineNumber + 1, $output, self::$parsedFilename); 354 | } 355 | 356 | if ($output && '%' === $output[0]) { 357 | @trigger_error(self::getDeprecationMessage(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $output)), E_USER_DEPRECATED); 358 | } 359 | 360 | if ($evaluate) { 361 | $output = self::evaluateScalar($output, $flags, $references); 362 | } 363 | } 364 | 365 | return $output; 366 | } 367 | 368 | /** 369 | * Parses a YAML quoted scalar. 370 | * 371 | * @param string $scalar 372 | * @param int &$i 373 | * 374 | * @return string 375 | * 376 | * @throws ParseException When malformed inline YAML string is parsed 377 | */ 378 | private static function parseQuotedScalar($scalar, &$i) 379 | { 380 | if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) { 381 | throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 382 | } 383 | 384 | $output = substr($match[0], 1, \strlen($match[0]) - 2); 385 | 386 | $unescaper = new Unescaper(); 387 | if ('"' == $scalar[$i]) { 388 | $output = $unescaper->unescapeDoubleQuotedString($output); 389 | } else { 390 | $output = $unescaper->unescapeSingleQuotedString($output); 391 | } 392 | 393 | $i += \strlen($match[0]); 394 | 395 | return $output; 396 | } 397 | 398 | /** 399 | * Parses a YAML sequence. 400 | * 401 | * @param string $sequence 402 | * @param int $flags 403 | * @param int &$i 404 | * @param array $references 405 | * 406 | * @return array 407 | * 408 | * @throws ParseException When malformed inline YAML string is parsed 409 | */ 410 | private static function parseSequence($sequence, $flags, &$i = 0, $references = array()) 411 | { 412 | $output = array(); 413 | $len = \strlen($sequence); 414 | ++$i; 415 | 416 | // [foo, bar, ...] 417 | while ($i < $len) { 418 | if (']' === $sequence[$i]) { 419 | return $output; 420 | } 421 | if (',' === $sequence[$i] || ' ' === $sequence[$i]) { 422 | ++$i; 423 | 424 | continue; 425 | } 426 | 427 | $tag = self::parseTag($sequence, $i, $flags); 428 | switch ($sequence[$i]) { 429 | case '[': 430 | // nested sequence 431 | $value = self::parseSequence($sequence, $flags, $i, $references); 432 | break; 433 | case '{': 434 | // nested mapping 435 | $value = self::parseMapping($sequence, $flags, $i, $references); 436 | break; 437 | default: 438 | $isQuoted = \in_array($sequence[$i], array('"', "'")); 439 | $value = self::parseScalar($sequence, $flags, array(',', ']'), $i, null === $tag, $references); 440 | 441 | // the value can be an array if a reference has been resolved to an array var 442 | if (\is_string($value) && !$isQuoted && false !== strpos($value, ': ')) { 443 | // embedded mapping? 444 | try { 445 | $pos = 0; 446 | $value = self::parseMapping('{'.$value.'}', $flags, $pos, $references); 447 | } catch (\InvalidArgumentException $e) { 448 | // no, it's not 449 | } 450 | } 451 | 452 | --$i; 453 | } 454 | 455 | if (null !== $tag) { 456 | $value = new TaggedValue($tag, $value); 457 | } 458 | 459 | $output[] = $value; 460 | 461 | ++$i; 462 | } 463 | 464 | throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename); 465 | } 466 | 467 | /** 468 | * Parses a YAML mapping. 469 | * 470 | * @param string $mapping 471 | * @param int $flags 472 | * @param int &$i 473 | * @param array $references 474 | * 475 | * @return array|\stdClass 476 | * 477 | * @throws ParseException When malformed inline YAML string is parsed 478 | */ 479 | private static function parseMapping($mapping, $flags, &$i = 0, $references = array()) 480 | { 481 | $output = array(); 482 | $len = \strlen($mapping); 483 | ++$i; 484 | $allowOverwrite = false; 485 | 486 | // {foo: bar, bar:foo, ...} 487 | while ($i < $len) { 488 | switch ($mapping[$i]) { 489 | case ' ': 490 | case ',': 491 | ++$i; 492 | continue 2; 493 | case '}': 494 | if (self::$objectForMap) { 495 | return (object) $output; 496 | } 497 | 498 | return $output; 499 | } 500 | 501 | // key 502 | $isKeyQuoted = \in_array($mapping[$i], array('"', "'"), true); 503 | $key = self::parseScalar($mapping, $flags, array(':', ' '), $i, false, array(), true); 504 | 505 | if (':' !== $key && false === $i = strpos($mapping, ':', $i)) { 506 | break; 507 | } 508 | 509 | if (':' === $key) { 510 | @trigger_error(self::getDeprecationMessage('Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0.'), E_USER_DEPRECATED); 511 | } 512 | 513 | if (!$isKeyQuoted) { 514 | $evaluatedKey = self::evaluateScalar($key, $flags, $references); 515 | 516 | if ('' !== $key && $evaluatedKey !== $key && !\is_string($evaluatedKey) && !\is_int($evaluatedKey)) { 517 | @trigger_error(self::getDeprecationMessage('Implicit casting of incompatible mapping keys to strings is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead.'), E_USER_DEPRECATED); 518 | } 519 | } 520 | 521 | if (':' !== $key && !$isKeyQuoted && (!isset($mapping[$i + 1]) || !\in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) { 522 | @trigger_error(self::getDeprecationMessage('Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since Symfony 3.2 and will throw a ParseException in 4.0.'), E_USER_DEPRECATED); 523 | } 524 | 525 | if ('<<' === $key) { 526 | $allowOverwrite = true; 527 | } 528 | 529 | while ($i < $len) { 530 | if (':' === $mapping[$i] || ' ' === $mapping[$i]) { 531 | ++$i; 532 | 533 | continue; 534 | } 535 | 536 | $tag = self::parseTag($mapping, $i, $flags); 537 | switch ($mapping[$i]) { 538 | case '[': 539 | // nested sequence 540 | $value = self::parseSequence($mapping, $flags, $i, $references); 541 | // Spec: Keys MUST be unique; first one wins. 542 | // Parser cannot abort this mapping earlier, since lines 543 | // are processed sequentially. 544 | // But overwriting is allowed when a merge node is used in current block. 545 | if ('<<' === $key) { 546 | foreach ($value as $parsedValue) { 547 | $output += $parsedValue; 548 | } 549 | } elseif ($allowOverwrite || !isset($output[$key])) { 550 | if (null !== $tag) { 551 | $output[$key] = new TaggedValue($tag, $value); 552 | } else { 553 | $output[$key] = $value; 554 | } 555 | } elseif (isset($output[$key])) { 556 | @trigger_error(self::getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED); 557 | } 558 | break; 559 | case '{': 560 | // nested mapping 561 | $value = self::parseMapping($mapping, $flags, $i, $references); 562 | // Spec: Keys MUST be unique; first one wins. 563 | // Parser cannot abort this mapping earlier, since lines 564 | // are processed sequentially. 565 | // But overwriting is allowed when a merge node is used in current block. 566 | if ('<<' === $key) { 567 | $output += $value; 568 | } elseif ($allowOverwrite || !isset($output[$key])) { 569 | if (null !== $tag) { 570 | $output[$key] = new TaggedValue($tag, $value); 571 | } else { 572 | $output[$key] = $value; 573 | } 574 | } elseif (isset($output[$key])) { 575 | @trigger_error(self::getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED); 576 | } 577 | break; 578 | default: 579 | $value = self::parseScalar($mapping, $flags, array(',', '}'), $i, null === $tag, $references); 580 | // Spec: Keys MUST be unique; first one wins. 581 | // Parser cannot abort this mapping earlier, since lines 582 | // are processed sequentially. 583 | // But overwriting is allowed when a merge node is used in current block. 584 | if ('<<' === $key) { 585 | $output += $value; 586 | } elseif ($allowOverwrite || !isset($output[$key])) { 587 | if (null !== $tag) { 588 | $output[$key] = new TaggedValue($tag, $value); 589 | } else { 590 | $output[$key] = $value; 591 | } 592 | } elseif (isset($output[$key])) { 593 | @trigger_error(self::getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED); 594 | } 595 | --$i; 596 | } 597 | ++$i; 598 | 599 | continue 2; 600 | } 601 | } 602 | 603 | throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping), self::$parsedLineNumber + 1, null, self::$parsedFilename); 604 | } 605 | 606 | /** 607 | * Evaluates scalars and replaces magic values. 608 | * 609 | * @param string $scalar 610 | * @param int $flags 611 | * @param array $references 612 | * 613 | * @return mixed The evaluated YAML string 614 | * 615 | * @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved 616 | */ 617 | private static function evaluateScalar($scalar, $flags, $references = array()) 618 | { 619 | $scalar = trim($scalar); 620 | $scalarLower = strtolower($scalar); 621 | 622 | if (0 === strpos($scalar, '*')) { 623 | if (false !== $pos = strpos($scalar, '#')) { 624 | $value = substr($scalar, 1, $pos - 2); 625 | } else { 626 | $value = substr($scalar, 1); 627 | } 628 | 629 | // an unquoted * 630 | if (false === $value || '' === $value) { 631 | throw new ParseException('A reference must contain at least one character.', self::$parsedLineNumber + 1, $value, self::$parsedFilename); 632 | } 633 | 634 | if (!array_key_exists($value, $references)) { 635 | throw new ParseException(sprintf('Reference "%s" does not exist.', $value), self::$parsedLineNumber + 1, $value, self::$parsedFilename); 636 | } 637 | 638 | return $references[$value]; 639 | } 640 | 641 | switch (true) { 642 | case 'null' === $scalarLower: 643 | case '' === $scalar: 644 | case '~' === $scalar: 645 | return; 646 | case 'true' === $scalarLower: 647 | return true; 648 | case 'false' === $scalarLower: 649 | return false; 650 | case '!' === $scalar[0]: 651 | switch (true) { 652 | case 0 === strpos($scalar, '!str'): 653 | @trigger_error(self::getDeprecationMessage('Support for the !str tag is deprecated since Symfony 3.4. Use the !!str tag instead.'), E_USER_DEPRECATED); 654 | 655 | return (string) substr($scalar, 5); 656 | case 0 === strpos($scalar, '!!str '): 657 | return (string) substr($scalar, 6); 658 | case 0 === strpos($scalar, '! '): 659 | @trigger_error(self::getDeprecationMessage('Using the non-specific tag "!" is deprecated since Symfony 3.4 as its behavior will change in 4.0. It will force non-evaluating your values in 4.0. Use plain integers or !!float instead.'), E_USER_DEPRECATED); 660 | 661 | return (int) self::parseScalar(substr($scalar, 2), $flags); 662 | case 0 === strpos($scalar, '!php/object:'): 663 | if (self::$objectSupport) { 664 | @trigger_error(self::getDeprecationMessage('The !php/object: tag to indicate dumped PHP objects is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.'), E_USER_DEPRECATED); 665 | 666 | return unserialize(substr($scalar, 12)); 667 | } 668 | 669 | if (self::$exceptionOnInvalidType) { 670 | throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 671 | } 672 | 673 | return; 674 | case 0 === strpos($scalar, '!!php/object:'): 675 | if (self::$objectSupport) { 676 | @trigger_error(self::getDeprecationMessage('The !!php/object: tag to indicate dumped PHP objects is deprecated since Symfony 3.1 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.'), E_USER_DEPRECATED); 677 | 678 | return unserialize(substr($scalar, 13)); 679 | } 680 | 681 | if (self::$exceptionOnInvalidType) { 682 | throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 683 | } 684 | 685 | return; 686 | case 0 === strpos($scalar, '!php/object'): 687 | if (self::$objectSupport) { 688 | return unserialize(self::parseScalar(substr($scalar, 12))); 689 | } 690 | 691 | if (self::$exceptionOnInvalidType) { 692 | throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 693 | } 694 | 695 | return; 696 | case 0 === strpos($scalar, '!php/const:'): 697 | if (self::$constantSupport) { 698 | @trigger_error(self::getDeprecationMessage('The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead.'), E_USER_DEPRECATED); 699 | 700 | if (\defined($const = substr($scalar, 11))) { 701 | return \constant($const); 702 | } 703 | 704 | throw new ParseException(sprintf('The constant "%s" is not defined.', $const), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 705 | } 706 | if (self::$exceptionOnInvalidType) { 707 | throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 708 | } 709 | 710 | return; 711 | case 0 === strpos($scalar, '!php/const'): 712 | if (self::$constantSupport) { 713 | $i = 0; 714 | if (\defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) { 715 | return \constant($const); 716 | } 717 | 718 | throw new ParseException(sprintf('The constant "%s" is not defined.', $const), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 719 | } 720 | if (self::$exceptionOnInvalidType) { 721 | throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 722 | } 723 | 724 | return; 725 | case 0 === strpos($scalar, '!!float '): 726 | return (float) substr($scalar, 8); 727 | case 0 === strpos($scalar, '!!binary '): 728 | return self::evaluateBinaryScalar(substr($scalar, 9)); 729 | default: 730 | @trigger_error(self::getDeprecationMessage(sprintf('Using the unquoted scalar value "%s" is deprecated since Symfony 3.3 and will be considered as a tagged value in 4.0. You must quote it.', $scalar)), E_USER_DEPRECATED); 731 | } 732 | 733 | // Optimize for returning strings. 734 | // no break 735 | case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]): 736 | switch (true) { 737 | case Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar): 738 | $scalar = str_replace('_', '', (string) $scalar); 739 | // omitting the break / return as integers are handled in the next case 740 | // no break 741 | case ctype_digit($scalar): 742 | $raw = $scalar; 743 | $cast = (int) $scalar; 744 | 745 | return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); 746 | case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)): 747 | $raw = $scalar; 748 | $cast = (int) $scalar; 749 | 750 | return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw); 751 | case is_numeric($scalar): 752 | case Parser::preg_match(self::getHexRegex(), $scalar): 753 | $scalar = str_replace('_', '', $scalar); 754 | 755 | return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar; 756 | case '.inf' === $scalarLower: 757 | case '.nan' === $scalarLower: 758 | return -log(0); 759 | case '-.inf' === $scalarLower: 760 | return log(0); 761 | case Parser::preg_match('/^(-|\+)?[0-9][0-9,]*(\.[0-9_]+)?$/', $scalar): 762 | case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar): 763 | if (false !== strpos($scalar, ',')) { 764 | @trigger_error(self::getDeprecationMessage('Using the comma as a group separator for floats is deprecated since Symfony 3.2 and will be removed in 4.0.'), E_USER_DEPRECATED); 765 | } 766 | 767 | return (float) str_replace(array(',', '_'), '', $scalar); 768 | case Parser::preg_match(self::getTimestampRegex(), $scalar): 769 | if (Yaml::PARSE_DATETIME & $flags) { 770 | // When no timezone is provided in the parsed date, YAML spec says we must assume UTC. 771 | return new \DateTime($scalar, new \DateTimeZone('UTC')); 772 | } 773 | 774 | $timeZone = date_default_timezone_get(); 775 | date_default_timezone_set('UTC'); 776 | $time = strtotime($scalar); 777 | date_default_timezone_set($timeZone); 778 | 779 | return $time; 780 | } 781 | } 782 | 783 | return (string) $scalar; 784 | } 785 | 786 | /** 787 | * @param string $value 788 | * @param int &$i 789 | * @param int $flags 790 | * 791 | * @return null|string 792 | */ 793 | private static function parseTag($value, &$i, $flags) 794 | { 795 | if ('!' !== $value[$i]) { 796 | return; 797 | } 798 | 799 | $tagLength = strcspn($value, " \t\n", $i + 1); 800 | $tag = substr($value, $i + 1, $tagLength); 801 | 802 | $nextOffset = $i + $tagLength + 1; 803 | $nextOffset += strspn($value, ' ', $nextOffset); 804 | 805 | // Is followed by a scalar 806 | if ((!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], array('[', '{'), true)) && 'tagged' !== $tag) { 807 | // Manage non-whitelisted scalars in {@link self::evaluateScalar()} 808 | return; 809 | } 810 | 811 | // Built-in tags 812 | if ($tag && '!' === $tag[0]) { 813 | throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename); 814 | } 815 | 816 | if (Yaml::PARSE_CUSTOM_TAGS & $flags) { 817 | $i = $nextOffset; 818 | 819 | return $tag; 820 | } 821 | 822 | throw new ParseException(sprintf('Tags support is not enabled. Enable the `Yaml::PARSE_CUSTOM_TAGS` flag to use "!%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename); 823 | } 824 | 825 | /** 826 | * @param string $scalar 827 | * 828 | * @return string 829 | * 830 | * @internal 831 | */ 832 | public static function evaluateBinaryScalar($scalar) 833 | { 834 | $parsedBinaryData = self::parseScalar(preg_replace('/\s/', '', $scalar)); 835 | 836 | if (0 !== (\strlen($parsedBinaryData) % 4)) { 837 | throw new ParseException(sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', \strlen($parsedBinaryData)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 838 | } 839 | 840 | if (!Parser::preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) { 841 | throw new ParseException(sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); 842 | } 843 | 844 | return base64_decode($parsedBinaryData, true); 845 | } 846 | 847 | private static function isBinaryString($value) 848 | { 849 | return !preg_match('//u', $value) || preg_match('/[^\x00\x07-\x0d\x1B\x20-\xff]/', $value); 850 | } 851 | 852 | /** 853 | * Gets a regex that matches a YAML date. 854 | * 855 | * @return string The regular expression 856 | * 857 | * @see http://www.yaml.org/spec/1.2/spec.html#id2761573 858 | */ 859 | private static function getTimestampRegex() 860 | { 861 | return <<[0-9][0-9][0-9][0-9]) 864 | -(?P[0-9][0-9]?) 865 | -(?P[0-9][0-9]?) 866 | (?:(?:[Tt]|[ \t]+) 867 | (?P[0-9][0-9]?) 868 | :(?P[0-9][0-9]) 869 | :(?P[0-9][0-9]) 870 | (?:\.(?P[0-9]*))? 871 | (?:[ \t]*(?PZ|(?P[-+])(?P[0-9][0-9]?) 872 | (?::(?P[0-9][0-9]))?))?)? 873 | $~x 874 | EOF; 875 | } 876 | 877 | /** 878 | * Gets a regex that matches a YAML number in hexadecimal notation. 879 | * 880 | * @return string 881 | */ 882 | private static function getHexRegex() 883 | { 884 | return '~^0x[0-9a-f_]++$~i'; 885 | } 886 | 887 | private static function getDeprecationMessage($message) 888 | { 889 | $message = rtrim($message, '.'); 890 | 891 | if (null !== self::$parsedFilename) { 892 | $message .= ' in '.self::$parsedFilename; 893 | } 894 | 895 | if (-1 !== self::$parsedLineNumber) { 896 | $message .= ' on line '.(self::$parsedLineNumber + 1); 897 | } 898 | 899 | return $message.'.'; 900 | } 901 | } 902 | -------------------------------------------------------------------------------- /dist/symfony/yaml/Unescaper.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Symfony\Component\Yaml; 13 | 14 | use Symfony\Component\Yaml\Exception\ParseException; 15 | 16 | /** 17 | * Unescaper encapsulates unescaping rules for single and double-quoted 18 | * YAML strings. 19 | * 20 | * @author Matthew Lewinski 21 | * 22 | * @internal 23 | */ 24 | class Unescaper 25 | { 26 | /** 27 | * Regex fragment that matches an escaped character in a double quoted string. 28 | */ 29 | const REGEX_ESCAPED_CHARACTER = '\\\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)'; 30 | 31 | /** 32 | * Unescapes a single quoted string. 33 | * 34 | * @param string $value A single quoted string 35 | * 36 | * @return string The unescaped string 37 | */ 38 | public function unescapeSingleQuotedString($value) 39 | { 40 | return str_replace('\'\'', '\'', $value); 41 | } 42 | 43 | /** 44 | * Unescapes a double quoted string. 45 | * 46 | * @param string $value A double quoted string 47 | * 48 | * @return string The unescaped string 49 | */ 50 | public function unescapeDoubleQuotedString($value) 51 | { 52 | $callback = function ($match) { 53 | return $this->unescapeCharacter($match[0]); 54 | }; 55 | 56 | // evaluate the string 57 | return preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value); 58 | } 59 | 60 | /** 61 | * Unescapes a character that was found in a double-quoted string. 62 | * 63 | * @param string $value An escaped character 64 | * 65 | * @return string The unescaped character 66 | */ 67 | private function unescapeCharacter($value) 68 | { 69 | switch ($value[1]) { 70 | case '0': 71 | return "\x0"; 72 | case 'a': 73 | return "\x7"; 74 | case 'b': 75 | return "\x8"; 76 | case 't': 77 | return "\t"; 78 | case "\t": 79 | return "\t"; 80 | case 'n': 81 | return "\n"; 82 | case 'v': 83 | return "\xB"; 84 | case 'f': 85 | return "\xC"; 86 | case 'r': 87 | return "\r"; 88 | case 'e': 89 | return "\x1B"; 90 | case ' ': 91 | return ' '; 92 | case '"': 93 | return '"'; 94 | case '/': 95 | return '/'; 96 | case '\\': 97 | return '\\'; 98 | case 'N': 99 | // U+0085 NEXT LINE 100 | return "\xC2\x85"; 101 | case '_': 102 | // U+00A0 NO-BREAK SPACE 103 | return "\xC2\xA0"; 104 | case 'L': 105 | // U+2028 LINE SEPARATOR 106 | return "\xE2\x80\xA8"; 107 | case 'P': 108 | // U+2029 PARAGRAPH SEPARATOR 109 | return "\xE2\x80\xA9"; 110 | case 'x': 111 | return self::utf8chr(hexdec(substr($value, 2, 2))); 112 | case 'u': 113 | return self::utf8chr(hexdec(substr($value, 2, 4))); 114 | case 'U': 115 | return self::utf8chr(hexdec(substr($value, 2, 8))); 116 | default: 117 | throw new ParseException(sprintf('Found unknown escape character "%s".', $value)); 118 | } 119 | } 120 | 121 | /** 122 | * Get the UTF-8 character for the given code point. 123 | * 124 | * @param int $c The unicode code point 125 | * 126 | * @return string The corresponding UTF-8 character 127 | */ 128 | private static function utf8chr($c) 129 | { 130 | if (0x80 > $c %= 0x200000) { 131 | return \chr($c); 132 | } 133 | if (0x800 > $c) { 134 | return \chr(0xC0 | $c >> 6).\chr(0x80 | $c & 0x3F); 135 | } 136 | if (0x10000 > $c) { 137 | return \chr(0xE0 | $c >> 12).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F); 138 | } 139 | 140 | return \chr(0xF0 | $c >> 18).\chr(0x80 | $c >> 12 & 0x3F).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /dist/symfony/yaml/Yaml.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Symfony\Component\Yaml; 13 | 14 | use Symfony\Component\Yaml\Exception\ParseException; 15 | 16 | /** 17 | * Yaml offers convenience methods to load and dump YAML. 18 | * 19 | * @author Fabien Potencier 20 | * 21 | * @final since version 3.4 22 | */ 23 | class Yaml 24 | { 25 | const DUMP_OBJECT = 1; 26 | const PARSE_EXCEPTION_ON_INVALID_TYPE = 2; 27 | const PARSE_OBJECT = 4; 28 | const PARSE_OBJECT_FOR_MAP = 8; 29 | const DUMP_EXCEPTION_ON_INVALID_TYPE = 16; 30 | const PARSE_DATETIME = 32; 31 | const DUMP_OBJECT_AS_MAP = 64; 32 | const DUMP_MULTI_LINE_LITERAL_BLOCK = 128; 33 | const PARSE_CONSTANT = 256; 34 | const PARSE_CUSTOM_TAGS = 512; 35 | const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024; 36 | 37 | /** 38 | * @deprecated since version 3.4, to be removed in 4.0. Quote your evaluable keys instead. 39 | */ 40 | const PARSE_KEYS_AS_STRINGS = 2048; 41 | 42 | /** 43 | * Parses a YAML file into a PHP value. 44 | * 45 | * Usage: 46 | * 47 | * $array = Yaml::parseFile('config.yml'); 48 | * print_r($array); 49 | * 50 | * @param string $filename The path to the YAML file to be parsed 51 | * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior 52 | * 53 | * @return mixed The YAML converted to a PHP value 54 | * 55 | * @throws ParseException If the file could not be read or the YAML is not valid 56 | */ 57 | public static function parseFile($filename, $flags = 0) 58 | { 59 | $yaml = new Parser(); 60 | 61 | return $yaml->parseFile($filename, $flags); 62 | } 63 | 64 | /** 65 | * Parses YAML into a PHP value. 66 | * 67 | * Usage: 68 | * 69 | * $array = Yaml::parse(file_get_contents('config.yml')); 70 | * print_r($array); 71 | * 72 | * 73 | * @param string $input A string containing YAML 74 | * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior 75 | * 76 | * @return mixed The YAML converted to a PHP value 77 | * 78 | * @throws ParseException If the YAML is not valid 79 | */ 80 | public static function parse($input, $flags = 0) 81 | { 82 | if (\is_bool($flags)) { 83 | @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); 84 | 85 | if ($flags) { 86 | $flags = self::PARSE_EXCEPTION_ON_INVALID_TYPE; 87 | } else { 88 | $flags = 0; 89 | } 90 | } 91 | 92 | if (\func_num_args() >= 3) { 93 | @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the PARSE_OBJECT flag instead.', E_USER_DEPRECATED); 94 | 95 | if (func_get_arg(2)) { 96 | $flags |= self::PARSE_OBJECT; 97 | } 98 | } 99 | 100 | if (\func_num_args() >= 4) { 101 | @trigger_error('Passing a boolean flag to toggle object for map support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED); 102 | 103 | if (func_get_arg(3)) { 104 | $flags |= self::PARSE_OBJECT_FOR_MAP; 105 | } 106 | } 107 | 108 | $yaml = new Parser(); 109 | 110 | return $yaml->parse($input, $flags); 111 | } 112 | 113 | /** 114 | * Dumps a PHP value to a YAML string. 115 | * 116 | * The dump method, when supplied with an array, will do its best 117 | * to convert the array into friendly YAML. 118 | * 119 | * @param mixed $input The PHP value 120 | * @param int $inline The level where you switch to inline YAML 121 | * @param int $indent The amount of spaces to use for indentation of nested nodes 122 | * @param int $flags A bit field of DUMP_* constants to customize the dumped YAML string 123 | * 124 | * @return string A YAML string representing the original PHP value 125 | */ 126 | public static function dump($input, $inline = 2, $indent = 4, $flags = 0) 127 | { 128 | if (\is_bool($flags)) { 129 | @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED); 130 | 131 | if ($flags) { 132 | $flags = self::DUMP_EXCEPTION_ON_INVALID_TYPE; 133 | } else { 134 | $flags = 0; 135 | } 136 | } 137 | 138 | if (\func_num_args() >= 5) { 139 | @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the DUMP_OBJECT flag instead.', E_USER_DEPRECATED); 140 | 141 | if (func_get_arg(4)) { 142 | $flags |= self::DUMP_OBJECT; 143 | } 144 | } 145 | 146 | $yaml = new Dumper($indent); 147 | 148 | return $yaml->dump($input, $inline, 0, $flags); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /models.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sober Coding Standards 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/ConfigNoFile.php: -------------------------------------------------------------------------------- 1 | getPath(); 19 | $this->load(); 20 | } 21 | 22 | /** 23 | * Get custom path 24 | */ 25 | protected function getPath() 26 | { 27 | $default = (file_exists(dirname(get_template_directory()) . '/app') ? 28 | dirname(get_template_directory()) . '/app/models' : 29 | get_stylesheet_directory() . '/models'); 30 | 31 | $this->path = (has_filter('sober/models/path') ? 32 | apply_filters('sober/models/path', rtrim($this->path)) : 33 | $default); 34 | } 35 | 36 | /** 37 | * Load 38 | */ 39 | protected function load() 40 | { 41 | if (file_exists($this->path)) { 42 | $path = new \RecursiveDirectoryIterator($this->path); 43 | foreach (new \RecursiveIteratorIterator($path) as $filename => $file) { 44 | if (in_array(pathinfo($file, PATHINFO_EXTENSION), ['json', 'php', 'yml', 'yaml'])) { 45 | $this->config = new Config($file); 46 | ($this->isMultiple() ? $this->loadEach() : $this->route($this->config)); 47 | } 48 | } 49 | } 50 | } 51 | 52 | /** 53 | * Is multidimensional config 54 | */ 55 | protected function isMultiple() 56 | { 57 | return (is_array(current($this->config->all()))); 58 | } 59 | 60 | /** 61 | * Load each from multidimensional config 62 | */ 63 | protected function loadEach() 64 | { 65 | foreach ($this->config as $config) { 66 | $this->route(new ConfigNoFile($config)); 67 | } 68 | } 69 | 70 | /** 71 | * Route to class 72 | */ 73 | protected function route($config) 74 | { 75 | if (in_array($config['type'], ['post-type', 'cpt', 'posttype', 'post_type'])) { 76 | (new PostType($config))->run(); 77 | } 78 | if (in_array($config['type'], ['taxonomy', 'tax', 'category', 'cat', 'tag'])) { 79 | (new Taxonomy($config))->run(); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/Model.php: -------------------------------------------------------------------------------- 1 | data = $data; 23 | 24 | if ($this->isDisabled()) { 25 | return; 26 | } 27 | 28 | $this->setName(); 29 | $this->setNameLabels(); 30 | } 31 | 32 | /** 33 | * Check to see if model has been disabled 34 | * 35 | * @return boolean 36 | */ 37 | protected function isDisabled() 38 | { 39 | return (($this->data['active'] === false) ? true : false); 40 | } 41 | 42 | /** 43 | * Set name 44 | * 45 | * Required to register post type 46 | */ 47 | protected function setName() 48 | { 49 | $this->name = $this->data['name']; 50 | } 51 | 52 | /** 53 | * Set config 54 | * 55 | * Merge and/or replace defaults with user config 56 | */ 57 | protected function setConfig() 58 | { 59 | if ($this->data['config']) { 60 | $this->config = array_replace($this->config, $this->data['config']); 61 | } 62 | } 63 | 64 | /** 65 | * Set required labels 66 | * 67 | * Based on name, or keys labels.has-one and labels.has-many 68 | */ 69 | protected function setNameLabels() 70 | { 71 | $this->one = ($this->data['labels.has_one'] ? $this->data['labels.has_one'] : ucfirst($this->name)); 72 | $this->many = ($this->data['labels.has_many'] ? $this->data['labels.has_many'] : ucfirst($this->name . 's')); 73 | $this->i18n = ($this->data['labels.text_domain'] ? $this->data['labels.text_domain'] : 'sober'); 74 | } 75 | 76 | /** 77 | * Set label overrides 78 | * 79 | * If key labels.overrides exists, add to or replace label defaults 80 | */ 81 | protected function setLabels() 82 | { 83 | if ($this->data['labels.overrides']) { 84 | $this->labels = array_replace($this->labels, $this->data['labels.overrides']); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/Model/PostType.php: -------------------------------------------------------------------------------- 1 | isDisabled()) { 15 | return; 16 | } 17 | 18 | $this->setDefaultConfig()->setConfig(); 19 | $this->setDefaultLabels()->setLabels(); 20 | 21 | $this->merge(); 22 | $this->register(); 23 | } 24 | 25 | /** 26 | * Set config defaults 27 | * 28 | * Make public and change menu position 29 | * @return $this 30 | */ 31 | protected function setDefaultConfig() 32 | { 33 | $this->config = [ 34 | 'public' => true, 35 | 'menu_position' => 5 36 | ]; 37 | $this->supports = $this->data['supports']; 38 | 39 | return $this; 40 | } 41 | 42 | /** 43 | * Set default labels 44 | * 45 | * Create an labels array and implement default singular and plural labels 46 | * @return $this 47 | */ 48 | protected function setDefaultLabels() 49 | { 50 | $this->labels = [ 51 | 'name' => _x($this->many, 'Post type general name', $this->i18n), 52 | 'singular_name' => _x($this->one, 'Post type singular name', $this->i18n), 53 | 'menu_name' => _x($this->many, 'Admin Menu text', $this->i18n), 54 | 'name_admin_bar' => _x($this->one, 'Add New on Toolbar', $this->i18n), 55 | 'add_new_item' => __('Add New ' . $this->one, $this->i18n), 56 | 'edit_item' => __('Edit ' . $this->one, $this->i18n), 57 | 'new_item' => __('New ' . $this->one, $this->i18n), 58 | 'view_item' => __('View ' . $this->one, $this->i18n), 59 | 'view_items' => __('View ' . $this->many, $this->i18n), 60 | 'search_items' => __('Search ' . $this->many, $this->i18n), 61 | 'not_found' => __('No ' . strtolower($this->many) . ' found.', $this->i18n), 62 | 'not_found_in_trash' => __('No ' . strtolower($this->many) . ' found in Trash.', $this->i18n), 63 | 'parent_item_colon' => __('Parent ' . $this->many . ':', $this->i18n), 64 | 'all_items' => __('All ' . $this->many, $this->i18n), 65 | 'archives' => __($this->one . ' Archives', $this->i18n), 66 | 'attributes' => __($this->one . ' Attributes', $this->i18n), 67 | 'insert_into_item' => __('Insert into ' . strtolower($this->one), $this->i18n), 68 | 'uploaded_to_this_item' => __('Uploaded to this ' . strtolower($this->one), $this->i18n), 69 | 'filter_items_list' => __('Filter ' . strtolower($this->many) . ' list', $this->i18n), 70 | 'items_list_navigation' => __($this->many . ' list navigation', $this->i18n), 71 | 'items_list' => __($this->many . ' list', $this->i18n) 72 | ]; 73 | 74 | return $this; 75 | } 76 | 77 | /** 78 | * Merge 79 | * 80 | * Args to be passed to WP register_post_type() 81 | * @return $this 82 | */ 83 | protected function merge() 84 | { 85 | $this->args = [ 86 | 'labels' => $this->labels, 87 | 'supports' => $this->supports, 88 | ]; 89 | $this->args = array_merge($this->args, $this->config); 90 | } 91 | 92 | /** 93 | * Register Post Type 94 | * 95 | * Uses extended-cpts if available. 96 | * @see https://github.com/johnbillion/extended-cpts 97 | * 98 | * @return void 99 | */ 100 | protected function register() 101 | { 102 | if (function_exists('register_extended_post_type')) { 103 | register_extended_post_type($this->name, $this->args); 104 | } else { 105 | register_post_type($this->name, $this->args); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/Model/Taxonomy.php: -------------------------------------------------------------------------------- 1 | isDisabled()) { 15 | return; 16 | } 17 | 18 | $this->setDefaultConfig()->setConfig(); 19 | $this->setDefaultLabels()->setLabels(); 20 | 21 | $this->merge(); 22 | $this->register(); 23 | } 24 | 25 | /** 26 | * Set config defaults 27 | * 28 | * Make public and change menu position 29 | * @return $this 30 | */ 31 | protected function setDefaultConfig() 32 | { 33 | if ($this->data['config']) { 34 | $this->config = $this->data['config']; 35 | } 36 | if (in_array($this->data['type'], ['cat', 'category'])) { 37 | $this->config = ['hierarchical' => true]; 38 | } 39 | if ($this->data['links']) { 40 | $this->links = $this->data['links']; 41 | } 42 | 43 | return $this; 44 | } 45 | 46 | /** 47 | * Set default labels 48 | * 49 | * Create an labels array and implement default singular and plural labels 50 | * @return $this 51 | */ 52 | protected function setDefaultLabels() 53 | { 54 | $this->labels = [ 55 | 'name' => _x($this->many, 'Taxonomy general name', $this->i18n), 56 | 'singular_name' => _x($this->one, 'Taxonomy singular name', $this->i18n), 57 | 'search_items' => __('Search ' . $this->many, $this->i18n), 58 | 'popular_items' => __('Popular ' . $this->many, $this->i18n), 59 | 'all_items' => __('All ' . $this->many, $this->i18n), 60 | 'parent_item' => __('Parent ' . $this->one, $this->i18n), 61 | 'parent_item_colon' => __('Parent ' . $this->one . ':', $this->i18n), 62 | 'edit_item' => __('Edit ' . $this->one, $this->i18n), 63 | 'view_item' => __('View ' . $this->one, $this->i18n), 64 | 'update_item' => __('Update ' . $this->one, $this->i18n), 65 | 'add_new_item' => __('Add New ' . $this->one, $this->i18n), 66 | 'new_item_name' => __('New ' . $this->one . ' Name', $this->i18n), 67 | 'separate_items_with_commas' => __('Separate ' . strtolower($this->many) . ' with commas', $this->i18n), 68 | 'add_or_remove_items' => __('Add or remove '. strtolower($this->many), $this->i18n), 69 | 'choose_from_most_used' => __('Choose from the most used ' . strtolower($this->many), $this->i18n), 70 | 'not_found' => __('No ' . strtolower($this->many) . ' found.', $this->i18n), 71 | 'no_terms' => __('No ' . strtolower($this->many), $this->i18n), 72 | 'items_list_navigation' => __($this->many . ' list navigation', $this->i18n), 73 | 'items_list' => __($this->many . ' list', $this->i18n) 74 | ]; 75 | 76 | return $this; 77 | } 78 | 79 | /** 80 | * Merge 81 | * 82 | * Args to be passed to WP register_taxonomy() 83 | * @return $this 84 | */ 85 | protected function merge() 86 | { 87 | $this->args = [ 88 | 'labels' => $this->labels 89 | ]; 90 | $this->args = array_merge($this->args, $this->config); 91 | } 92 | 93 | /** 94 | * Register Taxonomy 95 | * 96 | * Uses extended-cpts if available. 97 | * @see https://github.com/johnbillion/extended-cpts 98 | * 99 | * @return void 100 | */ 101 | protected function register() 102 | { 103 | if (function_exists('register_extended_taxonomy')) { 104 | register_extended_taxonomy($this->name, $this->links, $this->args); 105 | } else { 106 | register_taxonomy($this->name, $this->links, $this->args); 107 | } 108 | } 109 | } 110 | --------------------------------------------------------------------------------