| Conditions | 2 |
| Paths | 2 |
| Total Lines | 60 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 151 | public function indexAction(Request $request) |
||
| 152 | { |
||
| 153 | /** @var \PageController $pageController */ |
||
| 154 | //$pageController = $this->get('page_controller'); |
||
| 155 | $pageController = new PageController(); |
||
| 156 | |||
| 157 | //$sessionHandler = $request->getSession(); |
||
| 158 | //$sessionHandler->remove('coursesAlreadyVisited'); |
||
| 159 | |||
| 160 | $user = $this->getUser(); |
||
| 161 | $userId = 0; |
||
| 162 | if ($user) { |
||
| 163 | $userId = $this->getUser()->getId(); |
||
| 164 | } |
||
| 165 | $announcementsBlock = $pageController->getAnnouncements($userId); |
||
| 166 | |||
| 167 | /** @var User $user */ |
||
| 168 | //$userManager = $this->container->get('fos_user.user_manager'); |
||
| 169 | //$user = $userManager->find(1); |
||
| 170 | |||
| 171 | //$attribute = $this->container->get('doctrine')->getRepository('ChamiloCoreBundle:ExtraField')->find(1); |
||
| 172 | /* |
||
| 173 | $attribute = new ExtraField(); |
||
| 174 | $attribute->setName('size'); |
||
| 175 | $attribute->setVariable('size'); |
||
| 176 | $attribute->setType(TextAttributeType::TYPE); |
||
| 177 | $attribute->setStorageType(AttributeValueInterface::STORAGE_TEXT); |
||
| 178 | $this->getDoctrine()->getManager()->persist($attribute); |
||
| 179 | $this->getDoctrine()->getManager()->flush(); |
||
| 180 | |||
| 181 | $attributeColor = new ExtraField(); |
||
| 182 | $attributeColor->setName('color'); |
||
| 183 | $attributeColor->setVariable('color'); |
||
| 184 | $attributeColor->setType(TextAttributeType::TYPE); |
||
| 185 | $attributeColor->setStorageType(AttributeValueInterface::STORAGE_TEXT); |
||
| 186 | $this->getDoctrine()->getManager()->persist($attributeColor); |
||
| 187 | $this->getDoctrine()->getManager()->flush(); |
||
| 188 | |||
| 189 | $color = new ExtraFieldValues(); |
||
| 190 | $color->setComment('lol'); |
||
| 191 | $color->setAttribute($attributeColor); |
||
| 192 | $color->setValue('blue'); |
||
| 193 | |||
| 194 | $user->addAttribute($color); |
||
| 195 | |||
| 196 | $smallSize = new ExtraFieldValues(); |
||
| 197 | $smallSize->setComment('lol'); |
||
| 198 | $smallSize->setAttribute($attribute); |
||
| 199 | $smallSize->setValue('S'); |
||
| 200 | |||
| 201 | $user->addAttribute($smallSize); |
||
| 202 | $userManager->updateUser($user); |
||
| 203 | */ |
||
| 204 | //$this->get('session')->remove('id_session'); |
||
| 205 | |||
| 206 | return $this->render( |
||
| 207 | '@ChamiloCore/Index/index.html.twig', |
||
| 208 | [ |
||
| 209 | 'content' => '', |
||
| 210 | 'announcements_block' => $announcementsBlock, |
||
| 211 | //'home_page_block' => $pageController->returnHomePage() |
||
| 244 |