-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PCC-61: Changing ContentApi to ArticleApi. (#9)
- Loading branch information
1 parent
2347dbf
commit 33ef588
Showing
11 changed files
with
369 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
services: | ||
pcx_connect.pcc_api_client: | ||
class: Drupal\pcx_connect\Service\PccApiClient | ||
class: Drupal\pcx_connect\Pcc\Service\PccApiClient | ||
arguments: ['@logger.factory'] | ||
pcx_connect.pcc_content_api: | ||
class: Drupal\pcx_connect\Service\PccContentApi | ||
arguments: ['@pcx_connect.pcc_api_client', '@logger.factory'] | ||
pcx_connect.articles_mapper: | ||
class: Drupal\pcx_connect\Pcc\Mapper\PccArticlesMapper | ||
pcx_connect.pcc_articles_api: | ||
class: Drupal\pcx_connect\Pcc\Service\PccArticlesApi | ||
arguments: ['@pcx_connect.pcc_api_client', '@pcx_connect.articles_mapper', '@logger.factory'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace Drupal\pcx_connect\Pcc\Entity; | ||
|
||
class PccSiteArticle { | ||
|
||
/** | ||
* Article ID. | ||
* | ||
* @var string $id | ||
*/ | ||
public string $id; | ||
|
||
/** | ||
* Article Slug. | ||
* | ||
* @var string $slug | ||
*/ | ||
public string $slug; | ||
|
||
/** | ||
* Article Title. | ||
* | ||
* @var string $title | ||
*/ | ||
public string $title; | ||
|
||
/** | ||
* Site ID. | ||
* | ||
* @var string $siteId | ||
*/ | ||
public string $siteId; | ||
|
||
/** | ||
* Article Content. | ||
* | ||
* @var string $content | ||
*/ | ||
public string $content; | ||
|
||
/** | ||
* Article snippet. | ||
* | ||
* @var string $snippet | ||
*/ | ||
public string $snippet; | ||
|
||
/** | ||
* Article Tags. | ||
* | ||
* @todo Redefine exact type of Tags, id or string. | ||
* | ||
* @var array $tags | ||
*/ | ||
public array $tags; | ||
|
||
/** | ||
* Published Date. | ||
* | ||
* @var string $publishedDate | ||
*/ | ||
public string $publishedDate; | ||
|
||
/** | ||
* Updated Date. | ||
* | ||
* @var string $updatedAt | ||
*/ | ||
public string $updatedAt; | ||
|
||
public static function getDefaultFields() { | ||
return [ | ||
'id', | ||
'slug', | ||
'title', | ||
'siteId', | ||
'content', | ||
'snippet', | ||
'tags', | ||
'publishedDate', | ||
'updatedAt', | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Drupal\pcx_connect\Pcc\Mapper; | ||
|
||
use PccPhpSdk\api\Response\Article; | ||
use PccPhpSdk\api\Response\PaginatedArticles; | ||
|
||
class PccArticlesMapper implements PccArticlesMapperInterface { | ||
|
||
public function toArticleData(Article $article): array { | ||
return (array) $article; | ||
} | ||
|
||
public function toArticlesList(PaginatedArticles $paginatedArticles): array { | ||
$list = []; | ||
foreach ($paginatedArticles->articles as $article) { | ||
$list[] = $this->toArticleData($article); | ||
} | ||
return $list; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Drupal\pcx_connect\Pcc\Mapper; | ||
|
||
use PccPhpSdk\api\Response\Article; | ||
use PccPhpSdk\api\Response\PaginatedArticles; | ||
|
||
interface PccArticlesMapperInterface { | ||
|
||
function toArticleData(Article $article): array; | ||
|
||
function toArticlesList(PaginatedArticles $paginatedArticles): array; | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
src/Service/PccApiClient.php → src/Pcc/Service/PccApiClient.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.