Skip to content

Commit

Permalink
Fixed php stan error
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Feb 5, 2025
1 parent e46f9b5 commit ad9f878
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 0 additions & 1 deletion inc/Engine/Media/PreloadFonts/AJAX/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use WP_Rocket\Engine\Optimization\UrlTrait;

class Controller implements ControllerInterface {
use UrlTrait;
use AJAXControllerTrait;

/**
Expand Down
19 changes: 18 additions & 1 deletion inc/Engine/Media/PreloadFonts/Context/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,34 @@

namespace WP_Rocket\Engine\Media\PreloadFonts\Context;

use WP_Rocket\Admin\Options_Data;
use WP_Rocket\Engine\Common\Context\ContextInterface;

class Context implements ContextInterface {
/**
* Instance of the Option_Data class.
*
* @var Options_Data
*/
private $options;

/**
* Constructor.
*
* @param Options_Data $options Instance of the Option_Data class.
*/
public function __construct( Options_Data $options ) {
$this->options = $options;
}

/**
* Determine if the action is allowed.
*
* @param array $data Data to pass to the context.
* @return bool
*/
public function is_allowed( array $data = [] ): bool {
if ( get_option( 'wp_rocket_no_licence' ) ) {
if ( $this->options->get( 'wp_rocket_no_licence' ) ) {
return false;
}

Expand Down
5 changes: 4 additions & 1 deletion inc/Engine/Media/PreloadFonts/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ public function provides( string $id ): bool {
* @return void
*/
public function register(): void {
$options = $this->getContainer()->get( 'options' );

$this->getContainer()->addShared( 'preload_fonts_table', PreloadFontsTable::class );
$this->getContainer()->add( 'preload_fonts_query', PreloadFontsQuery::class );
$this->getContainer()->add( 'preload_fonts_context', Context::class );
$this->getContainer()->add( 'preload_fonts_context', Context::class )
->addArgument( $options );

$this->getContainer()->add( 'preload_fonts_ajax_controller', AJAXController::class )
->addArguments(
Expand Down

0 comments on commit ad9f878

Please sign in to comment.