<?php
/**
 * Boolean Column
 * 
 * Use this column for displaying a yes/no for an boolean
 * 
 * @author Elze Kool <info@visualmedia.nl>
 */

namespace VisualM\ManagementBundle\AdminList\Column;

use VisualM\ManagementBundle\AdminList\Column\ColumnConfigurationAbstract;
use VisualM\ManagementBundle\AdminList\Column\ColumnConfigurationInterface;

/**
 * Boolean Column
 *
 * @author Elze Kool <info@visualmedia.nl>
 */
class BooleanColumn extends ColumnConfigurationAbstract implements ColumnConfigurationInterface
{
    /**
     * Class to use for Boolean true
     * @var boolean
     */
    private $trueClass;
	
	/**
     * Class to use for Boolean false
     * @var boolean
     */
	private $falseClass;

    /**
     * Constructor
     * 
     * @param string  $field      Field (null for no field binding)
     * @param string  $title      Title
     * @param boolean $sortable   Sortable
     * @param string  $trueClass  Class to use for Boolean true
	 * @param string  $falseClass Class to use for Boolean false
     */
    public function __construct($field, $title, $sortable = true, $trueClass = null, $falseClass = null)
    {
        parent::__construct(
            $field,
            $title,
            $sortable,
            'VisualMManagementBundle:AdminList:Column/Boolean/listItem.html.twig', 
            'VisualMManagementBundle:AdminList:Column/PlainValueColumn/listHeader.html.twig',
            null
        );

        $this->trueClass = $trueClass;
		$this->falseClass = $falseClass;
    }

    /**
     * Get Class for Value
	 *
	 * @param boolean $value Value
     * 
     * @return string Class to use
     */
    public function getBooleanClass($value) {
		return ($value) ? $this->trueClass : $this->falseClass;
	}

}