Repository navigation
Expand file tree
/
Copy pathImageFactory.php
More file actions
69 lines (61 loc) · 2.3 KB
/
Copy pathImageFactory.php
File metadata and controls
69 lines (61 loc) · 2.3 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*************************************************************************************/
/* This file is part of the module ImageFactory. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace ImageFactory;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Thelia\Install\Database;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Module\BaseModule;
/**
* Class ImageFactory
* @package ImageFactory
* @author Gilles Bourgeat <gilles@thelia.net>
*/
class ImageFactory extends BaseModule
{
/** @var string */
const DOMAIN_NAME = 'imagefactory';
/**
* @inheritDoc
*/
public function install(ConnectionInterface $con = null)
{
(new Database($con))
->insertSql(null, [$this->getSetupDir() . "thelia.sql", $this->getSetupDir() . "insert.sql"]);
}
/**
* @inheritDoc
*/
public function update($currentVersion, $newVersion, ConnectionInterface $con = null)
{
$finder = (new Finder())
->files()
->name('#.*?\.sql#')
->in($this->getSetupDir() . 'update'. DS . 'sql')
;
$database = new Database($con);
/** @var SplFileInfo $updateSQLFile */
foreach ($finder as $updateSQLFile) {
if (version_compare($currentVersion, str_replace('.sql', '', $updateSQLFile->getFilename()), '<')) {
$database->insertSql(null, [$updateSQLFile->getPathname()]);
}
}
}
/**
* @return string
* @since 0.2.4
*/
protected function getSetupDir()
{
return __DIR__ . DS . 'setup' . DS;
}
}