Skip to content

Commit

Permalink
Compatibility with Symfony 3 (Form Type)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilov committed Jul 1, 2016
1 parent a124f59 commit b0e7d30
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
21 changes: 10 additions & 11 deletions Controller/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function uploadAction(Request $request, $context)
}
}

return $this->createSupportedJsonResponse($response->assemble());
return $this->createSupportedJsonResponse($response->assemble(), $request);
}

/**
Expand Down Expand Up @@ -112,15 +112,15 @@ public function uploadLinkAction(Request $request, $context)
$this->errorHandler->addException($response, $e);
}

return $this->createSupportedJsonResponse($response->assemble());
return $this->createSupportedJsonResponse($response->assemble(), $request);
}

/**
* @param Request $request
* @return JsonResponse
*/
public function progressAction()
public function progressAction(Request $request)
{
$request = $this->container->get('request');
$session = $this->container->get('session');

$prefix = ini_get('session.upload_progress.prefix');
Expand All @@ -135,11 +135,11 @@ public function progressAction()
}

/**
* @param Request $request
* @return JsonResponse
*/
public function cancelAction()
public function cancelAction(Request $request)
{
$request = $this->container->get('request');
$session = $this->container->get('session');

$prefix = ini_get('session.upload_progress.prefix');
Expand Down Expand Up @@ -366,18 +366,17 @@ protected function validate(FileInterface $file, Request $request, $context)
* On top of that, if the client does not support the application/json type,
* then the content type of the response will be set to text/plain instead.
*
* @param mixed $data
* @param int $status
*
* @param mixed $data
* @param Request $request
* @param int $status
* @return JsonResponse
*/
protected function createSupportedJsonResponse($data, $status = null)
protected function createSupportedJsonResponse($data, Request $request, $status = null)
{
if ($status === null) {
$status = isset($data['error']) ? 400 : 200;
}

$request = $this->container->get('request');
$response = new JsonResponse($data, $status);
$response->headers->set('Vary', 'Accept');

Expand Down
10 changes: 5 additions & 5 deletions Form/Type/DropzoneType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Glavweb\UploaderBundle\Helper\MediaHelper;

/**
Expand Down Expand Up @@ -112,9 +112,9 @@ public function buildView(FormView $view, FormInterface $form, array $options)
}

/**
* @param OptionsResolverInterface $resolver
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'previewImg' => null,
Expand Down Expand Up @@ -144,9 +144,9 @@ public function getParent()
}

/**
* @return string
* {@inheritdoc}
*/
public function getName()
public function getBlockPrefix()
{
return 'glavweb_uploader_dropzone';
}
Expand Down

0 comments on commit b0e7d30

Please sign in to comment.