예제 #1
0
파일: Lazy.php 프로젝트: GemsTracker/MUtil
 /**
  * Set the current stack
  *
  * @param mixed $stack Value to be turned into stack for evaluation
  * @return \MUtil_Lazy_StackInterface
  */
 public static function setStack($stack)
 {
     if ($stack instanceof \MUtil_Lazy_StackInterface) {
         self::$_stack = $stack;
     } elseif ($stack instanceof \MUtil_Model_Bridge_TableBridgeAbstract) {
         self::$_stack = new \MUtil_Lazy_Stack_BridgeStack($stack);
     } elseif ($stack instanceof \MUtil_Lazy_Repeatable) {
         self::$_stack = new RepeatableStack($stack);
     } elseif (\MUtil_Ra::is($stack)) {
         $stack = \MUtil_Ra::to($stack);
         self::$_stack = new \MUtil_Lazy_Stack_ArrayStack($stack);
     } elseif (is_object($stack)) {
         self::$_stack = new \MUtil_Lazy_Stack_ObjectStack($stack);
     } else {
         throw new \MUtil_Lazy_LazyException("Lazy stack set to invalid scalar type.");
     }
     return self::$_stack;
 }
예제 #2
0
 /**
  * Set the parameters where the survey should return to
  *
  * @param mixed $return \Zend_Controller_Request_Abstract, array of something that can be turned into one.
  * @return \Gems_User_User
  */
 public function setSurveyReturn($return = null)
 {
     if (null === $return) {
         $this->_unsetVar('surveyReturn');
         return $this;
     }
     if ($return instanceof \Zend_Controller_Request_Abstract) {
         $return = $return->getParams();
     } elseif (!is_array($return)) {
         $return = \MUtil_Ra::to($return);
     }
     if ('autofilter' == $return['action']) {
         $return['action'] = 'index';
     }
     $return = array_filter($return);
     // \MUtil_Echo::track($return);
     $this->_setVar('surveyReturn', $return);
     return $this;
 }
예제 #3
0
 /**
  * The transform function performs the actual transformation of the data and is called after
  * the loading of the data in the source model.
  *
  * @param \MUtil_Model_ModelAbstract $model The parent model
  * @param array $data Nested array
  * @param boolean $new True when loading a new item
  * @param boolean $isPostData With post data, unselected multiOptions values are not set so should be added
  * @return array Nested array containing (optionally) transformed data
  */
 public function transformLoad(\MUtil_Model_ModelAbstract $model, array $data, $new = false, $isPostData = false)
 {
     $defaults = $this->getDefaultRow($model);
     $keyCount = $this->getKeyItemCount();
     $requireds = $this->getRequiredRows();
     $data = \MUtil_Ra::to($data, \MUtil_Ra::RELAXED);
     $results = array();
     if (!$data) {
         foreach ($requireds as $key => $required) {
             $results[$key] = $required + $defaults;
         }
     } else {
         $row = reset($data);
         foreach ($requireds as $key => $required) {
             if ($this->_compareRows($required, $row, $keyCount)) {
                 $results[$key] = $row + $required;
                 $row = next($data);
             } else {
                 $results[$key] = $required + $defaults;
             }
         }
     }
     return $results;
 }