Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #47 from sanderborgman/master
Browse files Browse the repository at this point in the history
Copy vendor module assets & Scaffolding fix
  • Loading branch information
arius86 committed Jun 22, 2015
2 parents d858d3b + 293ba4a commit 4c5b9ae
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/DI/Scaffolding.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function doDelete($id)
*/
private function processForm($values)
{
$form = $this->getForm();
$form = $this->getForm($this->record);
$form->bind($values, $this->record);

if ($form->isValid()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Mvc/Module/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function dump($inputDirectory, $outputDirectory, $dumpVendorModules = tru
* @param $modulesList
* @return mixed
*/
private function dumpModulesFromVendor(array &$modulesList)
public function dumpModulesFromVendor(array &$modulesList)
{
if (!file_exists(APP_ROOT.'/composer.json')) {
return $modulesList;
Expand Down
37 changes: 34 additions & 3 deletions src/Task/AssetsTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Vegas\Cli\Task\Option;
use Vegas\Cli\Task;
use Vegas\Cli\TaskAbstract;
use Vegas\Mvc\Module\Loader;

/**
* Class AssetsTask
Expand All @@ -28,16 +29,20 @@ class AssetsTask extends TaskAbstract
*/
public function publishAction()
{
$this->putText("Copying assets...");
$this->copyAllAssets();
$this->putText("Copying Vegas CMF assets...");
$this->copyCmfAssets();

$this->putText("Copying vendor assets:");
$this->copyVendorAssets();

$this->putSuccess("Done.");
}

/**
* Copies all assets from vegas-cmf libraries
* @internal
*/
private function copyAllAssets()
private function copyCmfAssets()
{
$vegasCmfPath = APP_ROOT . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'vegas-cmf';
$publicAssetsDir = $this->getOption('d', APP_ROOT.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'assets');
Expand All @@ -59,6 +64,32 @@ private function copyAllAssets()
}
}

/**
* Copies all assets vendor modules
* @internal
*/
private function copyVendorAssets()
{
$modules = [];
$moduleLoader = new Loader($this->di);
$moduleLoader->dumpModulesFromVendor($modules);

$publicAssetsDir = $this->getOption('d', APP_ROOT.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'assets');


if ($modules) {
foreach ($modules as $moduleName => $module) {
$assetsDir = dirname($module['path']) . '/../assets';

if (file_exists($assetsDir)) {
$this->putText("- " . $moduleName . "...");

$this->copyRecursive($assetsDir, $publicAssetsDir);
}
}
}
}

/**
* Copies assets recursively
*
Expand Down

0 comments on commit 4c5b9ae

Please sign in to comment.