本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Controller\Controller::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::get方法的具体用法?PHP Controller::get怎么用?PHP Controller::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Controller\Controller
的用法示例。
在下文中一共展示了Controller::get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Controller $controller, $parametres = null)
{
$this->controller = $controller;
$this->securityContext = $controller->get('security.context');
$this->pageweb = $controller->get('aetools.pageweb');
if ($parametres === null) {
$parametres = array();
}
$this->parametres = $parametres;
}
示例2: 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
}
}
示例3: get
/**
* @param string $id Service name/id
*
* @return object
*/
public function get($id)
{
if (!isset($this->loadedServices[$id])) {
$this->loadedServices[$id] = parent::get($id);
}
return $this->loadedServices[$id];
}
示例4: 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}");
}
示例5: 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));
}
示例6: 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));
}
示例7: 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;
}
示例8: bundleInstalled
/**
* Checks if bundle with given name is installed.
*
* @param \Symfony\Bundle\FrameworkBundle\Controller\Controller $controller
* @param string $bundleName Bundle name to search for
*
* @internal param array $bundles All bundles
* @return bool Returns TRUE if we found bundle; otherwise FALSE
*/
public static function bundleInstalled(Controller $controller, $bundleName)
{
$allBundles = $controller->get('kernel')->getBundles();
$installed = false;
if (!is_array($allBundles)) {
return $installed;
}
foreach ($allBundles as $key => $bundle) {
if ($bundle instanceof BundleInterface) {
$name = $bundle->getName();
if ($bundleName === $name) {
$installed = true;
break;
}
}
}
return $installed;
}
示例9: onController
public function onController(Controller $controller, Request $request)
{
$object = $this->admin->getRouteObject();
$list_url = $this->admin->path('list');
if (!$object) {
$request->getSession()->getFlashBag()->add('error', 'not exists!');
return $controller->redirect($this->admin->path('list'));
}
$admin_children = array();
$children = $this->admin->getAdminRouteChildren();
if ($children) {
foreach ($children as $child_admin_name => $o) {
if ($o[0]) {
throw new \Exception("unimplement");
}
$admin_children[$child_admin_name] = array();
$child_admin = $this->admin->getAdminLoader()->getAdminByName($child_admin_name);
$properties = $o[0] ? $o[1] : array($o[1]);
foreach ($properties as $config) {
$child_property = $config[0];
$my_property = $config[1];
$count = $child_admin->countBy($child_property, $object);
$admin_children[$child_admin_name][$child_property] = $count;
}
}
}
/**
* @var \Symfony\Component\Form\FormBuilder
*/
$builder = $controller->createFormBuilder($object, array('label' => $this->admin->getFormLabel(), 'constraints' => array(new \Symfony\Component\Validator\Constraints\Callback(function ($object, \Symfony\Component\Validator\Context\ExecutionContext $context) use($controller, $admin_children) {
foreach ($admin_children as $child_admin_name => $list) {
$child_admin = $this->admin->getAdminLoader()->getAdminByName($child_admin_name);
foreach ($list as $count) {
if ($count > 0) {
if (!$child_admin->auth('delete')) {
$error = $this->admin->trans('sf.action.delete.error.child', array('%admin%' => $this->admin->getLabel(), '%child%' => $child_admin->getLabel(), '%count%' => $count), $this->sf_domain);
$context->addViolation($error);
}
}
}
}
}))));
$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->bind($request);
$this->admin->fireEvent('submit', $form);
if ($form->isValid()) {
$msg = $this->trans('sf.action.delete.finish', $object);
$this->admin->remove($object);
$request->getSession()->getFlashBag()->add('info', $msg);
return $controller->redirect($this->getFormReferer($form));
}
}
return $controller->render($this->template, array('sf_admin_loader' => $controller->get('sf.admin.loader'), 'admin' => $this->admin, 'action' => $this, 'form' => $form->createView()));
}
示例10: get
public function get($id)
{
return parent::get($id);
}