function it_gets_form_from_class_name(Configuration $configuration, FormFactoryInterface $formFactory, FormInterface $form) { $formClass = 'spec\\Sylius\\Bundle\\ResourceBundle\\Controller\\TestFormType'; $configuration->getFormType()->willReturn($formClass); $formFactory->create(Argument::type($formClass), Argument::cetera())->shouldBeCalled()->willReturn($form); $this->getForm()->shouldReturn($form); }
protected function handleView(View $view) { $handler = $this->get('fos_rest.view_handler'); $handler->setExclusionStrategyGroups($this->config->getSerializationGroups()); if ($version = $this->config->getSerializationVersion()) { $handler->setExclusionStrategyVersion($version); } return $handler->handle($view); }
protected function isGrantedOr403($permission) { if (!$this->container->has('sylius.authorization_checker')) { return true; } $permission = $this->config->getPermission($permission); if ($permission && !$this->get('sylius.authorization_checker')->isGranted(sprintf('%s.%s.%s', $this->config->getBundlePrefix(), $this->config->getResourceName(), $permission))) { throw new AccessDeniedException(); } }
protected function isGrantedOr403($permission) { if (!$this->container->has('sylius.authorization_checker')) { return true; } $permission = $this->config->getPermission($permission); if ($permission) { $grant = sprintf('%s.%s.%s', $this->config->getBundlePrefix(), $this->config->getResourceName(), $permission); if (!$this->get('sylius.authorization_checker')->isGranted($grant)) { throw new AccessDeniedException(sprintf('Access denied to "%s" for "%s".', $grant, $this->getUser() ? $this->getUser()->getUsername() : 'anon.')); } } }
/** * @param string $message * @param array $params * * @return string */ private function translateFlashMessage($message, $params = array()) { $resource = ucfirst(str_replace('_', ' ', $this->config->getResourceName())); return $this->translator->trans($message, array_merge(array('%resource%' => $resource), $params), 'flashes'); }
/** * @return RedirectResponse */ public function redirectToReferer() { return $this->redirect($this->config->getRedirectReferer()); }
/** * @param string $name * @param Event $event * * @return ResourceEvent */ public function dispatchEvent($name, Event $event) { $name = $this->config->getEventName($name); return $this->eventDispatcher->dispatch($name, $event); }
/** * Create resource. * * @param RepositoryInterface $repository * @param string $defaultMethod * @param array $defaultArguments * * @return mixed */ public function createResource(RepositoryInterface $repository, $defaultMethod, array $defaultArguments = array()) { $callable = array($repository, $this->config->getFactoryMethod($defaultMethod)); $arguments = $this->config->getFactoryArguments($defaultArguments); return call_user_func_array($callable, $arguments); }
/** * @return RedirectResponse */ public function redirectToReferer() { return $this->redirect($this->config->getRequest()->headers->get('referer')); }