GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Data Fields | Private Member Functions | Private Attributes
Entry_Collection Class Reference

If this file is called directly, abort. More...

Inheritance diagram for Entry_Collection:
Collection

Public Member Functions

 add ( $entry)
 Add an to this collection. More...
 
 add_count_callback ( $callback)
 Defer counting of data to the provided callable. More...
 
 add_fetch_callback ( $callback)
 Defer fetching of data to the provided callable. More...
 
 all ()
 Get the entries as an array. More...
 
 clear ()
 
 fetch ()
 Hydrate this collection now. More...
 
 filter (\GV\Entry_Filter $filter)
 Apply a filter to the current collection. More...
 
 first ()
 Get the first in this collection. More...
 
 get ( $entry_id, $backend='gravityforms')
 Get a from this list. More...
 
 last ()
 Get the last in this collection. More...
 
 limit ( $limit)
 Limit the fetch to a specified window. More...
 
 offset ( $offset)
 Add an $offset to these entries. More...
 
 page ( $page)
 Set the current page. More...
 
 pluck ( $key)
 Pluck by key. More...
 
 sort ( $sort)
 Sort. More...
 
 total ()
 Count the total number of objects that are possible to get. More...
 
- Public Member Functions inherited from Collection
 add ( $value)
 Add an object to this collection. More...
 
 all ()
 Returns all the objects in this collection as an an array. More...
 
 clear ()
 Clear this collection. More...
 
 count ()
 Returns the count of the objects in this collection. More...
 
 first ()
 Get the first added object. More...
 
 last ()
 Get the last added object. More...
 
 merge (\GV\Collection $collection)
 Merge another collection into here. More...
 

Data Fields

 $current_page = 1
 
 $filters = array()
 
 $limit = 20
 
 $offset = 0
 
 $sorts = array()
 

Private Member Functions

 add_callback ( $type, $callback)
 Add a callback for lazy loading/counting. More...
 

Private Attributes

 $callbacks = array()
 
 $fetched = -1
 

Detailed Description

If this file is called directly, abort.

A collection of objects.

Definition at line 12 of file class-gv-collection-entry.php.

Member Function Documentation

◆ add()

add (   $entry)

Add an to this collection.

Parameters
\GV\Entry$entryThe entry to add to the internal array.
Since
2.0
Returns
void

Definition at line 64 of file class-gv-collection-entry.php.

References $entry, and gravityview().

◆ add_callback()

add_callback (   $type,
  $callback 
)
private

Add a callback for lazy loading/counting.

Parameters
callable$callbackThe callback to call when needed.
Returns
void

Definition at line 364 of file class-gv-collection-entry.php.

◆ add_count_callback()

add_count_callback (   $callback)

Defer counting of data to the provided callable.

The callback signature should be as follows: int callback( $filter );

The methods that trigger the callback are:

  • ::count
Parameters
callable$callbackThe callback to call when needed.

Definition at line 353 of file class-gv-collection-entry.php.

◆ add_fetch_callback()

add_fetch_callback (   $callback)

Defer fetching of data to the provided callable.

The callback signature should be as follows: callback( $filter, $sort, $offset );

The methods that trigger the callback are:

  • ::fetch

::fetch is triggered via:

  • ::all
  • ::last
Parameters
callable$callbackThe callback to call when needed.

Definition at line 333 of file class-gv-collection-entry.php.

◆ all()

all ( )

Get the entries as an array.

Since
2.0
Returns
[] The entries as an array.

Definition at line 129 of file class-gv-collection-entry.php.

◆ clear()

clear ( )

Definition at line 375 of file class-gv-collection-entry.php.

◆ fetch()

fetch ( )

Hydrate this collection now.

Since
2.0
Returns
This collection, now hydrated.

Calculate the offsets.

Call all lazy callbacks.

Definition at line 195 of file class-gv-collection-entry.php.

References GV\$i.

◆ filter()

filter ( \GV\Entry_Filter  $filter)

Apply a filter to the current collection.

This operation is non-destructive as a copy of the collection is returned.

Parameters
\GV\Entry_Filter$filterThe filter to be applied.
Since
2.0
Returns
A copy of the this collection with the filter applied.

Definition at line 233 of file class-gv-collection-entry.php.

◆ first()

first ( )

Get the first in this collection.

Since
2.0
Returns
|null The first entry or null.

Definition at line 180 of file class-gv-collection-entry.php.

◆ get()

get (   $entry_id,
  $backend = 'gravityforms' 
)

Get a from this list.

Parameters
int$entry_idThe ID of the entry to get.
string$backendThe form backend identifier, allows for multiple form backends in the future. Unused until then.
Since
2.0
Returns
|null The with the $entry_id as the ID, or null if not found.

Definition at line 85 of file class-gv-collection-entry.php.

References $entry.

◆ last()

last ( )

Get the last in this collection.

Since
2.0
Returns
|null The last entry or null.

Definition at line 165 of file class-gv-collection-entry.php.

◆ limit()

int The limit (   $limit)

Limit the fetch to a specified window.

Parameters
int$limitThe limit.
Since
2.0
Returns
A copy of the this collection with the limit applied.

Definition at line 271 of file class-gv-collection-entry.php.

◆ offset()

int The offset (   $offset)

Add an $offset to these entries.

Useful, you know, for pagination and stuff. Not too useful directly.

See also
::page()
Parameters
int$offsetThe number of entries to skip in the database.
Since
2.0
Returns
A copy of the this collection with the offset applied.

Definition at line 292 of file class-gv-collection-entry.php.

◆ page()

int The current page (   $page)

Set the current page.

Parameters
int$pageSet the current page to this page. Ends up agumenting the $offset in
Returns
A copy of the this collection with the offset applied.

Definition at line 306 of file class-gv-collection-entry.php.

◆ pluck()

pluck (   $key)

Pluck by key.

Since
develop
Parameters
string$keyThe key to pluck by.
Returns
array The plucked values.

Definition at line 146 of file class-gv-collection-entry.php.

References $entry.

◆ sort()

sort (   $sort)

Sort.

Parameters
\GV\Entry_Sort$sortThe sort to apply to this collection.
Since
2.0
Returns
A copy of the this collection with the sort applied.

Definition at line 252 of file class-gv-collection-entry.php.

◆ total()

total ( )

Count the total number of objects that are possible to get.

Since
2.0
Returns
int The total number of entries that are fetchable.

Call all lazy callbacks.

Definition at line 102 of file class-gv-collection-entry.php.

Field Documentation

◆ $callbacks

$callbacks = array()
private

Definition at line 23 of file class-gv-collection-entry.php.

◆ $current_page

$current_page = 1

Definition at line 48 of file class-gv-collection-entry.php.

◆ $fetched

$fetched = -1
private

Definition at line 53 of file class-gv-collection-entry.php.

◆ $filters

$filters = array()

Definition at line 28 of file class-gv-collection-entry.php.

◆ $limit

$limit = 20

Definition at line 43 of file class-gv-collection-entry.php.

◆ $offset

$offset = 0

Definition at line 38 of file class-gv-collection-entry.php.

◆ $sorts

$sorts = array()

Definition at line 33 of file class-gv-collection-entry.php.


The documentation for this class was generated from the following file: