<?php
namespace SabaiApps\Directories\Component\Payment\DisplayLabel;

use SabaiApps\Directories\Component\Display;
use SabaiApps\Directories\Component\Entity\Model\Bundle;
use SabaiApps\Directories\Component\Entity\Type\IEntity;

class PlanDisplayLabel extends Display\Label\AbstractLabel {

	protected function _displayLabelInfo( Bundle $bundle ) {
		return array(
			'label'            => __( 'Payment plan label', 'directories-pro' ),
			'default_settings' => array(
				'_color' => array( 'type' => 'secondary' ),
			),
			'labellable'       => false,
		);
	}

	public function displayLabelText( Bundle $bundle, IEntity $entity, array $settings ) {
		if ( ! $plan = $this->_application->Payment_Plan( $entity ) ) {
			return;
		}

		return array(
			'label' => $plan->paymentPlanTitle(),
			'color' => isset( $settings['_color'] ) ? $settings['_color'] : null,
			'attr'  => array(
				'data-plan-name' => $plan->paymentPlanName(),
			),
		);
	}
}
