Skip to content

Commit

Permalink
Corrects composer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstandiford committed Nov 23, 2021
1 parent eb21065 commit 1d89375
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 66 deletions.
31 changes: 0 additions & 31 deletions background-processes.php

This file was deleted.

20 changes: 20 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

use Underpin\Abstracts\Underpin;
use Underpin\Factories\Observers\Loader;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

Underpin::attach( 'setup', new Loader( 'background_processes', [
'update' => function ( Underpin $plugin ) {
$plugin->loaders()->add( 'background_processes', [
'class' => 'Underpin\Background_Processes\Loaders\Background_Processes',
] );

$plugin->loaders()->add( 'async_requests', [
'class' => 'Underpin\Background_Processes\Loaders\Async_Requests',
] );
},
] ) );
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
}
],
"require": {
"underpin/underpin": "^2.0",
"deliciousbrains/wp-background-processing": "^1.0"
"deliciousbrains/wp-background-processing": "^1.0",
"underpin/underpin": "^2.0"
},
"autoload": {
"psr-4": {"Underpin\\Admin_Notices\\": "lib/"},
"files": [
"background-processes.php"
"bootstrap.php"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Underpin_Background_Processes\Abstracts;
namespace Underpin\Background_Processes\Abstracts;


use function Underpin\underpin;
use Underpin\Loaders\Logger;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand All @@ -17,9 +17,9 @@ protected function handle() {
$result = $this->task_action();

if ( is_wp_error( $result ) ) {
underpin()->logger()->log_wp_error( 'error', $result );
Logger::log_wp_error( 'error', $result );
} else {
underpin()->logger()->log(
Logger::log(
'info',
'async_request_complete',
'An async request completed',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php


namespace Underpin_Background_Processes\Abstracts;
namespace Underpin\Background_Processes\Abstracts;

use function Underpin\underpin;

use Underpin\Loaders\Logger;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand All @@ -16,7 +17,7 @@ abstract protected function task_action( $item );
public function push_to_queue( $data ) {
$result = parent::push_to_queue( $data );

underpin()->logger()->log( 'info',
Logger::log( 'info',
'background_process_item_queued',
'A background process item has been queued for processing',
[
Expand All @@ -29,15 +30,15 @@ public function push_to_queue( $data ) {

protected function task( $item ) {
$item = $this->task_action( $item );
underpin()->logger()->log(
Logger::log(
'debug',
'background_task_ran',
'A background task step ran.',
[ 'item' => $item ]
);

if ( is_wp_error( $item ) ) {
underpin()->logger()->log_wp_error( 'error', $item );
Logger::log_wp_error( 'error', $item );
$item = false;
}

Expand All @@ -47,7 +48,7 @@ protected function task( $item ) {
protected function complete() {
parent::complete();

underpin()->logger()->log(
Logger::log(
'info',
'background_task_complete',
'A background task completed',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Underpin_Background_Processes\Factories;
namespace Underpin\Background_Processes\Factories;


use Underpin\Traits\Instance_Setter;
use Underpin_Background_Processes\Abstracts\Async_Request;
use Underpin\Background_Processes\Abstracts\Async_Request;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Underpin_Background_Processes\Factories;
namespace Underpin\Background_Processes\Factories;


use Underpin\Traits\Instance_Setter;
use Underpin_Background_Processes\Abstracts\Background_Process;
use Underpin\Background_Processes\Abstracts\Background_Process;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
* Background Process Loader
*
* @since 1.0.0
* @package Underpin_Background_Process\Loaders
* @package Underpin\Background_Process\Loaders
*/


namespace Underpin_Background_Processes\Loaders;
namespace Underpin\Background_Processes\Loaders;

use Underpin\Abstracts\Registries\Object_Registry;
use Underpin_Background_Processes\Abstracts\Async_Request;
use Underpin_Background_Processes\Abstracts\Background_Process;
use Underpin\Loaders\Logger;
use Underpin\Background_Processes\Abstracts\Async_Request;
use WP_Error;
use function Underpin\underpin;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand All @@ -24,16 +23,16 @@
* Database Registry
*
* @since 1.0.0
* @package Underpin_Background_Processes\Loaders
* @package Underpin\Background_Processes\Loaders
*/
class Async_Requests extends Object_Registry {

/**
* @inheritDoc
*/
protected $abstraction_class = '\Underpin_Background_Processes\Abstracts\Async_Request';
protected $abstraction_class = '\Underpin\Background_Processes\Abstracts\Async_Request';

protected $default_factory = '\Underpin_Background_Processes\Factories\Async_Request_Instance';
protected $default_factory = '\Underpin\Background_Processes\Factories\Async_Request_Instance';

/**
* @inheritDoc
Expand All @@ -56,7 +55,7 @@ public function dispatch( $key, $args = [] ) {
$instance = $this->get( $key );

if ( is_wp_error( $instance ) ) {
underpin()->logger()->log_wp_error( 'error', $instance );
Logger::log_wp_error( 'error', $instance );
return $instance;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
* Background Process Loader
*
* @since 1.0.0
* @package Underpin_Background_Process\Loaders
* @package Underpin\Background_Process\Loaders
*/


namespace Underpin_Background_Processes\Loaders;
namespace Underpin\Background_Processes\Loaders;

use Underpin\Abstracts\Registries\Object_Registry;
use Underpin_Background_Processes\Abstracts\Background_Process;
use Underpin\Loaders\Logger;
use Underpin\Background_Processes\Abstracts\Background_Process;
use WP_Error;
use function Underpin\underpin;


if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand All @@ -23,16 +24,16 @@
* Database Registry
*
* @since 1.0.0
* @package Underpin_Background_Processes\Loaders
* @package Underpin\Background_Processes\Loaders
*/
class Background_Processes extends Object_Registry {

/**
* @inheritDoc
*/
protected $abstraction_class = '\Underpin_Background_Processes\Abstracts\Background_Process';
protected $abstraction_class = '\Underpin\Background_Processes\Abstracts\Background_Process';

protected $default_factory = '\Underpin_Background_Processes\Factories\Background_Process_Instance';
protected $default_factory = '\Underpin\Background_Processes\Factories\Background_Process_Instance';

/**
* @inheritDoc
Expand All @@ -55,7 +56,7 @@ public function enqueue( $key, $data ) {
$instance = $this->get( $key );

if ( is_wp_error( $instance ) ) {
underpin()->logger()->log_wp_error( 'error', $instance );
Logger::log_wp_error( 'error', $instance );
}

return $instance->push_to_queue( $data );
Expand All @@ -65,7 +66,7 @@ public function dispatch( $key ) {
$instance = $this->get( $key );

if ( is_wp_error( $instance ) ) {
underpin()->logger()->log_wp_error( 'error', $instance );
Logger::log_wp_error( 'error', $instance );
return $instance;
}

Expand Down

0 comments on commit 1d89375

Please sign in to comment.