|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Canvas\Mapper; |
|
6
|
|
|
|
|
7
|
|
|
use AutoMapperPlus\CustomMapper\CustomMapper; |
|
8
|
|
|
use Canvas\Models\Subscription; |
|
9
|
|
|
|
|
10
|
|
|
// You can either extend the CustomMapper, or just implement the MapperInterface |
|
11
|
|
|
// directly. |
|
12
|
|
|
class CompaniesGroupsMapper extends CustomMapper |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @param Baka\Database\CustomFilters\CustomFilters $filter |
|
|
|
|
|
|
16
|
|
|
* @param \Canvas\Dto\CustomFilter $filterSchema |
|
|
|
|
|
|
17
|
|
|
* @return ListSchema |
|
18
|
|
|
*/ |
|
19
|
|
|
public function mapToObject($companiesGroup, $companiesGroupDto, array $context = []) |
|
20
|
|
|
{ |
|
21
|
|
|
$companiesGroupDto->id = $companiesGroup->getId(); |
|
22
|
|
|
$companiesGroupDto->name = $companiesGroup->name; |
|
23
|
|
|
$companiesGroupDto->users_id = $companiesGroup->users_id; |
|
24
|
|
|
$companiesGroupDto->apps_id = $companiesGroup->apps_id; |
|
25
|
|
|
$companyArray = []; |
|
26
|
|
|
/** |
|
27
|
|
|
* Let's find all companies and their apps plans |
|
28
|
|
|
*/ |
|
29
|
|
|
foreach ($companiesGroup->getCompanies() as $company) { |
|
30
|
|
|
|
|
31
|
|
|
$subscription = Subscription::findFirst([ |
|
32
|
|
|
'conditions'=> 'user_id = ?0 and companies_id = ?1 and is_deleted = 0', |
|
33
|
|
|
'bind'=>[$companiesGroup->users_id,$company->id] |
|
34
|
|
|
]); |
|
35
|
|
|
|
|
36
|
|
|
foreach ($company as $key => $value) { |
|
37
|
|
|
$companyArray[$key] = $value; |
|
38
|
|
|
$companyArray['app_plan'] = $subscription->getAppPlan(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$companiesGroupDto->companies[] = $companyArray; |
|
42
|
|
|
} |
|
43
|
|
|
$companiesGroupDto->created_at = $companiesGroup->created_at; |
|
44
|
|
|
$companiesGroupDto->updated_at = $companiesGroup->updated_at; |
|
45
|
|
|
$companiesGroupDto->is_deleted = $companiesGroup->is_deleted; |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
return $companiesGroupDto; |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
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
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.