forked from thelia/thelia
/
AreaDeliveryModuleQuery.php
47 lines (40 loc) · 1.3 KB
/
AreaDeliveryModuleQuery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace Thelia\Model;
use Thelia\Model\Base\AreaDeliveryModuleQuery as BaseAreaDeliveryModuleQuery;
use Thelia\Module\BaseModule;
/**
* Skeleton subclass for performing query and update operations on the 'area_delivery_module' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class AreaDeliveryModuleQuery extends BaseAreaDeliveryModuleQuery
{
/**
* Check if a delivery module is suitable for the given country.
*
* @param Country $country
* @param Module $module
* @return null|AreaDeliveryModule
* @throws \Propel\Runtime\Exception\PropelException
*/
public function findByCountryAndModule(Country $country, Module $module)
{
$response = null;
$countryInAreaList = CountryAreaQuery::create()->filterByCountryId($country->getId())->find();
foreach ($countryInAreaList as $countryInArea) {
$response = $this->filterByAreaId($countryInArea->getAreaId())
->filterByModule($module)
->findOne();
if ($response !== null) {
break;
}
}
return $response;
}
}
// AreaDeliveryModuleQuery