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

Helper for setting and retrieving script elements for HTML head section. More...

Public Member Functions

 __construct ()
 Constructor.
 
 __invoke ($mode=self::FILE, $spec=null, $placement= 'APPEND', array $attrs=[], $type= 'text/javascript')
 Return headScript object.
 
 __call ($method, $args)
 Overload method access.
 
 toString ($indent=null)
 Retrieve string representation.
 
 captureStart ($captureType=Placeholder\Container\AbstractContainer::APPEND, $type= 'text/javascript', $attrs=[])
 Start capture action.
 
 captureEnd ()
 End capture action and store.
 
 createData ($type, array $attributes, $content=null)
 Create data item containing all necessary components of script.
 
 itemToString ($item, $indent, $escapeStart, $escapeEnd)
 Create script HTML.
 
 append ($value)
 Override append.
 
 prepend ($value)
 Override prepend.
 
 set ($value)
 Override set.
 
 offsetSet ($index, $value)
 Override offsetSet.
 
 setAllowArbitraryAttributes ($flag)
 Set flag indicating if arbitrary attributes are allowed.
 
 arbitraryAttributesAllowed ()
 Are arbitrary attributes allowed?
 
- Public Member Functions inherited from AbstractStandalone
 __construct ()
 Constructor.
 
 __call ($method, $args)
 Overload.
 
 __set ($key, $value)
 Overloading: set property value.
 
 __get ($key)
 Overloading: retrieve property.
 
 __isset ($key)
 Overloading: check if property is set.
 
 __unset ($key)
 Overloading: unset property.
 
 __toString ()
 Cast to string representation.
 
 toString ()
 String representation.
 
 setAutoEscape ($autoEscape=true)
 Set whether or not auto escaping should be used.
 
 getAutoEscape ()
 Return whether autoEscaping is enabled or disabled.
 
 setContainer (AbstractContainer $container)
 Set container on which to operate.
 
 getContainer ()
 Retrieve placeholder container.
 
 deleteContainer ()
 Delete a container.
 
 setContainerClass ($name)
 Set the container class to use.
 
 getContainerClass ()
 Retrieve the container class.
 
 setEscaper (Escaper $escaper)
 Set Escaper instance.
 
 getEscaper ($enc= 'UTF-8')
 Get Escaper instance.
 
 count ()
 Countable.
 
 offsetExists ($offset)
 ArrayAccess: offsetExists.
 
 offsetGet ($offset)
 ArrayAccess: offsetGet.
 
 offsetSet ($offset, $value)
 ArrayAccess: offsetSet.
 
 offsetUnset ($offset)
 ArrayAccess: offsetUnset.
 
 getIterator ()
 IteratorAggregate: get Iterator.
 
- Public Member Functions inherited from AbstractHelper
 setView (Renderer $view)
 Set the View object.
 
 getView ()
 Get the view object.
 

Public Attributes

const FILE = 'FILE'
 Script type constants.
 
const SCRIPT = 'SCRIPT'
 
 $useCdata = false
 

Protected Member Functions

 isDuplicate ($file)
 Is the file specified a duplicate?
 
 isValid ($value)
 Is the script provided valid?
 
- Protected Member Functions inherited from AbstractStandalone
 escape ($string)
 Escape a string.
 

Protected Attributes

 $regKey = 'Zend_View_Helper_HeadScript'
 
 $arbitraryAttributes = false
 
 $captureLock
 
 $captureScriptType
 
 $captureScriptAttrs = null
 
 $captureType
 
 $optionalAttributes
 
 $requiredAttributes = ['type']
 
- Protected Attributes inherited from AbstractStandalone
 $autoEscape = true
 
 $container
 
 $containerClass = 'Zend\View\Helper\Placeholder\Container'
 
 $escapers = []
 
- Protected Attributes inherited from AbstractHelper
 $view = null
 

Detailed Description

Helper for setting and retrieving script elements for HTML head section.

Allows the following method calls: HeadScript appendFile($src, $type = 'text/javascript', $attrs = array()) HeadScript offsetSetFile($index, $src, $type = 'text/javascript', $attrs = array()) HeadScript prependFile($src, $type = 'text/javascript', $attrs = array()) HeadScript setFile($src, $type = 'text/javascript', $attrs = array()) HeadScript appendScript($script, $type = 'text/javascript', $attrs = array()) HeadScript offsetSetScript($index, $src, $type = 'text/javascript', $attrs = array()) HeadScript prependScript($script, $type = 'text/javascript', $attrs = array()) HeadScript setScript($script, $type = 'text/javascript', $attrs = array())

Constructor & Destructor Documentation

__construct ( )

Constructor.

Set separator to PHP_EOL.

Member Function Documentation

__call (   $method,
  $args 
)

Overload method access.

Parameters
string$methodMethod to call
array$argsArguments of method
Exceptions
Exception\BadMethodCallExceptionif too few arguments or invalid method
Returns
HeadScript
__invoke (   $mode = self::FILE,
  $spec = null,
  $placement = 'APPEND',
array  $attrs = [],
  $type = 'text/javascript' 
)

Return headScript object.

Returns headScript helper object; optionally, allows specifying a script or script file to include.

Parameters
string$modeScript or file
string$specScript/url
string$placementAppend, prepend, or set
array$attrsArray of script attributes
string$typeScript type and/or array of script attributes
Returns
HeadScript
append (   $value)

Override append.

Parameters
string$valueAppend script or file
Exceptions
Exception\InvalidArgumentException
Returns
void
arbitraryAttributesAllowed ( )

Are arbitrary attributes allowed?

Returns
bool
captureEnd ( )

End capture action and store.

Returns
void
captureStart (   $captureType = Placeholder\Container\AbstractContainer::APPEND,
  $type = 'text/javascript',
  $attrs = [] 
)

Start capture action.

Parameters
mixed$captureTypeType of capture
string$typeType of script
array$attrsAttributes of capture
Exceptions
Exception\RuntimeException
Returns
void
createData (   $type,
array  $attributes,
  $content = null 
)

Create data item containing all necessary components of script.

Parameters
string$typeType of data
array$attributesAttributes of data
string$contentContent of data
Returns
stdClass
isDuplicate (   $file)
protected

Is the file specified a duplicate?

Parameters
string$fileName of file to check
Returns
bool
isValid (   $value)
protected

Is the script provided valid?

Parameters
mixed$valueIs the given script valid?
Returns
bool
itemToString (   $item,
  $indent,
  $escapeStart,
  $escapeEnd 
)

Create script HTML.

Parameters
mixed$itemItem to convert
string$indentString to add before the item
string$escapeStartStarting sequence
string$escapeEndEnding sequence
Returns
string
offsetSet (   $index,
  $value 
)

Override offsetSet.

Parameters
string | int$indexSet script of file offset
mixed$value
Exceptions
Exception\InvalidArgumentException
Returns
void
prepend (   $value)

Override prepend.

Parameters
string$valuePrepend script or file
Exceptions
Exception\InvalidArgumentException
Returns
void
set (   $value)

Override set.

Parameters
string$valueSet script or file
Exceptions
Exception\InvalidArgumentException
Returns
void
setAllowArbitraryAttributes (   $flag)

Set flag indicating if arbitrary attributes are allowed.

Parameters
bool$flagSet flag
Returns
HeadScript
toString (   $indent = null)

Retrieve string representation.

Parameters
string | int$indentAmount of whitespaces or string to use for indention
Returns
string

Member Data Documentation

$arbitraryAttributes = false
protected
$captureLock
protected
$captureScriptAttrs = null
protected
$captureScriptType
protected
$captureType
protected
$optionalAttributes
protected
Initial value:
= [
'charset',
'crossorigin',
'defer',
'async',
'language',
'src',
]
$regKey = 'Zend_View_Helper_HeadScript'
protected
$requiredAttributes = ['type']
protected
$useCdata = false
const FILE = 'FILE'

Script type constants.

string

const SCRIPT = 'SCRIPT'