Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Installer Class Reference
Inheritance diagram for Installer:

Public Member Functions

 __construct (IOInterface $io, Composer $composer, $type='magento-module')
 
 setDeployManager (DeployManager $deployManager)
 
 setConfig (ProjectConfig $config)
 
 getDeployManager ()
 
 setDeployStrategy ($strategy)
 
 getDeployStrategy (PackageInterface $package, $strategy=null)
 
 supports ($packageType)
 
 getTargetDir ()
 
 install (InstalledRepositoryInterface $repo, PackageInterface $package)
 
 getGitIgnoreFileLocation ()
 
 appendGitIgnore (PackageInterface $package, $ignoreFile)
 
 prepareMagentoCore ()
 
 update (InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
 
 toggleMagentoMaintenanceMode ($active=false)
 
 clearMagentoCache ()
 
 uninstall (InstalledRepositoryInterface $repo, PackageInterface $package)
 
 getParser (PackageInterface $package)
 
 getInstallPath (PackageInterface $package)
 
 transformArrayKeysToLowerCase ($array)
 
 annoy (IOInterface $io)
 

Data Fields

const MAGENTO_REMOVE_DEV_FLAG = 'magento-remove-dev'
 
const MAGENTO_MAINTANANCE_FLAG = 'maintenance.flag'
 
const MAGENTO_CACHE_PATH = 'var/cache'
 
const MAGENTO_ROOT_DIR_TMP_SUFFIX = '_tmp'
 
const MAGENTO_ROOT_DIR_BACKUP_SUFFIX = '_bkup'
 

Protected Member Functions

 initializeMagentoRootDir ()
 
 getSourceDir (PackageInterface $package)
 
 preInstallMagentoCore ()
 
 clearRootDir ()
 
 setMagentoPermissions ()
 
 setPermissions ($path, $dirmode, $filemode)
 
 redeployProject ()
 
 preUpdateMagentoCore ()
 
 postUpdateMagentoCore ()
 
 cleanupPostUpdateMagentoCore ()
 

Protected Attributes

 $magentoRootDir = null
 
 $defaultMagentoRootDir = './'
 
 $modmanRootDir = null
 
 $isForced = false
 
 $_source_dir
 
 $_deployStrategy = "copy"
 
 $noMaintenanceMode = false
 
 $originalMagentoRootDir = null
 
 $backupMagentoRootDir = null
 
 $removeMagentoDev = false
 
 $keepMagentoCache = false
 
 $_magentoLocalXmlPath = 'app/etc/local.xml'
 
 $_defaultEnvFilePaths
 
 $_magentoDevDir = 'dev'
 
 $_magentoWritableDirs
 
 $deployManager
 
 $config
 
 $appendGitIgnore = false
 
 $_pathMappingTranslations = array()
 

Detailed Description

Composer Magento Installer

Definition at line 22 of file Installer.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( IOInterface  $io,
Composer  $composer,
  $type = 'magento-module' 
)

Initializes Magento Module installer

Parameters
\Composer\IO\IOInterface$io
\Composer\Composer$composer
string$type
Exceptions

Definition at line 117 of file Installer.php.

118  {
119  parent::__construct($io, $composer, $type);
120  $this->initializeVendorDir();
121 
122  $this->annoy( $io );
123 
124  $extra = $composer->getPackage()->getExtra();
125 
126  if (isset($extra['magento-root-dir']) || $rootDirInput = $this->defaultMagentoRootDir) {
127 
128  if (isset($rootDirInput)) {
129  $extra['magento-root-dir'] = $rootDirInput;
130  }
131 
132  $dir = rtrim(trim($extra['magento-root-dir']), '/\\');
133  $this->magentoRootDir = new \SplFileInfo($dir);
134  if (!is_dir($dir) && $io->askConfirmation('magento root dir "' . $dir . '" missing! create now? [Y,n] ')) {
135  $this->initializeMagentoRootDir($dir);
136  $io->write('magento root dir "' . $dir . '" created');
137  }
138 
139  if (!is_dir($dir)) {
140  $dir = $this->vendorDir . "/$dir";
141  $this->magentoRootDir = new \SplFileInfo($dir);
142  }
143  }
144 
145  if (isset($extra['modman-root-dir'])) {
146 
147  $dir = rtrim(trim($extra['modman-root-dir']), '/\\');
148  if (!is_dir($dir)) {
149  $dir = $this->vendorDir . "/$dir";
150  }
151  if (!is_dir($dir)) {
152  throw new \ErrorException("modman root dir \"{$dir}\" is not valid");
153  }
154  $this->modmanRootDir = new \SplFileInfo($dir);
155  }
156 
157  if (isset($extra['magento-deploystrategy'])) {
158  $this->_deployStrategy = (string)$extra['magento-deploystrategy'];
159  if($this->_deployStrategy !== "copy"){
160  $io->write("<warning>Warning: Magento 2 is not tested with \"{$this->_deployStrategy}\" deployment strategy. It may not function properly.</warning>");
161  }
162  }
163 
164  if ((is_null($this->magentoRootDir) || false === $this->magentoRootDir->isDir())
165  && $this->_deployStrategy != 'none'
166  ) {
167  $dir = $this->magentoRootDir instanceof \SplFileInfo ? $this->magentoRootDir->getPathname() : '';
168  $io->write("<error>magento root dir \"{$dir}\" is not valid</error>", true);
169  $io->write('<comment>You need to set an existing path for "magento-root-dir" in your composer.json</comment>', true);
170  $io->write('<comment>For more information please read about the "Usage" in the README of the installer Package</comment>', true);
171  throw new \ErrorException("magento root dir \"{$dir}\" is not valid");
172  }
173 
174  if (isset($extra['magento-force'])) {
175  $this->isForced = (bool)$extra['magento-force'];
176  }
177 
178  if (false !== getenv('MAGENTO_CLOUD_PROJECT')) {
179  $this->setDeployStrategy('none');
180  }
181 
182  if (isset($extra['magento-deploystrategy'])) {
183  $this->setDeployStrategy((string)$extra['magento-deploystrategy']);
184  }
185 
186  if (!empty($extra['auto-append-gitignore'])) {
187  $this->appendGitIgnore = true;
188  }
189 
190  if (!empty($extra['path-mapping-translations'])) {
191  $this->_pathMappingTranslations = (array)$extra['path-mapping-translations'];
192  }
193  }
$type
Definition: item.phtml:13
appendGitIgnore(PackageInterface $package, $ignoreFile)
Definition: Installer.php:448
if( $_orders &&count( $_orders))( 'Orders') ?></caption >< thead >< tr >< th scopeforeach( $_orders as $_order)(__( 'Order #')) ?>" class $extra
Definition: history.phtml:32

Member Function Documentation

◆ annoy()

annoy ( IOInterface  $io)

this function is for annoying people with messages.

First usage: get people to vote about the future release of composer so later I can say "you wanted it this way"

Parameters
IOInterface$io

No <error> in future, as some people look for error lines inside of CI Applications, which annoys them

Definition at line 812 of file Installer.php.

813  {
814 
818  /*
819  $io->write('<comment> time for voting about the future of the #magento #composer installer. </comment>', true);
820  $io->write('<comment> https://github.com/magento-hackathon/magento-composer-installer/blob/discussion-master/Milestone/2/index.md </comment>', true);
821  $io->write('<error> For the case you don\'t vote, I will ignore your problems till iam finished with the resulting release. </error>', true);
822  *
823  **/
824  }

◆ appendGitIgnore()

appendGitIgnore ( PackageInterface  $package,
  $ignoreFile 
)

Add all the files which are to be deployed to the .gitignore file, if it doesn't exist then create a new one

Parameters
PackageInterface$package
string$ignoreFile

Definition at line 448 of file Installer.php.

449  {
450  $contents = array();
451  if(file_exists($ignoreFile)) {
452  $contents = file($ignoreFile, FILE_IGNORE_NEW_LINES);
453  }
454 
455  $additions = array();
456  foreach($this->getParser($package)->getMappings() as $map) {
457  $dest = $map[1];
458  $ignore = sprintf("/%s", $dest);
459  $ignore = str_replace('/./','/', $ignore);
460  $ignore = str_replace('//','/', $ignore);
461  $ignore = rtrim($ignore,'/');
462  if(!in_array($ignore, $contents)) {
463  $ignoredMappings = $this->getDeployStrategy($package)->getIgnoredMappings();
464  if( in_array($ignore, $ignoredMappings) ){
465  continue;
466  }
467 
468  $additions[] = $ignore;
469  }
470  }
471 
472  if(!empty($additions)) {
473  array_unshift($additions, '#' . $package->getName());
474  $contents = array_merge($contents, $additions);
475  file_put_contents($ignoreFile, implode("\n", $contents));
476  }
477 
478  if ($package->getType() === 'magento-core') {
479  $this->prepareMagentoCore();
480  }
481  }
$contents
Definition: website.php:14
getDeployStrategy(PackageInterface $package, $strategy=null)
Definition: Installer.php:312
getParser(PackageInterface $package)
Definition: Installer.php:743

◆ cleanupPostUpdateMagentoCore()

cleanupPostUpdateMagentoCore ( )
protected

Definition at line 669 of file Installer.php.

669  {
670  $rootDir = $this->magentoRootDir->getPathname();
671  $backupDir = $this->backupMagentoRootDir->getPathname();
672  $persistentFolders = array('media', 'var');
673  copy($backupDir . DIRECTORY_SEPARATOR . $this->_magentoLocalXmlPath, $rootDir . DIRECTORY_SEPARATOR . $this->_magentoLocalXmlPath);
674  foreach ($persistentFolders as $folder) {
675  $this->filesystem->removeDirectory($rootDir . DIRECTORY_SEPARATOR . $folder);
676  $this->filesystem->rename($backupDir . DIRECTORY_SEPARATOR . $folder, $rootDir . DIRECTORY_SEPARATOR . $folder);
677  }
678  if ($this->io->ask('Remove root backup? [Y,n] ', true)) {
679  $this->filesystem->removeDirectory($backupDir);
680  $this->io->write('Removed root backup!', true);
681  } else {
682  $this->io->write('Skipping backup removal...', true);
683  }
684  $this->clearMagentoCache();
685  }
$rootDir
Definition: website.php:12

◆ clearMagentoCache()

clearMagentoCache ( )

Definition at line 700 of file Installer.php.

700  {
701  if (($targetDir = $this->getTargetDir()) && !$this->keepMagentoCache) {
702  $magentoCachePath = $targetDir . DIRECTORY_SEPARATOR . self::MAGENTO_CACHE_PATH;
703  if ($this->filesystem->removeDirectory($magentoCachePath)) {
704  $this->io->write('Magento cache cleared');
705  }
706  }
707  }

◆ clearRootDir()

clearRootDir ( )
protected

Definition at line 498 of file Installer.php.

498  {
499  $this->filesystem->removeDirectory($this->magentoRootDir->getPathname());
500  $this->filesystem->ensureDirectoryExists($this->magentoRootDir->getPathname());
501  }

◆ getDeployManager()

getDeployManager ( )
Returns
DeployManager

Definition at line 213 of file Installer.php.

◆ getDeployStrategy()

getDeployStrategy ( PackageInterface  $package,
  $strategy = null 
)

Returns the strategy class used for deployment

Parameters
\Composer\Package\PackageInterface$package
string$strategy
Returns
\MagentoHackathon\Composer\Magento\Deploystrategy\DeploystrategyAbstract

Definition at line 312 of file Installer.php.

313  {
314  if (null === $strategy) {
315  $strategy = $this->_deployStrategy;
316  }
317  $extra = $this->composer->getPackage()->getExtra();
318  if( isset($extra['magento-deploystrategy-overwrite']) ){
319  $moduleSpecificDeployStrategys = $this->transformArrayKeysToLowerCase($extra['magento-deploystrategy-overwrite']);
320  if( isset($moduleSpecificDeployStrategys[$package->getName()]) ){
321  $strategy = $moduleSpecificDeployStrategys[$package->getName()];
322  }
323  }
324  $moduleSpecificDeployIgnores = array();
325  if( isset($extra['magento-deploy-ignore']) ){
326  $extra['magento-deploy-ignore'] = $this->transformArrayKeysToLowerCase($extra['magento-deploy-ignore']);
327  if( isset($extra['magento-deploy-ignore']["*"]) ){
328  $moduleSpecificDeployIgnores = $extra['magento-deploy-ignore']["*"];
329  }
330  if( isset($extra['magento-deploy-ignore'][$package->getName()]) ){
331  $moduleSpecificDeployIgnores = array_merge(
332  $moduleSpecificDeployIgnores,
333  $extra['magento-deploy-ignore'][$package->getName()]
334  );
335  }
336  }
337  if($package->getType() === 'magento-core'){
338  $strategy = 'copy';
339  }
340  $targetDir = $this->getTargetDir();
341  $sourceDir = $this->getSourceDir($package);
342  switch ($strategy) {
343  case 'symlink':
344  $impl = new \MagentoHackathon\Composer\Magento\Deploystrategy\Symlink($sourceDir, $targetDir);
345  break;
346  case 'link':
347  $impl = new \MagentoHackathon\Composer\Magento\Deploystrategy\Link($sourceDir, $targetDir);
348  break;
349  case 'none':
350  $impl = new \MagentoHackathon\Composer\Magento\Deploystrategy\None($sourceDir, $targetDir);
351  break;
352  case 'copy':
353  default:
354  $impl = new \MagentoHackathon\Composer\Magento\Deploystrategy\Copy($sourceDir, $targetDir);
355  }
356  // Inject isForced setting from extra config
357  $impl->setIsForced($this->isForced);
358  $impl->setIgnoredMappings($moduleSpecificDeployIgnores);
359  return $impl;
360  }
getSourceDir(PackageInterface $package)
Definition: Installer.php:379
if( $_orders &&count( $_orders))( 'Orders') ?></caption >< thead >< tr >< th scopeforeach( $_orders as $_order)(__( 'Order #')) ?>" class $extra
Definition: history.phtml:32

◆ getGitIgnoreFileLocation()

getGitIgnoreFileLocation ( )

Get .gitignore file location

Returns
string

Definition at line 433 of file Installer.php.

434  {
435  $ignoreFile = $this->magentoRootDir->getPathname() . '/.gitignore';
436 
437  return $ignoreFile;
438  }

◆ getInstallPath()

getInstallPath ( PackageInterface  $package)

Definition at line 775 of file Installer.php.

776  {
777 
778  if (!is_null($this->modmanRootDir) && true === $this->modmanRootDir->isDir()) {
779  $targetDir = $package->getTargetDir();
780  if (!$targetDir) {
781  list($vendor, $targetDir) = explode('/', $package->getPrettyName());
782  }
783  $installPath = $this->modmanRootDir . '/' . $targetDir;
784  } else {
785  $installPath = parent::getInstallPath($package);
786  }
787 
788  // Make install path absolute. This is needed in the symlink deploy strategies.
789  if (DIRECTORY_SEPARATOR !== $installPath[0] && $installPath[1] !== ':') {
790  $installPath = getcwd() . "/$installPath";
791  }
792 
793  return $installPath;
794  }

◆ getParser()

getParser ( PackageInterface  $package)

Returns the modman parser for the vendor dir

Parameters
PackageInterface$package
Returns
Parser
Exceptions

Definition at line 743 of file Installer.php.

744  {
745  $extra = $package->getExtra();
746  $moduleSpecificMap = $this->composer->getPackage()->getExtra();
747  if( isset($moduleSpecificMap['magento-map-overwrite']) ){
748  $moduleSpecificMap = $this->transformArrayKeysToLowerCase($moduleSpecificMap['magento-map-overwrite']);
749  if( isset($moduleSpecificMap[$package->getName()]) ){
750  $map = $moduleSpecificMap[$package->getName()];
751  }
752  }
753  $suffix = PackageTypes::$packageTypes[$package->getType()];
754  if (isset($map)) {
755  $parser = new MapParser($map, $this->_pathMappingTranslations,$suffix);
756  return $parser;
757  } elseif (isset($extra['map'])) {
758  $parser = new MapParser($extra['map'], $this->_pathMappingTranslations, $suffix);
759  return $parser;
760  } elseif (isset($extra['package-xml'])) {
761  $parser = new PackageXmlParser($this->getSourceDir($package), $extra['package-xml'], $this->_pathMappingTranslations, $suffix);
762  return $parser;
763  } elseif (file_exists($this->getSourceDir($package) . '/modman')) {
764  $parser = new ModmanParser($this->getSourceDir($package), $this->_pathMappingTranslations, $suffix);
765  return $parser;
766  } else {
767  throw new \ErrorException('Unable to find deploy strategy for module: no known mapping');
768  }
769 
770  }
$suffix
Definition: name.phtml:27
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
getSourceDir(PackageInterface $package)
Definition: Installer.php:379
if( $_orders &&count( $_orders))( 'Orders') ?></caption >< thead >< tr >< th scopeforeach( $_orders as $_order)(__( 'Order #')) ?>" class $extra
Definition: history.phtml:32

◆ getSourceDir()

getSourceDir ( PackageInterface  $package)
protected

Return Source dir of package

Parameters
\Composer\Package\PackageInterface$package
Returns
string

Definition at line 379 of file Installer.php.

380  {
381  $this->filesystem->ensureDirectoryExists($this->vendorDir);
382  return $this->getInstallPath($package);
383  }
getInstallPath(PackageInterface $package)
Definition: Installer.php:775

◆ getTargetDir()

getTargetDir ( )

Return the absolute target directory path for package installation

Returns
string

Definition at line 390 of file Installer.php.

391  {
392  $targetDir = realpath($this->magentoRootDir->getPathname());
393  return $targetDir;
394  }

◆ initializeMagentoRootDir()

initializeMagentoRootDir ( )
protected

Create base requrements for project installation

Definition at line 221 of file Installer.php.

221  {
222  if (!$this->magentoRootDir->isDir()) {
223  $magentoRootPath = $this->magentoRootDir->getPathname();
224  $pathParts = explode(DIRECTORY_SEPARATOR, $magentoRootPath);
225  $baseDir = explode(DIRECTORY_SEPARATOR, $this->vendorDir);
226  array_pop($baseDir);
227  $pathParts = array_merge($baseDir, $pathParts);
228  $directoryPath = '';
229  foreach ($pathParts as $pathPart) {
230  $directoryPath .= $pathPart . DIRECTORY_SEPARATOR;
231  $this->filesystem->ensureDirectoryExists($directoryPath);
232  }
233  }
234 
235  // $this->getSourceDir($package);
236  }
$baseDir
Definition: autoload.php:9

◆ install()

install ( InstalledRepositoryInterface  $repo,
PackageInterface  $package 
)

Installs specific package

Parameters
InstalledRepositoryInterface$reporepository in which to check
PackageInterface$packagepackage instance

Definition at line 402 of file Installer.php.

403  {
404 
405  if ($package->getType() === 'magento-core' && !$this->preInstallMagentoCore()) {
406  return;
407  }
408 
409  parent::install($repo, $package);
410 
411  // skip marshal and apply default behavior if extra->map does not exist
412  if (!$this->hasExtraMap($package)) {
413  return;
414  }
415 
416  $strategy = $this->getDeployStrategy($package);
417  $strategy->setMappings($this->getParser($package)->getMappings());
418  $deployManagerEntry = new Entry();
419  $deployManagerEntry->setPackageName($package->getName());
420  $deployManagerEntry->setDeployStrategy($strategy);
421  $this->deployManager->addPackage($deployManagerEntry);
422 
423  if ($this->appendGitIgnore) {
424  $this->appendGitIgnore($package, $this->getGitIgnoreFileLocation());
425  }
426  }
getDeployStrategy(PackageInterface $package, $strategy=null)
Definition: Installer.php:312
appendGitIgnore(PackageInterface $package, $ignoreFile)
Definition: Installer.php:448
getParser(PackageInterface $package)
Definition: Installer.php:743

◆ postUpdateMagentoCore()

postUpdateMagentoCore ( )
protected

Definition at line 655 of file Installer.php.

655  {
656  $tmpDir = $this->magentoRootDir->getPathname();
657  $backupDir = $this->originalMagentoRootDir->getPathname() . self::MAGENTO_ROOT_DIR_BACKUP_SUFFIX;
658  $this->backupMagentoRootDir = new \SplFileInfo($backupDir);
659 
660  $origRootDir = $this->originalMagentoRootDir->getPathName();
661  $this->filesystem->rename($origRootDir, $backupDir);
662  $this->filesystem->rename($tmpDir, $origRootDir);
663  $this->magentoRootDir = clone $this->originalMagentoRootDir;
664 
665  $this->prepareMagentoCore();
667  }

◆ preInstallMagentoCore()

preInstallMagentoCore ( )
protected

Install Magento core

Parameters
InstalledRepositoryInterface$reporepository in which to check
PackageInterface$packagepackage instance

Definition at line 489 of file Installer.php.

489  {
490  if (!$this->io->askConfirmation('<info>Are you sure you want to install the Magento core?</info><error>Attention: Your Magento root dir will be cleared in the process!</error> [<comment>Y,n</comment>] ', true)) {
491  $this->io->write('Skipping core installation...');
492  return false;
493  }
494  $this->clearRootDir();
495  return true;
496  }

◆ prepareMagentoCore()

prepareMagentoCore ( )

Definition at line 503 of file Installer.php.

◆ preUpdateMagentoCore()

preUpdateMagentoCore ( )
protected

Definition at line 643 of file Installer.php.

643  {
644  if (!$this->io->askConfirmation('<info>Are you sure you want to manipulate the Magento core installation</info> [<comment>Y,n</comment>]? ', true)) {
645  $this->io->write('Skipping core update...');
646  return false;
647  }
648  $tmpDir = $this->magentoRootDir->getPathname() . self::MAGENTO_ROOT_DIR_TMP_SUFFIX;
649  $this->filesystem->ensureDirectoryExists($tmpDir);
650  $this->originalMagentoRootDir = clone $this->magentoRootDir;
651  $this->magentoRootDir = new \SplFileInfo($tmpDir);
652  return true;
653  }

◆ redeployProject()

redeployProject ( )
protected

Definition at line 551 of file Installer.php.

551  {
552  $ioInterface = $this->io;
553  // init repos
554  $composer = $this->composer;
555  $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
556 
557  $dm = $composer->getDownloadManager();
558  $im = $composer->getInstallationManager();
559 
560  /*
561  * @var $moduleInstaller MagentoHackathon\Composer\Magento\Installer
562  */
563  $moduleInstaller = $im->getInstaller("magento-module");
564 
565  foreach ($installedRepo->getPackages() as $package) {
566 
567  if ($ioInterface->isVerbose()) {
568  $ioInterface->write($package->getName());
569  $ioInterface->write($package->getType());
570  }
571 
572  if ($package->getType() != "magento-module") {
573  continue;
574  }
575  if ($ioInterface->isVerbose()) {
576  $ioInterface->write("package {$package->getName()} recognized");
577  }
578 
579  $strategy = $moduleInstaller->getDeployStrategy($package);
580  if ($ioInterface->getOption('verbose')) {
581  $ioInterface->write("used " . get_class($strategy) . " as deploy strategy");
582  }
583  $strategy->setMappings($moduleInstaller->getParser($package)->getMappings());
584 
585  $strategy->deploy();
586  }
587 
588 
589  return;
590  }

◆ setConfig()

setConfig ( ProjectConfig  $config)

Definition at line 205 of file Installer.php.

206  {
207  $this->config = $config;
208  }

◆ setDeployManager()

setDeployManager ( DeployManager  $deployManager)
Parameters
DeployManager$deployManager

Definition at line 199 of file Installer.php.

200  {
201  $this->deployManager = $deployManager;
202  }

◆ setDeployStrategy()

setDeployStrategy (   $strategy)
Parameters
string$strategy

Definition at line 300 of file Installer.php.

301  {
302  $this->_deployStrategy = $strategy;
303  }

◆ setMagentoPermissions()

setMagentoPermissions ( )
protected

some directories have to be writable for the server

Definition at line 511 of file Installer.php.

511  {
512  foreach ($this->_magentoWritableDirs as $dir) {
513  if (!file_exists($this->getTargetDir() . DIRECTORY_SEPARATOR . $dir)) {
514  mkdir($this->getTargetDir() . DIRECTORY_SEPARATOR . $dir, 0777, true);
515  }
516  $this->setPermissions($this->getTargetDir() . DIRECTORY_SEPARATOR . $dir, 0777, 0666);
517  }
518  }
setPermissions($path, $dirmode, $filemode)
Definition: Installer.php:527
mkdir($pathname, $mode=0777, $recursive=false, $context=null)
Definition: ioMock.php:25

◆ setPermissions()

setPermissions (   $path,
  $dirmode,
  $filemode 
)
protected

set permissions recursively

Parameters
string$pathPath to set permissions for
int$dirmodePermissions to be set for directories
int$filemodePermissions to be set for files

Definition at line 527 of file Installer.php.

527  {
528  if (is_dir($path)) {
529  if (!@chmod($path, $dirmode)) {
530  $this->io->write(
531  'Failed to set permissions "%s" for directory "%s"', decoct($dirmode), $path
532  );
533  }
534  $dh = opendir($path);
535  while (($file = readdir($dh)) !== false) {
536  if ($file != '.' && $file != '..') { // skip self and parent pointing directories
537  $fullpath = $path . '/' . $file;
538  $this->setPermissions($fullpath, $dirmode, $filemode);
539  }
540  }
541  closedir($dh);
542  } elseif (is_file($path)) {
543  if (false == !@chmod($path, $filemode)) {
544  $this->io->write(
545  'Failed to set permissions "%s" for file "%s"', decoct($filemode), $path
546  );
547  }
548  }
549  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
setPermissions($path, $dirmode, $filemode)
Definition: Installer.php:527

◆ supports()

supports (   $packageType)

Decides if the installer supports the given type

Parameters
string$packageType
Returns
bool

Definition at line 368 of file Installer.php.

369  {
370  return array_key_exists($packageType, PackageTypes::$packageTypes);
371  }

◆ toggleMagentoMaintenanceMode()

toggleMagentoMaintenanceMode (   $active = false)

Definition at line 687 of file Installer.php.

687  {
688  if (($targetDir = $this->getTargetDir()) && !$this->noMaintenanceMode) {
689  $flagPath = $targetDir . DIRECTORY_SEPARATOR . self::MAGENTO_MAINTANANCE_FLAG;
690  if ($active) {
691  $this->io->write("Adding magento maintenance flag...");
692  file_put_contents($flagPath, '*');
693  } elseif (file_exists($flagPath)) {
694  $this->io->write("Removing magento maintenance flag...");
695  unlink($flagPath);
696  }
697  }
698  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17

◆ transformArrayKeysToLowerCase()

transformArrayKeysToLowerCase (   $array)

Definition at line 796 of file Installer.php.

797  {
798  $arrayNew = array();
799  foreach($array as $key=>$value){
800  $arrayNew[strtolower($key)] = $value;
801  }
802  return $arrayNew;
803  }
$value
Definition: gender.phtml:16

◆ uninstall()

uninstall ( InstalledRepositoryInterface  $repo,
PackageInterface  $package 
)

Uninstalls specific package.

Parameters
InstalledRepositoryInterface$reporepository in which to check
PackageInterface$packagepackage instance

Definition at line 715 of file Installer.php.

716  {
717  // skip marshal and apply default behavior if extra->map does not exist
718  if (!$this->hasExtraMap($package)) {
719  parent::uninstall($repo, $package);
720  return;
721  }
722 
723  $strategy = $this->getDeployStrategy($package);
724  $strategy->setMappings($this->getParser($package)->getMappings());
725  try {
726  $strategy->clean();
727  } catch (\ErrorException $e) {
728  if ($this->io->isDebug()) {
729  $this->io->write($e->getMessage());
730  }
731  }
732 
733  parent::uninstall($repo, $package);
734  }
getDeployStrategy(PackageInterface $package, $strategy=null)
Definition: Installer.php:312
getParser(PackageInterface $package)
Definition: Installer.php:743

◆ update()

update ( InstalledRepositoryInterface  $repo,
PackageInterface  $initial,
PackageInterface  $target 
)

Updates specific package

Parameters
InstalledRepositoryInterface$reporepository in which to check
PackageInterface$initialalready installed package version
PackageInterface$targetupdated version
Exceptions
InvalidArgumentExceptionif $from package is not installed

Definition at line 601 of file Installer.php.

602  {
603 
604  if ($target->getType() === 'magento-core' && !$this->preUpdateMagentoCore()) {
605  return;
606  }
607 
608  // cleanup marshaled files if extra->map exist
609  if ($this->hasExtraMap($initial)) {
610  $initialStrategy = $this->getDeployStrategy($initial);
611  $initialStrategy->setMappings($this->getParser($initial)->getMappings());
612  try {
613  $initialStrategy->clean();
614  } catch (\ErrorException $e) {
615  if ($this->io->isDebug()) {
616  $this->io->write($e->getMessage());
617  }
618  }
619  }
620 
621  parent::update($repo, $initial, $target);
622 
623  // marshal files for new package version if extra->map exist
624  if ($this->hasExtraMap($target)) {
625  $targetStrategy = $this->getDeployStrategy($target);
626  $targetStrategy->setMappings($this->getParser($target)->getMappings());
627  $deployManagerEntry = new Entry();
628  $deployManagerEntry->setPackageName($target->getName());
629  $deployManagerEntry->setDeployStrategy($targetStrategy);
630  $this->deployManager->addPackage($deployManagerEntry);
631  }
632 
633  if($this->appendGitIgnore) {
635  }
636 
637  if ($target->getType() === 'magento-core') {
638  $this->postUpdateMagentoCore();
639  }
640  }
$target
Definition: skip.phtml:8
getDeployStrategy(PackageInterface $package, $strategy=null)
Definition: Installer.php:312
appendGitIgnore(PackageInterface $package, $ignoreFile)
Definition: Installer.php:448
getParser(PackageInterface $package)
Definition: Installer.php:743

Field Documentation

◆ $_defaultEnvFilePaths

$_defaultEnvFilePaths
protected
Initial value:
= array(
'app/etc/local.xml'
)

Definition at line 76 of file Installer.php.

◆ $_deployStrategy

$_deployStrategy = "copy"
protected

Definition at line 62 of file Installer.php.

◆ $_magentoDevDir

$_magentoDevDir = 'dev'
protected

Definition at line 79 of file Installer.php.

◆ $_magentoLocalXmlPath

$_magentoLocalXmlPath = 'app/etc/local.xml'
protected

Definition at line 75 of file Installer.php.

◆ $_magentoWritableDirs

$_magentoWritableDirs
protected
Initial value:
= array(
'app/etc',
'media',
'var'
)

Definition at line 80 of file Installer.php.

◆ $_pathMappingTranslations

$_pathMappingTranslations = array()
protected

Definition at line 107 of file Installer.php.

◆ $_source_dir

$_source_dir
protected

Definition at line 57 of file Installer.php.

◆ $appendGitIgnore

$appendGitIgnore = false
protected

Definition at line 101 of file Installer.php.

◆ $backupMagentoRootDir

$backupMagentoRootDir = null
protected

Definition at line 72 of file Installer.php.

◆ $config

$config
protected

Definition at line 94 of file Installer.php.

◆ $defaultMagentoRootDir

$defaultMagentoRootDir = './'
protected

Definition at line 36 of file Installer.php.

◆ $deployManager

$deployManager
protected

Definition at line 89 of file Installer.php.

◆ $isForced

$isForced = false
protected

Definition at line 50 of file Installer.php.

◆ $keepMagentoCache

$keepMagentoCache = false
protected

Definition at line 74 of file Installer.php.

◆ $magentoRootDir

$magentoRootDir = null
protected

Definition at line 29 of file Installer.php.

◆ $modmanRootDir

$modmanRootDir = null
protected

Definition at line 43 of file Installer.php.

◆ $noMaintenanceMode

$noMaintenanceMode = false
protected

Definition at line 70 of file Installer.php.

◆ $originalMagentoRootDir

$originalMagentoRootDir = null
protected

Definition at line 71 of file Installer.php.

◆ $removeMagentoDev

$removeMagentoDev = false
protected

Definition at line 73 of file Installer.php.

◆ MAGENTO_CACHE_PATH

const MAGENTO_CACHE_PATH = 'var/cache'

Definition at line 66 of file Installer.php.

◆ MAGENTO_MAINTANANCE_FLAG

const MAGENTO_MAINTANANCE_FLAG = 'maintenance.flag'

Definition at line 65 of file Installer.php.

◆ MAGENTO_REMOVE_DEV_FLAG

const MAGENTO_REMOVE_DEV_FLAG = 'magento-remove-dev'

Definition at line 64 of file Installer.php.

◆ MAGENTO_ROOT_DIR_BACKUP_SUFFIX

const MAGENTO_ROOT_DIR_BACKUP_SUFFIX = '_bkup'

Definition at line 68 of file Installer.php.

◆ MAGENTO_ROOT_DIR_TMP_SUFFIX

const MAGENTO_ROOT_DIR_TMP_SUFFIX = '_tmp'

Definition at line 67 of file Installer.php.


The documentation for this class was generated from the following file: