Skip to content

Add a return to the function 'loadConfig' in the plugin API #2

@rgadon107

Description

@rgadon107

@hellofromtonya In the 'Reusable Meta Box Lab', Episode 15 ('Loading The Configuration Into the Store') between +11:25 - 11:40, you add return _the_store( $store_key, $config ); to the function 'loadConfigFromFilesystem' and add _the_store( $store_key, $config ); to the function 'loadConfig'. Then you inspect the return from 'loadConfigFromFilesystem' using Kint.

In Episode 23 of the same lab ('Fix the Default Merge'), in '/src/metadata/module.php' you build a function 'init_custom_fields_configuration' to merge the runtime and default configurations to remove the 'meta_key' array key in the 'custom_fields' configuration. At the end of 'init_custom_fields_configuration', you load the altered configuration back into the store by declaring 'configStore\loadConfig( $store_key, $config)'.

When 'configStore\loadConfig( $store_key, $config)' is inspected using Kint, it returns NULL. But if the API function 'loadConfig' is modified to return '_the_store' (rather than returning no value), then Kint returns the configuration from '_the_store' when 'init_custom_fields_configuration' runs 'configStore\loadConfig( $store_key, $config)'.

This is a small issue, and of little consequence in this particular lab. But if the plugin is extended and 'loadConfig' is used in other situations, on inspection one would find that the function does not return a value, when if fact it does contain data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions