Example #1
0
 /**
  * @param string $message
  * @param array  $params
  *
  * @return string
  */
 private function translateFlashMessage($message, $params = array())
 {
     $resource = ucfirst(str_replace('_', ' ', $this->config->getResourceName()));
     $resourceLower = strtolower($resource);
     $baseParams = array('%resource%' => $resource, '%resource_lower%' => $resourceLower);
     return $this->translator->trans($message, array_merge($baseParams, $params), 'flashes');
 }
 protected function handleView(View $view)
 {
     $handler = $this->get('fos_rest.view_handler');
     $context = $view->getSerializationContext();
     if ($groups = $this->config->getSerializationGroups()) {
         $context->setGroups($groups);
     }
     if ($version = $this->config->getSerializationVersion()) {
         $context->setVersion($version);
     }
     return $handler->handle($view);
 }
Example #3
0
 /**
  * Prepare a new log object.
  *
  * Grabs data from the request and elsewhere to construct a new log object
  * from controller data.
  *
  * @param string $action
  * @return LogInterface
  */
 private function prepareLog($action)
 {
     $request = $this->config->getRequest();
     $method = strtolower($request->getMethod());
     $attributes = $this->prepareAttributes($request->attributes);
     $query = $request->query->all();
     $post = $request->request->all();
     extract($attributes);
     // $route, $params, $id
     $log = new Log();
     $log->setUser($this->user)->setAction($action)->setResource($this->config->getResourceName())->setResourceId($id)->setRoute($route)->setAttributes($params)->setQuery($query ? $query : null)->setRequest($post ? $post : null);
     return $log;
 }
 /**
  * @return RedirectResponse
  */
 public function redirectToReferer()
 {
     return $this->redirect($this->config->getRequest()->headers->get('referer'));
 }
 public function testConfigurationYieldsExpectedRedirectParametersWhenArray()
 {
     $expected = array('array');
     $this->paramHandler = Mockery::mock('DAG\\Bundle\\ResourceBundle\\Controller\\ParametersParser')->shouldReceive('process')->once()->andReturn($expected)->getMock();
     $config = new Configuration($this->paramHandler, 'prefix', 'resource', 'namespace');
     $config->setParameters(array('redirect' => array('parameters' => $expected)));
     $this->assertSame($expected, $config->getRedirectParameters('resource'));
 }
 /**
  * @param string $name
  * @param Event  $event
  *
  * @return Event
  */
 public function dispatchEvent($name, Event $event)
 {
     $name = $this->config->getEventName($name);
     return $this->eventDispatcher->dispatch($name, $event);
 }