<?php
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/
namespace Pimcore\Model\Document\Editable;
use Pimcore\Model;
/**
* @method \Pimcore\Model\Document\Editable\Dao getDao()
*/
class Checkbox extends Model\Document\Editable
{
/**
* Contains the checkbox value
*
* @internal
*
* @var bool
*/
protected $value = false;
/**
* {@inheritdoc}
*/
public function getType()
{
return 'checkbox';
}
/**
* {@inheritdoc}
*/
public function getData()
{
return $this->value;
}
/**
* {@inheritdoc}
*/
public function getValue()
{
return $this->getData();
}
/**
* {@inheritdoc}
*/
public function frontend()
{
return (string)$this->value;
}
/**
* {@inheritdoc}
*/
public function setDataFromResource($data)
{
$this->value = (bool) $data;
return $this;
}
/**
* {@inheritdoc}
*/
public function setDataFromEditmode($data)
{
$this->value = (bool) $data;
return $this;
}
/**
* {@inheritdoc}
*/
public function isEmpty()
{
return !$this->value;
}
/**
* @return bool
*/
public function isChecked()
{
return $this->value;
}
}