FeedReaderFeeds extends FeedReaderModel
Table of Contents
Properties
| $articles_per_feed | |
| $query_feed_rate |
Methods
| __construct() | Initialize Feeds |
| addArticle() | Adds an article |
| addFeed() | Adds a feed with the given details |
| addSubscriber() | Adds a subscriber to a feed |
| deleteFeed() | Deletes a feed and any subscribers and articles if possible |
| deleteSubscriber() | Deletes the subscriber from the feed, and additionally deletes the feed if there are no other subscribers and the feed is not a default feed. |
| editFeed() | Update a feed's last updated date/time |
| fetchArticles() | Fetch articles for the given feed, store them in the database and remove old records |
| getArticles() | Returns a list of articles the staff member is explicitly or implicitly subscribed to based on the given feed ID |
| getArticlesCount() | Returns a count of all articles that match the given criteria |
| getDefaultFeeds() | Get default feeds for the given company. These are feeds which are rendered for a user if they have no previously saved feeds. |
| getFeed() | Returns a single feed record |
| getSubscribedFeeds() | Fetches all feeds the user is explicitly subscribed to, or inherintly subscribed if no explicit subscriptions exist |
| articles() | Builds a partially constructed query Record object use to fetch or count results |
| getFeedIdByUrl() | Fetches the ID of the feed with the given URL, if it exists |
| hasSubscribers() | Checks if the given feed has any subscribers either for the feed in general or for the given company |
Methods
__construct()
Initialize Feeds
public
__construct() : mixed
addArticle()
Adds an article
public
addArticle(int $feed_id, array<string|int, mixed> $vars) : mixed
Parameters
- $feed_id : int
-
The ID of the feed to add an article to
- $vars : array<string|int, mixed>
-
An array of article information including:
- data An array of data for the article
- date The date of the article
- guid The unique ID from this feed for this article
addFeed()
Adds a feed with the given details
public
addFeed(array<string|int, mixed> $vars[, int $staff_id = null ][, int $company_id = null ]) : mixed
Parameters
- $vars : array<string|int, mixed>
-
An array of feed information including:
- url The full URL to the feed
- company_id The company ID to make this feed a default feed for (optional)
- $staff_id : int = null
-
The staff member adding the feed to subscribe to the feed
- $company_id : int = null
-
The ID of the company belonging to the staff member to subscribe the feed to
addSubscriber()
Adds a subscriber to a feed
public
addSubscriber(int $feed_id, int $staff_id, int $company_id) : mixed
Parameters
- $feed_id : int
-
The ID of the feed to subscribe to
- $staff_id : int
-
The ID of the staff member to assign to the feed
- $company_id : int
-
The ID of the company the feed should appear under for the given staff member
deleteFeed()
Deletes a feed and any subscribers and articles if possible
public
deleteFeed(int $feed_id, int $company_id) : mixed
Parameters
- $feed_id : int
-
The ID of the feed to delete
- $company_id : int
-
The ID of the company to remove the feed for
deleteSubscriber()
Deletes the subscriber from the feed, and additionally deletes the feed if there are no other subscribers and the feed is not a default feed.
public
deleteSubscriber(int $feed_id, int $staff_id, int $company_id) : mixed
Parameters
- $feed_id : int
-
The ID of the feed to remove from the subscriber
- $staff_id : int
-
The ID of the staff member to unsubscribe
- $company_id : int
-
The ID of the company for the staff member to unsubscribe the feed from
editFeed()
Update a feed's last updated date/time
public
editFeed(int $feed_id, array<string|int, mixed> $vars) : mixed
Parameters
- $feed_id : int
-
The ID of the feed to update
- $vars : array<string|int, mixed>
-
An array of feed info including:
- updated The date/time the feed was last updated
fetchArticles()
Fetch articles for the given feed, store them in the database and remove old records
public
fetchArticles(int $feed_id[, mixed $query_rate = '0 seconds' ]) : mixed
Parameters
- $feed_id : int
-
The ID of the feed to fetch articles for
- $query_rate : mixed = '0 seconds'
getArticles()
Returns a list of articles the staff member is explicitly or implicitly subscribed to based on the given feed ID
public
getArticles(int $staff_id, int $company_id[, int $feed_id = null ][, int $page = 1 ][, array<string|int, mixed> $order = ['date' => 'desc'] ]) : array<string|int, mixed>
Parameters
- $staff_id : int
-
The ID of the staff member to fetch articles for
- $company_id : int
-
The ID of the company to fetch articles for
- $feed_id : int = null
-
The ID of the feed to fetch articles for (if not given will fetch articles for ALL subscribed feeds)
- $page : int = 1
-
The page number to fetch articles for
- $order : array<string|int, mixed> = ['date' => 'desc']
-
The order to sort the result by
Return values
array<string|int, mixed> —An array of stdClass objects each representing an article containing the following:
- id The ID of the article
- feed_id The ID of the feed the article belongs to
- guid The globally unique identifier for the article within the given feed
- data An array of data from the feed
- date The date the article was published
getArticlesCount()
Returns a count of all articles that match the given criteria
public
getArticlesCount(int $staff_id, int $company_id[, int $feed_id = null ]) : int
Parameters
- $staff_id : int
-
The ID of the staff member to fetch articles for
- $company_id : int
-
The ID of the company to fetch articles for
- $feed_id : int = null
-
The ID of the feed to fetch articles for (if not given will fetch articles for ALL subscribed feeds)
Return values
int —The number of results that match the criteria
getDefaultFeeds()
Get default feeds for the given company. These are feeds which are rendered for a user if they have no previously saved feeds.
public
getDefaultFeeds(int $company_id[, array<string|int, mixed> $order = ['id' => 'asc'] ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The ID of the company to fetch feeds for
- $order : array<string|int, mixed> = ['id' => 'asc']
-
The order to list the feeds in key/value pairs where each key is a field and each value is a direction (asc or desc)
Return values
array<string|int, mixed> —An array of stdClass objects each representing a default feed
getFeed()
Returns a single feed record
public
getFeed(int $feed_id) : stdClass
Parameters
- $feed_id : int
-
The ID of the feed to fetch
Return values
stdClass —A stdClass object representing the feed, false if the feed does not exist
getSubscribedFeeds()
Fetches all feeds the user is explicitly subscribed to, or inherintly subscribed if no explicit subscriptions exist
public
getSubscribedFeeds(int $staff_id, int $company_id[, array<string|int, mixed> $order = ['id' => 'asc'] ]) : mixed
Parameters
- $staff_id : int
-
The ID of the staff member to fetch subscriptions for
- $company_id : int
-
The ID of the company to fetch subscriptions for
- $order : array<string|int, mixed> = ['id' => 'asc']
-
The order to list the feeds in key/value pairs where each key is a field and each value is a direction (asc or desc)
articles()
Builds a partially constructed query Record object use to fetch or count results
private
articles(int $staff_id, int $company_id[, int $feed_id = null ]) : Record
Parameters
- $staff_id : int
-
The ID of the staff member to fetch articles for
- $company_id : int
-
The ID of the company to fetch articles for
- $feed_id : int = null
-
The ID of the feed to fetch articles for (if not given will fetch articles for ALL subscribed feeds)
Tags
Return values
Record —A partially constructed query Record object
getFeedIdByUrl()
Fetches the ID of the feed with the given URL, if it exists
private
getFeedIdByUrl(string $url) : int
Parameters
- $url : string
-
The URL to query a feed for
Return values
int —The ID of the feed with the given URL, false if none exists
hasSubscribers()
Checks if the given feed has any subscribers either for the feed in general or for the given company
private
hasSubscribers(int $feed_id[, int $company_id = null ]) : bool
Parameters
- $feed_id : int
-
The ID of the feed to check for subscribers
- $company_id : int = null
-
The ID of the company to check explicitly for subscribers to the given feed
Return values
bool —True if there are subscribers, false otherwise