|
| static | get ($action, $accessToken=null, $httpClient=null, CacheInterface $cache=null, $apiCacheTTL=5) |
| |
| static | defaultCache () |
| |
This class embodies a connection to your prismic.io repository's API. Initialize it with Prismic::Api::get(), and use your Prismic::Api::forms() to make API calls (read more in the kit's README file)
§ bookmark()
| Prismic\Api::bookmark |
( |
|
$name | ) |
|
From a bookmark name, returns the ID of the attached document. You can then use this ID for anything, for instance to query with a predicate that looks like this [:d = at(document.id, "abcdefghijkl")]. Most starter projects embed a helper to query a document from their ID string, which makes this even easier.
- Parameters
-
| string | $name | the bookmark name to use |
- Returns
- string|null the ID string for a given bookmark name
§ bookmarks()
| Prismic\Api::bookmarks |
( |
| ) |
|
Returns the list of all bookmarks on the repository. If you're looking for a document from it's bookmark name, you should use the bookmark() function.
- Returns
- array the array of bookmarks
§ defaultCache()
| static Prismic\Api::defaultCache |
( |
| ) |
|
|
static |
Use the APC cache if APC is activated on the server, otherwise fallback to the noop cache (no cache)
- Returns
- ApcCache::NoCache
§ forms()
Returns all forms of type Prismic::SearchForm that are available for this repository's API. The intended syntax of a call is: api->forms()->everything->query(query)->ref(ref)->submit(). Learn more about those keywords in prismic.io's documentation on our developers' portal.
- Returns
- all forms
§ get()
| static Prismic\Api::get |
( |
|
$action, |
|
|
|
$accessToken = null, |
|
|
|
$httpClient = null, |
|
|
CacheInterface |
$cache = null, |
|
|
|
$apiCacheTTL = 5 |
|
) |
| |
|
static |
This is the endpoint to build your API, and is a static method. If your API is set to "public" or "open", you can instantiate your Api object just like this: Api::get('http://idofyourrepository.prismic.io/api')
- Parameters
-
| string | $action | the URL of your repository API's endpoint |
| string | $accessToken | a permanent access token to use to access your content, for instance if your repository API is set to private |
| Client | $httpClient | Custom Guzzle http client |
| CacheInterface | $cache | Cache implementation |
| int | $apiCacheTTL | max time to keep the API object in cache (in seconds) |
- Exceptions
-
- Returns
- Api the Api object, usable to perform queries
§ getByID()
| Prismic\Api::getByID |
( |
|
$id | ) |
|
Search a document by its id
- Parameters
-
| string | $id | the requested id |
- Returns
- Prismic::Document the resulting document (null if no match)
§ getByIDs()
| Prismic\Api::getByIDs |
( |
|
$ids | ) |
|
Return a set of document from their ids
- Parameters
-
| array | $ids | array of strings, the requested ids |
- Returns
- Prismic::Response the response, including documents and pagination information
§ getByUID()
| Prismic\Api::getByUID |
( |
|
$type, |
|
|
|
$uid |
|
) |
| |
Search a document by its uid
- Parameters
-
| string | $type | the custom type of the requested document |
| string | $uid | the requested uid |
- Returns
- Prismic::Document the resulting document (null if no match)
§ getCache()
| Prismic\Api::getCache |
( |
| ) |
|
Accessing the cache object specifying how to store the cache
- Returns
- CacheInterface the cache object itself
§ getData()
Accessing raw data returned by the /api endpoint
- Returns
- ApiData the raw data
§ getExperiments()
| Prismic\Api::getExperiments |
( |
| ) |
|
§ getHttpClient()
| Prismic\Api::getHttpClient |
( |
| ) |
|
Accessing the underlying Guzzle HTTP client
- Returns
- HttpAdapterInterface
§ getRef()
| Prismic\Api::getRef |
( |
|
$label | ) |
|
- Parameters
-
| string | $label | the label of the requested ref |
- Returns
- Ref a reference or null
§ master()
Returns the master ref repository: the ref which is to be used to query content that is live right now.
- Returns
- string the master ref
§ oauthInitiateEndpoint()
| Prismic\Api::oauthInitiateEndpoint |
( |
| ) |
|
Returning the URL of the endpoint to initiate OAuth authentication.
- Returns
- string the URL of the endpoint
§ oauthTokenEndpoint()
| Prismic\Api::oauthTokenEndpoint |
( |
| ) |
|
Returning the URL of the endpoint to use OAuth authentication.
- Returns
- string the URL of the endpoint
§ previewSession()
| Prismic\Api::previewSession |
( |
|
$token, |
|
|
|
$linkResolver, |
|
|
|
$defaultUrl |
|
) |
| |
Return the URL to display a given preview
- Parameters
-
| string | $token | as received from Prismic server to identify the content to preview |
| \Prismic\LinkResolver | $linkResolver | the link resolver to build URL for your site |
| string | $defaultUrl | the URL to default to return if the preview doesn't correspond to a document (usually the home page of your site) |
- Returns
- string the URL you should redirect the user to preview the requested change
§ query()
| Prismic\Api::query |
( |
|
$q, |
|
|
|
$options = array() |
|
) |
| |
Shortcut to query on the default reference. Use the reference from previews or experiment cookie, fallback to the master reference otherwise.
- Parameters
-
| string | array | \Prismic\Predicate | $q | the query, as a string, predicate or array of predicates |
| array | $options | query options: pageSize, orderings, etc. |
- Returns
- Prismic::Response the response, including documents and pagination information
§ queryFirst()
| Prismic\Api::queryFirst |
( |
|
$q | ) |
|
Return the first document matching the query Use the reference from previews or experiment cookie, fallback to the master reference otherwise.
- Parameters
-
| string | array | \Prismic\Predicate | $q | the query, as a string, predicate or array of predicates |
- Returns
- Prismic::Document the resulting document, or null
§ refs()
Returns all of the repository's references (queryable points in time)
- Returns
- array the array of references, with their IDs, labels, ...
§ submit()
Submit several requests in parallel
- Returns
- array
§ $accessToken
| Prismic\Api::$accessToken |
|
protected |
string the API's access token to be used with each API call
§ $data
ApiData the raw data of the /api document (prefer to use this class's instance methods)
§ EXPERIMENTS_COOKIE
| const Prismic\Api::EXPERIMENTS_COOKIE = "io.prismic.experiment" |
Name of the cookie that will be used to remember the experiment reference
§ PREVIEW_COOKIE
| const Prismic\Api::PREVIEW_COOKIE = "io.prismic.preview" |
Name of the cookie that will be used to remember the preview reference
§ VERSION
| const Prismic\Api::VERSION = "3.0.0" |
The documentation for this class was generated from the following file: