本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Controller\Controller类的典型用法代码示例。如果您正苦于以下问题:PHP Controller类的具体用法?PHP Controller怎么用?PHP Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onController
public function onController(Controller $controller, Request $request)
{
$object = $this->admin->newObject();
$label = null;
if ($this->admin->tree && $this->admin->getTreeObjectId()) {
$label = $this->admin->trans('sf.tree.create.title', array('%object%' => $this->admin->string($this->admin->getTreeObject()), '%admin%' => $this->admin->getLabel()), $this->sf_domain);
} else {
$label = $this->admin->getFormLabel();
}
$list_url = $this->admin->path('list');
$this->admin->setFormOriginalObject($object);
$builder = $controller->createFormBuilder($object, array('label' => $label));
$this->admin->buildCreateForm($controller, $object, $builder, $this);
$this->buildFormReferer($request, $builder, $object, $list_url);
$form = $builder->getForm();
$this->setForm($form);
$dispatcher = $this->admin->getService('event_dispatcher');
$event = new \Symforce\AdminBundle\Event\FormEvent($form, $request);
$dispatcher->dispatch('sf.event.form', $event);
if (null !== $event->getResponse()) {
return $event->getResponse();
}
if ($request->isMethod('POST')) {
$form->handleRequest($request);
$this->admin->fireEvent('submit', $form);
if ($form->isValid()) {
$this->admin->onUpdate($controller, $request, $this, $object, $form);
if ($form->isValid()) {
$this->admin->update($object);
return $this->admin->afterUpdate($controller, $request, $this, $object, $form);
}
}
}
return $controller->render($this->template, array('sf_admin_loader' => $controller->get('sf.admin.loader'), 'admin' => $this->admin, 'action' => $this, 'form' => $form->createView()));
}
示例2: getUploadForms
public static function getUploadForms(Controller $controller)
{
$formImage = $controller->createForm(new ImageMediaFormType(), new Image(), array());
// $formMultipleFiles = $controller->createForm ( new ImageMediaMultipleFormType (), array (), array () );
return array($formImage->createView());
return $formMultipleFiles->createView();
}
示例3: createRosaceWind
/**
* @param Spot $spot spot contenant les orientation de vent
* Créer une image png de la rosace des vents, avec GD.
* L'image sera stockée dans : images/windRosaces/spotId.png
*/
static function createRosaceWind(Spot $spot, Controller $controller)
{
try {
$rosaceImg = RosaceWindManage::createImageRosaceWind($spot);
$ds = DIRECTORY_SEPARATOR;
$urlImage = $controller->get("kernel")->getRootDir() . $ds . '..' . $ds . 'web' . $ds . 'images' . $ds . 'windRosaces';
RosaceWindManage::createRoute($urlImage);
$urlImageMin = $urlImage . $ds . $spot->getId() . ".min.png";
$urlImage = $urlImage . $ds . $spot->getId() . ".png";
$rosaceImgMin = imagecreate(LargeurImg * ScalledImgMin, HauteurImg * ScalledImgMin);
$blanc = imagecolorallocate($rosaceImgMin, 255, 255, 255);
imagecopyresampled($rosaceImgMin, $rosaceImg, 0, 0, 0, 0, LargeurImg * ScalledImgMin, HauteurImg * ScalledImgMin, LargeurImg, HauteurImg);
imagecolortransparent($rosaceImgMin, $blanc);
imagepng($rosaceImg, $urlImage);
// on enregistre l'image dans le dossier "images/windRosaces"
imagepng($rosaceImgMin, $urlImageMin);
// on enregistre l'image dans le dossier "images/windRosaces"
imagedestroy($rosaceImg);
// libération de l'espace mémoire utilisé
imagedestroy($rosaceImgMin);
} catch (\Exception $e) {
$toto = $e->getMessage();
// pour debug
}
}
示例4: createNewForm
public static function createNewForm(Controller $controller, Spot $spot)
{
$infoSpot = new InfoSpot();
$form = $controller->createForm(InfoSpotType::class, $infoSpot, array('action' => $controller->generateUrl('_bo_ajax_spot_add_spot_info', array('id' => $spot->getId())), 'method' => 'POST'));
$form->add('Create', SubmitType::class, array('label' => 'Create', 'attr' => array('class' => 'btn btn-default pull-right')));
return $form;
}
示例5: emergency
public static function emergency(Controller $controller, $object, $text = '', $mode = 0)
{
$message = self::getMessage($object, $text, $mode);
$logger = $controller->get('logger');
/* @var $logger \Symfony\Bridge\Monolog\Logger */
$pre = Debug::typeof($object, true);
$logger->emerg("{$pre} | {$message}");
}
示例6: getPath
/**
* Permet de récupérer la bon route en php
* @param $route
* @param $params
* @param string $locale
* @param Controller $controller
* @return string
*/
public function getPath($route, $params, $locale = 'fr', Controller $controller)
{
if ($locale !== 'fr') {
$route .= ucfirst($locale);
$params['_locale'] = $locale;
}
return $controller->generateUrl($route, $params);
}
示例7: __construct
public function __construct(Controller $controller, $parametres = null)
{
$this->controller = $controller;
$this->securityContext = $controller->get('security.context');
if ($parametres === null) {
$parametres = array();
}
$this->parametres = $parametres;
}
示例8: onController
public function onController(Controller $controller, Request $request)
{
$repos = $this->admin->getRepository();
$dql = $this->admin->getListDQL();
$em = $this->admin->getManager();
$query = $em->createQuery($dql);
$paginator = $this->admin->getService('knp_paginator');
$pagination = $paginator->paginate($query, $this->page_number, 10, array('pageParameterName' => 'admin_list_page'));
return $controller->render($this->template, array('sf_admin_loader' => $controller->get('sf.admin.loader'), 'admin' => $this->admin, 'action' => $this, 'pagination' => $pagination));
}
示例9: onController
public function onController(Controller $controller, Request $request)
{
$object = $this->admin->getRouteObject();
$label = null;
if ($this->admin->tree && $this->admin->getTreeObjectId()) {
$label = $this->admin->trans('sf.tree.create.title', array('%object%' => $this->admin->string($this->admin->getTreeObject()), '%admin%' => $this->admin->getLabel()), $this->sf_domain);
} else {
$label = $this->admin->getFormLabel();
}
return $controller->render($this->template, array('sf_admin_loader' => $controller->get('sf.admin.loader'), 'admin' => $this->admin, 'action' => $this, 'object' => $object, 'title' => $label));
}
示例10: createPaginators
/**
* Esta funcion permite instanciar un nuevo paginador para los listados
* de la aplicacion, seteando los valores por defecto o parametrizados
* por el usuario
* @author Cesar Giraldo <cesargiraldo1108@gmail.com> 27/08/2015
* @param \Symfony\Bundle\FrameworkBundle\Controller\Controller $controller
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Ideup\SimplePaginatorBundle\Paginator\Paginator instancia del paginador
*/
public static function createPaginators($controller, $request, array $ids)
{
$paginator = $controller->get('ideup.simple_paginator');
$paginator->pageRanges = Paginator::$defaultPageRanges;
foreach ($ids as $id) {
$paginator->setItemsPerPage($request->get('itemsPerPage') != '' ? $request->get('itemsPerPage') : Paginator::$defaultItemsPerPage, $id);
if ($paginator->getItemsPerPage($id) == 0) {
$paginator->setItemsPerPage(Paginator::$defaultPageRanges[count(Paginator::$defaultPageRanges) - 1], $id);
}
$paginator->setMaxPagerItems(Paginator::$defaultMaxPagerItems, $id);
}
return $paginator;
}
示例11: setContainer
/**
* Check if self registration is allowed.
*
* setContainer is called after controller creation is used to deny access to controller if self registration has
* been disabled.
*/
public function setContainer(ContainerInterface $container = NULL)
{
parent::setContainer($container);
if (!$this->container->getParameter('fom_user.selfregister')) {
throw new AccessDeniedHttpException();
}
}
示例12: redirectToRoute
public function redirectToRoute($route, array $parameters = array(), $status = 302)
{
if ($route instanceof Request) {
$route = $route->get('_route', 'error_no_route_specified');
}
return parent::redirectToRoute($route, $parameters, $status);
}
示例13: generateUrl
/**
* {@inheritdoc}
*/
public function generateUrl($route, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
{
if (array_key_exists('id', $parameters)) {
$parameters['id'] = IriHelper::extractId($parameters['id']);
}
return parent::generateUrl($route, $parameters, $referenceType);
}
示例14: setContainer
public function setContainer(ContainerInterface $container = null)
{
parent::setContainer($container);
$options = $this->container->getParameter('bushidoio_qrcode');
$this->http_max_age = $options['http_max_age'];
$this->https_max_age = $options['https_max_age'];
}
示例15: generateUrl
/**
* Generates a URL from the given parameters adding project id.
*
* @param string $route The name of the route
* @param mixed $parameters An array of parameters
* @param int $referenceType The type of reference (one of the constants in UrlGeneratorInterface)
*
* @return string The generated URL
*
* @see UrlGeneratorInterface
*/
public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
{
if ($this->project) {
$mergedParameters = array_merge(array('id' => $this->project->getId()), $parameters);
}
return parent::generateUrl($route, $mergedParameters, $referenceType);
}