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

Public Member Functions

 activate (Composer $composer, IOInterface $io)
 
 onPackageUnistall (\Composer\Installer\PackageEvent $event)
 
 onCommandEvent (\Composer\Plugin\CommandEvent $event)
 
 onNewCodeEvent (\Composer\Script\Event $event)
 

Static Public Member Functions

static getSubscribedEvents ()
 

Protected Member Functions

 initDeployManager (Composer $composer, IOInterface $io)
 
 copyRecursive ($source, $target)
 

Protected Attributes

 $io
 
 $config
 
 $deployManager
 
 $composer
 
 $filesystem
 

Detailed Description

Definition at line 27 of file Plugin.php.

Member Function Documentation

◆ activate()

activate ( Composer  $composer,
IOInterface  $io 
)

Definition at line 84 of file Plugin.php.

85  {
86  $this->io = $io;
87  $this->composer = $composer;
88  $this->filesystem = new Filesystem();
89  $this->config = new ProjectConfig($composer->getPackage()->getExtra());
90  $this->installer = new Installer($io, $composer);
92  $this->installer->setDeployManager($this->deployManager);
93  $this->installer->setConfig($this->config);
94  if ($this->io->isDebug()) {
95  $this->io->write('activate magento plugin');
96  }
97  $composer->getInstallationManager()->addInstaller($this->installer);
98  }
initDeployManager(Composer $composer, IOInterface $io)
Definition: Plugin.php:73

◆ copyRecursive()

copyRecursive (   $source,
  $target 
)
protected

Copy then delete is a non-atomic version of rename.

Some systems can't rename and also don't have proc_open, which requires this solution.

copied from \Composer\Util\Filesystem::copyThenRemove and removed the remove part

Parameters
string$source
string$target

Definition at line 283 of file Plugin.php.

284  {
285  $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
286  $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
287  $this->filesystem->ensureDirectoryExists($target);
288 
289  foreach ($ri as $file) {
290  $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
291  if ($file->isDir()) {
292  $this->filesystem->ensureDirectoryExists($targetPath);
293  } else {
294  copy($file->getPathname(), $targetPath);
295  }
296  }
297 
298  }
$source
Definition: source.php:23
$target
Definition: skip.phtml:8

◆ getSubscribedEvents()

static getSubscribedEvents ( )
static

Definition at line 100 of file Plugin.php.

101  {
102  return array(
103  PluginEvents::COMMAND => array(
104  array('onCommandEvent', 0),
105  ),
106  ScriptEvents::POST_INSTALL_CMD => array(
107  array('onNewCodeEvent', 0),
108  ),
109  ScriptEvents::POST_UPDATE_CMD => array(
110  array('onNewCodeEvent', 0),
111  ),
112  PackageEvents::POST_PACKAGE_UNINSTALL => array(
113  array('onPackageUnistall', 0),
114  )
115  );
116  }

◆ initDeployManager()

initDeployManager ( Composer  $composer,
IOInterface  $io 
)
protected

Definition at line 73 of file Plugin.php.

74  {
75  $this->deployManager = new DeployManager($io);
76 
77  $extra = $composer->getPackage()->getExtra();
78  $sortPriority = isset($extra['magento-deploy-sort-priority']) ? $extra['magento-deploy-sort-priority'] : array();
79  $this->deployManager->setSortPriority($sortPriority);
80 
81  }
if( $_orders &&count( $_orders))( 'Orders') ?></caption >< thead >< tr >< th scopeforeach( $_orders as $_order)(__( 'Order #')) ?>" class $extra
Definition: history.phtml:32

◆ onCommandEvent()

onCommandEvent ( \Composer\Plugin\CommandEvent  $event)

actually is triggered before anything got executed

Parameters
\Composer\Plugin\CommandEvent$event

Definition at line 140 of file Plugin.php.

141  {
142  $command = $event->getCommandName();
143  }

◆ onNewCodeEvent()

onNewCodeEvent ( \Composer\Script\Event  $event)

event listener is named this way, as it listens for events leading to changed code files

Parameters
\Composer\Script\Event$event

Definition at line 150 of file Plugin.php.

151  {
152  if ($this->io->isDebug()) {
153  $this->io->write('start magento deploy via deployManager');
154  }
155 
156  $this->deployManager->doDeploy();
157  $this->deployLibraries();
158  $this->saveVendorDirPath($event->getComposer());
159  $this->requestRegeneration();
160  $this->setFilePermissions();
161  }

◆ onPackageUnistall()

onPackageUnistall ( \Composer\Installer\PackageEvent  $event)

Definition at line 118 of file Plugin.php.

119  {
120  $ds = DIRECTORY_SEPARATOR;
121  $package = $event->getOperation()->getPackage();
122  list($vendor, $packageName) = explode('/', $package->getPrettyName());
123  $packageName = trim(str_replace('module-', '', $packageName));
124  $packageInstallationPath = $packageInstallationPath = $this->installer->getTargetDir();
125  $packagePath = ucfirst($vendor) . $ds . str_replace(' ', '', ucwords(str_replace('-', ' ', $packageName)));
126  $this->io->write("Removing $packagePath");
127  $libPath = 'lib' . $ds . 'internal' . $ds . $packagePath;
128  $magentoPackagePath = 'app' . $ds . 'code' . $ds . $packagePath;
129  $deployStrategy = $this->installer->getDeployStrategy($package);
130  $deployStrategy->rmdirRecursive($packageInstallationPath . $ds . $libPath);
131  $deployStrategy->rmdirRecursive($packageInstallationPath . $ds . $magentoPackagePath);
132  $this->requestRegeneration();
133  }

Field Documentation

◆ $composer

$composer
protected

Definition at line 51 of file Plugin.php.

◆ $config

$config
protected

Definition at line 39 of file Plugin.php.

◆ $deployManager

$deployManager
protected

Definition at line 45 of file Plugin.php.

◆ $filesystem

$filesystem
protected

Definition at line 61 of file Plugin.php.

◆ $io

$io
protected

Definition at line 33 of file Plugin.php.


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