October\Rain\Halcyon\Datasource\FileDatasource

Source: ~/vendor/october/rain/src/Halcyon/Datasource/FileDatasource.php

Extends:

Implements:

File based datasource.

Protected properties

protected string $basePath

The local path where the datasource can be found.

protected October\Rain\Filesystem\Filesystem $files

The filesystem instance.

Show inherited protected properties

Inherited protected properties

Public methods

public void __construct(string $basePath, Filesystem $files)

Create a new datasource instance.

Parameters
  • string $basePath
  • Filesystem $files

public bool delete(string $dirName, string $fileName, string $extension)

Run a delete statement against the datasource.

Parameters
  • string $dirName
  • string $fileName
  • string $extension

public array getAvailablePaths()

Get all available paths within this datastore

public string getBasePath()

Returns the base path for this datasource.

public string getPathsCacheKey()

Generate a paths cache key unique to this datasource

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

Creates a new template.

Parameters
  • string $dirName
  • string $fileName
  • string $extension
  • string $content

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

Run a delete statement against the datasource.

Parameters
  • string $dirName
  • string $fileName
  • string $extension

public string makeCacheKey(string $name='')

Generate a cache key unique to this datasource.

Parameters
  • string $name

public array select(string $dirName, array $options=array())

Returns all templates.

Parameters
  • string $dirName
  • array $options - Array of options, [ 'columns' => ['fileName', 'mtime', 'content'], // Only return specific columns 'extensions' => ['htm', 'md', 'twig'], // Extensions to search for 'fileMatch' => '*gr[ae]y', // Shell matching pattern to match the filename against using the fnmatch function 'orders' => false // Not implemented 'limit' => false // Not implemented 'offset' => false // Not implemented ];

public mixed selectOne(string $dirName, string $fileName, string $extension)

Returns a single template.

Parameters
  • string $dirName
  • string $fileName
  • string $extension

public 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 - Defaults to null
  • string $oldExtension - Defaults to null

Show inherited public methods

Inherited public methods

Protected methods

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

Helper to make file path.

Parameters
  • string $dirName
  • string $fileName
  • string $extension

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

Show inherited protected methods

Inherited protected methods