Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Boolean.php
Go to the documentation of this file.
1 <?php
7 
13 class Boolean extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
14 {
21  public function beforeSave($customer)
22  {
23  $attributeName = $this->getAttribute()->getName();
24  $inputValue = $customer->getData($attributeName);
25  $inputValue = $inputValue === null ? $this->getAttribute()->getDefaultValue() : $inputValue;
26  $sanitizedValue = !empty($inputValue) ? '1' : '0';
27  $customer->setData($attributeName, $sanitizedValue);
28  return $this;
29  }
30 }
$customer
Definition: customers.php:11