symfony-si /
symfony.si
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace AppBundle\Controller; |
||
| 4 | |||
| 5 | use AppBundle\Entity\Contact; |
||
| 6 | use AppBundle\Entity\Project; |
||
| 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache; |
||
| 8 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
||
| 9 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
||
| 10 | use Symfony\Component\Form\Extension\Core\Type\EmailType; |
||
| 11 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
||
| 12 | use Symfony\Component\Form\Extension\Core\Type\TextType; |
||
| 13 | use Symfony\Component\Form\Extension\Core\Type\TextareaType; |
||
| 14 | use Symfony\Component\HttpFoundation\RedirectResponse; |
||
| 15 | use Symfony\Component\HttpFoundation\Request; |
||
| 16 | use Symfony\Component\HttpFoundation\Response; |
||
| 17 | |||
| 18 | class DefaultController extends Controller |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @Route("/", name="homepage") |
||
| 22 | * @Cache(expires="tomorrow", public=true) |
||
| 23 | */ |
||
| 24 | public function indexAction() |
||
| 25 | { |
||
| 26 | $posts = $this->get('AppBundle\Repository\PostRepository')->findLatest(); |
||
| 27 | |||
| 28 | $jsonData = json_decode(file_get_contents('http://knpbundles.com/newest.json'), true); |
||
| 29 | |||
| 30 | return $this->render('default/index.html.twig', [ |
||
| 31 | 'posts' => $posts, |
||
| 32 | 'bundles' => $jsonData['results'] |
||
| 33 | ]); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @Route("/copyrights", name="copyrights") |
||
| 38 | * @param Request $request |
||
| 39 | * @return Response |
||
| 40 | */ |
||
| 41 | public function copyrightAction(Request $request) |
||
|
0 ignored issues
–
show
|
|||
| 42 | { |
||
| 43 | return $this->render('default/copyright.html.twig'); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @Route("/join-us", name="join") |
||
| 48 | * @param Request $request |
||
| 49 | * @return Response |
||
| 50 | */ |
||
| 51 | public function joinAction(Request $request) |
||
|
0 ignored issues
–
show
|
|||
| 52 | { |
||
| 53 | return $this->render('default/join.html.twig'); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @Route("/contact", name="contact") |
||
| 58 | * @Cache(maxage="20", public=true) |
||
| 59 | * |
||
| 60 | * @param Request $request |
||
| 61 | * @return RedirectResponse|Response |
||
| 62 | */ |
||
| 63 | public function contactAction(Request $request) |
||
| 64 | { |
||
| 65 | $contact = new Contact(); |
||
| 66 | |||
| 67 | $form = $this->createFormBuilder($contact) |
||
| 68 | ->add('name', TextType::class) |
||
| 69 | ->add('email', EmailType::class) |
||
| 70 | ->add('message', TextareaType::class) |
||
| 71 | ->add('send', SubmitType::class) |
||
| 72 | ->getForm(); |
||
| 73 | |||
| 74 | $form->handleRequest($request); |
||
| 75 | |||
| 76 | if($form->isSubmitted() && $form->isValid()) { |
||
| 77 | // send email to admin |
||
| 78 | $message = \Swift_Message::newInstance() |
||
| 79 | ->setSubject('Message from Symfony.si') |
||
| 80 | ->setFrom($contact->getEmail()) |
||
| 81 | ->setTo($this->container->getParameter('symfonysi_admin_email')) |
||
| 82 | ->setBody( |
||
| 83 | $this->renderView( |
||
| 84 | 'emails/email.txt.twig', |
||
| 85 | [ |
||
| 86 | 'name' => $contact->getName(), |
||
| 87 | 'email' => $contact->getEmail(), |
||
| 88 | 'message' => $contact->getMessage() |
||
| 89 | ] |
||
| 90 | ) |
||
| 91 | ) |
||
| 92 | ; |
||
| 93 | $this->get('mailer')->send($message); |
||
| 94 | |||
| 95 | return $this->redirect($this->generateUrl('contact_success')); |
||
| 96 | } |
||
| 97 | |||
| 98 | return $this->render('default/contact.html.twig', [ |
||
| 99 | 'form' => $form->createView(), |
||
| 100 | ]); |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @Route("/contact-succeeded", name="contact_success") |
||
| 105 | * @param Request $request |
||
| 106 | * @return Response |
||
| 107 | */ |
||
| 108 | public function contactSuccessAction(Request $request) |
||
|
0 ignored issues
–
show
|
|||
| 109 | { |
||
| 110 | return $this->render('default/contactSuccess.html.twig'); |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @Route("/contributors", name="contributors") |
||
| 115 | * @param Request $request |
||
| 116 | * @return Response |
||
| 117 | */ |
||
| 118 | public function contributorsAction(Request $request) |
||
|
0 ignored issues
–
show
|
|||
| 119 | { |
||
| 120 | $cache = $this->get('cache.app'); |
||
| 121 | $contributorsFromCache = $cache->getItem('app.contributors'); |
||
| 122 | if (!$contributorsFromCache->isHit()) { |
||
| 123 | $client = new \Github\Client(); |
||
| 124 | |||
| 125 | $repos = [ |
||
| 126 | ['symfony-si', 'symfony.si'], |
||
| 127 | ['symfony-si', 'symfony-must-watch'], |
||
| 128 | ['symfony-si', 'symfony-resources'], |
||
| 129 | ['symfony-si', 'symfony-cheatsheet'], |
||
| 130 | ]; |
||
| 131 | $contributors = []; |
||
| 132 | foreach ($repos as $repo) { |
||
| 133 | $organizationApi = $client->api('repo'); |
||
| 134 | $paginator = new \Github\ResultPager($client); |
||
| 135 | $parameters = [$repo[0], $repo[1]]; |
||
| 136 | $repoContributors = $paginator->fetchAll($organizationApi, 'contributors', $parameters); |
||
| 137 | foreach ($repoContributors as $contributor) { |
||
| 138 | $contributors[$contributor['login']] = [ |
||
| 139 | 'html_url' => $contributor['html_url'], |
||
| 140 | 'avatar_url' => $contributor['avatar_url'], |
||
| 141 | 'contributions' => (isset($contributors[$contributor['login']]['contributions'])) ? $contributors[$contributor['login']]['contributions'] + $contributor['contributions'] : $contributor['contributions'], |
||
| 142 | ]; |
||
| 143 | } |
||
| 144 | } |
||
| 145 | |||
| 146 | uasort($contributors, function($a, $b) { |
||
| 147 | return $a['contributions'] <=> $b['contributions']; |
||
| 148 | }); |
||
| 149 | |||
| 150 | $contributors = array_reverse($contributors); |
||
| 151 | |||
| 152 | $contributorsFromCache->set($contributors); |
||
| 153 | $cache->save($contributorsFromCache); |
||
| 154 | } else { |
||
| 155 | $contributors = $contributorsFromCache->get(); |
||
| 156 | } |
||
| 157 | |||
| 158 | return $this->render('default/contributors.html.twig', [ |
||
| 159 | 'contributors' => $contributors |
||
| 160 | ]); |
||
| 161 | } |
||
| 162 | |||
| 163 | /** |
||
| 164 | * @Route("/resources", name="resources") |
||
| 165 | * @param Request $request |
||
| 166 | * @return Response |
||
| 167 | */ |
||
| 168 | public function resourcesAction(Request $request) |
||
|
0 ignored issues
–
show
|
|||
| 169 | { |
||
| 170 | $file = $this->get('kernel')->getRootDir().'/../vendor/symfony-si/symfony-resources/README.md'; |
||
| 171 | $content = (file_exists($file)) ? file_get_contents($file) : '<h1>Symfony resources</h1>'; |
||
| 172 | |||
| 173 | return $this->render('default/resources.html.twig', ['html' => $content]); |
||
| 174 | } |
||
| 175 | |||
| 176 | /** |
||
| 177 | * @Route("/cheatsheet", name="cheatsheet") |
||
| 178 | * @return Response |
||
| 179 | */ |
||
| 180 | public function cheatsheetAction() |
||
| 181 | { |
||
| 182 | $file = $this->get('kernel')->getRootDir().'/../vendor/symfony-si/symfony-cheatsheet/README.md'; |
||
| 183 | $content = (file_exists($file)) ? file_get_contents($file) : '<h1>Symfony cheat sheet</h1>'; |
||
| 184 | |||
| 185 | return $this->render('default/cheatsheet.html.twig', ['html' => $content]); |
||
| 186 | } |
||
| 187 | |||
| 188 | /** |
||
| 189 | * @Route("/ecosystem", name="ecosystem") |
||
| 190 | * @return Response |
||
| 191 | */ |
||
| 192 | public function ecosystemAction() |
||
| 193 | { |
||
| 194 | $projects = []; |
||
| 195 | $project = new Project(); |
||
| 196 | $project->setTitle('Symfony Framework'); |
||
| 197 | $project->setDescription('Prevod ogrodja Symfony'); |
||
| 198 | $project->setLink('https://github.com/symfony/symfony'); |
||
| 199 | $project->setRepository('https://github.com/symfony/symfony'); |
||
| 200 | $project->setSlug('symfony'); |
||
| 201 | $projects[] = $project; |
||
| 202 | |||
| 203 | $project = new Project(); |
||
| 204 | $project->setTitle('Symfony.com'); |
||
| 205 | $project->setDescription('Symfony.com website'); |
||
| 206 | $project->setLink('https://github.com/symfony/symfony-marketing'); |
||
| 207 | $project->setRepository('https://github.com/symfony/symfony-marketing'); |
||
| 208 | $project->setSlug('symfony-marketing'); |
||
| 209 | $projects[] = $project; |
||
| 210 | |||
| 211 | $project = new Project(); |
||
| 212 | $project->setTitle('Sonata Project'); |
||
| 213 | $project->setDescription('Prevod projekta Sonata Project'); |
||
| 214 | $project->setLink('https://github.com/sonata-project'); |
||
| 215 | $project->setRepository('https://github.com/sonata-project'); |
||
| 216 | $project->setSlug('sonata-project'); |
||
| 217 | $projects[] = $project; |
||
| 218 | |||
| 219 | $project = new Project(); |
||
| 220 | $project->setTitle('EasyAdminBundle'); |
||
| 221 | $project->setDescription('Prevod Symfony paketa EasyAdminBundle'); |
||
| 222 | $project->setLink('https://github.com/javiereguiluz/EasyAdminBundle'); |
||
| 223 | $project->setRepository('https://github.com/javiereguiluz/EasyAdminBundle'); |
||
| 224 | $project->setSlug('easy-admin-bundle'); |
||
| 225 | $projects[] = $project; |
||
| 226 | |||
| 227 | $project = new Project(); |
||
| 228 | $project->setTitle('PHP: The Right Way'); |
||
| 229 | $project->setDescription('An easy-to-read, quick reference for PHP best practices, accepted coding standards, and links to authoritative tutorials around the Web'); |
||
| 230 | $project->setLink('http://sl.phptherightway.com'); |
||
| 231 | $project->setRepository('https://github.com/symfony-si/php-the-right-way'); |
||
| 232 | $project->setSlug('php-the-right-way'); |
||
| 233 | $projects[] = $project; |
||
| 234 | |||
| 235 | $project = new Project(); |
||
| 236 | $project->setTitle('PHP FIG'); |
||
| 237 | $project->setDescription('PHP Standards Recommendations'); |
||
| 238 | $project->setLink('http://php-fig.org'); |
||
| 239 | $project->setRepository('https://github.com/php-fig/fig-standards'); |
||
| 240 | $project->setSlug('php-fig-standards'); |
||
| 241 | $projects[] = $project; |
||
| 242 | |||
| 243 | $project = new Project(); |
||
| 244 | $project->setTitle('Magento'); |
||
| 245 | $project->setDescription('Magento 1.x Translation'); |
||
| 246 | $project->setLink('http://magento.com/'); |
||
| 247 | $project->setRepository('https://github.com/symfony-si/magento1-sl-si'); |
||
| 248 | $project->setSlug('magento1'); |
||
| 249 | $projects[] = $project; |
||
| 250 | |||
| 251 | $project = new Project(); |
||
| 252 | $project->setTitle('Magento 2'); |
||
| 253 | $project->setDescription('Magento 2.x Translation'); |
||
| 254 | $project->setLink('http://magento.com/'); |
||
| 255 | $project->setRepository('https://github.com/symfony-si/magento2-sl_si'); |
||
| 256 | $project->setSlug('magento2'); |
||
| 257 | $projects[] = $project; |
||
| 258 | |||
| 259 | $project = new Project(); |
||
| 260 | $project->setTitle('Semver.org'); |
||
| 261 | $project->setDescription('Semantic Versions'); |
||
| 262 | $project->setLink('http://semver.org/lang/sl'); |
||
| 263 | $project->setRepository('https://github.com/mojombo/semver.org'); |
||
| 264 | $project->setSlug('semantic-versioning'); |
||
| 265 | $projects[] = $project; |
||
| 266 | |||
| 267 | $project = new Project(); |
||
| 268 | $project->setTitle('The PHP League'); |
||
| 269 | $project->setDescription('Slovenski prevod strani PHP lige paketov'); |
||
| 270 | $project->setLink('http://thephpleague.com/sl/'); |
||
| 271 | $project->setRepository('https://github.com/thephpleague/thephpleague.github.io'); |
||
| 272 | $project->setSlug('the-php-league'); |
||
| 273 | $projects[] = $project; |
||
| 274 | |||
| 275 | $project = new Project(); |
||
| 276 | $project->setTitle('Yii framework'); |
||
| 277 | $project->setDescription('Slovenski prevod ogrodja Yii 2'); |
||
| 278 | $project->setLink('https://github.com/yiisoft/yii2'); |
||
| 279 | $project->setRepository('https://github.com/yiisoft/yii2'); |
||
| 280 | $project->setSlug('the-php-league'); |
||
| 281 | $projects[] = $project; |
||
| 282 | |||
| 283 | $project = new Project(); |
||
| 284 | $project->setTitle('Progit'); |
||
| 285 | $project->setDescription('Slovenski prevod knjige progit'); |
||
| 286 | $project->setLink('http://git-scm.com/book/sl'); |
||
| 287 | $project->setRepository('https://github.com/progit/progit2-sl'); |
||
| 288 | $project->setSlug('progit'); |
||
| 289 | $projects[] = $project; |
||
| 290 | |||
| 291 | $project = new Project(); |
||
| 292 | $project->setTitle('Zend Framework 2'); |
||
| 293 | $project->setDescription('Slovenian translation of Zend Framework 2'); |
||
| 294 | $project->setLink('https://github.com/zendframework/zf2'); |
||
| 295 | $project->setRepository('https://github.com/zendframework/zf2'); |
||
| 296 | $project->setSlug('zend-framework-2'); |
||
| 297 | $projects[] = $project; |
||
| 298 | |||
| 299 | return $this->render( |
||
| 300 | 'default/ecosystem.html.twig', |
||
| 301 | ['projects' => $projects] |
||
| 302 | ); |
||
| 303 | } |
||
| 304 | |||
| 305 | /** |
||
| 306 | * @Route("/code-of-conduct", name="conduct") |
||
| 307 | * @Cache(expires="tomorrow", public=true) |
||
| 308 | * |
||
| 309 | * @return Response |
||
| 310 | */ |
||
| 311 | public function conductAction() |
||
| 312 | { |
||
| 313 | $file = $this->get('kernel')->getRootDir().'/../vendor/symfony-si/conduct/README.md'; |
||
| 314 | $content = (file_exists($file)) ? file_get_contents($file) : '<h1>Symfony.si Code of Conduct</h1>'; |
||
| 315 | |||
| 316 | return $this->render('default/conduct.html.twig', ['content' => $content]); |
||
| 317 | } |
||
| 318 | } |
||
| 319 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.