Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load app configuration based on a PHP / YAML tree #21

Open
gorkalaucirica opened this issue Oct 2, 2018 · 0 comments
Open

Load app configuration based on a PHP / YAML tree #21

gorkalaucirica opened this issue Oct 2, 2018 · 0 comments

Comments

@gorkalaucirica
Copy link
Contributor

Based on the usage of WPFoundation done in the latest projects I see that mainly configuration related things are done.

My proposal is to generate a config tree using PHP (maybe a YAML alternative could be used also, but might be limited).

Example of a basic configuration tree:

class Config
{
    const MENU_MAIN = 'Main menu';
    const VENDOR_PATH = '';

    const POST_TYPE_EXHIBITION = 'exhibition';
    const POST_TYPE_PAGE = 'page';

    const TAXONOMY_EXHIBITION_CATEGORY = 'exhibition_category';

    const TEMPLATE_PAGE_CONTACT = 'page_contact';
    const TEMPLATE_PAGE_FRONT_PAGE = 'front_page';
    const TEMPLATE_PAGE_GENERIC = 'generic';
}

$baseOptions = [
    'has_archive'        => true,
    'public'             => true,
    'publicly_queryable' => true,
    'query_var'          => true,
    'show_in_rest'       => true,
    'show_ui'            => true,
];

$config = [
    'logo'       => get_stylesheet_directory_uri() . '/../../themes/app/assets/images/site-login-logo.png',
    'menus'      => [
        Config::MENU_MAIN => Translations::trans('Main menu'),
    ],
    'assets'     => [
        'jquery.sidr.min' => [
            'path'         => Config::VENDOR_PATH . '/sidr',
            'dependencies' => [],
            'version'      => '1.0.0',
            'media'        => 'all'
        ]
    ],
    'templates'  => [
        'front_page'   => Translations::trans('Front Page'),
        'page_contact' => Translations::trans('Contact'),
        'Generic'      => Translations::trans('Generic (Page builder)'),
    ],
    'post_types' => [
        Config::POST_TYPE_EXHIBITION => array_merge($baseOptions, [
            'labels'   => [
                'name'          => Translations::trans('Exhibitions'),
                'singular_name' => Translations::trans('Exhibition'),
            ],
            'supports' => ['title', 'editor', 'thumbnail'],
        ])
    ],
    'fields' => [
        [
            'fields' => [ExhibitionPostFields::class],
            'connector' => new PostTypeFieldConnector(Config::POST_TYPE_EXHIBITION)
        ]
    ]
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant