Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • ActionFormModel
  • ArrayUtil
  • ArrayValidator
  • AssociatedMediaBehavior
  • AuxLib
  • Changelog
  • DetailView
  • EncryptUtilTmp
  • EventsWidgetFieldFormatter
  • FailedLogins
  • FieldFormatter
  • FieldFormatterBase
  • FieldInputRenderer
  • FileFieldBehavior
  • FiltersForm
  • FilterUtil
  • FineDiff
  • FineDiffCopyOp
  • FineDiffDeleteOp
  • FineDiffInsertOp
  • FineDiffOp
  • FineDiffOps
  • FineDiffReplaceOp
  • GlobalCSSFormModel
  • GlobalImportFormModel
  • GoogleAuthenticator
  • JSONFieldsBehavior
  • JSONResponse
  • MediaFieldFormatter
  • MediaSelector
  • MobileActiveRecordFieldFormatter
  • MobileActivityFeed
  • MobileChartDashboard
  • MobileFieldFormatter
  • MobileFieldInputRenderer
  • ModuleModelNameValidator
  • MultiChildNode
  • MultiTypeAutocomplete
  • PasswordUtil
  • ProductFeature
  • ProfileWidgetLayout
  • QueryParamGenerator
  • RecordLimitBehavior
  • RecordView
  • RecordViewWidgetLayout
  • RelationshipsGridModel
  • RelationshipsJoin
  • RepairUserDataCommand
  • RequestUtil
  • RequiredIfNotSetValidator
  • ResponseUtil
  • RunMigrationScriptCommand
  • ServiceWebFormDesigner
  • Settings
  • StringUtil
  • TestEmailAction
  • TestEmailActionForm
  • ThemeGenerator
  • TimerUtil
  • TopicsFieldFormatter
  • TopicsWidgetLayout
  • TransactionalViewFieldFormatter
  • UrlUtil
  • ValidLinkValidator
  • WebFormDesigner
  • WebLeadFormDesigner
  • X2ActiveRecordBehavior
  • X2ActiveRecordFieldFormatter
  • X2ButtonColumn
  • X2ConditionList
  • X2ConsoleCommand
  • X2ControllerBehavior
  • X2DataColumn
  • X2DuplicateBehavior
  • X2Flashes
  • X2GridViewFieldFormatter
  • X2IPAddress
  • X2LeadsDataColumn
  • X2MergeableBehavior
  • X2MessageSource
  • X2MobileControllerBehavior
  • X2MobileProfileControllerBehavior
  • X2MobileQuotesControllerBehavior
  • X2MobileSiteControllerBehavior
  • X2MobileTopicsControllerBehavior
  • X2ModelConversionBehavior
  • X2ModelConversionWidget
  • X2ModelForeignKeyValidator
  • X2ModelUniqueIndexValidator
  • X2NonWebUser
  • X2StaticDropdown
  • X2StaticField
  • X2StaticFieldsBehavior
  • X2UrlManager
  • X2Validator
  • X2WidgetBehavior

Interfaces

  • AdminOwnedCredentials

Exceptions

  • CampaignMailingException
  • CodeExchangeException
  • GetCredentialsException
  • NoRefreshTokenException
  • NoUserIdException
  • StringUtilException

Functions

  • checkCurrency
  • checkDNS
  • checkServerVar
  • checkTimezone
  • decodeQuotes
  • echoIcons
  • encodeQuotes
  • exceptionForError
  • getField
  • getLanguageName
  • getModuleTitle
  • handleReqError
  • handleReqException
  • installer_t
  • installer_tr
  • isAllowedDir
  • mediaMigrationRrmdir
  • migrateMediaDir
  • printGraph
  • printR
  • renderFields
  • reqShutdown
  • RIP
  • translateOptions
  • tryGetRemote
  • Overview
  • Package
  • Class
  • Tree

Class ResponseUtil

Standalone environmentally-agnostic content/message feedback utility.

In the scope of a web request, it will respond via JSON (i.e. for use in an API or AJAX response action). When run in a command line interface, it will echo messages without exiting.

Setting elements of an object of this class (using the ArrayAccess implementation) will control the properties of the JSON that is returned when using it in a web request.

ResponseUtil implements ArrayAccess
Author: Demitri Morgan <demitri@x2engine.com>
Located at x2engine/protected/components/util/ResponseUtil.php
Methods summary
public static
# end( )

Performs the shutdown code.

Performs the shutdown code.

public static
# getObject( )

Returns the current response singleton object.

Returns the current response singleton object.

public static array
# getStatusMessages( )

Returns the static array of status messages, i.e. for reference

Returns the static array of status messages, i.e. for reference

Returns

array
public static boolean
# isCli( )

Returns true or false based on whether or not the current thread of PHP is being run from the command line.

Returns true or false based on whether or not the current thread of PHP is being run from the command line.

Returns

boolean
public static
# respond( type $message, boolean $error = false, boolean $fatal = false )

Universal, web-agnostic response function.

Universal, web-agnostic response function.

Responds with a JSON and closes the connection if used in a web request; merely echoes the response message (but optionally exits) otherwise.

Parameters

$message
type
$message The message to respond with.
$error
boolean
$error Indicates that an error has occurred
$fatal
boolean
$fatal Shut down PHP thread after printing the message
public static
# respondWithError( type $no, type $st, type $fi = Null, type $ln = Null )

Error handler method that uses the web-agnostic response method.

Error handler method that uses the web-agnostic response method.

This is disabled by default; fatal errors should ordinarily be caught by ResponseUtil::respondFatalErrorMessage(). This can be enabled for debugging purposes via setting ResponseUtil::$exitNonFatal to true.

Parameters

$no
type
$no
$st
type
$st
$fi
type
$fi
$ln
type
$ln
public static
# respondFatalErrorMessage( )

Shutdown function for handling fatal errors not caught by ResponseUtil::respondWithError().

Shutdown function for handling fatal errors not caught by ResponseUtil::respondWithError().

public static
# respondWithException( Exception $e )

Parameters

$e
Exception
$e The uncaught exception
public static string
# statusMessage( integer $code )

Obtain an appropriate message for a given HTTP status code.

Obtain an appropriate message for a given HTTP status code.

Parameters

$code
integer
$status

Returns

string
public
# __construct( )

Constructor. If one tries to instantiate two ResponseUtil objects, an exception will be thrown. The idea is that there should only ever be one response happening at a time.

Constructor. If one tries to instantiate two ResponseUtil objects, an exception will be thrown. The idea is that there should only ever be one response happening at a time.

public type
# offsetExists( type $offset )

Array interface method from ArrayAccess

Array interface method from ArrayAccess

Parameters

$offset
type
$offset

Returns

type

Implementation of

ArrayAccess::offsetExists()
public type
# offsetGet( type $offset )

Array interface method from ArrayAccess

Array interface method from ArrayAccess

Parameters

$offset
type
$offset

Returns

type

Implementation of

ArrayAccess::offsetGet()
public
# offsetSet( type $offset, type $value )

Array interface method from ArrayAccess

Array interface method from ArrayAccess

Parameters

$offset
type
$offset
$value
type
$value

Implementation of

ArrayAccess::offsetSet()
public
# offsetUnset( type $offset )

Array interface method from ArrayAccess

Array interface method from ArrayAccess

Parameters

$offset
type
$offset

Implementation of

ArrayAccess::offsetUnset()
public
# sendHttp( integer $status = null, type $message = '', type $error = null )

Sends a HTTP response back to the client.

Sends a HTTP response back to the client.

Parameters

$status
integer
$status The status code to use
$message
type
$message
$error
type
$error

Throws

Exception
protected
# sendHttpHeader( boolean $replace = true )

Sends HTTP headers. This method should be called before any content is sent.

Sends HTTP headers. This method should be called before any content is sent.

Parameters

$replace
boolean
$replace The argument sent to header as the replacement flag.
public
# setProperties( array $properties )

Sets _properties

Sets _properties

Parameters

$properties
array
$properties
Properties summary
public static boolean $exitNonFatal false
#

Exit on non-fatal PHP errors.

Exit on non-fatal PHP errors.

If set to true, the error handler ResponseUtil::respondWithError() will force a premature response for any PHP error, even if it's not of type E_ERROR.

public static integer $errorCode 500
#

The default HTTP status code to use when handling an internal error.

The default HTTP status code to use when handling an internal error.

This can be set to 200 when dealing with client-side code that cannot retrieve response data if the response code is not 200. This would thus allow user-friendly error reporting.

public static boolean $includeExtraneousOutput false
#

Whether to include or ignore any unintentional output

Whether to include or ignore any unintentional output

If false, any extra output generated within the scope of the response (i.e. error messages) will be excluded from the response altogether.

public static string|array|closure $shutdown 'die();'
#

Shutdown method.

Shutdown method.

Can be set to, for instance, "Yii::app()->end();" for a graceful Yii shutdown that saves/rotates logs and performs other useful/appropriate operations before terminating the PHP thread.

public static type $longErrorTrace false
#

Produce extended error traces in responses triggered by error handlers.

Produce extended error traces in responses triggered by error handlers.

public string $body
#

Override body.

Override body.

If left unset, the content type header will be set to JSON, and the response body will be _properties, encoded in JSON. Otherwise, any content type can be used, andthis property will be returned instead.

public array $httpHeader array( 'Content-Type' => 'application/json' )
#

HTTP header fields.

HTTP header fields.

The default of the "Content-type" field is JSON for ease of use, since it's expected that this class will be used mostly to compose responses in JSON format.

X2CRM Documentation API documentation generated by ApiGen 2.8.0