Skip to content

Commit

Permalink
Add filesystem.localToPublic event (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
acasar authored May 13, 2024
1 parent 8ec3f78 commit 52e67e1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace October\Rain\Filesystem;

use Event;
use ReflectionClass;
use FilesystemIterator;
use Illuminate\Filesystem\Filesystem as FilesystemBase;
Expand Down Expand Up @@ -103,6 +104,20 @@ public function sizeToString($bytes)
*/
public function localToPublic($path)
{
/**
* @event filesystem.localToPublic
* Allow custom logic for converting local to public paths on non-standard installations.
*
* Example usage
*
* Event::listen('filesystem.localToPublic', function ($path) {
* return '/custom/public/path';
* });
*/
if (($event = Event::fire('filesystem.localToPublic', [$path], true)) !== null) {
return $event;
}

// Check real paths
$basePath = base_path();
if (strpos($path, $basePath) === 0) {
Expand Down

0 comments on commit 52e67e1

Please sign in to comment.