class HttpServiceApiWrapperPosts in HTTP Client Manager 8.2
Class HttpServiceApiWrapperPosts.
@package Drupal\http_client_manager\Plugin\HttpServiceApiWrapper
Hierarchy
- class \Drupal\http_client_manager\Plugin\HttpServiceApiWrapper\HttpServiceApiWrapperBase implements HttpServiceApiWrapperInterface uses StringTranslationTrait
- class \Drupal\http_client_manager_example\Plugin\HttpServiceApiWrapper\HttpServiceApiWrapperPosts
Expanded class hierarchy of HttpServiceApiWrapperPosts
1 string reference to 'HttpServiceApiWrapperPosts'
- http_client_manager_example.services.yml in modules/
http_client_manager_example/ http_client_manager_example.services.yml - modules/http_client_manager_example/http_client_manager_example.services.yml
1 service uses HttpServiceApiWrapperPosts
File
- modules/
http_client_manager_example/ src/ Plugin/ HttpServiceApiWrapper/ HttpServiceApiWrapperPosts.php, line 13
Namespace
Drupal\http_client_manager_example\Plugin\HttpServiceApiWrapperView source
class HttpServiceApiWrapperPosts extends HttpServiceApiWrapperBase {
/**
* {@inheritdoc}
*/
public function getHttpClient() {
return $this->httpClientFactory
->get('example_services_yaml');
}
/**
* Create Post.
*
* @param string $title
* The Post title.
* @param mixed $body
* The Post body.
*
* @return array
* The service response array.
*/
public function createPost($title, $body) {
$args = [
'userId' => $this->currentUser
->id(),
'title' => $title,
'body' => $body,
];
return $this
->call(Posts::CREATE_POST, $args)
->toArray();
}
/**
* Find Posts.
*
* @return array
* An array of posts.
*/
public function findPosts() {
return $this
->call(Posts::FIND_POSTS)
->toArray();
}
/**
* Find Post.
*
* @param int $postId
* The Post id.
*
* @return array
* An array representing the Post matching the provided id.
*/
public function findPost($postId) {
$args = [
'postId' => (int) $postId,
];
return $this
->call(Posts::FIND_POST, $args)
->toArray();
}
/**
* Find Comments.
*
* @param null|int $postId
* The Post id from which extract the related Comments.
*
* @return array
* An array of Comments related to the given Post.
*/
public function findComments($postId = NULL) {
$args = is_null($postId) ? [] : [
'postId' => (int) $postId,
];
return $this
->call(Posts::FIND_COMMENTS, $args)
->toArray();
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HttpServiceApiWrapperBase:: |
protected | property | Drupal\Core\Cache\CacheBackendInterface definition. | |
HttpServiceApiWrapperBase:: |
protected | property | The current user. | |
HttpServiceApiWrapperBase:: |
protected | property | The Http Client Factory Service. | |
HttpServiceApiWrapperBase:: |
protected | property | The Language Manager Service. | |
HttpServiceApiWrapperBase:: |
protected | property | The Messenger Service. | |
HttpServiceApiWrapperBase:: |
constant | The cache id prefix. | ||
HttpServiceApiWrapperBase:: |
protected | function | Call REST web services. | |
HttpServiceApiWrapperBase:: |
protected | function | Call by Request. | |
HttpServiceApiWrapperBase:: |
protected | function | Get cached HTTP Config Request. | |
HttpServiceApiWrapperBase:: |
protected | function | Get response. | |
HttpServiceApiWrapperBase:: |
public | function |
Executes an HTTP Config Request. Overrides HttpServiceApiWrapperInterface:: |
|
HttpServiceApiWrapperBase:: |
protected | function | Logs a command exception. | |
HttpServiceApiWrapperBase:: |
public | function | HttpServiceApiWrapperBase constructor. | |
HttpServiceApiWrapperPosts:: |
public | function | Create Post. | |
HttpServiceApiWrapperPosts:: |
public | function | Find Comments. | |
HttpServiceApiWrapperPosts:: |
public | function | Find Post. | |
HttpServiceApiWrapperPosts:: |
public | function | Find Posts. | |
HttpServiceApiWrapperPosts:: |
public | function |
Get HTTP Client. Overrides HttpServiceApiWrapperInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |