master

laravel/framework

Last updated at: 29/12/2023 09:25

FileEngine.php

TLDR

This file defines a class called FileEngine in the Illuminate\View\Engines namespace. The FileEngine class implements the Engine interface and is responsible for retrieving the evaluated contents of a view file.

Methods

__construct(Filesystem $files)

This method is the constructor for the FileEngine class. It initializes the files property with the provided Filesystem instance.

get(string $path, array $data = [])

This method is responsible for getting the evaluated contents of the view. It accepts the file path and an optional array of data as parameters. It retrieves the contents of the view file using the get() method of the Filesystem instance and returns the contents as a string.

Classes

FileEngine

This class implements the Engine interface and provides functionality to retrieve the evaluated contents of a view file. It has a constructor method and a get() method to fulfill this functionality.

<?php

namespace Illuminate\View\Engines;

use Illuminate\Contracts\View\Engine;
use Illuminate\Filesystem\Filesystem;

class FileEngine implements Engine
{
    /**
     * The filesystem instance.
     *
     * @var \Illuminate\Filesystem\Filesystem
     */
    protected $files;

    /**
     * Create a new file engine instance.
     *
     * @param  \Illuminate\Filesystem\Filesystem  $files
     * @return void
     */
    public function __construct(Filesystem $files)
    {
        $this->files = $files;
    }

    /**
     * Get the evaluated contents of the view.
     *
     * @param  string  $path
     * @param  array  $data
     * @return string
     */
    public function get($path, array $data = [])
    {
        return $this->files->get($path);
    }
}