-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocumentsSharing.php
More file actions
106 lines (89 loc) · 3.28 KB
/
Copy pathDocumentsSharing.php
File metadata and controls
106 lines (89 loc) · 3.28 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/**
* This class has been generated by TheliaStudio
* For more information, see https://github.com/thelia-modules/TheliaStudio
*/
namespace DocumentsSharing;
use Symfony\Component\Filesystem\Filesystem;
use Thelia\Model\ConfigQuery;
use Thelia\Module\BaseModule;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Install\Database;
use Thelia\Action\Document;
use Thelia\Log\Tlog;
/**
* Class DocumentsSharing
* @package DocumentsSharing
*/
class DocumentsSharing extends BaseModule
{
const MESSAGE_DOMAIN = "documentssharing";
const ROUTER = "router.documentssharing";
protected $useFallbackTemplate = true;
private $jsPath;
private $webJsPath;
private $webMediaPath;
private $webMediaEnvPath;
public function __construct()
{
$this->jsPath = __DIR__.DS.'Resources';
$this->webJsPath = THELIA_WEB_DIR.'documentssharing';
$this->webMediaPath = THELIA_WEB_DIR.'media/documentssharing';
}
public function postActivation(ConnectionInterface $con = null)
{
$database = new Database($con);
$database->insertSql(null, [__DIR__ . "/Config/create.sql", __DIR__ . "/Config/insert.sql"]);
$fileSystem = new Filesystem();
//Check for environment
if ($env = $this->getContainer()->getParameter('kernel.environment')) {
//Check for backward compatibility
if ($env !== "prod" && $env !== "dev") {
//Remove separtion between dev and prod in particular environment
$env = str_replace('_dev', '', $env);
$this->webMediaEnvPath = $this->webMediaPath.DS.$env;
}
}
// Create symbolic links or hard copy in the web directory
// (according to \Thelia\Action\Document::CONFIG_DELIVERY_MODE),
// to make the TinyMCE code available.
if (false === $fileSystem->exists($this->webJsPath)) {
if (ConfigQuery::read(Document::CONFIG_DELIVERY_MODE) === 'symlink') {
$fileSystem->symlink($this->jsPath, $this->webJsPath);
} else {
$fileSystem->mirror($this->jsPath, $this->webJsPath);
}
}
// Create the media directory in the web root , if required
if (null !== $this->webMediaEnvPath) {
if (false === $fileSystem->exists($this->webMediaEnvPath)) {
$fileSystem->mkdir($this->webMediaEnvPath.DS.'upload');
$fileSystem->mkdir($this->webMediaEnvPath.DS.'thumbs');
}
} else {
if (false === $fileSystem->exists($this->webMediaPath)) {
$fileSystem->mkdir($this->webMediaPath.DS.'upload');
$fileSystem->mkdir($this->webMediaPath.DS.'thumbs');
}
}
}
/**
* @inheritdoc
*/
public function postDeactivation(ConnectionInterface $con = null)
{
$fileSystem = new Filesystem();
$fileSystem->remove($this->webJsPath);
}
/**
* @inheritdoc
*/
public function destroy(ConnectionInterface $con = null, $deleteModuleData = false)
{
// If we have to delete module data, remove the media directory.
if ($deleteModuleData) {
$fileSystem = new Filesystem();
$fileSystem->remove($this->webMediaPath);
}
}
}