FeedArticleApiHandler
in package
Sub-handler for feed article API operations.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
-
createTextsFromEdited()
: array{success: bool, created: int, archived: int, errors: list
, error?: string} - Create texts from articles the caller has already edited.
- deleteArticles() : array{success: bool, deleted: int, error?: string}
- Delete articles.
-
extractArticles()
: array{success: bool, texts: list
>, language_id: int, errors: list } - Extract selected articles into editable texts without importing them.
- formatArticleRecord() : array<string|int, mixed>
- Format an article record for API response.
- formatDeleteArticles() : array<string|int, mixed>
- Format response for deleting articles.
- formatGetArticles() : array<string|int, mixed>
- Format response for getting articles.
- formatImportArticles() : array<string|int, mixed>
- Format response for importing articles.
- formatResetErrorArticles() : array<string|int, mixed>
- Format response for resetting error articles.
- getArticles() : array{articles?: array, pagination?: array, feed?: array, error?: string}
- Get articles for a feed.
- importArticles() : array{success: bool, imported: int, errors: array}
- Import articles as texts.
- resetErrorArticles() : array{success: bool, reset: int}
- Reset error articles (remove leading space from links).
- resolveFeedTagAndLimit() : array{0: string, 1: int}
- Resolve the tag name and max-texts limit a feed's options imply.
Properties
$feedFacade
private
FeedFacade
$feedFacade
Methods
__construct()
public
__construct(FeedFacade $feedFacade) : mixed
Parameters
- $feedFacade : FeedFacade
createTextsFromEdited()
Create texts from articles the caller has already edited.
public
createTextsFromEdited(array<string, mixed> $data) : array{success: bool, created: int, archived: int, errors: list, error?: string}
The write half of extractArticles(). importArticles() extracts
and writes in a single step, so it has no way to accept a title or body
the user changed in between; this takes the edited rows instead.
The tag and the max-texts limit come from the feed's own options, never
from the payload. The retired edit_text_form.php posted Nf_Max_Texts
as a hidden field, so a caller could opt out of archiving by editing it;
it also never posted a tag at all, which is why texts created through
that form came out untagged.
Parameters
- $data : array<string, mixed>
-
Payload carrying
feed_idandtexts
Return values
array{success: bool, created: int, archived: int, errors: listdeleteArticles()
Delete articles.
public
deleteArticles(int $feedId[, array<string|int, mixed> $articleIds = [] ]) : array{success: bool, deleted: int, error?: string}
Parameters
- $feedId : int
-
Feed ID
- $articleIds : array<string|int, mixed> = []
-
Article IDs to delete (empty = all)
Return values
array{success: bool, deleted: int, error?: string}extractArticles()
Extract selected articles into editable texts without importing them.
public
extractArticles(array<string, mixed> $data) : array{success: bool, texts: list>, language_id: int, errors: list}
This is the read half of importArticles(): it runs the same
extraction, but returns the texts for the caller to edit and submit
rather than writing them. It performs no writes except marking links
whose extraction failed, which importArticles() does too — leaving
them unmarked would make the same article fail again on every attempt.
Parameters
- $data : array<string, mixed>
-
Request payload carrying
article_ids
Return values
array{success: bool, texts: listformatArticleRecord()
Format an article record for API response.
public
formatArticleRecord(array<string|int, mixed> $row) : array<string|int, mixed>
Parameters
- $row : array<string|int, mixed>
-
Database record
Return values
array<string|int, mixed> —Formatted article data
formatDeleteArticles()
Format response for deleting articles.
public
formatDeleteArticles(int $feedId[, array<string|int, mixed> $articleIds = [] ]) : array<string|int, mixed>
Parameters
- $feedId : int
-
Feed ID
- $articleIds : array<string|int, mixed> = []
-
Article IDs (empty = all)
Return values
array<string|int, mixed> —Deletion result
formatGetArticles()
Format response for getting articles.
public
formatGetArticles(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
-
Filter parameters
Return values
array<string|int, mixed> —Articles with pagination
formatImportArticles()
Format response for importing articles.
public
formatImportArticles(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
-
Import data
Return values
array<string|int, mixed> —Import result
formatResetErrorArticles()
Format response for resetting error articles.
public
formatResetErrorArticles(int $feedId) : array<string|int, mixed>
Parameters
- $feedId : int
-
Feed ID
Return values
array<string|int, mixed> —Reset result
getArticles()
Get articles for a feed.
public
getArticles(array<string|int, mixed> $params) : array{articles?: array, pagination?: array, feed?: array, error?: string}
Parameters
- $params : array<string|int, mixed>
-
Parameters:
- feed_id: int (required)
- query: string (search)
- page: int
- per_page: int
- sort: int (1=date desc, 2=date asc, 3=title)
Return values
array{articles?: array, pagination?: array, feed?: array, error?: string}importArticles()
Import articles as texts.
public
importArticles(array<string|int, mixed> $data) : array{success: bool, imported: int, errors: array}
Parameters
- $data : array<string|int, mixed>
-
Import data:
- article_ids: array of article IDs
Return values
array{success: bool, imported: int, errors: array}resetErrorArticles()
Reset error articles (remove leading space from links).
public
resetErrorArticles(int $feedId) : array{success: bool, reset: int}
Parameters
- $feedId : int
-
Feed ID
Return values
array{success: bool, reset: int}resolveFeedTagAndLimit()
Resolve the tag name and max-texts limit a feed's options imply.
private
resolveFeedTagAndLimit(array<string, mixed> $row) : array{0: string, 1: int}
Both fall back the same way the import path has always done: an unset
tag becomes the feed name truncated to 20 characters, and an unset
limit becomes the global set-max-texts-per-feed setting.
Parameters
- $row : array<string, mixed>
-
Feed record carrying NfOptions/NfName
Return values
array{0: string, 1: int} —Tag name and max texts