| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace JFB_Components\Module; |
| 5 |
|
| 6 |
// If this file is called directly, abort. |
| 7 |
use Jet_Form_Builder\Exceptions\Repository_Exception; |
| 8 |
|
| 9 |
if ( ! defined( 'WPINC' ) ) { |
| 10 |
die; |
| 11 |
} |
| 12 |
|
| 13 |
trait Base_Module_Static_Instance_Trait { |
| 14 |
|
| 15 |
/** |
| 16 |
* @return Base_Module_After_Install_It|Base_Module_Dir_It|Base_Module_Handle_It|Base_Module_It|Base_Module_Url_It|Mock_Module |
| 17 |
*/ |
| 18 |
public static function instance() { |
| 19 |
if ( ! jet_form_builder()->has_module( static::get_instance_id() ) ) { |
| 20 |
return new Mock_Module(); |
| 21 |
} |
| 22 |
|
| 23 |
try { |
| 24 |
return jet_form_builder()->module( static::get_instance_id() ); |
| 25 |
} catch ( Repository_Exception $exception ) { |
| 26 |
return new Mock_Module(); |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
public function rep_item_id() { |
| 31 |
return static::get_instance_id(); |
| 32 |
} |
| 33 |
|
| 34 |
} |
| 35 |
|