Skip to content

Commit

Permalink
fixed options init (in tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
moldcraft committed Jan 4, 2017
1 parent 143ec38 commit ca14331
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions framework/core/components/backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,9 @@ private function register_option_type( $option_type_class, $type = null ) {
}

if ( isset( $this->option_types[ $type ] ) ) {
if ( isset( $this->option_types[ $type ] ) ) {
trigger_error( 'Option type "' . $type . '" already registered', E_USER_WARNING );
trigger_error( 'Option type "' . $type . '" already registered', E_USER_WARNING );

return;
}
return;
}

$this->option_types[$type] = $option_type_class;
Expand All @@ -256,11 +254,9 @@ private function register_container_type( $container_type_class, $type = null )
}

if ( isset( $this->container_types[ $type ] ) ) {
if ( isset( $this->container_types[ $type ] ) ) {
trigger_error( 'Container type "' . $type . '" already registered', E_USER_WARNING );
trigger_error( 'Container type "' . $type . '" already registered', E_USER_WARNING );

return;
}
return;
}

$this->container_types[$type] = $container_type_class;
Expand Down Expand Up @@ -1588,8 +1584,10 @@ public function _register_container_type( FW_Access_Key $access_key, $container_
* @return FW_Option_Type
*/
public function option_type( $type ) {
if ( ! did_action( $init_action = 'fw_option_types_init' ) ) {
do_action( $init_action );
static $did_options_init = false;
if ( ! $did_options_init ) {
$did_options_init = true;
do_action( 'fw_option_types_init' );
}

if ( isset( $this->option_types[ $type ] ) ) {
Expand All @@ -1610,9 +1608,9 @@ public function option_type( $type ) {

if ( ! $this->undefined_option_type ) {
$this->undefined_option_type = new FW_Option_Type_Undefined();
} else {
return $this->undefined_option_type;
}

return $this->undefined_option_type;
}
}

Expand Down Expand Up @@ -1645,8 +1643,10 @@ public function get_container_types() {
* @return FW_Container_Type
*/
public function container_type( $type ) {
if ( ! did_action( $init_action = 'fw_container_types_init' ) ) {
do_action( $init_action );
static $did_containers_init = false;
if ( ! $did_containers_init ) {
$did_containers_init = true;
do_action( 'fw_container_types_init' );
}

if ( isset( $this->container_types[ $type ] ) ) {
Expand All @@ -1667,9 +1667,9 @@ public function container_type( $type ) {

if ( ! $this->undefined_container_type ) {
$this->undefined_container_type = new FW_Container_Type_Undefined();
} else {
return $this->undefined_container_type;
}

return $this->undefined_container_type;
}
}

Expand Down

0 comments on commit ca14331

Please sign in to comment.