AutoDatasource
        
        Datasource that loads from other data sources automatically
    
    
 class Cms\Classes\AutoDatasource
extends Winter\Storm\Halcyon\Datasource\Datasource
implements 
    Winter\Storm\Halcyon\Datasource\DatasourceInterfaceExtends
| Class | Description | 
|---|---|
| Datasource | Datasource base class. | 
Traits
| Trait | Description | 
|---|---|
| Emitter | Adds event related features to any class. | 
Properties
            
            
            
                public
            
            
            $activeDatasourceKey
            
                :
                                                            string
                                                                        
                        = ""
                    
                            
        
        
        The key for the datasource to perform CRUD operations on
            
            
            
                protected
            
            
            $allowCacheRefreshes
            
                :
                                                            bool
                                                                        
                        = true
                    
                            
        
        
        Flag on whether the cache should respect refresh requests
            
            
            
                protected
            
            
            $cacheKey
            
                :
                                                            string
                                                                        
                        = "halcyon-datastore-auto"
                    
                            
        
        
        The cache key to use for this datasource instance
            
            
            
                protected
            
            
            $datasources
            
                :
                                                            array
                                                                        
                        = []
                    
                            
        
        
        The available datasource instances
            
            
            
                protected
            
            
            $pathCache
            
                :
                                                            array
                                                                        
                        = []
                    
                            
        
        
        Local cache of paths available in the datasources
            
            
            
                protected
            
            
            $singleDatasourceMode
            
                :
                                                            bool
                                                                        
                        = false
                    
                            
        
        
        Flag to indicate that we're in "single datasource mode"
            
                            
                    inherited
                
            
            
                protected
            
            
            $emitterEventCollection
            
                :
                                                            array
                                                                        
                        = []
                    
                            
        
                    Collection of registered events.
            
                            
                    inherited
                
            
            
                protected
            
            
            $emitterEventSorted
            
                :
                                                            array
                                                                        
                        = []
                    
                            
        
                    Sorted collection of events.
            
                            
                    inherited
                
            
            
                protected
            
            
            $emitterSingleEventCollection
            
                :
                                                            array
                                                                        
                        = []
                    
                            
        
                    Collection of registered events to be fired once only.
            
                            
                    inherited
                
            
            
                protected
            
            
            $forceDeleting
            
                :
                                                            bool
                                                                        
                        = false
                    
                            
        
                    Indicates if the record is currently being force deleted.
inherited protected $postProcessor : Winter\Storm\Halcyon\Processors\Processor
The query post processor implementation.
Methods
            
            
            
                public
            
                        
            __construct (array $datasources, $cacheKey = null)
                            : void
                    
        
        Create a new datasource instance.
| Property | Type | Description | 
|---|---|---|
| $datasources | array | array Array of datasources to utilize. Lower indexes = higher priority ['datasourceName' => $datasource] | 
| $cacheKey | mixed | mixed | 
public appendDatasource (string $key, Winter\Storm\Halcyon\Datasource\DatasourceInterface $datasource) : void
Append a datasource to the end of the list of datasources
| Property | Type | Description | 
|---|---|---|
| $key | string | string | 
| $datasource | Winter\Storm\Halcyon\Datasource\DatasourceInterface | Winter\Storm\Halcyon\Datasource\DatasourceInterface | 
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 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 getPathCache () : array
Returns the in memory path cache map
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 getSourcePaths (string $source) : array
Get the available paths for the specified datasource key
| Property | Type | Description | 
|---|---|---|
| $source | string | string | 
public insert (string $dirName, string $fileName, string $extension, string $content) : integer
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
            
                        
            populateCache (boolean $refresh = false)
                            : void
                    
        
        Populate the local cache of paths available in each datasource
| Property | Type | Description | 
|---|---|---|
| $refresh | boolean | boolean Default false, set to true to force the cache to be rebuilt | 
public prependDatasource (string $key, Winter\Storm\Halcyon\Datasource\DatasourceInterface $datasource) : void
Prepend a datasource to the beginning of the list of datasources
| Property | Type | Description | 
|---|---|---|
| $key | string | string | 
| $datasource | Winter\Storm\Halcyon\Datasource\DatasourceInterface | Winter\Storm\Halcyon\Datasource\DatasourceInterface | 
public pushToSource (Winter\Storm\Halcyon\Model $model, string $source) : void
Push the provided model to the specified datasource
| Property | Type | Description | 
|---|---|---|
| $model | Winter\Storm\Halcyon\Model | Winter\Storm\Halcyon\Model | 
| $source | string | string | 
public removeFromSource (Winter\Storm\Halcyon\Model $model, string $source) : void
Remove the provided model from the specified datasource
| Property | Type | Description | 
|---|---|---|
| $model | Winter\Storm\Halcyon\Model | Winter\Storm\Halcyon\Model | 
| $source | string | string | 
            
            
            
                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 sourceHasModel (string $source, Winter\Storm\Halcyon\Model $model) : bool
Check to see if the specified datasource has the provided Halcyon Model
| Property | Type | Description | 
|---|---|---|
| $source | string | string | 
| $model | Winter\Storm\Halcyon\Model | Winter\Storm\Halcyon\Model | 
            
            
            
                public
            
                        
            update (string $dirName, string $fileName, string $extension, string $content, $oldFileName = 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 | mixed | mixed Used for renaming templates. If specified, this will delete the "old" path. | 
| $oldExtension | mixed | mixed Used for renaming templates. If specified, this will delete the "old" path. | 
The filesize of the updated model.
public usingSource (string $source, Closure $closure)
Forces all operations in a provided closure to run within a selected datasource.
| Property | Type | Description | 
|---|---|---|
| $source | string | string | 
| $closure | Closure | Closure | 
protected getActiveDatasource () : Winter\Storm\Halcyon\Datasource\DatasourceInterface
Get the datasource for use with CRUD operations
protected getDatasourceForPath (string $path) : Winter\Storm\Halcyon\Datasource\DatasourceInterface
Get the appropriate datasource for the provided path
| Property | Type | Description | 
|---|---|---|
| $path | string | string | 
            
            
            
                protected
            
                        
            getValidPaths (string $dirName, array $options = [])
                            : array
                    
        
        Get all valid paths for the provided directory, removing any paths marked as deleted
| Property | Type | Description | 
|---|---|---|
| $dirName | string | string | 
| $options | array | array Array of options, [ 'extensions' => ['htm', 'md', 'twig'], // Extensions to search for 'fileMatch' => '*gr[ae]y', // Shell matching pattern to match the filename against using the fnmatch function ]; | 
$paths ["$dirName/path/1.md", "$dirName/path/2.md"]
protected makeFilePath (string $dirName, string $fileName, string $extension) : string
Helper to make file path.
| Property | Type | Description | 
|---|---|---|
| $dirName | string | string | 
| $fileName | string | string | 
| $extension | string | string | 
            
                            
                    inherited
                
            
            
                public
            
                        
            bindEvent (string | Closure | QueuedClosure $event, mixed $callback = null, integer $priority)
                            : self
                    
                    Create a new event binding.
| Property | Type | Description | 
|---|---|---|
| $event | string | Closure | QueuedClosure | string | Closure | QueuedClosure | 
| $callback | mixed | mixed when the third parameter is omitted and a Closure or QueuedClosure is provided this parameter is used as an integer this is used as priority variable | 
| $priority | integer | integer | 
            
                            
                    inherited
                
            
            
                public
            
                        
            bindEventOnce (string | Closure | QueuedClosure $event, QueuedClosure | Closure | null $callback = null)
                            : self
                    
                    Create a new event binding that fires once only
| Property | Type | Description | 
|---|---|---|
| $event | string | Closure | QueuedClosure | string | Closure | QueuedClosure | 
| $callback | QueuedClosure | Closure | null | QueuedClosure | Closure | null When a Closure or QueuedClosure is provided as the first parameter this parameter can be omitted | 
            
                            
                    inherited
                
            
            
                public
            
                        
            fireEvent (string $event, array $params = [], boolean $halt = false)
                            : array | mixed | null
                    
                    Fire an event and call the listeners.
| Property | Type | Description | 
|---|---|---|
| $event | string | string Event name | 
| $params | array | array Event parameters | 
| $halt | boolean | boolean Halt after first non-null result | 
If halted, the first non-null result. If not halted, an array of event results. Returns null if no listeners returned a result.
inherited public forceDelete (string $dirName, string $fileName, string $extension) : bool
| Property | Type | Description | 
|---|---|---|
| $dirName | string | string | 
| $fileName | string | string | 
| $extension | string | string | 
inherited public getPostProcessor () : Winter\Storm\Halcyon\Processors\Processor
            
                            
                    inherited
                
            
            
                public
            
                        
            unbindEvent (string | array | object $event = null)
                            : self
                    
                    Destroys an event binding.
| Property | Type | Description | 
|---|---|---|
| $event | string | array | object | string | array | object Event to destroy | 
inherited protected emitterEventSortEvents (string $eventName) : void
Sort the listeners for a given event by priority.
| Property | Type | Description | 
|---|---|---|
| $eventName | string | string | 
            
                            
                    inherited
                
            
            
                protected
            
                        
            parseEventAndPayload (mixed $event, mixed $payload = null)
                            : array
                    
                    Parse the given event and payload and prepare them for dispatching.
| Property | Type | Description | 
|---|---|---|
| $event | mixed | mixed | 
| $payload | mixed | mixed |