October\Rain\Halcyon\Datasource\DbDatasource
Overview
DbDatasource looks at the database for templates
Extends
Implements
- October\Rain\Halcyon\Datasource\DatasourceInterface
Protected Properties
protected string $source
source identifier for this datasource instance
protected string $table
table name of the datasource
protected static array $pathCache
protected static array|null $mtimeCache
protected static array $trashedPathCache
Show inherited protected properties
Inherited Protected Properties
- $forceDeleting - indicates if the record is currently being force deleted. (defined in October\Rain\Halcyon\Datasource\Datasource)
- $postProcessor - (defined in October\Rain\Halcyon\Datasource\Datasource)
- $emitterSingleEventCollection - of events to be fired once only. (defined in October\Rain\Halcyon\Datasource\Datasource)
- $emitterEventCollection - of all registered events. (defined in October\Rain\Halcyon\Datasource\Datasource)
- $emitterEventSorted - collection. (defined in October\Rain\Halcyon\Datasource\Datasource)
Public Methods
public __construct()
public __construct($source, $table): void
__construct a new datasource instance
public static clearCache()
public static clearCache($source, $table): void
clearCache drops in-memory indexes and the application cache entry for a source
public delete()
public delete($dirName, $fileName, $extension): bool
delete against the 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 isTemplateTrashed()
public isTemplateTrashed($dirName, $fileName, $extension): bool
isTemplateTrashed returns true when a soft-deleted record exists at the path
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 availableoptions:
- 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 selectTrashedFileNames()
public selectTrashedFileNames($dirName, $options = []): array
selectTrashedFileNames returns file names for soft-deleted templates in a directory
public tombstone()
public tombstone($dirName, $fileName, $extension): bool
tombstone creates a soft-deleted record for a path with no active DB template
public update()
public update(
$dirName,
$fileName,
$extension,
$content,
$oldFileName = null,
$oldExtension = null
): int
update an existing template
Inherited Public Methods
- bindEvent() - creates a new event binding. (defined in October\Rain\Halcyon\Datasource\Datasource)
- bindEventOnce() - creates a new event binding that fires once only. (defined in October\Rain\Halcyon\Datasource\Datasource)
- fireEvent() - and call the listeners. (defined in October\Rain\Halcyon\Datasource\Datasource)
- forceDelete() - a record against the datasource. (defined in October\Rain\Halcyon\Datasource\Datasource)
- getPostProcessor() - used by the connection. (defined in October\Rain\Halcyon\Datasource\Datasource)
- unbindEvent() - destroys an event binding. (defined in October\Rain\Halcyon\Datasource\Datasource)
Protected Methods
protected applyExtensionsFilter()
protected applyExtensionsFilter($query, $extensions): void
applyExtensionsFilter to a directory query
protected buildDirectoryQuery()
protected buildDirectoryQuery($dirName, $extensions): void
buildDirectoryQuery for active templates in a directory
protected canShareIndexCache()
protected canShareIndexCache(): bool
canShareIndexCache excludes custom scopes and transactions from shared content, mtime and tombstone indexes. Scopes may select an unkeyed tenant; transactional reads must not reuse or publish uncommitted snapshots.
protected fillIndexCaches()
protected fillIndexCaches(): void
fillIndexCaches loads mtime and trashed path indexes from cache or the database
protected flushCache()
protected flushCache(): void
protected static forgetCache()
protected static forgetCache($source, $table): void
forgetCache invalidates both request-local data and shared index snapshots.
protected getBaseQuery()
protected getBaseQuery(): void
getBaseQuery builder object
protected getQuery()
protected getQuery($withTrashed = true): void
getQuery object
protected getTrashedPaths()
protected getTrashedPaths(): array
getTrashedPaths returns cached tombstoned paths for this datasource source
protected static invalidateCacheAfterCommit()
protected static invalidateCacheAfterCommit(
$connection,
$source,
$table
): void
invalidateCacheAfterCommit rejects snapshots another request may fill from committed rows while this connection's changes are still uncommitted.
protected makeFilePath()
protected makeFilePath($dirName, $fileName, $extension): string
makeFilePath helper to make file path
protected static makeIndexCacheKey()
protected static makeIndexCacheKey($source, $table): string
makeIndexCacheKey unique to a datasource table and source
protected matchesExtensionFilter()
protected matchesExtensionFilter($path, $extensions): bool
matchesExtensionFilter checks a stored path against optional extensions
protected matchesFileMatch()
protected matchesFileMatch($fileMatch, $fileName): bool
matchesFileMatch checks a file name against an optional fnmatch pattern
protected pathToFileName()
protected pathToFileName($dirName, $path): string
pathToFileName converts a stored path to a file name within a directory
protected prepareCacheInvalidation()
protected prepareCacheInvalidation(): void
prepareCacheInvalidation registers commit invalidation before any write, so an unsupported standalone transaction fails without mutating a record.
Show inherited protected methods
Inherited Protected Methods
- emitterEventSortEvents() - sorts the listeners for a given event by priority. (defined in October\Rain\Halcyon\Datasource\Datasource)