1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the wow-apps/symfony-proxybonanza project |
4
|
|
|
* https://github.com/wow-apps/symfony-proxybonanza |
5
|
|
|
* |
6
|
|
|
* (c) 2016 WoW-Apps |
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 WowApps\ProxybonanzaBundle\Repository; |
13
|
|
|
|
14
|
|
|
use WowApps\ProxybonanzaBundle\Entity\Plan; |
15
|
|
|
use WowApps\ProxybonanzaBundle\Entity\Proxy; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class ProxiesRepository |
19
|
|
|
* @author Alexey Samara <[email protected]> |
20
|
|
|
* @package wow-apps/symfony-proxybonanza |
21
|
|
|
*/ |
22
|
|
|
class ProxiesRepository extends AbstractRepository |
23
|
|
|
{ |
24
|
|
|
public function empty() |
25
|
|
|
{ |
26
|
|
|
$queryBuilder = $this->pdoDB->createQueryBuilder(); |
|
|
|
|
27
|
|
|
$queryBuilder->delete(Proxy::TABLE_NAME); |
28
|
|
|
$queryBuilder->execute(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param \ArrayObject|Plan[] $pbPlans |
33
|
|
|
* @return bool |
34
|
|
|
*/ |
35
|
|
|
public function insertProxies(\ArrayObject $pbPlans): bool |
36
|
|
|
{ |
37
|
|
|
if (!$pbPlans->count()) { |
38
|
|
|
return false; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** @var Plan $pbPlan */ |
42
|
|
|
foreach ($pbPlans as $pbPlan) { |
43
|
|
|
if (!$pbPlan->getProxy()->count()) { |
44
|
|
|
continue; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** @var Proxy $proxy */ |
48
|
|
|
foreach ($pbPlan->getProxy() as $proxy) { |
49
|
|
|
$this->entityManager->persist($proxy); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$this->entityManager->flush(); |
54
|
|
|
|
55
|
|
|
return true; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param Plan|null $pbPlan |
60
|
|
|
* @return \ArrayObject|Proxy[] |
61
|
|
|
*/ |
62
|
|
|
public function getLocalProxies(Plan $pbPlan = null): \ArrayObject |
63
|
|
|
{ |
64
|
|
|
$proxies = new \ArrayObject(); |
65
|
|
|
|
66
|
|
|
if (is_null($pbPlan)) { |
67
|
|
|
$doctrineResult = $this->findAll(); |
68
|
|
|
} else { |
69
|
|
|
$doctrineResult = $this->findBy(['proxyPlan' => $pbPlan->getId()]); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** @var Proxy $proxy */ |
73
|
|
|
foreach ($doctrineResult as $proxy) { |
74
|
|
|
$proxies->offsetSet($proxy->getProxyId(), $proxy); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
return $proxies; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.