Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "-dev" for extra values #163

Merged
merged 1 commit into from
Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/MagentoHackathon/Composer/Magento/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ function (PackageInterface $package) use ($packageTypeToMatch) {
$vendorDir
);

if ($event->isDevMode()) {
$this->config->setDevMode();
}

$this->applyEvents($this->getEventManager());

if (in_array('--redeploy', $event->getArguments())) {
Expand Down
41 changes: 40 additions & 1 deletion src/MagentoHackathon/Composer/Magento/ProjectConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,18 @@ class ProjectConfig

const EXTRA_WITH_SKIP_SUGGEST_KEY = 'skip-suggest-repositories';

const EXTRA_DEV_MODE_APPEND = '-dev';

protected $libraryPath;
protected $libraryPackages;
protected $extra;
protected $composerConfig;

/**
* @var bool
*/
protected $isDevMode;

/**
* @param array $extra
* @param array $composerConfig
Expand All @@ -58,6 +65,8 @@ public function __construct(array $extra, array $composerConfig)
$this->extra = $extra;
$this->composerConfig = $composerConfig;

$this->isDevMode = false;

if (!is_null($projectConfig = $this->fetchVarFromConfigArray($this->extra, self::MAGENTO_PROJECT_KEY))) {
$this->applyMagentoConfig($projectConfig);
}
Expand All @@ -74,7 +83,10 @@ protected function fetchVarFromConfigArray($array, $key, $default = null)
{
$array = (array)$array;
$result = $default;
if (isset($array[$key])) {

if ($this->isDevMode && isset($array[$key . self::EXTRA_DEV_MODE_APPEND])) {
$result = $array[$key . self::EXTRA_DEV_MODE_APPEND];
} elseif (isset($array[$key])) {
$result = $array[$key];
}

Expand Down Expand Up @@ -479,4 +491,31 @@ public function getIncludeRootPackage()
{
return (bool)$this->fetchVarFromExtraConfig(self::INCLUDE_ROOT_PACKAGE_KEY);
}

/**
* Get dev mode
*
* @return bool
*/
public function isDevMode()
{
return $this->isDevMode;
}

/**
* Dev mode
*/
public function setDevMode()
{
$this->isDevMode = true;
}

/**
* No dev mode
*/
public function setNoDevMode()
{
$this->isDevMode = false;
}

}