@@ -32,14 +32,14 @@ |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - public function findBySearchQuery(array $searchTerms){ |
|
| 35 | + public function findBySearchQuery(array $searchTerms) { |
|
| 36 | 36 | |
| 37 | 37 | $queryBuilder = $this->createQueryBuilder('p'); |
| 38 | 38 | |
| 39 | 39 | foreach ($searchTerms as $key => $term) { |
| 40 | 40 | $queryBuilder |
| 41 | - ->orWhere('p.name LIKE :term_' . $key) |
|
| 42 | - ->setParameter('term_' . $key, '%' . $term . '%'); |
|
| 41 | + ->orWhere('p.name LIKE :term_'.$key) |
|
| 42 | + ->setParameter('term_'.$key, '%'.$term.'%'); |
|
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getUsername(): string |
| 123 | 123 | { |
| 124 | - return (string)$this->userName; |
|
| 124 | + return (string) $this->userName; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function getPassword(): string |
| 150 | 150 | { |
| 151 | - return (string)$this->password; |
|
| 151 | + return (string) $this->password; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | public function setPassword(string $password): self |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | public function getImage() |
| 186 | 186 | { |
| 187 | - if($this->image === ""){ |
|
| 187 | + if ($this->image === "") { |
|
| 188 | 188 | return ""; |
| 189 | 189 | } |
| 190 | 190 | return $this->image; |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | $this->verified, |
| 344 | 344 | $this->verifiedDateTime, |
| 345 | 345 | $this->updatedAt, |
| 346 | - )=unserialize($serialized, ['allowed_classes' => false]); |
|
| 346 | + ) = unserialize($serialized, ['allowed_classes' => false]); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -40,22 +40,22 @@ |
||
| 40 | 40 | $fixedTag = new Tag(); |
| 41 | 41 | $fixedTag->setName("Starbug tag"); |
| 42 | 42 | |
| 43 | - foreach ($tricks as $trick){ |
|
| 44 | - $maxTags = rand(0,5); |
|
| 45 | - if($maxTags >0){ |
|
| 46 | - for($i=0; $i<=$maxTags; $i++){ |
|
| 43 | + foreach ($tricks as $trick) { |
|
| 44 | + $maxTags = rand(0, 5); |
|
| 45 | + if ($maxTags > 0) { |
|
| 46 | + for ($i = 0; $i <= $maxTags; $i++) { |
|
| 47 | 47 | |
| 48 | - $tagName = $faker->words(rand(1,3), true); |
|
| 48 | + $tagName = $faker->words(rand(1, 3), true); |
|
| 49 | 49 | //Avoid duplicate tags |
| 50 | 50 | $tag = $tagRepository->findOneBy(['name'=>$tagName]); |
| 51 | - if($tag === null){ |
|
| 52 | - $tag=new Tag(); |
|
| 51 | + if ($tag === null) { |
|
| 52 | + $tag = new Tag(); |
|
| 53 | 53 | $tag->setName($tagName); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $trick->addTag($tag); |
| 57 | 57 | |
| 58 | - if(rand(0,6)===1){ |
|
| 58 | + if (rand(0, 6) === 1) { |
|
| 59 | 59 | $trick->addTag($fixedTag); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | $comment = new Comment(); |
| 51 | 51 | $comment->setTrick($trick); |
| 52 | 52 | $comment->setUser($faker->randomElement($users)); |
| 53 | - $comment->setComment($faker->realText(rand(10,75))); |
|
| 53 | + $comment->setComment($faker->realText(rand(10, 75))); |
|
| 54 | 54 | |
| 55 | 55 | $manager->persist($comment); |
| 56 | 56 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | 'admin' |
| 34 | 34 | )) |
| 35 | 35 | ->setRoles(['ROLE_ADMIN']) |
| 36 | - ->setImage($faker->image('public/uploads/images',400,300, null, false) ) |
|
| 36 | + ->setImage($faker->image('public/uploads/images', 400, 300, null, false)) |
|
| 37 | 37 | ->setVerified(true) |
| 38 | 38 | ->setVerifiedHash(bin2hex(random_bytes(16))); |
| 39 | 39 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $user, |
| 48 | 48 | 'user' |
| 49 | 49 | )) |
| 50 | - ->setImage($faker->image('public/uploads/images',400,300, null, false) ) |
|
| 50 | + ->setImage($faker->image('public/uploads/images', 400, 300, null, false)) |
|
| 51 | 51 | ->setVerified(true) |
| 52 | 52 | ->setVerifiedHash(bin2hex(random_bytes(16))); |
| 53 | 53 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | //Adding extra users |
| 72 | 72 | |
| 73 | - for($i=0; $i<10; $i++){ |
|
| 73 | + for ($i = 0; $i < 10; $i++) { |
|
| 74 | 74 | $user = new User(); |
| 75 | 75 | $user->setEmail('user'.$i.'@localhost.com') |
| 76 | 76 | ->setUserName('user'.$i) |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | ->setVerifiedHash(bin2hex(random_bytes(16))); |
| 84 | 84 | |
| 85 | 85 | //Not all users will have an image |
| 86 | - if(rand(0,2)>=1){ |
|
| 87 | - $user->setImage($faker->image('public/uploads/images',400,300, null, false) ); |
|
| 86 | + if (rand(0, 2) >= 1) { |
|
| 87 | + $user->setImage($faker->image('public/uploads/images', 400, 300, null, false)); |
|
| 88 | 88 | } |
| 89 | 89 | // $product = new Product(); |
| 90 | 90 | $manager->persist($user); |
@@ -15,19 +15,19 @@ |
||
| 15 | 15 | $faker = Factory::create(); |
| 16 | 16 | |
| 17 | 17 | $categoryList = array(); |
| 18 | - for($i=0; $i<5; $i++){ |
|
| 18 | + for ($i = 0; $i < 5; $i++) { |
|
| 19 | 19 | $category = new Category(); |
| 20 | 20 | $categoryList[] = $category->setName($faker->sentence(5)); |
| 21 | 21 | $manager->persist($category); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - for ($i=0; $i<25; $i++){ |
|
| 24 | + for ($i = 0; $i < 25; $i++) { |
|
| 25 | 25 | $trick = new Trick(); |
| 26 | 26 | $trick |
| 27 | - ->setName($faker->words(rand(1,5), true)) |
|
| 28 | - ->setText($faker->paragraph(rand(3,20))) |
|
| 27 | + ->setName($faker->words(rand(1, 5), true)) |
|
| 28 | + ->setText($faker->paragraph(rand(3, 20))) |
|
| 29 | 29 | ->setCreatedAt($faker->dateTimeThisDecade()) |
| 30 | - ->setCategory($categoryList[rand(0,4)]) |
|
| 30 | + ->setCategory($categoryList[rand(0, 4)]) |
|
| 31 | 31 | ; |
| 32 | 32 | |
| 33 | 33 | $manager->persist($trick); |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | use Symfony\Component\Form\FormBuilderInterface; |
| 10 | 10 | use Symfony\Component\OptionsResolver\OptionsResolver; |
| 11 | 11 | |
| 12 | -class CommentType extends AbstractType{ |
|
| 12 | +class CommentType extends AbstractType { |
|
| 13 | 13 | |
| 14 | 14 | public function buildForm(FormBuilderInterface $builder, array $options) |
| 15 | 15 | { |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | private $tagRepository; |
| 43 | 43 | |
| 44 | - public function __construct(EventDispatcherInterface $dispatcher, TrickHistory $trickHistory, TagRepository $tagRepository ) |
|
| 44 | + public function __construct(EventDispatcherInterface $dispatcher, TrickHistory $trickHistory, TagRepository $tagRepository) |
|
| 45 | 45 | { |
| 46 | 46 | $this->dispatcher = $dispatcher; |
| 47 | 47 | $this->trickHistory = $trickHistory; |
@@ -85,10 +85,10 @@ |
||
| 85 | 85 | * Checks if the user is admin or author of the comment. |
| 86 | 86 | * Thows a redirect to the trick show page |
| 87 | 87 | */ |
| 88 | - private function checkSecurity(Comment $comment){ |
|
| 89 | - if(!($this->isGranted('ROLE_ADMIN') || $this->getUser()->getId() === $comment->getUser()->getId())) |
|
| 88 | + private function checkSecurity(Comment $comment) { |
|
| 89 | + if (!($this->isGranted('ROLE_ADMIN') || $this->getUser()->getId() === $comment->getUser()->getId())) |
|
| 90 | 90 | { |
| 91 | - Throw new RedirectException($this->generateUrl('trick.show', ['id'=> $comment->getTrick()->getId(), 'slug'=> $comment->getTrick()->getSlug()]),"You are not allowed to edit this comment"); |
|
| 91 | + Throw new RedirectException($this->generateUrl('trick.show', ['id'=> $comment->getTrick()->getId(), 'slug'=> $comment->getTrick()->getSlug()]), "You are not allowed to edit this comment"); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |