Skip to content
Snippets Groups Projects
Select Git revision
  • 5d5ada792d8f3dcad55230d990424b983b5b9718
  • master default protected
  • bugfix/wordpress-review
  • fix/duplicate
  • bugfix/get_current_screen_fail
  • feature/dismiss-nonce
  • replace-dodgy-path
  • bugfix/notice-not-show
  • devel
  • 3.3.0
  • 3.2.5
  • 3.2.4
  • 3.2.3
  • 3.2.2
  • 3.2.1
  • 3.2.0
  • 3.2.0-beta7
  • 3.2.0-beta6
  • 3.2.0-beta5
  • 3.2.0-beta4
  • 3.2.0-beta3
  • 3.2.0-beta2
  • 3.2.0-beta1
  • 3.1.4
  • 3.1.4-beta1
  • 3.1.3
  • 3.1.1
  • 3.1
  • 3.0
29 results

notice.js

Blame
  • ArrayBindingLoader.php 1017 B
    <?php
    declare( strict_types=1 );
    
    namespace WPDesk\Init\Binding\Loader;
    
    use WPDesk\Init\Binding\DefinitionFactory;
    use WPDesk\Init\Configuration\ReadableConfig;
    use WPDesk\Init\Plugin\Plugin;
    
    class ArrayDefinitions implements BindingDefinitions {
    
    	/** @var array */
    	private $bindings;
    
    	/** @var DefinitionFactory */
    	private $factory;
    
    	public function __construct( array $bindings, ?DefinitionFactory $factory = null) {
    		$this->bindings = $bindings;
    		$this->factory  = $factory ?? new DefinitionFactory();
    	}
    
    	public function load(): iterable {
    		yield from $this->normalize( $this->bindings );
    	}
    
    	private function normalize( $bindings ) {
    		$normalized = [];
    		foreach ( $bindings as $key => $value ) {
    			if ( is_array( $value ) ) {
    				foreach ( $value as $unit ) {
    					yield $this->create( $unit, $key );
    				}
    			} else {
    				yield $this->create( $value, $key );
    			}
    		}
    	}
    
    	private function create( $value, $hook ) {
    		return $this->factory->create( $value, is_int( $hook ) ? null : $hook );
    	}
    }