Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
poolassembler.php
1<?php
3
7
8class PoolAssembler implements Assembler
9{
15 public static function toDTO(HttpRequest $request)
16 {
17 $pool = new Pool();
18 $id = (int)$request->get('id');
19 $filters = $request->get('filter');
20
21 if($id)
22 {
23 $pool->setId($id);
24 }
25
26 if (!empty($filters))
27 {
28 foreach ($filters as $key => $filter)
29 {
30 if (is_array($filter))
31 {
32 foreach ($filter as $filterValue)
33 {
34 $poolFilter = new Filter();
35 $pool->addFilter(
36 $poolFilter->setValue($filterValue)
37 ->setKey(strtolower($key))
38 );
39 }
40 }
41 }
42 }
43
44 $willExpire = \DateTime::createFromFormat('d.m.Y H:i:s',
45 $request->get('will_expire'));
46
47 if(!$willExpire)
48 {
49 $willExpire = new \DateTime();
50 $willExpire->setTime(23,59,59);
51 }
52
53 $pool->setMayContainAdultContent(json_decode($request->get('may_contain_adult_content')));
54 $pool->setPrivateName($request->get('private_name'));
55 $pool->setPublicDescription($request->get('public_description'));
56 $pool->setProjectId($request->get('project_id'));
57 $pool->setRewardPerAssignment($request->get('reward_per_assignment'));
58 $pool->setWillExpire(
59 $willExpire->format('Y-m-d\TH:i:s')
60 );
61
62 $pool->setDefaults(PoolDefaultsAssembler::toDTO($request));
63
64 return $pool;
65 }
66}