TutorialController::labelsAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
3
namespace SumoCoders\FrameworkExampleBundle\Controller;
4
5
use Knp\Menu\MenuItem;
6
use SumoCoders\FrameworkExampleBundle\Form\Type\ButtonIconType;
7
use SumoCoders\FrameworkExampleBundle\Form\Type\CollectionsType;
8
use SumoCoders\FrameworkExampleBundle\Form\Type\DatePickerType;
9
use SumoCoders\FrameworkExampleBundle\Form\Type\FieldsetType;
10
use SumoCoders\FrameworkExampleBundle\Form\Type\LabelsType;
11
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
12
use Symfony\Component\HttpFoundation\Request;
13
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
14
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
15
16
class TutorialController extends Controller
17
{
18
    /**
19
     * @Route("/tutorial/datepicker")
20
     * @Template()
21
     * @return array
22
     */
23
    public function datePickerAction()
24
    {
25
        $form = $this->createForm(DatePickerType::class);
26
27
        return array(
28
            'form' => $form->createView(),
29
        );
30
    }
31
32
    /**
33
     * @Route("/tutorial/labels")
34
     * @Template()
35
     */
36
    public function labelsAction()
37
    {
38
        $form = $this->createForm(LabelsType::class);
39
40
        return array(
41
            'form' => $form->createView(),
42
        );
43
    }
44
45
    /**
46
     * @Route("/tutorial/button-icons")
47
     * @Template()
48
     */
49
    public function buttonIconsAction()
50
    {
51
        $form = $this->createForm(ButtonIconType::class);
52
53
        return array(
54
            'form' => $form->createView(),
55
        );
56
    }
57
58
    /**
59
     * @Route("/tutorial/fieldset")
60
     * @Template()
61
     */
62
    public function fieldsetAction()
63
    {
64
        $form = $this->createForm(FieldsetType::class);
65
66
        return array(
67
            'form' => $form->createView(),
68
        );
69
    }
70
71
    /**
72
     * @Route("/tutorial/statistics")
73
     * @Template()
74
     */
75
    public function statisticsAction()
76
    {
77
        return array();
78
    }
79
80
    /**
81
     * @Route("/tutorial/custom-bread-crumb")
82
     * @Template()
83
     */
84
    public function customBreadCrumbAction(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
85
    {
86
        /** @var /SumoCoders\FrameworkCoreBundle\BreadCrumb\BreadCrumbBuilder $breadCrumbBuilder */
0 ignored issues
show
Documentation introduced by
The doc-type /SumoCoders\FrameworkCor...Crumb\BreadCrumbBuilder could not be parsed: Unknown type name "/SumoCoders\FrameworkCoreBundle\BreadCrumb\BreadCrumbBuilder" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
87
        $breadCrumbBuilder = $this->get('framework.breadcrumb_builder');
88
        $factory = $this->get('knp_menu.factory');
89
90
        $breadCrumbBuilder->dontExtractFromTheRequest();
91
        $item = (new MenuItem('foo.bar', $factory))
92
            ->setlabel('First!')
93
            ->setUri(
94
                $this->generateUrl('sumocoders_frameworkexample_tutorial_custombreadcrumb') . '#first'
95
            );
96
97
        $breadCrumbBuilder->addItem($item);
98
        $breadCrumbBuilder->addSimpleItem('Second');
99
        $breadCrumbBuilder->addSimpleItem(
100
            'Third',
101
            $this->generateUrl('sumocoders_frameworkexample_tutorial_custombreadcrumb') . '#third'
102
        );
103
104
        return array();
105
    }
106
107
    /**
108
     * @Route("/tutorial/collections")
109
     * @Template()
110
     * @return array
111
     */
112
    public function collectionsAction()
113
    {
114
        $form = $this->createForm(CollectionsType::class);
115
116
        return array(
117
            'form' => $form->createView(),
118
        );
119
    }
120
121
    /**
122
     * @Route("/tutorial/send-mail")
123
     * @Template()
124
     * @param Request $request
125
     * @return array
126
     */
127
    public function sendMailAction(Request $request)
128
    {
129
        $form = $this->createFormBuilder()
130
            ->getForm();
131
132
        $form->handleRequest($request);
133
134
        if ($form->isSubmitted() && $form->isValid()) {
135
            // get the message factory so we can create messages
136
            $messageFactory = $this->get('framework.message_factory');
137
138
            // create a simple message
139
            $message = $messageFactory->createHtmlMessage(
140
                'the subject',
141
                '<p>foo bar</p>'
142
            );
143
144
            // set some extra properties, just like you would do with a normal \Swift_Message
145
            $message->setTo(
146
                $this->getParameter('mailer.default_to_email')
147
            );
148
149
            // send it
150
            $this->get('mailer')->send($message);
151
        }
152
153
        return array(
154
            'form' => $form->createView(),
155
        );
156
    }
157
}
158