Completed
Push — master ( 000445...c8f0e6 )
by
unknown
04:21
created

MediaAdminController::imageAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
crap 2
1
<?php
2
3
namespace MediaMonks\SonataMediaBundle\Controller;
4
5
use Sonata\AdminBundle\Controller\CRUDController;
6
use Symfony\Component\HttpFoundation\Request;
7
8
class MediaAdminController extends CRUDController
9
{
10
    /**
11
     * @return \Symfony\Component\HttpFoundation\Response
12
     */
13
    public function createAction()
14
    {
15
        if (!$this->getRequest()->get('provider') && $this->getRequest()->isMethod('get')) {
16
            return $this->render(
17
                '@MediaMonksSonataMedia/MediaAdmin/select_provider.html.twig',
18
                [
19
                    'providers'     => $this->get('mediamonks.sonata_media.provider.pool')->getProviders(),
20
                    'base_template' => $this->getBaseTemplate(),
21
                    'admin'         => $this->admin,
22
                    'action'        => 'create',
23
                ]
24
            );
25
        }
26
27
        return parent::createAction();
28
    }
29
30
    /**
31
     * @param Request $request
32
     * @param int $id
33
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
34
     */
35
    public function imageAction(Request $request, $id)
36
    {
37
        return $this->get('mediamonks.sonata_media.helper.controller')->redirectToThumbnail(
38
            $request,
39
            $id,
40
            function ($id) {
41
                return $this->getDoctrine()->getManager()->find('MediaMonksSonataMediaBundle:Media', $id);
42
            }
43
        );
44
    }
45
}
46