October\Rain\Halcyon\Datasource\FileDatasource

Extends
Implements
  • October\Rain\Halcyon\Datasource\DatasourceInterface

Protected Properties

protected string $basePath

basePath is a local path to find the datasource

protected October\Rain\Filesystem\Filesystem $files

Show inherited protected properties

Inherited Protected Properties


Public Methods

public __construct()

public __construct($basePath, $files): void

__construct a new datasource instance

public delete()

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

delete against the datasource

public getBasePath()

public getBasePath(): string 

getBasePath returns the base path for this datasource

public hasTemplate()

public hasTemplate($dirName, $fileName, $extension): bool 

hasTemplate checks if a template is found in the datasource

public insert()

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

insert creates a new template

public lastModified()

public lastModified($dirName, $fileName, $extension): int|null 

lastModified date of an object

public makeCacheKey()

public makeCacheKey($name = ''): string 

makeCacheKey unique to this datasource

public select()

public select($dirName, $options = []): array 

select returns all templates, with available options:

  • columns: only return specific columns, eg: ['fileName', 'mtime', 'content']
  • extensions: extensions to search for, eg: ['htm', 'md', 'twig']
  • fileMatch: pattern to match the filename against using the fnmatch function, eg: *gr[ae]y

public selectOne()

public selectOne($dirName, $fileName, $extension): void

selectOne returns a single template

public update()

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

update an existing template

Show inherited public methods

Inherited Public Methods

Protected Methods

protected makeFilePath()

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

makeFilePath helper to make file path

protected validateDirectoryForSave()

protected validateDirectoryForSave($dirName, $fileName, $extension): void

validateDirectoryForSave ensures the requested file can be created in the requested directory

Show inherited protected methods

Inherited Protected Methods