Visits the outer array

@param Parameter         $model
@param ResultInterface   $result
@param ResponseInterface $response
@param array             $context
@return ResultInterface|void
344085
private function visitOuterArray(
        Parameter $model,
        ResultInterface $result,
        ResponseInterface $response,
        array &$context
    ) {
        // Use 'location' defined on the top of the model
        if (!($location = $model->getLocation())) {
            return;
        }

        // Trigger the before method on each unique visitor location
        if (!isset($context['visitors'][$location])) {
            $result = $this->triggerBeforeVisitor($location, $model, $result, $response, $context);
        }

        // Visit each item in the response
        $result = $this->responseLocations[$location]->visit($result, $response, $model);

        return $result;
    }
97341
public function _findComputed(Model $Model, $func, $state, $query, $result = array()) {
		if ('after' == $state) {
			return $result;
		}

		$query['fields'] = array(sprintf(
			'%s(%s) AS %s'
			, strtoupper($this->_methods[strtolower($this->settings[$Model->alias]['method'])])
			, $Model->alias . '.' . $this->settings[$Model->alias]['column']
			, $this->settings[$Model->alias]['result']
		));

		return $query;
	}
660962
public function afterFind(Model $Model, $results, $primary) {
		if (!$primary) {
			return $results;
		}

		$settings = $this->settings[$Model->alias];

		if ($settings['skip'] === true) {
			return $results;
		}

		// the permit behavour is a bit pointless if we're handing more than one result
		if (count($results) > 1) {
			return $results;
		}

		// HACK: Retrieve the zeroth index in the resultset
		$userId = Hash::get($results, "0.{$settings['field']}");
		if ($userId === null) {
			return $results;
		}

		if ($userId == $this->user($Model, $results, 'id')) {
			return $results;
		}

		$adminCheck = $settings['check'];
		$adminValue = $settings['value'];
		if ($adminCheck && $this->user($Model, $results, $adminCheck) == $adminValue) {
			return $results;
		}

		throw new UnauthorizedException($settings['message']);
	}
271359
protected function loadField($modelFieldInfo, &$parameter, $result) {
    if ($modelFieldInfo->isMABIModel) {
      if (empty($result)) {
        $parameter = NULL;
      }
      else {
        /**
         * @var $model \MABI\Model
         */
        $model = call_user_func($modelFieldInfo->type . '::init', $this->app);
        $model->load($result);
        $parameter = $model;
      }
    }
    else {
      switch ($modelFieldInfo->type) {
        case 'string':
          $parameter = $result;
          break;
        case 'int':
          $parameter = intval($result);
          break;
        case 'bool':
          $parameter = $result == TRUE;
          break;
        case 'float':
          $parameter = floatval($result);
          break;
        case 'DateTime':
        case '\DateTime':
          if (empty($result)) {
            $parameter = NULL;
          }
          else {
            $parameter = new \DateTime('@' . $result);
          }
          break;
        case '':
        case 'array':
          $parameter = $result;
      }
    };
  }
1136049
protected function realMatchRoute(ResultInterface $result)/*# : bool */
    {
        $res = false;
        $param = ['result' => $result];
        if ($this->trigger(self::EVENT_BEFORE_MATCH, $param) &&
            $this->match($result) &&
            $this->trigger(self::EVENT_AFTER_MATCH, $param)
        ) {
            $res = true;
        }

        $this->setCollectorHandler($result);
        return $res;
    }
1110305
private function handleResult($result): void
    {
        if ($result instanceof ActionResultInterface) {
            $result->updateResponse($this->getApplication(), $this->getRequest(), $this->getResponse());

            return;
        }

        if ($result === null) {
            return;
        }

        $this->getResponse()->setContent(json_encode($result));
        $this->getResponse()->setHeader('Content-Type', 'application/json');
    }
153390
public final function render(OutputBuffer $out, ViewModelInterface $model, array $params = [])
	{
		$this->context->bind($model);
		$this->context->set('@view', $this);
		
		foreach($params as $k => $v)
		{
			$this->context->set($k, $v);
		}
		
		try
		{
			if($this->getParent() === NULL)
			{
				$this->renderMain($out);
			}
			else
			{
				$this->parent->renderMain($out);
			}

			return $out;
		}
		finally
		{
			$this->parent = false;
			$this->context->unbind();
		}
	}
448920
protected function _actionCancel(ControllerContextModel $context)
    {
        //Create the redirect
        $context->response->setRedirect($this->getReferrer($context));

        if ($context->result instanceof ModelEntityInterface) {
            $entity = $context->result;
        }
        else $entity = $this->getModel()->fetch();

        return $entity;
    }
275510
protected function _prepareResponse(Context $c, $result, $buffer = null)
  {
    return $result ?: ($buffer !== false ? $buffer : null);
  }
1236600
public function output($response, $context = null)
    {
        $this->builder->output()->response($response, $context);
    }
290606
public function dispatch(Request $request, $result)
    {
        foreach ($request->getAcceptableContentTypes() as $mimeType) {
            /** @var \eZ\Publish\Core\REST\Common\Output\Visitor $visitor */
            foreach ($this->mapping as $regexp => $visitor) {
                if (preg_match($regexp, $mimeType)) {
                    return $visitor->visit($result);
                }
            }
        }

        throw new RuntimeException('No view mapping found.');
    }
1202348
protected function _actionFetch(ModelContext $context)
    {
        $table = $this->getTable();

        //Entity options
        $options = array(
            'identity_column' => $context->getIdentityKey()
        );

        //Select the rows
        if (!$context->state->isEmpty()) {
            $data = $table->select($context->query, Database::FETCH_ROWSET, $options);
        } else {
            $data = $table->createRowset($options);
        }

        return $data;
    }
500927
public function route_respond( $result_data ) {
		// Logic depends on the contents/state of result_data
		if ( !is_null( $result_data ) ) {

			// True response
			if ( $result_data === true ) {
				// True case WITHOUT any returned data
			}
			elseif ( $result_data === false ) {
				// Throw an exception
				throw new InvalidApiParameters();
			}
			else {
				// Prepare our data for response
				$this->response->data = $result_data;
			}

		}
		else {
			// The response is null, throw an exception
			throw new ObjectNotFound();
		}
	}
429094
public static function execute($value, ContextInterface $context): array
    {
        assert(is_int($value) || is_string($value));

        $apiClass = $context->getProperties()->getProperty(static::PROPERTY_API_CLASS);

        /** @var FactoryInterface $apiFactory */
        $apiFactory = $context->getContainer()->get(FactoryInterface::class);

        /** @var CrudInterface $api */
        $api = $apiFactory->createApi($apiClass);

        $data   = $api->withIndexFilter((string)$value)->indexIdentities();
        $result = !empty($data);

        return $result === true ?
            static::createSuccessReply($value) :
            static::createErrorReply(
                $context,
                $value,
                ErrorCodes::EXIST_IN_DATABASE_SINGLE,
                Messages::EXIST_IN_DATABASE_SINGLE,
                []
            );
    }
279560
protected function processResponse(array $context = array())
    {
        if (!$this->response) {
            // If no response, then processResponse shouldn't have been called
            $e = new RequestException('Error completing request');
            $e->setRequest($this);
            throw $e;
        }

        $this->state = self::STATE_COMPLETE;

        // A request was sent, but we don't know if we'll send more or if the final response will be successful
        $this->dispatch('request.sent', $this->getEventArray() + $context);

        // Some response processors will remove the response or reset the state (example: ExponentialBackoffPlugin)
        if ($this->state == RequestInterface::STATE_COMPLETE) {

            // The request completed, so the HTTP transaction is complete
            $this->dispatch('request.complete', $this->getEventArray());

            // If the response is bad, allow listeners to modify it or throw exceptions. You can change the response by
            // modifying the Event object in your listeners or calling setResponse() on the request
            if ($this->response->isError()) {
                $event = new Event($this->getEventArray());
                $this->getEventDispatcher()->dispatch('request.error', $event);
                // Allow events of request.error to quietly change the response
                if ($event['response'] !== $this->response) {
                    $this->response = $event['response'];
                }
            }

            // If a successful response was received, dispatch an event
            if ($this->response->isSuccessful()) {
                $this->dispatch('request.success', $this->getEventArray());
            }
        }
    }
348182
function collectionResultPost (context) {
    // if there are synchronous views then execute any post functions
    if (this.hasCollectionSynchronous) {
        _.each(this.modelViews.collection.synchronous, modelView => {
            // if view does not have post function do nothing
            if (!modelView.post) {
                return
            }
            // execute post function and merge result to context
            _.merge(context, modelView.post(context))
        })
    }
    // if there are asynchronous views then execute any post functions
    if (this.hasCollectionAsynchronous) {
        return Promise.all(_.map(this.modelViews.collection.asynchronous, modelView => {
            // if view does not have post function do nothing
            if (!modelView.post) {
                return
            }
            // execute post function
            return modelView.post({
                context: context,
                session: this.query.session,
            }).then(ctx => {
                _.merge(context, ctx)
            })
        }))
        // resolve with context
        .then(() => context)
    }
    // otherwise resolve with context
    else {
        return Promise.resolve(context)
    }
}
1033839
public static function validate($result, array $context)
    {
        if (!empty($context['parent'])) {
            if (!($result instanceof $context['parent'])) {
                throw new InvalidPointer('Object must be an instance of '.$context['parent']);
            }
        }
        if (!empty($context['validator'])) {
            if (!Callback::call($context['validator'], [$result])) {
                throw new InvalidPointer('Object is not valid');
            }
        }
        return true;
    }