src/bekanntmacher/boxmaker-bundle/src/Classes/UserInput.php line 17

Open in your IDE?
  1. <?php
  2. namespace Bekanntmacher\BoxmakerBundle\Classes;
  3. use Bekanntmacher\BoxmakerBundle\Model\FarbeModel;
  4. use Bekanntmacher\BoxmakerBundle\Model\TypeOptionModel;
  5. class UserInput
  6. {
  7.     /**
  8.      * Parameters
  9.      * @var array
  10.      */
  11.     protected $arrUserInput = array();
  12.     public function __construct($objConfig$idStandardwelle=null)
  13.     {
  14.         if(!is_array($objConfig))
  15.         {
  16.             // Farbe
  17.             $objFarbe FarbeModel::findByPk((int) \Input::get('farbe'));
  18.             $this->arrUserInput = array
  19.             (
  20.                 'type'              => (int) \Input::get('type'),
  21.                 'laenge'            => ((int) \Input::get('laenge') > 0) ? (int) \Input::get('laenge') : $objConfig->laenge,
  22.                 'breite'            => ((int) \Input::get('breite') > 0) ? (int) \Input::get('breite') : $objConfig->breite,
  23.                 'hoehe'             => ((int) \Input::get('hoehe') > 0) ? (int) \Input::get('hoehe') : $objConfig->hoehe,
  24.                 'stk'               => ((int) \Input::get('stk') > 0) ? (int) \Input::get('stk') : $objConfig->stk,
  25.                 'farbe'             => ($objFarbe !== null) ? $objFarbe->id $objConfig->farbe,
  26.                 'welle'             => ((int) \Input::get('welle') > 0) ? (int) \Input::get('welle') : $idStandardwelle,
  27.                 'druckfarben'       => (\Input::get('druckfarben')) ? \Input::get('druckfarben') : null,
  28.                 'druckverfahren'    => (\Input::get('druckverfahren')) ? \Input::get('druckverfahren') : null,
  29.                 'seite'             => (\Input::get('seite')) ? \Input::get('seite') : '1s',
  30.                 'stw'               => $this->objType->type_standardwelle
  31.             );
  32.             $objOptionen TypeOptionModel::findAll(array('order' => 'sorting'));
  33.             $arrOpts = array();
  34.             foreach ($objOptionen as $option)
  35.             {
  36.                 if(!(\Input::get('o_'.$option->id))) continue;
  37.                 $arrOpts[$option->id] = $option;
  38.             }
  39.             $this->arrUserInput['options'] = $arrOpts;
  40.         } else {
  41.             $this->arrUserInput $objConfig;
  42.         }
  43.     }
  44.     public function __get($key)
  45.     {
  46.         return $this->get($key);
  47.     }
  48.     public function __set($key$value)
  49.     {
  50.         $this->set($key$value);
  51.     }
  52.     public function get($key)
  53.     {
  54.         if(key_exists($key$this->arrUserInput) !== false)
  55.         {
  56.             return $this->arrUserInput[$key];
  57.         }
  58.         return false;
  59.     }
  60.     public function set($key$value)
  61.     {
  62.         $this->arrUserInput[$key] = $value;
  63.     }
  64.     public function getAll()
  65.     {
  66.         return $this->arrUserInput;
  67.     }
  68.     public function merge(array $arr)
  69.     {
  70.         if(is_array($arr) === false)
  71.         {
  72.             return false;
  73.         }
  74.         foreach ($arr as $key => $value)
  75.         {
  76.             if(key_exists($key$this->arrUserInput))
  77.             {
  78.                 continue;
  79.             }
  80.             $this->set($key$value);
  81.         }
  82.     }
  83. }