PHP Class Newscoop\Service\Implementation\ThemeServiceLocalFileSystem

Inheritance: implements Newscoop\Service\IThemeService
Datei anzeigen Open project: sourcefabric/newscoop Class Usage Examples

Public Properties

Property Type Description
$themeConfigFileName string
$themesFolder string

Protected Properties

Property Type Description
$cacheThemeConfigs array
$cacheXMLEmelemt array
$errorHandler Newscoop\Service\IErrorHandler
$id Newscoop\Service\Resource\ResourceId

Public Methods

Method Description
__construct ( ResourceId $id ) Construct the service based on the provided resource id.
findById ( $id )
getById ( $id ) * ---------------------------------------------------------------
getCount ( Search $search = NULL )
getEntities ( Search $search = NULL, $offset, $limit )
getPresentationImages ( Theme $theme ) * ---------------------------------------------------------------
toFullPath ( Theme | string $theme, string $file = '' ) : string Provides the full path for a theme.

Protected Methods

Method Description
escapePath ( string $path ) : string Converts the provided path from the OS specific form (if is the cae) to using just forward slashes.
extractRelativePathFrom ( string $path ) : string Extracts from a provided file path the path where that file is located, attention the path needs to be in the escaped form.
filterThemes ( SearchTheme $search, array $themes ) : array Filters the provided array of themes based on the search.
findAllThemesConfigPaths ( ) : array Finds all paths to the configurations XML files for themes, that are located in the theme folder.
getErrorHandler ( ) : Newscoop\Service\IErrorHandler Provides the error handler.
getNodes ( SimpleXMLElement $node, string $tagName, string $attribute = NULL, $value = '' ) : array Finds all the childrens from the provided node that have the provided tag name
getResourceId ( ) : Newscoop\Services\Resource\ResourceId Provides the resource id.
loadTheme ( SimpleXMLElement $nodeTheme, string $id, string $themeConfig ) : Theme Loads the theme object.
loadThemeByPath ( str $themePath ) : Theme Load the theme from the provided relative path.
loadThemes ( array $themesConfigs ) : array Loads the provided theme configuration files.
loadXML ( string $path ) : SimpleXMLElement Loads the XML content into SimpleXMLElement.
readAttribute ( SimpleXMLElement $node, string $attribute ) : string Convienient method for read an attribute from a node.
sort ( array $array, string $property, $ascending ) : array Sort the array.
trim ( array $array, integer $offset, integer $limit ) : array Trims the array based on the offset and limit.

Method Details

__construct() public method

Construct the service based on the provided resource id.
public __construct ( ResourceId $id )
$id Newscoop\Service\Resource\ResourceId The resource id, not null not empty

escapePath() protected method

Converts the provided path from the OS specific form (if is the cae) to using just forward slashes.
protected escapePath ( string $path ) : string
$path string The path, *(not null not empty).
return string The escaped path.

extractRelativePathFrom() protected method

Extracts from a provided file path the path where that file is located, attention the path needs to be in the escaped form.
protected extractRelativePathFrom ( string $path ) : string
$path string The path from which to extract the relative path, *(not null not empty).
return string The relative path for the provided path, not null.

filterThemes() protected method

Filters the provided array of themes based on the search.
protected filterThemes ( SearchTheme $search, array $themes ) : array
$search Newscoop\Service\Model\SearchTheme The search to filter the themes by, *(not null not empty).
$themes array The array of Theme objects to be filtered, *(not null not empty).
return array The array containing all themes that respect the search.

findAllThemesConfigPaths() protected method

Finds all paths to the configurations XML files for themes, that are located in the theme folder.
protected findAllThemesConfigPaths ( ) : array
return array The array containing as key the id of the theme config and as a value the relative path of the theme configuration XML file in escaped form. The id of a theme is formed based on the publication path with the crec32 applied.

findById() public method

public findById ( $id )

getById() public method

* ---------------------------------------------------------------
public getById ( $id )

getCount() public method

public getCount ( Search $search = NULL )
$search Newscoop\Service\Model\Search\Search

getEntities() public method

public getEntities ( Search $search = NULL, $offset, $limit )
$search Newscoop\Service\Model\Search\Search

getErrorHandler() protected method

Provides the error handler.
protected getErrorHandler ( ) : Newscoop\Service\IErrorHandler
return Newscoop\Service\IErrorHandler The error handler to be used.

getNodes() protected method

Finds all the childrens from the provided node that have the provided tag name
protected getNodes ( SimpleXMLElement $node, string $tagName, string $attribute = NULL, $value = '' ) : array
$node SimpleXMLElement The node in which to search the childrens, not null.
$tagName string The tag name for the childrens to find, not null.
$attribute string Optional attribute name to search the kids by, beside the tag name.
$value Optional but if $attribute is specified than specify also the value of the attribute to find by.
return array an array containing all the found nodes, not null can be empty.

getPresentationImages() public method

* ---------------------------------------------------------------
public getPresentationImages ( Theme $theme )
$theme Newscoop\Entity\Theme

getResourceId() protected method

Provides the resource id.
protected getResourceId ( ) : Newscoop\Services\Resource\ResourceId
return Newscoop\Services\Resource\ResourceId The resource id.

loadTheme() protected method

Loads the theme object.
protected loadTheme ( SimpleXMLElement $nodeTheme, string $id, string $themeConfig ) : Theme
$nodeTheme SimpleXMLElement The node Theme XML element, *(not null not empty).
$id string The id of the loaded Theme, *(not null not empty).
$themeConfig string The path of the Theme XML file in order to extract the theme path, *(not null not empty).
return Newscoop\Entity\Theme The loaded theme object, NULL if there was an issue.

loadThemeByPath() protected method

Load the theme from the provided relative path.
protected loadThemeByPath ( str $themePath ) : Theme
$themePath str The theme relative path.
return Newscoop\Entity\Theme The loaded theme.

loadThemes() protected method

Loads the provided theme configuration files.
protected loadThemes ( array $themesConfigs ) : array
$themesConfigs array The array containing as key the ide of the theme config (index) and as a value the relative path of the theme configuration XML file, *(not null not empty).
return array The array containing all the loaded themes.

loadXML() protected method

Loads the XML content into SimpleXMLElement.
protected loadXML ( string $path ) : SimpleXMLElement
$path string The path to the XML file, *(not null not empty).
return SimpleXMLElement The XML element, NULL if the XML is not valid.

readAttribute() protected method

This method will throw an exception in case the attribute is not specified.
protected readAttribute ( SimpleXMLElement $node, string $attribute ) : string
$node SimpleXMLElement The node to read from, *(not null not empty).
$attribute string The attribute name, *(not null not empty).
return string The attribute value, not null.

sort() protected method

Sort the array.
protected sort ( array $array, string $property, $ascending ) : array
$array array The array of elements to be sorted.
$property string The method name that provides the sorting key.
return array The sorted array.

toFullPath() public method

Provides the full path for a theme.
public toFullPath ( Theme | string $theme, string $file = '' ) : string
$theme Newscoop\Entity\Theme | string The Theme or path, *(not null not empty).
$file string Optional a file to be appended to the path.
return string The full path to the theme and file if is the case.

trim() protected method

Trims the array based on the offset and limit.
protected trim ( array $array, integer $offset, integer $limit ) : array
$array array The array to be trimed, not null.
$offset integer The offset.
$limit integer The limit.
return array The trimed array.

Property Details

$cacheThemeConfigs protected_oe property

protected array $cacheThemeConfigs
return array

$cacheXMLEmelemt protected_oe property

protected array $cacheXMLEmelemt
return array

$errorHandler protected_oe property

protected IErrorHandler,Newscoop\Service $errorHandler
return Newscoop\Service\IErrorHandler

$id protected_oe property

protected ResourceId,Newscoop\Service\Resource $id
return Newscoop\Service\Resource\ResourceId

$themeConfigFileName public_oe property

public string $themeConfigFileName
return string

$themesFolder public_oe property

public string $themesFolder
return string