functions.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPML\Container; |
| 4 | |
| 5 | use function WPML\FP\curryN; |
| 6 | |
| 7 | if ( ! function_exists( 'WPML\Container\make' ) ) { |
| 8 | function make( $class_name = null, ?array $args = null ) { |
| 9 | $make = function ( $class_name, $args = [] ) { |
| 10 | if ( class_exists( $class_name ) || interface_exists( $class_name ) ) { |
| 11 | return Container::make( $class_name, $args ); |
| 12 | } |
| 13 | |
| 14 | return null; |
| 15 | }; |
| 16 | |
| 17 | return call_user_func_array( curryN( 1, $make ), func_get_args() ); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | if ( ! function_exists( 'WPML\Container\share' ) ) { |
| 22 | |
| 23 | function share( array $names_or_instances ) { |
| 24 | Container::share( $names_or_instances ); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | if ( ! function_exists( 'WPML\Container\alias' ) ) { |
| 29 | |
| 30 | function alias( array $aliases ) { |
| 31 | Container::alias( $aliases ); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | if ( ! function_exists( 'WPML\Container\delegate' ) ) { |
| 36 | |
| 37 | function delegate( array $delegated ) { |
| 38 | Container::delegate( $delegated ); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | if ( ! function_exists( 'WPML\Container\execute' ) ) { |
| 43 | |
| 44 | function execute( $callableOrMethodStr = null, $args = null ) { |
| 45 | return call_user_func_array( curryN( 1, [ Container::class, 'execute' ] ), func_get_args() ); |
| 46 | } |
| 47 | } |
| 48 |