Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
f7e6b957
Commit
f7e6b957
authored
Jan 18, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added function to recursively copy a directory.
parent
c314c0ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
36 deletions
+50
-36
publisher.php
laravel/cli/tasks/bundle/publisher.php
+2
-35
file.php
laravel/file.php
+48
-1
No files found.
laravel/cli/tasks/bundle/publisher.php
View file @
f7e6b957
<?php
namespace
Laravel\CLI\Tasks\Bundle
;
use
Laravel\File
;
use
Laravel\Bundle
;
use
FilesystemIterator
;
...
...
@@ -28,41 +29,7 @@ class Publisher {
*/
protected
function
move
(
$bundle
,
$source
,
$destination
)
{
if
(
!
is_dir
(
$source
))
return
;
// First we need to create the destination directory if it doesn't
// already exists. This directory hosts all of the assets we copy
// from the installed bundle's source directory.
if
(
!
is_dir
(
$destination
))
{
mkdir
(
$destination
);
}
$items
=
new
FilesystemIterator
(
$source
,
FilesystemIterator
::
SKIP_DOTS
);
foreach
(
$items
as
$item
)
{
// If the file system item is a directory, we will recurse the
// function, passing in the item directory. To get the proper
// destination path, we'll replace the root bundle asset
// directory with the root public asset directory.
if
(
$item
->
isDir
())
{
$path
=
$item
->
getRealPath
();
$recurse
=
str_replace
(
$this
->
from
(
$bundle
),
$this
->
to
(
$bundle
),
$path
);
$this
->
move
(
$bundle
,
$path
,
$recurse
);
}
// If the file system item is an actual file, we can copy the
// file from the bundle asset directory to the public asset
// directory. The "copy" method will overwrite any existing
// files with the same name.
else
{
copy
(
$item
->
getRealPath
(),
$destination
.
DS
.
$item
->
getBasename
());
}
}
File
::
copy_dir
(
$source
,
$destination
);
}
/**
...
...
laravel/file.php
View file @
f7e6b957
<?php
namespace
Laravel
;
use
Closure
;
<?php
namespace
Laravel
;
use
Closure
,
FilesystemIterator
;
class
File
{
...
...
@@ -170,4 +170,51 @@ class File {
return
false
;
}
/**
* Recursively copy directory contents to another directory.
*
* @param string $source
* @param string $destination
* @return void
*/
public
static
function
copy_dir
(
$source
,
$destination
)
{
if
(
!
is_dir
(
$source
))
return
;
// First we need to create the destination directory if it doesn't
// already exists. This directory hosts all of the assets we copy
// from the installed bundle's source directory.
if
(
!
is_dir
(
$destination
))
{
mkdir
(
$destination
);
}
$items
=
new
FilesystemIterator
(
$source
,
FilesystemIterator
::
SKIP_DOTS
);
foreach
(
$items
as
$item
)
{
$location
=
$destination
.
DS
.
$item
->
getBasename
();
// If the file system item is a directory, we will recurse the
// function, passing in the item directory. To get the proper
// destination path, we'll add the basename of the source to
// to the destination directory.
if
(
$item
->
isDir
())
{
$path
=
$item
->
getRealPath
();
static
::
copy_dir
(
$path
,
$location
);
}
// If the file system item is an actual file, we can copy the
// file from the bundle asset directory to the public asset
// directory. The "copy" method will overwrite any existing
// files with the same name.
else
{
copy
(
$item
->
getRealPath
(),
$location
);
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment