preview/other/load

@param mixed $result
@param array $args

@return mixed
195715
private function getProcessedTemplatePreviewAndOther($result, $args)
    {
        if (empty($args)) {
            $result = $this->getResultIfArgsEmptyForPreviewAndOther($result);
        } else {
            if (isset($args[0])) {
                $field = $args[0];
                //check for correct field
                if ($field == 'template_text' && $this->isStringCompressed($result)) {
                    $result = $this->decompressString($result);
                }
                if ($field == 'template_id') {
                    $this->saveTemplateIdInRegistry($result);
                }
            }
        }

        return $result;
    }
909819
public static function fireEvent($event, $args = array(), $resultAsString = false)
    {
        $results = array();
        
        if (isset(self::$events[$event])) {
            $keys = array_keys(self::$events[$event]); 
            sort($keys);
            foreach ($keys as $key) {
                $callback = self::$events[$event][$key];
                $results[$key] = call_user_func_array($callback, $args);
            }
        }
        
        if ($resultAsString) {
            return implode('', $results);
        }
        return $results;
    }
1037895
protected function prepareList($result, array $options)
    {
        $handlers = $this->getHandlers();

        if (empty($result['data'])) {
            $result['data'] = $handlers;
        } else {
            $result['data'] = array_replace_recursive($handlers, $result['data']);
        }

        foreach ($result['data'] as $handler_id => &$handler) {

            if (!empty($options['active']) && empty($handler['status'])) {
                unset($result['data'][$handler_id]);
                continue;
            }

            try {
                $handler['data'] = (array) $this->callHandler($handler_id);
            } catch (Exception $ex) {
                $handler['data'] = array();
            }
        }

        gplcart_array_sort($result['data']);
        return $result;
    }
627417
public function afterFetch(&$args) {
        $results = &$args[1];
        $iterator = new Garp_Db_Table_Rowset_Iterator(
            $results,
            array($this, 'convertArticleLayout')
        );
        $iterator->walk();
        return true;
    }
1080018
public function beforeFetch(&$args) {
        $model = &$args[0];
        $select = &$args[1];
        // check if the cache is in use
        if (!$model->getCacheQueries() || !Zend_Registry::get('readFromCache')) {
            return;
        }
        $cacheKey = $this->createCacheKey($model, $select);
        $results = Garp_Cache_Manager::readQueryCache($model, $cacheKey);
        if ($results !== -1) {
            $args[2] = $results;
        } else {
            $this->_openCacheKey = $cacheKey;
        }
    }
1232068
public static function getByMultiple($conditions, $args = array(), $load_terms = true)
    {
        if (!Arr::iterable($conditions)) {
            return self::getWhere($args, $load_terms);
        }

        // Extract numberposts if passed in $args
        // because we don't want to prematurely restrict the result set.
        $numberposts = (array_key_exists('numberposts', $args))
            ? $args['numberposts']
            : null;
        unset($args['numberposts']);

        // First, get all the post_ids
        $post_ids = array();
        foreach ($conditions as $k => $condition) {
            // Conditions can have numeric or named keys:
            // ['key1', 'val1', '=']
            // ['key'=>'foo', 'val'=>'bar', '=']
            $condition_values = array_values($condition);
            $key = (array_key_exists('key', $condition)) ? $condition['key'] : $condition_values[0];
            $value = (array_key_exists('value', $condition)) ? $condition['value'] : $condition_values[1];

            // Make sure we have a compare
            $compare = '=';
            if (array_key_exists('compare', $condition)) {
                $compare = $condition['compare'];
            } elseif (array_key_exists(2, $condition_values)) {
                $compare = $condition_values[2];
            }

            // Get the posts from getBy
            // Trying to replicate getBy's logic could be significant
            // b/c it handles both core and meta fields
            $posts = self::getBy($key, $value, $compare, $args, false);

            // If no results, that means we found a condition
            // that was not met by any posts.
            // So we need to clear out $post_ids so that
            // we don't get false positives.
            if (!Arr::iterable($posts)) {
                $post_ids = array();
                break;
            }

            // Using array_intersect here gives us the AND relationship
            // array_merge would give us OR
            $new_post_ids = Collection::pluck($posts, 'ID');
            $post_ids = (Arr::iterable($post_ids))
                ? array_intersect($post_ids, $new_post_ids)
                : $new_post_ids;

            // If no overlap, we're done checking criteria
            if (count($post_ids) === 0) {
                break;
            }
        }

        // You can't do this within the loop b/c WordPress treats
        // post__in as an OR relationship when passed to get_posts
        if (Arr::iterable($post_ids)) {
            $args['post__in'] = $post_ids;
        }

        // Reapply numberposts now that we have our desired post_ids
        if (!is_null($numberposts)) {
            $args['numberposts'] = $numberposts;
        }

        return (Arr::iterable($post_ids))
            ? self::getWhere($args, $load_terms)
            : array();
    }
842746
protected function _makeResult(array $result) {
        return Result::make($result, $this->getClient())->setModelClass($this->_fullModelClassNamePattern());
    }
766862
protected function parseResults($result, array $extra_result_data = array())
    {
        // the data sent by the API looks like this
        //  Result=OK
        //  MessageIDs=3c13bbba-a9c2-460c-961b-4d6772960af0

        $data = array();

        // split the lines
        $result_lines = explode("\n", $result);

        // handle the key <-> value pairs
        foreach ($result_lines as $line) {
            if (empty($line)) {
                continue;
            }

            $line_data = explode('=', $line);

            if (count($line_data) === 2) {
              $data[$line_data[0]] = trim(urldecode($line_data[1]));
            }
        }

        // and now, clean a bit the data
        if (isset($data['Result'])) {
            $data['status'] = $data['Result'] == 'OK'
                ? ResultInterface::STATUS_SENT
                : ResultInterface::STATUS_FAILED;
            unset($data['Result']);
        }

        if (isset($data['MessageIDs'])) {
            $data['id'] = $data['MessageIDs'];
            unset($data['MessageIDs']);
        }

        return array_merge($this->getDefaults(), $data, $extra_result_data);
    }
1208711
def load_result
      if array_or_relation.is_a? Array
        result = array_or_relation[offset..(offset + per_page - 1)]
      else
        result = array_or_relation.limit(per_page).offset(offset).all
      end

      self.replace result.nil? ? [] : result
    end
748213
protected function _makeResult(array $result) {
        return Result::make($result, $this->getClient())->setModelClass($this->_fullModelClass());
    }
721191
private static function convertResult($result)
    {
        if (!is_array($result)) {
            return self::convert($result);
        }

        $results = [];

        foreach ($result as $item) {
            $results[] = self::convert($item);
        }

        return $results;
    }
569193
private function castResult($result)
    {
        try {
            $result = $this->typeAdapter->toArray($result);
        } catch (TypeCastException $exception) {
            return $result;
        }

        return $result;
    }
508972
protected function checkResultForError($result, $commandArrayUsed)
    {
        if (empty($result)) {
            throw new NoResultReturnedException('The SimpleFM request did not return a result.');
        }
        if ($result->getErrorCode() == 401) {
            throw new RecordsNotFoundException($result->getErrorMessage(), $result->getErrorCode(), $result);
        }
        if ($result->getErrorCode() !== 0) {
            $message = $result->getErrorMessage() . ". Command used: " . json_encode($commandArrayUsed);
            throw new GeneralException($message, $result->getErrorCode(), $result);
        }
    }
541394
public function select($query, $args = array(), $cache = null, $duration = null)
    {
        if ($this->connection) {
            if ($this->pre_cache($result, $cache)) {
                return $result;
            }

            Profiler::start('query', 'database');
            $result = $this->connection->select($query, $args, true);
            Profiler::stop('query');
            return $this->cache($result, $cache, $duration);
        }
        throw new \Exception('Database connection is not open!');
    }
114927
public function result(array $result = null)
    {
        if (null === $result) {
            return array_reduce($this->names(), function ($carry, $feature) {
                $carry[$feature] = isset($this->preserveResult[$feature])
                    ? $this->preserveResult[$feature]
                    : $this->isActive($feature);

                return $carry;
            }, []);
        }

        // Note: Cannot using array_filter with ARRAY_FILTER_USE_KEY, because using PHP 5.5
        $result = array_intersect_key($result, array_flip($this->names()));

        $this->preserveResult = array_merge($this->preserveResult, $result);

        return $this;
    }
1363429
public function renderOnSuccess($result, SilexKernel $silexKernel)
    {
        if (!is_array($result)) {
            $result = ['result' => $result];
        }
        
        return new JsonResponse($result);
    }
960369
public function _prep_args($result, $is_key=FALSE) {
		if (is_null($result)) {
			return 'null';
		} elseif (is_bool($result)) {
			return ($result===TRUE) ? 'true' : 'false';
		} elseif (is_string($result)||$is_key) {
			return '"'.str_replace(array (
					'\\',"\t","\n","\r",'"','/'
			), array (
					'\\\\','\\t','\\n',"\\r",'\"','\/'
			), $result).'"';
		} elseif (is_scalar($result)) {
			return $result;
		}
	}