PHP Class Bolt\Controller\Base

Author: Carson Full ([email protected])
Inheritance: implements Silex\ControllerProviderInterface
Datei anzeigen Open project: bolt/bolt Class Usage Examples

Protected Properties

Property Type Description
$app Silex\Application

Public Methods

Method Description
connect ( Silex\Application $app )

Protected Methods

Method Description
abort ( integer $statusCode, string $message = '', array $headers = [] ) Shortcut to abort the current request by sending a proper HTTP error.
accessControl ( ) : AccessChecker Returns the Authentication object.
addRoutes ( Silex\ControllerCollection $c )
createForm ( string | Symfony\Component\Form\FormTypeInterface $type = FormType::class, mixed $data = null, array $options = [] ) : Form Creates and returns a Form instance from the type of the form.
createFormBuilder ( string | Symfony\Component\Form\FormTypeInterface $type = FormType::class, mixed $data = null, array $options = [] ) : Symfony\Component\Form\FormBuilderInterface Returns a form builder.
createQueryBuilder ( ) : Doctrine\DBAL\Query\QueryBuilder Return a new Query Builder.
extensions ( ) : Manager Gets the \Bolt\Extensions object.
filesystem ( ) : Bolt\Filesystem\Manager Gets the Bolt\Filesystem\Manager object.
flashes ( ) : Bolt\Logger\FlashLoggerInterface Gets the flash logger
generateUrl ( string $name, array $params = [], integer $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH ) : string Shortcut for {@see UrlGeneratorInterface::generate}
getContent ( string $textquery, array $parameters = [], array &$pager = [], array $whereparameters = [] ) : Content | Content[] Shortcut for {@see \Bolt\Legacy\Storage::getContent()}
getContentType ( string $slug ) : boolean | array Get the contenttype as an array, based on the given slug.
getContentTypeUserPermissions ( string $contentTypeSlug, array | Bolt\Storage\Entity\Users $user = null ) : boolean[] Helper to get a user's permissions for a ContentType.
getOption ( string $path, mixed $default = null ) : string | integer | array | null Shortcut for {@see \Bolt\Config::get}.
getRefererQueryParameters ( Request $request ) : array Get an array of query parameters used in the request.
getRepository ( string $repository ) : Repository Return a repository.
getUser ( integer | string | null $userId = null ) : Bolt\Storage\Entity\Users | false Return current user or user by ID.
hasUsers ( ) : boolean Check to see if the user table exists and has records.
isAllowed ( string $what, mixed $user = null, string | null $contenttype = null, integer | null $contentid = null ) : boolean Shortcut for {@see \Bolt\AccessControl\Permissions::isAllowed}
isCsrfTokenValid ( string | null $value = null, string $id = 'bolt' ) : boolean Check if csrf token is valid.
json ( mixed $data = [], integer $status = 200, array $headers = [] ) : Symfony\Component\HttpFoundation\JsonResponse Convert some data into a JSON response.
redirect ( string $url, integer $status = 302 ) : RedirectResponse Redirects the user to another URL.
redirectToRoute ( string $route, array $parameters = [], integer $status = 302 ) : RedirectResponse Returns a RedirectResponse to the given route with the given parameters.
render ( string $template, array $context = [], array $globals = [] ) : TemplateResponse Renders a template
resources ( ) : ResourceManager
session ( ) : Symfony\Component\HttpFoundation\Session\Session Returns the session.
storage ( ) : EntityManager | Storage Returns the Entity Manager.
templateChooser ( ) : TemplateChooser Return the Bolt\TemplateChooser provider.
users ( ) : Users Returns the Users object.
validateCsrfToken ( string | null $value = null, string $id = 'bolt' ) Validates CSRF token and throws HttpException if not.

Method Details

abort() protected method

Shortcut to abort the current request by sending a proper HTTP error.
protected abort ( integer $statusCode, string $message = '', array $headers = [] )
$statusCode integer The HTTP status code
$message string The status message
$headers array An array of HTTP headers

accessControl() protected method

Returns the Authentication object.
protected accessControl ( ) : AccessChecker
return Bolt\AccessControl\AccessChecker

addRoutes() abstract protected method

abstract protected addRoutes ( Silex\ControllerCollection $c )
$c Silex\ControllerCollection

connect() public method

public connect ( Silex\Application $app )
$app Silex\Application

createForm() protected method

Creates and returns a Form instance from the type of the form.
protected createForm ( string | Symfony\Component\Form\FormTypeInterface $type = FormType::class, mixed $data = null, array $options = [] ) : Form
$type string | Symfony\Component\Form\FormTypeInterface The built type of the form
$data mixed The initial data for the form
$options array Options for the form
return Symfony\Component\Form\Form

createFormBuilder() protected method

Returns a form builder.
protected createFormBuilder ( string | Symfony\Component\Form\FormTypeInterface $type = FormType::class, mixed $data = null, array $options = [] ) : Symfony\Component\Form\FormBuilderInterface
$type string | Symfony\Component\Form\FormTypeInterface The type of the form
$data mixed The initial data
$options array The options
return Symfony\Component\Form\FormBuilderInterface The form builder

createQueryBuilder() protected method

Return a new Query Builder.
protected createQueryBuilder ( ) : Doctrine\DBAL\Query\QueryBuilder
return Doctrine\DBAL\Query\QueryBuilder

extensions() protected method

Gets the \Bolt\Extensions object.
protected extensions ( ) : Manager
return Bolt\Extension\Manager

filesystem() protected method

Gets the Bolt\Filesystem\Manager object.
protected filesystem ( ) : Bolt\Filesystem\Manager
return Bolt\Filesystem\Manager

flashes() protected method

Gets the flash logger
protected flashes ( ) : Bolt\Logger\FlashLoggerInterface
return Bolt\Logger\FlashLoggerInterface

generateUrl() protected method

Shortcut for {@see UrlGeneratorInterface::generate}
protected generateUrl ( string $name, array $params = [], integer $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH ) : string
$name string The name of the route
$params array An array of parameters
$referenceType integer The type of reference to be generated (one of the constants)
return string

getContent() protected method

Shortcut for {@see \Bolt\Legacy\Storage::getContent()}
See also: Bolt\Legacy\Storage::getContent()
protected getContent ( string $textquery, array $parameters = [], array &$pager = [], array $whereparameters = [] ) : Content | Content[]
$textquery string
$parameters array
$pager array
$whereparameters array
return Bolt\Legacy\Content | Bolt\Legacy\Content[]

getContentType() protected method

Get the contenttype as an array, based on the given slug.
protected getContentType ( string $slug ) : boolean | array
$slug string
return boolean | array

getContentTypeUserPermissions() protected method

Helper to get a user's permissions for a ContentType.
protected getContentTypeUserPermissions ( string $contentTypeSlug, array | Bolt\Storage\Entity\Users $user = null ) : boolean[]
$contentTypeSlug string
$user array | Bolt\Storage\Entity\Users
return boolean[]

getOption() protected method

Shortcut for {@see \Bolt\Config::get}.
protected getOption ( string $path, mixed $default = null ) : string | integer | array | null
$path string
$default mixed
return string | integer | array | null

getRefererQueryParameters() protected method

Get an array of query parameters used in the request.
protected getRefererQueryParameters ( Request $request ) : array
$request Symfony\Component\HttpFoundation\Request
return array

getRepository() protected method

Return a repository.
protected getRepository ( string $repository ) : Repository
$repository string
return Bolt\Storage\Repository

getUser() protected method

Return current user or user by ID.
protected getUser ( integer | string | null $userId = null ) : Bolt\Storage\Entity\Users | false
$userId integer | string | null
return Bolt\Storage\Entity\Users | false

hasUsers() protected method

Check to see if the user table exists and has records.
protected hasUsers ( ) : boolean
return boolean

isAllowed() protected method

Shortcut for {@see \Bolt\AccessControl\Permissions::isAllowed}
protected isAllowed ( string $what, mixed $user = null, string | null $contenttype = null, integer | null $contentid = null ) : boolean
$what string
$user mixed The user to check permissions against.
$contenttype string | null
$contentid integer | null
return boolean

isCsrfTokenValid() protected method

Check if csrf token is valid.
protected isCsrfTokenValid ( string | null $value = null, string $id = 'bolt' ) : boolean
$value string | null The token value or null to use "bolt_csrf_token" parameter from request.
$id string The token ID.
return boolean

json() protected method

Convert some data into a JSON response.
protected json ( mixed $data = [], integer $status = 200, array $headers = [] ) : Symfony\Component\HttpFoundation\JsonResponse
$data mixed The response data
$status integer The response status code
$headers array An array of response headers
return Symfony\Component\HttpFoundation\JsonResponse

redirect() protected method

Redirects the user to another URL.
protected redirect ( string $url, integer $status = 302 ) : RedirectResponse
$url string The URL to redirect to
$status integer The status code (302 by default)
return Symfony\Component\HttpFoundation\RedirectResponse

redirectToRoute() protected method

Returns a RedirectResponse to the given route with the given parameters.
protected redirectToRoute ( string $route, array $parameters = [], integer $status = 302 ) : RedirectResponse
$route string The name of the route
$parameters array An array of parameters
$status integer The status code to use for the Response
return Symfony\Component\HttpFoundation\RedirectResponse

render() protected method

Renders a template
protected render ( string $template, array $context = [], array $globals = [] ) : TemplateResponse
$template string Template name
$context array Context variables
$globals array Global variables
return Bolt\Response\TemplateResponse

resources() protected method

protected resources ( ) : ResourceManager
return Bolt\Configuration\ResourceManager

session() protected method

Returns the session.
protected session ( ) : Symfony\Component\HttpFoundation\Session\Session
return Symfony\Component\HttpFoundation\Session\Session

storage() protected method

Returns the Entity Manager.
protected storage ( ) : EntityManager | Storage
return Bolt\Storage\EntityManager | Bolt\Legacy\Storage

templateChooser() protected method

Return the Bolt\TemplateChooser provider.
protected templateChooser ( ) : TemplateChooser
return Bolt\TemplateChooser

users() protected method

Returns the Users object.
protected users ( ) : Users
return Bolt\Users

validateCsrfToken() protected method

Validates CSRF token and throws HttpException if not.
protected validateCsrfToken ( string | null $value = null, string $id = 'bolt' )
$value string | null The token value or null to use "bolt_csrf_token" parameter from request.
$id string The token ID.

Property Details

$app protected_oe property

protected Application,Silex $app
return Silex\Application