public function testCreateActionWithPreview()
 {
     $this->admin->expects($this->once())->method('isGranted')->with($this->equalTo('CREATE'))->will($this->returnValue(true));
     $object = new \stdClass();
     $this->admin->expects($this->once())->method('getNewInstance')->will($this->returnValue($object));
     $form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
     $this->admin->expects($this->any())->method('getClass')->will($this->returnValue('stdClass'));
     $this->admin->expects($this->once())->method('getForm')->will($this->returnValue($form));
     $this->admin->expects($this->once())->method('supportsPreviewMode')->will($this->returnValue(true));
     $formView = $this->getMock('Symfony\\Component\\Form\\FormView');
     $form->expects($this->any())->method('createView')->will($this->returnValue($formView));
     $form->expects($this->once())->method('isSubmitted')->will($this->returnValue(true));
     $form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->request->setMethod('POST');
     $this->request->request->set('btn_preview', 'Preview');
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $this->controller->createAction($this->request));
     $this->assertEquals($this->admin, $this->parameters['admin']);
     $this->assertEquals('SonataAdminBundle::standard_layout.html.twig', $this->parameters['base_template']);
     $this->assertEquals($this->pool, $this->parameters['admin_pool']);
     $this->assertEquals('create', $this->parameters['action']);
     $this->assertInstanceOf('Symfony\\Component\\Form\\FormView', $this->parameters['form']);
     $this->assertEquals($object, $this->parameters['object']);
     $this->assertEquals(array(), $this->session->getFlashBag()->all());
     $this->assertEquals('SonataAdminBundle:CRUD:preview.html.twig', $this->template);
 }
 /**
  * Surcharge pour ne pas autoriser de nouvelles configurations si il y en a déja en base
  */
 public function createAction()
 {
     if ($this->admin->getDatagrid()->getResults()->count() > 0) {
         $this->addFlash('sonata_flash_error', $this->admin->trans('flash_configuration_already_exists_error', array(), 'RedkingCoreRestBundle'));
         return new RedirectResponse($this->admin->generateUrl('list'));
     }
     return parent::createAction();
 }
 public function createAction()
 {
     $repo = $this->getDoctrine()->getManager()->getRepository('IndicadoresBundle:OrigenDatos');
     $this->admin->setRepository($repo);
     $vitacora = $this->get('vitacora.siig');
     $vitacora->addInfo('Se Creo nuevo significado de Campo');
     return parent::createAction();
 }
Пример #4
0
 /**
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function createAction()
 {
     $object = $this->admin->getCurrentDevises($this->admin->getCurrentYearMonth());
     if ($object) {
         $url = $this->admin->generateObjectUrl('edit', $object);
         return $this->redirect($url);
     }
     return parent::createAction();
 }
 public function createAction()
 {
     $result = parent::createAction();
     if ($this->getRestMethod() == 'POST' && $this->admin->getForm()->isValid()) {
         /** @var SeoFile $seo_file */
         $seo_file = $this->admin->getSubject();
         $this->writeFile($seo_file->getName(), $seo_file->getContent());
     }
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 public function createAction(Request $request = null)
 {
     if (false === $this->admin->isGranted('CREATE')) {
         throw new AccessDeniedException();
     }
     if (!$request->get('provider') && $request->isMethod('get')) {
         return $this->render('SonataMediaBundle:MediaAdmin:select_provider.html.twig', array('providers' => $this->get('sonata.media.pool')->getProvidersByContext($this->get('request')->get('context', $this->get('sonata.media.pool')->getDefaultContext())), 'base_template' => $this->getBaseTemplate(), 'admin' => $this->admin, 'action' => 'create'));
     }
     return parent::createAction();
 }
Пример #7
0
 /**
  * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
  *
  * @return \Symfony\Bundle\FrameworkBundle\Controller\Response|\Symfony\Component\HttpFoundation\Response
  */
 public function createAction(Request $request = null)
 {
     if (false === $this->admin->isGranted('CREATE')) {
         throw new AccessDeniedException();
     }
     $parameters = $this->admin->getPersistentParameters();
     if (!$parameters['provider']) {
         return $this->render('SonataProductBundle:ProductAdmin:select_provider.html.twig', array('providers' => $this->get('sonata.product.pool')->getProducts(), 'base_template' => $this->getBaseTemplate(), 'admin' => $this->admin, 'action' => 'create'));
     }
     return parent::createAction($request);
 }
 /**
  * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
  * @return \Symfony\Bundle\FrameworkBundle\Controller\Response|\Symfony\Component\HttpFoundation\Response
  */
 public function createAction()
 {
     if (false === $this->admin->isGranted('CREATE')) {
         throw new AccessDeniedException();
     }
     $parameters = $this->admin->getPersistentParameters();
     if (!$parameters['provider']) {
         return $this->render('SonataMediaBundle:MediaAdmin:select_provider.html.twig', array('providers' => $this->get('sonata.media.pool')->getProvidersByContext($this->get('request')->get('context', 'default')), 'base_template' => $this->getBaseTemplate(), 'admin' => $this->admin, 'action' => 'create'));
     }
     return parent::createAction();
 }
Пример #9
0
 public function createAction()
 {
     if (false === $this->admin->isGranted('CREATE')) {
         throw new AccessDeniedException();
     }
     $parameters = $this->admin->getPersistentParameters();
     $routeTypes = $this->admin->getRouteTypePool()->getRouteTypes();
     if (!isset($parameters['route_type'])) {
         return $this->render('GravityCmsBundle:Route:create_select_route_type.html.twig', ['route_types' => $routeTypes, 'base_template' => $this->getBaseTemplate(), 'admin' => $this->admin, 'action' => 'create']);
     }
     return parent::createAction();
 }
 /**
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function createAction(Request $request = null)
 {
     $this->admin->checkAccess('create');
     $sharedBlockAdminClass = $this->container->getParameter('sonata.page.admin.shared_block.class');
     if (!$this->admin->getParent() && get_class($this->admin) !== $sharedBlockAdminClass) {
         throw new PageNotFoundException('You cannot create a block without a page');
     }
     $parameters = $this->admin->getPersistentParameters();
     if (!$parameters['type']) {
         return $this->render('SonataPageBundle:BlockAdmin:select_type.html.twig', array('services' => $this->get('sonata.block.manager')->getServicesByContext('sonata_page_bundle'), 'base_template' => $this->getBaseTemplate(), 'admin' => $this->admin, 'action' => 'create'));
     }
     return parent::createAction();
 }
Пример #11
0
 /**
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function createAction()
 {
     if (false === $this->admin->isGranted('CREATE')) {
         throw new AccessDeniedException();
     }
     if (!$this->admin->getParent()) {
         throw new PageNotFoundException('You cannot create a block without a page');
     }
     $parameters = $this->admin->getPersistentParameters();
     if (!$parameters['type']) {
         return $this->render('SonataPageBundle:BlockAdmin:select_type.html.twig', array('services' => $this->get('sonata.block.manager')->getServices(), 'base_template' => $this->getBaseTemplate(), 'admin' => $this->admin, 'action' => 'create'));
     }
     return parent::createAction();
 }
 /**
  * @param Request $request
  *
  * @return Response
  */
 public function createAction(Request $request = null)
 {
     $this->admin->checkAccess('create');
     if (!$this->admin->getParent()) {
         throw new NotFoundHttpException('You cannot create a block without a dashboard');
     }
     $parameters = $this->admin->getPersistentParameters();
     if (!$parameters['type']) {
         return $this->render('SonataDashboardBundle:BlockAdmin:select_type.html.twig', array('services' => $this->get('sonata.block.manager')->getServicesByContext('sonata_dashboard_bundle'), 'base_template' => $this->getBaseTemplate(), 'admin' => $this->admin, 'action' => 'create'));
     } elseif ($parameters['type'] == $this->admin->getDefaultContainerType()) {
         $dashboard = $this->admin->getParent()->getSubject();
         $position = count($dashboard->getBlocks()) + 1;
         $name = $request->get('name') != '' ? $request->get('name') : $this->admin->trans('composer.default.container.name', array('%position%' => $position), '');
         $container = $this->get('sonata.dashboard.block_interactor')->createNewContainer(array('name' => $name, 'dashboard' => $dashboard, 'position' => $position, 'code' => $name));
         return $this->render('SonataDashboardBundle:BlockAdmin:block_container.html.twig', array('admin' => $this->admin->getParent(), 'object' => $container));
     }
     return parent::createAction();
 }
Пример #13
0
 /**
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  *
  * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
  */
 public function createAction()
 {
     if (false === $this->admin->isGranted('CREATE')) {
         throw new AccessDeniedException();
     }
     if ($this->getRequest()->getMethod() == 'GET' && !$this->getRequest()->get('siteId')) {
         $sites = $this->get('sonata.page.manager.site')->findBy(array());
         if (count($sites) == 1) {
             return $this->redirect($this->admin->generateUrl('create', array('siteId' => $sites[0]->getId(), 'uniqid' => $this->admin->getUniqid())));
         }
         try {
             $current = $this->get('sonata.page.site.selector')->retrieve();
         } catch (\RuntimeException $e) {
             $current = false;
         }
         return $this->render('SonataPageBundle:PageAdmin:select_site.html.twig', array('sites' => $sites, 'current' => $current));
     }
     return parent::createAction();
 }
 public function createAction()
 {
     $repo = $this->getDoctrine()->getEntityManager()->getRepository('IndicadoresBundle:OrigenDatos');
     $this->admin->setRepository($repo);
     return parent::createAction();
 }
 public function createAction()
 {
     $repo = $this->getDoctrine()->getManager()->getRepository('IndicadoresBundle:FichaTecnica');
     $this->admin->setRepository($repo);
     return parent::createAction();
 }
 /**
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function createAction()
 {
     return $this->_action(parent::createAction(), 'create');
 }
Пример #17
0
 public function createAction()
 {
     $create = parent::createAction();
     if ($this->getRestMethod() == 'POST') {
         $this->updatePaymentContactInfo();
         $products = $this->get('request')->get('product');
         $object = $this->admin->getSubject();
         $this->createOrderProducts($object->getId(), $products);
         $this->getRequest()->getSession()->set('submit_action', 'submit');
     }
     return $create;
 }
 /**
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function createAction()
 {
     if ($this->getLocking() && ($this->_tabAlias == 'debexped' || $this->_tabAlias == 'debintro')) {
         throw new AccessDeniedException();
     }
     return $this->_action(parent::createAction(), 'create', 'form_layout');
 }
 /**
  * {@inheritdoc}
  */
 public function createAction(Request $request = null)
 {
     $this->admin->checkAccess('create');
     if ($request->getMethod() == 'GET' && !$this->getRequest()->get('siteId')) {
         $sites = $this->get('sonata.page.manager.site')->findBy(array());
         if (count($sites) == 1) {
             return $this->redirect($this->admin->generateUrl('create', array('siteId' => $sites[0]->getId(), 'uniqid' => $this->admin->getUniqid())));
         }
         try {
             $current = $this->get('sonata.page.site.selector')->retrieve();
         } catch (\RuntimeException $e) {
             $current = false;
         }
         return $this->render($this->admin->getTemplate('select_site'), array('sites' => $sites, 'current' => $current));
     }
     return parent::createAction();
 }