Skip to content

Commit

Permalink
Add filesystem.localToPublic event
Browse files Browse the repository at this point in the history
  • Loading branch information
acasar authored May 6, 2024
1 parent ba495f9 commit 88f0877
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 88f0877

Please sign in to comment.