wp-di
wp-di copied to clipboard
Simple PHP Dependency Injection for WordPress
Right now the provider takes care of compiling service definitions into a WP-like structure. This does not seem like a single purpose, because the provider should just pass things to...
Non-existant services are resolved every time except for some caching. ServiceDefinition::resolveCache is such caching but still this is limited to all ServiceDefinition instances. We want a global caching for non-existant...
We used sanitizer to complete invalid configurations. This has grown over time and covers more than just sanitizing. As preparation for a compiler layer we turn the sanitizer into normalizer....
```yaml translations: - 'some-dir/with-translations/' - 'en_US.single-translation.yaml' services: Foo: arguments: '%bar%' ``` Translation: ```yaml # en_GB.yaml This is a complete sentence: Ok cool wp-di: is: great: n1 huge: 0: Nothing found....
WordPress has its minimum PHP version set to 5.6 . Right now we only allow PHP 7.0 and above. To fully support WordPress we should to get this PHP 5.6...
Definition: ``` GenericMetaColumn: arguments: - 'meta_key' manage_posts_custom_column: post_type: key ``` Shortcut: ``` PostColumns: some-post-type: key: service-name ``` Contract: ``` interface PostColumn { __toString(): string // label __invoke( string $columnName, $id...
WP Example on ``` add_action( 'admin_menu', 'my_plugin_menu' ); function my_plugin_menu() { add_options_page( 'My Options', 'My Plugin', 'manage_options', 'my-plugin.php', 'my_plugin_page' ); } ``` Short in wp-di: ``` [ 'menu_slug' => SomeClass::class,...
``` [ 'myplugin/v1' => [ 'foo/(?P\d+) => [ 'GET' => [ SomeService::class, 'someMethod' ], [ OtherService::class, 'forOtherHttpMethods' ] ] ] ]; ``` for ``` register_rest_route( 'myplugin/v1', '/foo/(?P\d+)', array( 'methods' =>...