DatasourceInterface
interface Winter\Storm\Halcyon\Datasource\DatasourceInterface
Methods
public delete (string $dirName, string $fileName, string $extension) : bool
Runs a delete statement against the datasource.
| Property | Type | Description |
|---|---|---|
| $dirName | string |
string
The directory in which the model is stored. |
| $fileName | string |
string
The filename of the model. |
| $extension | string |
string
The file extension of the model. |
If the delete operation completed successfully.
public forceDelete (string $dirName, string $fileName, string $extension) : bool
Runs a delete statement against the datasource, forcing the complete removal of the model (template).
| Property | Type | Description |
|---|---|---|
| $dirName | string |
string
The directory in which the model is stored. |
| $fileName | string |
string
The filename of the model. |
| $extension | string |
string
The file extension of the model. |
If the delete operation completed successfully.
public getAvailablePaths () : array
Get all available paths within this datasource.
This method returns an array, with all available paths as the key, and a boolean that represents whether the path can be handled or modified.
Example:
[
'path/to/file.md' => true, // (this path is available, and can be handled)
'path/to/file2.md' => false // (this path is available, but cannot be handled)
]
An array of available paths alongside whether they can be handled.
public getPathsCacheKey () : string
Gets the prefix of the cache keys.
This is based off a prefix including the base path for the model.
The cache key prefix.
public getPostProcessor () : Winter\Storm\Halcyon\Processors\Processor
Get the query post processor used by the connection.
public insert (string $dirName, string $fileName, string $extension, string $content) : int
Creates a new Halcyon model (template).
| Property | Type | Description |
|---|---|---|
| $dirName | string |
string
The directory in which the model is stored. |
| $fileName | string |
string
The filename of the model. |
| $extension | string |
string
The file extension of the model. |
| $content | string |
string
The content to store for the model. |
The filesize of the created model.
public lastModified (string $dirName, string $fileName, string $extension) : integer | null
Returns the last modified date of a model (template).
| Property | Type | Description |
|---|---|---|
| $dirName | string |
string
The directory in which the model is stored. |
| $fileName | string |
string
The filename of the model. |
| $extension | string |
string
The file extension of the model. |
The last modified time as a timestamp, or null if the object doesn't exist.
public
makeCacheKey (string $name = "")
: string
Generate a cache key unique to this datasource.
| Property | Type | Description |
|---|---|---|
| $name | string |
string
The name of the key. |
The hashed key.
public
select (string $dirName, array $options = [])
: array
Returns all Halcyon models (templates) within a given directory.
You can provide multiple options with the $options property, in order to filter the retrieved records:
-
columns: Only retrieve certain columns. Must be an array with any combination offileName,mtimeandcontent. -
extensions: Defines the accepted extensions as an array. Eg:['htm', 'md', 'twig'] -
fileMatch: Defines a glob string to match filenames against. Eg:'*gr[ae]y' -
orders: Not implemented -
limit: Not implemented -
offset: Not implemented
| Property | Type | Description |
|---|---|---|
| $dirName | string |
string
The directory in which the model is stored. |
| $options | array |
array
Defines the options for this query. |
An array of models found, with the columns defined as per the columns parameter for $options.
public selectOne (string $dirName, string $fileName, string $extension) : array | null
Returns a single Halcyon model (template).
| Property | Type | Description |
|---|---|---|
| $dirName | string |
string
The directory in which the model is stored. |
| $fileName | string |
string
The filename of the model. |
| $extension | string |
string
The file extension of the model. |
An array of template data (fileName, mtime and content), or null if the model does
not exist.
public
update (string $dirName, string $fileName, string $extension, string $content, string | null $oldFileName = null, string | null $oldExtension = null)
: integer
Updates an existing Halcyon model (template).
| Property | Type | Description |
|---|---|---|
| $dirName | string |
string
The directory in which the model is stored. |
| $fileName | string |
string
The filename of the model. |
| $extension | string |
string
The file extension of the model. |
| $content | string |
string
The content to store for the model. |
| $oldFileName | string | null |
string | null
Used for renaming templates. If specified, this will delete the "old" path. |
| $oldExtension | string | null |
string | null
Used for renaming templates. If specified, this will delete the "old" path. |
The filesize of the updated model.
Implemented by
| Class | Description |
|---|---|
AutoDatasource
|
Datasource that loads from other data sources automatically |
Datasource
|
Datasource base class. |
DbDatasource
|
Database based data source |
FileDatasource
|
File based datasource. |