LFT
  • Namespace
  • Class
  • Tree

Namespaces

  • Docoflow
    • Contracts
    • Entity
    • Facades
    • Models
    • Traits
  • Docolight
    • Agno
      • Traits
    • Container
    • Http
      • Contracts
    • Rest
      • Handler
      • Http
    • Support
      • Debug
      • Traits
  • Docotory
    • Traits
  • None

Classes

  • Docoflow\Docoflow
  • Docoflow\Entity\Group
  • Docoflow\Entity\Step
  • Docoflow\Entity\Verificator
  • Docoflow\Facades\Action
  • Docoflow\Facades\Activity
  • Docoflow\Facades\Flo
  • Docoflow\Facades\StateActivity
  • Docoflow\Flo
  • Docoflow\Models\Workflow
  • Docoflow\Models\WorkflowAction
  • Docoflow\Models\WorkflowActivity
  • Docoflow\Models\WorkflowGroups
  • Docoflow\Models\WorkflowNotification
  • Docoflow\Models\WorkflowState
  • Docoflow\Models\WorkflowStateActivity
  • Docoflow\Models\WorkflowStep
  • Docoflow\Models\WorkflowVerificator
  • Docolight
  • Docolight\Agno\AgnoModule
  • Docolight\Container\Container
  • Docolight\Http\Headers
  • Docolight\Http\JsonResponse
  • Docolight\Http\MimeResponse
  • Docolight\Http\Response
  • Docolight\Http\ResponseFactory
  • Docolight\Rest\Handler\RestfulErrorHandler
  • Docolight\Rest\Http\RestFulController
  • Docolight\Support\ActiveRecordWrapper
  • Docolight\Support\Arr
  • Docolight\Support\Carbonate
  • Docolight\Support\ClassLoader
  • Docolight\Support\Collection
  • Docolight\Support\CollectionDataProvider
  • Docolight\Support\Debug\Dumper
  • Docolight\Support\Debug\HtmlDumper
  • Docolight\Support\Facade
  • Docolight\Support\Factory
  • Docolight\Support\Fluent
  • Docolight\Support\Html
  • Docolight\Support\IterablePager
  • Docolight\Support\Repository
  • Docolight\Support\Set
  • Docolight\Support\Str
  • Docotory\Factory

Interfaces

  • Docoflow\Contracts\DocoflowContract
  • Docoflow\Contracts\ValidationStatus
  • Docolight\Http\Contracts\Arrayable

Traits

  • Docoflow\Traits\BulkValidator
  • Docoflow\Traits\Entity
  • Docoflow\Traits\HasMutator
  • Docoflow\Traits\Validable
  • Docolight\Agno\Traits\HasAssetsUrl
  • Docolight\Agno\Traits\HasAutoload
  • Docolight\Support\Traits\Macroable
  • Docotory\Traits\HasFactories

Exceptions

  • Docolight\Container\BindingResolutionException
  • Docotory\ResolvingTypeException

Functions

  • array_add
  • array_build
  • array_collapse
  • array_divide
  • array_dot
  • array_except
  • array_first
  • array_flatten
  • array_forget
  • array_get
  • array_has
  • array_last
  • array_only
  • array_pluck
  • array_pull
  • array_replace_value
  • array_set
  • array_sort
  • array_sort_recursive
  • array_where
  • cache
  • camel_case
  • class_basename
  • class_uses_recursive
  • collect
  • container
  • data_get
  • dd
  • def
  • dump
  • e
  • ends_with
  • fluent
  • get
  • head
  • input
  • last
  • object_get
  • preg_replace_sub
  • request
  • response
  • session
  • snake_case
  • starts_with
  • str_contains
  • str_finish
  • str_is
  • str_limit
  • str_random
  • str_replace_array
  • str_slug
  • studly_case
  • title_case
  • trait_uses_recursive
  • transaction
  • trimtolower
  • value
  • with
  1 <?php
  2 
  3 namespace Docolight\Http;
  4 
  5 use Exception;
  6 use Docolight\Http\Contracts\Arrayable;
  7 
  8 /**
  9  * Response that has specified mime type.
 10  *
 11  * @author Krisan Alfa Timur <krisanalfa@docotel.co.id>
 12  */
 13 abstract class MimeResponse extends Response
 14 {
 15     /**
 16      * String representation of the body.
 17      *
 18      * @var string
 19      */
 20     protected $stringRepresentation;
 21 
 22     /**
 23      * {@inheritdoc}
 24      */
 25     public function getBody()
 26     {
 27         return (empty($this->body)) ? $this->getEmpty() : $this->body;
 28     }
 29 
 30     /**
 31      * {@inheritdoc}
 32      */
 33     public function finalize()
 34     {
 35         list($status, $headers, $body) = parent::finalize();
 36 
 37         $this->stringRepresentation = $this->convertToStringRepresentation($body);
 38         $this->length = strlen($this->stringRepresentation);
 39 
 40         $this->headers->set('Content-Type', $this->getContentType());
 41         $this->headers->set('Content-Length', $this->length);
 42 
 43         return array($status, $headers, $body);
 44     }
 45 
 46     /**
 47      * {@inheritdoc}
 48      */
 49     public function write($body, $replace = false)
 50     {
 51         if ($body) {
 52             return $this->innerWrite($body, $replace);
 53         }
 54     }
 55 
 56     /**
 57      * Inner write.
 58      *
 59      * @param Docolight\Http\Contracts\Arrayable $body
 60      * @param boolean                            $replace
 61      *
 62      * @return \Docolight\Http\Response
 63      */
 64     protected function innerWrite(Arrayable $body, $replace = false)
 65     {
 66         if ($replace === true) {
 67             $this->body = $body;
 68         } elseif ($replace === false) {
 69             $this->body->fill($body->castToArray());
 70         }
 71 
 72         return $this;
 73     }
 74 
 75     /**
 76      * {@inheritdoc}
 77      */
 78     protected function sendBody($body)
 79     {
 80         if (trim(strtoupper(def($_SERVER, 'REQUEST_METHOD', ''))) !== 'HEAD') {
 81             echo $this->stringRepresentation;
 82         }
 83     }
 84 
 85     /**
 86      * Convert to a string representation.
 87      *
 88      * @param Docolight\Http\Contracts\Arrayable $body
 89      *
 90      * @return string
 91      */
 92     abstract protected function convertToStringRepresentation(Arrayable $body);
 93 
 94 
 95     /**
 96      * Get content type specified for this class.
 97      *
 98      * @return string
 99      */
100     abstract protected function getContentType();
101 }
102 
LFT API documentation generated by ApiGen