Skip to content

Commit

Permalink
little refacto
Browse files Browse the repository at this point in the history
  • Loading branch information
Acrack committed Mar 26, 2014
1 parent 53e6d08 commit 0d191af
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
20 changes: 2 additions & 18 deletions Command/Bigfoot/ThemeInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Symfony\Component\Finder\Finder;

use Bigfoot\Bundle\CoreBundle\Command\BaseCommand;
use Bigfoot\Bundle\CoreBundle\Utils\CommonUtils;

/**
* Command that places the active bigfoot theme web assets into a given directory.
Expand Down Expand Up @@ -74,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$contentBundle = $this->getContainer()->get('kernel')->getBundle('BigfootContentBundle');
$images = $contentBundle->getPath().'/Resources/public/images';

$this->recurseCopy($images, $targetArg.'/images');
CommonUtils::recurseCopy($images, $targetArg.'/images');

if (is_dir($originDir = $themeBundle->getPath().'/Resources/assets')) {
$targetDir = $targetArg.'/admin';
Expand All @@ -99,21 +100,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
}

protected function recurseCopy($src, $dst) {
$dir = opendir($src);
@mkdir($dst);

while (false !== ($file = readdir($dir))) {
if (($file != '.') && ( $file != '..' )) {
if (is_dir($src.'/'.$file)) {
$this->recurseCopy($src.'/'.$file, $dst.'/'.$file);
} else {
copy($src.'/'.$file, $dst.'/'.$file);
}
}
}

closedir($dir);
}
}
26 changes: 26 additions & 0 deletions Utils/CommonUtils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Bigfoot\Bundle\CoreBundle\Utils;

class CommonUtils
{
/**
* Copy entire contents of a directory to another
*/
public static function recurseCopy($src, $dst) {
$dir = opendir($src);
@mkdir($dst);

while (false !== ($file = readdir($dir))) {
if (($file != '.') && ( $file != '..' )) {
if (is_dir($src.'/'.$file)) {
self::recurseCopy($src.'/'.$file, $dst.'/'.$file);
} else {
copy($src.'/'.$file, $dst.'/'.$file);
}
}
}

closedir($dir);
}
}
4 changes: 2 additions & 2 deletions Util/StringManager.php → Utils/StringUtils.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Bigfoot\Bundle\CoreBundle\Util;
namespace Bigfoot\Bundle\CoreBundle\Utils;

class StringManager
class StringUtils
{
/**
* Camelize string
Expand Down

0 comments on commit 0d191af

Please sign in to comment.