Skip to content

Commit caee72a

Browse files
committed
Merge branch 'master' of github.com:davidverholen/magento-composer-installer
Conflicts: src/MagentoHackathon/Composer/Magento/Deploystrategy/DeploystrategyAbstract.php src/MagentoHackathon/Composer/Magento/Installer.php
2 parents 3faf71c + 4df64c0 commit caee72a

File tree

17 files changed

+1744
-1014
lines changed

17 files changed

+1744
-1014
lines changed

.travis.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,4 @@ script:
2323
notifications:
2424
email:
2525
recipients:
26-
27-
28-
on_success: never
29-
on_failure: always
30-
irc:
31-
channels:
32-
- "irc.freenode.org#magento-composer"
33-
on_success: change # default: always
34-
on_failure: always # default: always
26+

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ other support contacts
3636
* irc: freenode the channels #magento-composer #magento-reddit and for german speaking people #magento-de
3737
* twitter: [@firegento](https://twitter.com/firegento)
3838

39+
## Known issue
40+
- Error message: `Fatal error: Call to undefined method MagentoHackathon\Composer\Magento\Installer::setDeployManager()` happens when you update from 1.x to 2.x, as we switched from pure installer to plugin.
41+
42+
Solution: remove the `vendor` directory and the `composer.lock` and do a fresh install.
43+
=======
3944
## Known issues
4045

4146
### When upgrading from 1.x to 2.x

src/MagentoHackathon/Composer/Magento/DeployManager.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
class DeployManager {
1717

18+
const SORT_PRIORITY_KEY = 'magento-deploy-sort-priority';
19+
1820
/**
1921
* @var Entry[]
2022
*/
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
<?php
2+
/**
3+
* Core.php
4+
*
5+
* PHP Version 5
6+
*
7+
* @category Brandung
8+
* @package Brandung_magento-composer-installer
9+
* @author David Verholen <[email protected]>
10+
* @copyright 2014 Brandung GmbH & Co Kg
11+
* @license http://opensource.org/licenses/OSL-3.0 OSL-3.0
12+
* @link http://www.brandung.de
13+
*/
14+
15+
namespace MagentoHackathon\Composer\Magento\Deploystrategy;
16+
17+
use Composer\Util\Filesystem;
18+
19+
20+
/**
21+
* Class Core
22+
*
23+
* @category Brandung
24+
* @package Brandung_magento-composer-installer
25+
* @author David Verholen <[email protected]>
26+
* @copyright 2014 Brandung GmbH & Co Kg
27+
* @license http://opensource.org/licenses/OSL-3.0 OSL-3.0
28+
* @link http://www.brandung.de
29+
*/
30+
class Core extends Copy
31+
{
32+
const DS = DIRECTORY_SEPARATOR;
33+
34+
const BACKUP_DIR = 'persistent';
35+
36+
const DEFAULT_MAGENTO_ROOT = 'magento';
37+
38+
/**
39+
* Directories that need write Permissions for the Web Server
40+
*
41+
* @var array
42+
*/
43+
protected $magentoWritableDirs
44+
= array(
45+
'app/etc',
46+
'media',
47+
'var'
48+
);
49+
50+
/**
51+
* Directories that persist between Updates
52+
*
53+
* @var array
54+
*/
55+
protected $persistentDirs
56+
= array(
57+
'media',
58+
'var'
59+
);
60+
61+
/**
62+
* fs
63+
*
64+
* @var Filesystem
65+
*/
66+
protected $fs;
67+
68+
public function __construct($sourceDir, $destDir)
69+
{
70+
parent::__construct($sourceDir, $destDir);
71+
$this->fs = new Filesystem();
72+
}
73+
74+
/**
75+
* beforeDeploy
76+
*
77+
* @return void
78+
*/
79+
protected function beforeClean()
80+
{
81+
parent::beforeDeploy();
82+
if (!file_exists($this->destDir) || !is_dir($this->destDir)) {
83+
return;
84+
}
85+
86+
$this->fs->ensureDirectoryExists(self::BACKUP_DIR);
87+
$this->movePersistentFiles($this->destDir, self::BACKUP_DIR);
88+
}
89+
90+
/**
91+
* afterClean
92+
*
93+
* @return void
94+
*/
95+
protected function afterClean()
96+
{
97+
parent::afterClean();
98+
$this->emptyDir($this->destDir);
99+
}
100+
101+
102+
/**
103+
* afterDeploy
104+
*
105+
* @return void
106+
*/
107+
protected function afterDeploy()
108+
{
109+
parent::afterDeploy();
110+
if (!file_exists(self::BACKUP_DIR) || !is_dir(self::BACKUP_DIR)) {
111+
return;
112+
}
113+
$this->movePersistentFiles(self::BACKUP_DIR, $this->destDir);
114+
$this->rrmdir(self::BACKUP_DIR);
115+
}
116+
117+
/**
118+
* getLocalXmlPath
119+
*
120+
* @return string
121+
*/
122+
protected function getLocalXmlPath()
123+
{
124+
return 'app' . self::DS . 'etc' . self::DS . 'local.xml';
125+
}
126+
127+
protected function movePersistentFiles($sourceDir, $targetDir)
128+
{
129+
$this->movePersistentDirectories($sourceDir, $targetDir);
130+
$this->moveLocalXml($sourceDir, $targetDir);
131+
}
132+
133+
protected function moveLocalXml($sourceDir, $targetDir)
134+
{
135+
$source = $sourceDir . self::DS . $this->getLocalXmlPath();
136+
$target = $targetDir . self::DS . $this->getLocalXmlPath();
137+
if (file_exists($source)) {
138+
$this->fs->ensureDirectoryExists(dirname($target));
139+
rename($source, $target);
140+
}
141+
}
142+
143+
protected function movePersistentDirectories($sourceDir, $targetDir)
144+
{
145+
foreach ($this->persistentDirs as $dir) {
146+
$source = $sourceDir . self::DS . $dir;
147+
$target = $targetDir . self::DS . $dir;
148+
if (file_exists($source)) {
149+
$this->emptyDir($target);
150+
$this->fs->copyThenRemove($source, $target);
151+
}
152+
}
153+
}
154+
155+
/**
156+
* rrmdir
157+
*
158+
* @param string $dirPath path of the dir to recursively remove
159+
*
160+
* @return bool
161+
*/
162+
protected function rrmdir($dirPath)
163+
{
164+
if (file_exists($dirPath)) {
165+
foreach (
166+
new \RecursiveIteratorIterator(
167+
new \RecursiveDirectoryIterator(
168+
$dirPath,
169+
\FilesystemIterator::SKIP_DOTS
170+
),
171+
\RecursiveIteratorIterator::CHILD_FIRST
172+
) as $path
173+
) {
174+
/* @var \SplFileInfo $path */
175+
$path->isDir()
176+
? rmdir($path->getPathname())
177+
: unlink($path->getPathname());
178+
}
179+
return rmdir($dirPath);
180+
}
181+
return false;
182+
}
183+
184+
/**
185+
* emptyDir
186+
*
187+
* @param $dir
188+
*
189+
* @return void
190+
*/
191+
protected function emptyDir($dir)
192+
{
193+
$this->rrmdir($dir);
194+
$this->fs->ensureDirectoryExists($dir);
195+
}
196+
}

0 commit comments

Comments
 (0)