1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Tinyissue package. |
5
|
|
|
* |
6
|
|
|
* (c) Mohamed Alsharaf <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Tinyissue\Repository\Project\Issue\Comment; |
13
|
|
|
|
14
|
|
|
use Tinyissue\Model; |
15
|
|
|
use Tinyissue\Model\Message\Queue; |
16
|
|
|
use Tinyissue\Model\Project\Issue\Comment as CommentModel; |
17
|
|
|
|
18
|
|
|
trait MessageQueuer |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Insert add comment to message queue. |
22
|
|
|
* |
23
|
|
|
* @param CommentModel $comment |
24
|
|
|
* @param Model\User $changeBy |
25
|
|
|
* |
26
|
|
|
* @return void |
27
|
|
|
*/ |
28
|
|
|
public function queueAdd(CommentModel $comment, Model\User $changeBy) |
29
|
|
|
{ |
30
|
|
|
// Skip message if issue closed |
31
|
|
|
if (!$comment->issue->isOpen()) { |
32
|
|
|
return; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
return (new Queue())->updater($changeBy)->queue(Queue::ADD_COMMENT, $comment, $changeBy); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Insert update comment to message queue. |
40
|
|
|
* |
41
|
|
|
* @param CommentModel $comment |
42
|
|
|
* @param Model\User $changeBy |
43
|
|
|
* |
44
|
|
|
* @return void |
45
|
|
|
*/ |
46
|
|
|
public function queueUpdate(CommentModel $comment, Model\User $changeBy) |
47
|
|
|
{ |
48
|
|
|
// Skip message if issue closed or nothing changed in comment |
49
|
|
|
if (!$comment->issue->isOpen() || !$comment->isDirty()) { |
50
|
|
|
return; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
return (new Queue())->updater($changeBy)->queue(Queue::UPDATE_COMMENT, $comment, $changeBy); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Insert delete comment to message queue. |
58
|
|
|
* |
59
|
|
|
* @param CommentModel $comment |
60
|
|
|
* @param Model\User $changeBy |
61
|
|
|
* |
62
|
|
|
* @return void |
63
|
|
|
*/ |
64
|
|
|
public function queueDelete(CommentModel $comment, Model\User $changeBy) |
65
|
|
|
{ |
66
|
|
|
// Skip message if issue closed |
67
|
|
|
if ($comment->issue instanceof Issue && !$comment->issue->isOpen()) { |
|
|
|
|
68
|
|
|
return; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return (new Queue())->updater($changeBy)->queueDelete(Queue::DELETE_COMMENT, $comment, $changeBy); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.