| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- <?php
- namespace ModulesGarden\Servers\ZimbraEmail\App\Services\ConfigurableOptions\Models;
- use ModulesGarden\Servers\ZimbraEmail\App\Services\ConfigurableOptions\Abstracts\AbstractSerialize;
- use ModulesGarden\Servers\ZimbraEmail\App\Services\ConfigurableOptions\Helper\TypeConstans;
- /**
- * Description of Option
- *
- * @author Mateusz Pawłowski <mateusz.pa@modulesgarden.com>
- */
- class Option extends AbstractSerialize
- {
- /*
- * @var string $optionname
- */
- protected $gid;
- /*
- * @var string $optionname
- */
- protected $optionname;
- /*
- * @var string $optiontype
- */
- protected $optiontype = 1;
- /*
- * @var integer $min
- */
- protected $qtyminimum = 0;
- /*
- * @var integer $max
- */
- protected $qtymaximum = 0;
- /*
- * @var integer $order
- */
- protected $order = 0;
- /*
- * @var integer $hidden
- */
- protected $hidden = 0;
- /*
- * @var array $subOptions
- */
- protected $subOptions = [];
- /*
- * Alternative method to set required fields
- *
- * @param string $name, \ModulesGarden\Servers\ZimbraEmail\App\Service\ConfigurableOptions\Helper\TypeConstans $type
- */
- public function __construct($key, $name = null, $type = null)
- {
- $this->optionname = $this->prepareName($key, $name);
- $this->optiontype = $type;
- }
- /*
- * Add additional suboptions
- *
- * @params \ModulesGarden\Servers\ZimbraEmail\App\Service\ConfigurableOptions\Models\SubOption $option
- * @return $this
- */
- public function addSubOption(SubOption $option)
- {
- $this->subOptions[] = $option;
- return $this;
- }
- /*
- * Set Option Name
- *
- * @param string $name;
- *
- * @return object $this
- */
- public function setName($name)
- {
- $this->optionname = $name;
- return $this;
- }
- /*
- * Set Option Name
- *
- * @param object \ModulesGarden\Servers\ZimbraEmail\App\Service\ConfigurableOptions\Helper\TypeConstans
- *
- * @return object $this
- */
- public function setType(TypeConstans $type)
- {
- $this->optiontype = $type;
- return $this;
- }
- /*
- * Set option min, require for quantity
- *
- * @param string $min;
- *
- * @return object $this
- */
- public function setMin($min)
- {
- $this->qtyminimum = $min;
- return $this;
- }
- /*
- * Set option max, require for quantity
- *
- * @param string $max;
- *
- * @return object $this
- */
- public function setMax($max)
- {
- $this->qtymaximum = $max;
- return $this;
- }
- /*
- * Set Order
- *
- * @param integer $order;
- *
- * @return object $this
- */
- public function setOrder($order)
- {
- $this->order = $order;
- return $this;
- }
- /*
- * Set Option Name
- *
- * @param string $name;
- *
- * @return object $this
- */
- public function setHidden($hidden)
- {
- $this->hidden = $hidden;
- return $this;
- }
- /*
- * Set Group Option ID
- *
- * @param integer $gid;
- *
- * @return object $this
- */
- public function setGid($gid)
- {
- $this->gid = $gid;
- return $this;
- }
- public function getSubOptions()
- {
- return $this->subOptions;
- }
- public function getName()
- {
- $expoldeName = explode('|', $this->optionname);
- if (!empty($expoldeName[1]))
- {
- return $expoldeName[1];
- }
- return $this->optionname;
- }
- public function getKey()
- {
- return explode('|', $this->optionname)[0];
- }
- }
|