<?php
/**
 * Payment retry service provider.
 *
 * @since 2.6.10
 *
 * @package Masteriyo\Providers
 */

namespace Masteriyo\Pro\Providers;

defined( 'ABSPATH' ) || exit;

use League\Container\ServiceProvider\AbstractServiceProvider;
use League\Container\ServiceProvider\BootableServiceProviderInterface;
use Masteriyo\Models\PaymentRetry;
use Masteriyo\Repository\PaymentRetryRepository;

class PaymentRetryServiceProvider extends AbstractServiceProvider implements BootableServiceProviderInterface {
	/**
	 * The provided 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
	 *
	 * @since 2.6.10
	 *
	 * @var array
	 */
	protected $provides = array(
		'payment-retry',
		'payment-retry.store',
		'payment-retry.rest',
	);

	/**
	 * This is where the magic happens, within the method you can
	 * access the container and register or retrieve anything
	 * that you need to, but remember, every alias registered
	 * within this method must be declared in the `$provides` array.
	 *
	 * @since 2.6.10
	 */
	public function register() {
		$this->getContainer()->add( 'payment-retry.store', PaymentRetryRepository::class );

		// $this->getContainer()
		//  ->add( 'payment-retry.rest', PaymentRetriesController::class )
		//  ->addArgument( 'permission' );

		$this->getContainer()
			->add( 'payment-retry', PaymentRetry::class )
			->addArgument( 'payment-retry.store' );
	}

	/**
	 * In much the same way, this method has access to the container
	 * itself and can interact with it however you wish, the difference
	 * is that the boot method is invoked as soon as you register
	 * the service provider with the container meaning that everything
	 * in this method is eagerly loaded.
	 *
	 * If you wish to apply inflectors or register further service providers
	 * from this one, it must be from a bootable service provider like
	 * this one, otherwise they will be ignored.
	 *
	 * @since 2.6.10
	 */
	public function boot() {
	}
}
