CoreSite
extends AbstractSite
in package
The primary site manager
Tags
Table of Contents
Constants
- DYNAMIC_REPO_CONFIG_FILE = "dynamic.db.repositories"
- SITE_PAGES_CONFIG_FILE = "site.pages"
Properties
- $cachedDataRepositories : array<string|int, DataRepository>
- $cachedHelpers : array<string|int, AbstractHelper>
- $currentPage : SitePage
- $sanitizedInputData : array<string|int, string>
- $systemMessages : array<string|int, SystemMessage>
- $configs : array<string, array<string|int, mixed>>
- $globalUser : User
- $pages : array<string|int, SitePage>
- $redirectUrl : string
- $siteConfig : array<string|int, mixed>
- $viewRenderer : ViewRenderer
Methods
- __construct() : mixed
- Constructs an instance of CoreSite
- addSystemError() : void
- Adds an error message to the systemMessages array
- addSystemMessage() : void
- Push a new message string to the Site's system messages
- generateSanitizedInputData() : void
- Generate safe input data from GET/POST/REQUEST Restricts basic repo actions (insert,remove,update) to POST Override this method to restrict additional app specific actions
- getAppConfiguration() : array<string|int, mixed>
- Provides a single instance of the global app configuration to all extenders of CoreObject
- getControllerClass() : string|null
- Provides a fully namespaced Pipit\Interfaces\Controller class name based on a Controller string name Ex. The string 'Widgets' will result in a Controller class name of NAMESPACE_APP\\Classes\\Controllers\\(WidgetsController,WidgetsAdminController)
- getCurrentPage() : SitePage
- Gets the currently requested page
- getDataRepository() : DataRepository|null
- Provides a unified source for DataRepository singletons in response to requests for a DataRepository
- getGlobalUser() : User
- Get a representation of the application user associated with a request.
- getHelper() : object|null
- Fetch a Helper from the cache by its name
- getLogger() : Logger
- Provides a single instance of a configured Logger to all extenders of CoreObject
- getPages() : array<string|int, SitePage>
- Get the pages defined for the Site.
- getSanitizedInputData() : array<string|int, mixed>
- Provide a sanitized and secured version of user input data (POST,GET,COOKIE,etc) to components All components should access user input data exclusively through this method.
- getSiteConfig() : array<string|int, mixed>
- Returns the site configuration
- getSystemMessages() : array<string|int, SystemMessage>
- Get the Site's SystemMessages
- getViewRenderer() : ViewRenderer
- Get the ViewRenderer. Components like Controllers can access this method to configure the set ViewRenderer.
- hasRedirectUrl() : bool
- redirect() : void
- setCurrentPage() : void
- Sets the currently requested page
- setRedirectUrl() : void
- Define a redirect URL.
- setViewRenderer() : void
- Set the ViewRenderer.
- addCachedDataRepository() : void
- Adds a new DataRepository to the list of previously requested DataRepositories
- addCachedHelper() : void
- Adds a Helper instance to the cache
- configurationFileExists() : bool
- Checks for the existence of a file with the given filename
- getCachedDataRepository() : DataRepository|null
- Fetch a DataRepository from the cache by its name
- getCachedHelper() : AbstractHelper|null
- getConfigurationFromFileName() : array<string|int, mixed>
- Retrieves a config array by its corresponding filename
- setGlobalUser() : void
- Set a representation of the application user associated with a request.
- setPages() : void
- Set the pages for the Site.
- setSiteConfig() : void
- Sets the site configuration
- setUser() : void
- Associates the session User with CoreSite
- loadConfigurationFile() : void
- Loads and parses a php ini file into an array keyed by ini sections
Constants
DYNAMIC_REPO_CONFIG_FILE
private
mixed
DYNAMIC_REPO_CONFIG_FILE
= "dynamic.db.repositories"
SITE_PAGES_CONFIG_FILE
private
mixed
SITE_PAGES_CONFIG_FILE
= "site.pages"
Properties
$cachedDataRepositories
protected
array<string|int, DataRepository>
$cachedDataRepositories
= array()
A store of DataRepositories to provide (singletons) to requestors
$cachedHelpers
protected
array<string|int, AbstractHelper>
$cachedHelpers
= array()
A store of Helpers to provide (singletons) to requestors
$currentPage
protected
SitePage
$currentPage
The currently requested SitePage
$sanitizedInputData
protected
array<string|int, string>
$sanitizedInputData
HTTP Request (GET, POST, etc..) data.
$systemMessages
protected
array<string|int, SystemMessage>
$systemMessages
An array of SystemMessage
$configs
private
array<string, array<string|int, mixed>>
$configs
= []
An array of configuration arrays
$globalUser
private
User
$globalUser
An array containing data about the logged in user
$pages
private
array<string|int, SitePage>
$pages
An array of SitePage
$redirectUrl
private
string
$redirectUrl
= null
A url to be redirected to
$siteConfig
private
array<string|int, mixed>
$siteConfig
An array containing the site configuration
$viewRenderer
private
ViewRenderer
$viewRenderer
A ViewRenderer implementation
Methods
__construct()
Constructs an instance of CoreSite
public
__construct(array<string|int, mixed> &$siteConfig) : mixed
Parameters
- $siteConfig : array<string|int, mixed>
-
A reference to the global site configuration
addSystemError()
Adds an error message to the systemMessages array
public
addSystemError(string $message) : void
Parameters
- $message : string
-
The error message
addSystemMessage()
Push a new message string to the Site's system messages
public
addSystemMessage(mixed $message[, mixed $type = "info" ]) : void
Parameters
- $message : mixed
-
The message
- $type : mixed = "info"
-
The type of the message
generateSanitizedInputData()
Generate safe input data from GET/POST/REQUEST Restricts basic repo actions (insert,remove,update) to POST Override this method to restrict additional app specific actions
public
generateSanitizedInputData() : void
getAppConfiguration()
Provides a single instance of the global app configuration to all extenders of CoreObject
public
getAppConfiguration() : array<string|int, mixed>
Return values
array<string|int, mixed>getControllerClass()
Provides a fully namespaced Pipit\Interfaces\Controller class name based on a Controller string name Ex. The string 'Widgets' will result in a Controller class name of NAMESPACE_APP\\Classes\\Controllers\\(WidgetsController,WidgetsAdminController)
public
getControllerClass(string $controllerName) : string|null
If no controller is found for the given controller name, the method will attempt to fall back to either DefaultController or DefaultAdminController provided by client
Parameters
- $controllerName : string
-
The name of the desired controller
Return values
string|nullgetCurrentPage()
Gets the currently requested page
public
getCurrentPage() : SitePage
Return values
SitePage —The currently requested SitePage
getDataRepository()
Provides a unified source for DataRepository singletons in response to requests for a DataRepository
public
getDataRepository(string $repositoryName) : DataRepository|null
Parameters
- $repositoryName : string
-
The name of the desired DataRepository
Return values
DataRepository|null —The resulting DataRepository if found, null otherwise
getGlobalUser()
Get a representation of the application user associated with a request.
public
getGlobalUser() : User
Return values
UsergetHelper()
Fetch a Helper from the cache by its name
public
getHelper(string $helperName) : object|null
Parameters
- $helperName : string
-
The name of the desired Helper
Return values
object|nullgetLogger()
Provides a single instance of a configured Logger to all extenders of CoreObject
public
getLogger() : Logger
Return values
LoggergetPages()
Get the pages defined for the Site.
public
getPages() : array<string|int, SitePage>
Return values
array<string|int, SitePage>getSanitizedInputData()
Provide a sanitized and secured version of user input data (POST,GET,COOKIE,etc) to components All components should access user input data exclusively through this method.
public
getSanitizedInputData() : array<string|int, mixed>
Return values
array<string|int, mixed>getSiteConfig()
Returns the site configuration
public
getSiteConfig() : array<string|int, mixed>
Return values
array<string|int, mixed> —$siteConfig
getSystemMessages()
Get the Site's SystemMessages
public
getSystemMessages() : array<string|int, SystemMessage>
Return values
array<string|int, SystemMessage>getViewRenderer()
Get the ViewRenderer. Components like Controllers can access this method to configure the set ViewRenderer.
public
getViewRenderer() : ViewRenderer
Return values
ViewRenderer —The currently set ViewRenderer
hasRedirectUrl()
public
hasRedirectUrl() : bool
Return values
boolredirect()
public
redirect() : void
setCurrentPage()
Sets the currently requested page
public
setCurrentPage(SitePage $page) : void
Parameters
- $page : SitePage
-
The currently requested SitePage
setRedirectUrl()
Define a redirect URL.
public
setRedirectUrl(mixed $redirectUrl) : void
Parameters
- $redirectUrl : mixed
setViewRenderer()
Set the ViewRenderer.
public
setViewRenderer(mixed $viewRenderer) : void
Parameters
- $viewRenderer : mixed
addCachedDataRepository()
Adds a new DataRepository to the list of previously requested DataRepositories
protected
addCachedDataRepository(string $repositoryName, DataRepository $dataRepository) : void
Parameters
- $repositoryName : string
-
The name of the DataRepository
- $dataRepository : DataRepository
-
An instance of a DataRepository implementation
addCachedHelper()
Adds a Helper instance to the cache
protected
addCachedHelper(string $helperName, AbstractHelper $helperInstance) : void
Parameters
- $helperName : string
-
The name of the Helper instance
- $helperInstance : AbstractHelper
-
The Helper instance to cache
configurationFileExists()
Checks for the existence of a file with the given filename
protected
configurationFileExists(string $configurationFileName) : bool
Parameters
- $configurationFileName : string
-
The name of the file without extension or path
Return values
boolgetCachedDataRepository()
Fetch a DataRepository from the cache by its name
protected
getCachedDataRepository(string $repositoryName) : DataRepository|null
Parameters
- $repositoryName : string
-
The name of the desired DataRepository
Return values
DataRepository|nullgetCachedHelper()
protected
getCachedHelper(string $helperName) : AbstractHelper|null
Parameters
- $helperName : string
-
The name of the helper to retrieve from the cache
Return values
AbstractHelper|nullgetConfigurationFromFileName()
Retrieves a config array by its corresponding filename
protected
getConfigurationFromFileName(string $configurationFileName) : array<string|int, mixed>
Parameters
- $configurationFileName : string
-
The name of the file without extension or path
Return values
array<string|int, mixed>setGlobalUser()
Set a representation of the application user associated with a request.
protected
setGlobalUser(User $globalUser) : void
Parameters
- $globalUser : User
-
The application user
setPages()
Set the pages for the Site.
protected
setPages() : void
setSiteConfig()
Sets the site configuration
protected
setSiteConfig(array<string|int, mixed> $siteConfig) : void
Parameters
- $siteConfig : array<string|int, mixed>
-
The site configuration
setUser()
Associates the session User with CoreSite
protected
setUser() : void
loadConfigurationFile()
Loads and parses a php ini file into an array keyed by ini sections
private
loadConfigurationFile(string $configurationFileName) : void
Parameters
- $configurationFileName : string
-
The name of the file without extension or path