| Server IP : www.new.bangkokfinder.com / Your IP : 104.23.176.9 Web Server : nginx/1.20.1 System : Linux new 4.15.0-159-generic #167-Ubuntu SMP Tue Sep 21 08:55:05 UTC 2021 x86_64 User : bangkokfinder ( 1000) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/bangkokfinder/www/wp-content/plugins/gravityforms/includes/ |
Upload File : |
<?php
namespace Gravity_Forms\Gravity_Forms;
/**
* Class GF_Service_Container
*
* A simple Service Container used to collect and organize Services used by the application and its modules.
*
* @since 2.5
*
* @package Gravity_Forms\Gravity_Forms
*/
class GF_Service_Container {
private $services = array();
private $providers = array();
/**
* Add a service to the container.
*
* @since 2.5
*
* @param string $name The service Name
* @param mixed $service The service to add
*/
public function add( $name, $service, $defer = false ) {
if ( empty( $name ) ) {
$name = get_class( $service );
}
if ( ! $defer && is_callable( $service ) ) {
$service = $service();
}
$this->services[ $name ] = $service;
}
/**
* Remove a service from the container.
*
* @since 2.5
*
* @param string $name The service name.
*/
public function remove( $name ) {
unset( $this->services[ $name ] );
}
/**
* Get a service from the container by name.
*
* @since 2.5
*
* @param string $name The service name.
*
* @return mixed|null
*/
public function get( $name ) {
if ( ! isset( $this->services[ $name ] ) ) {
return null;
}
if ( is_callable( $this->services[ $name ] ) ) {
$called = $this->services[ $name ]();
$this->services[ $name ] = $called;
}
return $this->services[ $name ];
}
/**
* Add a service provider to the container and register each of its services.
*
* @since 2.5
*
* @param GF_Service_Provider $provider
*/
public function add_provider( GF_Service_Provider $provider ) {
$provider_name = get_class( $provider );
// Only add providers a single time.
if ( isset( $this->providers[ $provider_name ] ) ) {
return;
}
$this->providers[ $provider_name ] = $provider;
$provider->set_container( $this );
$provider->register( $this );
$provider->init( $this );
}
}