Skip to content

Commit 60e1cd7

Browse files
fixed install routine for pimcore
1 parent 0f137b4 commit 60e1cd7

File tree

4 files changed

+111
-2
lines changed

4 files changed

+111
-2
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
namespace MinifyCssJsBundle\Install;
3+
use Pimcore\Extension\Bundle\Installer\AbstractInstaller;
4+
use Pimcore\Extension\Bundle\Installer\OutputWriterInterface;
5+
use Pimcore\Model\Document\DocType;
6+
use Pimcore\Db;
7+
use Pimcore\Model\Translation\Admin;
8+
use Pimcore\Model\DataObject;
9+
use Symfony\Component\Filesystem\Filesystem;
10+
11+
class Installer extends AbstractInstaller {
12+
13+
/**
14+
* @var string
15+
*/
16+
private $installSourcesPath;
17+
/**
18+
* @var Filesystem
19+
*/
20+
private $fileSystem;
21+
const LOCAL_CONFIG_PATH = '/bundles/MinifyCssJsBundle/config.yml';
22+
const LOCAL_CONFIG_BACKUP_PATH = '/bundles/MinifyCssJsBundle/config_backup.yml';
23+
24+
public function __construct(OutputWriterInterface $outputWriter = null) {
25+
parent::__construct($outputWriter);
26+
$this->installSourcesPath = __DIR__ . '/../Resources/install';
27+
$this->fileSystem = new Filesystem();
28+
}
29+
30+
/**
31+
* {@inheritdoc}
32+
*/
33+
public function install() {
34+
$this->copyConfigFile();
35+
return true;
36+
}
37+
38+
/**
39+
* {@inheritdoc}
40+
*/
41+
public function uninstall() {
42+
$target = PIMCORE_PRIVATE_VAR . self::LOCAL_CONFIG_PATH;
43+
if ($this->fileSystem->exists(PIMCORE_PRIVATE_VAR . self::LOCAL_CONFIG_BACKUP_PATH)) {
44+
$this->fileSystem->remove(PIMCORE_PRIVATE_VAR . self::LOCAL_CONFIG_BACKUP_PATH);
45+
}
46+
if ($this->fileSystem->exists($target)) {
47+
$this->fileSystem->rename(
48+
$target,
49+
PIMCORE_PRIVATE_VAR . self::LOCAL_CONFIG_BACKUP_PATH
50+
);
51+
}
52+
}
53+
54+
/**
55+
* {@inheritdoc}
56+
*/
57+
public function isInstalled() {
58+
$target = PIMCORE_PRIVATE_VAR . self::LOCAL_CONFIG_PATH;
59+
return $this->fileSystem->exists($target);
60+
}
61+
62+
/**
63+
* {@inheritdoc}
64+
*/
65+
public function canBeInstalled() {
66+
$target = PIMCORE_PRIVATE_VAR . self::LOCAL_CONFIG_PATH;
67+
return !$this->fileSystem->exists($target);
68+
}
69+
70+
/**
71+
* {@inheritdoc}
72+
*/
73+
public function canBeUninstalled() {
74+
$target = PIMCORE_PRIVATE_VAR . self::LOCAL_CONFIG_PATH;
75+
return $this->fileSystem->exists($target);
76+
}
77+
78+
/**
79+
* {@inheritdoc}
80+
*/
81+
public function needsReloadAfterInstall() {
82+
return false;
83+
}
84+
85+
/**
86+
* {@inheritdoc}
87+
*/
88+
public function canBeUpdated() {
89+
return false;
90+
}
91+
92+
/**
93+
* copy sample config file - if not exists.
94+
*/
95+
private function copyConfigFile() {
96+
$target = PIMCORE_PRIVATE_VAR . self::LOCAL_CONFIG_PATH;
97+
if (!$this->fileSystem->exists($target)) {
98+
$this->fileSystem->copy(
99+
$this->installSourcesPath . '/config.yml',
100+
$target
101+
);
102+
}
103+
}
104+
105+
}

src/MinifyCssJsBundle/MinifyCssJsBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class MinifyCssJsBundle extends AbstractPimcoreBundle {
88

99
use PackageVersionTrait;
1010

11-
const PACKAGE_NAME = 'nambu.ch/pimcore-minify-cssjs';
11+
const PACKAGE_NAME = 'nambu-ch/pimcore-minify-cssjs';
1212

1313
protected function getComposerPackageName(): string
1414
{

src/MinifyCssJsBundle/Resources/config/services.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ services:
33
autowire: true
44
autoconfigure: true
55

6+
minifycssjsbundle.install.installer:
7+
class: MinifyCssJsBundle\Install\Installer
8+
69
minifycssjs.templating.helper.headlink:
710
class: MinifyCssJsBundle\Templating\Helper\HeadLink
811
tags:
@@ -11,4 +14,4 @@ services:
1114
minifycssjs.templating.helper.headscript:
1215
class: MinifyCssJsBundle\Templating\Helper\HeadScript
1316
tags:
14-
- { name: templating.helper, alias: headScript }
17+
- { name: templating.helper, alias: headScript }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version: 1.0.0

0 commit comments

Comments
 (0)