2020-09-01 10:24:10 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* The renderer.
|
|
|
|
*
|
2020-09-11 14:11:10 +03:00
|
|
|
* @package WooCommerce\PayPalCommerce\AdminNotices\Renderer
|
2020-09-01 10:24:10 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-09-11 14:11:10 +03:00
|
|
|
namespace WooCommerce\PayPalCommerce\AdminNotices\Renderer;
|
2020-09-01 10:24:10 +03:00
|
|
|
|
2020-09-11 14:11:10 +03:00
|
|
|
use WooCommerce\PayPalCommerce\AdminNotices\Repository\RepositoryInterface;
|
2020-09-01 10:24:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Renderer
|
|
|
|
*/
|
|
|
|
class Renderer implements RendererInterface {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The message repository.
|
|
|
|
*
|
|
|
|
* @var RepositoryInterface
|
|
|
|
*/
|
|
|
|
private $repository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renderer constructor.
|
|
|
|
*
|
|
|
|
* @param RepositoryInterface $repository The message repository.
|
|
|
|
*/
|
|
|
|
public function __construct( RepositoryInterface $repository ) {
|
|
|
|
$this->repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the current messages.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function render(): bool {
|
|
|
|
$messages = $this->repository->current_message();
|
|
|
|
foreach ( $messages as $message ) {
|
|
|
|
printf(
|
|
|
|
'<div class="notice notice-%s %s"><p>%s</p></div>',
|
|
|
|
$message->type(),
|
|
|
|
( $message->is_dismissable() ) ? 'is-dismissible' : '',
|
|
|
|
wp_kses_post( $message->message() )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (bool) count( $messages );
|
|
|
|
}
|
|
|
|
}
|