vendor/pimcore/pimcore/models/Document/Editable/Checkbox.php line 23

  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Pimcore
  5.  *
  6.  * This source file is available under two different licenses:
  7.  * - GNU General Public License version 3 (GPLv3)
  8.  * - Pimcore Commercial License (PCL)
  9.  * Full copyright and license information is available in
  10.  * LICENSE.md which is distributed with this source code.
  11.  *
  12.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  13.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  14.  */
  15. namespace Pimcore\Model\Document\Editable;
  16. use Pimcore\Model;
  17. /**
  18.  * @method \Pimcore\Model\Document\Editable\Dao getDao()
  19.  */
  20. class Checkbox extends Model\Document\Editable
  21. {
  22.     /**
  23.      * Contains the checkbox value
  24.      *
  25.      * @internal
  26.      *
  27.      */
  28.     protected bool $value false;
  29.     public function getType(): string
  30.     {
  31.         return 'checkbox';
  32.     }
  33.     public function getData(): mixed
  34.     {
  35.         return $this->value;
  36.     }
  37.     public function getValue(): mixed
  38.     {
  39.         return $this->getData();
  40.     }
  41.     public function frontend()
  42.     {
  43.         return (string)$this->value;
  44.     }
  45.     public function setDataFromResource(mixed $data): static
  46.     {
  47.         $this->value = (bool) $data;
  48.         return $this;
  49.     }
  50.     public function setDataFromEditmode(mixed $data): static
  51.     {
  52.         $this->value = (bool) $data;
  53.         return $this;
  54.     }
  55.     public function isEmpty(): bool
  56.     {
  57.         return !$this->value;
  58.     }
  59.     public function isChecked(): bool
  60.     {
  61.         return $this->value;
  62.     }
  63. }