forked from FriendsOfSymfony/FOSCommentBundle
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from bukhr/feature/upgrade-symfony-6
Feature - Upgrade Symfony 6
- Loading branch information
Showing
13 changed files
with
117 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,24 +11,26 @@ | |
|
||
namespace FOS\CommentBundle\Tests\Functional\Bundle\CommentBundle\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
/** | ||
* Test controller used in the functional tests for CommentBundle. | ||
* | ||
* @author Tim Nagel <[email protected]> | ||
*/ | ||
class CommentController extends Controller | ||
class CommentController extends AbstractController | ||
{ | ||
public function asyncAction($id) | ||
public function asyncAction($id): Response | ||
{ | ||
return $this->render('CommentBundle:Comment:async.html.twig', [ | ||
'id' => $id, | ||
]); | ||
} | ||
|
||
public function inlineAction(Request $request, $id) | ||
public function inlineAction(Request $request, $id): Response | ||
{ | ||
$thread = $this->container->get('fos_comment.manager.thread')->findThreadById($id); | ||
if (null === $thread) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,117 +18,67 @@ | |
use FOS\CommentBundle\Model\VotableCommentInterface; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
|
||
/** | ||
* @ORM\Entity | ||
* @ORM\Table(name="test_comment") | ||
* @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT") | ||
* | ||
* @author Tim Nagel <[email protected]> | ||
*/ | ||
#[ORM\Entity] | ||
#[ORM\Table(name: 'test_comment')] | ||
#[ORM\ChangeTrackingPolicy('DEFERRED_EXPLICIT')] | ||
class Comment extends BaseComment implements SignedCommentInterface, VotableCommentInterface | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\Column(type="integer") | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
#[ORM\Column(name: 'id', type: 'integer')] | ||
#[ORM\Id] | ||
#[ORM\GeneratedValue(strategy: 'AUTO')] | ||
protected $id; | ||
|
||
/** | ||
* Thread of this comment. | ||
* | ||
* @ORM\ManyToOne(targetEntity="Thread") | ||
* | ||
* @var Thread | ||
*/ | ||
|
||
#[ORM\ManyToOne(targetEntity: Thread::class)] | ||
protected $thread; | ||
|
||
/** | ||
* @ORM\Column(type="string", nullable=true) | ||
* | ||
* @var string | ||
*/ | ||
|
||
#[ORM\Column(type: 'string', nullable: true)] | ||
protected $author; | ||
|
||
/** | ||
* @ORM\Column(type="integer") | ||
* | ||
* @var int | ||
*/ | ||
|
||
#[ORM\Column(type: 'integer')] | ||
protected $score = 0; | ||
|
||
/** | ||
* @return Thread | ||
*/ | ||
public function getThread() | ||
|
||
public function getThread(): Thread | ||
{ | ||
return $this->thread; | ||
} | ||
|
||
/** | ||
* @param Thread $thread | ||
* | ||
* @return null | ||
*/ | ||
public function setThread(ThreadInterface $thread) | ||
public function setThread(ThreadInterface $thread): void | ||
{ | ||
$this->thread = $thread; | ||
} | ||
|
||
/** | ||
* Sets the author of the Comment. | ||
* | ||
* @param string $user | ||
*/ | ||
public function setAuthor(UserInterface $author) | ||
|
||
public function setAuthor(UserInterface $author): void | ||
{ | ||
$this->author = $author->getUsername(); | ||
$this->author = method_exists($author, 'getUsername') ? $author->getUsername() : $author->getUserIdentifier(); | ||
|
||
} | ||
|
||
/** | ||
* Gets the author of the Comment. | ||
* | ||
* @return string | ||
*/ | ||
public function getAuthor() | ||
public function getAuthor(): ?string | ||
{ | ||
return $this->author; | ||
} | ||
|
||
/** | ||
* Sets the score of the comment. | ||
* | ||
* @param int $score | ||
*/ | ||
public function setScore($score) | ||
public function setScore($score): void | ||
{ | ||
$this->score = $score; | ||
} | ||
|
||
/** | ||
* Returns the current score of the comment. | ||
* | ||
* @return int | ||
*/ | ||
public function getScore() | ||
public function getScore(): int | ||
{ | ||
return $this->score; | ||
} | ||
|
||
/** | ||
* Increments the comment score by the provided | ||
* value. | ||
* | ||
* @param int value | ||
* | ||
* @return int The new comment score | ||
*/ | ||
public function incrementScore($by = 1) | ||
public function incrementScore($by = 1): void | ||
{ | ||
$this->score += $by; | ||
} | ||
|
||
public function getAuthorName() | ||
public function getAuthorName(): string | ||
{ | ||
return $this->author ?: parent::getAuthorName(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,29 +14,21 @@ | |
use Doctrine\ORM\Mapping as ORM; | ||
use FOS\CommentBundle\Entity\Thread as BaseThread; | ||
|
||
/** | ||
* @ORM\Entity | ||
* @ORM\Table(name="test_thread") | ||
* @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT") | ||
* | ||
* @author Tim Nagel <[email protected]> | ||
*/ | ||
#[ORM\Entity] | ||
#[ORM\Table(name: 'test_thread')] | ||
#[ORM\ChangeTrackingPolicy('DEFERRED_EXPLICIT')] | ||
class Thread extends BaseThread | ||
{ | ||
/** | ||
* @var string | ||
* | ||
* @ORM\Id | ||
* @ORM\Column(type="string") | ||
*/ | ||
#[ORM\Id] | ||
#[ORM\Column(type: 'string')] | ||
protected $id; | ||
|
||
public function getId() | ||
public function getId(): ?string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function setId($id) | ||
public function setId($id): void | ||
{ | ||
$this->id = $id; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.