Skip to content

Commit

Permalink
Merge pull request #2 from bibumathew/master
Browse files Browse the repository at this point in the history
Fix : Marshalling magento modules
  • Loading branch information
maksek committed Nov 11, 2014
2 parents e3453d2 + bbf56db commit a4bbfb9
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 96 deletions.
88 changes: 61 additions & 27 deletions src/MagentoHackathon/Composer/Magento/DeployManager.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
*
*
*
*
*
*
*
*
*/

namespace MagentoHackathon\Composer\Magento;
Expand All @@ -13,7 +13,8 @@
use MagentoHackathon\Composer\Magento\Deploy\Manager\Entry;
use MagentoHackathon\Composer\Magento\Deploystrategy\Copy;

class DeployManager {
class DeployManager
{

/**
* @var Entry[]
Expand All @@ -27,29 +28,44 @@ class DeployManager {

/**
* an array with package names as key and priorities as value
*
*
* @var array
*/
protected $sortPriority = array();


public function __construct( IOInterface $io )

/**
* @var Installer
*/
private $installer;

public function __construct(IOInterface $io)
{
$this->io = $io;
}
public function addPackage( Entry $package )


public function addPackage(Entry $package)
{
$this->packages[] = $package;
}
public function setSortPriority( $priorities )

public function setSortPriority($priorities)
{
$this->sortPriority = $priorities;
}


public function setInstaller(Installer $installer)
{
$this->installer = $installer;
}

public function getInstaller()
{
return $this->installer;
}


/**
* uses the sortPriority Array to sort the packages.
* Highest priority first.
Expand All @@ -58,18 +74,18 @@ public function setSortPriority( $priorities )
protected function sortPackages()
{
$sortPriority = $this->sortPriority;
$getPriorityValue = function( Entry $object ) use ( $sortPriority ){
$getPriorityValue = function (Entry $object) use ($sortPriority) {
$result = 100;
if( isset($sortPriority[$object->getPackageName()]) ){
if (isset($sortPriority[$object->getPackageName()])) {
$result = $sortPriority[$object->getPackageName()];
}elseif( $object->getDeployStrategy() instanceof Copy ){
} elseif ($object->getDeployStrategy() instanceof Copy) {
$result = 101;
}
return $result;
};
usort(
$this->packages,
function($a, $b)use( $getPriorityValue ){
usort(
$this->packages,
function ($a, $b) use ($getPriorityValue) {
/** @var Entry $a */
/** @var Entry $b */
$aVal = $getPriorityValue($a);
Expand All @@ -81,18 +97,36 @@ function($a, $b)use( $getPriorityValue ){
}
);
}
public function doDeploy()


public function doDeploy($installedLocalPackages = array())
{
$this->sortPackages();
$packageCount = count($this->packages);
$installedLocalPackagesCount = count($installedLocalPackages);
$installedPackages = [];

/** @var Entry $package */
foreach( $this->packages as $package ){
if( $this->io->isDebug() ){
$this->io->write('start magento deploy for '. $package->getPackageName() );
foreach ($this->packages as $package) {
if ($this->io->isDebug()) {
$this->io->write('start magento deploy for ' . $package->getPackageName());
}
$package->getDeployStrategy()->deploy();
$installedPackages [$package->getPackageName()] = $package->getPackageName();
}
}
if (!empty($installedLocalPackages) && $packageCount !== $installedLocalPackagesCount) {
$packageTypes = PackageTypes::$packageTypes;
foreach ($installedLocalPackages as $package) {
if (!isset($installedPackages[$package->getName()]) && isset($packageTypes[$package->getType()])) {
if ($this->io->isDebug()) {
$this->io->write('Updating missing packages ' . $package->getName());
}
$strategy = $this->getInstaller()->getDeployStrategy($package);
$strategy->setMappings($this->getInstaller()->getParser($package)->getMappings());
$strategy->deploy();
}
}

}
}
}
Loading

0 comments on commit a4bbfb9

Please sign in to comment.