xplo.re Medusa Core Framework 3.2
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Event
  • Todo
  • Download

Namespaces

  • Core
    • Authentication
      • Auto
        • Driver
      • Driver
    • Cache
      • Driver
    • Charset
      • Driver
    • Configuration
      • Driver
    • Controller
    • Converter
      • Driver
    • Decoder
      • Driver
    • Encoder
      • Driver
    • Env
      • Authentication
      • Locale
      • Proxy
      • Server
        • HTTP
        • Redirect
        • X
    • Exception
    • Exchange
      • Driver
    • Fault
      • Formatter
        • Driver
      • Incident
        • Exception
      • Reporter
        • Driver
    • Field
    • Filter
      • Driver
    • Formatter
      • Driver
        • coreuimarkup
          • Token
    • Hash
    • Loader
    • Locale
    • Log
      • Driver
    • Module
      • Dependency
        • Requirement
          • Core
          • PHP
      • Linkage
        • Driver
    • PDF
    • Plugin
    • Query
      • Driver
    • Server
      • Driver
    • Session
      • Driver
    • Set
    • Storage
      • Driver
      • Field
        • Element
    • Stream
      • Driver
    • String
    • Translation
      • Driver
      • Language
        • Driver
    • Type
    • URI
      • Driver
    • Version
    • View
      • Driver
        • coreui
          • Control
            • Button
            • Table
          • Element
        • htmlbuilder
          • Tags
        • yui
          • Modules
  • None
  • PHP

Classes

  • Authentication
  • Authentication_Token
  • AutoLoader
  • Cache
  • Charset
  • ClassDescriptor
  • Closure
  • Configuration
  • Controller
  • Converter
  • Date
  • Decoder
  • Delegate
  • Dispatcher
  • Encoder
  • Env
  • Env_Field
  • Env_File
  • Env_FileList
  • Env_Request
  • Env_SERVER
  • Exchange
  • Fault
  • Field
  • Filter
  • Filter_Value
  • Formatter
  • Hash
  • IP
  • Loader
  • Locale
  • Locale_Node
  • Log
  • Module
  • Module_Iterator
  • Nothing
  • Object
  • OS
  • Plugin
  • Profiler
  • Query
  • Registry
  • Resource
  • Server
  • Session
  • Session_Token
  • Set
  • Storage
  • Storage_Result
  • Storage_Statement
  • Stream
  • Translation
  • URI
  • URI_Parameters
  • UUID
  • Value
  • Version
  • View

Interfaces

  • Accessor
  • Chainable
  • Comparable
  • Configurable
  • Equality
  • Identity
  • Inquiry
  • Masquerade
  • Mutator
  • SeekableStream
  • Storable
  • Variator

Exceptions

  • Exception

Constants

  • Copyright
  • ProductName
  • Version

Class View

Base class for views with integrated support for data encoders, a shared proxy view, automated renderer delegation and chained translator instance.

Proxy views are generalised views that do not render a specific page but provide a shared output buffer and common methods that request-specific views utilise to render a page. Proxy views are implemented as view drivers and commonly implement some sort of template system.
For better IDE integration regarding application-specific extensions to the proxy view, all views should derive from base view class defined by the application and document a magic proxy property with the class of the configured proxy view.

Core\Object implements Core\Chainable
Extended by Core\Set implements Core\Accessor
Extended by Core\Set\Mutable implements Core\Mutator
Extended by Core\Field implements Core\Inquiry
Extended by Core\Field\Mutable implements Core\Variator
Extended by Core\View

Direct known subclasses

Core\View\Driver\html, Core\View\Driver\plain, Core\View\Driver\yui

Indirect known subclasses

Core\View\Driver\coreui, Core\View\Driver\htmlbuilder

Namespace: Core
Package: Core\MVC\View
Since: 3.0
Requires: PHP 5.3
Version: 1.3
Located at View.inc.php

Methods summary

public
# __construct( Core\URI $uri )

Initialises a new View instance.

Initialises a new View instance.

Parameters

$uri
Driver configuration URI.

Remark

The constructor is used by View drivers to parse and process parameters; an application level View generally does not utilise an own constructor.

A View subclass must provide a default encoder interface name. Due to optimisation issues for application-level View classes, a default encoder interface configuration entry has been removed to reduce unnecessary memory overhead; application-level View implementations generally derive their encoder interface from the registered View proxy.


Since

3.0
public static Core\View
# autocreate( Core\URI $uri )

Returns new view proxy instance for a given driver description.

Returns new view proxy instance for a given driver description.

Parameters

$uri
Driver description URI.

Returns

Core\View
Reference to new view proxy instance.

Throws

Core\Exception\InvalidDriver
Failed to load the requested proxy view driver.

Since

3.0
public static Core\View
# derive( $proxyKey, $viewClass )

Initialises and returns a new view instance with a chained proxy view instance retrieved from the global registry.

Initialises and returns a new view instance with a chained proxy view instance retrieved from the global registry.

Parameters

$proxyKey
key of proxy view to use.
$viewClass
class name of view to initialise.

Returns

Core\View
Reference to new view instance with chained proxy view.

Since

3.0
public boolean
# chain( Core\Chainable $object, array $flags = null )

Sets a new proxy view or translation instance. Existing entries are overwritten.

Sets a new proxy view or translation instance. Existing entries are overwritten.

Parameters

$object

Supports the following object types:

  • Core\View

    Sets or replaces the proxy view for this view.

  • Core\Translation

    Sets or replaces the translation interface for this view.

$flags
Unused.

Returns

boolean
true on success, otherwise false.

Throws

Core\Exception\InvalidArgument
Class of provided object is not supported.

Since

3.0

Overrides

Core\Object::chain
public
# clear( )

Resets the internal rendering buffer, if possible. Used to clear partly rendered outputs if rendering was stopped before completion, for example due to an exception.

Resets the internal rendering buffer, if possible. Used to clear partly rendered outputs if rendering was stopped before completion, for example due to an exception.

Remark

The default implementation does nothing; proxy drivers should reset their internal state upon call.


Since

3.1
public string
# encode( string $string )

Encodes a string using the associated encoder.

Encodes a string using the associated encoder.

Parameters

$string
String to encode.

Returns

string
Encoded string.

Since

3.0
public Core\Encoder
# encoder( )

Returns a reference to the associated encoder instance. If the view does not yet retain an encoder instance, either the encoder from its proxy view is retained or, if the view itself is a proxy or it is used standalone, a new encoder instance is automatically created from the URI string encoder parameter.

Returns a reference to the associated encoder instance. If the view does not yet retain an encoder instance, either the encoder from its proxy view is retained or, if the view itself is a proxy or it is used standalone, a new encoder instance is automatically created from the URI string encoder parameter.

Returns

Core\Encoder
Reference to associated encoder instance.

Throws

Core\Exception\MissingParameter
Encoder parameter missing.

Since

3.1
public boolean
# render( )

Renders contents.

Renders contents.

Up to version 1.0, the default implementation would return false. Since version 1.1, null is returned by default, allowing the use of registered renderers without the need to implement a stub render() method. If a called renderer explicitly returns false, all remaining renderers are executed but this method will return false.

Returns

boolean

If false is returned, the primary controller will stop rendering the page; this is useful for RPC requests or binary content renderers, that directly write to the client and do not need any further view (e.g. template) processing.

Since

3.0
public
# setDataForUndefinedKey( string $key, mixed $value )

Adds a KDC value to the view.

Adds a KDC value to the view.

Parameters

$key
Data field key.
$value
Value to store.

Throws

Core\Exception\UndefinedKey
No data field identified by the given key exists.

Since

3.0

Overrides

Core\Field\Mutable::setDataForUndefinedKey
public Core\URI
# uri( string|array $controller = null, string $action = null, array $parameters = null )

Returns reference to new URI instance for the URL returned by a call to Core\View::url() with forwarded parameters.

Returns reference to new URI instance for the URL returned by a call to Core\View::url() with forwarded parameters.

Parameters

$controller
See Core\View::url() for parameter details.
$action
See Core\View::url() for parameter details.
$parameters
See Core\View::url() for parameter details.

Returns

Core\URI
Reference to new URI instance from generated URL string.

See

Core\View::url()

Since

3.0
public string
# url( string|array $controller = null, string $action = null, array $parameters = null )

Formats URL string using the currently active query interface of the primary controller for a given MVC target.

Formats URL string using the currently active query interface of the primary controller for a given MVC target.

Parameters

$controller

Name of controller to target. If this value is an empty string, the default "index" controller is used; if this value is null, the current controller from the latest dispatcher command is used.

If an array if provided instead, a hash with URL parameters is expected; the following keys are recognised:

  • controller

    Same as plain controller argument.

  • action

    Same as plain action argument.

  • parameters

    Same as parameters argument.

  • protocol

    If set, the resulting link will switch to the specified protocol name; the hostname is derived from the current server environment, unless a different hostname value is provided as well.

  • hostname

    Hostname to use instead of hostname derived from current server environment, if the resulting URL is not relative.

  • port

    Port number to use, otherwise the URL will not contain an explicit port. If the provided port equals the protocol defaults 80 for HTTP and 443 for HTTPS, the port is also omitted.

  • relative

    If set to a value that evaluates to false, the returned URL will be absolute regardless of supplied arguments, otherwise the URL is only absolute, if a different protocol, hostname or port is used.

If a key is not defined, null is assumed.

$action

Name of controller action to run. If this value is the empty string, the default "main" action is used; if this value is null, the action from the latest dispatcher command is used.

$parameters
Hash of GET parameters to embed into the URL.

Returns

string
Generated URL string.

Since

3.0

Methods inherited from Core\Field\Mutable

offsetSet(), offsetUnset(), setDataForKey(), setDataForKeys(), setKeyMasquerade(), updateMasqueradedKeys()

Methods inherited from Core\Field

getDataForKey(), getDataForKeys(), getDataForUndefinedKey(), issetDataForKey(), offsetExists(), offsetGet()

Methods inherited from Core\Set\Mutable

__set(), __unset()

Methods inherited from Core\Set

__get(), __isset()

Methods inherited from Core\Object

__autocreateFactory(), __call(), __processParameters(), __toString(), attachMethod(), getValueForKey(), getValueForKeyPath(), getValueForUndefinedKey(), hash(), issetValueForKey(), setValueForKey(), setValueForKeyPath(), setValueForUndefinedKey(), uuid()

Constants summary

string EncoderParameter

Parameter name of encoder URI string to automatically create an encoder instance for data encoding.

Parameter name of encoder URI string to automatically create an encoder instance for data encoding.

Since

3.0
# 'encoder'

Constants inherited from Core\Object

AnyParameterType, AutochainParameterType, AutocreateParameterType, BooleanParameterType, CharParameterType, EnumParameterType, IntegerParameterType, RealParameterType, StringParameterType, UserParameterType

Properties summary

protected array $_v_parameters

KVC property.

KVC property.

Since

3.0
#
protected Core\View $_v_proxy

KVC property.

KVC property.

See

Core\View::derive()

Since

3.0
#
protected ArrayObject $_v_renderers

KVC property.

KVC property.

Since

3.1
#
protected Core\Translation $_v_translator

KVC property.

KVC property.

Since

3.1
#
protected Core\URI $_v_uri

KVC property.

KVC property.

Since

3.0
#
protected Core\Encoder $_encoder

Encoder instance used by the view. This value is unset and equals null until the encoder is initialised by the first call to the Core\View::encoder() or the Core\View::encode() methods (the latter implies a call to Core\View::encoder()).

Encoder instance used by the view. This value is unset and equals null until the encoder is initialised by the first call to the Core\View::encoder() or the Core\View::encode() methods (the latter implies a call to Core\View::encoder()).

Since

3.1
#

Properties inherited from Core\Field\Mutable

$_v_masqueradedKeys

Properties inherited from Core\Field

$_v_data

Magic properties

public read-only Core\Encoder $encoder

See Core\View::encoder() for details.

public read-only array $parameters

Hash of initialisation parameters extracted from the driver URI for proxy views.

public read-only Core\View $proxy

Reference to shared proxy view.

public read-only ArrayObject $renderers

Array of renderer function names. This property can be set by controllers to automatically run a specified set of renderer methods once the view is rendered. A controller can add a renderer name by simply appending to this array, as shown in the following example: php $view->renderers [] = 'myAction'; If the view does not override the default Core\View::render() implementation (doing so without calling the parent implementation is allowed to prevent the execution of standard renderers), the renderMyAction() method will be called by the standard renderer. Renderers are executed in the order they are added to the array; renderer names must be valid PHP identifiers, the first character is automatically transformed to uppercase and the prefix "render" is prepended to the name.

public read-only Core\Translation $translator

Reference to chained translator instance or null, if no translator instance has been chained to this view.

public read-only Core\URI $uri

Proxy URI. Stored by proxy views to apply parameters to normal views.

Magic properties inherited from Core\Field\Mutable

$masqueradedKeys

Magic properties inherited from Core\Field

$data

Magic properties inherited from Core\Object

$hash, $uuid

xplo.re Medusa Core Framework 3.2 API documentation generated by ApiGen