| 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 |
||
| 111 | public function indexAction(Request $request) |
||
| 112 | { |
||
| 113 | /** @var \PageController $pageController */ |
||
| 114 | //$pageController = $this->get('page_controller'); |
||
| 115 | $pageController = new PageController(); |
||
| 116 | |||
| 117 | //$sessionHandler = $request->getSession(); |
||
| 118 | //$sessionHandler->remove('coursesAlreadyVisited'); |
||
| 119 | |||
| 120 | $user = $this->getUser(); |
||
| 121 | $userId = 0; |
||
| 122 | if ($user) { |
||
| 123 | $userId = $this->getUser()->getId(); |
||
| 124 | } |
||
| 125 | $announcementsBlock = $pageController->getAnnouncements($userId); |
||
| 126 | |||
| 127 | /** @var User $user */ |
||
| 128 | //$userManager = $this->container->get('fos_user.user_manager'); |
||
| 129 | //$user = $userManager->find(1); |
||
| 130 | |||
| 131 | //$attribute = $this->container->get('doctrine')->getRepository('ChamiloCoreBundle:ExtraField')->find(1); |
||
| 132 | /* |
||
| 133 | $attribute = new ExtraField(); |
||
| 134 | $attribute->setName('size'); |
||
| 135 | $attribute->setVariable('size'); |
||
| 136 | $attribute->setType(TextAttributeType::TYPE); |
||
| 137 | $attribute->setStorageType(AttributeValueInterface::STORAGE_TEXT); |
||
| 138 | $this->getDoctrine()->getManager()->persist($attribute); |
||
| 139 | $this->getDoctrine()->getManager()->flush(); |
||
| 140 | |||
| 141 | $attributeColor = new ExtraField(); |
||
| 142 | $attributeColor->setName('color'); |
||
| 143 | $attributeColor->setVariable('color'); |
||
| 144 | $attributeColor->setType(TextAttributeType::TYPE); |
||
| 145 | $attributeColor->setStorageType(AttributeValueInterface::STORAGE_TEXT); |
||
| 146 | $this->getDoctrine()->getManager()->persist($attributeColor); |
||
| 147 | $this->getDoctrine()->getManager()->flush(); |
||
| 148 | |||
| 149 | $color = new ExtraFieldValues(); |
||
| 150 | $color->setComment('lol'); |
||
| 151 | $color->setAttribute($attributeColor); |
||
| 152 | $color->setValue('blue'); |
||
| 153 | |||
| 154 | $user->addAttribute($color); |
||
| 155 | |||
| 156 | $smallSize = new ExtraFieldValues(); |
||
| 157 | $smallSize->setComment('lol'); |
||
| 158 | $smallSize->setAttribute($attribute); |
||
| 159 | $smallSize->setValue('S'); |
||
| 160 | |||
| 161 | $user->addAttribute($smallSize); |
||
| 162 | $userManager->updateUser($user); |
||
| 163 | */ |
||
| 164 | //$this->get('session')->remove('id_session'); |
||
| 165 | |||
| 166 | return $this->render( |
||
| 167 | '@ChamiloCore/Index/index.html.twig', |
||
| 168 | [ |
||
| 169 | 'content' => '', |
||
| 170 | 'announcements_block' => $announcementsBlock, |
||
| 171 | //'home_page_block' => $pageController->returnHomePage() |
||
| 204 |