class FileSource extends AbstractSource implements SourceInterface

File based source.

Properties

protected Processor $processor

The query post processor implementation.

from  AbstractSource
protected string $basePath

The local path where the source can be found.

protected Filesystem $files

The filesystem instance.

Finder $finder

Methods

getProcessor()

Get the query post processor used by the connection.

int|string
makeCacheKey(string $name = '')

Generate a cache key unique to this source.

__construct($basePath, Filesystem $files)

Create a new source instance.

mixed
select(string $dirName, string $fileName, string $extension)

Returns a single template.

array
selectAll(string $dirName, array $options = [])

Returns all templates.

bool
insert(string $dirName, string $fileName, string $extension, string $content)

Creates a new template.

int
update(string $dirName, string $fileName, string $extension, string $content, string $oldFileName = null, string $oldExtension = null)

Updates an existing template.

int
delete(string $dirName, string $fileName, string $extension)

Run a delete statement against the source.

int
lastModified(string $dirName, string $fileName, string $extension)

Run a delete statement against the source.

void
validateDirectoryForSave(string $dirName, string $fileName, string $extension)

Ensure the requested file can be created in the requested directory.

string
makeFilePath($dirName, $fileName, $extension)

Helper to make file path.

string
getBasePath()

Returns the base path for this source.

string
getPathsCacheKey()

Generate a paths cache key unique to this source

array
getAvailablePaths()

Get all available paths within this source

Details

in AbstractSource at line 18
Processor getProcessor()

Get the query post processor used by the connection.

Return Value

Processor

at line 319
int|string makeCacheKey(string $name = '')

Generate a cache key unique to this source.

Parameters

string $name

Return Value

int|string

at line 43
__construct($basePath, Filesystem $files)

Create a new source instance.

Parameters

$basePath
Filesystem $files

at line 61
mixed select(string $dirName, string $fileName, string $extension)

Returns a single template.

Parameters

string $dirName
string $fileName
string $extension

Return Value

mixed

at line 86
array selectAll(string $dirName, array $options = [])

Returns all templates.

Parameters

string $dirName
array $options

Return Value

array

Exceptions

FileNotFoundException

at line 156
bool insert(string $dirName, string $fileName, string $extension, string $content)

Creates a new template.

Parameters

string $dirName
string $fileName
string $extension
string $content

Return Value

bool

at line 186
int update(string $dirName, string $fileName, string $extension, string $content, string $oldFileName = null, string $oldExtension = null)

Updates an existing template.

Parameters

string $dirName
string $fileName
string $extension
string $content
string $oldFileName
string $oldExtension

Return Value

int

at line 230
int delete(string $dirName, string $fileName, string $extension)

Run a delete statement against the source.

Parameters

string $dirName
string $fileName
string $extension

Return Value

int

at line 251
int lastModified(string $dirName, string $fileName, string $extension)

Run a delete statement against the source.

Parameters

string $dirName
string $fileName
string $extension

Return Value

int

at line 272
protected void validateDirectoryForSave(string $dirName, string $fileName, string $extension)

Ensure the requested file can be created in the requested directory.

Parameters

string $dirName
string $fileName
string $extension

Return Value

void

at line 307
protected string makeFilePath($dirName, $fileName, $extension)

Helper to make file path.

Parameters

$dirName
$fileName
$extension

Return Value

string

at line 328
string getBasePath()

Returns the base path for this source.

Return Value

string

at line 338
string getPathsCacheKey()

Generate a paths cache key unique to this source

Return Value

string

at line 348
array getAvailablePaths()

Get all available paths within this source

Return Value

array

$paths ['path/to/file1.md' => true (path can be handled and exists), 'path/to/file2.md' => false (path can be handled but doesn't exist)]