<?php
namespace SabaiApps\Directories\Component\Display\Button;

use SabaiApps\Directories\Component\Entity;

class BackButton extends AbstractButton {

	protected function _displayButtonInfo( Entity\Model\Bundle $bundle ) {
		if ( empty( $bundle->info['public'] ) ) {
			return false;
		}

		return array(
			'label'            => __( 'Back button', 'directories-pro' ),
			'default_settings' => array(
				'_label' => __( 'Back', 'directories-pro' ),
				'_color' => 'outline-secondary',
				'_icon'  => 'fas fa-arrow-left',
			),
			'overlayable'      => false,
		);
	}

	public function displayButtonLink( Entity\Model\Bundle $bundle, Entity\Type\IEntity $entity, array $settings, $displayName ) {
		return $this->_application->LinkTo(
			$settings['_label'],
			'#',
			array( 'icon' => $settings['_icon'] ),
			array(
				'class'   => $settings['_class'],
				'style'   => $settings['_style'],
				'onclick' => 'window.history.back();',
			)
		);
	}
}
