Documentation

FeedApiHandler
in package
implements ApiRoutableInterface uses ApiRoutableTrait

API handler for feed-related operations.

Delegates to FeedCrudApiHandler, FeedArticleApiHandler, and FeedLoadApiHandler for actual logic.

Tags
since
3.0.0

Table of Contents

Interfaces

ApiRoutableInterface
Interface for API handlers that participate in route dispatch.

Properties

$article  : FeedArticleApiHandler
$crud  : FeedCrudApiHandler
$load  : FeedLoadApiHandler

Methods

__construct()  : mixed
createFeed()  : array{success: bool, feed?: array, error?: string}
Create a new feed.
deleteArticles()  : array{success: bool, deleted: int}
Delete articles.
deleteFeeds()  : array{success: bool, deleted: int}
Delete feeds.
detectFeed()  : array<string|int, mixed>|null
Detect feed format and parse.
formatArticleRecord()  : array<string|int, mixed>
Format an article record for API response.
formatCreateFeed()  : array<string|int, mixed>
Format response for creating feed.
formatDeleteArticles()  : array<string|int, mixed>
Format response for deleting articles.
formatDeleteFeeds()  : array<string|int, mixed>
Format response for deleting feeds.
formatFeedRecord()  : array<string|int, mixed>
Format a feed record for API response.
formatGetArticles()  : array<string|int, mixed>
Format response for getting articles.
formatGetFeed()  : array<string|int, mixed>
Format response for getting single feed.
formatGetFeedList()  : array<string|int, mixed>
Format response for getting feed list.
formatImportArticles()  : array<string|int, mixed>
Format response for importing articles.
formatLoadFeed()  : array{success?: true, message?: string, imported?: int, duplicates?: int, error?: string}
Format response for loading a feed.
formatResetErrorArticles()  : array<string|int, mixed>
Format response for resetting error articles.
formatUpdateFeed()  : array<string|int, mixed>
Format response for updating feed.
getArticles()  : array{articles?: array, pagination?: array, feed?: array, error?: string}
Get articles for a feed.
getFeed()  : array<string|int, mixed>
Get a single feed by ID.
getFeedList()  : array{feeds: array, pagination: array, languages: array}
Get list of feeds with pagination and filtering.
getFeedLoadConfig()  : array<string|int, mixed>
Get feed load configuration for frontend.
getFeedResult()  : string
Update the feeds database and return a result message.
getFeeds()  : array<string|int, mixed>
Get list of feeds (simple version).
getFeedsList()  : array{0: int, 1: int}
Get the list of feeds and insert them into the database.
getFeedsNeedingAutoUpdate()  : array<string|int, mixed>
Get feeds needing auto-update.
getLanguagesForSelect()  : array<string|int, mixed>
Get languages for filter dropdown.
importArticles()  : array{success: bool, imported: int, errors: array}
Import articles as texts.
loadFeed()  : array{success?: true, message?: string, imported?: int, duplicates?: int, error?: string}
Load a feed and return result.
parseFeed()  : array<string|int, mixed>|null
Parse an RSS feed for preview.
resetErrorArticles()  : array{success: bool, reset: int}
Reset error articles (remove leading space from links).
routeDelete()  : JsonResponse
Handle a DELETE request for this resource.
routeGet()  : JsonResponse
Handle a GET request for this resource.
routePost()  : JsonResponse
Handle a POST request for this resource.
routePut()  : JsonResponse
Handle a PUT request for this resource.
updateFeed()  : array{success: bool, feed?: array, error?: string}
Update an existing feed.
frag()  : string
Extract a fragment from the fragments array.

Properties

Methods

createFeed()

Create a new feed.

public createFeed(array<string|int, mixed> $data) : array{success: bool, feed?: array, error?: string}
Parameters
$data : array<string|int, mixed>

Feed data

Return values
array{success: bool, feed?: array, error?: string}

deleteArticles()

Delete articles.

public deleteArticles(int $feedId[, array<string|int, mixed> $articleIds = [] ]) : array{success: bool, deleted: int}
Parameters
$feedId : int

Feed ID

$articleIds : array<string|int, mixed> = []

Article IDs to delete (empty = all)

Return values
array{success: bool, deleted: int}

deleteFeeds()

Delete feeds.

public deleteFeeds(array<string|int, mixed> $feedIds) : array{success: bool, deleted: int}
Parameters
$feedIds : array<string|int, mixed>

Array of feed IDs to delete

Return values
array{success: bool, deleted: int}

detectFeed()

Detect feed format and parse.

public detectFeed(string $sourceUri) : array<string|int, mixed>|null
Parameters
$sourceUri : string

Feed URL

Return values
array<string|int, mixed>|null

Feed data with metadata or null on error

formatArticleRecord()

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

formatCreateFeed()

Format response for creating feed.

public formatCreateFeed(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>

Feed data

Return values
array<string|int, mixed>

Creation result

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

formatDeleteFeeds()

Format response for deleting feeds.

public formatDeleteFeeds(array<string|int, mixed> $feedIds) : array<string|int, mixed>
Parameters
$feedIds : array<string|int, mixed>

Feed IDs

Return values
array<string|int, mixed>

Deletion result

formatFeedRecord()

Format a feed record for API response.

public formatFeedRecord(array<string|int, mixed> $row) : array<string|int, mixed>
Parameters
$row : array<string|int, mixed>

Database record

Return values
array<string|int, mixed>

Formatted feed data

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

formatGetFeed()

Format response for getting single feed.

public formatGetFeed(int $feedId) : array<string|int, mixed>
Parameters
$feedId : int

Feed ID

Return values
array<string|int, mixed>

Feed data

formatGetFeedList()

Format response for getting feed list.

public formatGetFeedList(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>

Filter parameters

Return values
array<string|int, mixed>

Feed list 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

formatLoadFeed()

Format response for loading a feed.

public formatLoadFeed(string $name, int $feedId, string $sourceUri, string $options) : array{success?: true, message?: string, imported?: int, duplicates?: int, error?: string}
Parameters
$name : string

Feed name

$feedId : int

Feed ID

$sourceUri : string

Feed source URI

$options : string

Feed options

Return values
array{success?: true, message?: string, imported?: int, duplicates?: int, error?: string}

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

formatUpdateFeed()

Format response for updating feed.

public formatUpdateFeed(int $feedId, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$feedId : int

Feed ID

$data : array<string|int, mixed>

Feed data

Return values
array<string|int, mixed>

Update 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

Return values
array{articles?: array, pagination?: array, feed?: array, error?: string}

getFeed()

Get a single feed by ID.

public getFeed(int $feedId) : array<string|int, mixed>
Parameters
$feedId : int

Feed ID

Return values
array<string|int, mixed>

Feed data or error

getFeedList()

Get list of feeds with pagination and filtering.

public getFeedList(array<string|int, mixed> $params) : array{feeds: array, pagination: array, languages: array}
Parameters
$params : array<string|int, mixed>

Filter parameters

Return values
array{feeds: array, pagination: array, languages: array}

getFeedLoadConfig()

Get feed load configuration for frontend.

public getFeedLoadConfig(int $feedId[, bool $checkAutoupdate = false ]) : array<string|int, mixed>
Parameters
$feedId : int

Feed ID

$checkAutoupdate : bool = false

Check auto-update feeds

Return values
array<string|int, mixed>

Configuration

getFeedResult()

Update the feeds database and return a result message.

public getFeedResult(int $importedFeed, int $nif, string $nfname, int $nfid, string $nfoptions) : string
Parameters
$importedFeed : int

Number of imported feeds

$nif : int

Number of duplicated feeds

$nfname : string

News feed name

$nfid : int

News feed ID

$nfoptions : string

News feed options

Return values
string

Result message

getFeeds()

Get list of feeds (simple version).

public getFeeds([int|null $languageId = null ]) : array<string|int, mixed>
Parameters
$languageId : int|null = null

Language ID filter (null for all)

Return values
array<string|int, mixed>

Array of feeds

getFeedsList()

Get the list of feeds and insert them into the database.

public getFeedsList(array<string|int, array<string, string>> $feed, int $nfid) : array{0: int, 1: int}
Parameters
$feed : array<string|int, array<string, string>>

A feed with articles

$nfid : int

News feed ID

Return values
array{0: int, 1: int}

Number of imported feeds and number of duplicated feeds.

getFeedsNeedingAutoUpdate()

Get feeds needing auto-update.

public getFeedsNeedingAutoUpdate() : array<string|int, mixed>
Return values
array<string|int, mixed>

Array of feeds

getLanguagesForSelect()

Get languages for filter dropdown.

public getLanguagesForSelect() : array<string|int, mixed>
Return values
array<string|int, mixed>

Array of language options

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

Return values
array{success: bool, imported: int, errors: array}

loadFeed()

Load a feed and return result.

public loadFeed(string $nfname, int $nfid, string $nfsourceuri, string $nfoptions) : array{success?: true, message?: string, imported?: int, duplicates?: int, error?: string}
Parameters
$nfname : string

Newsfeed name

$nfid : int

News feed ID

$nfsourceuri : string

News feed source

$nfoptions : string

News feed options

Return values
array{success?: true, message?: string, imported?: int, duplicates?: int, error?: string}

parseFeed()

Parse an RSS feed for preview.

public parseFeed(string $sourceUri[, string $articleSection = '' ]) : array<string|int, mixed>|null
Parameters
$sourceUri : string

Feed URL

$articleSection : string = ''

Article section tag

Return values
array<string|int, mixed>|null

Feed data or null on error

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}

routeDelete()

Handle a DELETE request for this resource.

public routeDelete(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

Query/body parameters

Return values
JsonResponse

routeGet()

Handle a GET request for this resource.

public routeGet(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

Query parameters

Return values
JsonResponse

routePost()

Handle a POST request for this resource.

public routePost(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

POST/JSON body parameters

Return values
JsonResponse

routePut()

Handle a PUT request for this resource.

public routePut(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

JSON body parameters

Return values
JsonResponse

updateFeed()

Update an existing feed.

public updateFeed(int $feedId, array<string|int, mixed> $data) : array{success: bool, feed?: array, error?: string}
Parameters
$feedId : int

Feed ID

$data : array<string|int, mixed>

Feed data

Return values
array{success: bool, feed?: array, error?: string}

frag()

Extract a fragment from the fragments array.

protected frag(array<int, string> $fragments, int $index) : string
Parameters
$fragments : array<int, string>

The URL path fragments

$index : int

The index to extract

Return values
string

The fragment at the index, or empty string if not present


        
On this page

Search results