October\Rain\Halcyon\Builder

Builder for Halcyon queries

Public properties

public array $columns

columns that should be returned

public array $extensions

extensions filter the query by these file extensions

public string $from

from the directory name which the query is targeting

public bool $selectSingle

selectSingle query should pluck a single record

public string $fileMatch

fileMatch using the specified pattern

public array $orders

orders is the orderings for the query

public int $limit

limit is the maximum number of records to return

public int $offset

offset is the number of records to skip

Protected properties

protected October\Rain\Halcyon\Datasource\DatasourceInterface $datasource

datasource instance

protected October\Rain\Halcyon\Model $model

model being queried

protected October\Rain\Halcyon\Processors\Processor $processor

processor datasource query post processor instance

protected string $cacheKey

cacheKey that should be used when caching the query

protected int $cacheMinutes

cacheMinutes number of minutes to cache the query

protected array $cacheTags

cacheTags for the query cache

protected string $cacheDriver

cacheDriver to be used

protected bool $loadedFromCache

loadedFromCache is an internal variable to specify if the record was loaded from cache

Public methods

public mixed __call(string $method, array $parameters)

__call handles dynamic method calls into the method

Parameters
  • string $method
  • array $parameters

public void __construct($datasource, $processor)

__construct creates a new query builder instance

Parameters
  • $datasource
  • $processor

public $this cacheDriver(string $cacheDriver)

cacheDriver indicate that the results, if cached, should use the given cache driver

Parameters
  • string $cacheDriver

public $this cacheTags(array|mixed $cacheTags)

cacheTags indicates that the results, if cached, should use the given cache tags

Parameters
  • array|mixed $cacheTags

public static void clearInternalCache()

clearInternalCache request-level object cache

public int delete()

delete a record from the database.

public mixed|static find(string $fileName)

find a single template by its file name.

Parameters
  • string $fileName

public mixed|static first()

first executes the query and get the first result

public $this from(string $dirName)

from sets the directory name which the query is targeting

Parameters
  • string $dirName

public string generateCacheKey()

generateCacheKey for the query

public October\Rain\Halcyon\Collection|static[] get(array $columns=array( 0=>'*'))

get executes the query as a "select" statement

Parameters
  • array $columns

public string getCacheKey()

getCacheKey gets a unique cache key for the complete query

public array getCached(array $columns=array( 0=>'*'))

getCached executes the query as a cached "select" statement

Parameters
  • array $columns

public October\Rain\Halcyon\Collection|static[] getFresh(array $columns=array( 0=>'*'))

getFresh executes the query as a fresh "select" statement

Parameters
  • array $columns

public October\Rain\Halcyon\Model getModel()

getModel instance being queried

public October\Rain\Halcyon\Model[] getModels(array $results)

getModels gets the hydrated models

Parameters
  • array $results

public bool insert($values)

insert a new record into the datasource.

Parameters
  • $values

public int lastModified()

lastModified returns the last modified time of the object

public $this limit(int $value)

limit sets the "limit" value of the query

Parameters
  • int $value

public array lists(string $column, string $key=NULL)

lists gets an array with the values of a given column

Parameters
  • string $column
  • string $key

public $this offset(int $value)

offset sets the "offset" value of the query

Parameters
  • int $value

public $this remember(DateTime|int $minutes, string $key=NULL)

remember indicates that the query results should be cached

Parameters
  • DateTime|int $minutes
  • string $key

public $this rememberForever(string $key=NULL)

rememberForever indicates that the query results should be cached forever

Parameters
  • string $key

public $this setModel($model)

setModel instance for the model being queried

Parameters
  • $model

public October\Rain\Halcyon\Builder|static skip(int $value)

skip is an alias to set the "offset" value of the query

Parameters
  • int $value

public October\Rain\Halcyon\Builder|static take(int $value)

take is an alias to set the "limit" value of the query

Parameters
  • int $value

public string toCompiled()

toCompiled gets the compiled file content representation of the query

public int update($values)

update a record in the datasource.

Parameters
  • $values

public $this whereFileName(string $fileName)

whereFileName switches mode to select a single template by its name

Parameters
  • string $fileName

Protected methods

protected Illuminate\Cache\CacheManager getCache()

getCache object with tags assigned, if applicable

protected Closure getCacheCallback(string $fileName)

getCacheCallback used when caching queries

Parameters
  • string $fileName

protected bool isCacheBusted(array $result)

isCacheBusted returns true if the cache for the file is busted. This only applies to single record selection

Parameters
  • array $result

protected array processInitCacheData(array $data)

processInitCacheData initializes the cache data of each record

Parameters
  • array $data

protected array runSelect()

runSelect runs the query as a "select" statement against the datasource

protected void validateDirectoryName(string $dirName=NULL)

validateDirectoryName validates the supplied directory path

Parameters
  • string $dirName

protected void validateFileName(string $fileName=NULL)

validateFileName validates the supplied filename, extension and path

Parameters
  • string $fileName

protected void validateFileNameExtension(string $fileName, array $allowedExtensions)

validateFileNameExtension validates whether a file has an allowed extension

Parameters
  • string $fileName - Specifies a path to validate
  • array $allowedExtensions - A list of allowed file extensions

protected void validateFileNamePath(string $filePath, int $maxNesting=5)

validateFileNamePath validates a template path Template directory and file names can contain only alphanumeric symbols, dashes and dots.

Parameters
  • string $filePath - Specifies a path to validate
  • int $maxNesting - Specifies the maximum allowed nesting level

protected boolean validateFileNamePattern(string $fileName)

validateFileNamePattern validates a template file or directory name template file names can contain only alphanumeric symbols, dashes, underscores and dots.

Parameters
  • string $fileName - Specifies a path to validate