class Finder

Properties

protected SourceInterface $source

The source instance.

protected Processor $processor

The source query processor instance.

protected Model $model

The model being queried.

array $extensions

Filter by these file extensions.

array $columns

The columns that should be returned.

string $in

The directory name which the finder is targeting.

bool $select

Query should pluck a single record.

string $fileMatch

Match files using the specified pattern.

array $orders

The orderings for the query.

int $limit

The maximum number of records to return.

int $offset

The number of records to skip.

protected string $cacheKey

The key that should be used when caching the query.

protected int $cacheSeconds

The number of seconds to cache the query.

protected array $cacheTags

The tags for the query cache.

protected string $cacheDriver

The cache driver to be used.

protected bool $loadedFromCache

Internal variable to specify if the record was loaded from cache.

Methods

__construct(SourceInterface $source, Processor $processor)

Create a new query finder instance.

$this
whereFileName(string $fileName)

Switches mode to select a single template by its name.

$this
in(string $dirName)

Set the directory name which the finder is targeting.

$this
offset(int $value)

Set the "offset" value of the query.

skip(int $value)

Alias to set the "offset" value of the query.

$this
limit(int $value)

Set the "limit" value of the query.

take(int $value)

Alias to set the "limit" value of the query.

mixed|Finder
find(string $fileName)

Find a single template by its file name.

mixed|Finder
first()

Execute the query and get the first result.

Collection|Finder[]
get(array $columns = ['*'])

Execute the query as a "select" statement.

array|Collection
lists(string $column, string $key = null)

Get an array with the values of a given column.

bool
insert(array $values)

Insert a new record into the source.

int
update(array $values)

Update a record in the source.

bool
delete()

Delete a source from the filesystem.

int
lastModified()

Returns the last modified time of the object.

Collection|Finder[]
getFresh(array $columns = ['*'])

Execute the query as a fresh "select" statement.

array
runSelect()

Run the query as a "select" statement against the source.

$this
setModel(Model $model)

Set a model instance for the model being queried.

Model[]
getModels(array $results)

Get the hydrated models.

getModel()

Get the model instance being queried.

bool
validateFileName(string $fileName = null)

Validate the supplied filename, extension and path.

void
validateFileNameExtension(string $fileName, array $allowedExtensions)

Validates whether a file has an allowed extension.

bool
validateFileNamePath(string $filePath, int $maxNesting = 2)

Validates a template path.

$this
remember(DateTime|int $seconds, string $key = null)

Indicate that the query results should be cached.

$this
rememberForever(string $key = null)

Indicate that the query results should be cached forever.

$this
cacheTags(array|mixed $cacheTags)

Indicate that the results, if cached, should use the given cache tags.

$this
cacheDriver(string $cacheDriver)

Indicate that the results, if cached, should use the given cache driver.

array
getCached(array $columns = ['*'])

Execute the query as a cached "select" statement.

bool
isCacheBusted(array $result)

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

CacheManager
getCache()

Get the cache object with tags assigned, if applicable.

string
getCacheKey()

Get a unique cache key for the complete query.

string
generateCacheKey()

Generate the unique cache key for the query.

getCacheCallback($columns)

Get the Closure callback used when caching queries.

array
processInitCacheData(array $data)

Initialize the cache data of each record.

static 
clearInternalCache()

Clears the internal request-level object cache.

mixed
__call(string $method, array $parameters)

Handle dynamic method calls into the method.

Details

at line 118
__construct(SourceInterface $source, Processor $processor)

Create a new query finder instance.

Parameters

SourceInterface $source
Processor $processor

at line 131
$this whereFileName(string $fileName)

Switches mode to select a single template by its name.

Parameters

string $fileName

Return Value

$this

at line 145
$this in(string $dirName)

Set the directory name which the finder is targeting.

Parameters

string $dirName

Return Value

$this

at line 159
$this offset(int $value)

Set the "offset" value of the query.

Parameters

int $value

Return Value

$this

at line 173
Finder|Finder skip(int $value)

Alias to set the "offset" value of the query.

Parameters

int $value

Return Value

Finder|Finder

at line 185
$this limit(int $value)

Set the "limit" value of the query.

Parameters

int $value

Return Value

$this

at line 201
Finder|Finder take(int $value)

Alias to set the "limit" value of the query.

Parameters

int $value

Return Value

Finder|Finder

at line 213
mixed|Finder find(string $fileName)

Find a single template by its file name.

Parameters

string $fileName

Return Value

mixed|Finder

at line 222
mixed|Finder first()

Execute the query and get the first result.

Return Value

mixed|Finder

at line 234
Collection|Finder[] get(array $columns = ['*'])

Execute the query as a "select" statement.

Parameters

array $columns

Return Value

Collection|Finder[]

at line 256
array|Collection lists(string $column, string $key = null)

Get an array with the values of a given column.

Parameters

string $column
string $key

Return Value

array|Collection

at line 272
bool insert(array $values)

Insert a new record into the source.

Parameters

array $values

Return Value

bool

at line 299
int update(array $values)

Update a record in the source.

Parameters

array $values

Return Value

int

at line 330
bool delete()

Delete a source from the filesystem.

Return Value

bool

at line 348
int lastModified()

Returns the last modified time of the object.

Return Value

int

at line 368
Collection|Finder[] getFresh(array $columns = ['*'])

Execute the query as a fresh "select" statement.

Parameters

array $columns

Return Value

Collection|Finder[]

at line 383
protected array runSelect()

Run the query as a "select" statement against the source.

Return Value

array

at line 404
$this setModel(Model $model)

Set a model instance for the model being queried.

Parameters

Model $model

Return Value

$this

at line 422
Model[] getModels(array $results)

Get the hydrated models.

Parameters

array $results

Return Value

Model[]

at line 444
Model getModel()

Get the model instance being queried.

Return Value

Model

at line 460
protected bool validateFileName(string $fileName = null)

Validate the supplied filename, extension and path.

Parameters

string $fileName

Return Value

bool

at line 487
protected void validateFileNameExtension(string $fileName, array $allowedExtensions)

Validates whether a file has an allowed extension.

Parameters

string $fileName

Specifies a path to validate

array $allowedExtensions

A list of allowed file extensions

Return Value

void

at line 507
protected bool validateFileNamePath(string $filePath, int $maxNesting = 2)

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

Return Value

bool

at line 545
$this remember(DateTime|int $seconds, string $key = null)

Indicate that the query results should be cached.

Parameters

DateTime|int $seconds
string $key

Return Value

$this

at line 559
$this rememberForever(string $key = null)

Indicate that the query results should be cached forever.

Parameters

string $key

Return Value

$this

at line 571
$this cacheTags(array|mixed $cacheTags)

Indicate that the results, if cached, should use the given cache tags.

Parameters

array|mixed $cacheTags

Return Value

$this

at line 585
$this cacheDriver(string $cacheDriver)

Indicate that the results, if cached, should use the given cache driver.

Parameters

string $cacheDriver

Return Value

$this

at line 599
array getCached(array $columns = ['*'])

Execute the query as a cached "select" statement.

Parameters

array $columns

Return Value

array

at line 654
protected bool isCacheBusted(array $result)

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

Parameters

array $result

Return Value

bool

at line 677
protected CacheManager getCache()

Get the cache object with tags assigned, if applicable.

Return Value

CacheManager

at line 688
string getCacheKey()

Get a unique cache key for the complete query.

Return Value

string

at line 697
string generateCacheKey()

Generate the unique cache key for the query.

Return Value

string

at line 716
protected Closure getCacheCallback($columns)

Get the Closure callback used when caching queries.

Parameters

$columns

Return Value

Closure

at line 730
protected array processInitCacheData(array $data)

Initialize the cache data of each record.

Parameters

array $data

Return Value

array

at line 746
static clearInternalCache()

Clears the internal request-level object cache.

at line 760
mixed __call(string $method, array $parameters)

Handle dynamic method calls into the method.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException