|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the CCDNForum ForumBundle |
|
5
|
|
|
* |
|
6
|
|
|
* (c) CCDN (c) CodeConsortium <http://www.codeconsortium.com/> |
|
7
|
|
|
* |
|
8
|
|
|
* Available on github <http://www.github.com/codeconsortium/> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace CCDNForum\ForumBundle\Model\FrontModel; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
17
|
|
|
use CCDNForum\ForumBundle\Model\FrontModel\BaseModel; |
|
18
|
|
|
use CCDNForum\ForumBundle\Model\FrontModel\ModelInterface; |
|
19
|
|
|
use CCDNForum\ForumBundle\Entity\Board; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* |
|
23
|
|
|
* @category CCDNForum |
|
24
|
|
|
* @package ForumBundle |
|
25
|
|
|
* |
|
26
|
|
|
* @author Reece Fowell <[email protected]> |
|
27
|
|
|
* @license http://opensource.org/licenses/MIT MIT |
|
28
|
|
|
* @version Release: 2.0 |
|
29
|
|
|
* @link https://github.com/codeconsortium/CCDNForumForumBundle |
|
30
|
|
|
* |
|
31
|
|
|
*/ |
|
32
|
|
|
class BoardModel extends BaseModel implements ModelInterface |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* |
|
36
|
|
|
* @access public |
|
37
|
|
|
* @return \CCDNForum\ForumBundle\Entity\Board |
|
38
|
|
|
*/ |
|
39
|
|
|
public function createBoard() |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->getManager()->createBoard(); |
|
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* |
|
46
|
|
|
* @access public |
|
47
|
|
|
* @return \Doctrine\Common\Collection\ArrayCollection |
|
48
|
|
|
*/ |
|
49
|
|
|
public function findAllBoards() |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->getRepository()->findAllBoards(); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* |
|
56
|
|
|
* @access public |
|
57
|
|
|
* @param int $categoryId |
|
58
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection |
|
59
|
|
|
*/ |
|
60
|
|
|
public function findAllBoardsForCategoryById($categoryId) |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->getRepository()->findAllBoardsForCategoryById($categoryId); |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* |
|
67
|
|
|
* @access public |
|
68
|
|
|
* @param int $forumId |
|
69
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection |
|
70
|
|
|
*/ |
|
71
|
|
|
public function findAllBoardsForForumById($forumId) |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->getRepository()->findAllBoardsForForumById($forumId); |
|
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* |
|
78
|
|
|
* @access public |
|
79
|
|
|
* @param int $boardId |
|
80
|
|
|
* @return \CCDNForum\ForumBundle\Entity\Board |
|
81
|
|
|
*/ |
|
82
|
|
|
public function findOneBoardById($boardId) |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->getRepository()->findOneBoardById($boardId); |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* |
|
89
|
|
|
* @access public |
|
90
|
|
|
* @param int $boardId |
|
91
|
|
|
* @return \CCDNForum\ForumBundle\Entity\Board |
|
92
|
|
|
*/ |
|
93
|
|
|
public function findOneBoardByIdWithCategory($boardId) |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->getRepository()->findOneBoardByIdWithCategory($boardId); |
|
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* |
|
100
|
|
|
* @access public |
|
101
|
|
|
* @return Array |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getBoardCount() |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->getRepository()->getBoardCount(); |
|
|
|
|
|
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* |
|
110
|
|
|
* @access public |
|
111
|
|
|
* @param \CCDNForum\ForumBundle\Entity\Board $board |
|
112
|
|
|
* @return \CCDNForum\ForumBundle\Model\Component\Manager\ManagerInterface |
|
113
|
|
|
*/ |
|
114
|
|
|
public function saveBoard(Board $board) |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->getManager()->saveBoard($board); |
|
|
|
|
|
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* |
|
121
|
|
|
* @access public |
|
122
|
|
|
* @param \CCDNForum\ForumBundle\Entity\Board $board |
|
123
|
|
|
* @return \CCDNForum\ForumBundle\Model\Component\Manager\ManagerInterface |
|
124
|
|
|
*/ |
|
125
|
|
|
public function updateBoard(Board $board) |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->getManager()->updateBoard($board); |
|
|
|
|
|
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* |
|
132
|
|
|
* @access public |
|
133
|
|
|
* @param \CCDNForum\ForumBundle\Entity\Board $board |
|
134
|
|
|
* @return \CCDNForum\ForumBundle\Model\Component\Manager\ManagerInterface |
|
135
|
|
|
*/ |
|
136
|
|
|
public function deleteBoard(Board $board) |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->getManager()->deleteBoard($board); |
|
|
|
|
|
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* |
|
143
|
|
|
* @access public |
|
144
|
|
|
* @param \Doctrine\Common\Collections\ArrayCollection $topics |
|
145
|
|
|
* @param \CCDNForum\ForumBundle\Entity\Board $board |
|
|
|
|
|
|
146
|
|
|
* @return \CCDNForum\ForumBundle\Model\Component\Manager\ManagerInterface |
|
147
|
|
|
*/ |
|
148
|
|
|
public function reassignTopicsToBoard(ArrayCollection $topics, Board $board = null) |
|
149
|
|
|
{ |
|
150
|
|
|
return $this->getManager()->reassignTopicsToBoard($topics, $board); |
|
|
|
|
|
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* |
|
155
|
|
|
* @access public |
|
156
|
|
|
* @param Array $boards |
|
157
|
|
|
* @param \CCDNForum\ForumBundle\Entity\Board $boardShift |
|
158
|
|
|
* @param int $direction |
|
159
|
|
|
* @return \CCDNForum\ForumBundle\Model\Component\Manager\ManagerInterface |
|
160
|
|
|
*/ |
|
161
|
|
|
public function reorderBoards($boards, Board $boardShift, $direction) |
|
162
|
|
|
{ |
|
163
|
|
|
return $this->getManager()->reorderBoards($boards, $boardShift, $direction); |
|
|
|
|
|
|
164
|
|
|
} |
|
165
|
|
|
} |
|
166
|
|
|
|
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: