当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller\Controller类代码示例

本文整理汇总了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()));
 }
开发者ID:symforce,项目名称:symforce-admin,代码行数:35,代码来源:CreateActionCache.php

示例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();
 }
开发者ID:mgerdzhev,项目名称:WebImageAnnotator,代码行数:7,代码来源:MediaChooserGatewayController.php

示例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
     }
 }
开发者ID:lapoiz,项目名称:WindServer2,代码行数:30,代码来源:RosaceWindManage.php

示例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;
 }
开发者ID:lapoiz,项目名称:WindServer2,代码行数:7,代码来源:ManageInfoSpot.php

示例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}");
 }
开发者ID:ephp,项目名称:utility,代码行数:8,代码来源:Log.php

示例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);
 }
开发者ID:GregHubs,项目名称:GestionRessources,代码行数:16,代码来源:Helper.php

示例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;
 }
开发者ID:manu7772,项目名称:adaje_haltegarderie,代码行数:9,代码来源:mediaType.php

示例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));
 }
开发者ID:symforce,项目名称:symforce-admin,代码行数:10,代码来源:ListActionCache.php

示例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));
 }
开发者ID:symforce,项目名称:symforce-admin,代码行数:11,代码来源:ViewActionCache.php

示例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;
 }
开发者ID:cesar-giraldo,项目名称:agile-scrum,代码行数:22,代码来源:Paginator.php

示例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();
     }
 }
开发者ID:mapbender,项目名称:fom,代码行数:13,代码来源:RegistrationController.php

示例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);
 }
开发者ID:stopsopa,项目名称:utils,代码行数:7,代码来源:AbstractController.php

示例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);
 }
开发者ID:EllynB,项目名称:Incipio,代码行数:10,代码来源:BaseController.php

示例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'];
 }
开发者ID:hyperbolaa,项目名称:QRCodeBundle,代码行数:7,代码来源:QRCodeController.php

示例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);
 }
开发者ID:sshversioncontrol,项目名称:git-web-client,代码行数:18,代码来源:BaseProjectController.php


注:本文中的Symfony\Bundle\FrameworkBundle\Controller\Controller类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。