forked from thelia-modules/CustomerGroupAcl
/
CustomerGroupAcl.php
51 lines (43 loc) · 1.41 KB
/
CustomerGroupAcl.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
48
49
50
51
<?php
namespace CustomerGroupAcl;
use CustomerGroupAcl\ACL\AclXmlFileloader;
use CustomerGroupAcl\Model\AclQuery;
use CustomerGroupAcl\Model\CustomerGroupAclQuery;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Install\Database;
use Thelia\Model\Module;
use Thelia\Model\ModuleQuery;
use Thelia\Module\BaseModule;
class CustomerGroupAcl extends BaseModule
{
const DOMAIN_MESSAGE = "customergroupacl";
public function preActivation(ConnectionInterface $con = null)
{
try {
// Try find Acl DB Model
AclQuery::create()->findOne();
CustomerGroupAclQuery::create()->findOne();
} catch (\Exception $e) {
$database = new Database($con);
$database->insertSql(null, [__DIR__ . DS . 'Config' . DS . 'thelia.sql']);
}
return true;
}
public function postActivation(ConnectionInterface $con = null)
{
$aclXmlFileloader = new AclXmlFileloader(Translator::getInstance());
$modules = ModuleQuery::create()->findByActivate(BaseModule::IS_ACTIVATED);
/** @var Module $module */
foreach ($modules as $module) {
$aclXmlFileloader->load($module);
}
}
/**
* @return Module This module.
*/
public static function getModule()
{
return ModuleQuery::create()->findOneByCode(static::getModuleCode());
}
}