Tribe__Events__Pro__Service_Providers__RBE::set_in_use( string|null $in_use = null )
Sets the engine currently in use.
Contents
The method will update the value of the rbe_engine Tribe option.
Parameters
- $in_use
-
(string|null) (Optional) Either the string representing an engine or
nullif no engine is in use.Default value: null
Return
(string) The slug of the engine in use.
Source
File: src/Tribe/Service_Providers/RBE.php
public function set_in_use( $in_use = null ) {
$engines_map = $this->get_engines_map();
$currently_in_use = $this->get_in_use();
if ( ! array_key_exists( $in_use, $engines_map ) || $currently_in_use === $in_use ) {
// Let's not change to an engine that does not exist.
return $currently_in_use;
}
$current = $engines_map[ $this->get_in_use() ];
$current = $current instanceof Tribe__Events__Pro__Recurrence__Engines__Engine_Interface
? $current
: $this->container->make( $current );
$unhooked = $current->unhook();
if ( false === $unhooked ) {
// For some reasons the current engine cannot be unhooked, return its slug.
return $current->get_slug();
}
try {
$engine = $engines_map[ $in_use ];
$engine = $engine instanceof Tribe__Events__Pro__Recurrence__Engines__Engine_Interface
? $engine
: $this->container->make( $engine );
$hooked = $engine->hook();
} catch ( Exception $e ) {
// Something went wrong; let's hook none.
tribe_update_option( self::OPTION_NAME, self::NONE );
return self::NONE;
}
$now_in_use = empty( $hooked ) ? self::NONE : $engine->get_slug();
tribe_update_option( self::OPTION_NAME, $now_in_use );
return $now_in_use;
}
Changelog
| Version | Description |
|---|---|
| 4.7 | Introduced. |