PHP 클래스 WpGears\Plugin

When run in Client mode it will allow adding new jobs to the Queue. When run in worker mode it will execute jobs on the Queue. Worker mode also allows adding new jobs to the queue just like Mlient mode.
파일 보기 프로젝트 열기: 10up/wp-gears 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$client The Client object used to enqueue jobs
$client_class client class
$config_prefix Configuration constants are prefixed by WP_GEARS by default. ;w Eg:- WP_GEARS_JOBS_PER_WORKER
$did_enable *
$did_run *
$instance Single instance of the plugin
$jobs_per_worker Number of jobs to execute per worker, Default 1
$worker The Worker object used to execute jobs
$worker_class Custom worker class

공개 메소드들

메소드 설명
add ( string $hook, array $args = [], string $priority = 'normal' ) : boolean Adds a new job to the Client with the specified arguments and priority.
build_client ( ) : Client Conditionally builds a new Client object. If the constant WP_GEARS_CLIENT_CLASS is defined it will return an instance of that class.
build_worker ( ) : Worker Conditionally builds a new Worker object. If the constant WP_GEARS_WORKER_CLASS is defined it will return an instance of that class.
enable ( ) Enables the plugin by registering it's clients and workers.
get_client ( ) : Client Returns the Client object used to add jobs. Creates the instance of the client lazily.
get_config ( string $constant, string $default = '', string $config_prefix = '' ) : mixed Helper to pickup config options from Constants with fallbacks.
get_instance ( ) : Plugin Returns the singleton instance of the Plugin. Creates the instance if it is absent.
get_jobs_per_worker ( ) : integer Returns the jobs to execute per worker instance
get_worker ( ) Returns the Worker object used to execute jobs. Creates the instance of the worker lazily.
get_wp_load ( ) : string Returns the path to the wp-load.php file.
has_config ( string $constant ) : boolean Checks if a config option is defined. Empty strings are treated as an undefined config option.
load_wordpress ( ) Tries to load WordPress using wp-load.php. If loading fails an error message is logged and the Script will exit immediately with a status code of 1.
quit ( integer $status_code ) Helper to quit with a status code. When running under PHPUnit it returns the status_code instead of exiting immediately.
run ( ) : integer Starts processing jobs in the Worker.
work ( ) : integer Executes jobs on the current Worker. A Worker will taken up only one job by default. If WP_GEARS_JOBS_PER_WORKER is defined that many jobs will be executed before it exits.

메소드 상세

add() 공개 메소드

Adds a new job to the Client with the specified arguments and priority.
public add ( string $hook, array $args = [], string $priority = 'normal' ) : boolean
$hook string The action hook name for the job
$args array Optional arguments for the job
$priority string Optional priority of the job
리턴 boolean true or false depending on the Client

build_client() 공개 메소드

By default it will detect if Gearman is present and return the Gearman Client else fallback to the Cron Client.
public build_client ( ) : Client
리턴 Client New instance of the Client

build_worker() 공개 메소드

By default it will detect if Gearman is present and return the Gearman Worker else fallback to the Cron Worker.
public build_worker ( ) : Worker
리턴 Worker New instance of the Worker

enable() 공개 메소드

Ignored if already enabled
public enable ( )

get_client() 공개 메소드

Returns the Client object used to add jobs. Creates the instance of the client lazily.
public get_client ( ) : Client
리턴 Client The client instance

get_config() 공개 메소드

Order of lookup is, 1. Local Property 2. Constant of that name 3. Default specified Eg:- get_config( 'FOO', 'abc', 'MY' ) will look for, 1. Local Property $this->my_foo 2. Constant MY_FOO 3. Defaualt ie:- abc
public get_config ( string $constant, string $default = '', string $config_prefix = '' ) : mixed
$constant string Name of constant to lookup
$default string Optional default
$config_prefix string Optional config prefix, Default is WP_GEARS
리턴 mixed The value of the config

get_instance() 공개 정적인 메소드

Returns the singleton instance of the Plugin. Creates the instance if it is absent.
public static get_instance ( ) : Plugin
리턴 Plugin instance of Plugin

get_jobs_per_worker() 공개 메소드

Returns the jobs to execute per worker instance
public get_jobs_per_worker ( ) : integer
리턴 integer Defaults to 1

get_worker() 공개 메소드

Returns the Worker object used to execute jobs. Creates the instance of the worker lazily.
public get_worker ( )

get_wp_load() 공개 메소드

Returns the path to the wp-load.php file.
public get_wp_load ( ) : string
리턴 string Path to the wp-load.php file

has_config() 공개 메소드

Checks if a config option is defined. Empty strings are treated as an undefined config option.
public has_config ( string $constant ) : boolean
$constant string The name of the constant
리턴 boolean True or false depending on whether the config is present

load_wordpress() 공개 메소드

Tries to load WordPress using wp-load.php. If loading fails an error message is logged and the Script will exit immediately with a status code of 1.
public load_wordpress ( )

quit() 공개 메소드

Helper to quit with a status code. When running under PHPUnit it returns the status_code instead of exiting immediately.
public quit ( integer $status_code )
$status_code integer The status between 0-255 to quit with.

run() 공개 메소드

Only one run is permitted.
public run ( ) : integer
리턴 integer The exit status code (only for PHPUnit)

work() 공개 메소드

This method will exit with the result code based on success/failure of executing the job.
public work ( ) : integer
리턴 integer 0 for success and 1 for failure

프로퍼티 상세

$client 공개적으로 프로퍼티

The Client object used to enqueue jobs
public $client

$client_class 공개적으로 프로퍼티

client class
public $client_class

$config_prefix 공개적으로 프로퍼티

Configuration constants are prefixed by WP_GEARS by default. ;w Eg:- WP_GEARS_JOBS_PER_WORKER
public $config_prefix

$did_enable 공개적으로 프로퍼티

*
public $did_enable

$did_run 공개적으로 프로퍼티

*
public $did_run

$instance 공개적으로 정적으로 프로퍼티

Single instance of the plugin
public static $instance

$jobs_per_worker 공개적으로 프로퍼티

Number of jobs to execute per worker, Default 1
public $jobs_per_worker

$worker 공개적으로 프로퍼티

The Worker object used to execute jobs
public $worker

$worker_class 공개적으로 프로퍼티

Custom worker class
public $worker_class