Example #1
0
 /**
  * @return \BitrixHelperLib\Classes\Block\Object[]
  */
 public function get()
 {
     if (\BitrixHelperLib\Classes\Registry::bitrixCacheEnabled() && ($retval = $this->getCachedResult())) {
         return $retval;
     }
     $retval = array();
     $resultSet = $this->getResult();
     if (isset($this->resultSetCallback)) {
         $resultSet = call_user_func($this->resultSetCallback, $resultSet);
     }
     $key = -1;
     while ($obRes = $resultSet->GetNextElement()) {
         switch ($this->fetchMode) {
             case self::FETCH_MODE_FIELDS:
                 $element = $obRes->GetFields();
                 break;
             case self::FETCH_MODE_PROPERTIES:
                 $element = $obRes->getProperties();
                 break;
             default:
                 $element = array_merge($obRes->GetFields(), $obRes->getProperties());
                 break;
         }
         foreach ((array) $this->callbacks as $callback) {
             if ($callbackResult = call_user_func($callback, $element)) {
                 $element = $callbackResult;
             }
         }
         $key = $this->hydrateById ? $element['ID'] : ++$key;
         switch ($this->hydrationMode) {
             case self::HYDRATION_MODE_OBJECTS_ARRAY:
             case self::HYDRATION_MODE_OBJECTS_COLLECTION:
                 $className = $this->className;
                 $retval[$key] = new $className($element);
                 break;
             default:
                 $retval[$key] = $element;
                 break;
         }
     }
     if ($this->hydrationMode == self::HYDRATION_MODE_OBJECTS_COLLECTION) {
         $retval = new Collection($retval);
     }
     if (\BitrixHelperLib\Classes\Registry::bitrixCacheEnabled()) {
         $this->cacheResult($retval);
     }
     return $retval;
 }
Example #2
0
 /**
  * @return \BitrixHelperLib\Classes\Section\Object[]
  */
 public function get()
 {
     if (\BitrixHelperLib\Classes\Registry::bitrixCacheEnabled() && ($retval = $this->getCachedResult())) {
         return $retval;
     }
     $retval = array();
     if (!is_array($this->arSelectFields)) {
         $this->arSelectFields = array();
     }
     if ($this->bAddUFToSelect) {
         $this->arSelectFields[] = 'UF_*';
     }
     $resultSet = \CIBlockSection::GetList($this->arOrder, $this->arFilter, $this->bIncCnt, $this->arSelectFields, $this->arNavStartParams);
     if (isset($this->resultSetCallback)) {
         $resultSet = call_user_func($this->resultSetCallback, $resultSet);
     }
     while ($section = $resultSet->GetNext()) {
         foreach ((array) $this->callbacks as $callback) {
             if ($callbackResult = call_user_func($callback, $section)) {
                 $section = $callbackResult;
             }
         }
         $key = $this->hydrateById ? $section['ID'] : count($retval);
         switch ($this->hydrationMode) {
             case self::HYDRATION_MODE_OBJECTS_ARRAY:
                 $className = $this->className;
                 $retval[$key] = new $className($section);
                 //                    $retval[$key] = new Object($section);
                 break;
             default:
                 $retval[$key] = $section;
                 break;
         }
     }
     if (\BitrixHelperLib\Classes\Registry::bitrixCacheEnabled()) {
         $this->cacheResult($retval);
     }
     return $retval;
 }