Nextrek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<?php namespace Illuminate\Foundation;
use Illuminate\Filesystem\Filesystem;
class AssetPublisher {
/**
* The filesystem instance.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;
/**
* The path where assets should be published.
*
* @var string
*/
protected $publishPath;
/**
* The path where packages are located.
*
* @var string
*/
protected $packagePath;
/**
* Create a new asset publisher instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param string $publishPath
* @return void
*/
public function __construct(Filesystem $files, $publishPath)
{
$this->files = $files;
$this->publishPath = $publishPath;
}
/**
* Copy all assets from a given path to the publish path.
*
* @param string $name
* @param string $source
* @return bool
*
* @throws \RuntimeException
*/
public function publish($name, $source)
{
$destination = $this->publishPath."/packages/{$name}";
$success = $this->files->copyDirectory($source, $destination);
if ( ! $success)
{
throw new \RuntimeException("Unable to publish assets.");
}
return $success;
}
/**
* Publish a given package's assets to the publish path.
*
* @param string $package
* @param string $packagePath
* @return bool
*/
public function publishPackage($package, $packagePath = null)
{
$packagePath = $packagePath ?: $this->packagePath;
// Once we have the package path we can just create the source and destination
// path and copy the directory from one to the other. The directory copy is
// recursive so all nested files and directories will get copied as well.
$source = $packagePath."/{$package}/public";
return $this->publish($package, $source);
}
/**
* Set the default package path.
*
* @param string $packagePath
* @return void
*/
public function setPackagePath($packagePath)
{
$this->packagePath = $packagePath;
}
}
|
Revision |
Author |
Commited |
Message |
1464
|
MOliva
|
Tue 13 Oct, 2020 11:16:56 +0000 |
|