2017 © Pedro Peláez
 

craft-plugin agnostic-fetch

uniform syntax for fetching elements whether or not they have been eager loaded

image

marionnewlevant/agnostic-fetch

uniform syntax for fetching elements whether or not they have been eager loaded

  • Wednesday, February 14, 2018
  • by marionnewlevant
  • Repository
  • 1 Watchers
  • 5 Stars
  • 221 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 7 Versions
  • 21 % Grown

The README.md

Agnostic Fetch plugin for Craft CMS 3.x

Craft plugin that provides uniform syntax for fetching elements whether or not they have been eager loaded, (*1)

Installation

To install Agnostic Fetch, follow these steps:, (*2)

  1. Download & unzip the file, rename the unzipped folder to agnosticfetch and place the agnosticfetch folder into your craft/plugins folder
  2. -OR- do a git clone https://github.com/marionnewlevant/craft3-agnositic_fetch.git directly into your craft/plugins folder, and rename to agnosticfetch. You can then update it with git pull
  3. -OR- install with Composer via composer require marionnewlevant/agnostic-fetch from your project folder
  4. Install plugin in the Craft Control Panel under Settings > Plugins
  5. The plugin folder should be named agnosticfetch for Craft to see it.

Agnostic Fetch works on Craft 3.x., (*3)

Agnostic Fetch Overview

The code to fetch the elements from a Craft Element Query is different when the elements have been eager-loaded. For example, to get the first element of a non eagerly loaded field, someField.one(), but for an eagerly loaded field, someField[0] (and that doesn't even get into the error checking). With Agnostic Fetch, you can do someField | one (or one(someField) or craft.agnosticfetch.one(someField))., (*4)

The Agnostic Fetch functions are available as twig filters, as twig functions, and as craft variables., (*5)

Using Agnostic Fetch

all

Use any of:, (*6)

  • someField | all
  • all(someField)
  • craft.agnosticfetch.all(someField)

one

Use any of:, (*7)

  • someField | one
  • one(someField)
  • craft.agnosticfetch.one(someField)

nth

Use any of:, (*8)

  • someField | nth(index)
  • nth(someField, index)
  • craft.agnosticfetch.nth(someField, index)

(index is based from 0), (*9)

ids

Use any of:, (*10)

  • someField | ids
  • ids(someField)
  • craft.agnosticfetch.ids(someField)

count

Use any of:, (*11)

  • someField | count
  • count(someField)
  • craft.agnosticfetch.count(someField)

isEager

In addition to the fetching functions, isEager will tell you whether elements have been eager loaded or not., (*12)

Use any of:, (*13)

  • someField | isEager
  • isEager(someField)
  • craft.agnosticfetch.isEager(someField)

Brought to you by Marion Newlevant, (*14)

The Versions

14/02 2018

v2.x-dev

2.9999999.9999999.9999999-dev

uniform syntax for fetching elements whether or not they have been eager loaded

  Sources   Download

MIT

The Requires

 

craftcms craft-plugin craft eager agnostic-fetch

14/02 2018

2.0.3

2.0.3.0

uniform syntax for fetching elements whether or not they have been eager loaded

  Sources   Download

MIT

The Requires

 

craftcms craft-plugin craft eager agnostic-fetch

13/02 2018

2.0.2

2.0.2.0

uniform syntax for fetching elements whether or not they have been eager loaded

  Sources   Download

MIT

The Requires

 

craftcms craft-plugin craft eager agnostic-fetch

08/02 2018

2.0.1

2.0.1.0

uniform syntax for fetching elements whether or not they have been eager loaded

  Sources   Download

MIT

The Requires

 

craftcms craft-plugin craft eager agnostic-fetch

23/10 2017

2.0.0

2.0.0.0

uniform syntax for fetching elements whether or not they have been eager loaded

  Sources   Download

MIT

craftcms craft-plugin craft eager agnostic-fetch

29/06 2017

dev-master

9999999-dev

uniform syntax for fetching elements whether or not they have been eager loaded

  Sources   Download

MIT

craftcms craft-plugin craft eager agnosticfetch

06/02 2017

1.0.0

1.0.0.0

uniform syntax for fetching elements whether or not they have been eager loaded

  Sources   Download

MIT

craftcms craft-plugin craft eager agnosticfetch