Overview

Namespaces

  • Nethgui
    • Adapter
    • Authorization
    • Component
    • Controller
      • Collection
      • Table
    • Exception
    • Log
    • Model
    • Module
      • Help
      • Notification
    • Renderer
    • Serializer
    • System
    • Test
      • Tool
      • Unit
        • Nethgui
          • Adapter
            • ParameterSet
          • Authorization
          • Log
          • Module
            • Notification
          • Renderer
          • Serializer
          • System
          • Utility
          • View
        • Test
          • Tool
    • Utility
    • View
    • Widget
      • Xhtml
  • None
  • Test
    • Tool

Classes

  • LegacyCommandBag
  • Translator
  • View

Interfaces

  • CommandReceiverInterface
  • TranslatorInterface
  • ViewableInterface
  • ViewInterface
  • Overview
  • Namespace
  • Class
  • Deprecated

Class View

A view object holds output data and references to child views.

It inherits an ArrayAccess interface and is capable to convert its internal state to a string using a Template.

A Template can be a PHP script or a callback function that receives the view state.

Usually, PHP templates are kept into View/ directories, but generally they follow the class naming convention.

Moreover, every module has a View object assigned to it as a parameter during prepareView() operation.

Nethgui\View\View implements Nethgui\View\ViewInterface, Nethgui\Log\LogConsumerInterface, Nethgui\View\CommandReceiverInterface
Namespace: Nethgui\View
Author: Davide Principi davide.principi@nethesis.it
Since: 1.0
See: \Nethgui\Module\ModuleInterface::prepareView()
Located at View/View.php
Methods summary
public
# __construct( string $targetFormat, Nethgui\Module\ModuleInterface $module, Nethgui\View\TranslatorInterface $translator, array $urlParts = array() )

Parameters

$targetFormat
The target format file extension of the final view output
$module
$translator
$urlParts
An array of three strings corresponding to <siteUrl, pathUrl, controllerPath>
public string
# getTargetFormat( )

Get the requested resource format

Get the requested resource format

Deprecated

since 1.6

Returns

string

Api

Implementation of

Nethgui\View\ViewInterface::getTargetFormat()
public Nethgui\View\ViewInterface
# copyFrom( Traversable $data )

Assign data to the View state.

Assign data to the View state.

Parameters

$data

Returns

Nethgui\View\ViewInterface

Api

Implementation of

Nethgui\View\ViewInterface::copyFrom()
public Nethgui\View\ViewInterface
# setTemplate( string|callable|boolean $template )

Set the template to be applied to the view

Set the template to be applied to the view

  • If a string is given, it identifies a PHP Template script (ie. Nethgui\Template\Main);

  • If a callback function is given, it is invoked with an array representing the view state as argument and is expected to return a string representing the view;

  • If a boolean FALSE, is given the view is rendered as an empty string.

Parameters

$template
The template converting the view state to a string

Returns

Nethgui\View\ViewInterface

Api

Implementation of

Nethgui\View\ViewInterface::setTemplate()
public string|callable|boolean
# getTemplate( )

TODO

TODO

Returns

string|callable|boolean

See

Nethgui\View\View::setTemplate()

Api

Implementation of

Nethgui\View\ViewInterface::getTemplate()
public Nethgui\View\ViewInterface
# spawnView( Nethgui\Module\ModuleInterface $module, boolean $register = FALSE )

Create a new view object associated to $module

Create a new view object associated to $module

Parameters

$module
The associated $module
$register
If TRUE the returned view is added to the current object with key equal to the module identifier

Returns

Nethgui\View\ViewInterface
The new view object, of the same type of the actual.

Api

Implementation of

Nethgui\View\ViewInterface::spawnView()
public
# getIterator( )

Implementation of

IteratorAggregate::getIterator()
public
# offsetExists( $offset )

Implementation of

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

Implementation of

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

Implementation of

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

Implementation of

ArrayAccess::offsetUnset()
public string
# translate( string $value, array $args = array() )

A method to translate a message according to the user language preferences.

A method to translate a message according to the user language preferences.

Parameters

$value
$args

Returns

string

See

TranslatorInterface::translate()
Nethgui\View\View::getTranslator()

Api

Implementation of

Nethgui\View\ViewInterface::translate()
public Nethgui\View\TranslatorInterface
# getTranslator( )

Access to the object performing string translations

Access to the object performing string translations

Returns

Nethgui\View\TranslatorInterface

See

Nethgui\View\View::translate()

Api

Implementation of

Nethgui\View\ViewInterface::getTranslator()
public Nethgui\Module\ModuleInterface
# getModule( )

The module associated to this view.

The module associated to this view.

Returns

Nethgui\Module\ModuleInterface

Api

Implementation of

Nethgui\View\ViewInterface::getModule()
public array
# getModulePath( )

Gets the array of the current module identifier plus all identifiers of the ancestor modules, starting from the root.

Gets the array of the current module identifier plus all identifiers of the ancestor modules, starting from the root.

Returns

array

See

ModuleInterface::getParent()
ModuleInterface::getIdentifier()

Api

Implementation of

Nethgui\View\ViewInterface::getModulePath()
public array
# resolvePath( string $path )

Obtain the complete path list, starting from root.

Obtain the complete path list, starting from root.

An heading '/' character treat the $path as absolute, otherwise the $path is considered relative to the current module and a '..' substring goes one level up.

Parameters

$path
The path

Returns

array
The path parts, starting from root

See

Nethgui\View\View::getModulePath()
Nethgui\View\View::getModule()

Api

Implementation of

Nethgui\View\ViewInterface::resolvePath()
public string
# getUniqueId( string $path = '' )

Generate a unique identifier for the given $path. If no parts are given the identifier refers the the module referenced by the view.

Generate a unique identifier for the given $path. If no parts are given the identifier refers the the module referenced by the view.

Parameters

$path
Relative to the current module

Returns

string

Api

Implementation of

Nethgui\View\ViewInterface::getUniqueId()
public string
# getClientEventTarget( string $name )

Get the target control identifier for the given view member

Get the target control identifier for the given view member

Parameters

$name

Returns

string

See

358


Api

Implementation of

Nethgui\View\ViewInterface::getClientEventTarget()
public string
# getModuleUrl( string $path = '' )

Return an absolute url path.

Return an absolute url path.

Parameters

$path
Relative to the current module

Returns

string

See

Nethgui\View\View::resolvePath()

Api

Implementation of

Nethgui\View\ViewInterface::getModuleUrl()
public string
# getSiteUrl( )

The web site URL without trailing slash

The web site URL without trailing slash

Returns

string

Example

http://www.example.org:8080

Api

Implementation of

Nethgui\View\ViewInterface::getSiteUrl()
public string
# getPathUrl( )

The path component of an URL with a leading slash and trailing

The path component of an URL with a leading slash and trailing

Returns

string

Example

/my/path/to/the/app/

Api

Implementation of

Nethgui\View\ViewInterface::getPathUrl()
public Nethgui\Log\LogConsumerInterface
# setLog( Nethgui\Log\LogInterface $log )

Change the log attached to the interface implementor

Change the log attached to the interface implementor

Parameters

$log

Returns

Nethgui\Log\LogConsumerInterface

Api

Implementation of

Nethgui\Log\LogConsumerInterface::setLog()
public Nethgui\Log\LogInterface
# getLog( )

The log attached to the interface implementor

The log attached to the interface implementor

Returns

Nethgui\Log\LogInterface

Api

Implementation of

Nethgui\Log\LogConsumerInterface::getLog()
public mixed
# executeCommand( Nethgui\View\ViewInterface $origin, string $selector, string $name, array $arguments )

Specify an implementation for the given method and arguments.

Specify an implementation for the given method and arguments.

The original view that generated the command and the selector string that identifies the logical target provide more contextual informations.

Parameters

$origin
$selector
$name
$arguments

Returns

mixed

Implementation of

Nethgui\View\CommandReceiverInterface::executeCommand()
public Nethgui\View\LegacyCommandBag
# getCommandList( string $selector = '' )

Get a command list for the given selector

Get a command list for the given selector

The returned command list is ready to execute().

NOTE: only view objects correctly deliver commands to the client-side. Widget commands are delivered to widget objects and executed server-side only.

Deprecated

since version 1.6

Parameters

$selector
Routes the command list to the receiver appointed by this parameter.

Returns

Nethgui\View\LegacyCommandBag

Api

Implementation of

Nethgui\View\ViewInterface::getCommandList()
public boolean
# hasCommandList( $selector = '' )

Check if one or more commands has been added to the selected command list

Check if one or more commands has been added to the selected command list

Deprecated

since version 1.6

Returns

boolean
TRUE, if some command has been added to the list

Api

Implementation of

Nethgui\View\ViewInterface::hasCommandList()
public
# getCommands( )
public Nethgui\View\View
# clearAllCommands( )

Remove all enqueued commands without executing them

Remove all enqueued commands without executing them

Returns

Nethgui\View\View
Constants inherited from Nethgui\View\ViewInterface
TARGET_JSON, TARGET_XHTML
Properties summary
public Nethgui\View\LegacyCommandBag $commands

Provided for backward compatibility

Provided for backward compatibility

Deprecated

since 1.6
#
Nethgui Framework API documentation generated by ApiGen