Trait PluginAssetsTrait
Trait for symlinking / copying plugin assets to app's webroot.
Method Summary
-
copyDirectory() protected
Copy directory
-
createDirectory() protected
Create directory
-
createSymlink() protected
Create symlink
-
isSymlinkValid() protected
Checks if symlink exist and points to the correct target.
-
list() protected
Get list of plugins to process. Plugins without a webroot directory are skipped.
-
makeRelativePath() protected
Generate a relative path from one directory to another.
-
process() protected
Process plugins
-
remove() protected
Remove folder/symlink.
Method Detail
copyDirectory() ¶ protected
copyDirectory(string $source, string $destination): bool
Copy directory
Parameters
-
string$source Source directory
-
string$destination Destination directory
Returns
boolcreateDirectory() ¶ protected
createDirectory(string $dir): bool
Create directory
Parameters
-
string$dir Directory name
Returns
boolcreateSymlink() ¶ protected
createSymlink(string $target, string $link, bool $relative = false): bool
Create symlink
Parameters
-
string$target Target directory
-
string$link Link name
-
bool$relative optional Relative (true) or Absolute (false)
Returns
boolisSymlinkValid() ¶ protected
isSymlinkValid(string $target, string $link): bool
Checks if symlink exist and points to the correct target.
Parameters
-
string$target -
string$link
Returns
boollist() ¶ protected
list(string|null $name = null): array<string, mixed>
Get list of plugins to process. Plugins without a webroot directory are skipped.
Parameters
-
string|null$name optional Name of plugin for which to symlink assets. If null all plugins will be processed.
Returns
array<string, mixed>List of plugins with meta data.
makeRelativePath() ¶ protected
makeRelativePath(string $from, string $to): string
Generate a relative path from one directory to another.
Parameters
-
string$from The symlink path
-
string$to The target path
Returns
stringRelative path
process() ¶ protected
process(array<string, mixed> $plugins, bool $copy = false, bool $overwrite = false, bool $relative = false): void
Process plugins
Parameters
-
array<string, mixed>$plugins List of plugins to process
-
bool$copy optional Force copy mode. Default false.
-
bool$overwrite optional Overwrite existing files.
-
bool$relative optional Relative. Default false.
Returns
voidremove() ¶ protected
remove(array<string, mixed> $config): bool
Remove folder/symlink.
Parameters
-
array<string, mixed>$config Plugin config.
Returns
bool