Commit e81b00d7 authored by mickadoo's avatar mickadoo

68: Extend base filesystem service

parent 8180f4b7
......@@ -3,7 +3,6 @@
parameters:
books_dir: %kernel.root_dir%/../books
publish_path_root: %kernel.root_dir%/../web
repos_path_root: %kernel.root_dir%/../var/repos
services:
......@@ -31,11 +30,14 @@ services:
- '@git'
- '@paths'
filesystem:
class: AppBundle\Utils\FileSystem
paths:
class: AppBundle\Utils\Paths
arguments:
- '%publish_path_root%'
- '%repos_path_root%'
- '%kernel.root_dir%'
- '%kernel.cache_dir%'
git:
class: AppBundle\Utils\GitTools
......
<?php
namespace AppBundle\Utils;
use Symfony\Component\Filesystem\Filesystem as BaseFileSystem;
class FileSystem extends BaseFileSystem {
/**
* @param $source
* @param $target
*/
public function copyDir($source, $target) {
$this->mkdir($target);
$selfFirst = \RecursiveIteratorIterator::SELF_FIRST;
$directoryIterator = new \RecursiveDirectoryIterator($source);
$iterator = new \RecursiveIteratorIterator($directoryIterator, $selfFirst);
foreach ($iterator as $item) {
if ($item->isDir()) {
$targetDir = $target.DIRECTORY_SEPARATOR. $iterator->getSubPathName();
$this->mkdir($targetDir);
} else {
$targetFilename = $target.DIRECTORY_SEPARATOR. $iterator->getSubPathName();
$this->copy($item, $targetFilename);
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment