PHP 클래스 Symfony\Bundle\FrameworkBundle\Controller\Controller

It provides methods to common features needed in controllers.
저자: Fabien Potencier ([email protected])
상속: extends Symfony\Component\DependencyInjection\ContainerAware
파일 보기 프로젝트 열기: symfony/symfony 1 사용 예제들

보호된 메소드들

메소드 설명
addFlash ( string $type, string $message ) Adds a flash message to the current session for type.
createAccessDeniedException ( string $message = 'Access Denied.', Exception $previous = null ) : Symfony\Component\Security\Core\Exception\AccessDeniedException Returns an AccessDeniedException.
createForm ( string $type, mixed $data = null, array $options = [] ) : Form Creates and returns a Form instance from the type of the form.
createFormBuilder ( mixed $data = null, array $options = [] ) : FormBuilder Creates and returns a form builder instance.
createNotFoundException ( string $message = 'Not Found', Exception $previous = null ) : NotFoundHttpException Returns a NotFoundHttpException.
denyAccessUnlessGranted ( mixed $attributes, mixed $object = null, string $message = 'Access Denied.' ) Throws an exception unless the attributes are granted against the current authentication token and optionally supplied object.
file ( SplFileInfo | string $file, string | null $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT ) : BinaryFileResponse Returns a BinaryFileResponse object with original or customized file name and disposition header.
forward ( string $controller, array $path = [], array $query = [] ) : Response Forwards the request to another controller.
generateUrl ( string $route, mixed $parameters = [], integer $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH ) : string Generates a URL from the given parameters.
get ( string $id ) : object Gets a container service by its id.
getDoctrine ( ) : Doctrine\Bundle\DoctrineBundle\Registry Shortcut to return the Doctrine Registry service.
getParameter ( string $name ) : mixed Gets a container configuration parameter by its name.
getUser ( ) : mixed Get a user from the Security Token Storage.
has ( string $id ) : boolean Returns true if the service id is defined.
isCsrfTokenValid ( string $id, string $token ) : boolean Checks the validity of a CSRF token.
isGranted ( mixed $attributes, mixed $object = null ) : boolean Checks if the attributes are granted against the current authentication token and optionally supplied object.
json ( mixed $data, integer $status = 200, array $headers = [], array $context = [] ) : Symfony\Component\HttpFoundation\JsonResponse Returns a JsonResponse that uses the serializer component if enabled, or json_encode.
redirect ( string $url, integer $status = 302 ) : RedirectResponse Returns a RedirectResponse to the given URL.
redirectToRoute ( string $route, array $parameters = [], integer $status = 302 ) : RedirectResponse Returns a RedirectResponse to the given route with the given parameters.
render ( string $view, array $parameters = [], Response $response = null ) : Response Renders a view.
renderView ( string $view, array $parameters = [] ) : string Returns a rendered view.
stream ( string $view, array $parameters = [], Symfony\Component\HttpFoundation\StreamedResponse $response = null ) : Symfony\Component\HttpFoundation\StreamedResponse Streams a view.

메소드 상세

addFlash() 보호된 메소드

Adds a flash message to the current session for type.
protected addFlash ( string $type, string $message )
$type string The type
$message string The message

createAccessDeniedException() 보호된 메소드

This will result in a 403 response code. Usage example: throw $this->createAccessDeniedException('Unable to access this page!');
protected createAccessDeniedException ( string $message = 'Access Denied.', Exception $previous = null ) : Symfony\Component\Security\Core\Exception\AccessDeniedException
$message string A message
$previous Exception The previous exception
리턴 Symfony\Component\Security\Core\Exception\AccessDeniedException

createForm() 보호된 메소드

Creates and returns a Form instance from the type of the form.
protected createForm ( string $type, mixed $data = null, array $options = [] ) : Form
$type string The fully qualified class name of the form type
$data mixed The initial data for the form
$options array Options for the form
리턴 Symfony\Component\Form\Form

createFormBuilder() 보호된 메소드

Creates and returns a form builder instance.
protected createFormBuilder ( mixed $data = null, array $options = [] ) : FormBuilder
$data mixed The initial data for the form
$options array Options for the form
리턴 Symfony\Component\Form\FormBuilder

createNotFoundException() 보호된 메소드

This will result in a 404 response code. Usage example: throw $this->createNotFoundException('Page not found!');
protected createNotFoundException ( string $message = 'Not Found', Exception $previous = null ) : NotFoundHttpException
$message string A message
$previous Exception The previous exception
리턴 Symfony\Component\HttpKernel\Exception\NotFoundHttpException

denyAccessUnlessGranted() 보호된 메소드

Throws an exception unless the attributes are granted against the current authentication token and optionally supplied object.
protected denyAccessUnlessGranted ( mixed $attributes, mixed $object = null, string $message = 'Access Denied.' )
$attributes mixed The attributes
$object mixed The object
$message string The message passed to the exception

file() 보호된 메소드

Returns a BinaryFileResponse object with original or customized file name and disposition header.
protected file ( SplFileInfo | string $file, string | null $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT ) : BinaryFileResponse
$file SplFileInfo | string File object or path to file to be sent as response
$fileName string | null File name to be sent to response or null (will use original file name)
$disposition string Disposition of response ("attachment" is default, other type is "inline")
리턴 Symfony\Component\HttpFoundation\BinaryFileResponse

forward() 보호된 메소드

Forwards the request to another controller.
protected forward ( string $controller, array $path = [], array $query = [] ) : Response
$controller string The controller name (a string like BlogBundle:Post:index)
$path array An array of path parameters
$query array An array of query parameters
리턴 Symfony\Component\HttpFoundation\Response A Response instance

generateUrl() 보호된 메소드

Generates a URL from the given parameters.
또한 보기: UrlGeneratorInterface
protected generateUrl ( string $route, mixed $parameters = [], integer $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH ) : string
$route string The name of the route
$parameters mixed An array of parameters
$referenceType integer The type of reference (one of the constants in UrlGeneratorInterface)
리턴 string The generated URL

get() 보호된 메소드

Gets a container service by its id.
protected get ( string $id ) : object
$id string The service id
리턴 object The service

getDoctrine() 보호된 메소드

Shortcut to return the Doctrine Registry service.
protected getDoctrine ( ) : Doctrine\Bundle\DoctrineBundle\Registry
리턴 Doctrine\Bundle\DoctrineBundle\Registry

getParameter() 보호된 메소드

Gets a container configuration parameter by its name.
protected getParameter ( string $name ) : mixed
$name string The parameter name
리턴 mixed

getUser() 보호된 메소드

Get a user from the Security Token Storage.
또한 보기: TokenInterface::getUser()
protected getUser ( ) : mixed
리턴 mixed

has() 보호된 메소드

Returns true if the service id is defined.
protected has ( string $id ) : boolean
$id string The service id
리턴 boolean true if the service id is defined, false otherwise

isCsrfTokenValid() 보호된 메소드

Checks the validity of a CSRF token.
protected isCsrfTokenValid ( string $id, string $token ) : boolean
$id string The id used when generating the token
$token string The actual token sent with the request that should be validated
리턴 boolean

isGranted() 보호된 메소드

Checks if the attributes are granted against the current authentication token and optionally supplied object.
protected isGranted ( mixed $attributes, mixed $object = null ) : boolean
$attributes mixed The attributes
$object mixed The object
리턴 boolean

json() 보호된 메소드

Returns a JsonResponse that uses the serializer component if enabled, or json_encode.
protected json ( mixed $data, integer $status = 200, array $headers = [], array $context = [] ) : Symfony\Component\HttpFoundation\JsonResponse
$data mixed The response data
$status integer The status code to use for the Response
$headers array Array of extra headers to add
$context array Context to pass to serializer when using serializer component
리턴 Symfony\Component\HttpFoundation\JsonResponse

redirect() 보호된 메소드

Returns a RedirectResponse to the given URL.
protected redirect ( string $url, integer $status = 302 ) : RedirectResponse
$url string The URL to redirect to
$status integer The status code to use for the Response
리턴 Symfony\Component\HttpFoundation\RedirectResponse

redirectToRoute() 보호된 메소드

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
리턴 Symfony\Component\HttpFoundation\RedirectResponse

render() 보호된 메소드

Renders a view.
protected render ( string $view, array $parameters = [], Response $response = null ) : Response
$view string The view name
$parameters array An array of parameters to pass to the view
$response Symfony\Component\HttpFoundation\Response A response instance
리턴 Symfony\Component\HttpFoundation\Response A Response instance

renderView() 보호된 메소드

Returns a rendered view.
protected renderView ( string $view, array $parameters = [] ) : string
$view string The view name
$parameters array An array of parameters to pass to the view
리턴 string The rendered view

stream() 보호된 메소드

Streams a view.
protected stream ( string $view, array $parameters = [], Symfony\Component\HttpFoundation\StreamedResponse $response = null ) : Symfony\Component\HttpFoundation\StreamedResponse
$view string The view name
$parameters array An array of parameters to pass to the view
$response Symfony\Component\HttpFoundation\StreamedResponse A response instance
리턴 Symfony\Component\HttpFoundation\StreamedResponse A StreamedResponse instance