1
|
|
|
<?php namespace Comodojo\Extender\Worklog; |
2
|
|
|
|
3
|
|
|
use \Comodojo\Foundation\Base\Configuration; |
4
|
|
|
use \Comodojo\Foundation\Base\ConfigurationTrait; |
5
|
|
|
use \Comodojo\Foundation\Events\Manager as EventsManager; |
6
|
|
|
use \Comodojo\Foundation\Logging\LoggerTrait; |
7
|
|
|
use \Comodojo\Foundation\Events\EventsTrait; |
8
|
|
|
use \Comodojo\Extender\Components\Database; |
9
|
|
|
use \Comodojo\Extender\Traits\EntityManagerTrait; |
10
|
|
|
use \Comodojo\Extender\Orm\Entities\Worklog; |
11
|
|
|
use \Comodojo\Extender\Events\WorklogEvent; |
12
|
|
|
use \Doctrine\ORM\EntityManager; |
13
|
|
|
use \Psr\Log\LoggerInterface; |
14
|
|
|
use \Exception; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @package Comodojo Extender |
18
|
|
|
* @author Marco Giovinazzi <[email protected]> |
19
|
|
|
* @license MIT |
20
|
|
|
* |
21
|
|
|
* LICENSE: |
22
|
|
|
* |
23
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
24
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
25
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
26
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
27
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
28
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
29
|
|
|
* THE SOFTWARE. |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
class Manager { |
33
|
|
|
|
34
|
|
|
use ConfigurationTrait; |
35
|
|
|
use LoggerTrait; |
36
|
|
|
use EventsTrait; |
37
|
|
|
use EntityManagerTrait; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Class constructor |
41
|
|
|
* |
42
|
|
|
* @param Configuration $configuration |
43
|
|
|
* @param LoggerInterface $logger |
44
|
|
|
* @param TasksTable $tasks |
|
|
|
|
45
|
|
|
* @param EventsManager $events |
46
|
|
|
* @param EntityManager $em |
47
|
|
|
*/ |
48
|
|
View Code Duplication |
public function __construct( |
|
|
|
|
49
|
|
|
Configuration $configuration, |
50
|
|
|
LoggerInterface $logger, |
51
|
|
|
EventsManager $events, |
52
|
|
|
EntityManager $em = null |
53
|
|
|
) { |
54
|
|
|
|
55
|
|
|
$this->setConfiguration($configuration); |
56
|
|
|
$this->setLogger($logger); |
57
|
|
|
$this->setEvents($events); |
58
|
|
|
|
59
|
|
|
$em = is_null($em) ? Database::init($configuration)->getEntityManager() : $em; |
60
|
|
|
$this->setEntityManager($em); |
61
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function count() { |
65
|
|
|
|
66
|
|
|
$em = $this->getEntityManager(); |
67
|
|
|
|
68
|
|
|
$query = $em->createQuery('SELECT COUNT(w.id) FROM Comodojo\Extender\Orm\Entities\Worklog w'); |
69
|
|
|
|
70
|
|
|
return $query->getSingleScalarResult(); |
71
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function get( |
75
|
|
|
array $filter = [], |
76
|
|
|
$limit = 10, |
77
|
|
|
$offset = 0, |
78
|
|
|
$reverse = false |
79
|
|
|
) { |
80
|
|
|
|
81
|
|
|
$em = $this->getEntityManager(); |
82
|
|
|
|
83
|
|
|
return $em->getRepository('Comodojo\Extender\Orm\Entities\Worklog') |
84
|
|
|
->findBy( |
85
|
|
|
$filter, |
86
|
|
|
['id' => $reverse ? 'DESC' : 'ASC'], |
87
|
|
|
$limit, |
88
|
|
|
$offset |
89
|
|
|
); |
90
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getOne(array $filter) { |
94
|
|
|
|
95
|
|
|
$em = $this->getEntityManager(); |
96
|
|
|
|
97
|
|
|
return $em->getRepository('Comodojo\Extender\Orm\Entities\Worklog') |
98
|
|
|
->findOneBy($filter); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
} |
102
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.