-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b64400
commit e86dc8e
Showing
8 changed files
with
122 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace WP_Rocket\Engine\TestLazyload; | ||
|
||
use WP_Rocket\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider; | ||
|
||
class ServiceProvider extends AbstractServiceProvider { | ||
/** | ||
* The provides array is a way to let the container | ||
* know that a service is provided by this service | ||
* provider. Every service that is registered via | ||
* this service provider must have an alias added | ||
* to this array or it will be ignored. | ||
* | ||
* @var array | ||
*/ | ||
protected $provides = [ | ||
'test_lazyload_subscriber', | ||
'test_lazyload_class', | ||
]; | ||
|
||
/** | ||
* Registers the subscribers in the container | ||
* | ||
* @return void | ||
*/ | ||
public function register() { | ||
$this->getContainer() | ||
->share( 'test_lazyload_class', TestClass::class ); | ||
|
||
$this->getContainer() | ||
->share( 'test_lazyload_subscriber', Subscriber::class ) | ||
->addArgument( $this->getContainer()->get( 'test_lazyload_class', true, true ) ); | ||
|
||
|
||
} | ||
Check notice on line 37 in inc/Engine/TestLazyload/ServiceProvider.php
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
namespace WP_Rocket\Engine\TestLazyload; | ||
|
||
use WP_Rocket\Event_Management\Subscriber_Interface; | ||
|
||
class Subscriber implements Subscriber_Interface { | ||
|
||
private $test_class; | ||
|
||
public function __construct( TestClass $test_class ) { | ||
$this->test_class = $test_class; | ||
} | ||
|
||
public static function get_subscribed_events() { | ||
return [ | ||
'admin_init' => 'log_message', | ||
]; | ||
} | ||
|
||
public function log_message() | ||
{ | ||
$this->test_class->test1(); | ||
} | ||
|
||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
namespace WP_Rocket\Engine\TestLazyload; | ||
|
||
class TestClass { | ||
|
||
public function __construct() { | ||
error_log( 'log message from TestClass::__construct' ); | ||
error_log( var_export( wp_debug_backtrace_summary(), true ) ); | ||
error_log( '-------------------------' ); | ||
} | ||
|
||
public function test1() { | ||
error_log( 'log message from TestClass::test1' ); | ||
error_log( var_export( wp_debug_backtrace_summary(), true ) ); | ||
error_log( '-------------------------' ); | ||
} | ||
|
||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters