示例#1
0
 /**
  * @param Request $request
  * @return object|null
  */
 private function getObject(Request $request)
 {
     $id = $request->get('id');
     if (empty($id)) {
         return null;
     }
     $object = $this->element->getDataIndexer()->getData($id);
     if (!$object) {
         throw new NotFoundHttpException(sprintf('Can\'t find object with id %s', $id));
     }
     return $object;
 }
示例#2
0
 /**
  * @param \FSi\Bundle\AdminBundle\Admin\CRUD\GenericFormElement $element
  * @param \FSi\Bundle\AdminBundle\Admin\Context\ContextManager $manager
  * @param \Symfony\Component\HttpFoundation\Request $request
  */
 function it_throw_exception_when_cant_find_context_builder_that_supports_admin_element($element, $manager, $request)
 {
     $element->getId()->willReturn('admin_element_id');
     $manager->createContext(Argument::type('string'), $element)->shouldBeCalled()->willReturn(null);
     $this->shouldThrow('Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException')->during('formAction', array($element, $request));
 }