Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
Rework namespacing to match the new name of the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender committed Jul 6, 2017
1 parent b4115fc commit 7f92369
Show file tree
Hide file tree
Showing 23 changed files with 95 additions and 228 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [3.0.0]
- Renamed from WP Gears to WP Minions, to better reflect that this is designed to be used with any job queue backend - not just Gearman

## [2.1.0]
### Added
- `wp_async_task_after_work` action after the gearman worker finishes working
Expand Down
14 changes: 7 additions & 7 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?php

function wp_gears_autoloader() {
global $wp_gears_autoloaded;
function wp_minions_autoloader() {
global $wp_minions_autoloaded;

if ( ! $wp_gears_autoloaded ) {
if ( ! $wp_minions_autoloaded ) {
$composer_autoloader = __DIR__ . '/vendor/autoload.php';

if ( file_exists( $composer_autoloader ) ) {
require_once( $composer_autoloader );
} else {
spl_autoload_register( 'wp_gears_autoload' );
spl_autoload_register( 'wp_minions_autoload' );
}

$wp_gears_autoloaded = true;
$wp_minions_autoloaded = true;
}
}

function wp_gears_autoload( $class_path ) {
if ( strpos( $class_path, 'WpGears\\' ) !== false ) {
function wp_minions_autoload( $class_path ) {
if ( strpos( $class_path, 'WpMinions\\' ) !== false ) {
$class_file = __DIR__ . '/includes/';
$class_file .= str_replace( '\\', '/', $class_path );
$class_file .= '.php';
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "10up/wp-gears",
"description": "Integrate Gearman with WordPress",
"name": "10up/wp-minions",
"description": "Job Queue for WordPress",
"type": "wordpress-plugin",
"license": "GPLv2",
"authors": [
Expand Down Expand Up @@ -28,7 +28,7 @@
},
"autoload": {
"psr-4": {
"WpGears\\": "includes/WpGears"
"WpMinions\\": "includes/WpMinions"
}
}
}
4 changes: 2 additions & 2 deletions includes/WpGears/Client.php → includes/WpMinions/Client.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace WpGears;
namespace WpMinions;

/**
* Base class for all WpGears Clients. A Client is responsible for
* Base class for all WpMinions Clients. A Client is responsible for
* adding jobs to it's Queue. It may optionally perform additional
* initialization to setup it's initial state.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace WpGears\Cron;
namespace WpMinions\Cron;

use WpGears\Client as BaseClient;
use WpMinions\Client as BaseClient;

/**
* The Cron Client uses WPCron to add jobs. This is the fallback used if
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace WpGears\Cron;
namespace WpMinions\Cron;

use WpGears\Worker as BaseWorker;
use WpMinions\Worker as BaseWorker;

/**
* The WP-Cron implementation does not have a concept of Workers. We
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace WpGears\Gearman;
namespace WpMinions\Gearman;

use WpGears\Client as BaseClient;
use WpMinions\Client as BaseClient;

/**
* The Gearman Client uses the libGearman API to add jobs to the Gearman
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace WpGears\Gearman;
namespace WpMinions\Gearman;

use WpGears\Worker as BaseWorker;
use WpMinions\Worker as BaseWorker;

/**
* The Gearman Worker uses the libGearman API to execute Jobs in the
Expand Down
40 changes: 20 additions & 20 deletions includes/WpGears/Plugin.php → includes/WpMinions/Plugin.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace WpGears;
namespace WpMinions;

/**
* The main WpGears Plugin object. It creates a client and worker object
* The main WpMinions Plugin object. It creates a client and worker object
* based the current configuration.
*
* When run in Client mode it will allow adding new jobs to the Queue.
Expand Down Expand Up @@ -33,21 +33,21 @@ static public function get_instance() {
}

/**
* @var \WpGears\Client The Client object used to enqueue jobs
* @var \WpMinions\Client The Client object used to enqueue jobs
*/
public $client;

/**
* @var \WpGears\Worker The Worker object used to execute jobs
* @var \WpMinions\Worker The Worker object used to execute jobs
*/
public $worker;

/**
* @var string Configuration constants are prefixed by WP_GEARS by default.
* @var string Configuration constants are prefixed by WP_MINIONS by default.
* ;w
* Eg:- WP_GEARS_JOBS_PER_WORKER
* Eg:- WP_MINIONS_JOBS_PER_WORKER
*/
public $config_prefix = 'WP_GEARS';
public $config_prefix = 'WP_MINIONS';

/**
* @var int Number of jobs to execute per worker, Default 1
Expand Down Expand Up @@ -105,7 +105,7 @@ public function run() {

/**
* Executes jobs on the current Worker. A Worker will taken up
* only one job by default. If WP_GEARS_JOBS_PER_WORKER is defined
* only one job by default. If WP_MINIONS_JOBS_PER_WORKER is defined
* that many jobs will be executed before it exits.
*
* This method will exit with the result code based on
Expand Down Expand Up @@ -142,7 +142,7 @@ public function add( $hook, $args = array(), $priority = 'normal' ) {
* Returns the Client object used to add jobs. Creates the instance
* of the client lazily.
*
* @return \WpGears\Client The client instance
* @return \WpMinions\Client The client instance
*/
function get_client() {
if ( is_null( $this->client ) ) {
Expand All @@ -156,7 +156,7 @@ function get_client() {
* Returns the Worker object used to execute jobs. Creates the instance
* of the worker lazily.
*
* @param \WpGears\Worker The worker instance
* @param \WpMinions\Worker The worker instance
*/
function get_worker() {
if ( is_null( $this->worker ) ) {
Expand All @@ -168,20 +168,20 @@ function get_worker() {

/**
* Conditionally builds a new Client object. If the constant
* WP_GEARS_CLIENT_CLASS is defined it will return an instance of that
* WP_MINIONS_CLIENT_CLASS is defined it will return an instance of that
* class.
*
* By default it will detect if Gearman is present and return the
* Gearman Client else fallback to the Cron Client.
*
* @return \WpGears\Client New instance of the Client
* @return \WpMinions\Client New instance of the Client
*/
function build_client() {
if ( ! $this->has_config( 'CLIENT_CLASS' ) ) {
if ( class_exists( '\GearmanClient' ) ) {
return new \WpGears\Gearman\Client();
return new \WpMinions\Gearman\Client();
} else {
return new \WpGears\Cron\Client();
return new \WpMinions\Cron\Client();
}
} else {
$klass = $this->get_config( 'CLIENT_CLASS' );
Expand All @@ -191,20 +191,20 @@ function build_client() {

/**
* Conditionally builds a new Worker object. If the constant
* WP_GEARS_WORKER_CLASS is defined it will return an instance of
* WP_MINIONS_WORKER_CLASS is defined it will return an instance of
* that class.
*
* By default it will detect if Gearman is present and return the
* Gearman Worker else fallback to the Cron Worker.
*
* @return \WpGears\Worker New instance of the Worker
* @return \WpMinions\Worker New instance of the Worker
*/
function build_worker() {
if ( ! $this->has_config( 'WORKER_CLASS' ) ) {
if ( class_exists( '\GearmanWorker' ) ) {
return new \WpGears\Gearman\Worker();
return new \WpMinions\Gearman\Worker();
} else {
return new \WpGears\Cron\Worker();
return new \WpMinions\Cron\Worker();
}
} else {
$klass = $this->get_config( 'WORKER_CLASS' );
Expand Down Expand Up @@ -242,7 +242,7 @@ function get_jobs_per_worker() {
*
* @param string $constant Name of constant to lookup
* @param string $default Optional default
* @param string $config_prefix Optional config prefix, Default is WP_GEARS
* @param string $config_prefix Optional config prefix, Default is WP_MINIONS
* @return mixed The value of the config
*/
function get_config( $constant, $default = '', $config_prefix = '' ) {
Expand Down Expand Up @@ -315,7 +315,7 @@ function load_wordpress() {
require_once( $wp_load );
} else {
error_log(
"WP Gears Fatal Error - Cannot find wp-load.php( $wp_load )"
"WP Minions Fatal Error - Cannot find wp-load.php( $wp_load )"
);

return $this->quit( 1 );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace WpGears;
namespace WpMinions;

/**
* Workers are responsible for executing jobs. They may perform any
Expand Down
9 changes: 0 additions & 9 deletions includes/abstract-wp-async-task.php

This file was deleted.

116 changes: 0 additions & 116 deletions includes/class-gearman-async-task.php

This file was deleted.

11 changes: 0 additions & 11 deletions includes/class-wp-async-task-fallback.php

This file was deleted.

Loading

0 comments on commit 7f92369

Please sign in to comment.