PHP Class Newscoop\Services\TemplatesService

Show file Open project: sourcefabric/newscoop Class Usage Examples

Protected Properties

Property Type Description
$originalVector
$publicationService PublicationService Publication Service
$smarty CampTemplate
$themesService ThemesServiceInterface Themes Service

Public Methods

Method Description
__construct ( ThemesService $themesService, PublicationService $publicationService )
fetchTemplate ( string $file, array $params = [], integer $lifetime = 1400 ) : string Fetch template with smarty
getSmarty ( ) : Smarty Get current smarty object
renderTemplate ( string $file, array $params = [], integer $lifetime = 1400, boolean $render = true ) : string Render template with smarty (will echo outupt)
setLifetime ( integer $lifetime ) Set template cache lifetime
setVector ( array $vector ) Newscoop caching save cached template file content with special vector parameters.

Private Methods

Method Description
assignParameters ( $params = [] )
preconfigureSmarty ( )
preconfigureVector ( )

Method Details

__construct() public method

public __construct ( ThemesService $themesService, PublicationService $publicationService )
$themesService ThemesService
$publicationService PublicationService

fetchTemplate() public method

Fetch template with smarty
public fetchTemplate ( string $file, array $params = [], integer $lifetime = 1400 ) : string
$file string template file path
$params array array with template parameters
$lifetime integer template cache lifetime (default: 1400 seconds)
return string Template output

getSmarty() public method

Get current smarty object
public getSmarty ( ) : Smarty
return Smarty

renderTemplate() public method

Render template with smarty (will echo outupt)
public renderTemplate ( string $file, array $params = [], integer $lifetime = 1400, boolean $render = true ) : string
$file string template file path
$params array array with template parameters
$lifetime integer template cache lifetime (default: 1400 seconds)
$render boolean render or just fetch template (default: true [render])
return string Template output

setLifetime() public method

Set template cache lifetime
public setLifetime ( integer $lifetime )
$lifetime integer

setVector() public method

By default vector is filled with 6 parameters: * (int) language * (int) publication * (int) issue * (int) section * (int) article * (string) params In this service vector is allways prefilled only with publication and language values. You need to set manualny (if needed) issue, section, article or params keys
public setVector ( array $vector )
$vector array

Property Details

$originalVector protected property

protected $originalVector

$publicationService protected property

Publication Service
protected PublicationService,Newscoop\Services $publicationService
return PublicationService

$smarty protected property

protected CampTemplate $smarty
return CampTemplate

$themesService protected property

Themes Service
protected ThemesServiceInterface $themesService
return ThemesServiceInterface