PHP Class FluidTYPO3\Vhs\Asset

Class to create Assets in PHP. ### Examples: $asset = $this->objectManager->get('FluidTYPO3\\Vhs\\Asset'); OR you can use the static factory method which works anywhere including outside of Extbase. $asset = \FluidTYPO3\Vhs\Asset::getInstance(); $asset->setPath('fileadmin/test.js')->setStandalone(TRUE)->finalize(); Or simply: $this->objectManager->get('FluidTYPO3\\Vhs\\Asset')->setPath('...')->finalize(); And you can create clean instances: Depending on how you need to access the Asset afterwards, you will want wo switch between these methods. Or if you have all settings in an array (with members named according to the properties on this class: \FluidTYPO3\Vhs\Asset::createFromSettings($settings)->finalize(); Finally, if your Asset is file based, VHS can perform a few detections to set initial attributes like standalone, external (if file contains protocol), type (based on extension) and name (base name of file). \FluidTYPO3\Vhs\Asset::createFromFile($filePathAndFilename); \FluidTYPO3\Vhs\Asset::createFromUrl($urlToExternalFile); You can chain all setters on the class before finally calling finalize() to register the Asset (you can still modify the Asset afterwards, but an Asset that has not been finalize()'ed will never show up or be processed - which is a lot friendlier than requiring you to use remove() on unwanted Assets). > Note: the "createFrom..." suite of methods automatically calls finalize() > on your Asset just before returning it. You can of course keep modifying > the instance after it is returned - but when using a "createFrom"... method > VHS assumes you always want your Asset included in the output.
Inheritance: implements FluidTYPO3\Vhs\ViewHelpers\Asset\AssetInterface
Show file Open project: fluidtypo3/vhs Class Usage Examples

Protected Properties

Property Type Description
$configurationManager TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
$content string
$dependencies array
$external boolean
$fluid boolean
$movable boolean
$name string
$namedChunks boolean
$path string
$removed boolean
$rewrite boolean
$settings array
$standalone boolean
$type string
$variables array

Public Methods

Method Description
assertAddNameCommentWithChunk ( ) : boolean Returns TRUE if settings specify that the name of each Asset should be placed above the built content when placed in merged Asset cache files.
assertAllowedInFooter ( ) : boolean
assertDebugEnabled ( ) : boolean Returns TRUE if the current Asset should be debugged as commanded by settings in TypoScript an/ord ViewHelper attributes.
assertFluidEnabled ( ) : boolean Returns TRUE of settings specify that the source of this Asset should be rendered as if it were a Fluid template, using variables from the "arguments" attribute
assertHasBeenRemoved ( ) : boolean
build ( ) : mixed Build this asset. Override this method in the specific implementation of an Asset in order to:
createFromContent ( string $content ) : Asset
createFromFile ( string $filePathAndFilename ) : Asset
createFromSettings ( array $settings ) : Asset
createFromUrl ( string $url ) : Asset
finalize ( ) : Asset
getAssetSettings ( ) : array
getContent ( ) : string
getDebugInformation ( ) : array Allows public access to debug this particular Asset instance later, when including the Asset in the page.
getDependencies ( ) : array
getExternal ( ) : boolean
getFluid ( ) : boolean
getInstance ( ) : Asset
getMovable ( ) : boolean
getName ( ) : string
getNamedChunks ( ) : boolean
getPath ( ) : string
getRemoved ( ) : boolean
getRewrite ( ) : boolean
getSettings ( ) : array Returns the settings used by this particular Asset during inclusion. Public access allows later inspection of the TypoScript values which were applied to the Asset.
getStandalone ( ) : boolean
getType ( ) : string
getVariables ( ) : array
injectConfigurationManager ( TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager ) : void
remove ( ) : Asset
render ( ) : mixed Render method
setContent ( string $content ) : Asset
setDependencies ( array $dependencies ) : Asset
setExternal ( boolean $external ) : Asset
setFluid ( boolean $fluid ) : Asset
setMovable ( boolean $movable )
setName ( string $name ) : Asset
setNamedChunks ( boolean $namedChunks ) : Asset
setPath ( string $path ) : Asset
setRemoved ( boolean $removed ) : Asset
setRewrite ( boolean $rewrite ) : Asset
setSettings ( array $settings ) : Asset
setStandalone ( boolean $standalone ) : Asset
setType ( string $type ) : Asset
setVariables ( array $variables ) : Asset

Method Details

assertAddNameCommentWithChunk() public method

Returns TRUE if settings specify that the name of each Asset should be placed above the built content when placed in merged Asset cache files.

assertAllowedInFooter() public method

public assertAllowedInFooter ( ) : boolean
return boolean

assertDebugEnabled() public method

Returns TRUE if the current Asset should be debugged as commanded by settings in TypoScript an/ord ViewHelper attributes.
public assertDebugEnabled ( ) : boolean
return boolean

assertFluidEnabled() public method

Returns TRUE of settings specify that the source of this Asset should be rendered as if it were a Fluid template, using variables from the "arguments" attribute
public assertFluidEnabled ( ) : boolean
return boolean

assertHasBeenRemoved() public method

public assertHasBeenRemoved ( ) : boolean
return boolean

build() public method

- if necessary compile the Asset (LESS, SASS, CoffeeScript etc) - make a final rendering decision based on arguments Note that within this function the ViewHelper and TemplateVariable Containers are not dependable, you cannot use the ControllerContext and RenderingContext and you should therefore also never call renderChildren from within this function. Anything else goes; CLI commands to build, caching implementations - you name it.
public build ( ) : mixed
return mixed

createFromContent() public static method

public static createFromContent ( string $content ) : Asset
$content string
return Asset

createFromFile() public static method

public static createFromFile ( string $filePathAndFilename ) : Asset
$filePathAndFilename string
return Asset

createFromSettings() public static method

public static createFromSettings ( array $settings ) : Asset
$settings array
return Asset

createFromUrl() public static method

public static createFromUrl ( string $url ) : Asset
$url string
return Asset

finalize() public method

public finalize ( ) : Asset
return Asset

getAssetSettings() public method

public getAssetSettings ( ) : array
return array

getContent() public method

public getContent ( ) : string
return string

getDebugInformation() public method

Allows public access to debug this particular Asset instance later, when including the Asset in the page.
public getDebugInformation ( ) : array
return array

getDependencies() public method

public getDependencies ( ) : array
return array

getExternal() public method

public getExternal ( ) : boolean
return boolean

getFluid() public method

public getFluid ( ) : boolean
return boolean

getInstance() public static method

public static getInstance ( ) : Asset
return Asset

getMovable() public method

public getMovable ( ) : boolean
return boolean

getName() public method

public getName ( ) : string
return string

getNamedChunks() public method

public getNamedChunks ( ) : boolean
return boolean

getPath() public method

public getPath ( ) : string
return string

getRemoved() public method

public getRemoved ( ) : boolean
return boolean

getRewrite() public method

public getRewrite ( ) : boolean
return boolean

getSettings() public method

Returns the settings used by this particular Asset during inclusion. Public access allows later inspection of the TypoScript values which were applied to the Asset.
public getSettings ( ) : array
return array

getStandalone() public method

public getStandalone ( ) : boolean
return boolean

getType() public method

public getType ( ) : string
return string

getVariables() public method

public getVariables ( ) : array
return array

injectConfigurationManager() public method

public injectConfigurationManager ( TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager ) : void
$configurationManager TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
return void

remove() public method

public remove ( ) : Asset
return Asset

render() public method

Render method
public render ( ) : mixed
return mixed

setContent() public method

public setContent ( string $content ) : Asset
$content string
return Asset

setDependencies() public method

public setDependencies ( array $dependencies ) : Asset
$dependencies array
return Asset

setExternal() public method

public setExternal ( boolean $external ) : Asset
$external boolean
return Asset

setFluid() public method

public setFluid ( boolean $fluid ) : Asset
$fluid boolean
return Asset

setMovable() public method

public setMovable ( boolean $movable )
$movable boolean

setName() public method

public setName ( string $name ) : Asset
$name string
return Asset

setNamedChunks() public method

public setNamedChunks ( boolean $namedChunks ) : Asset
$namedChunks boolean
return Asset

setPath() public method

public setPath ( string $path ) : Asset
$path string
return Asset

setRemoved() public method

public setRemoved ( boolean $removed ) : Asset
$removed boolean
return Asset

setRewrite() public method

public setRewrite ( boolean $rewrite ) : Asset
$rewrite boolean
return Asset

setSettings() public method

public setSettings ( array $settings ) : Asset
$settings array
return Asset

setStandalone() public method

public setStandalone ( boolean $standalone ) : Asset
$standalone boolean
return Asset

setType() public method

public setType ( string $type ) : Asset
$type string
return Asset

setVariables() public method

public setVariables ( array $variables ) : Asset
$variables array
return Asset

Property Details

$configurationManager protected property

protected ConfigurationManagerInterface,TYPO3\CMS\Extbase\Configuration $configurationManager
return TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface

$content protected property

protected string $content
return string

$dependencies protected property

protected array $dependencies
return array

$external protected property

protected bool $external
return boolean

$fluid protected property

protected bool $fluid
return boolean

$movable protected property

protected bool $movable
return boolean

$name protected property

protected string $name
return string

$namedChunks protected property

protected bool $namedChunks
return boolean

$path protected property

protected string $path
return string

$removed protected property

protected bool $removed
return boolean

$rewrite protected property

protected bool $rewrite
return boolean

$settings protected property

protected array $settings
return array

$standalone protected property

protected bool $standalone
return boolean

$type protected property

protected string $type
return string

$variables protected property

protected array $variables
return array