vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Model/Attribute/SelectMenu.php line 44

Open in your IDE?
  1. <?php
  2. /*
  3.  * Isotope eCommerce for Contao Open Source CMS
  4.  *
  5.  * Copyright (C) 2009 - 2019 terminal42 gmbh & Isotope eCommerce Workgroup
  6.  *
  7.  * @link       https://isotopeecommerce.org
  8.  * @license    https://opensource.org/licenses/lgpl-3.0.html
  9.  */
  10. namespace Isotope\Model\Attribute;
  11. use Isotope\Interfaces\IsotopeAttributeForVariants;
  12. /**
  13.  * Attribute to impelement SelectMenu widget
  14.  */
  15. class SelectMenu extends AbstractAttributeWithOptions implements IsotopeAttributeForVariants
  16. {
  17.     /**
  18.      * @inheritdoc
  19.      */
  20.     public function prepareOptionsWizard($objWidget$arrColumns)
  21.     {
  22.         if ($this->isVariantOption()) {
  23.             unset($arrColumns['default'], $arrColumns['group']);
  24.         }
  25.         return $arrColumns;
  26.     }
  27.     /**
  28.      * @inheritdoc
  29.      */
  30.     public function saveToDCA(array &$arrData)
  31.     {
  32.         // Varian select menu cannot have multiple option
  33.         if ($this->isVariantOption()) {
  34.             $this->multiple           false;
  35.             $this->size               1;
  36.         }
  37.         parent::saveToDCA($arrData);
  38.         if ($this->isVariantOption()) {
  39.             $arrData['fields'][$this->field_name]['eval']['includeBlankOption'] = true;
  40.         }
  41.         if ($this->multiple) {
  42.             $arrData['fields'][$this->field_name]['sql'] = 'blob NULL';
  43.         } else {
  44.             if ('attribute' === $this->optionsSource) {
  45.                 $arrData['fields'][$this->field_name]['sql'] = "varchar(64) NOT NULL default ''";
  46.             } else {
  47.                 $arrData['fields'][$this->field_name]['sql'] = 'int(10) NOT NULL default 0';
  48.             }
  49.             if ($this->fe_filter) {
  50.                 $arrData['config']['sql']['keys'][$this->field_name] = 'index';
  51.             }
  52.         }
  53.     }
  54. }