<?php
namespace SabaiApps\Directories\Component\Review\EntityFeature;

use SabaiApps\Directories\Component\Entity\Feature\AbstractFeature;
use SabaiApps\Directories\Component\Entity\Model\Bundle;

class ReviewsEntityFeature extends AbstractFeature {

	protected function _entityFeatureInfo() {
		return array(
			'label'            => __( 'Reviews', 'directories-pro' ),
			'weight'           => 50,
			'default_settings' => array(
				'enable' => false,
			),
		);
	}

	public function entityFeatureSupports( Bundle $bundle, $planType = 'base' ) {
		return ! empty( $bundle->info['review_enable'] );
	}

	public function entityFeatureSettingsForm( Bundle $bundle, array $settings, array $parents = array() ) {
		return array(
			'enable' => array(
				'#title'         => __( 'Enable reviews', 'directories-pro' ),
				'#type'          => 'checkbox',
				'#default_value' => ! empty( $settings['enable'] ),
				'#horizontal'    => true,
			),
		);
	}

	public function entityFeatureIsEnabled( Bundle $bundle, array $settings ) {
		return ! empty( $settings['enable'] );
	}
}
