Class \Prado\Web\Services\TPageService
TPageService implements the service for serving user page requests.
Pages that are available to client users are stored under a directory specified by \Prado\Web\Services\setBasePath. The directory may contain subdirectories. Pages serving for a similar goal are usually placed under the same directory. A directory may contain a configuration file config.xml whose content is similar to that of application configuration file.
A page is requested via page path, which is a dot-connected directory names appended by the page name. Assume '<BasePath>/Users/Admin' is the directory containing the page 'Update'. Then the page can be requested via 'Users.Admin.Update'. By default, the \Prado\Web\Services\setBasePath of the page service is the "pages" directory under the application base path. You may change this default by setting \Prado\Web\Services\setBasePath with a different path you prefer.
Page name refers to the file name (without extension) of the page template. In order to differentiate from the common control template files, the extension name of the page template files must be '.page'. If there is a PHP file with the same page name under the same directory as the template file, that file will be considered as the page class file and the file name is the page class name. If such a file is not found, the page class is assumed as TPage.
Modules can be configured and loaded in page directory configurations. Configuration of a module in a subdirectory will overwrite its parent directory's configuration, if both configurations refer to the same module.
By default, TPageService will automatically load two modules:
- TTemplateManager : manages page and control templates
- TThemeManager : manages themes used in a Prado application
In page directory configurations, static authorization rules can also be specified,
which governs who and which roles can access particular pages.
Refer to TAuthorizationRule for more details about authorization rules.
Page authorization rules can be configured within an
Class hierarchy
- \Prado\Web\Services\TPageService
- \Prado\TService implements IService
- \Prado\TApplicationComponent
- \Prado\TComponent
Author: Carl G. Mathisen <carlgmathisen@gmail.com>
Since: 3.0
public
|
constructUrl(string $pagePath[, array<string|int, mixed> $getParams = null ][, bool $encodeAmpersand = true ][, bool $encodeGetItems = true ]) : string
Constructs a URL with specified page path and GET parameters.
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
deprecated
|
|
public
deprecated
|
|
public
|
init(TXmlElement $config) : mixed
Initializes the service.
This method is required by IService interface and is invoked by application. |
public
|
onAdditionalPagePaths(mixed $param) : mixed
This event is raised if the page is not found in the BasePath.
This provides additional possible Page Paths to look for the page. The typical handler would look like:
|
public
|
onPreRunPage(mixed $param) : mixed
This event is raised just before the page is run. Any part of the system can patch into the page
events with an onPreRunPage handler.
|
public
|
run() : mixed
Runs the service.
This will create the requested page, initializes it with the property values specified in the configuration, and executes the page. |
public
|
setBasePageClass(string $value) : mixed
Sets the base page class name (in namespace format).
If a page only has a template file without page class file, this base page class will be instantiated. |
public
|
|
public
|
setClientScriptManagerClass(string $value) : mixed
Sets the clientscript manager class (in namespace format).
|
public
|
|
public
deprecated
|
|
public
deprecated
|
|
protected
|
|
protected
|
createPage(string $pagePath) : TPage
Creates a page instance based on requested page path. If the Page is not
found in the BasePath then this method raises onAdditionalPagePaths($pagePath)
to query for any additional page paths. eg. from composer package modules.
|
protected
|
|
protected
|
initPageContext(TPageConfiguration $pageConfig) : mixed
Initializes page context.
Page context includes path alias settings, namespace usages, parameter initialization, module loadings, page initial properties and authorization rules. |
protected
|
|
protected
|
public
mixed
|
CONFIG_CACHE_PREFIX
Prefix of ID used for storing parsed configuration in cache
|
'prado:pageservice:'
|
public
mixed
|
CONFIG_FILE_PHP
Configuration file name
|
'config.php'
|
public
mixed
|
CONFIG_FILE_XML
Configuration file name
|
'config.xml'
|
public
mixed
|
DEFAULT_BASEPATH
Default base path
|
'Pages'
|
public
mixed
|
FALLBACK_BASEPATH
Fallback base path - used to be the default up to Prado < 3.2
|
'pages'
|
public
mixed
|
PAGE_FILE_EXT
Page template file extension
|
'.page'
|
public
mixed
|
PAGE_NAMESPACE_PREFIX
Prefix of Pages used for instantiating new pages
|
'Application\\Pages\\'
|
\Prado\TApplicationComponent::FX_CACHE_FILE, \Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |