Returns the request body content.

@param bool $asResource If true, a resource will be returned
@return string|resource The request body content or a resource to read the body stream.

@throws \LogicException
556826
public function getContent($asResource = FALSE) {

		$currentContentIsResource = is_resource($this->content);

		if (PHP_VERSION_ID < 50600 && FALSE === $this->content) {
			throw new \LogicException('getContent() can only be called once when using the resource return type and PHP below 5.6.');
		}

		if ($asResource) {

			if ($currentContentIsResource) {
				rewind($this->content);
				return $this->content;
			}

			// Content passed in parameter (test)

			if (is_string($this->content)) {
				$resource = fopen('php://temp', 'r+');
				fwrite($resource, $this->content);
				rewind($resource);
				return $resource;
			}

			$this->content = FALSE;
			return fopen('php://input', 'rb');

		}

		if ($currentContentIsResource) {
			rewind($this->content);
			return stream_get_contents($this->content);
		}

		if (NULL === $this->content) {
			$this->content = file_get_contents('php://input');
		}

		return $this->content;

	}
1330799
public function request($method, $uri = null, array $options = [], $asJson = true)
    {
        $response = parent::request($method, $uri, $options);

        if ($response->getStatusCode() !== 200) {
            ErrorHandler::handleErrorResponse($response);
        }

        if ($asJson) {
            return json_decode($response->getBody(), true);
        }

        return $response->getBody()->getContents();
    }
457509
static function fetchByName( $name, $asObject = true )
    {
        $conds = array( 'name' => $name );
        return eZPersistentObject::fetchObject( eZContentClassGroup::definition(),
                                                null,
                                                $conds,
                                                $asObject );
    }
923274
static function parseWith($optionsResource, array $_ = null)
    {
        if (!static::isConfigurableWith($optionsResource))
            throw new \InvalidArgumentException(sprintf(
                'Invalid Configuration Resource provided on (%s); given: (%s).'
                , static::class, \Poirot\Std\flatten($optionsResource)
            ));


        // ..

        if ($optionsResource instanceof iHttpRequest)
            # Parse and assert Http Request
            $optionsResource = Plugin\ParseRequestData::_($optionsResource)->parseBody();

        return parent::parseWith($optionsResource);
    }
1013614
protected function getZipContent( $file, $as_xml = true ) {

		// Locates an entry using its name
		$index = $this->zip->locateName( urldecode( $file ) );

		if ( false === $index ) {
			return '';
		}

		// returns the contents using its index
		$content = $this->zip->getFromIndex( $index );

		// if it's not xml, return
		if ( ! $as_xml ) {
			return $content;
		}

		// if it is xml, then instantiate and return a simplexml object
		return new \SimpleXMLElement( $content );
	}
369897
public static function getClientIP($getSource = false)
    {
        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
            $ip     = $_SERVER['HTTP_CLIENT_IP'];
            $source = 'HTTP_CLIENT_IP';

        } elseif (!empty($_SERVER['HTTP_X_REAL_IP'])) {
            $ip     = $_SERVER['HTTP_X_REAL_IP'];
            $source = 'HTTP_X_REAL_IP';

        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ip     = $_SERVER['HTTP_X_FORWARDED_FOR'];
            $source = 'HTTP_X_FORWARDED_FOR';

        } elseif (!empty($_SERVER['REMOTE_ADDR'])) {
            $ip     = $_SERVER['REMOTE_ADDR'];
            $source = 'REMOTE_ADDR';

        } else {
            $ip     = '0.0.0.0';
            $source = 'undefined';
        }

        if ($getSource) {
            return $source;
        } else {
            return $ip;
        }
    }
293993
static function fetchUpdateChildrenPendingList( $asObject = true )
    {
        $resultArray = array();

        $conds = array( 'updatechildren' => 1 );

        $pendingList = eZPersistentObject::fetchObjectList( eZPaEx::definition(),
                                                    null,
                                                    $conds,
                                                    null,
                                                    null,
                                                    $asObject );
        if (is_array( $pendingList ) && count( $pendingList ) )
        {
            foreach ( $pendingList as $pendingItem )
            {
                $resultArray[$pendingItem->attribute( 'contentobject_id' )] = $pendingItem;
            }
        }

        return $resultArray;
    }
531187
private function getCacheableAnnotation(ResourceObject $ro)
    {
        $annotation = $this->reader->getClassAnnotation(new \ReflectionClass($ro), Cacheable::class);
        if ($annotation instanceof Cacheable || $annotation === null) {
            return $annotation;
        }

        throw new \LogicException();
    }
928565
public function getUrl()
    {
        if (empty($this->url)) {
            throw new LogicException(
                sprintf(self::ERROR_MISSING_ATTRIBUTE_FORMAT, 'url')
            );
        }
        return $this->url;
    }
917603
public function getExactlyOneClass($fileSource) {
        if (count($this->ast) !== 1 || $this->ast[0]->getType() !== "Stmt_Class")
            throw new PhpParserException("\"$fileSource\" does not define exactly one class");
        return $this->ast[0];
    }
392168
protected function getFromResource($handle, $closeAfter=true)
    {
        $contents = '';

        while (!feof($handle)) {
            $contents .= fread($handle, 8192);
        }

        if ($closeAfter) {
            fclose($handle);
        }

        return $contents;
    }
1276095
public function getResponseBody($decode = true)
    {
        $data = $this->response->getBody();
        return $decode === true ? json_decode($data) : $data;
    }
1287998
public function readFromResource($descriptor, $close = true)
    {
        if (isset($this->_pipes[$descriptor])) {
            $contents = stream_get_contents($this->_pipes[$descriptor]);
            if ($close) {
                $this->closeResource($descriptor);
            }
            return $contents;
        }
        return false;
    }
993583
public function getParameter($as = self::AS_STRING) {
		if ($as == self::AS_SIMPLEXML) {
			//convert to SimpleXMLElement
			$success = simplexml_load_string($this->parameter);
				
			if ($success === false) {
				$error = libxml_get_last_error();
				throw new \RuntimeException("XML Syntax error: " . $error->message);
			}
				
			return $success;
		}
		elseif ($as == self::AS_DOM) {
			//convert to DOMDocument
			$dom = new \DOMDocument();
				
			if (!$dom->loadXML($this->parameter)) {
				$error = libxml_get_last_error();
				throw new \RuntimeException("XML Syntax error: " . $error->message);
			}
				
			return $dom;
		}
		
		return $this->parameter;
	}
748693
public function getBody($name = false)
    {
        if ($name === false) {
            ob_start();
            $this->sendBody();
            return ob_get_clean();
        } elseif ($name === true) {
            return $this->body;
        } elseif (is_string($name) && isset($this->body[$name])) {
            return $this->body[$name];
        }
        return null;
    }
1098610
public function getSourceURL($grant = true)
    {
        if ($this->File->exists()) {
            return $this->File->getSourceURL($grant);
        }
        return null;
    }
858575
public static function fromResource(Resource $resource)
    {
        if (!is_subclass_of($resource->model_class, Medools\Model::class)) {
            $message = 'Invalid Resource model_class in ' . static::class . ': '
                . $resource->model_class;
            throw new \LogicException($message);
        }

        $controller = new static;

        $list = $resource->getList();
        if (empty($list)) {
            return false;
        }

        foreach ($list as $id) {
            if (!$controller->generate($id)) {
                return false;
            }
        }

        if ($resource->content_type === 'application/zip') {
            $controller->zip();
        } else {
            $controller->output();
        }

        return true;
    }