HEX
Server: LiteSpeed
System: Linux s3.sitechai.com 4.18.0-553.51.1.lve.1.el8.x86_64 #1 SMP Wed May 14 14:34:57 UTC 2025 x86_64
User: workzeni (2217)
PHP: 8.1.32
Disabled: mail, show_source, system, shell_exec, passthru, exec, eval, shell
Upload Files
File: /home/workzeni/stream-flix.workzenix.com/vendor/livewire/volt/src/MountedDirectories.php
<?php

namespace Livewire\Volt;

use Illuminate\Support\Arr;
use Illuminate\Support\Facades\View;

class MountedDirectories
{
    /**
     * The mounted directory paths.
     *
     * @var array<int, \Livewire\Volt\MountedDirectory>
     */
    protected array $paths = [];

    /**
     * Mount the given path and auto-register its Volt components.
     *
     * @param  array<int, string>|string  $paths
     * @param  array<int, class-string>|class-string  $uses
     */
    public function mount(array|string $paths, array|string $uses = []): void
    {
        $paths = collect(Arr::wrap($paths))
            ->filter(fn (string $path) => is_dir($path))
            ->values()
            ->map(fn (string $path) => new MountedDirectory($path, Arr::wrap($uses)));

        $this->paths = array_merge($this->paths, $paths->all());

        View::replaceNamespace('volt-livewire', collect($this->paths)->pluck('path')->all());
    }

    /**
     * Determine if the given path is within a mounted directory.
     */
    public function isWithinMountedDirectory(string $path): bool
    {
        return collect($this->paths)->pluck('path')->contains(fn (string $m) => str_starts_with($path, $m));
    }

    /**
     * Get the mounted directory paths.
     *
     * @return array<int, \Livewire\Volt\MountedDirectory>
     */
    public function paths(): array
    {
        return $this->paths;
    }
}