Vaskovsky Web Application  3.17.0306
Public Member Functions | Protected Member Functions | List of all members
AVaskovsky\WebApplication\AbstractPage Class Reference

An abstract page. More...

Inheritance diagram for AVaskovsky\WebApplication\AbstractPage:
Inheritance graph
[legend]

Public Member Functions

 getClass ()
 Returns new \ReflectionClass($this).
 
 getPageName ()
 Returns short class name without 'Page' suffix.
 
 show ()
 Handles a server request and displays this page.
 

Protected Member Functions

 setApplicationURL ($url)
 Sets the application URL. More...
 
 getApplicationURL ($path)
 Returns a path relative to the application URL. More...
 
 setApplicationDirectory ($directory)
 Sets the application directory. More...
 
 getApplicationFile ($filename)
 Returns a file path relative to the application directory. More...
 
 setLocale ($locale)
 Sets a locale to use with this page. More...
 
 openPDO ($dsn, $user="", $password="")
 Opens a database connection to use in this application. More...
 
 getPDO ()
 Returns a PDO connection. More...
 
 setAuthentication (AbstractAuthentication $auth)
 Sets an authentication to use with this page. More...
 
 getAuthentication ()
 Returns an AbstractAuthentication object; never null. More...
 
 authorize ()
 Performs authorization. More...
 
 authorizeByAttribute ($attribute)
 Performs authorization by the account attribute. More...
 
 authorizeByPageName (array $public_pages=array())
 Performs authorization by the page name. More...
 
 render ($template, array $view_data=array(), $code=200)
 Renders a view. More...
 
 renderError ($message, $code=500)
 Renders an error. More...
 
 renderException (\Exception $ex)
 Renders an exception. More...
 

Detailed Description

An abstract page.

Author
Alexey Vaskovsky

Definition at line 23 of file AbstractPage.php.

Member Function Documentation

AVaskovsky\WebApplication\AbstractPage::authorize ( )
protected

Performs authorization.

Returns
true if user is authorized; false otherwise.

Definition at line 266 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::authorizeByAttribute (   $attribute)
protected

Performs authorization by the account attribute.

Parameters
string$attributeis an account attribute name.
Returns
true if user is authorized; false otherwise.
See also
authorize()

Definition at line 280 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::authorizeByPageName ( array  $public_pages = array())
protected

Performs authorization by the page name.

Parameters
array$public_pagesare list of page names.
Returns
true if user is authorized; false otherwise.
See also
authorize()

Definition at line 299 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::getApplicationFile (   $filename)
finalprotected

Returns a file path relative to the application directory.

Parameters
string$filenameis a file name.
Exceptions
InvalidArgumentExceptionif $filename is empty.

Definition at line 96 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::getApplicationURL (   $path)
finalprotected

Returns a path relative to the application URL.

Parameters
string$pathis a relative path.
Exceptions
InvalidArgumentExceptionif $path is null.

Definition at line 53 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::getAuthentication ( )
finalprotected

Returns an AbstractAuthentication object; never null.

Exceptions
PDOExceptionif $this->getPDO() throws.

Definition at line 253 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::getPDO ( )
finalprotected

Returns a PDO connection.

Exceptions
PDOExceptionif a database access error occurs.
See also
openPDO()

Definition at line 225 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::openPDO (   $dsn,
  $user = "",
  $password = "" 
)
finalprotected

Opens a database connection to use in this application.

Parameters
string$dsnis a string that contains the information required to connect to the database.
string$useris a user name for the DSN string.
string$passwordis a password for the DSN string.
Exceptions
PDOExceptionif a database access error occurs.
InvalidArgumentException: if $dsn is empty; if $user is null; if $password is null.

Definition at line 188 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::render (   $template,
array  $view_data = array(),
  $code = 200 
)
protected

Renders a view.

Parameters
string$templateis a template name.
array$view_datais an associative array that contains a view data.
int$codeis an HTTP status code.
Exceptions
InvalidArgumentException: if $template is empty; if $code is out of the bounds 100..599.
Returns
a string; never null.

Definition at line 328 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::renderError (   $message,
  $code = 500 
)
protected

Renders an error.

Parameters
string$messageis an error message.
int$codeis an HTTP status code.
Exceptions
InvalidArgumentException: if $message is null; if $code is out of the bounds 100..599.
Returns
a string; never null.

Definition at line 364 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::renderException ( \Exception  $ex)
protected

Renders an exception.

Parameters
Exception$exis an exception.
Returns
a string; never null.

Definition at line 391 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::setApplicationDirectory (   $directory)
finalprotected

Sets the application directory.

Parameters
string$directoryis a directory name.
Exceptions
InvalidArgumentExceptionif $directory is empty.

Definition at line 78 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::setApplicationURL (   $url)
finalprotected

Sets the application URL.

Parameters
string$urlis the application URL.
Exceptions
InvalidArgumentExceptionif $url is null.

Definition at line 36 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::setAuthentication ( AbstractAuthentication  $auth)
finalprotected

Sets an authentication to use with this page.

Parameters
AbstractAuthentication$authis an authentication.
Exceptions
InvalidArgumentExceptionif $auth is null.

Definition at line 243 of file AbstractPage.php.

AVaskovsky\WebApplication\AbstractPage::setLocale (   $locale)
protected

Sets a locale to use with this page.

Parameters
string$localeis the locale name.
Exceptions
InvalidArgumentExceptionif $locale is empty.

Definition at line 152 of file AbstractPage.php.


The documentation for this class was generated from the following file: