Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
AbstractHelper Class Reference

Base class for navigational helpers. More...

Public Member Functions

 __call ($method, array $arguments=[])
 Magic overload: Proxy calls to the navigation container.
 
 __toString ()
 Magic overload: Proxy to render().
 
 accept (AbstractPage $page, $recursive=true)
 Determines whether a page should be accepted when iterating.
 
 setAcl (Acl\AclInterface $acl=null)
 Sets ACL to use when iterating pages.
 
 getAcl ()
 Returns ACL or null if it isn't set using setAcl() or setDefaultAcl().
 
 hasAcl ()
 Checks if the helper has an ACL instance.
 
 setEventManager (EventManagerInterface $events)
 Set the event manager.
 
 getEventManager ()
 Get the event manager, if present.
 
 setContainer ($container=null)
 Sets navigation container the helper operates on by default.
 
 getContainer ()
 Returns the navigation container helper operates on by default.
 
 hasContainer ()
 Checks if the helper has a container.
 
 setIndent ($indent)
 Set the indentation string for using in render(), optionally a number of spaces to indent with.
 
 getIndent ()
 Returns indentation.
 
 setMaxDepth ($maxDepth=null)
 Sets the maximum depth a page can have to be included when rendering.
 
 getMaxDepth ()
 Returns maximum depth a page can have to be included when rendering.
 
 setMinDepth ($minDepth=null)
 Sets the minimum depth a page must have to be included when rendering.
 
 getMinDepth ()
 Returns minimum depth a page must have to be included when rendering.
 
 setRenderInvisible ($renderInvisible=true)
 Render invisible items?
 
 getRenderInvisible ()
 Return renderInvisible flag.
 
 setRole ($role=null)
 Sets ACL role(s) to use when iterating pages.
 
 getRole ()
 Returns ACL role to use when iterating pages, or null if it isn't set using setRole() or setDefaultRole().
 
 hasRole ()
 Checks if the helper has an ACL role.
 
 setServiceLocator (ContainerInterface $serviceLocator)
 Set the service locator.
 
 getServiceLocator ()
 Get the service locator.
 
 setUseAcl ($useAcl=true)
 Sets whether ACL should be used.
 
 getUseAcl ()
 Returns whether ACL should be used.
 
- Public Member Functions inherited from AbstractHtmlElement
 getClosingBracket ()
 Get the tag closing bracket.
 
- Public Member Functions inherited from AbstractHelper
 setView (Renderer $view)
 Set the View object.
 
 getView ()
 Get the view object.
 
- Public Member Functions inherited from HelperInterface
 render ($container=null)
 Renders helper.
 

Static Public Member Functions

static setDefaultAcl (Acl\AclInterface $acl=null)
 Sets default ACL to use if another ACL is not explicitly set.
 
static setDefaultRole ($role=null)
 Sets default ACL role(s) to use when iterating pages if not explicitly set later with setRole().
 

Protected Member Functions

 parseContainer (&$container=null)
 Verifies container and eventually fetches it from service locator if it is a string.
 
 isAllowed ($params)
 Determines whether a page should be allowed given certain parameters.
 
 getWhitespace ($indent)
 Retrieve whitespace representation of $indent.
 
 htmlAttribs ($attribs)
 Converts an associative array to a string of tag attributes.
 
 translate ($message, $textDomain=null)
 Translate a message (for label, title, …)
 
 normalizeId ($value)
 Normalize an ID.
 
 setDefaultListeners ()
 Attaches default ACL listeners, if ACLs are in use.
 
- Protected Member Functions inherited from AbstractHtmlElement
 isXhtml ()
 Is doctype XHTML?
 
 htmlAttribs ($attribs)
 Converts an associative array to a string of tag attributes.
 
 normalizeId ($value)
 Normalize an ID.
 

Protected Attributes

 $events
 
 $container
 
 $minDepth
 
 $maxDepth
 
 $indent = ''
 
 $acl
 
 $renderInvisible = false
 
 $role
 
 $serviceLocator
 
 $useAcl = true
 
- Protected Attributes inherited from AbstractHtmlElement
 $closingBracket = null
 
- Protected Attributes inherited from AbstractHelper
 $view = null
 

Static Protected Attributes

static $defaultAcl
 
static $defaultRole
 

Additional Inherited Members

- Public Attributes inherited from AbstractHtmlElement
const EOL = PHP_EOL
 EOL character.
 

Detailed Description

Base class for navigational helpers.

Duck-types against Zend.

Member Function Documentation

__call (   $method,
array  $arguments = [] 
)

Magic overload: Proxy calls to the navigation container.

Parameters
string$methodmethod name in container
array$argumentsrguments to pass
Returns
mixed
Exceptions
Navigation\Exception\ExceptionInterface
__toString ( )

Magic overload: Proxy to render().

This method will trigger an E_USER_ERROR if rendering the helper causes an exception to be thrown.

Implements HelperInterface::__toString().

Returns
string

Implements HelperInterface.

accept ( AbstractPage  $page,
  $recursive = true 
)

Determines whether a page should be accepted when iterating.

Default listener may be 'overridden' by attaching listener to 'isAllowed' method. Listener must be 'short circuited' if overriding default ACL listener.

Rules:

  • If a page is not visible it is not accepted, unless RenderInvisible has been set to true
  • If $useAcl is true (default is true):
    • Page is accepted if listener returns true, otherwise false
  • If page is accepted and $recursive is true, the page will not be accepted if it is the descendant of a non-accepted page
Parameters
AbstractPage$pagepage to check
bool$recursive[optional] if true, page will not be accepted if it is the descendant of a page that is not accepted. Default is true
Returns
bool Whether page should be accepted
getAcl ( )

Returns ACL or null if it isn't set using setAcl() or setDefaultAcl().

Implements HelperInterface::getAcl().

Returns
Acl|null ACL object or null

Implements HelperInterface.

getContainer ( )

Returns the navigation container helper operates on by default.

Implements HelperInterface::getContainer().

If no container is set, a new container will be instantiated and stored in the helper.

Returns
Navigation navigation container

Implements HelperInterface.

getEventManager ( )

Get the event manager, if present.

Internally, the helper will lazy-load an EM instance the first time it requires one, but ideally it should be injected during instantiation.

Returns
null|EventManagerInterface

Implements EventsCapableInterface.

getIndent ( )

Returns indentation.

Returns
string
getMaxDepth ( )

Returns maximum depth a page can have to be included when rendering.

Returns
int|null
getMinDepth ( )

Returns minimum depth a page must have to be included when rendering.

Returns
int|null
getRenderInvisible ( )

Return renderInvisible flag.

Returns
bool

Implements HelperInterface.

getRole ( )

Returns ACL role to use when iterating pages, or null if it isn't set using setRole() or setDefaultRole().

Implements HelperInterface::getRole().

Returns
string|Acl|null

Implements HelperInterface.

getServiceLocator ( )

Get the service locator.

Used internally to pull named navigation containers to render.

Returns
ContainerInterface
getUseAcl ( )

Returns whether ACL should be used.

Implements HelperInterface::getUseAcl().

Returns
bool

Implements HelperInterface.

getWhitespace (   $indent)
protected

Retrieve whitespace representation of $indent.

Parameters
int | string$indent
Returns
string
hasAcl ( )

Checks if the helper has an ACL instance.

Implements HelperInterface::hasAcl().

Returns
bool

Implements HelperInterface.

hasContainer ( )

Checks if the helper has a container.

Implements HelperInterface::hasContainer().

Returns
bool

Implements HelperInterface.

hasRole ( )

Checks if the helper has an ACL role.

Implements HelperInterface::hasRole().

Returns
bool

Implements HelperInterface.

htmlAttribs (   $attribs)
protected

Converts an associative array to a string of tag attributes.

Overloads ::htmlAttribs().

Parameters
array$attribsan array where each key-value pair is converted to an attribute name and value
Returns
string
isAllowed (   $params)
protected

Determines whether a page should be allowed given certain parameters.

Parameters
array$params
Returns
bool
normalizeId (   $value)
protected

Normalize an ID.

Overrides ::normalizeId().

Parameters
string$value
Returns
string
parseContainer ( $container = null)
protected

Verifies container and eventually fetches it from service locator if it is a string.

Parameters
Navigation\AbstractContainer | string | null$container
Exceptions
Exception\InvalidArgumentException

Load the navigation container from the root service locator

setAcl ( Acl\AclInterface  $acl = null)

Sets ACL to use when iterating pages.

Implements HelperInterface::setAcl().

Parameters
Acl\AclInterface$aclACL object.
Returns
AbstractHelper

Implements HelperInterface.

setContainer (   $container = null)

Sets navigation container the helper operates on by default.

Implements HelperInterface::setContainer().

Parameters
string | Navigation\AbstractContainer$containerDefault is null, meaning container will be reset.
Returns
AbstractHelper

Implements HelperInterface.

static setDefaultAcl ( Acl\AclInterface  $acl = null)
static

Sets default ACL to use if another ACL is not explicitly set.

Parameters
Acl\AclInterface$acl[optional] ACL object. Default is null, which sets no ACL object.
Returns
void
setDefaultListeners ( )
protected

Attaches default ACL listeners, if ACLs are in use.

static setDefaultRole (   $role = null)
static

Sets default ACL role(s) to use when iterating pages if not explicitly set later with setRole().

Parameters
mixed$role[optional] role to set. Expects null, string, or an instance of Acl. Default is null, which sets no default role.
Returns
void
Exceptions
Exception\InvalidArgumentExceptionif role is invalid
setEventManager ( EventManagerInterface  $events)

Set the event manager.

Parameters
EventManagerInterface$events
Returns
AbstractHelper

Implements EventManagerAwareInterface.

setIndent (   $indent)

Set the indentation string for using in render(), optionally a number of spaces to indent with.

Parameters
string | int$indent
Returns
AbstractHelper
setMaxDepth (   $maxDepth = null)

Sets the maximum depth a page can have to be included when rendering.

Parameters
int$maxDepthDefault is null, which sets no maximum depth.
Returns
AbstractHelper
setMinDepth (   $minDepth = null)

Sets the minimum depth a page must have to be included when rendering.

Parameters
int$minDepthDefault is null, which sets no minimum depth.
Returns
AbstractHelper
setRenderInvisible (   $renderInvisible = true)

Render invisible items?

Parameters
bool$renderInvisible
Returns
AbstractHelper

Implements HelperInterface.

setRole (   $role = null)

Sets ACL role(s) to use when iterating pages.

Implements HelperInterface::setRole().

Parameters
mixed$role[optional] role to set. Expects a string, an instance of type Acl, or null. Default is null, which will set no role.
Returns
AbstractHelper
Exceptions
Exception\InvalidArgumentException

Implements HelperInterface.

setServiceLocator ( ContainerInterface  $serviceLocator)

Set the service locator.

Used internally to pull named navigation containers to render.

Parameters
ContainerInterface$serviceLocator
Returns
AbstractHelper
setUseAcl (   $useAcl = true)

Sets whether ACL should be used.

Implements HelperInterface::setUseAcl().

Parameters
bool$useAcl
Returns
AbstractHelper

Implements HelperInterface.

translate (   $message,
  $textDomain = null 
)
protected

Translate a message (for label, title, …)

Parameters
string$messageID of the message to translate
string$textDomainText domain (category name for the translations)
Returns
string Translated message

Member Data Documentation

$acl
protected
$container
protected
$defaultAcl
staticprotected
$defaultRole
staticprotected
$events
protected
$indent = ''
protected
$maxDepth
protected
$minDepth
protected
$renderInvisible = false
protected
$role
protected
$serviceLocator
protected
$useAcl = true
protected