<?php
/**
 * Config provider manager for "exclusions".
 *
 * @package Ealab\Deployer
 */

namespace Ealab\Deployer\Tracking\Config\Exclusions;

use Ealab\Deployer\Tracking\Config\ConfigCollector;
use Ealab\Deployer\Tracking\Config\ConfigProviderManagerBase;
use Ealab\Deployer\Tracking\Config\StaticConfigProvider;

/**
 * Config provider manager for "exclusions".
 */
class ExclusionsConfigProviderManager extends ConfigProviderManagerBase {
	/**
	 * {@inheritDoc}
	 */
	protected function getBaseConfigProviderDefinitions(): array {
		$providers = array();

		// Default config in case the repository config is not available.
		$providers[] = array(
			'class'      => StaticConfigProvider::class,
			'exclusions' => array(
				'config' => array(
					''            => array(
						'options'  => array(
							'options.option_name' => array(
								'_site_transient_%',
								'_transient_%',
								'cron',
							),
						),
						'postmeta' => array(
							'postmeta.meta_key' => array(
								'_edit_lock',
							),
						),
					),
					'deploy-sync-content' => array(
						'options' => array(
							'options.option_name' => array(
								'deploy_sync_content__current_config__%',
							),
						),
					),
				),
			),
		);

		$providers[] = array( 'class' => ExclusionsRepositoryConfigProvider::class );

		return $providers;
	}

	/**
	 * {@inheritDoc}
	 */
	public static function getManagerId(): string {
		return 'exclusions';
	}

	/**
	 * {@inheritDoc}
	 */
	public static function getConfigMergeStrategy(): string {
		return ConfigCollector::CONFIG_MERGE_STRATEGY__CUMULATE;
	}
}
