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; }
/** * @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 } }
/** * @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]; }
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}"); }
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)); }
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)); }
/** * 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 <*****@*****.**> 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; }
/** * 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; }
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())); }
public function get($id) { return parent::get($id); }