Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
100
web/vendor/zendframework/zend-feed/CHANGELOG.md
vendored
100
web/vendor/zendframework/zend-feed/CHANGELOG.md
vendored
|
@ -2,12 +2,94 @@
|
|||
|
||||
All notable changes to this project will be documented in this file, in reverse chronological order by release.
|
||||
|
||||
## 2.5.2 - TBD
|
||||
## 2.8.0 - 2017-04-02
|
||||
|
||||
### Added
|
||||
|
||||
- [#27](https://github.com/zendframework/zend-feed/pull/27) adds a documentation
|
||||
chapter demonstrating wrapping a PSR-7 client to use with `Zend\Feed\Reader`.
|
||||
- [#22](https://github.com/zendframework/zend-feed/pull/22) adds missing
|
||||
ExtensionManagerInterface on Writer\ExtensionPluginManager.
|
||||
- [#32](https://github.com/zendframework/zend-feed/pull/32) adds missing
|
||||
ExtensionManagerInterface on Reader\ExtensionPluginManager.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Removed
|
||||
|
||||
- [#38](https://github.com/zendframework/zend-feed/pull/38) dropped php 5.5
|
||||
support
|
||||
|
||||
### Fixed
|
||||
|
||||
- [#35](https://github.com/zendframework/zend-feed/pull/35) fixed
|
||||
"A non-numeric value encountered" in php 7.1
|
||||
- [#39](https://github.com/zendframework/zend-feed/pull/39) fixed protocol
|
||||
relative link absolutisation
|
||||
- [#40](https://github.com/zendframework/zend-feed/pull/40) fixed service
|
||||
manager v3 compatibility aliases in extension plugin managers
|
||||
|
||||
## 2.7.0 - 2016-02-11
|
||||
|
||||
### Added
|
||||
|
||||
- [#21](https://github.com/zendframework/zend-feed/pull/21) edits, revises, and
|
||||
prepares the documentation for publication at https://zendframework.github.io/zend-feed/
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Removed
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Fixed
|
||||
|
||||
- [#20](https://github.com/zendframework/zend-feed/pull/20) makes the two
|
||||
zend-servicemanager extension manager implementations forwards compatible
|
||||
with version 3, and the overall code base forwards compatible with zend-stdlib
|
||||
v3.
|
||||
|
||||
## 2.6.0 - 2015-11-24
|
||||
|
||||
### Added
|
||||
|
||||
- [#13](https://github.com/zendframework/zend-feed/pull/13) introduces
|
||||
`Zend\Feed\Writer\StandaloneExtensionManager`, an implementation of
|
||||
`Zend\Feed\Writer\ExtensionManagerInterface` that has no dependencies.
|
||||
`Zend\Feed\Writer\ExtensionManager` now composes this by default, instead of
|
||||
`Zend\Feed\Writer\ExtensionPluginManager`, for managing the various feed and
|
||||
entry extensions. If you relied on `ExtensionPluginManager` previously, you
|
||||
will need to create an instance manually and inject it into the `Writer`
|
||||
instance.
|
||||
- [#14](https://github.com/zendframework/zend-feed/pull/14) introduces:
|
||||
- `Zend\Feed\Reader\Http\HeaderAwareClientInterface`, which extends
|
||||
`ClientInterface` and adds an optional argument to the `get()` method,
|
||||
`array $headers = []`; this argument allows specifying request headers for
|
||||
the client to send. `$headers` should have header names for keys, and the
|
||||
values should be arrays of strings/numbers representing the header values
|
||||
(if only a single value is necessary, it should be represented as an single
|
||||
value array).
|
||||
- `Zend\Feed\Reader\Http\HeaderAwareResponseInterface`, which extends
|
||||
`ResponseInterface` and adds the method `getHeader($name, $default = null)`.
|
||||
Clients may return either a `ResponseInterface` or
|
||||
`HeaderAwareResponseInterface` instance.
|
||||
- `Zend\Feed\Reader\Http\Response`, which is an implementation of
|
||||
`HeaderAwareResponseInterface`. Its constructor accepts the status code,
|
||||
body, and, optionally, headers.
|
||||
- `Zend\Feed\Reader\Http\Psr7ResponseDecorator`, which is an implementation of
|
||||
`HeaderAwareResponseInterface`. Its constructor accepts a PSR-7 response
|
||||
instance, and the various methdos then proxy to those methods. This should
|
||||
make creating wrappers for PSR-7 HTTP clients trivial.
|
||||
- `Zend\Feed\Reader\Http\ZendHttpClientDecorator`, which decorates a
|
||||
`Zend\Http\Client` instance, implements `HeaderAwareClientInterface`, and
|
||||
returns a `Response` instance seeded from the zend-http response upon
|
||||
calling `get()`. The class exposes a `getDecoratedClient()` method to allow
|
||||
retrieval of the decorated zend-http client instance.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Nothing.
|
||||
|
@ -23,3 +105,19 @@ All notable changes to this project will be documented in this file, in reverse
|
|||
- [#2](https://github.com/zendframework/zend-feed/pull/2) ensures that the
|
||||
routine for "absolutising" a link in `Reader\FeedSet` always generates a URI
|
||||
with a scheme.
|
||||
- [#14](https://github.com/zendframework/zend-feed/pull/14) makes the following
|
||||
changes to fix behavior around HTTP clients used within
|
||||
`Zend\Feed\Reader\Reader`:
|
||||
- `setHttpClient()` now ensures that the passed client is either a
|
||||
`Zend\Feed\Reader\Http\ClientInterface` or `Zend\Http\Client`, raising an
|
||||
`InvalidArgumentException` if neither. If a `Zend\Http\Client` is passed, it
|
||||
is passed to the constructor of `Zend\Feed\Reader\Http\ZendHttpClientDecorator`,
|
||||
and the decorator instance is used.
|
||||
- `getHttpClient()` now *always* returns a `Zend\Feed\Reader\Http\ClientInterface`
|
||||
instance. If no instance is currently registered, it lazy loads a
|
||||
`ZendHttpClientDecorator` instance.
|
||||
- `import()` was updated to consume a `ClientInterface` instance; when caches
|
||||
are in play, it checks the client against `HeaderAwareClientInterface` to
|
||||
determine if it can check for HTTP caching headers, and, if so, to retrieve
|
||||
them.
|
||||
- `findFeedLinks()` was updated to consume a `ClientInterface`.
|
||||
|
|
43
web/vendor/zendframework/zend-feed/CONDUCT.md
vendored
Normal file
43
web/vendor/zendframework/zend-feed/CONDUCT.md
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
# Contributor Code of Conduct
|
||||
|
||||
The Zend Framework project adheres to [The Code Manifesto](http://codemanifesto.com)
|
||||
as its guidelines for contributor interactions.
|
||||
|
||||
## The Code Manifesto
|
||||
|
||||
We want to work in an ecosystem that empowers developers to reach their
|
||||
potential — one that encourages growth and effective collaboration. A space that
|
||||
is safe for all.
|
||||
|
||||
A space such as this benefits everyone that participates in it. It encourages
|
||||
new developers to enter our field. It is through discussion and collaboration
|
||||
that we grow, and through growth that we improve.
|
||||
|
||||
In the effort to create such a place, we hold to these values:
|
||||
|
||||
1. **Discrimination limits us.** This includes discrimination on the basis of
|
||||
race, gender, sexual orientation, gender identity, age, nationality, technology
|
||||
and any other arbitrary exclusion of a group of people.
|
||||
2. **Boundaries honor us.** Your comfort levels are not everyone’s comfort
|
||||
levels. Remember that, and if brought to your attention, heed it.
|
||||
3. **We are our biggest assets.** None of us were born masters of our trade.
|
||||
Each of us has been helped along the way. Return that favor, when and where
|
||||
you can.
|
||||
4. **We are resources for the future.** As an extension of #3, share what you
|
||||
know. Make yourself a resource to help those that come after you.
|
||||
5. **Respect defines us.** Treat others as you wish to be treated. Make your
|
||||
discussions, criticisms and debates from a position of respectfulness. Ask
|
||||
yourself, is it true? Is it necessary? Is it constructive? Anything less is
|
||||
unacceptable.
|
||||
6. **Reactions require grace.** Angry responses are valid, but abusive language
|
||||
and vindictive actions are toxic. When something happens that offends you,
|
||||
handle it assertively, but be respectful. Escalate reasonably, and try to
|
||||
allow the offender an opportunity to explain themselves, and possibly correct
|
||||
the issue.
|
||||
7. **Opinions are just that: opinions.** Each and every one of us, due to our
|
||||
background and upbringing, have varying opinions. The fact of the matter, is
|
||||
that is perfectly acceptable. Remember this: if you respect your own
|
||||
opinions, you should respect the opinions of others.
|
||||
8. **To err is human.** You might not intend it, but mistakes do happen and
|
||||
contribute to build experience. Tolerate honest mistakes, and don't hesitate
|
||||
to apologize if you make one yourself.
|
|
@ -77,24 +77,24 @@ To do so:
|
|||
|
||||
## Running Coding Standards Checks
|
||||
|
||||
This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding
|
||||
This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding
|
||||
standards checks, and provides configuration for our selected checks.
|
||||
`php-cs-fixer` is installed by default via Composer.
|
||||
`phpcs` is installed by default via Composer.
|
||||
|
||||
To run checks only:
|
||||
|
||||
```console
|
||||
$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs
|
||||
$ composer cs-check
|
||||
```
|
||||
|
||||
To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run`
|
||||
flag:
|
||||
`phpcs` also includes a tool for fixing most CS violations, `phpcbf`:
|
||||
|
||||
|
||||
```console
|
||||
$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs
|
||||
$ composer cs-fix
|
||||
```
|
||||
|
||||
If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure
|
||||
If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure
|
||||
they pass, and make sure you add and commit the changes after verification.
|
||||
|
||||
## Recommended Workflow for Contributions
|
||||
|
@ -227,3 +227,8 @@ repository, we suggest doing some cleanup of these branches.
|
|||
```console
|
||||
$ git push {username} :<branchname>
|
||||
```
|
||||
|
||||
|
||||
## Conduct
|
||||
|
||||
Please see our [CONDUCT.md](CONDUCT.md) to understand expected behavior when interacting with others in the project.
|
||||
|
|
2
web/vendor/zendframework/zend-feed/README.md
vendored
2
web/vendor/zendframework/zend-feed/README.md
vendored
|
@ -10,4 +10,4 @@ structure with the same natural syntax, and turning the result back into XML.
|
|||
|
||||
|
||||
- File issues at https://github.com/zendframework/zend-feed/issues
|
||||
- Documentation is at http://framework.zend.com/manual/current/en/index.html#zend-feed
|
||||
- Documentation is at https://zendframework.github.io/zend-feed/
|
||||
|
|
49
web/vendor/zendframework/zend-feed/composer.json
vendored
49
web/vendor/zendframework/zend-feed/composer.json
vendored
|
@ -13,37 +13,48 @@
|
|||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5",
|
||||
"zendframework/zend-escaper": "~2.5",
|
||||
"zendframework/zend-stdlib": "~2.5"
|
||||
"php": "^5.6 || ^7.0",
|
||||
"zendframework/zend-escaper": "^2.5",
|
||||
"zendframework/zend-stdlib": "^2.7 || ^3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"zendframework/zend-db": "~2.5",
|
||||
"zendframework/zend-cache": "~2.5",
|
||||
"zendframework/zend-http": "~2.5",
|
||||
"zendframework/zend-servicemanager": "~2.5",
|
||||
"zendframework/zend-validator": "~2.5",
|
||||
"fabpot/php-cs-fixer": "1.7.*",
|
||||
"phpunit/PHPUnit": "~4.0"
|
||||
"zendframework/zend-db": "^2.7",
|
||||
"zendframework/zend-cache": "^2.6",
|
||||
"zendframework/zend-http": "^2.5.4",
|
||||
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
|
||||
"zendframework/zend-validator": "^2.6",
|
||||
"phpunit/PHPUnit": "^6.0.8 || ^5.7.15",
|
||||
"psr/http-message": "^1.0",
|
||||
"zendframework/zend-coding-standard": "~1.0.0"
|
||||
},
|
||||
"suggest": {
|
||||
"zendframework/zend-cache": "Zend\\Cache component",
|
||||
"zendframework/zend-db": "Zend\\Db component",
|
||||
"psr/http-message": "PSR-7 ^1.0, if you wish to use Zend\\Feed\\Reader\\Http\\Psr7ResponseDecorator",
|
||||
"zendframework/zend-cache": "Zend\\Cache component, for optionally caching feeds between requests",
|
||||
"zendframework/zend-db": "Zend\\Db component, for use with PubSubHubbub",
|
||||
"zendframework/zend-http": "Zend\\Http for PubSubHubbub, and optionally for use with Zend\\Feed\\Reader",
|
||||
"zendframework/zend-servicemanager": "Zend\\ServiceManager component, for default/recommended ExtensionManager implementations",
|
||||
"zendframework/zend-validator": "Zend\\Validator component"
|
||||
"zendframework/zend-servicemanager": "Zend\\ServiceManager component, for easily extending ExtensionManager implementations",
|
||||
"zendframework/zend-validator": "Zend\\Validator component, for validating email addresses used in Atom feeds and entries ehen using the Writer subcomponent"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.5-dev",
|
||||
"dev-develop": "2.6-dev"
|
||||
"dev-master": "2.8-dev",
|
||||
"dev-develop": "2.9-dev"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"ZendTest\\Feed\\": "test/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"check": [
|
||||
"@cs-check",
|
||||
"@test"
|
||||
],
|
||||
"cs-check": "phpcs",
|
||||
"cs-fix": "phpcbf",
|
||||
"test": "phpunit --colors=always",
|
||||
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
|
||||
"upload-coverage": "coveralls -v"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2115
web/vendor/zendframework/zend-feed/composer.lock
generated
vendored
Normal file
2115
web/vendor/zendframework/zend-feed/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
23
web/vendor/zendframework/zend-feed/doc/book/consuming-atom-entry.md
vendored
Normal file
23
web/vendor/zendframework/zend-feed/doc/book/consuming-atom-entry.md
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Consuming a Single Atom Entry
|
||||
|
||||
Single Atom `<entry>` elements are also valid by themselves. Usually the URL for
|
||||
an entry is the feed's URL followed by `/<entryId>`, such as
|
||||
`http://atom.example.com/feed/1`, using the example URL we used above. This
|
||||
pattern may exist for some web services which use Atom as a container syntax.
|
||||
|
||||
If you read a single entry, you will have a `Zend\Feed\Reader\Entry\Atom` object.
|
||||
|
||||
## Reading a Single-Entry Atom Feed
|
||||
|
||||
```php
|
||||
$entry = Zend\Feed\Reader\Reader::import('http://atom.example.com/feed/1');
|
||||
echo 'Entry title: ' . $entry->getTitle();
|
||||
```
|
||||
|
||||
> ## Importing requires an HTTP client
|
||||
>
|
||||
> To import a feed, you will need to have an [HTTP client](zend.feed.http-clients)
|
||||
> available.
|
||||
>
|
||||
> If you are not using zend-http, you will need to inject `Reader` with the HTTP
|
||||
> client. See the [section on providing a client to Reader](http-clients.md#providing-a-client-to-reader).
|
62
web/vendor/zendframework/zend-feed/doc/book/consuming-atom.md
vendored
Normal file
62
web/vendor/zendframework/zend-feed/doc/book/consuming-atom.md
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
# Consuming Atom Feeds
|
||||
|
||||
`Zend\Feed\Reader\Feed\Atom` is used in much the same way as
|
||||
`Zend\Feed\Reader\Feed\Rss`. It provides the same access to feed-level
|
||||
properties and iteration over entries in the feed. The main difference is in the
|
||||
structure of the Atom protocol itself. Atom is a successor to RSS; it is a
|
||||
more generalized protocol and it is designed to deal more easily with feeds that
|
||||
provide their full content inside the feed, splitting RSS' `description` tag
|
||||
into two elements, `summary` and `content`, for that purpose.
|
||||
|
||||
## Basic Use of an Atom Feed
|
||||
|
||||
Read an Atom feed and print the `title` and `summary` of each entry:
|
||||
|
||||
```php
|
||||
$feed = Zend\Feed\Reader\Reader::import('http://atom.example.com/feed/');
|
||||
echo 'The feed contains ' . $feed->count() . ' entries.' . "\n\n";
|
||||
foreach ($feed as $entry) {
|
||||
echo 'Title: ' . $entry->getTitle() . "\n";
|
||||
echo 'Description: ' . $entry->getDescription() . "\n";
|
||||
echo 'URL: ' . $entry->getLink() . "\n\n";
|
||||
}
|
||||
```
|
||||
|
||||
> ## Importing requires an HTTP client
|
||||
>
|
||||
> To import a feed, you will need to have an [HTTP client](zend.feed.http-clients)
|
||||
> available.
|
||||
>
|
||||
> If you are not using zend-http, you will need to inject `Reader` with the HTTP
|
||||
> client. See the [section on providing a client to Reader](http-clients.md#providing-a-client-to-reader).
|
||||
|
||||
In an Atom feed, you can expect to find the following feed properties:
|
||||
|
||||
- `title`: The feed's title, same as RSS' channel title.
|
||||
- `id`: Every feed and entry in Atom has a unique identifier.
|
||||
- `link`: Feeds can have multiple links, which are distinguished by a `type`
|
||||
attribute. The equivalent to RSS's channel link would be `type="text/html"`.
|
||||
If the link is to an alternate version of the same content that's in the feed,
|
||||
it would have a `rel="alternate"` attribute.
|
||||
- `subtitle`: The feed's description, equivalent to RSS' channel description.
|
||||
- `author`: The feed's author, with `name` and `email` sub-tags.
|
||||
|
||||
Atom entries commonly have the following properties:
|
||||
|
||||
- `id`: The entry's unique identifier.
|
||||
- `title`: The entry's title, same as RSS item titles.
|
||||
- `link`: A link to another format or an alternate view of this entry.
|
||||
The link property of an atom entry typically has an `href` attribute.
|
||||
- `summary`: A summary of this entry's content.
|
||||
- `content`: The full content of the entry; can be skipped if the feed just
|
||||
contains summaries.
|
||||
- `author`: with `name` and `email` sub-tags like feeds have.
|
||||
- `published`: the date the entry was published, in RFC 3339 format.
|
||||
- `updated`: the date the entry was last updated, in RFC 3339 format.
|
||||
|
||||
Where relevant, `Zend\Feed` supports a number of common RSS extensions including
|
||||
Dublin Core; Content, Slash, Syndication, and Syndication/Thread; and several
|
||||
others in common use on blogs.
|
||||
|
||||
For more information on Atom and plenty of resources, see
|
||||
[http://www.atomenabled.org/](http://www.atomenabled.org/).
|
99
web/vendor/zendframework/zend-feed/doc/book/consuming-rss.md
vendored
Normal file
99
web/vendor/zendframework/zend-feed/doc/book/consuming-rss.md
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
# Consuming RSS Feeds
|
||||
|
||||
## Reading a feed
|
||||
|
||||
To read an RSS feed, pass its URL to `Zend\Feed\Reader\Reader::import()`:
|
||||
|
||||
```php
|
||||
$channel = Zend\Feed\Reader\Reader::import('http://rss.example.com/channelName');
|
||||
```
|
||||
|
||||
> ## Importing requires an HTTP client
|
||||
>
|
||||
> To import a feed, you will need to have an [HTTP client](zend.feed.http-clients)
|
||||
> available.
|
||||
>
|
||||
> If you are not using zend-http, you will need to inject `Reader` with the HTTP
|
||||
> client. See the [section on providing a client to Reader](http-clients.md#providing-a-client-to-reader).
|
||||
|
||||
If any errors occur fetching the feed, a
|
||||
`Zend\Feed\Reader\Exception\RuntimeException` will be thrown.
|
||||
|
||||
## Get properties
|
||||
|
||||
Once you have a feed object, you can access any of the standard RSS channel
|
||||
properties via the various instance getter methods:
|
||||
|
||||
```php
|
||||
echo $channel->getTitle();
|
||||
echo $channel->getAuthor();
|
||||
// etc.
|
||||
```
|
||||
|
||||
If channel properties have attributes, the getter method will return a key/value
|
||||
pair, where the key is the attribute name, and the value is the attribute value.
|
||||
|
||||
```php
|
||||
$author = $channel->getAuthor();
|
||||
echo $author['name'];
|
||||
```
|
||||
|
||||
Most commonly, you'll want to loop through the feed and do something with its
|
||||
entries. `Zend\Feed\Reader\Feed\Rss` internally converts all entries to a
|
||||
`Zend\Feed\Reader\Entry\Rss` instance. Entry properties, similarly to channel
|
||||
properties, can be accessed via getter methods, such as `getTitle`,
|
||||
`getDescription`, etc.
|
||||
|
||||
An example of printing all titles of articles in a channel is:
|
||||
|
||||
```php
|
||||
foreach ($channel as $item) {
|
||||
echo $item->getTitle() . "\n";
|
||||
}
|
||||
```
|
||||
|
||||
If you are not familiar with RSS, here are the standard elements you can expect
|
||||
to be available in an RSS channel and in individual RSS items (entries).
|
||||
|
||||
Required channel elements:
|
||||
|
||||
- `title`: The name of the channel.
|
||||
- `link`: The URL of the web site corresponding to the channel.
|
||||
- `description`: A sentence (or more) describing the channel.
|
||||
|
||||
Common optional channel elements:
|
||||
|
||||
- `pubDate`: The publication date of this set of content, in RFC 822 date
|
||||
format.
|
||||
- `language`: The language the channel is written in.
|
||||
- `category`: One or more (specified by multiple tags) categories the channel
|
||||
belongs to.
|
||||
|
||||
RSS `<item>` elements do not have any strictly required elements. However,
|
||||
either `title` or `description` must be present.
|
||||
|
||||
Common item elements:
|
||||
|
||||
- `title`: The title of the item.
|
||||
- `link`: The URL of the item.
|
||||
- `description`: A synopsis of the item.
|
||||
- `author`: The author's email address.
|
||||
- `category`: One more categories that the item belongs to.
|
||||
- `comments`: URL of comments relating to this item.
|
||||
- `pubDate`: The date the item was published, in RFC 822 date format.
|
||||
|
||||
In your code you can always test to see if an element is non-empty by calling
|
||||
the getter:
|
||||
|
||||
```php
|
||||
if ($item->getPropname()) {
|
||||
// ... proceed.
|
||||
}
|
||||
```
|
||||
|
||||
Where relevant, `Zend\Feed` supports a number of common RSS extensions including
|
||||
Dublin Core, Atom (inside RSS); the Content, Slash, Syndication,
|
||||
Syndication/Thread extensions; as well as several others.
|
||||
|
||||
Please see the official [RSS 2.0 specification](http://cyber.law.harvard.edu/rss/rss.html)
|
||||
for further information.
|
48
web/vendor/zendframework/zend-feed/doc/book/find-feeds.md
vendored
Normal file
48
web/vendor/zendframework/zend-feed/doc/book/find-feeds.md
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Feed Discovery from Web Pages
|
||||
|
||||
Web pages often contain `<link>` tags that refer to feeds with content relevant
|
||||
to the particular page. `Zend\Feed\Reader\Reader` enables you to retrieve all
|
||||
feeds referenced by a web page with one method call:
|
||||
|
||||
```php
|
||||
$feedLinks = Zend\Feed\Reader\Reader::findFeedLinks('http://www.example.com/news.html');
|
||||
```
|
||||
|
||||
> ## Finding feed links requires an HTTP client
|
||||
>
|
||||
> To find feed links, you will need to have an [HTTP client](zend.feed.http-clients)
|
||||
> available.
|
||||
>
|
||||
> If you are not using zend-http, you will need to inject `Reader` with the HTTP
|
||||
> client. See the [section on providing a client to Reader](http-clients.md#providing-a-client-to-reader).
|
||||
|
||||
Here the `findFeedLinks()` method returns a `Zend\Feed\Reader\FeedSet` object,
|
||||
which is in turn a collection of other `Zend\Feed\Reader\FeedSet` objects, each
|
||||
referenced by `<link>` tags on the `news.html` web page.
|
||||
`Zend\Feed\Reader\Reader` will throw a
|
||||
`Zend\Feed\Reader\Exception\RuntimeException` upon failure, such as an HTTP
|
||||
404 response code or a malformed feed.
|
||||
|
||||
You can examine all feed links located by iterating across the collection:
|
||||
|
||||
```php
|
||||
$rssFeed = null;
|
||||
$feedLinks = Zend\Feed\Reader\Reader::findFeedLinks('http://www.example.com/news.html');
|
||||
foreach ($feedLinks as $link) {
|
||||
if (stripos($link['type'], 'application/rss+xml') !== false) {
|
||||
$rssFeed = $link['href'];
|
||||
break;
|
||||
}
|
||||
```
|
||||
|
||||
Each `Zend\Feed\Reader\FeedSet` object will expose the `rel`, `href`, `type`,
|
||||
and `title` properties of detected links for all RSS, Atom, or RDF feeds. You
|
||||
can always select the first encountered link of each type by using a shortcut:
|
||||
the first encountered link of a given type is assigned to a property named after
|
||||
the feed type.
|
||||
|
||||
```php
|
||||
$rssFeed = null;
|
||||
$feedLinks = Zend\Feed\Reader\Reader::findFeedLinks('http://www.example.com/news.html');
|
||||
$firstAtomFeed = $feedLinks->atom;
|
||||
```
|
236
web/vendor/zendframework/zend-feed/doc/book/http-clients.md
vendored
Normal file
236
web/vendor/zendframework/zend-feed/doc/book/http-clients.md
vendored
Normal file
|
@ -0,0 +1,236 @@
|
|||
# HTTP Clients and zend-feed
|
||||
|
||||
Several operations in zend-feed's Reader subcomponent require an HTTP client:
|
||||
|
||||
- importing a feed
|
||||
- finding links in a feed
|
||||
|
||||
In order to allow developers a choice in HTTP clients, the subcomponent defines
|
||||
several interfaces and classes. Elsewhere in the documentation, we reference
|
||||
where an HTTP client may be used; this document details what constitutes an HTTP
|
||||
client and its behavior, and some of the concrete classes available within the
|
||||
component for implementing this behavior.
|
||||
|
||||
## ClientInterface and HeaderAwareClientInterface
|
||||
|
||||
First, we define two interfaces for clients,
|
||||
`Zend\Feed\Reader\Http\ClientInterface` and `HeaderAwareClientInterface`:
|
||||
|
||||
```php
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
interface ClientInterface
|
||||
{
|
||||
/**
|
||||
* Make a GET request to a given URL.
|
||||
*
|
||||
* @param string $url
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function get($url);
|
||||
}
|
||||
|
||||
interface HeaderAwareClientInterface extends ClientInterface
|
||||
{
|
||||
/**
|
||||
* Make a GET request to a given URL.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $headers
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function get($url, array $headers = []);
|
||||
}
|
||||
```
|
||||
|
||||
The first is header-agnostic, and assumes that the client will simply perform an
|
||||
HTTP GET request. The second allows providing headers to the client; typically,
|
||||
these are used for HTTP caching headers. `$headers` must be in the following
|
||||
structure:
|
||||
|
||||
```php
|
||||
$headers = [
|
||||
'X-Header-Name' => [
|
||||
'header',
|
||||
'values',
|
||||
],
|
||||
];
|
||||
```
|
||||
|
||||
i.e., each key is a header name, and each value is an array of values for that
|
||||
header. If the header represents only a single value, it should be an array with
|
||||
that value:
|
||||
|
||||
```php
|
||||
$headers = [
|
||||
'Accept' => [ 'application/rss+xml' ],
|
||||
];
|
||||
```
|
||||
|
||||
A call to `get()` should yield a *response*.
|
||||
|
||||
## ResponseInterface and HeaderAwareResponseInterface
|
||||
|
||||
Responses are modeled using `Zend\Feed\Reader\Http\ResponseInterface` and
|
||||
`HeaderAwareResponseInterface`:
|
||||
|
||||
```php
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
class ResponseInterface
|
||||
{
|
||||
/**
|
||||
* Retrieve the status code.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode();
|
||||
|
||||
/**
|
||||
* Retrieve the response body contents.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBody();
|
||||
}
|
||||
|
||||
class HeaderAwareResponseInterface extends ResponseInterface
|
||||
{
|
||||
/**
|
||||
* Retrieve a named header line.
|
||||
*
|
||||
* Retrieve a header by name; all values MUST be concatenated to a single
|
||||
* line. If no matching header is found, return the $default value.
|
||||
*
|
||||
* @param string $name
|
||||
* @param null|string $default
|
||||
* @return string
|
||||
public function getHeaderLine($name, $default = null);
|
||||
}
|
||||
```
|
||||
|
||||
Internally, `Reader` will typehint against `ClientInterface` for the bulk of
|
||||
operations. In some cases, however, certain capabilities are only possible if
|
||||
the response can provide headers (e.g., for caching); in such cases, it will
|
||||
check the instance against `HeaderAwareResponseInterface`, and only call
|
||||
`getHeaderLine()` if it matches.
|
||||
|
||||
## Response
|
||||
|
||||
zend-feed ships with a generic `ResponseInterface` implementation,
|
||||
`Zend\Feed\Http\Response`. It implements `HeaderAwareResponseInterface`, and
|
||||
defines the following constructor:
|
||||
|
||||
```php
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
class Response implements HeaderAwareResponseInterface
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $statusCode Response status code
|
||||
* @param string $body Response body
|
||||
* @param array $headers Response headers, if available
|
||||
*/
|
||||
public function __construct($statusCode, $body, array $headers = []);
|
||||
}
|
||||
```
|
||||
|
||||
## PSR-7 Response
|
||||
|
||||
[PSR-7](http://www.php-fig.org/psr/psr-7/) defines a set of HTTP message
|
||||
interfaces, but not a client interface. To facilitate wrapping an HTTP client
|
||||
that uses PSR-7 messages, we provide `Zend\Feed\Reader\Psr7ResponseDecorator`:
|
||||
|
||||
```php
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
|
||||
|
||||
class Psr7ResponseDecorator implements HeaderAwareResponseInterface
|
||||
{
|
||||
/**
|
||||
* @param PsrResponseInterface $response
|
||||
*/
|
||||
public function __construct(PsrResponseInterface $response);
|
||||
|
||||
/**
|
||||
* @return PsrResponseInterface
|
||||
*/
|
||||
public function getDecoratedResponse();
|
||||
}
|
||||
```
|
||||
|
||||
Clients can then take the PSR-7 response they receive, pass it to the decorator,
|
||||
and return the decorator.
|
||||
|
||||
To use the PSR-7 response, you will need to add the PSR-7 interfaces to your
|
||||
application, if they are not already installed by the client of your choice:
|
||||
|
||||
```bash
|
||||
$ composer require psr/http-message
|
||||
```
|
||||
|
||||
## zend-http
|
||||
|
||||
We also provide a zend-http client decorator,
|
||||
`Zend\Feed\Reader\Http\ZendHttpClientDecorator`:
|
||||
|
||||
```php
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
use Zend\Http\Client as HttpClient;
|
||||
|
||||
class ZendHttpClientDecorator implements HeaderAwareClientInterface
|
||||
{
|
||||
/**
|
||||
* @param HttpClient $client
|
||||
*/
|
||||
public function __construct(HttpClient $client);
|
||||
|
||||
/**
|
||||
* @return HttpClient
|
||||
*/
|
||||
public function getDecoratedClient();
|
||||
}
|
||||
```
|
||||
|
||||
Its `get()` implementation returns a `Response` instance seeded from the
|
||||
zend-http response returned, including status, body, and headers.
|
||||
|
||||
zend-http is the default implementation assumed by `Zend\Feed\Reader\Reader`,
|
||||
but *is not installed by default*. You may install it using composer:
|
||||
|
||||
```bash
|
||||
$ composer require zendframework/zend-http
|
||||
```
|
||||
|
||||
## Providing a client to Reader
|
||||
|
||||
By default, `Zend\Feed\Reader\Reader` will lazy load a zend-http client. If you
|
||||
have not installed zend-http, however, PHP will raise an error indicating the
|
||||
class is not found!
|
||||
|
||||
As such, you have two options:
|
||||
|
||||
1. Install zend-http: `composer require zendframework/zend-http`.
|
||||
2. Inject the `Reader` with your own HTTP client.
|
||||
|
||||
To accomplish the second, you will need an implementation of
|
||||
`Zend\Feed\Reader\Http\ClientInterface` or `HeaderAwareClientInterface`, and an
|
||||
instance of that implementation. Once you do, you can use the static method
|
||||
`setHttpClient()` to inject it.
|
||||
|
||||
As an example, let's say you've created a PSR-7-based implementation named
|
||||
`My\Http\Psr7FeedClient`. You could then do the following:
|
||||
|
||||
```php
|
||||
use My\Http\Psr7FeedClient;
|
||||
use Zend\Feed\Reader\Reader;
|
||||
|
||||
Reader::setHttpClient(new Psr7FeedClient());
|
||||
```
|
||||
|
||||
Your client will then be used for all `import()` and `findFeedLinks()`
|
||||
operations.
|
49
web/vendor/zendframework/zend-feed/doc/book/importing.md
vendored
Normal file
49
web/vendor/zendframework/zend-feed/doc/book/importing.md
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
# Importing Feeds
|
||||
|
||||
`Zend\Feed` enables developers to retrieve feeds via `Zend\Feader\Reader`. If
|
||||
you know the URI of a feed, use the `Zend\Feed\Reader\Reader::import()` method
|
||||
to consume it:
|
||||
|
||||
```php
|
||||
$feed = Zend\Feed\Reader\Reader::import('http://feeds.example.com/feedName');
|
||||
```
|
||||
|
||||
> ## Importing requires an HTTP client
|
||||
>
|
||||
> To import a feed, you will need to have an [HTTP client](zend.feed.http-clients)
|
||||
> available.
|
||||
>
|
||||
> If you are not using zend-http, you will need to inject `Reader` with the HTTP
|
||||
> client. See the [section on providing a client to Reader](http-clients.md#providing-a-client-to-reader).
|
||||
|
||||
You can also use `Zend\Feed\Reader\Reader` to fetch the contents of a feed from
|
||||
a file or the contents of a PHP string variable:
|
||||
|
||||
```php
|
||||
// importing a feed from a text file
|
||||
$feedFromFile = Zend\Feed\Reader\Reader::importFile('feed.xml');
|
||||
|
||||
// importing a feed from a PHP string variable
|
||||
$feedFromPHP = Zend\Feed\Reader\Reader::importString($feedString);
|
||||
```
|
||||
|
||||
In each of the examples above, an object of a class that extends
|
||||
`Zend\Feed\Reader\Feed\AbstractFeed` is returned upon success, depending on the
|
||||
type of the feed. If an RSS feed were retrieved via one of the import methods
|
||||
above, then a `Zend\Feed\Reader\Feed\Rss` object would be returned. On the other
|
||||
hand, if an Atom feed were imported, then a `Zend\Feed\Reader\Feed\Atom` object
|
||||
is returned. The import methods will also throw a
|
||||
`Zend\Feed\Exception\Reader\RuntimeException` object upon failure, such as an
|
||||
unreadable or malformed feed.
|
||||
|
||||
## Dumping the contents of a feed
|
||||
|
||||
To dump the contents of a `Zend\Feed\Reader\Feed\AbstractFeed` instance, you may
|
||||
use the `saveXml()` method.
|
||||
|
||||
```php
|
||||
assert($feed instanceof Zend\Feed\Reader\Feed\AbstractFeed);
|
||||
|
||||
// dump the feed to standard output
|
||||
print $feed->saveXml();
|
||||
```
|
10
web/vendor/zendframework/zend-feed/doc/book/index.html
vendored
Normal file
10
web/vendor/zendframework/zend-feed/doc/book/index.html
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<div class="container">
|
||||
<div class="jumbotron">
|
||||
<h1>zend-feed</h1>
|
||||
|
||||
<p>Consume and generate Atom and RSS feeds, and interact with Pubsubhubbub.</p>
|
||||
|
||||
<pre><code class="language-bash">$ composer require zendframework/zend-feed</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
1
web/vendor/zendframework/zend-feed/doc/book/index.md
vendored
Symbolic link
1
web/vendor/zendframework/zend-feed/doc/book/index.md
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../README.md
|
62
web/vendor/zendframework/zend-feed/doc/book/intro.md
vendored
Normal file
62
web/vendor/zendframework/zend-feed/doc/book/intro.md
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
# Introduction
|
||||
|
||||
`Zend\Feed` provides functionality for consuming RSS and Atom feeds. It provides
|
||||
a natural syntax for accessing elements of feeds, feed attributes, and entry
|
||||
attributes. `Zend\Feed` also has extensive support for modifying feed and entry
|
||||
structure with the same natural syntax, and turning the result back into XML.
|
||||
In the future, this modification support could provide support for the Atom
|
||||
Publishing Protocol.
|
||||
|
||||
`Zend\Feed` consists of `Zend\Feed\Reader` for reading RSS and Atom feeds,
|
||||
`Zend\Feed\Writer` for writing RSS and Atom feeds, and `Zend\Feed\PubSubHubbub`
|
||||
for working with Hub servers. Furthermore, both `Zend\Feed\Reader` and
|
||||
`Zend\Feed\Writer` support extensions which allows for working with additional
|
||||
data in feeds, not covered in the core API but used in conjunction with RSS and
|
||||
Atom feeds.
|
||||
|
||||
In the example below, we demonstrate a simple use case of retrieving an RSS feed
|
||||
and saving relevant portions of the feed data to a simple PHP array, which could
|
||||
then be used for printing the data, storing to a database, etc.
|
||||
|
||||
> ## RSS optional properties
|
||||
>
|
||||
> Many *RSS* feeds have different channel and item properties available. The
|
||||
> *RSS* specification provides for many optional properties, so be aware of this
|
||||
> when writing code to work with *RSS* data. `Zend\Feed` supports all optional
|
||||
> properties of the core *RSS* and *Atom* specifications.
|
||||
|
||||
## Reading RSS Feed Data
|
||||
|
||||
```php
|
||||
// Fetch the latest Slashdot headlines
|
||||
try {
|
||||
$slashdotRss =
|
||||
Zend\Feed\Reader\Reader::import('http://rss.slashdot.org/Slashdot/slashdot');
|
||||
} catch (Zend\Feed\Reader\Exception\RuntimeException $e) {
|
||||
// feed import failed
|
||||
echo "Exception caught importing feed: {$e->getMessage()}\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Initialize the channel/feed data array
|
||||
$channel = [
|
||||
'title' => $slashdotRss->getTitle(),
|
||||
'link' => $slashdotRss->getLink(),
|
||||
'description' => $slashdotRss->getDescription(),
|
||||
'items' => [],
|
||||
];
|
||||
|
||||
// Loop over each channel item/entry and store relevant data for each
|
||||
foreach ($slashdotRss as $item) {
|
||||
$channel['items'][] = [
|
||||
'title' => $item->getTitle(),
|
||||
'link' => $item->getLink(),
|
||||
'description' => $item->getDescription(),
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
Your `$channel` array now contains the basic meta-information for the RSS
|
||||
channel and all items that it contained. The process is identical for Atom
|
||||
feeds since `Zend\Feed` provides a common feed API; i.e. all getters and
|
||||
setters are the same regardless of feed format.
|
90
web/vendor/zendframework/zend-feed/doc/book/psr7-clients.md
vendored
Normal file
90
web/vendor/zendframework/zend-feed/doc/book/psr7-clients.md
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
# Using PSR-7 Clients
|
||||
|
||||
As noted in the previous section, you can [substitute your own HTTP client by implementing the ClientInterface](http-clients.md#clientinterface-and-headerawareclientinterface).
|
||||
In this section, we'll demonstrate doing so in order to use a client that is
|
||||
[PSR-7](http://www.php-fig.org/psr/psr-7/)-capable.
|
||||
|
||||
## Responses
|
||||
|
||||
zend-feed provides a facility to assist with generating a
|
||||
`Zend\Feed\Reader\Response` from a PSR-7 `ResponseInterface` via
|
||||
`Zend\Feed\Reader\Http\Psr7ResponseDecorator`. As such, if you have a
|
||||
PSR-7-capable client, you can pass the response to this decorator, and
|
||||
immediately return it from your custom client:
|
||||
|
||||
```php
|
||||
return new Psr7ResponseDecorator($psr7Response);
|
||||
```
|
||||
|
||||
We'll do this with our PSR-7 client.
|
||||
|
||||
## Guzzle
|
||||
|
||||
[Guzzle](http://docs.guzzlephp.org/en/latest/) is arguably the most popular HTTP
|
||||
client library for PHP, and fully supports PSR-7 since version 5. Let's install
|
||||
it:
|
||||
|
||||
```bash
|
||||
$ composer require guzzlehttp/guzzle
|
||||
```
|
||||
|
||||
We'll use the `GuzzleHttp\Client` to make our requests to feeds.
|
||||
|
||||
## Creating a client
|
||||
|
||||
From here, we'll create our client. To do this, we'll create a class that:
|
||||
|
||||
- implements `Zend\Feed\Reader\Http\ClientInterface`
|
||||
- accepts a `GuzzleHttp\ClientInterface` to its constructor
|
||||
- uses the Guzzle client to make the request
|
||||
- returns a zend-feed response decorating the actual PSR-7 response
|
||||
|
||||
The code looks like this:
|
||||
|
||||
```php
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\ClientInterface as GuzzleClientInterface;
|
||||
use Zend\Feed\Reader\Http\ClientInterface as FeedReaderHttpClientInterface;
|
||||
use Zend\Feed\Reader\Http\Psr7ResponseDecorator;
|
||||
|
||||
class GuzzleClient implements FeedReaderHttpClientInterface
|
||||
{
|
||||
/**
|
||||
* @var GuzzleClientInterface
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @param GuzzleClientInterface|null $client
|
||||
*/
|
||||
public function __construct(GuzzleClientInterface $client = null)
|
||||
{
|
||||
$this->client = $client ?: new Client();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($uri)
|
||||
{
|
||||
return new Psr7ResponseDecorator(
|
||||
$this->client->request('GET', $uri)
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Using the client
|
||||
|
||||
In order to use our new client, we need to tell `Zend\Feed\Reader\Reader` about
|
||||
it:
|
||||
|
||||
```php
|
||||
Zend\Feed\Reader\Reader::setHttpClient(new GuzzleClient());
|
||||
```
|
||||
|
||||
From this point forward, this custom client will be used to retrieve feeds.
|
||||
|
||||
## References
|
||||
|
||||
This chapter is based on [a blog post by Stefan Gehrig](https://www.teqneers.de/2016/05/zendfeedreader-guzzle-and-psr-7/).
|
452
web/vendor/zendframework/zend-feed/doc/book/pubsubhubbub.md
vendored
Normal file
452
web/vendor/zendframework/zend-feed/doc/book/pubsubhubbub.md
vendored
Normal file
|
@ -0,0 +1,452 @@
|
|||
# Zend\\Feed\\PubSubHubbub
|
||||
|
||||
`Zend\Feed\PubSubHubbub` is an implementation of the [PubSubHubbub Core 0.2/0.3
|
||||
Specification (Working Draft)](http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.3.html).
|
||||
It offers implementations of a Pubsubhubbub Publisher and Subscriber suited to
|
||||
PHP applications.
|
||||
|
||||
## What is PubSubHubbub?
|
||||
|
||||
Pubsubhubbub is an open, simple, web-scale, pubsub protocol. A common use case
|
||||
to enable blogs (Publishers) to "push" updates from their RSS or Atom feeds
|
||||
(Topics) to end Subscribers. These Subscribers will have subscribed to the
|
||||
blog's RSS or Atom feed via a Hub, a central server which is notified of any
|
||||
updates by the Publisher, and which then distributes these updates to all
|
||||
Subscribers. Any feed may advertise that it supports one or more Hubs using an
|
||||
Atom namespaced link element with a rel attribute of "hub" (i.e., `rel="hub"`).
|
||||
|
||||
Pubsubhubbub has garnered attention because it is a pubsub protocol which is
|
||||
easy to implement and which operates over HTTP. Its philosophy is to replace the
|
||||
traditional model where blog feeds have been polled at regular intervals to
|
||||
detect and retrieve updates. Depending on the frequency of polling, this can
|
||||
take a lot of time to propagate updates to interested parties from planet
|
||||
aggregators to desktop readers. With a pubsub system in place, updates are not
|
||||
simply polled by Subscribers, they are pushed to Subscribers, eliminating any
|
||||
delay. For this reason, Pubsubhubbub forms part of what has been dubbed the
|
||||
real-time web.
|
||||
|
||||
The protocol does not exist in isolation. Pubsub systems have been around for a
|
||||
while, such as the familiar Jabber Publish-Subscribe protocol,
|
||||
[XEP-0060](http://www.xmpp.org/extensions/xep-0060.html), or the less well-known
|
||||
[rssCloud](http://www.rssboard.org/rsscloud-interface) (described in 2001).
|
||||
However, these have not achieved widespread adoption due to either their
|
||||
complexity, poor timing, or lack of suitability for web applications. rssCloud,
|
||||
which was recently revived as a response to the appearance of Pubsubhubbub, has
|
||||
also seen its usage increase significantly, though it lacks a formal
|
||||
specification and currently does not support Atom 1.0 feeds.
|
||||
|
||||
Perhaps surprisingly given its relative early age, Pubsubhubbub is already in
|
||||
use including in Google Reader and Feedburner, and there are plugins available
|
||||
for Wordpress blogs.
|
||||
|
||||
## Architecture
|
||||
|
||||
`Zend\Feed\PubSubHubbub` implements two sides of the Pubsubhubbub 0.2/0.3
|
||||
Specification: a Publisher and a Subscriber. It does not currently implement a
|
||||
Hub Server.
|
||||
|
||||
A Publisher is responsible for notifying all supported Hubs (many can be
|
||||
supported to add redundancy to the system) of any updates to its feeds, whether
|
||||
they be Atom or RSS based. This is achieved by pinging the supported Hub Servers
|
||||
with the URL of the updated feed. In Pubsubhubbub terminology, any updatable
|
||||
resource capable of being subscribed to is referred to as a Topic. Once a ping
|
||||
is received, the Hub will request the updated feed, process it for updated
|
||||
items, and forward all updates to all Subscribers subscribed to that feed.
|
||||
|
||||
A Subscriber is any party or application which subscribes to one or more Hubs to
|
||||
receive updates from a Topic hosted by a Publisher. The Subscriber never
|
||||
directly communicates with the Publisher since the Hub acts as an intermediary,
|
||||
accepting subscriptions and sending updates to Subscribers. The Subscriber
|
||||
therefore communicates only with the Hub, either to subscribe or unsubscribe to
|
||||
Topics, or when it receives updates from the Hub. This communication design
|
||||
("Fat Pings") effectively removes the possibility of a "Thundering Herd" issue.
|
||||
(Thundering Herds occur in a pubsub system where the Hub merely informs
|
||||
Subscribers that an update is available, prompting all Subscribers to
|
||||
immediately retrieve the feed from the Publisher, giving rise to a traffic
|
||||
spike.) In Pubsubhubbub, the Hub distributes the actual update in a "Fat Ping"
|
||||
so the Publisher is not subjected to any traffic spike.
|
||||
|
||||
`Zend\Feed\PubSubHubbub` implements Pubsubhubbub Publishers and Subscribers with
|
||||
the classes `Zend\Feed\PubSubHubbub\Publisher` and
|
||||
`Zend\Feed\PubSubHubbub\Subscriber`. In addition, the Subscriber implementation
|
||||
may handle any feed updates forwarded from a Hub by using
|
||||
`Zend\Feed\PubSubHubbub\Subscriber\Callback`. These classes, their use cases,
|
||||
and etheir APIs are covered in subsequent sections.
|
||||
|
||||
## Zend\\Feed\\PubSubHubbub\\Publisher
|
||||
|
||||
In Pubsubhubbub, the Publisher is the party publishing a live feed with content
|
||||
updates. This may be a blog, an aggregator, or even a web service with a public
|
||||
feed based API. In order for these updates to be pushed to Subscribers, the
|
||||
Publisher must notify all of its supported Hubs that an update has occurred
|
||||
using a simple HTTP POST request containing the URI of the updated Topic (i.e.,
|
||||
the updated RSS or Atom feed). The Hub will confirm receipt of the notification,
|
||||
fetch the updated feed, and forward any updates to any Subscribers who have
|
||||
subscribed to that Hub for updates from the relevant feed.
|
||||
|
||||
By design, this means the Publisher has very little to do except send these Hub
|
||||
pings whenever its feeds change. As a result, the Publisher implementation is
|
||||
extremely simple to use and requires very little work to setup and use when
|
||||
feeds are updated.
|
||||
|
||||
`Zend\Feed\PubSubHubbub\Publisher` implements a full Pubsubhubbub Publisher. Its
|
||||
setup for use primarily requires that it is configured with the URI endpoint for
|
||||
all Hubs to be notified of updates, and the URIs of all Topics to be included in
|
||||
the notifications.
|
||||
|
||||
The following example shows a Publisher notifying a collection of Hubs about
|
||||
updates to a pair of local RSS and Atom feeds. The class retains a collection of
|
||||
errors which include the Hub URLs, so that notification can be attempted again
|
||||
later and/or logged if any notifications happen to fail. Each resulting error
|
||||
array also includes a "response" key containing the related HTTP response
|
||||
object. In the event of any errors, it is strongly recommended to attempt the
|
||||
operation for failed Hub Endpoints at least once more at a future time. This may
|
||||
require the use of either a scheduled task for this purpose or a job queue,
|
||||
though such extra steps are optional.
|
||||
|
||||
```php
|
||||
use Zend\Feed\PubSubHubbub\Publisher;
|
||||
|
||||
$publisher = Publisher;
|
||||
$publisher->addHubUrls([
|
||||
'http://pubsubhubbub.appspot.com/',
|
||||
'http://hubbub.example.com',
|
||||
]);
|
||||
$publisher->addUpdatedTopicUrls([
|
||||
'http://www.example.net/rss',
|
||||
'http://www.example.net/atom',
|
||||
]);
|
||||
$publisher->notifyAll();
|
||||
|
||||
if (! $publisher->isSuccess()) {
|
||||
// check for errors
|
||||
$errors = $publisher->getErrors();
|
||||
$failedHubs = [];
|
||||
foreach ($errors as $error) {
|
||||
$failedHubs[] = $error['hubUrl'];
|
||||
}
|
||||
}
|
||||
|
||||
// reschedule notifications for the failed Hubs in $failedHubs
|
||||
```
|
||||
|
||||
If you prefer having more concrete control over the Publisher, the methods
|
||||
`addHubUrls()` and `addUpdatedTopicUrls()` pass each array value to the singular
|
||||
`addHubUrl()` and `addUpdatedTopicUrl()` public methods. There are also matching
|
||||
`removeUpdatedTopicUrl()` and `removeHubUrl()` methods.
|
||||
|
||||
You can also skip setting Hub URIs, and notify each in turn using the
|
||||
`notifyHub()` method which accepts the URI of a Hub endpoint as its only
|
||||
argument.
|
||||
|
||||
There are no other tasks to cover. The Publisher implementation is very simple
|
||||
since most of the feed processing and distribution is handled by the selected
|
||||
Hubs. It is, however, important to detect errors and reschedule notifications as
|
||||
soon as possible (with a reasonable maximum number of retries) to ensure
|
||||
notifications reach all Subscribers. In many cases, as a final alternative, Hubs
|
||||
may frequently poll your feeds to offer some additional tolerance for failures
|
||||
both in terms of their own temporary downtime or Publisher errors or downtime.
|
||||
|
||||
## Zend\\Feed\\PubSubHubbub\\Subscriber
|
||||
|
||||
In Pubsubhubbub, the Subscriber is the party who wishes to receive updates to
|
||||
any Topic (RSS or Atom feed). They achieve this by subscribing to one or more of
|
||||
the Hubs advertised by that Topic, usually as a set of one or more Atom 1.0
|
||||
links with a rel attribute of "hub" (i.e., `rel="hub"`). The Hub from that point
|
||||
forward will send an Atom or RSS feed containing all updates to that
|
||||
Subscriber's callback URL when it receives an update notification from the
|
||||
Publisher. In this way, the Subscriber need never actually visit the original
|
||||
feed (though it's still recommended at some level to ensure updates are
|
||||
retrieved if ever a Hub goes offline). All subscription requests must contain
|
||||
the URI of the Topic being subscribed and a callback URL which the Hub will use
|
||||
to confirm the subscription and to forward updates.
|
||||
|
||||
The Subscriber therefore has two roles. The first is to *create* and *manage*
|
||||
subscriptions, including subscribing for new Topics with a Hub, unsubscribing
|
||||
(if necessary), and periodically renewing subscriptions, since they may have an
|
||||
expiry set by the Hub. This is handled by `Zend\Feed\PubSubHubbub\Subscriber`.
|
||||
|
||||
The second role is to *accept updates* sent by a Hub to the Subscriber's
|
||||
callback URL, i.e. the URI the Subscriber has assigned to handle updates. The
|
||||
callback URL also handles events where the Hub contacts the Subscriber to
|
||||
confirm all subscriptions and unsubscriptions. This is handled by using an
|
||||
instance of `Zend\Feed\PubSubHubbub\Subscriber\Callback` when the callback URL
|
||||
is accessed.
|
||||
|
||||
> ### Query strings in callback URLs
|
||||
>
|
||||
> `Zend\Feed\PubSubHubbub\Subscriber` implements the Pubsubhubbub 0.2/0.3
|
||||
> specification. As this is a new specification version, not all Hubs currently
|
||||
> implement it. The new specification allows the callback URL to include a query
|
||||
> string which is used by this class, but not supported by all Hubs. In the
|
||||
> interests of maximising compatibility, it is therefore recommended that the
|
||||
> query string component of the Subscriber callback URI be presented as a path
|
||||
> element, i.e. recognised as a parameter in the route associated with the
|
||||
> callback URI and used by the application's router.
|
||||
|
||||
### Subscribing and Unsubscribing
|
||||
|
||||
`Zend\Feed\PubSubHubbub\Subscriber` implements a full Pubsubhubbub Subscriber
|
||||
capable of subscribing to, or unsubscribing from, any Topic via any Hub
|
||||
advertised by that Topic. It operates in conjunction with
|
||||
`Zend\Feed\PubSubHubbub\Subscriber\Callback`, which accepts requests from a Hub
|
||||
to confirm all subscription or unsubscription attempts (to prevent third-party
|
||||
misuse).
|
||||
|
||||
Any subscription (or unsubscription) requires the relevant information before
|
||||
proceeding, i.e. the URI of the Topic (Atom or RSS feed) to be subscribed to for
|
||||
updates, and the URI of the endpoint for the Hub which will handle the
|
||||
subscription and forwarding of the updates. The lifetime of a subscription may
|
||||
be determined by the Hub, but most Hubs should support automatic subscription
|
||||
refreshes by checking with the Subscriber. This is supported by
|
||||
`Zend\Feed\PubSubHubbub\Subscriber\Callback` and requires no other work on your
|
||||
part. It is still strongly recommended that you use the Hub-sourced subscription
|
||||
time-to.live (ttl) to schedule the creation of new subscriptions (the process is
|
||||
identical to that for any new subscription) to refresh it with the Hub. While it
|
||||
should not be necessary per se, it covers cases where a Hub may not support
|
||||
automatic subscription refreshing, and rules out Hub errors for additional
|
||||
redundancy.
|
||||
|
||||
With the relevant information to hand, a subscription can be attempted as
|
||||
demonstrated below:
|
||||
|
||||
```php
|
||||
use Zend\Feed\PubSubHubbub\Model\Subscription;
|
||||
use Zend\Feed\PubSubHubbub\Subscriber;
|
||||
|
||||
$storage = new Subscription;
|
||||
$subscriber = new Subscriber;
|
||||
$subscriber->setStorage($storage);
|
||||
$subscriber->addHubUrl('http://hubbub.example.com');
|
||||
$subscriber->setTopicUrl('http://www.example.net/rss.xml');
|
||||
$subscriber->setCallbackUrl('http://www.mydomain.com/hubbub/callback');
|
||||
$subscriber->subscribeAll();
|
||||
```
|
||||
|
||||
In order to store subscriptions and offer access to this data for general use,
|
||||
the component requires a database (a schema is provided later in this section).
|
||||
By default, it is assumed the table name is "subscription", and it utilises
|
||||
`Zend\Db\TableGateway\TableGateway` in the background, meaning it will use the
|
||||
default adapter you have set for your application. You may also pass a specific
|
||||
custom `Zend\Db\TableGateway\TableGateway` instance into the associated model
|
||||
`Zend\Feed\PubSubHubbub\Model\Subscription`. This custom adapter may be as
|
||||
simple in intent as changing the table name to use or as complex as you deem
|
||||
necessary.
|
||||
|
||||
While this model is offered as a default ready-to-roll solution, you may create
|
||||
your own model using any other backend or database layer (e.g. Doctrine) so long
|
||||
as the resulting class implements the interface
|
||||
`Zend\Feed\PubSubHubbub\Model\SubscriptionInterface`.
|
||||
|
||||
An example schema (MySQL) for a subscription table accessible by the provided
|
||||
model may look similar to:
|
||||
|
||||
```sql
|
||||
CREATE TABLE IF NOT EXISTS `subscription` (
|
||||
`id` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
`topic_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`hub_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`created_time` datetime DEFAULT NULL,
|
||||
`lease_seconds` bigint(20) DEFAULT NULL,
|
||||
`verify_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`secret` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`expiration_time` datetime DEFAULT NULL,
|
||||
`subscription_state` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
```
|
||||
|
||||
Behind the scenes, the Subscriber above will send a request to the Hub endpoint
|
||||
containing the following parameters (based on the previous example):
|
||||
|
||||
Parameter | Value | Explanation
|
||||
--------- | ----- | -----------
|
||||
`hub.callback` | `http://www.mydomain.com/hubbub/callback?xhub.subscription=5536df06b5dcb966edab3a4c4d56213c16a8184` | The URI used by a Hub to contact the Subscriber and either request confirmation of a (un)subscription request, or send updates from subscribed feeds. The appended query string contains a custom parameter (hence the xhub designation). It is a query string parameter preserved by the Hub and re-sent with all Subscriber requests. Its purpose is to allow the Subscriber to identify and look up the subscription associated with any Hub request in a backend storage medium. This is a non-standard parameter used by this component in preference to encoding a subscription key in the URI path, which is difficult to enforce generically. Nevertheless, since not all Hubs support query string parameters, we still strongly recommend adding the subscription key as a path component in the form `http://www.mydomain.com/hubbub/callback/5536df06b5dcb966edab3a4c4d56213c16a8184`. This requires defining a route capable of parsing out the final value of the key, retrieving the value, and passing it to the Subscriber callback object. The value should be passed into the method `Zend\PubSubHubbub\Subscriber\Callback::setSubscriptionKey()`. A detailed example is offered later.
|
||||
`hub.lease_seconds` | `2592000` | The number of seconds for which the Subscriber would like a new subscription to remain valid (i.e. a TTL). Hubs may enforce their own maximum subscription period. All subscriptions should be renewed by re-subscribing before the subscription period ends to ensure continuity of updates. Hubs should additionally attempt to automatically refresh subscriptions before they expire by contacting Subscribers (handled automatically by the `Callback` class).
|
||||
`hub.mode` | `subscribe` | Value indicating this is a subscription request. Unsubscription requests would use the "unsubscribe" value.
|
||||
`hub.topic` | `http://www.example.net/rss.xml` | The URI of the Topic (i.e. Atom or RSS feed) which the Subscriber wishes to subscribe to for updates.
|
||||
`hub.verify` | `sync` or `async` | Indicates to the Hub the preferred mode of verifying subscriptions or unsubscriptions. It is repeated twice in order of preference. Technically this component does not distinguish between the two modes and treats both equally.
|
||||
`hub.verify_token` | `3065919804abcaa7212ae89.879827871253878386` | A verification token returned to the Subscriber by the Hub when it is confirming a subscription or unsubscription. Offers a measure of reliance that the confirmation request originates from the correct Hub to prevent misuse.
|
||||
|
||||
You can modify several of these parameters to indicate a different preference.
|
||||
For example, you can set a different lease seconds value using
|
||||
`Zend\Feed\PubSubHubbub\Subscriber::setLeaseSeconds(),` or show a preference for
|
||||
the `async` verify mode by using `setPreferredVerificationMode(Zend\Feed\PubSubHubbub\PubSubHubbub::VERIFICATION_MODE_ASYNC)`.
|
||||
However, the Hubs retain the capability to enforce their own preferences, and
|
||||
for this reason the component is deliberately designed to work across almost any
|
||||
set of options with minimum end-user configuration required. Conventions are
|
||||
great when they work!
|
||||
|
||||
> ### Verification modes
|
||||
>
|
||||
> While Hubs may require the use of a specific verification mode (both are
|
||||
> supported by `Zend\Feed\PubSubHubbub`), you may indicate a specific preference
|
||||
> using the `setPreferredVerificationMode()` method. In `sync` (synchronous)
|
||||
> mode, the Hub attempts to confirm a subscription as soon as it is received,
|
||||
> and before responding to the subscription request. In `async` (asynchronous)
|
||||
> mode, the Hub will return a response to the subscription request immediately,
|
||||
> and its verification request may occur at a later time. Since
|
||||
> `Zend\Feed\PubSubHubbub` implements the Subscriber verification role as a
|
||||
> separate callback class and requires the use of a backend storage medium, it
|
||||
> actually supports both transparently. In terms of end-user performance,
|
||||
> asynchronous verification is very much preferred to eliminate the impact of a
|
||||
> poorly performing Hub tying up end-user server resources and connections for
|
||||
> too long.
|
||||
|
||||
Unsubscribing from a Topic follows the exact same pattern as the previous
|
||||
example, with the exception that we should call `unsubscribeAll()` instead. The
|
||||
parameters included are identical to a subscription request with the exception
|
||||
that `hub.mode` is set to "unsubscribe".
|
||||
|
||||
By default, a new instance of `Zend\PubSubHubbub\Subscriber` will attempt to use
|
||||
a database backed storage medium which defaults to using the default zend-db
|
||||
adapter with a table name of "subscription". It is recommended to set a custom
|
||||
storage solution where these defaults are not apt either by passing in a new
|
||||
model supporting the required interface or by passing a new instance of
|
||||
`Zend\Db\TableGateway\TableGateway` to the default model's constructor to change
|
||||
the used table name.
|
||||
|
||||
### Handling Subscriber Callbacks
|
||||
|
||||
Whenever a subscription or unsubscription request is made, the Hub must verify
|
||||
the request by forwarding a new verification request to the callback URL set in
|
||||
the subscription or unsubscription parameters. To handle these Hub requests,
|
||||
which will include all future communications containing Topic (feed) updates,
|
||||
the callback URL should trigger the execution of an instance of
|
||||
`Zend\Feed\PubSubHubbub\Subscriber\Callback` to handle the request.
|
||||
|
||||
The `Callback` class should be configured to use the same storage medium as the
|
||||
`Subscriber` class. The bulk of the work is handled internal to these classes.
|
||||
|
||||
```php
|
||||
use Zend\Feed\PubSubHubbub\Model\Subscription;
|
||||
use Zend\Feed\PubSubHubbub\Subscriber\Callback;
|
||||
|
||||
$storage = new Subscription();
|
||||
$callback = new Callback();
|
||||
$callback->setStorage($storage);
|
||||
$callback->handle();
|
||||
$callback->sendResponse();
|
||||
|
||||
/*
|
||||
* Check if the callback resulting in the receipt of a feed update.
|
||||
* Otherwise it was either a (un)sub verification request or invalid request.
|
||||
* Typically we need do nothing other than add feed update handling; the rest
|
||||
* is handled internally by the class.
|
||||
*/
|
||||
if ($callback->hasFeedUpdate()) {
|
||||
$feedString = $callback->getFeedUpdate();
|
||||
/*
|
||||
* Process the feed update asynchronously to avoid a Hub timeout.
|
||||
*/
|
||||
}
|
||||
```
|
||||
|
||||
> #### Query and body parameters
|
||||
>
|
||||
> It should be noted that `Zend\Feed\PubSubHubbub\Subscriber\Callback` may
|
||||
> independently parse any incoming query string and other parameters. This is
|
||||
> necessary since PHP alters the structure and keys of a query string when it is
|
||||
> parsed into the `$_GET` or `$_POST` superglobals; for example, all duplicate
|
||||
> keys are ignored and periods are converted to underscores. Pubsubhubbub
|
||||
> features both of these in the query strings it generates.
|
||||
|
||||
> #### Always delay feed processing
|
||||
>
|
||||
> It is essential that developers recognise that Hubs are only concerned with
|
||||
> sending requests and receiving a response which verifies its receipt. If a
|
||||
> feed update is received, it should never be processed on the spot since this
|
||||
> leaves the Hub waiting for a response. Rather, any processing should be
|
||||
> offloaded to another process or deferred until after a response has been
|
||||
> returned to the Hub. One symptom of a failure to promptly complete Hub
|
||||
> requests is that a Hub may continue to attempt delivery of the update or
|
||||
> verification request leading to duplicated update attempts being processed by
|
||||
> the Subscriber. This appears problematic, but in reality a Hub may apply a
|
||||
> timeout of just a few seconds, and if no response is received within that time
|
||||
> it may disconnect (assuming a delivery failure) and retry later. Note that
|
||||
> Hubs are expected to distribute vast volumes of updates so their resources are
|
||||
> stretched; please process feeds asynchronously (e.g. in a separate process or
|
||||
> a job queue or even a cronjob) as much as possible.
|
||||
|
||||
### Setting Up And Using A Callback URL Route
|
||||
|
||||
As noted earlier, the `Zend\Feed\PubSubHubbub\Subscriber\Callback` class
|
||||
receives the combined key associated with any subscription from the Hub via one
|
||||
of two methods. The technically preferred method is to add this key to the
|
||||
callback URL employed by the Hub in all future requests using a query string
|
||||
parameter with the key `xhub.subscription`. However, for historical reasons
|
||||
(primarily that this was not supported in Pubsubhubbub 0.1, and a late addition
|
||||
to 0.2 ), it is strongly recommended to use the most compatible means of adding
|
||||
this key to the callback URL by appending it to the URL's path.
|
||||
|
||||
Thus the URL `http://www.example.com/callback?xhub.subscription=key` would become
|
||||
`http://www.example.com/callback/key`.
|
||||
|
||||
Since the query string method is the default in anticipation of a greater level
|
||||
of future support for the full 0.2/0.3 specification, this requires some
|
||||
additional work to implement.
|
||||
|
||||
The first step is to make the `Zend\Feed\PubSubHubbub\Subscriber\Callback` class
|
||||
aware of the path contained subscription key. It's manually injected; therefore
|
||||
it also requires manually defining a route for this purpose. This is achieved by
|
||||
called the method `Zend\Feed\PubSubHubbub\Subscriber\Callback::setSubscriptionKey()`
|
||||
with the parameter being the key value available from the router. The example
|
||||
below demonstrates this using a zend-mvc controller.
|
||||
|
||||
```php
|
||||
use Zend\Feed\PubSubHubbub\Model\Subscription;
|
||||
use Zend\Feed\PubSubHubbub\Subscriber\Callback;
|
||||
use Zend\Mvc\Controller\AbstractActionController;
|
||||
|
||||
class CallbackController extends AbstractActionController
|
||||
{
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$storage = new Subscription();
|
||||
$callback = new Callback();
|
||||
$callback->setStorage($storage);
|
||||
|
||||
/*
|
||||
* Inject subscription key parsing from URL path using
|
||||
* a parameter from the router.
|
||||
*/
|
||||
$subscriptionKey = $this->params()->fromRoute('subkey');
|
||||
$callback->setSubscriptionKey($subscriptionKey);
|
||||
$callback->handle();
|
||||
$callback->sendResponse();
|
||||
|
||||
/*
|
||||
* Check if the callback resulting in the receipt of a feed update.
|
||||
* Otherwise it was either a (un)sub verification request or invalid
|
||||
* request. Typically we need do nothing other than add feed update
|
||||
* handling; the rest is handled internally by the class.
|
||||
*/
|
||||
if ($callback->hasFeedUpdate()) {
|
||||
$feedString = $callback->getFeedUpdate();
|
||||
/*
|
||||
* Process the feed update asynchronously to avoid a Hub timeout.
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The example below illustrates adding a route mapping the path segment to a route
|
||||
parameter, using zend-mvc:
|
||||
|
||||
```php
|
||||
use Zend\Mvc\Router\Http\Segment as SegmentRoute;;
|
||||
|
||||
// Route defininition for enabling appending of a PuSH Subscription's lookup key
|
||||
$route = SegmentRoute::factory([
|
||||
'route' => '/callback/:subkey',
|
||||
'constraints' => [
|
||||
'subkey' => '[a-z0-9]+',
|
||||
],
|
||||
'defaults' => [
|
||||
'controller' => 'application-index',
|
||||
'action' => 'index',
|
||||
]
|
||||
]);
|
||||
```
|
825
web/vendor/zendframework/zend-feed/doc/book/reader.md
vendored
Normal file
825
web/vendor/zendframework/zend-feed/doc/book/reader.md
vendored
Normal file
|
@ -0,0 +1,825 @@
|
|||
# Zend\\Feed\\Reader
|
||||
|
||||
`Zend\Feed\Reader` is a component used to consume RSS and Atom feeds of
|
||||
any version, including RDF/RSS 1.0, RSS 2.0, Atom 0.3, and Atom 1.0. The API for
|
||||
retrieving feed data is deliberately simple since `Zend\Feed\Reader` is capable
|
||||
of searching any feed of any type for the information requested through the API.
|
||||
If the typical elements containing this information are not present, it will
|
||||
adapt and fall back on a variety of alternative elements instead. This ability
|
||||
to choose from alternatives removes the need for users to create their own
|
||||
abstraction layer on top of the component to make it useful or have any in-depth
|
||||
knowledge of the underlying standards, current alternatives, and namespaced
|
||||
extensions.
|
||||
|
||||
Internally, the `Zend\Feed\Reader\Reader` class works almost entirely on the
|
||||
basis of making XPath queries against the feed XML's Document Object Model. This
|
||||
singular approach to parsing is consistent, and the component offers a plugin
|
||||
system to add to the Feed and Entry APIs by writing extensions on a similar
|
||||
basis.
|
||||
|
||||
Performance is assisted in three ways. First of all, `Zend\Feed\Reader\Reader`
|
||||
supports caching using [zend-cache](https://github.com/zendframework/zend-cache)
|
||||
to maintain a copy of the original feed XML. This allows you to skip network
|
||||
requests for a feed URI if the cache is valid. Second, the Feed and Entry APIs
|
||||
are backed by an internal cache (non-persistent) so repeat API calls for the
|
||||
same feed will avoid additional DOM or XPath use. Thirdly, importing feeds from
|
||||
a URI can take advantage of HTTP Conditional `GET` requests which allow servers
|
||||
to issue an empty 304 response when the requested feed has not changed since the
|
||||
last time you requested it. In the final case, an zend-cache storage instance
|
||||
will hold the last received feed along with the ETag and Last-Modified header
|
||||
values sent in the HTTP response.
|
||||
|
||||
`Zend\Feed\Reader\Reader` is not capable of constructing feeds, and delegates
|
||||
this responsibility to `Zend\Feed\Writer\Writer`.
|
||||
|
||||
## Importing Feeds
|
||||
|
||||
Feeds can be imported from a string, file or a URI. Importing from a URI can
|
||||
additionally utilise an HTTP Conditional `GET` request. If importing fails, an
|
||||
exception will be raised. The end result will be an object of type
|
||||
`Zend\Feed\Reader\Feed\AbstractFeed`, the core implementations of which are
|
||||
`Zend\Feed\Reader\Feed\Rss` and `Zend\Feed\Reader\Feed\Atom`. Both objects
|
||||
support multiple (all existing) versions of these broad feed types.
|
||||
|
||||
In the following example, we import an RDF/RSS 1.0 feed and extract some basic
|
||||
information that can be saved to a database or elsewhere.
|
||||
|
||||
```php
|
||||
$feed = Zend\Feed\Reader\Reader::import('http://www.planet-php.net/rdf/');
|
||||
$data = [
|
||||
'title' => $feed->getTitle(),
|
||||
'link' => $feed->getLink(),
|
||||
'dateModified' => $feed->getDateModified(),
|
||||
'description' => $feed->getDescription(),
|
||||
'language' => $feed->getLanguage(),
|
||||
'entries' => [],
|
||||
];
|
||||
|
||||
foreach ($feed as $entry) {
|
||||
$edata = [
|
||||
'title' => $entry->getTitle(),
|
||||
'description' => $entry->getDescription(),
|
||||
'dateModified' => $entry->getDateModified(),
|
||||
'authors' => $entry->getAuthors(),
|
||||
'link' => $entry->getLink(),
|
||||
'content' => $entry->getContent(),
|
||||
];
|
||||
$data['entries'][] = $edata;
|
||||
}
|
||||
```
|
||||
|
||||
> ## Importing requires an HTTP client
|
||||
>
|
||||
> To import a feed, you will need to have an [HTTP client](zend.feed.http-clients)
|
||||
> available.
|
||||
>
|
||||
> If you are not using zend-http, you will need to inject `Reader` with the HTTP
|
||||
> client. See the [section on providing a client to Reader](http-clients.md#providing-a-client-to-reader).
|
||||
|
||||
The example above demonstrates `Zend\Feed\Reader\Reader`'s API, and it also
|
||||
demonstrates some of its internal operation. In reality, the RDF feed selected
|
||||
does not have any native date or author elements; however it does utilise the
|
||||
Dublin Core 1.1 module which offers namespaced creator and date elements.
|
||||
`Zend\Feed\Reader\Reader` falls back on these and similar options if no relevant
|
||||
native elements exist. If it absolutely cannot find an alternative it will
|
||||
return `NULL`, indicating the information could not be found in the feed. You
|
||||
should note that classes implementing `Zend\Feed\Reader\Feed\AbstractFeed` also
|
||||
implement the SPL `Iterator` and `Countable` interfaces.
|
||||
|
||||
Feeds can also be imported from strings or files.
|
||||
|
||||
```php
|
||||
// from a URI
|
||||
$feed = Zend\Feed\Reader\Reader::import('http://www.planet-php.net/rdf/');
|
||||
|
||||
// from a String
|
||||
$feed = Zend\Feed\Reader\Reader::importString($feedXmlString);
|
||||
|
||||
// from a file
|
||||
$feed = Zend\Feed\Reader\Reader::importFile('./feed.xml');
|
||||
```
|
||||
|
||||
## Retrieving Underlying Feed and Entry Sources
|
||||
|
||||
`Zend\Feed\Reader\Reader` does its best not to stick you in a narrow confine. If
|
||||
you need to work on a feed outside of `Zend\Feed\Reader\Reader`, you can extract
|
||||
the base DOMDocument or DOMElement objects from any class, or even an XML
|
||||
string containing these. Also provided are methods to extract the current
|
||||
DOMXPath object (with all core and extension namespaces registered) and the
|
||||
correct prefix used in all XPath queries for the current feed or entry. The
|
||||
basic methods to use (on any object) are `saveXml()`, `getDomDocument()`,
|
||||
`getElement()`, `getXpath()` and `getXpathPrefix()`. These will let you break
|
||||
free of `Zend\Feed\Reader` and do whatever else you want.
|
||||
|
||||
- `saveXml()` returns an XML string containing only the element representing the
|
||||
current object.
|
||||
- `getDomDocument()` returns the DOMDocument object representing the entire feed
|
||||
(even if called from an entry object).
|
||||
- `getElement()` returns the DOMElement of the current object (i.e. the feed or
|
||||
current entry).
|
||||
- `getXpath()` returns the DOMXPath object for the current feed (even if called
|
||||
from an entry object) with the namespaces of the current feed type and all
|
||||
loaded extensions pre-registered.
|
||||
- `getXpathPrefix()` returns the query prefix for the current object (i.e. the
|
||||
feed or current entry) which includes the correct XPath query path for that
|
||||
specific feed or entry.
|
||||
|
||||
Let's look at an example where a feed might include an RSS extension not
|
||||
supported by `Zend\Feed\Reader\Reader` out of the box. Notably, you could write
|
||||
and register an extension (covered later) to do this, but that's not always
|
||||
warranted for a quick check. You must register any new namespaces on the
|
||||
DOMXPath object before use unless they are registered by `Zend\Feed\Reader` or
|
||||
an extension beforehand.
|
||||
|
||||
```php
|
||||
$feed = Zend\Feed\Reader\Reader::import('http://www.planet-php.net/rdf/');
|
||||
$xpathPrefix = $feed->getXpathPrefix();
|
||||
$xpath = $feed->getXpath();
|
||||
$xpath->registerNamespace('admin', 'http://webns.net/mvcb/');
|
||||
$reportErrorsTo = $xpath->evaluate(
|
||||
'string(' . $xpathPrefix . '/admin:errorReportsTo)'
|
||||
);
|
||||
```
|
||||
|
||||
> ### Do not register duplicate namespaces
|
||||
>
|
||||
> If you register an already registered namespace with a different prefix name
|
||||
> to that used internally by `Zend\Feed\Reader\Reader`, it will break the
|
||||
> internal operation of this component.
|
||||
|
||||
## Cache Support and Intelligent Requests
|
||||
|
||||
### Adding Cache Support to Zend\\Feed\\Reader\\Reader
|
||||
|
||||
`Zend\Feed\Reader\Reader` supports using a
|
||||
[zend-cache](https://github.com/zendframework/zend-cache) storage instance to
|
||||
cache feeds (as XML) to avoid unnecessary network requests. To add a cache,
|
||||
create and configure your cache instance, and then tell
|
||||
`Zend\Feed\Reader\Reader` to use it. The cache key used is
|
||||
"`Zend\Feed\Reader\\`" followed by the MD5 hash of the feed's URI.
|
||||
|
||||
```php
|
||||
$cache = Zend\Cache\StorageFactory::adapterFactory('Memory');
|
||||
Zend\Feed\Reader\Reader::setCache($cache);
|
||||
```
|
||||
|
||||
### HTTP Conditional GET Support
|
||||
|
||||
The big question often asked when importing a feed frequently is if it has even
|
||||
changed. With a cache enabled, you can add HTTP Conditional `GET` support to
|
||||
your arsenal to answer that question.
|
||||
|
||||
Using this method, you can request feeds from URIs and include their last known
|
||||
ETag and Last-Modified response header values with the request (using the
|
||||
If-None-Match and If-Modified-Since headers). If the feed on the server remains
|
||||
unchanged, you should receive a 304 response which tells
|
||||
`Zend\Feed\Reader\Reader` to use the cached version. If a full feed is sent in a
|
||||
response with a status code of 200, this means the feed has changed and
|
||||
`Zend\Feed\Reader\Reader` will parse the new version and save it to the cache.
|
||||
It will also cache the new ETag and Last-Modified header values for future use.
|
||||
|
||||
> #### Conditional GET requires a HeaderAwareClientInterface
|
||||
>
|
||||
> Conditional GET support only works for `Zend\Feed\Reader\Http\HeaderAwareClientInterface`
|
||||
> client implementations, as it requires the ability to send HTTP headers.
|
||||
|
||||
These "conditional" requests are not guaranteed to be supported by the server
|
||||
you request a *URI* of, but can be attempted regardless. Most common feed
|
||||
sources like blogs should however have this supported. To enable conditional
|
||||
requests, you will need to provide a cache to `Zend\Feed\Reader\Reader`.
|
||||
|
||||
```php
|
||||
$cache = Zend\Cache\StorageFactory::adapterFactory('Memory');
|
||||
|
||||
Zend\Feed\Reader\Reader::setCache($cache);
|
||||
Zend\Feed\Reader\Reader::useHttpConditionalGet();
|
||||
|
||||
$feed = Zend\Feed\Reader\Reader::import('http://www.planet-php.net/rdf/');
|
||||
```
|
||||
|
||||
In the example above, with HTTP Conditional `GET` requests enabled, the response
|
||||
header values for ETag and Last-Modified will be cached along with the feed. For
|
||||
the the cache's lifetime, feeds will only be updated on the cache if a non-304
|
||||
response is received containing a valid RSS or Atom XML document.
|
||||
|
||||
If you intend on managing request headers from outside
|
||||
`Zend\Feed\Reader\Reader`, you can set the relevant If-None-Matches and
|
||||
If-Modified-Since request headers via the URI import method.
|
||||
|
||||
```php
|
||||
$lastEtagReceived = '5e6cefe7df5a7e95c8b1ba1a2ccaff3d';
|
||||
$lastModifiedDateReceived = 'Wed, 08 Jul 2009 13:37:22 GMT';
|
||||
$feed = Zend\Feed\Reader\Reader::import(
|
||||
$uri, $lastEtagReceived, $lastModifiedDateReceived
|
||||
);
|
||||
```
|
||||
|
||||
## Locating Feed URIs from Websites
|
||||
|
||||
These days, many websites are aware that the location of their XML feeds is not
|
||||
always obvious. A small RDF, RSS, or Atom graphic helps when the user is reading
|
||||
the page, but what about when a machine visits trying to identify where your
|
||||
feeds are located? To assist in this, websites may point to their feeds using
|
||||
`<link>` tags in the `<head>` section of their HTML. To take advantage
|
||||
of this, you can use `Zend\Feed\Reader\Reader` to locate these feeds using the
|
||||
static `findFeedLinks()` method.
|
||||
|
||||
This method calls any URI and searches for the location of RSS, RDF, and Atom
|
||||
feeds assuming, the website's HTML contains the relevant links. It then returns
|
||||
a value object where you can check for the existence of a RSS, RDF or Atom feed
|
||||
URI.
|
||||
|
||||
The returned object is an `ArrayObject` subclass called
|
||||
`Zend\Feed\Reader\FeedSet`, so you can cast it to an array or iterate over it to
|
||||
access all the detected links. However, as a simple shortcut, you can just grab
|
||||
the first RSS, RDF, or Atom link using its public properties as in the example
|
||||
below. Otherwise, each element of the `ArrayObject` is a simple array with the
|
||||
keys `type` and `uri` where the type is one of "rdf", "rss", or "atom".
|
||||
|
||||
```php
|
||||
$links = Zend\Feed\Reader\Reader::findFeedLinks('http://www.planet-php.net');
|
||||
|
||||
if (isset($links->rdf)) {
|
||||
echo $links->rdf, "\n"; // http://www.planet-php.org/rdf/
|
||||
}
|
||||
if (isset($links->rss)) {
|
||||
echo $links->rss, "\n"; // http://www.planet-php.org/rss/
|
||||
}
|
||||
if (isset($links->atom)) {
|
||||
echo $links->atom, "\n"; // http://www.planet-php.org/atom/
|
||||
}
|
||||
```
|
||||
|
||||
Based on these links, you can then import from whichever source you wish in the usual manner.
|
||||
|
||||
> ### Finding feed links requires an HTTP client
|
||||
>
|
||||
> To find feed links, you will need to have an [HTTP client](zend.feed.http-clients)
|
||||
> available.
|
||||
>
|
||||
> If you are not using zend-http, you will need to inject `Reader` with the HTTP
|
||||
> client. See the [section on providing a client to Reader](http-clients.md#providing-a-client-to-reader).
|
||||
|
||||
This quick method only gives you one link for each feed type, but websites may
|
||||
indicate many links of any type. Perhaps it's a news site with a RSS feed for
|
||||
each news category. You can iterate over all links using the ArrayObject's
|
||||
iterator.
|
||||
|
||||
```php
|
||||
$links = Zend\Feed\Reader::findFeedLinks('http://www.planet-php.net');
|
||||
|
||||
foreach ($links as $link) {
|
||||
echo $link['href'], "\n";
|
||||
}
|
||||
```
|
||||
|
||||
## Attribute Collections
|
||||
|
||||
In an attempt to simplify return types, return types from the various feed and
|
||||
entry level methods may include an object of type
|
||||
`Zend\Feed\Reader\Collection\AbstractCollection`. Despite the special class name
|
||||
which I'll explain below, this is just a simple subclass of SPL's `ArrayObject`.
|
||||
|
||||
The main purpose here is to allow the presentation of as much data as possible
|
||||
from the requested elements, while still allowing access to the most relevant
|
||||
data as a simple array. This also enforces a standard approach to returning such
|
||||
data which previously may have wandered between arrays and objects.
|
||||
|
||||
The new class type acts identically to `ArrayObject` with the sole addition
|
||||
being a new method `getValues()` which returns a simple flat array containing
|
||||
the most relevant information.
|
||||
|
||||
A simple example of this is `Zend\Feed\Reader\Reader\FeedInterface::getCategories()`.
|
||||
When used with any RSS or Atom feed, this method will return category data as a
|
||||
container object called `Zend\Feed\Reader\Collection\Category`. The container
|
||||
object will contain, per category, three fields of data: term, scheme, and label.
|
||||
The "term" is the basic category name, often machine readable (i.e. plays nice
|
||||
with URIs). The scheme represents a categorisation scheme (usually a URI
|
||||
identifier) also known as a "domain" in RSS 2.0. The "label" is a human readable
|
||||
category name which supports HTML entities. In RSS 2.0, there is no label
|
||||
attribute so it is always set to the same value as the term for convenience.
|
||||
|
||||
To access category labels by themselves in a simple value array, you might
|
||||
commit to something like:
|
||||
|
||||
```php
|
||||
$feed = Zend\Feed\Reader\Reader::import('http://www.example.com/atom.xml');
|
||||
$categories = $feed->getCategories();
|
||||
$labels = [];
|
||||
foreach ($categories as $cat) {
|
||||
$labels[] = $cat['label']
|
||||
}
|
||||
```
|
||||
|
||||
It's a contrived example, but the point is that the labels are tied up with
|
||||
other information.
|
||||
|
||||
However, the container class allows you to access the "most relevant" data as a
|
||||
simple array using the `getValues()` method. The concept of "most relevant" is
|
||||
obviously a judgement call. For categories it means the category labels (not the
|
||||
terms or schemes) while for authors it would be the authors' names (not their
|
||||
email addresses or URIs). The simple array is flat (just values) and passed
|
||||
through `array_unique()` to remove duplication.
|
||||
|
||||
```php
|
||||
$feed = Zend\Feed\Reader\Reader::import('http://www.example.com/atom.xml');
|
||||
$categories = $feed->getCategories();
|
||||
$labels = $categories->getValues();
|
||||
```
|
||||
|
||||
The above example shows how to extract only labels and nothing else thus giving
|
||||
simple access to the category labels without any additional work to extract that
|
||||
data by itself.
|
||||
|
||||
## Retrieving Feed Information
|
||||
|
||||
Retrieving information from a feed (we'll cover entries and items in the next
|
||||
section though they follow identical principals) uses a clearly defined API
|
||||
which is exactly the same regardless of whether the feed in question is RSS,
|
||||
RDF, or Atom. The same goes for sub-versions of these standards and we've tested
|
||||
every single RSS and Atom version. While the underlying feed XML can differ
|
||||
substantially in terms of the tags and elements they present, they nonetheless
|
||||
are all trying to convey similar information and to reflect this all the
|
||||
differences and wrangling over alternative tags are handled internally by
|
||||
`Zend\Feed\Reader\Reader` presenting you with an identical interface for each.
|
||||
Ideally, you should not have to care whether a feed is RSS or Atom so long as
|
||||
you can extract the information you want.
|
||||
|
||||
> ### RSS feeds vary widely
|
||||
>
|
||||
> While determining common ground between feed types is itself complex, it
|
||||
> should be noted that *RSS* in particular is a constantly disputed
|
||||
> "specification". This has its roots in the original RSS 2.0 document, which
|
||||
> contains ambiguities and does not detail the correct treatment of all
|
||||
> elements. As a result, this component rigorously applies the RSS 2.0.11
|
||||
> Specification published by the RSS Advisory Board and its accompanying RSS
|
||||
> Best Practices Profile. No other interpretation of RSS
|
||||
> 2.0 will be supported, though exceptions may be allowed where it does not
|
||||
> directly prevent the application of the two documents mentioned above.
|
||||
|
||||
Of course, we don't live in an ideal world, so there may be times the API just
|
||||
does not cover what you're looking for. To assist you, `Zend\Feed\Reader\Reader`
|
||||
offers a plugin system which allows you to write extensions to expand the core
|
||||
API and cover any additional data you are trying to extract from feeds. If
|
||||
writing another extension is too much trouble, you can simply grab the
|
||||
underlying DOM or XPath objects and do it by hand in your application. Of
|
||||
course, we really do encourage writing an extension simply to make it more
|
||||
portable and reusable, and useful extensions may be proposed to the component
|
||||
for formal addition.
|
||||
|
||||
Below is a summary of the Core API for feeds. You should note it comprises not
|
||||
only the basic RSS and Atom standards, but also accounts for a number of
|
||||
included extensions bundled with `Zend\Feed\Reader\Reader`. The naming of these
|
||||
extension sourced methods remain fairly generic; all Extension methods operate
|
||||
at the same level as the Core API though we do allow you to retrieve any
|
||||
specific extension object separately if required.
|
||||
|
||||
### Feed Level API Methods
|
||||
|
||||
Method | Description
|
||||
------ | -----------
|
||||
`getId()` | Returns a unique ID associated with this feed
|
||||
`getTitle()` | Returns the title of the feed
|
||||
`getDescription()` | Returns the text description of the feed.
|
||||
`getLink()` | Returns a URI to the HTML website containing the same or similar information as this feed (i.e. if the feed is from a blog, it should provide the blog's URI where the HTML version of the entries can be read).
|
||||
`getFeedLink()` | Returns the URI of this feed, which may be the same as the URI used to import the feed. There are important cases where the feed link may differ because the source URI is being updated and is intended to be removed in the future.
|
||||
`getAuthors()` | Returns an object of type `Zend\Feed\Reader\Collection\Author` which is an `ArrayObject` whose elements are each simple arrays containing any combination of the keys "name", "email" and "uri". Where irrelevant to the source data, some of these keys may be omitted.
|
||||
`getAuthor(integer $index = 0)` | Returns either the first author known, or with the optional $index parameter any specific index on the array of authors as described above (returning `NULL` if an invalid index).
|
||||
`getDateCreated()` | Returns the date on which this feed was created. Generally only applicable to Atom, where it represents the date the resource described by an Atom 1.0 document was created. The returned date will be a `DateTime` object.
|
||||
`getDateModified()` | Returns the date on which this feed was last modified. The returned date will be a `DateTime` object.
|
||||
`getLastBuildDate()` | Returns the date on which this feed was last built. The returned date will be a `DateTime` object. This is only supported by RSS; Atom feeds will always return `NULL`.
|
||||
`getLanguage()` | Returns the language of the feed (if defined) or simply the language noted in the XML document.
|
||||
`getGenerator()` | Returns the generator of the feed, e.g. the software which generated it. This may differ between RSS and Atom since Atom defines a different notation.
|
||||
`getCopyright()` | Returns any copyright notice associated with the feed.
|
||||
`getHubs()` | Returns an array of all Hub Server URI endpoints which are advertised by the feed for use with the Pubsubhubbub Protocol, allowing subscriptions to the feed for real-time updates.
|
||||
`getCategories()` | Returns a `Zend\Feed\Reader\Collection\Category` object containing the details of any categories associated with the overall feed. The supported fields include "term" (the machine readable category name), "scheme" (the categorisation scheme and domain for this category), and "label" (a HTML decoded human readable category name). Where any of the three fields are absent from the field, they are either set to the closest available alternative or, in the case of "scheme", set to `NULL`.
|
||||
`getImage()` | Returns an array containing data relating to any feed image or logo, or `NULL` if no image found. The resulting array may contain the following keys: uri, link, title, description, height, and width. Atom logos only contain a URI so the remaining metadata is drawn from RSS feeds only.
|
||||
|
||||
Given the variety of feeds in the wild, some of these methods will undoubtedly
|
||||
return `NULL` indicating the relevant information couldn't be located. Where
|
||||
possible, `Zend\Feed\Reader\Reader` will fall back on alternative elements
|
||||
during its search. For example, searching an RSS feed for a modification date is
|
||||
more complicated than it looks. RSS 2.0 feeds should include a `<lastBuildDate>`
|
||||
tag and/or a `<pubDate>` element. But what if it doesn't? Maybe this is an RSS
|
||||
1.0 feed? Perhaps it instead has an `<atom:updated>` element with identical
|
||||
information (Atom may be used to supplement RSS syntax)? Failing that, we
|
||||
could simply look at the entries, pick the most recent, and use its `<pubDate>`
|
||||
element. Assuming it exists, that is. Many feeds also use Dublin Core 1.0 or 1.1
|
||||
`<dc:date>` elements for feeds and entries. Or we could find Atom lurking again.
|
||||
|
||||
The point is, `Zend\Feed\Reader\Reader` was designed to know this. When you ask
|
||||
for the modification date (or anything else), it will run off and search for all
|
||||
these alternatives until it either gives up and returns `NULL`, or finds an
|
||||
alternative that should have the right answer.
|
||||
|
||||
In addition to the above methods, all feed objects implement methods for
|
||||
retrieving the DOM and XPath objects for the current feeds as described
|
||||
earlier. Feed objects also implement the SPL Iterator and Countable
|
||||
interfaces. The extended API is summarised below.
|
||||
|
||||
### Extended Feed API Methods
|
||||
|
||||
Method | Description
|
||||
------ | -----------
|
||||
`getDomDocument()` | Returns the parent DOMDocument object for the entire source XML document.
|
||||
`getElement()` | Returns the current feed level DOMElement object.
|
||||
`saveXml()` | Returns a string containing an XML document of the entire feed element (this is not the original document, but a rebuilt version).
|
||||
`getXpath()` | Returns the DOMXPath object used internally to run queries on the DOMDocument object (this includes core and extension namespaces pre-registered).
|
||||
`getXpathPrefix()` | Returns the valid DOM path prefix prepended to all XPath queries matching the feed being queried.
|
||||
`getEncoding()` | Returns the encoding of the source XML document (note: this cannot account for errors such as the server sending documents in a different encoding). Where not defined, the default UTF-8 encoding of Unicode is applied.
|
||||
`count()` | Returns a count of the entries or items this feed contains (implements SPL `Countable` interface)
|
||||
`current()` | Returns either the current entry (using the current index from `key()`).
|
||||
`key()` | Returns the current entry index.
|
||||
`next()` | Increments the entry index value by one.
|
||||
`rewind()` | Resets the entry index to 0.
|
||||
`valid()` | Checks that the current entry index is valid, i.e. it does not fall below 0 and does not exceed the number of entries existing.
|
||||
`getExtensions()` | Returns an array of all extension objects loaded for the current feed (note: both feed-level and entry-level extensions exist, and only feed-level extensions are returned here). The array keys are of the form `{ExtensionName}_Feed`.
|
||||
`getExtension(string $name)` | Returns an extension object for the feed registered under the provided name. This allows more fine-grained access to extensions which may otherwise be hidden within the implementation of the standard API methods.
|
||||
`getType()` | Returns a static class constant (e.g. `Zend\Feed\Reader\Reader::TYPE_ATOM_03`, i.e. "Atom 0.3"), indicating exactly what kind of feed is being consumed.
|
||||
|
||||
## Retrieving Entry/Item Information
|
||||
|
||||
Retrieving information for specific entries or items (depending on whether you
|
||||
speak Atom or RSS) is identical to feed level data. Accessing entries is
|
||||
simply a matter of iterating over a feed object or using the SPL `Iterator`
|
||||
interface feed objects implement, and calling the appropriate method on each.
|
||||
|
||||
### Entry API Methods
|
||||
|
||||
Method | Description
|
||||
------ | -----------
|
||||
`getId()` | Returns a unique ID for the current entry.
|
||||
`getTitle()` | Returns the title of the current entry.
|
||||
`getDescription()` | Returns a description of the current entry.
|
||||
`getLink()` | Returns a URI to the HTML version of the current entry.
|
||||
`getPermaLink()` | Returns the permanent link to the current entry. In most cases, this is the same as using `getLink()`.
|
||||
`getAuthors()` | Returns an object of type `Zend\Feed\Reader\Collection\Author`, which is an `ArrayObject` whose elements are each simple arrays containing any combination of the keys "name", "email" and "uri". Where irrelevant to the source data, some of these keys may be omitted.
|
||||
`getAuthor(integer $index = 0)` | Returns either the first author known, or, with the optional `$index` parameter, any specific index on the array of Authors as described above (returning `NULL` if an invalid index).
|
||||
`getDateCreated()` | Returns the date on which the current entry was created. Generally only applicable to Atom where it represents the date the resource described by an Atom 1.0 document was created.
|
||||
`getDateModified()` | Returns the date on which the current entry was last modified.
|
||||
`getContent()` | Returns the content of the current entry (this has any entities reversed if possible, assuming the content type is HTML). The description is returned if a separate content element does not exist.
|
||||
`getEnclosure()` | Returns an array containing the value of all attributes from a multi-media `<enclosure>` element including as array keys: url, length, type. In accordance with the RSS Best Practices Profile of the RSS Advisory Board, no support is offers for multiple enclosures since such support forms no part of the RSS specification.
|
||||
`getCommentCount()` | Returns the number of comments made on this entry at the time the feed was last generated.
|
||||
`getCommentLink()` | Returns a URI pointing to the HTML page where comments can be made on this entry.
|
||||
`getCommentFeedLink([string $type = ‘atom'|'rss'])` | Returns a URI pointing to a feed of the provided type containing all comments for this entry (type defaults to Atom/RSS depending on current feed type).
|
||||
`getCategories()` | Returns a `Zend\Feed\Reader\Collection\Category` object containing the details of any categories associated with the entry. The supported fields include "term" (the machine readable category name), "scheme" (the categorisation scheme and domain for this category), and "label" (an HTML-decoded human readable category name). Where any of the three fields are absent from the field, they are either set to the closest available alternative or, in the case of "scheme", set to `NULL`.
|
||||
|
||||
The extended API for entries is identical to that for feeds with the exception
|
||||
of the `Iterator` methods, which are not needed here.
|
||||
|
||||
> ### Modified vs Created dates
|
||||
>
|
||||
> There is often confusion over the concepts of *modified* and *created* dates.
|
||||
> In Atom, these are two clearly defined concepts (so knock yourself out) but in
|
||||
> RSS they are vague. RSS 2.0 defines a single `<pubDate>` element which
|
||||
> typically refers to the date this entry was published, i.e. a creation date of
|
||||
> sorts. This is not always the case, and it may change with updates or not. As a
|
||||
> result, if you really want to check whether an entry has changed, don't rely on
|
||||
> the results of `getDateModified()`. Instead, consider tracking the MD5 hash of
|
||||
> three other elements concatenated, e.g. using `getTitle()`, `getDescription()`,
|
||||
> and `getContent()`. If the entry was truly updated, this hash computation will
|
||||
> give a different result than previously saved hashes for the same entry. This
|
||||
> is obviously content oriented, and will not assist in detecting changes to
|
||||
> other relevant elements. Atom feeds should not require such steps.
|
||||
|
||||
> Further muddying the waters, dates in feeds may follow different standards.
|
||||
> Atom and Dublin Core dates should follow ISO 8601, and RSS dates should
|
||||
> follow RFC 822 or RFC 2822 (which is also common). Date methods will throw an
|
||||
> exception if `DateTime` cannot load the date string using one of the above
|
||||
> standards, or the PHP recognised possibilities for RSS dates.
|
||||
|
||||
> ### Validation
|
||||
>
|
||||
> The values returned from these methods are not validated. This means users
|
||||
> must perform validation on all retrieved data including the filtering of any
|
||||
> HTML such as from `getContent()` before it is output from your application.
|
||||
> Remember that most feeds come from external sources, and therefore the default
|
||||
> assumption should be that they cannot be trusted.
|
||||
|
||||
### Extended Entry Level API Methods
|
||||
|
||||
Method | Description
|
||||
------ | -----------
|
||||
`getDomDocument()` | Returns the parent DOMDocument object for the entire feed (not just the current entry).
|
||||
`getElement()` | Returns the current entry level DOMElement object.
|
||||
`getXpath()` | Returns the DOMXPath object used internally to run queries on the DOMDocument object (this includes core and extension namespaces pre-registered).
|
||||
`getXpathPrefix()` | Returns the valid DOM path prefix prepended to all XPath queries matching the entry being queried.
|
||||
`getEncoding()` | Returns the encoding of the source XML document (note: this cannot account for errors such as the server sending documents in a different encoding). The default encoding applied in the absence of any other is the UTF-8 encoding of Unicode.
|
||||
`getExtensions()` | Returns an array of all extension objects loaded for the current entry (note: both feed-level and entry-level extensions exist, and only entry-level extensions are returned here). The array keys are in the form `{ExtensionName}Entry`.
|
||||
`getExtension(string $name)` | Returns an extension object for the entry registered under the provided name. This allows more fine-grained access to extensions which may otherwise be hidden within the implementation of the standard API methods.
|
||||
`getType()` | Returns a static class constant (e.g. `Zend\Feed\Reader\Reader::TYPE_ATOM_03`, i.e. "Atom 0.3") indicating exactly what kind of feed is being consumed.
|
||||
|
||||
## Extending Feed and Entry APIs
|
||||
|
||||
Extending `Zend\Feed\Reader\Reader` allows you to add methods at both the feed
|
||||
and entry level which cover the retrieval of information not already supported
|
||||
by `Zend\Feed\Reader\Reader`. Given the number of RSS and Atom extensions that
|
||||
exist, this is a good thing, since `Zend\Feed\Reader\Reader` couldn't possibly
|
||||
add everything.
|
||||
|
||||
There are two types of extensions possible, those which retrieve information
|
||||
from elements which are immediate children of the root element (e.g.
|
||||
`<channel>` for RSS or `<feed>` for Atom), and those who retrieve information
|
||||
from child elements of an entry (e.g. `<item>` for RSS or `<entry>` for Atom).
|
||||
On the filesystem, these are grouped as classes within a namespace based on the
|
||||
extension standard's name. For example, internally we have
|
||||
`Zend\Feed\Reader\Extension\DublinCore\Feed` and
|
||||
`Zend\Feed\Reader\Extension\DublinCore\Entry` classes which are two extensions
|
||||
implementing Dublin Core 1.0 and 1.1 support.
|
||||
|
||||
Extensions are loaded into `Zend\Feed\Reader\Reader` using an "extension
|
||||
manager". Extension managers must implement `Zend\Feed\Reader\ExtensionManagerInterface`.
|
||||
Three implementations exist:
|
||||
|
||||
- `Zend\Feed\Reader\StandaloneExtensionManager` is a hard-coded implementation
|
||||
seeded with all feed and entry implementations. You can extend it to add
|
||||
extensions, though it's likely easier to copy and paste it, adding your
|
||||
changes.
|
||||
- `Zend\Feed\Reader\ExtensionPluginManager` is a `Zend\ServiceManager\AbstractPluginManager`
|
||||
implementation, `Zend\Feed\Reader\ExtensionManager`; as such, you can extend
|
||||
it to add more extensions, use a `Zend\ServiceManager\ConfigInterface` instance
|
||||
to inject it with more extensions, or use its public API for adding services
|
||||
(e.g., `setService()`, `setFactory()`, etc.). This implementation *does not*
|
||||
implement `ExtensionManagerInterface`, and must be used with `ExtensionManager`.
|
||||
- `Zend\Feed\Reader\ExtensionManager` exists for legacy purposes; prior to 2.3,
|
||||
this was an `AbstractPluginManager` implementation, and the only provided
|
||||
extension manager. It now implements `ExtensionManagerInterface`, and acts as
|
||||
a decorator for `ExtensionPluginManager`.
|
||||
|
||||
By default, `Zend\Feed\Reader\Reader` composes a `StandaloneExtensionManager`. You
|
||||
can inject an alternate implementation using `Reader::setExtensionManager()`:
|
||||
|
||||
```php
|
||||
$extensions = new Zend\Feed\Reader\ExtensionPluginManager();
|
||||
Zend\Feed\Reader\Reader::setExtensionManager(
|
||||
new ExtensionManager($extensions)
|
||||
);
|
||||
```
|
||||
|
||||
The shipped implementations all provide the default extensions (so-called
|
||||
"Core Extensions") used internally by `Zend\Feed\Reader\Reader`. These
|
||||
include:
|
||||
|
||||
Extension | Description
|
||||
--------- | -----------
|
||||
DublinCore (Feed and Entry) | Implements support for Dublin Core Metadata Element Set 1.0 and 1.1.
|
||||
Content (Entry only) | Implements support for Content 1.0.
|
||||
Atom (Feed and Entry) | Implements support for Atom 0.3 and Atom 1.0.
|
||||
Slash | Implements support for the Slash RSS 1.0 module.
|
||||
WellFormedWeb | Implements support for the Well Formed Web CommentAPI 1.0.
|
||||
Thread | Implements support for Atom Threading Extensions as described in RFC 4685.
|
||||
Podcast | Implements support for the Podcast 1.0 DTD from Apple.
|
||||
|
||||
The core extensions are somewhat special since they are extremely common and
|
||||
multi-faceted. For example, we have a core extension for Atom. Atom is
|
||||
implemented as an extension (not just a base class) because it doubles as a
|
||||
valid RSS module; you can insert Atom elements into RSS feeds. I've even seen
|
||||
RDF feeds which use a lot of Atom in place of more common extensions like
|
||||
Dublin Core.
|
||||
|
||||
The following is a list of non-Core extensions that are offered, but not registered
|
||||
by default. If you want to use them, you'll need to
|
||||
tell `Zend\Feed\Reader\Reader` to load them in advance of importing a feed.
|
||||
Additional non-Core extensions will be included in future iterations of the
|
||||
component.
|
||||
|
||||
Extension | Description
|
||||
--------- | -----------
|
||||
Syndication | Implements Syndication 1.0 support for RSS feeds.
|
||||
CreativeCommons | An RSS module that adds an element at the `<channel>` or `<item>` level that specifies which Creative Commons license applies.
|
||||
|
||||
`Zend\Feed\Reader\Reader` requires you to explicitly register non-Core
|
||||
extensions in order to expose their API to feed and entry objects. Below, we
|
||||
register the optional Syndication extension, and discover that it can be
|
||||
directly called from the entry API without any effort. (Note that
|
||||
extension names are case sensitive and use camelCasing for multiple terms.)
|
||||
|
||||
```php
|
||||
use Zend\Feed\Reader\Reader;
|
||||
|
||||
Reader::registerExtension('Syndication');
|
||||
$feed = Reader::import('http://rss.slashdot.org/Slashdot/slashdot');
|
||||
$updatePeriod = $feed->getUpdatePeriod();
|
||||
```
|
||||
|
||||
In the simple example above, we checked how frequently a feed is being updated
|
||||
using the `getUpdatePeriod()` method. Since it's not part of
|
||||
`Zend\Feed\Reader\Reader`'s core API, it could only be a method supported by
|
||||
the newly registered Syndication extension.
|
||||
|
||||
As you can also notice, methods provided by extensions are accessible from the
|
||||
main API using method overloading. As an alternative, you can also directly
|
||||
access any extension object for a similar result as seen below.
|
||||
|
||||
```php
|
||||
use Zend\Feed\Reader\Reader;
|
||||
|
||||
Reader::registerExtension('Syndication');
|
||||
$feed = Reader::import('http://rss.slashdot.org/Slashdot/slashdot');
|
||||
$syndication = $feed->getExtension('Syndication');
|
||||
$updatePeriod = $syndication->getUpdatePeriod();
|
||||
```
|
||||
|
||||
### Writing Zend\\Feed\\Reader Extensions
|
||||
|
||||
Inevitably, there will be times when the `Zend\Feed\Reader` API is just
|
||||
not capable of getting something you need from a feed or entry. You can use the
|
||||
underlying source objects, like DOMDocument, to get these by hand; however, there
|
||||
is a more reusable method available: you can write extensions supporting these new
|
||||
queries.
|
||||
|
||||
As an example, let's take the case of a purely fictitious corporation named
|
||||
Jungle Books. Jungle Books have been publishing a lot of reviews on books they
|
||||
sell (from external sources and customers), which are distributed as an RSS 2.0
|
||||
feed. Their marketing department realises that web applications using this feed
|
||||
cannot currently figure out exactly what book is being reviewed. To make life
|
||||
easier for everyone, they determine that the geek department needs to extend
|
||||
RSS 2.0 to include a new element per entry supplying the ISBN-10 or ISBN-13
|
||||
number of the publication the entry concerns. They define the new `<isbn>`
|
||||
element quite simply with a standard name and namespace URI:
|
||||
|
||||
- Name: JungleBooks 1.0
|
||||
- Namespace URI: http://example.com/junglebooks/rss/module/1.0/
|
||||
|
||||
A snippet of RSS containing this extension in practice could be something
|
||||
similar to:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<rss version="2.0"
|
||||
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
||||
xmlns:jungle="http://example.com/junglebooks/rss/module/1.0/">
|
||||
<channel>
|
||||
<title>Jungle Books Customer Reviews</title>
|
||||
<link>http://example.com/junglebooks</link>
|
||||
<description>Many book reviews!</description>
|
||||
<pubDate>Fri, 26 Jun 2009 19:15:10 GMT</pubDate>
|
||||
<jungle:dayPopular>
|
||||
http://example.com/junglebooks/book/938
|
||||
</jungle:dayPopular>
|
||||
<item>
|
||||
<title>Review Of Flatland: A Romance of Many Dimensions</title>
|
||||
<link>http://example.com/junglebooks/review/987</link>
|
||||
<author>Confused Physics Student</author>
|
||||
<content:encoded>
|
||||
A romantic square?!
|
||||
</content:encoded>
|
||||
<pubDate>Thu, 25 Jun 2009 20:03:28 -0700</pubDate>
|
||||
<jungle:isbn>048627263X</jungle:isbn>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
```
|
||||
|
||||
Implementing this new ISBN element as a simple entry level extension would
|
||||
require the following class (using your own namespace).
|
||||
|
||||
```php
|
||||
namespace My\FeedReader\Extension\JungleBooks;
|
||||
|
||||
use Zend\Feed\Reader\Extension\AbstractEntry;
|
||||
|
||||
class Entry extends AbstractEntry
|
||||
{
|
||||
public function getIsbn()
|
||||
{
|
||||
if (isset($this->data['isbn'])) {
|
||||
return $this->data['isbn'];
|
||||
}
|
||||
|
||||
$isbn = $this->xpath->evaluate(
|
||||
'string(' . $this->getXpathPrefix() . '/jungle:isbn)'
|
||||
);
|
||||
|
||||
if (! $isbn) {
|
||||
$isbn = null;
|
||||
}
|
||||
|
||||
$this->data['isbn'] = $isbn;
|
||||
return $this->data['isbn'];
|
||||
}
|
||||
|
||||
protected function registerNamespaces()
|
||||
{
|
||||
$this->xpath->registerNamespace(
|
||||
'jungle',
|
||||
'http://example.com/junglebooks/rss/module/1.0/'
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This extension creates a new method `getIsbn()`, which runs an XPath query on
|
||||
the current entry to extract the ISBN number enclosed by the `<jungle:isbn>`
|
||||
element. It can optionally store this to the internal non-persistent cache (no
|
||||
need to keep querying the DOM if it's called again on the same entry). The
|
||||
value is returned to the caller. At the end we have a protected method (it's
|
||||
abstract, making it required by implementations) which registers the Jungle
|
||||
Books namespace for their custom RSS module. While we call this an RSS module,
|
||||
there's nothing to prevent the same element being used in Atom feeds; all
|
||||
extensions which use the prefix provided by `getXpathPrefix()` are actually
|
||||
neutral and work on RSS or Atom feeds with no extra code.
|
||||
|
||||
Since this extension is stored outside of zend-feed, you'll need to ensure your
|
||||
application can autoload it. Once that's in place, you will also need to ensure
|
||||
your extension manager knows about it, and then register the extension with
|
||||
`Zend\Feed\Reader\Reader`.
|
||||
|
||||
The following example uses `Zend\Feed\Reader\ExtensionPluginManager` to manage
|
||||
extensions, as it provides the ability to register new extensions without
|
||||
requiring extension of the plugin manager itself. To use it, first intall
|
||||
zend-servicemanager:
|
||||
|
||||
```bash
|
||||
$ composer require zendframework/zend-servicemanager
|
||||
```
|
||||
|
||||
From there:
|
||||
|
||||
```php
|
||||
use My\FeedReader\Extension\JungleBooks;
|
||||
use Zend\Feed\Reader\ExtensionManager;
|
||||
use Zend\Feed\Reader\ExtensionPluginManager;
|
||||
use Zend\Feed\Reader\Reader;
|
||||
|
||||
$extensions = new ExtensionPluginManager();
|
||||
$extensions->setInvokableClass('JungleBooks\Entry', JungleBooks\Entry::class);
|
||||
Reader::setExtensionManager(new ExtensionManager($extensions));
|
||||
Reader::registerExtension('JungleBooks');
|
||||
|
||||
$feed = Reader::import('http://example.com/junglebooks/rss');
|
||||
|
||||
// ISBN for whatever book the first entry in the feed was concerned with
|
||||
$firstIsbn = $feed->current()->getIsbn();
|
||||
```
|
||||
|
||||
Writing a feed extension is not much different. The example feed from earlier
|
||||
included an unmentioned `<jungle:dayPopular>` element which Jungle Books have
|
||||
added to their standard to include a link to the day's most popular book (in
|
||||
terms of visitor traffic). Here's an extension which adds a
|
||||
`getDaysPopularBookLink()` method to the feel level API.
|
||||
|
||||
```php
|
||||
namespace My\FeedReader\Extension\JungleBooks;
|
||||
|
||||
use Zend\Feed\Reader\Extension\AbstractFeed;
|
||||
|
||||
class Feed extends AbstractFeed
|
||||
{
|
||||
public function getDaysPopularBookLink()
|
||||
{
|
||||
if (isset($this->data['dayPopular'])) {
|
||||
return $this->data['dayPopular'];
|
||||
}
|
||||
|
||||
$dayPopular = $this->xpath->evaluate(
|
||||
'string(' . $this->getXpathPrefix() . '/jungle:dayPopular)'
|
||||
);
|
||||
|
||||
if (!$dayPopular) {
|
||||
$dayPopular = null;
|
||||
}
|
||||
|
||||
$this->data['dayPopular'] = $dayPopular;
|
||||
return $this->data['dayPopular'];
|
||||
}
|
||||
|
||||
protected function registerNamespaces()
|
||||
{
|
||||
$this->xpath->registerNamespace(
|
||||
'jungle',
|
||||
'http://example.com/junglebooks/rss/module/1.0/'
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Let's add to the previous example; we'll register the new class with the
|
||||
extension manager, and then demonstrate using the newly exposed method:
|
||||
|
||||
```php
|
||||
use My\FeedReader\Extension\JungleBooks;
|
||||
use Zend\Feed\Reader\ExtensionManager;
|
||||
use Zend\Feed\Reader\ExtensionPluginManager;
|
||||
use Zend\Feed\Reader\Reader;
|
||||
|
||||
$extensions = new ExtensionPluginManager();
|
||||
$extensions->setInvokableClass('JungleBooks\Entry', JungleBooks\Entry::class);
|
||||
$extensions->setInvokableClass('JungleBooks\Feed', JungleBooks\Feed::class);
|
||||
Reader::setExtensionManager(new ExtensionManager($extensions));
|
||||
Reader::registerExtension('JungleBooks');
|
||||
|
||||
$feed = Reader::import('http://example.com/junglebooks/rss');
|
||||
|
||||
// URI to the information page of the day's most popular book with visitors
|
||||
$daysPopularBookLink = $feed->getDaysPopularBookLink();
|
||||
```
|
||||
|
||||
Going through these examples, you'll note that while we need to register the
|
||||
feed and entry classes separately with the plugin manager, we don't register
|
||||
them separately when registering the extension with the `Reader`. Extensions
|
||||
within the same standard may or may not include both a feed and entry class, so
|
||||
`Zend\Feed\Reader\Reader` only requires you to register the overall parent name,
|
||||
e.g. JungleBooks, DublinCore, Slash. Internally, it can check at what level
|
||||
extensions exist and load them up if found. In our case, we have a complete
|
||||
extension now, spanning the classes `JungleBooks\Feed` and `JungleBooks\Entry`.
|
161
web/vendor/zendframework/zend-feed/doc/book/security.md
vendored
Normal file
161
web/vendor/zendframework/zend-feed/doc/book/security.md
vendored
Normal file
|
@ -0,0 +1,161 @@
|
|||
# Zend\\Feed\\Reader and Security
|
||||
|
||||
As with any data coming from a source that is beyond the developer's control,
|
||||
special attention needs to be given to securing, validating and filtering that
|
||||
data. Similar to data input to our application by users, data coming from RSS
|
||||
and Atom feeds should also be considered unsafe and potentially dangerous, as it
|
||||
allows the delivery of HTML and [xHTML](http://tools.ietf.org/html/rfc4287#section-8.1).
|
||||
Because data validation and filtration is out of `Zend\Feed`'s scope, this task
|
||||
is left for implementation by the developer, by using libraries such as
|
||||
zend-escaper for escaping and [HTMLPurifier](http://www.htmlpurifier.org/) for
|
||||
validating and filtering feed data.
|
||||
|
||||
Escaping and filtering of potentially insecure data is highly recommended before
|
||||
outputting it anywhere in our application or before storing that data in some
|
||||
storage engine (be it a simple file or a database.).
|
||||
|
||||
## Filtering data using HTMLPurifier
|
||||
|
||||
Currently, the best available library for filtering and validating (x)HTML data
|
||||
in PHP is [HTMLPurifier](http://www.htmlpurifier.org/), and, as such, is the
|
||||
recommended tool for this task. HTMLPurifier works by filtering out all (x)HTML
|
||||
from the data, except for the tags and attributes specifically allowed in a
|
||||
whitelist, and by checking and fixing nesting of tags, ensuring
|
||||
standards-compliant output.
|
||||
|
||||
The following examples will show a basic usage of HTMLPurifier, but developers
|
||||
are urged to go through and read [HTMLPurifier's documentation](http://www.htmlpurifier.org/docs).
|
||||
|
||||
```php
|
||||
// Setting HTMLPurifier's options
|
||||
$options = [
|
||||
// Allow only paragraph tags
|
||||
// and anchor tags wit the href attribute
|
||||
[
|
||||
'HTML.Allowed',
|
||||
'p,a[href]'
|
||||
],
|
||||
// Format end output with Tidy
|
||||
[
|
||||
'Output.TidyFormat',
|
||||
true
|
||||
],
|
||||
// Assume XHTML 1.0 Strict Doctype
|
||||
[
|
||||
'HTML.Doctype',
|
||||
'XHTML 1.0 Strict'
|
||||
],
|
||||
// Disable cache, but see note after the example
|
||||
[
|
||||
'Cache.DefinitionImpl',
|
||||
null
|
||||
]
|
||||
];
|
||||
|
||||
// Configuring HTMLPurifier
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
foreach ($options as $option) {
|
||||
$config->set($option[0], $option[1]);
|
||||
}
|
||||
|
||||
// Creating a HTMLPurifier with it's config
|
||||
$purifier = new HTMLPurifier($config);
|
||||
|
||||
// Fetch the RSS
|
||||
try {
|
||||
$rss = Zend\Feed\Reader\Reader::import('http://www.planet-php.net/rss/');
|
||||
} catch (Zend\Feed\Exception\Reader\RuntimeException $e) {
|
||||
// feed import failed
|
||||
echo "Exception caught importing feed: {$e->getMessage()}\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Initialize the channel data array
|
||||
// See that we're cleaning the description with HTMLPurifier
|
||||
$channel = [
|
||||
'title' => $rss->getTitle(),
|
||||
'link' => $rss->getLink(),
|
||||
'description' => $purifier->purify($rss->getDescription()),
|
||||
'items' => [],
|
||||
];
|
||||
|
||||
// Loop over each channel item and store relevant data
|
||||
// See that we're cleaning the descriptions with HTMLPurifier
|
||||
foreach ($rss as $item) {
|
||||
$channel['items'][] = [
|
||||
'title' => $item->getTitle(),
|
||||
'link' => $item->getLink(),
|
||||
'description' => $purifier->purify($item->getDescription()),
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
> ### Tidy is required
|
||||
>
|
||||
> HTMLPurifier is using the PHP [Tidy extension](http://php.net/tidy) to clean
|
||||
> and repair the final output. If this extension is not available, it will
|
||||
> silently fail, but its availability has no impact on the library's security.
|
||||
|
||||
> ### Caching
|
||||
>
|
||||
> For the sake of this example, the HTMLPurifier's cache is disabled, but it is
|
||||
> recommended to configure caching and use its standalone include file as it can
|
||||
> improve the performance of HTMLPurifier substantially.
|
||||
|
||||
## Escaping data using zend-escaper
|
||||
|
||||
To help prevent XSS attacks, Zend Framework provides the [zend-escaper component](https://github.com/zendframework/zend-escaper),
|
||||
which complies to the current [OWASP recommendations](https://www.owasp.org/index.php/XSS_Prevention_Cheat_Sheet),
|
||||
and as such, is the recommended tool for escaping HTML tags and attributes,
|
||||
Javascript, CSS and URLs before outputing any potentially insecure data to the
|
||||
users.
|
||||
|
||||
```php
|
||||
try {
|
||||
$rss = Zend\Feed\Reader\Reader::import('http://www.planet-php.net/rss/');
|
||||
} catch (Zend\Feed\Exception\Reader\RuntimeException $e) {
|
||||
// feed import failed
|
||||
echo "Exception caught importing feed: {$e->getMessage()}\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Validate all URIs
|
||||
$linkValidator = new Zend\Validator\Uri;
|
||||
$link = null;
|
||||
if ($linkValidator->isValid($rss->getLink())) {
|
||||
$link = $rss->getLink();
|
||||
}
|
||||
|
||||
// Escaper used for escaping data
|
||||
$escaper = new Zend\Escaper\Escaper('utf-8');
|
||||
|
||||
// Initialize the channel data array
|
||||
$channel = [
|
||||
'title' => $escaper->escapeHtml($rss->getTitle()),
|
||||
'link' => $escaper->escapeUrl($link),
|
||||
'description' => $escaper->escapeHtml($rss->getDescription()),
|
||||
'items' => [],
|
||||
];
|
||||
|
||||
// Loop over each channel item and store relevant data
|
||||
foreach ($rss as $item) {
|
||||
$link = null;
|
||||
if ($linkValidator->isValid($rss->getLink())) {
|
||||
$link = $item->getLink();
|
||||
}
|
||||
$channel['items'][] = [
|
||||
'title' => $escaper->escapeHtml($item->getTitle()),
|
||||
'link' => $escaper->escapeUrl($link),
|
||||
'description' => $escaper->escapeHtml($item->getDescription()),
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
The feed data is now safe for output to HTML templates. You can, of course, skip
|
||||
escaping when simply storing the data persistently, but remember to escape it on
|
||||
output later!
|
||||
|
||||
Of course, these are just basic examples, and cannot cover all possible
|
||||
scenarios that you, as a developer, can, and most likely will, encounter. Your
|
||||
responsibility is to learn what libraries and tools are at your disposal, and
|
||||
when and how to use them to secure your web applications.
|
280
web/vendor/zendframework/zend-feed/doc/book/writer.md
vendored
Normal file
280
web/vendor/zendframework/zend-feed/doc/book/writer.md
vendored
Normal file
|
@ -0,0 +1,280 @@
|
|||
# Zend\\Feed\\Writer
|
||||
|
||||
`Zend\Feed\Writer` is the sibling component to `Zend\Feed\Reader` responsible
|
||||
for *generating* feeds. It supports the Atom 1.0 specification (RFC 4287) and
|
||||
RSS 2.0 as specified by the RSS Advisory Board (RSS 2.0.11). It does not deviate
|
||||
from these standards. It does, however, offer a simple extension system which
|
||||
allows for any extension and module for either of these two specifications to be
|
||||
implemented if they are not provided out of the box.
|
||||
|
||||
In many ways, `Zend\Feed\Writer` is the inverse of `Zend\Feed\Reader`. Where
|
||||
`Zend\Reader\Reader` focuses on providing an easy to use architecture fronted by
|
||||
getter methods, `Zend\Feed\Writer` is fronted by similarly named setters or
|
||||
mutators. This ensures the API won't pose a learning curve to anyone familiar
|
||||
with `Zend\Feed\Reader`.
|
||||
|
||||
As a result of this design, the rest may even be obvious. Behind the scenes,
|
||||
data set on any `Zend\Feed\Writer\Writer` instance is translated at render time
|
||||
onto a DOMDocument object using the necessary feed elements. For each supported
|
||||
feed type there is both an Atom 1.0 and RSS 2.0 renderer. Using a DOMDocument
|
||||
class rather than a templating solution has numerous advantages, the most
|
||||
obvious being the ability to export the DOMDocument for additional processing
|
||||
and relying on PHP DOM for correct and valid rendering.
|
||||
|
||||
## Architecture
|
||||
|
||||
The architecture of `Zend\Feed\Writer` is very simple. It has two core sets of
|
||||
classes: data containers and renderers.
|
||||
|
||||
The containers include the `Zend\Feed\Writer\Feed` and `Zend\Feed\Writer\Entry`
|
||||
classes. The Entry classes can be attached to any Feed class. The sole purpose
|
||||
of these containers is to collect data about the feed to generate using a simple
|
||||
interface of setter methods. These methods perform some data validity testing.
|
||||
For example, it will validate any passed URIs, dates, etc. These checks are not
|
||||
tied to any of the feed standards definitions. The container objects also
|
||||
contain methods to allow for fast rendering and export of the final feed, and
|
||||
these can be reused at will.
|
||||
|
||||
In addition to the main data container classes, there are two additional Atom
|
||||
2.0-specific classes: `Zend\Feed\Writer\Source` and `Zend\Feed\Writer\Deleted`.
|
||||
The former implements Atom 2.0 source elements which carry source feed metadata
|
||||
for a specific entry within an aggregate feed (i.e. the current feed is not the
|
||||
entry's original source). The latter implements the [Atom Tombstones RFC](https://tools.ietf.org/html/rfc6721),
|
||||
allowing feeds to carry references to entries which have been deleted.
|
||||
|
||||
While there are two main data container types, there are four renderers: two
|
||||
matching container renderers per supported feed type. Each renderer accepts a
|
||||
container, and, based on its content, attempts to generate valid feed markup. If
|
||||
the renderer is unable to generate valid feed markup (perhaps due to the
|
||||
container missing an obligatory data point), it will report this by throwing an
|
||||
exception. While it is possible to ignore exceptions, this removes the default
|
||||
safeguard of ensuring you have sufficient data set to render a wholly valid
|
||||
feed.
|
||||
|
||||
To explain this more clearly: you may construct a set of data containers for a
|
||||
feed where there is a Feed container, into which has been added some Entry
|
||||
containers and a Deleted container. This forms a data hierarchy resembling a
|
||||
normal feed. When rendering is performed, this hierarchy has its pieces passed
|
||||
to relevant renderers, and the partial feeds (all DOMDocuments) are then pieced
|
||||
together to create a complete feed. In the case of Source or Deleted (Tombstone)
|
||||
containers, these are rendered only for Atom 2.0 and ignored for RSS.
|
||||
|
||||
Due to the system being divided between data containers and renderers,
|
||||
extensions have more mandatory requirements than their equivalents in the
|
||||
`Zend\Feed\Reader` subcomponent. A typical extension offering namespaced feed
|
||||
and entry level elements must itself reflect the exact same architecture: i.e.
|
||||
it must offer both feed and entry level data containers, and matching renderers.
|
||||
There is, fortunately, no complex integration work required since all extension
|
||||
classes are simply registered and automatically used by the core classes. We
|
||||
cover extensions in more detail at the end of this chapter.
|
||||
|
||||
## Getting Started
|
||||
|
||||
To use `Zend\Feed\Writer\Writer`, you will provide it with data, and then
|
||||
trigger the renderer. What follows is an example demonstrating generation of a
|
||||
minimal Atom 1.0 feed. Each feed or entry uses a separate data container.
|
||||
|
||||
```php
|
||||
use Zend\Feed\Writer\Feed;
|
||||
|
||||
/**
|
||||
* Create the parent feed
|
||||
*/
|
||||
$feed = new Feed;
|
||||
$feed->setTitle("Paddy's Blog");
|
||||
$feed->setLink('http://www.example.com');
|
||||
$feed->setFeedLink('http://www.example.com/atom', 'atom');
|
||||
$feed->addAuthor([
|
||||
'name' => 'Paddy',
|
||||
'email' => 'paddy@example.com',
|
||||
'uri' => 'http://www.example.com',
|
||||
]);
|
||||
$feed->setDateModified(time());
|
||||
$feed->addHub('http://pubsubhubbub.appspot.com/');
|
||||
|
||||
/**
|
||||
* Add one or more entries. Note that entries must
|
||||
* be manually added once created.
|
||||
*/
|
||||
$entry = $feed->createEntry();
|
||||
$entry->setTitle('All Your Base Are Belong To Us');
|
||||
$entry->setLink('http://www.example.com/all-your-base-are-belong-to-us');
|
||||
$entry->addAuthor([
|
||||
'name' => 'Paddy',
|
||||
'email' => 'paddy@example.com',
|
||||
'uri' => 'http://www.example.com',
|
||||
]);
|
||||
$entry->setDateModified(time());
|
||||
$entry->setDateCreated(time());
|
||||
$entry->setDescription('Exposing the difficulty of porting games to English.');
|
||||
$entry->setContent(
|
||||
'I am not writing the article. The example is long enough as is ;).'
|
||||
);
|
||||
$feed->addEntry($entry);
|
||||
|
||||
/**
|
||||
* Render the resulting feed to Atom 1.0 and assign to $out.
|
||||
* You can substitute "atom" with "rss" to generate an RSS 2.0 feed.
|
||||
*/
|
||||
$out = $feed->export('atom');
|
||||
```
|
||||
|
||||
The output rendered should be as follows:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<title type="text">Paddy's Blog</title>
|
||||
<subtitle type="text">Writing about PC Games since 176 BC.</subtitle>
|
||||
<updated>2009-12-14T20:28:18+00:00</updated>
|
||||
<generator uri="http://framework.zend.com" version="1.10.0alpha">
|
||||
Zend\Feed\Writer
|
||||
</generator>
|
||||
<link rel="alternate" type="text/html" href="http://www.example.com"/>
|
||||
<link rel="self" type="application/atom+xml"
|
||||
href="http://www.example.com/atom"/>
|
||||
<id>http://www.example.com</id>
|
||||
<author>
|
||||
<name>Paddy</name>
|
||||
<email>paddy@example.com</email>
|
||||
<uri>http://www.example.com</uri>
|
||||
</author>
|
||||
<link rel="hub" href="http://pubsubhubbub.appspot.com/"/>
|
||||
<entry>
|
||||
<title type="html"><![CDATA[All Your Base Are Belong To
|
||||
Us]]></title>
|
||||
<summary type="html">
|
||||
<![CDATA[Exposing the difficultly of porting games to
|
||||
English.]]>
|
||||
</summary>
|
||||
<published>2009-12-14T20:28:18+00:00</published>
|
||||
<updated>2009-12-14T20:28:18+00:00</updated>
|
||||
<link rel="alternate" type="text/html"
|
||||
href="http://www.example.com/all-your-base-are-belong-to-us"/>
|
||||
<id>http://www.example.com/all-your-base-are-belong-to-us</id>
|
||||
<author>
|
||||
<name>Paddy</name>
|
||||
<email>paddy@example.com</email>
|
||||
<uri>http://www.example.com</uri>
|
||||
</author>
|
||||
<content type="html">
|
||||
<![CDATA[I am not writing the article.
|
||||
The example is long enough as is ;).]]>
|
||||
</content>
|
||||
</entry>
|
||||
</feed>
|
||||
```
|
||||
|
||||
This is a perfectly valid Atom 1.0 example. It should be noted that omitting an
|
||||
obligatory point of data, such as a title, will trigger an exception when
|
||||
rendering as Atom 1.0. This will differ for RSS 2.0, since a title may be
|
||||
omitted so long as a description is present. This gives rise to exceptions that
|
||||
differ between the two standards depending on the renderer in use. By design,
|
||||
`Zend\Feed\Writer` will not render an invalid feed for either standard
|
||||
unless the end-user deliberately elects to ignore all exceptions. This built in
|
||||
safeguard was added to ensure users without in-depth knowledge of the relevant
|
||||
specifications have a bit less to worry about.
|
||||
|
||||
## Setting Feed Data Points
|
||||
|
||||
Before you can render a feed, you must first setup the data necessary for the
|
||||
feed being rendered. This utilises a simple setter style API, which doubles as
|
||||
a method for validating the data being set. By design, the API closely matches
|
||||
that for `Zend\Feed\Reader` to avoid undue confusion and uncertainty.
|
||||
|
||||
`Zend\Feed\Writer` offers this API via its data container classes
|
||||
`Zend\Feed\Writer\Feed` and `Zend\Feed\Writer\Entry` (not to mention the Atom
|
||||
2.0 specific and extension classes). These classes merely store all feed data in
|
||||
a type-agnostic manner, meaning you may reuse any data container with any
|
||||
renderer without requiring additional work. Both classes are also amenable to
|
||||
extensions, meaning that an extension may define its own container classes which
|
||||
are registered to the base container classes as extensions, and are checked when
|
||||
any method call triggers the base container's `__call()` method, allowing method
|
||||
overloading to the extension classes.
|
||||
|
||||
Here's a summary of the Core API for Feeds. You should note it comprises not
|
||||
only the basic RSS and Atom standards, but also accounts for a number of
|
||||
included extensions bundled with `Zend\Feed\Writer`. The naming of these
|
||||
extension sourced methods remain fairly generic; all extension methods operate
|
||||
at the same level as the Core API, though we do allow you to retrieve any
|
||||
specific extension object separately if required.
|
||||
|
||||
The Feed API for data is contained in `Zend\Feed\Writer\Feed`. In addition to the API
|
||||
detailed below, the class also implements the `Countable` and `Iterator` interfaces.
|
||||
|
||||
### Feed API Methods
|
||||
|
||||
Method | Description
|
||||
------ | -----------
|
||||
`setId()` | Set a unique identifier associated with this feed. For Atom 1.0 this is an `atom:id` element, whereas for RSS 2.0 it is added as a `guid` element. These are optional so long as a link is added; i.e. if no identifier is provided, the link is used.
|
||||
`setTitle()` | Set the title of the feed.
|
||||
`setDescription()` | Set the text description of the feed.
|
||||
`setLink()` | Set a URI to the HTML website containing the same or similar information as this feed (i.e. if the feed is from a blog, it should provide the blog's URI where the HTML version of the entries can be read).
|
||||
`setFeedLinks()` | Add a link to an XML feed, whether it is to the feed being generated, or an alternate URI pointing to the same feed but in a different format. At a minimum, it is recommended to include a link to the feed being generated so it has an identifiable final URI allowing a client to track its location changes without necessitating constant redirects. The parameter is an array of arrays, where each sub-array contains the keys "type" and "uri". The type should be one of "atom", "rss", or "rdf".
|
||||
`addAuthors()` | Sets the data for authors. The parameter is an array of array,s where each sub-array may contain the keys "name", "email", and "uri". The "uri" value is only applicable for Atom feeds, since RSS contains no facility to show it. For RSS 2.0, rendering will create two elements: an author element containing the email reference with the name in brackets, and a Dublin Core creator element only containing the name.
|
||||
`addAuthor()` | Sets the data for a single author following the same array format as described above for a single sub-array.
|
||||
`setDateCreated()` | Sets the date on which this feed was created. Generally only applicable to Atom, where it represents the date the resource described by an Atom 1.0 document was created. The expected parameter may be a UNIX timestamp or a `DateTime` object.
|
||||
`setDateModified()` | Sets the date on which this feed was last modified. The expected parameter may be a UNIX timestamp or a `DateTime` object.
|
||||
`setLastBuildDate()` | Sets the date on which this feed was last build. The expected parameter may be a UNIX timestamp or a `DateTime` object. This will only be rendered for RSS 2.0 feeds, and is automatically rendered as the current date by default when not explicitly set.
|
||||
`setLanguage()` | Sets the language of the feed. This will be omitted unless set.
|
||||
`setGenerator()` | Allows the setting of a generator. The parameter should be an array containing the keys "name", "version", and "uri". If omitted a default generator will be added referencing `Zend\Feed\Writer`, the current zend-version version, and the Framework's URI.
|
||||
`setCopyright()` | Sets a copyright notice associated with the feed.
|
||||
`addHubs()` | Accepts an array of Pubsubhubbub Hub Endpoints to be rendered in the feed as Atom links so that PuSH Subscribers may subscribe to your feed. Note that you must implement a Pubsubhubbub Publisher in order for real-time updates to be enabled. A Publisher may be implemented using `Zend\Feed\Pubsubhubbub\Publisher`. The method `addHub()` allows adding a single hub at a time.
|
||||
`addCategories()` | Accepts an array of categories for rendering, where each element is itself an array whose possible keys include "term", "label", and "scheme". The "term" is a typically a category name suitable for inclusion in a URI. The "label" may be a human readable category name supporting special characters (it is HTML encoded during rendering) and is a required key. The "scheme" (called the domain in RSS) is optional, but must be a valid URI. The method `addCategory()` allows adding a single category at a time.
|
||||
`setImage()` | Accepts an array of image metadata for an RSS image or Atom logo. Atom 1.0 only requires a URI. RSS 2.0 requires a URI, HTML link, and an image title. RSS 2.0 optionally may send a width, height, and image description. To provide these, use an array argument with the following keys: "uri", "link", "title", "description", "height", and "width". The RSS 2.0 HTML link should point to the feed source's HTML page.
|
||||
`createEntry()` | Returns a new instance of `Zend\Feed\Writer\Entry`. This is the Entry data container. New entries are not automatically assigned to the current feed, so you must explicitly call `addEntry()` to add the entry for rendering.
|
||||
`addEntry()` | Adds an instance of `Zend\Feed\Writer\Entry` to the current feed container for rendering.
|
||||
`createTombstone()` | Returns a new instance of `Zend\Feed\Writer\Deleted`. This is the Atom 2.0 Tombstone data container. New entries are not automatically assigned to the current feed, so you must explicitly call `addTombstone()` to add the deleted entry for rendering.
|
||||
`addTombstone()` | Adds an instance of `Zend\Feed\Writer\Deleted` to the current feed container for rendering.
|
||||
`removeEntry()` | Accepts a parameter indicating an array index of the entry to remove from the feed.
|
||||
`export()` | Exports the entire data hierarchy to an XML feed. The method has two parameters. The first is the feed type, one of "atom" or "rss". The second is an optional boolean to set indicating whether or not Exceptions are thrown. The default is `TRUE`.
|
||||
|
||||
> #### Retrieval methods
|
||||
>
|
||||
> In addition to the setters listed above, `Feed` instances also provide
|
||||
> matching getters to retrieve data from the `Feed` data container. For
|
||||
> example, `setImage()` is matched with a `getImage()` method.
|
||||
|
||||
## Setting Entry Data Points
|
||||
|
||||
Below is a summary of the Core API for entries and items. You should note that
|
||||
it covers not only the basic RSS and Atom standards, but also a number of
|
||||
included extensions bundled with `Zend\Feed\Writer`. The naming of these
|
||||
extension sourced methods remain fairly generic; all extension methods operate
|
||||
at the same level as the Core API, though we do allow you to retrieve any
|
||||
specific extension object separately if required.
|
||||
|
||||
The Entry *API* for data is contained in `Zend\Feed\Writer\Entry`.
|
||||
|
||||
### Entry API Methods
|
||||
|
||||
Method | Description
|
||||
------ | -----------
|
||||
`setId()` | Set a unique identifier associated with this entry. For Atom 1.0 this is an `atom:id` element, whereas for RSS 2.0 it is added as a `guid` element. These are optional so long as a link is added; i.e. if no identifier is provided, the link is used.
|
||||
`setTitle()` | Set the title of the entry.
|
||||
`setDescription()` | Set the text description of the entry.
|
||||
`setContent()` | Set the content of the entry.
|
||||
`setLink()` | Set a URI to the HTML website containing the same or similar information as this entry (i.e. if the feed is from a blog, it should provide the blog article's URI where the HTML version of the entry can be read).
|
||||
`setFeedLinks()` | Add a link to an XML feed, whether it is to the feed being generated, or an alternate URI pointing to the same feed but in a different format. At a minimum, it is recommended to include a link to the feed being generated so it has an identifiable final URI allowing a client to track its location changes without necessitating constant redirects. The parameter is an array of arrays, where each sub-array contains the keys "type" and "uri". The type should be one of "atom", "rss", or "rdf". If a type is omitted, it defaults to the type used when rendering the feed.
|
||||
`addAuthors()` | Sets the data for authors. The parameter is an array of array,s where each sub-array may contain the keys "name", "email", and "uri". The "uri" value is only applicable for Atom feeds, since RSS contains no facility to show it. For RSS 2.0, rendering will create two elements: an author element containing the email reference with the name in brackets, and a Dublin Core creator element only containing the name.
|
||||
`addAuthor()` | Sets the data for a single author following the same format as described above for a single sub-array.
|
||||
`setDateCreated()` | Sets the date on which this entry was created. Generally only applicable to Atom where it represents the date the resource described by an Atom 1.0 document was created. The expected parameter may be a UNIX timestamp or a `DateTime` object. If omitted, the date used will be the current date and time.
|
||||
`setDateModified()` | Sets the date on which this entry was last modified. The expected parameter may be a UNIX timestamp or a `DateTime` object. If omitted, the date used will be the current date and time.
|
||||
`setCopyright()` | Sets a copyright notice associated with the entry.
|
||||
`addCategories()` | Accepts an array of categories for rendering, where each element is itself an array whose possible keys include "term", "label", and "scheme". The "term" is a typically a category name suitable for inclusion in a URI. The "label" may be a human readable category name supporting special characters (it is encoded during rendering) and is a required key. The "scheme" (called the domain in RSS) is optional but must be a valid URI.
|
||||
`addCategory()` | Sets the data for a single category following the same format as described above for a single sub-array.
|
||||
`setCommentCount()` | Sets the number of comments associated with this entry. Rendering differs between RSS and Atom 2.0 depending on the element or attribute needed.
|
||||
`setCommentLink()` | Sets a link to an HTML page containing comments associated with this entry.
|
||||
`setCommentFeedLink()` | Sets a link to an XML feed containing comments associated with this entry. The parameter is an array containing the keys "uri" and "type", where the type is one of "rdf", "rss", or "atom".
|
||||
`setCommentFeedLinks()` | Same as `setCommentFeedLink()`, except it accepts an array of arrays, where each subarray contains the expected parameters of `setCommentFeedLink()`.
|
||||
`setEncoding()` | Sets the encoding of entry text. This will default to UTF-8, which is the preferred encoding.
|
||||
|
||||
> #### Retrieval methods
|
||||
>
|
||||
> In addition to the setters listed above, `Entry` instances also provide
|
||||
> matching getters to retrieve data from the `Entry` data container. For
|
||||
> example, `setContent()` is matched with a `getContent()` method.
|
||||
|
||||
## Extensions
|
||||
|
||||
- TODO
|
21
web/vendor/zendframework/zend-feed/mkdocs.yml
vendored
Normal file
21
web/vendor/zendframework/zend-feed/mkdocs.yml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
docs_dir: doc/book
|
||||
site_dir: doc/html
|
||||
pages:
|
||||
- index.md
|
||||
- Introduction: intro.md
|
||||
- Reader:
|
||||
- "Zend\\Feed\\Reader": reader.md
|
||||
- 'HTTP Clients': http-clients.md
|
||||
- 'Using PSR-7 Clients': psr7-clients.md
|
||||
- 'Importing Feeds': importing.md
|
||||
- 'Feed Discovery': find-feeds.md
|
||||
- 'Consuming RSS Feeds': consuming-rss.md
|
||||
- 'Consuming Atom Feeds': consuming-atom.md
|
||||
- 'Consuming Atom Entries': consuming-atom-entry.md
|
||||
- Security: security.md
|
||||
- Writer: writer.md
|
||||
- Pubsubhubbub: pubsubhubbub.md
|
||||
site_name: zend-feed
|
||||
site_description: Zend\Feed
|
||||
repo_url: 'https://github.com/zendframework/zend-feed'
|
||||
copyright: 'Copyright (c) 2016 <a href="http://www.zend.com/">Zend Technologies USA Inc.</a>'
|
8
web/vendor/zendframework/zend-feed/phpcs.xml
vendored
Normal file
8
web/vendor/zendframework/zend-feed/phpcs.xml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="Zend Framework coding standard">
|
||||
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml"/>
|
||||
|
||||
<!-- Paths to check -->
|
||||
<file>src</file>
|
||||
<file>test</file>
|
||||
</ruleset>
|
|
@ -67,7 +67,7 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
$options = ArrayUtils::iteratorToArray($options);
|
||||
}
|
||||
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
throw new Exception\InvalidArgumentException('Array or Traversable object'
|
||||
. 'expected, got ' . gettype($options));
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
*/
|
||||
public function setHttpResponse($httpResponse)
|
||||
{
|
||||
if (!$httpResponse instanceof HttpResponse && !$httpResponse instanceof PhpResponse) {
|
||||
if (! $httpResponse instanceof HttpResponse && ! $httpResponse instanceof PhpResponse) {
|
||||
throw new Exception\InvalidArgumentException('HTTP Response object must'
|
||||
. ' implement one of Zend\Feed\Pubsubhubbub\HttpResponse or'
|
||||
. ' Zend\Http\PhpEnvironment\Response');
|
||||
|
@ -196,8 +196,10 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
* Attempt to detect the callback URL (specifically the path forward)
|
||||
* @return string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _detectCallbackUrl()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$callbackUrl = '';
|
||||
if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
|
||||
$callbackUrl = $_SERVER['HTTP_X_ORIGINAL_URL'];
|
||||
|
@ -214,8 +216,8 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
$callbackUrl = substr($callbackUrl, strlen($schemeAndHttpHost));
|
||||
}
|
||||
} elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
|
||||
$callbackUrl= $_SERVER['ORIG_PATH_INFO'];
|
||||
if (!empty($_SERVER['QUERY_STRING'])) {
|
||||
$callbackUrl = $_SERVER['ORIG_PATH_INFO'];
|
||||
if (! empty($_SERVER['QUERY_STRING'])) {
|
||||
$callbackUrl .= '?' . $_SERVER['QUERY_STRING'];
|
||||
}
|
||||
}
|
||||
|
@ -227,9 +229,11 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getHttpHost()
|
||||
{
|
||||
if (!empty($_SERVER['HTTP_HOST'])) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! empty($_SERVER['HTTP_HOST'])) {
|
||||
return $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
$scheme = 'http';
|
||||
|
@ -253,19 +257,21 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
* @param string $header
|
||||
* @return bool|string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getHeader($header)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$temp = strtoupper(str_replace('-', '_', $header));
|
||||
if (!empty($_SERVER[$temp])) {
|
||||
if (! empty($_SERVER[$temp])) {
|
||||
return $_SERVER[$temp];
|
||||
}
|
||||
$temp = 'HTTP_' . strtoupper(str_replace('-', '_', $header));
|
||||
if (!empty($_SERVER[$temp])) {
|
||||
if (! empty($_SERVER[$temp])) {
|
||||
return $_SERVER[$temp];
|
||||
}
|
||||
if (function_exists('apache_request_headers')) {
|
||||
$headers = apache_request_headers();
|
||||
if (!empty($headers[$header])) {
|
||||
if (! empty($headers[$header])) {
|
||||
return $headers[$header];
|
||||
}
|
||||
}
|
||||
|
@ -277,8 +283,10 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
*
|
||||
* @return string|false Raw body, or false if not present
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getRawBody()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$body = file_get_contents('php://input');
|
||||
if (strlen(trim($body)) == 0 && isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
|
||||
$body = $GLOBALS['HTTP_RAW_POST_DATA'];
|
||||
|
|
|
@ -60,14 +60,14 @@ class HttpResponse
|
|||
}
|
||||
$httpCodeSent = false;
|
||||
foreach ($this->headers as $header) {
|
||||
if (!$httpCodeSent && $this->statusCode) {
|
||||
if (! $httpCodeSent && $this->statusCode) {
|
||||
header($header['name'] . ': ' . $header['value'], $header['replace'], $this->statusCode);
|
||||
$httpCodeSent = true;
|
||||
} else {
|
||||
header($header['name'] . ': ' . $header['value'], $header['replace']);
|
||||
}
|
||||
}
|
||||
if (!$httpCodeSent) {
|
||||
if (! $httpCodeSent) {
|
||||
header('HTTP/1.1 ' . $this->statusCode);
|
||||
}
|
||||
}
|
||||
|
@ -140,9 +140,11 @@ class HttpResponse
|
|||
{
|
||||
$ok = headers_sent($file, $line);
|
||||
if ($ok && $throw) {
|
||||
throw new Exception\RuntimeException('Cannot send headers; headers already sent in ' . $file . ', line ' . $line);
|
||||
throw new Exception\RuntimeException(
|
||||
'Cannot send headers; headers already sent in ' . $file . ', line ' . $line
|
||||
);
|
||||
}
|
||||
return !$ok;
|
||||
return ! $ok;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,7 +156,7 @@ class HttpResponse
|
|||
*/
|
||||
public function setStatusCode($code)
|
||||
{
|
||||
if (!is_int($code) || (100 > $code) || (599 < $code)) {
|
||||
if (! is_int($code) || (100 > $code) || (599 < $code)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid HTTP response'
|
||||
. ' code:' . $code);
|
||||
}
|
||||
|
@ -201,8 +203,10 @@ class HttpResponse
|
|||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _normalizeHeader($name)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$filtered = str_replace(['-', '_'], ' ', (string) $name);
|
||||
$filtered = ucwords(strtolower($filtered));
|
||||
$filtered = str_replace(' ', '-', $filtered);
|
||||
|
|
|
@ -31,7 +31,7 @@ class Subscription extends AbstractModel implements SubscriptionPersistenceInter
|
|||
*/
|
||||
public function setSubscription(array $data)
|
||||
{
|
||||
if (!isset($data['id'])) {
|
||||
if (! isset($data['id'])) {
|
||||
throw new PubSubHubbub\Exception\InvalidArgumentException(
|
||||
'ID must be set before attempting a save'
|
||||
);
|
||||
|
@ -66,7 +66,7 @@ class Subscription extends AbstractModel implements SubscriptionPersistenceInter
|
|||
*/
|
||||
public function getSubscription($key)
|
||||
{
|
||||
if (empty($key) || !is_string($key)) {
|
||||
if (empty($key) || ! is_string($key)) {
|
||||
throw new PubSubHubbub\Exception\InvalidArgumentException('Invalid parameter "key"'
|
||||
.' of "' . $key . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class Subscription extends AbstractModel implements SubscriptionPersistenceInter
|
|||
*/
|
||||
public function hasSubscription($key)
|
||||
{
|
||||
if (empty($key) || !is_string($key)) {
|
||||
if (empty($key) || ! is_string($key)) {
|
||||
throw new PubSubHubbub\Exception\InvalidArgumentException('Invalid parameter "key"'
|
||||
.' of "' . $key . '" must be a non-empty string');
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ class PubSubHubbub
|
|||
*/
|
||||
public static function getHttpClient()
|
||||
{
|
||||
if (!isset(static::$httpClient)) {
|
||||
if (! isset(static::$httpClient)) {
|
||||
static::$httpClient = new Http\Client;
|
||||
} else {
|
||||
static::$httpClient->resetParameters();
|
||||
|
|
|
@ -75,7 +75,7 @@ class Publisher
|
|||
$options = ArrayUtils::iteratorToArray($options);
|
||||
}
|
||||
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
throw new Exception\InvalidArgumentException('Array or Traversable object'
|
||||
. 'expected, got ' . gettype($options));
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class Publisher
|
|||
*/
|
||||
public function addHubUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. 'URL');
|
||||
|
@ -131,7 +131,7 @@ class Publisher
|
|||
*/
|
||||
public function removeHubUrl($url)
|
||||
{
|
||||
if (!in_array($url, $this->getHubUrls())) {
|
||||
if (! in_array($url, $this->getHubUrls())) {
|
||||
return $this;
|
||||
}
|
||||
$key = array_search($url, $this->hubUrls);
|
||||
|
@ -159,7 +159,7 @@ class Publisher
|
|||
*/
|
||||
public function addUpdatedTopicUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. 'URL');
|
||||
|
@ -190,7 +190,7 @@ class Publisher
|
|||
*/
|
||||
public function removeUpdatedTopicUrl($url)
|
||||
{
|
||||
if (!in_array($url, $this->getUpdatedTopicUrls())) {
|
||||
if (! in_array($url, $this->getUpdatedTopicUrls())) {
|
||||
return $this;
|
||||
}
|
||||
$key = array_search($url, $this->updatedTopicUrls);
|
||||
|
@ -219,7 +219,7 @@ class Publisher
|
|||
*/
|
||||
public function notifyHub($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. 'URL');
|
||||
|
@ -281,7 +281,7 @@ class Publisher
|
|||
$this->setParameters($name);
|
||||
return $this;
|
||||
}
|
||||
if (empty($name) || !is_string($name)) {
|
||||
if (empty($name) || ! is_string($name)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "name"'
|
||||
. ' of "' . $name . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ class Publisher
|
|||
$this->removeParameter($name);
|
||||
return $this;
|
||||
}
|
||||
if (empty($value) || (!is_string($value) && $value !== null)) {
|
||||
if (empty($value) || (! is_string($value) && $value !== null)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "value"'
|
||||
. ' of "' . $value . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ class Publisher
|
|||
*/
|
||||
public function removeParameter($name)
|
||||
{
|
||||
if (empty($name) || !is_string($name)) {
|
||||
if (empty($name) || ! is_string($name)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "name"'
|
||||
. ' of "' . $name . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ class Publisher
|
|||
*/
|
||||
public function isSuccess()
|
||||
{
|
||||
return !(count($this->errors) != 0);
|
||||
return ! (count($this->errors) != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -369,8 +369,10 @@ class Publisher
|
|||
* @return \Zend\Http\Client
|
||||
* @throws Exception\RuntimeException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getHttpClient()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$client = PubSubHubbub::getHttpClient();
|
||||
$client->setMethod(HttpRequest::METHOD_POST);
|
||||
$client->setOptions([
|
||||
|
|
|
@ -147,7 +147,7 @@ class Subscriber
|
|||
$options = ArrayUtils::iteratorToArray($options);
|
||||
}
|
||||
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
throw new Exception\InvalidArgumentException('Array or Traversable object'
|
||||
. 'expected, got ' . gettype($options));
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ class Subscriber
|
|||
*/
|
||||
public function setTopicUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
.' of "' . $url . '" must be a non-empty string and a valid'
|
||||
.' URL');
|
||||
|
@ -256,7 +256,7 @@ class Subscriber
|
|||
*/
|
||||
public function setCallbackUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. ' URL');
|
||||
|
@ -326,7 +326,7 @@ class Subscriber
|
|||
*/
|
||||
public function addHubUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. ' URL');
|
||||
|
@ -357,7 +357,7 @@ class Subscriber
|
|||
*/
|
||||
public function removeHubUrl($url)
|
||||
{
|
||||
if (!in_array($url, $this->getHubUrls())) {
|
||||
if (! in_array($url, $this->getHubUrls())) {
|
||||
return $this;
|
||||
}
|
||||
$key = array_search($url, $this->hubUrls);
|
||||
|
@ -386,7 +386,7 @@ class Subscriber
|
|||
*/
|
||||
public function addAuthentication($url, array $authentication)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. ' URL');
|
||||
|
@ -445,7 +445,7 @@ class Subscriber
|
|||
$this->setParameters($name);
|
||||
return $this;
|
||||
}
|
||||
if (empty($name) || !is_string($name)) {
|
||||
if (empty($name) || ! is_string($name)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "name"'
|
||||
. ' of "' . $name . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ class Subscriber
|
|||
$this->removeParameter($name);
|
||||
return $this;
|
||||
}
|
||||
if (empty($value) || (!is_string($value) && $value !== null)) {
|
||||
if (empty($value) || (! is_string($value) && $value !== null)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "value"'
|
||||
. ' of "' . $value . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ class Subscriber
|
|||
*/
|
||||
public function removeParameter($name)
|
||||
{
|
||||
if (empty($name) || !is_string($name)) {
|
||||
if (empty($name) || ! is_string($name)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "name"'
|
||||
. ' of "' . $name . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -602,8 +602,10 @@ class Subscriber
|
|||
* @return void
|
||||
* @throws Exception\RuntimeException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _doRequest($mode)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$client = $this->_getHttpClient();
|
||||
$hubs = $this->getHubUrls();
|
||||
if (empty($hubs)) {
|
||||
|
@ -648,8 +650,10 @@ class Subscriber
|
|||
*
|
||||
* @return \Zend\Http\Client
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getHttpClient()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$client = PubSubHubbub::getHttpClient();
|
||||
$client->setMethod(HttpRequest::METHOD_POST);
|
||||
$client->setOptions(['useragent' => 'Zend_Feed_Pubsubhubbub_Subscriber/'
|
||||
|
@ -666,9 +670,11 @@ class Subscriber
|
|||
* @return string
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getRequestParameters($hubUrl, $mode)
|
||||
{
|
||||
if (!in_array($mode, ['subscribe', 'unsubscribe'])) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! in_array($mode, ['subscribe', 'unsubscribe'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid mode specified: "'
|
||||
. $mode . '" which should have been "subscribe" or "unsubscribe"');
|
||||
}
|
||||
|
@ -705,7 +711,7 @@ class Subscriber
|
|||
$params['hub.verify_token'] = $token;
|
||||
|
||||
// Note: query string only usable with PuSH 0.2 Hubs
|
||||
if (!$this->usePathParameter) {
|
||||
if (! $this->usePathParameter) {
|
||||
$params['hub.callback'] = $this->getCallbackUrl()
|
||||
. '?xhub.subscription=' . PubSubHubbub::urlencode($key);
|
||||
} else {
|
||||
|
@ -738,7 +744,9 @@ class Subscriber
|
|||
'verify_token' => hash('sha256', $params['hub.verify_token']),
|
||||
'secret' => null,
|
||||
'expiration_time' => $expires,
|
||||
'subscription_state' => ($mode == 'unsubscribe')? PubSubHubbub::SUBSCRIPTION_TODELETE : PubSubHubbub::SUBSCRIPTION_NOTVERIFIED,
|
||||
// @codingStandardsIgnoreStart
|
||||
'subscription_state' => ($mode == 'unsubscribe') ? PubSubHubbub::SUBSCRIPTION_TODELETE : PubSubHubbub::SUBSCRIPTION_NOTVERIFIED,
|
||||
// @codingStandardsIgnoreEnd
|
||||
];
|
||||
$this->getStorage()->setSubscription($data);
|
||||
|
||||
|
@ -754,9 +762,11 @@ class Subscriber
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _generateVerifyToken()
|
||||
{
|
||||
if (!empty($this->testStaticToken)) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! empty($this->testStaticToken)) {
|
||||
return $this->testStaticToken;
|
||||
}
|
||||
return uniqid(rand(), true) . time();
|
||||
|
@ -770,8 +780,10 @@ class Subscriber
|
|||
* @param string $hubUrl The Hub Server URL for which this token will apply
|
||||
* @return string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _generateSubscriptionKey(array $params, $hubUrl)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$keyBase = $params['hub.topic'] . $hubUrl;
|
||||
$key = md5($keyBase);
|
||||
|
||||
|
@ -784,8 +796,10 @@ class Subscriber
|
|||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _urlEncode(array $params)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$encoded = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
|
@ -809,8 +823,10 @@ class Subscriber
|
|||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _toByteValueOrderedString(array $params)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$return = [];
|
||||
uksort($params, 'strnatcmp');
|
||||
foreach ($params as $key => $value) {
|
||||
|
|
|
@ -147,7 +147,7 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
'hub_verify_token',
|
||||
];
|
||||
foreach ($required as $key) {
|
||||
if (!array_key_exists($key, $httpGetData)) {
|
||||
if (! array_key_exists($key, $httpGetData)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -157,11 +157,11 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
return false;
|
||||
}
|
||||
if ($httpGetData['hub_mode'] == 'subscribe'
|
||||
&& !array_key_exists('hub_lease_seconds', $httpGetData)
|
||||
&& ! array_key_exists('hub_lease_seconds', $httpGetData)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (!Uri::factory($httpGetData['hub_topic'])->isValid()) {
|
||||
if (! Uri::factory($httpGetData['hub_topic'])->isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
* Attempt to retrieve any Verification Token Key attached to Callback
|
||||
* URL's path by our Subscriber implementation
|
||||
*/
|
||||
if (!$this->_hasValidVerifyToken($httpGetData)) {
|
||||
if (! $this->_hasValidVerifyToken($httpGetData)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -220,14 +220,16 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
* @param bool $checkValue
|
||||
* @return bool
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _hasValidVerifyToken(array $httpGetData = null, $checkValue = true)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$verifyTokenKey = $this->_detectVerifyTokenKey($httpGetData);
|
||||
if (empty($verifyTokenKey)) {
|
||||
return false;
|
||||
}
|
||||
$verifyTokenExists = $this->getStorage()->hasSubscription($verifyTokenKey);
|
||||
if (!$verifyTokenExists) {
|
||||
if (! $verifyTokenExists) {
|
||||
return false;
|
||||
}
|
||||
if ($checkValue) {
|
||||
|
@ -250,8 +252,10 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
* @param null|array $httpGetData
|
||||
* @return false|string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _detectVerifyTokenKey(array $httpGetData = null)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
/**
|
||||
* Available when sub keys encoding in Callback URL path
|
||||
*/
|
||||
|
@ -286,8 +290,10 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
*
|
||||
* @return array|void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _parseQueryString()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$params = [];
|
||||
$queryString = '';
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
|
|
|
@ -141,7 +141,7 @@ abstract class AbstractEntry
|
|||
*/
|
||||
public function getXpath()
|
||||
{
|
||||
if (!$this->xpath) {
|
||||
if (! $this->xpath) {
|
||||
$this->setXpath(new DOMXPath($this->getDomDocument()));
|
||||
}
|
||||
return $this->xpath;
|
||||
|
@ -207,8 +207,10 @@ abstract class AbstractEntry
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _loadExtensions()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$all = Reader::getExtensions();
|
||||
$feed = $all['entry'];
|
||||
foreach ($feed as $extension) {
|
||||
|
|
|
@ -23,7 +23,7 @@ class Category extends AbstractCollection
|
|||
{
|
||||
$categories = [];
|
||||
foreach ($this->getIterator() as $element) {
|
||||
if (isset($element['label']) && !empty($element['label'])) {
|
||||
if (isset($element['label']) && ! empty($element['label'])) {
|
||||
$categories[] = $element['label'];
|
||||
} else {
|
||||
$categories[] = $element['term'];
|
||||
|
|
|
@ -146,7 +146,7 @@ abstract class AbstractEntry
|
|||
*/
|
||||
public function getXpath()
|
||||
{
|
||||
if (!$this->xpath) {
|
||||
if (! $this->xpath) {
|
||||
$this->setXpath(new DOMXPath($this->getDomDocument()));
|
||||
}
|
||||
return $this->xpath;
|
||||
|
|
|
@ -104,7 +104,7 @@ class Atom extends AbstractEntry implements EntryInterface
|
|||
/**
|
||||
* Get the entry creation date
|
||||
*
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ class Atom extends AbstractEntry implements EntryInterface
|
|||
/**
|
||||
* Get the entry modification date
|
||||
*
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
|
@ -199,7 +199,7 @@ class Atom extends AbstractEntry implements EntryInterface
|
|||
*/
|
||||
public function getLink($index = 0)
|
||||
{
|
||||
if (!array_key_exists('links', $this->data)) {
|
||||
if (! array_key_exists('links', $this->data)) {
|
||||
$this->getLinks();
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ class Atom extends AbstractEntry implements EntryInterface
|
|||
|
||||
$commentcount = $this->getExtension('Thread')->getCommentCount();
|
||||
|
||||
if (!$commentcount) {
|
||||
if (! $commentcount) {
|
||||
$commentcount = $this->getExtension('Atom')->getCommentCount();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,14 +38,14 @@ interface EntryInterface
|
|||
/**
|
||||
* Get the entry creation date
|
||||
*
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateCreated();
|
||||
|
||||
/**
|
||||
* Get the entry modification date
|
||||
*
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateModified();
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
public function __construct(DOMElement $entry, $entryKey, $type = null)
|
||||
{
|
||||
parent::__construct($entry, $entryKey, $type);
|
||||
$this->xpathQueryRss = '//item[' . ($this->entryKey+1) . ']';
|
||||
$this->xpathQueryRdf = '//rss:item[' . ($this->entryKey+1) . ']';
|
||||
$this->xpathQueryRss = '//item[' . ($this->entryKey + 1) . ']';
|
||||
$this->xpathQueryRdf = '//rss:item[' . ($this->entryKey + 1) . ']';
|
||||
|
||||
$manager = Reader\Reader::getExtensionManager();
|
||||
$extensions = [
|
||||
|
@ -92,7 +92,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
|
||||
$authors = [];
|
||||
$authorsDc = $this->getExtension('DublinCore')->getAuthors();
|
||||
if (!empty($authorsDc)) {
|
||||
if (! empty($authorsDc)) {
|
||||
foreach ($authorsDc as $author) {
|
||||
$authors[] = [
|
||||
'name' => $author['name']
|
||||
|
@ -151,7 +151,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
|
||||
$content = $this->getExtension('Content')->getContent();
|
||||
|
||||
if (!$content) {
|
||||
if (! $content) {
|
||||
$content = $this->getDescription();
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
/**
|
||||
* Get the entry's date of creation
|
||||
*
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
|
@ -178,7 +178,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
* Get the entry's date of modification
|
||||
*
|
||||
* @throws Exception\RuntimeException
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
|
@ -209,7 +209,8 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
'Could not load date due to unrecognised'
|
||||
.' format (should follow RFC 822 or 2822):'
|
||||
. $e->getMessage(),
|
||||
0, $e
|
||||
0,
|
||||
$e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -218,15 +219,15 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
}
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getExtension('DublinCore')->getDate();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getExtension('Atom')->getDateModified();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = null;
|
||||
}
|
||||
|
||||
|
@ -256,7 +257,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$description = $this->xpath->evaluate('string(' . $this->xpathQueryRdf . '/rss:description)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = $this->getExtension('DublinCore')->getDescription();
|
||||
}
|
||||
|
||||
|
@ -264,7 +265,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$description = $this->getExtension('Atom')->getDescription();
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -296,7 +297,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
}
|
||||
}
|
||||
|
||||
if (!$enclosure) {
|
||||
if (! $enclosure) {
|
||||
$enclosure = $this->getExtension('Atom')->getEnclosure();
|
||||
}
|
||||
|
||||
|
@ -324,7 +325,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$id = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/guid)');
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
$id = $this->getExtension('DublinCore')->getId();
|
||||
}
|
||||
|
||||
|
@ -332,7 +333,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$id = $this->getExtension('Atom')->getId();
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
if ($this->getPermalink()) {
|
||||
$id = $this->getPermalink();
|
||||
} elseif ($this->getTitle()) {
|
||||
|
@ -355,7 +356,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
*/
|
||||
public function getLink($index = 0)
|
||||
{
|
||||
if (!array_key_exists('links', $this->data)) {
|
||||
if (! array_key_exists('links', $this->data)) {
|
||||
$this->getLinks();
|
||||
}
|
||||
|
||||
|
@ -386,7 +387,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$list = $this->xpath->query($this->xpathQueryRdf . '//rss:link');
|
||||
}
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$links = $this->getExtension('Atom')->getLinks();
|
||||
} else {
|
||||
foreach ($list as $link) {
|
||||
|
@ -470,15 +471,15 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$title = $this->xpath->evaluate('string(' . $this->xpathQueryRdf . '/rss:title)');
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = $this->getExtension('DublinCore')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = $this->getExtension('Atom')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
@ -500,15 +501,15 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
|
||||
$commentcount = $this->getExtension('Slash')->getCommentCount();
|
||||
|
||||
if (!$commentcount) {
|
||||
if (! $commentcount) {
|
||||
$commentcount = $this->getExtension('Thread')->getCommentCount();
|
||||
}
|
||||
|
||||
if (!$commentcount) {
|
||||
if (! $commentcount) {
|
||||
$commentcount = $this->getExtension('Atom')->getCommentCount();
|
||||
}
|
||||
|
||||
if (!$commentcount) {
|
||||
if (! $commentcount) {
|
||||
$commentcount = null;
|
||||
}
|
||||
|
||||
|
@ -536,11 +537,11 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$commentlink = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/comments)');
|
||||
}
|
||||
|
||||
if (!$commentlink) {
|
||||
if (! $commentlink) {
|
||||
$commentlink = $this->getExtension('Atom')->getCommentLink();
|
||||
}
|
||||
|
||||
if (!$commentlink) {
|
||||
if (! $commentlink) {
|
||||
$commentlink = null;
|
||||
}
|
||||
|
||||
|
@ -562,15 +563,15 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
|
||||
$commentfeedlink = $this->getExtension('WellFormedWeb')->getCommentFeedLink();
|
||||
|
||||
if (!$commentfeedlink) {
|
||||
if (! $commentfeedlink) {
|
||||
$commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rss');
|
||||
}
|
||||
|
||||
if (!$commentfeedlink) {
|
||||
if (! $commentfeedlink) {
|
||||
$commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rdf');
|
||||
}
|
||||
|
||||
if (!$commentfeedlink) {
|
||||
if (! $commentfeedlink) {
|
||||
$commentfeedlink = null;
|
||||
}
|
||||
|
||||
|
|
16
web/vendor/zendframework/zend-feed/src/Reader/Exception/InvalidHttpClientException.php
vendored
Normal file
16
web/vendor/zendframework/zend-feed/src/Reader/Exception/InvalidHttpClientException.php
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Exception;
|
||||
|
||||
use Zend\Feed\Exception;
|
||||
|
||||
class InvalidHttpClientException extends Exception\InvalidArgumentException implements ExceptionInterface
|
||||
{
|
||||
}
|
|
@ -135,18 +135,18 @@ abstract class AbstractEntry
|
|||
if ($type === Reader\Reader::TYPE_RSS_10
|
||||
|| $type === Reader\Reader::TYPE_RSS_090
|
||||
) {
|
||||
$this->setXpathPrefix('//rss:item[' . ($this->entryKey + 1) . ']');
|
||||
$this->setXpathPrefix('//rss:item[' . ((int)$this->entryKey + 1) . ']');
|
||||
return $this;
|
||||
}
|
||||
|
||||
if ($type === Reader\Reader::TYPE_ATOM_10
|
||||
|| $type === Reader\Reader::TYPE_ATOM_03
|
||||
) {
|
||||
$this->setXpathPrefix('//atom:entry[' . ($this->entryKey + 1) . ']');
|
||||
$this->setXpathPrefix('//atom:entry[' . ((int)$this->entryKey + 1) . ']');
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->setXpathPrefix('//item[' . ($this->entryKey + 1) . ']');
|
||||
$this->setXpathPrefix('//item[' . ((int)$this->entryKey + 1) . ']');
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ abstract class AbstractEntry
|
|||
*/
|
||||
public function getXpath()
|
||||
{
|
||||
if (!$this->xpath) {
|
||||
if (! $this->xpath) {
|
||||
$this->setXpath(new DOMXPath($this->getDomDocument()));
|
||||
}
|
||||
return $this->xpath;
|
||||
|
|
|
@ -51,7 +51,7 @@ class Entry extends Extension\AbstractEntry
|
|||
$authors = [];
|
||||
$list = $this->getXpath()->query($this->getXpathPrefix() . '//atom:author');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
/**
|
||||
* TODO: Limit query to feed level els only!
|
||||
*/
|
||||
|
@ -61,7 +61,7 @@ class Entry extends Extension\AbstractEntry
|
|||
if ($list->length) {
|
||||
foreach ($list as $author) {
|
||||
$author = $this->getAuthorFromElement($author);
|
||||
if (!empty($author)) {
|
||||
if (! empty($author)) {
|
||||
$authors[] = $author;
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ class Entry extends Extension\AbstractEntry
|
|||
}
|
||||
}
|
||||
|
||||
if (!$content) {
|
||||
if (! $content) {
|
||||
$content = $this->getDescription();
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ class Entry extends Extension\AbstractEntry
|
|||
*/
|
||||
protected function collectXhtml($xhtml, $prefix)
|
||||
{
|
||||
if (!empty($prefix)) {
|
||||
if (! empty($prefix)) {
|
||||
$prefix = $prefix . ':';
|
||||
}
|
||||
$matches = [
|
||||
|
@ -147,7 +147,7 @@ class Entry extends Extension\AbstractEntry
|
|||
"/<\/" . $prefix . "div>\s*$/"
|
||||
];
|
||||
$xhtml = preg_replace($matches, '', $xhtml);
|
||||
if (!empty($prefix)) {
|
||||
if (! empty($prefix)) {
|
||||
$xhtml = preg_replace("/(<[\/]?)" . $prefix . "([a-zA-Z]+)/", '$1$2', $xhtml);
|
||||
}
|
||||
return $xhtml;
|
||||
|
@ -222,7 +222,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:summary)');
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:id)');
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
if ($this->getPermalink()) {
|
||||
$id = $this->getPermalink();
|
||||
} elseif ($this->getTitle()) {
|
||||
|
@ -304,11 +304,11 @@ class Entry extends Extension\AbstractEntry
|
|||
. ')'
|
||||
);
|
||||
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
$baseUrl = $this->getXpath()->evaluate('string(//@xml:base[1])');
|
||||
}
|
||||
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
$baseUrl = null;
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ class Entry extends Extension\AbstractEntry
|
|||
*/
|
||||
public function getLink($index = 0)
|
||||
{
|
||||
if (!array_key_exists('links', $this->data)) {
|
||||
if (! array_key_exists('links', $this->data)) {
|
||||
$this->getLinks();
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:title)');
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
@ -554,10 +554,10 @@ class Entry extends Extension\AbstractEntry
|
|||
*/
|
||||
protected function absolutiseUri($link)
|
||||
{
|
||||
if (!Uri::factory($link)->isAbsolute()) {
|
||||
if (! Uri::factory($link)->isAbsolute()) {
|
||||
if ($this->getBaseUrl() !== null) {
|
||||
$link = $this->getBaseUrl() . $link;
|
||||
if (!Uri::factory($link)->isValid()) {
|
||||
if (! Uri::factory($link)->isValid()) {
|
||||
$link = null;
|
||||
}
|
||||
}
|
||||
|
@ -623,11 +623,11 @@ class Entry extends Extension\AbstractEntry
|
|||
$prefixAtom03 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_03);
|
||||
$prefixAtom10 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_10);
|
||||
if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_03)
|
||||
|| !empty($prefixAtom03)) {
|
||||
|| ! empty($prefixAtom03)) {
|
||||
return Reader\Reader::TYPE_ATOM_03;
|
||||
}
|
||||
if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_10)
|
||||
|| !empty($prefixAtom10)) {
|
||||
|| ! empty($prefixAtom10)) {
|
||||
return Reader\Reader::TYPE_ATOM_10;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class Feed extends Extension\AbstractFeed
|
|||
if ($list->length) {
|
||||
foreach ($list as $author) {
|
||||
$author = $this->getAuthorFromElement($author);
|
||||
if (!empty($author)) {
|
||||
if (! empty($author)) {
|
||||
$authors[] = $author;
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$copyright = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:rights)');
|
||||
}
|
||||
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$description = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:subtitle)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ class Feed extends Extension\AbstractFeed
|
|||
// TODO: Add uri support
|
||||
$generator = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:generator)');
|
||||
|
||||
if (!$generator) {
|
||||
if (! $generator) {
|
||||
$generator = null;
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$id = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:id)');
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
if ($this->getLink()) {
|
||||
$id = $this->getLink();
|
||||
} elseif ($this->getTitle()) {
|
||||
|
@ -247,11 +247,11 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$language = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:lang)');
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = $this->xpath->evaluate('string(//@xml:lang[1])');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$imageUrl = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:logo)');
|
||||
|
||||
if (!$imageUrl) {
|
||||
if (! $imageUrl) {
|
||||
$image = null;
|
||||
} else {
|
||||
$image = ['uri' => $imageUrl];
|
||||
|
@ -297,7 +297,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$baseUrl = $this->xpath->evaluate('string(//@xml:base[1])');
|
||||
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
$baseUrl = null;
|
||||
}
|
||||
$this->data['baseUrl'] = $baseUrl;
|
||||
|
@ -394,7 +394,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$title = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:title)');
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
@ -482,10 +482,10 @@ class Feed extends Extension\AbstractFeed
|
|||
*/
|
||||
protected function absolutiseUri($link)
|
||||
{
|
||||
if (!Uri::factory($link)->isAbsolute()) {
|
||||
if (! Uri::factory($link)->isAbsolute()) {
|
||||
if ($this->getBaseUrl() !== null) {
|
||||
$link = $this->getBaseUrl() . $link;
|
||||
if (!Uri::factory($link)->isValid()) {
|
||||
if (! Uri::factory($link)->isValid()) {
|
||||
$link = null;
|
||||
}
|
||||
}
|
||||
|
@ -523,12 +523,12 @@ class Feed extends Extension\AbstractFeed
|
|||
$prefixAtom03 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_03);
|
||||
$prefixAtom10 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_10);
|
||||
if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_10)
|
||||
|| !empty($prefixAtom10)
|
||||
|| ! empty($prefixAtom10)
|
||||
) {
|
||||
return Reader\Reader::TYPE_ATOM_10;
|
||||
}
|
||||
if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_03)
|
||||
|| !empty($prefixAtom03)
|
||||
|| ! empty($prefixAtom03)
|
||||
) {
|
||||
return Reader\Reader::TYPE_ATOM_03;
|
||||
}
|
||||
|
|
|
@ -47,13 +47,13 @@ class Entry extends Extension\AbstractEntry
|
|||
$authors = [];
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc11:creator');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc10:creator');
|
||||
}
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc11:publisher');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc10:publisher');
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc11:subject');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc10:subject');
|
||||
}
|
||||
|
||||
|
@ -133,11 +133,11 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:description)');
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:description)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:identifier)');
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
$id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:identifier)');
|
||||
}
|
||||
|
||||
|
@ -181,11 +181,11 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:title)');
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:title)');
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ class Entry extends Extension\AbstractEntry
|
|||
$d = null;
|
||||
$date = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:date)');
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:date)');
|
||||
}
|
||||
|
||||
|
|
|
@ -47,13 +47,13 @@ class Feed extends Extension\AbstractFeed
|
|||
$authors = [];
|
||||
$list = $this->getXpath()->query('//dc11:creator');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->query('//dc10:creator');
|
||||
}
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->query('//dc11:publisher');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->query('//dc10:publisher');
|
||||
}
|
||||
}
|
||||
|
@ -89,11 +89,11 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$copyright = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:rights)');
|
||||
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
$copyright = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:rights)');
|
||||
}
|
||||
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
|
@ -115,11 +115,11 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:description)');
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:description)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:identifier)');
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
$id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:identifier)');
|
||||
}
|
||||
|
||||
|
@ -163,11 +163,11 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$language = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:language)');
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:language)');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
|
@ -189,11 +189,11 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:title)');
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:title)');
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$d = null;
|
||||
$date = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:date)');
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:date)');
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc11:subject');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc10:subject');
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$author = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:author)');
|
||||
|
||||
if (!$author) {
|
||||
if (! $author) {
|
||||
$author = null;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$block = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:block)');
|
||||
|
||||
if (!$block) {
|
||||
if (! $block) {
|
||||
$block = null;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$duration = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:duration)');
|
||||
|
||||
if (!$duration) {
|
||||
if (! $duration) {
|
||||
$duration = null;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$explicit = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:explicit)');
|
||||
|
||||
if (!$explicit) {
|
||||
if (! $explicit) {
|
||||
$explicit = null;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$keywords = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:keywords)');
|
||||
|
||||
if (!$keywords) {
|
||||
if (! $keywords) {
|
||||
$keywords = null;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$subtitle = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:subtitle)');
|
||||
|
||||
if (!$subtitle) {
|
||||
if (! $subtitle) {
|
||||
$subtitle = null;
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$summary = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:summary)');
|
||||
|
||||
if (!$summary) {
|
||||
if (! $summary) {
|
||||
$summary = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$author = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:author)');
|
||||
|
||||
if (!$author) {
|
||||
if (! $author) {
|
||||
$author = null;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$block = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:block)');
|
||||
|
||||
if (!$block) {
|
||||
if (! $block) {
|
||||
$block = null;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$children = [];
|
||||
|
||||
foreach ($node->childNodes as $childNode) {
|
||||
if (!($childNode instanceof DOMText)) {
|
||||
if (! ($childNode instanceof DOMText)) {
|
||||
$children[$childNode->getAttribute('text')] = null;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class Feed extends Extension\AbstractFeed
|
|||
}
|
||||
}
|
||||
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
$categories = null;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$explicit = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:explicit)');
|
||||
|
||||
if (!$explicit) {
|
||||
if (! $explicit) {
|
||||
$explicit = null;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$image = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:image/@href)');
|
||||
|
||||
if (!$image) {
|
||||
if (! $image) {
|
||||
$image = null;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$keywords = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:keywords)');
|
||||
|
||||
if (!$keywords) {
|
||||
if (! $keywords) {
|
||||
$keywords = null;
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$newFeedUrl = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:new-feed-url)');
|
||||
|
||||
if (!$newFeedUrl) {
|
||||
if (! $newFeedUrl) {
|
||||
$newFeedUrl = null;
|
||||
}
|
||||
|
||||
|
@ -206,13 +206,13 @@ class Feed extends Extension\AbstractFeed
|
|||
$email = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:email)');
|
||||
$name = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:name)');
|
||||
|
||||
if (!empty($email)) {
|
||||
if (! empty($email)) {
|
||||
$owner = $email . (empty($name) ? '' : ' (' . $name . ')');
|
||||
} elseif (!empty($name)) {
|
||||
} elseif (! empty($name)) {
|
||||
$owner = $name;
|
||||
}
|
||||
|
||||
if (!$owner) {
|
||||
if (! $owner) {
|
||||
$owner = null;
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$subtitle = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:subtitle)');
|
||||
|
||||
if (!$subtitle) {
|
||||
if (! $subtitle) {
|
||||
$subtitle = null;
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$summary = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:summary)');
|
||||
|
||||
if (!$summary) {
|
||||
if (! $summary) {
|
||||
$summary = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class Entry extends Extension\AbstractEntry
|
|||
$stringParade = $this->getData($name);
|
||||
$hitParade = [];
|
||||
|
||||
if (!empty($stringParade)) {
|
||||
if (! empty($stringParade)) {
|
||||
$stringParade = explode(',', $stringParade);
|
||||
|
||||
foreach ($stringParade as $hit) {
|
||||
|
@ -78,7 +78,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$comments = $this->getData($name, 'string');
|
||||
|
||||
if (!$comments) {
|
||||
if (! $comments) {
|
||||
$this->data[$name] = null;
|
||||
return $this->data[$name];
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$data = $this->xpath->evaluate($type . '(' . $this->getXpathPrefix() . '/slash10:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
if (! $data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,7 @@ class Feed extends Extension\AbstractFeed
|
|||
return $period;
|
||||
default:
|
||||
throw new Reader\Exception\InvalidArgumentException("Feed specified invalid update period: '$period'."
|
||||
. " Must be one of hourly, daily, weekly or yearly"
|
||||
);
|
||||
. " Must be one of hourly, daily, weekly or yearly");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +53,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$name = 'updateFrequency';
|
||||
$freq = $this->getData($name, 'number');
|
||||
|
||||
if (!$freq || $freq < 1) {
|
||||
if (! $freq || $freq < 1) {
|
||||
$this->data[$name] = 1;
|
||||
return 1;
|
||||
}
|
||||
|
@ -72,7 +71,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$name = 'updateFrequency';
|
||||
$freq = $this->getData($name, 'number');
|
||||
|
||||
if (!$freq || $freq < 1) {
|
||||
if (! $freq || $freq < 1) {
|
||||
$this->data[$name] = 1;
|
||||
$freq = 1;
|
||||
}
|
||||
|
@ -130,7 +129,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$data = $this->xpath->evaluate($type . '(' . $this->getXpathPrefix() . '/syn10:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
if (! $data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$data = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/thread10:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
if (! $data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$data = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/wfw:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
if (! $data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class ExtensionManager implements ExtensionManagerInterface
|
|||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (!method_exists($this->pluginManager, $method)) {
|
||||
if (! method_exists($this->pluginManager, $method)) {
|
||||
throw new Exception\BadMethodCallException(sprintf(
|
||||
'Method by name of %s does not exist in %s',
|
||||
$method,
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
namespace Zend\Feed\Reader;
|
||||
|
||||
use Zend\ServiceManager\AbstractPluginManager;
|
||||
use Zend\ServiceManager\Exception\InvalidServiceException;
|
||||
use Zend\ServiceManager\Factory\InvokableFactory;
|
||||
|
||||
/**
|
||||
* Plugin manager implementation for feed reader extensions based on the
|
||||
|
@ -18,36 +20,119 @@ use Zend\ServiceManager\AbstractPluginManager;
|
|||
* Validation checks that we have an Extension\AbstractEntry or
|
||||
* Extension\AbstractFeed.
|
||||
*/
|
||||
class ExtensionPluginManager extends AbstractPluginManager
|
||||
class ExtensionPluginManager extends AbstractPluginManager implements ExtensionManagerInterface
|
||||
{
|
||||
/**
|
||||
* Default set of extension classes
|
||||
* Aliases for default set of extension classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $invokableClasses = [
|
||||
'atomentry' => 'Zend\Feed\Reader\Extension\Atom\Entry',
|
||||
'atomfeed' => 'Zend\Feed\Reader\Extension\Atom\Feed',
|
||||
'contententry' => 'Zend\Feed\Reader\Extension\Content\Entry',
|
||||
'creativecommonsentry' => 'Zend\Feed\Reader\Extension\CreativeCommons\Entry',
|
||||
'creativecommonsfeed' => 'Zend\Feed\Reader\Extension\CreativeCommons\Feed',
|
||||
'dublincoreentry' => 'Zend\Feed\Reader\Extension\DublinCore\Entry',
|
||||
'dublincorefeed' => 'Zend\Feed\Reader\Extension\DublinCore\Feed',
|
||||
'podcastentry' => 'Zend\Feed\Reader\Extension\Podcast\Entry',
|
||||
'podcastfeed' => 'Zend\Feed\Reader\Extension\Podcast\Feed',
|
||||
'slashentry' => 'Zend\Feed\Reader\Extension\Slash\Entry',
|
||||
'syndicationfeed' => 'Zend\Feed\Reader\Extension\Syndication\Feed',
|
||||
'threadentry' => 'Zend\Feed\Reader\Extension\Thread\Entry',
|
||||
'wellformedwebentry' => 'Zend\Feed\Reader\Extension\WellFormedWeb\Entry',
|
||||
protected $aliases = [
|
||||
'atomentry' => Extension\Atom\Entry::class,
|
||||
'atomEntry' => Extension\Atom\Entry::class,
|
||||
'AtomEntry' => Extension\Atom\Entry::class,
|
||||
'Atom\Entry' => Extension\Atom\Entry::class,
|
||||
'atomfeed' => Extension\Atom\Feed::class,
|
||||
'atomFeed' => Extension\Atom\Feed::class,
|
||||
'AtomFeed' => Extension\Atom\Feed::class,
|
||||
'Atom\Feed' => Extension\Atom\Feed::class,
|
||||
'contententry' => Extension\Content\Entry::class,
|
||||
'contentEntry' => Extension\Content\Entry::class,
|
||||
'ContentEntry' => Extension\Content\Entry::class,
|
||||
'Content\Entry' => Extension\Content\Entry::class,
|
||||
'creativecommonsentry' => Extension\CreativeCommons\Entry::class,
|
||||
'creativeCommonsEntry' => Extension\CreativeCommons\Entry::class,
|
||||
'CreativeCommonsEntry' => Extension\CreativeCommons\Entry::class,
|
||||
'CreativeCommons\Entry' => Extension\CreativeCommons\Entry::class,
|
||||
'creativecommonsfeed' => Extension\CreativeCommons\Feed::class,
|
||||
'creativeCommonsFeed' => Extension\CreativeCommons\Feed::class,
|
||||
'CreativeCommonsFeed' => Extension\CreativeCommons\Feed::class,
|
||||
'CreativeCommons\Feed' => Extension\CreativeCommons\Feed::class,
|
||||
'dublincoreentry' => Extension\DublinCore\Entry::class,
|
||||
'dublinCoreEntry' => Extension\DublinCore\Entry::class,
|
||||
'DublinCoreEntry' => Extension\DublinCore\Entry::class,
|
||||
'DublinCore\Entry' => Extension\DublinCore\Entry::class,
|
||||
'dublincorefeed' => Extension\DublinCore\Feed::class,
|
||||
'dublinCoreFeed' => Extension\DublinCore\Feed::class,
|
||||
'DublinCoreFeed' => Extension\DublinCore\Feed::class,
|
||||
'DublinCore\Feed' => Extension\DublinCore\Feed::class,
|
||||
'podcastentry' => Extension\Podcast\Entry::class,
|
||||
'podcastEntry' => Extension\Podcast\Entry::class,
|
||||
'PodcastEntry' => Extension\Podcast\Entry::class,
|
||||
'Podcast\Entry' => Extension\Podcast\Entry::class,
|
||||
'podcastfeed' => Extension\Podcast\Feed::class,
|
||||
'podcastFeed' => Extension\Podcast\Feed::class,
|
||||
'PodcastFeed' => Extension\Podcast\Feed::class,
|
||||
'Podcast\Feed' => Extension\Podcast\Feed::class,
|
||||
'slashentry' => Extension\Slash\Entry::class,
|
||||
'slashEntry' => Extension\Slash\Entry::class,
|
||||
'SlashEntry' => Extension\Slash\Entry::class,
|
||||
'Slash\Entry' => Extension\Slash\Entry::class,
|
||||
'syndicationfeed' => Extension\Syndication\Feed::class,
|
||||
'syndicationFeed' => Extension\Syndication\Feed::class,
|
||||
'SyndicationFeed' => Extension\Syndication\Feed::class,
|
||||
'Syndication\Feed' => Extension\Syndication\Feed::class,
|
||||
'threadentry' => Extension\Thread\Entry::class,
|
||||
'threadEntry' => Extension\Thread\Entry::class,
|
||||
'ThreadEntry' => Extension\Thread\Entry::class,
|
||||
'Thread\Entry' => Extension\Thread\Entry::class,
|
||||
'wellformedwebentry' => Extension\WellFormedWeb\Entry::class,
|
||||
'wellFormedWebEntry' => Extension\WellFormedWeb\Entry::class,
|
||||
'WellFormedWebEntry' => Extension\WellFormedWeb\Entry::class,
|
||||
'WellFormedWeb\Entry' => Extension\WellFormedWeb\Entry::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Do not share instances
|
||||
* Factories for default set of extension classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $factories = [
|
||||
Extension\Atom\Entry::class => InvokableFactory::class,
|
||||
Extension\Atom\Feed::class => InvokableFactory::class,
|
||||
Extension\Content\Entry::class => InvokableFactory::class,
|
||||
Extension\CreativeCommons\Entry::class => InvokableFactory::class,
|
||||
Extension\CreativeCommons\Feed::class => InvokableFactory::class,
|
||||
Extension\DublinCore\Entry::class => InvokableFactory::class,
|
||||
Extension\DublinCore\Feed::class => InvokableFactory::class,
|
||||
Extension\Podcast\Entry::class => InvokableFactory::class,
|
||||
Extension\Podcast\Feed::class => InvokableFactory::class,
|
||||
Extension\Slash\Entry::class => InvokableFactory::class,
|
||||
Extension\Syndication\Feed::class => InvokableFactory::class,
|
||||
Extension\Thread\Entry::class => InvokableFactory::class,
|
||||
Extension\WellFormedWeb\Entry::class => InvokableFactory::class,
|
||||
// Legacy (v2) due to alias resolution; canonical form of resolved
|
||||
// alias is used to look up the factory, while the non-normalized
|
||||
// resolved alias is used as the requested name passed to the factory.
|
||||
'zendfeedreaderextensionatomentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionatomfeed' => InvokableFactory::class,
|
||||
'zendfeedreaderextensioncontententry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensioncreativecommonsentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensioncreativecommonsfeed' => InvokableFactory::class,
|
||||
'zendfeedreaderextensiondublincoreentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensiondublincorefeed' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionpodcastentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionpodcastfeed' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionslashentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionsyndicationfeed' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionthreadentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionwellformedwebentry' => InvokableFactory::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Do not share instances (v2)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $shareByDefault = false;
|
||||
|
||||
/**
|
||||
* Do not share instances (v3)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $sharedByDefault = false;
|
||||
|
||||
/**
|
||||
* Validate the plugin
|
||||
*
|
||||
|
@ -57,7 +142,7 @@ class ExtensionPluginManager extends AbstractPluginManager
|
|||
* @return void
|
||||
* @throws Exception\InvalidArgumentException if invalid
|
||||
*/
|
||||
public function validatePlugin($plugin)
|
||||
public function validate($plugin)
|
||||
{
|
||||
if ($plugin instanceof Extension\AbstractEntry
|
||||
|| $plugin instanceof Extension\AbstractFeed
|
||||
|
@ -66,7 +151,7 @@ class ExtensionPluginManager extends AbstractPluginManager
|
|||
return;
|
||||
}
|
||||
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
throw new InvalidServiceException(sprintf(
|
||||
'Plugin of type %s is invalid; must implement %s\Extension\AbstractFeed '
|
||||
. 'or %s\Extension\AbstractEntry',
|
||||
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
|
||||
|
@ -74,4 +159,26 @@ class ExtensionPluginManager extends AbstractPluginManager
|
|||
__NAMESPACE__
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the plugin (v2)
|
||||
*
|
||||
* @param mixed $plugin
|
||||
* @return void
|
||||
* @throws Exception\InvalidArgumentException if invalid
|
||||
*/
|
||||
public function validatePlugin($plugin)
|
||||
{
|
||||
try {
|
||||
$this->validate($plugin);
|
||||
} catch (InvalidServiceException $e) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Plugin of type %s is invalid; must implement %s\Extension\AbstractFeed '
|
||||
. 'or %s\Extension\AbstractEntry',
|
||||
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
|
||||
__NAMESPACE__,
|
||||
__NAMESPACE__
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -282,8 +282,10 @@ abstract class AbstractFeed implements FeedInterface
|
|||
if (in_array($extension, $all['core'])) {
|
||||
continue;
|
||||
}
|
||||
if (!$manager->has($extension)) {
|
||||
throw new Exception\RuntimeException(sprintf('Unable to load extension "%s"; cannot find class', $extension));
|
||||
if (! $manager->has($extension)) {
|
||||
throw new Exception\RuntimeException(
|
||||
sprintf('Unable to load extension "%s"; cannot find class', $extension)
|
||||
);
|
||||
}
|
||||
$plugin = $manager->get($extension);
|
||||
$plugin->setDomDocument($this->getDomDocument());
|
||||
|
|
|
@ -92,7 +92,7 @@ class Atom extends AbstractFeed
|
|||
|
||||
$copyright = $this->getExtension('Atom')->getCopyright();
|
||||
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ class Atom extends AbstractFeed
|
|||
/**
|
||||
* Get the feed creation date
|
||||
*
|
||||
* @return string|null
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ class Atom extends AbstractFeed
|
|||
|
||||
$dateCreated = $this->getExtension('Atom')->getDateCreated();
|
||||
|
||||
if (!$dateCreated) {
|
||||
if (! $dateCreated) {
|
||||
$dateCreated = null;
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ class Atom extends AbstractFeed
|
|||
/**
|
||||
* Get the feed modification date
|
||||
*
|
||||
* @return string|null
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ class Atom extends AbstractFeed
|
|||
|
||||
$dateModified = $this->getExtension('Atom')->getDateModified();
|
||||
|
||||
if (!$dateModified) {
|
||||
if (! $dateModified) {
|
||||
$dateModified = null;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ class Atom extends AbstractFeed
|
|||
|
||||
$description = $this->getExtension('Atom')->getDescription();
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -226,11 +226,11 @@ class Atom extends AbstractFeed
|
|||
|
||||
$language = $this->getExtension('Atom')->getLanguage();
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = $this->xpath->evaluate('string(//@xml:lang[1])');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,14 +41,14 @@ interface FeedInterface extends Iterator, Countable
|
|||
/**
|
||||
* Get the feed creation date
|
||||
*
|
||||
* @return string|null
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getDateCreated();
|
||||
|
||||
/**
|
||||
* Get the feed modification date
|
||||
*
|
||||
* @return string|null
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getDateModified();
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class Rss extends AbstractFeed
|
|||
|
||||
$authors = [];
|
||||
$authorsDc = $this->getExtension('DublinCore')->getAuthors();
|
||||
if (!empty($authorsDc)) {
|
||||
if (! empty($authorsDc)) {
|
||||
foreach ($authorsDc as $author) {
|
||||
$authors[] = [
|
||||
'name' => $author['name']
|
||||
|
@ -153,7 +153,7 @@ class Rss extends AbstractFeed
|
|||
$copyright = $this->xpath->evaluate('string(/rss/channel/copyright)');
|
||||
}
|
||||
|
||||
if (!$copyright && $this->getExtension('DublinCore') !== null) {
|
||||
if (! $copyright && $this->getExtension('DublinCore') !== null) {
|
||||
$copyright = $this->getExtension('DublinCore')->getCopyright();
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ class Rss extends AbstractFeed
|
|||
$copyright = $this->getExtension('Atom')->getCopyright();
|
||||
}
|
||||
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ class Rss extends AbstractFeed
|
|||
/**
|
||||
* Get the feed creation date
|
||||
*
|
||||
* @return string|null
|
||||
* @return DateTime|null
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ class Rss extends AbstractFeed
|
|||
if ($this->getType() !== Reader\Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Reader\Reader::TYPE_RSS_090) {
|
||||
$dateModified = $this->xpath->evaluate('string(/rss/channel/pubDate)');
|
||||
if (!$dateModified) {
|
||||
if (! $dateModified) {
|
||||
$dateModified = $this->xpath->evaluate('string(/rss/channel/lastBuildDate)');
|
||||
}
|
||||
if ($dateModified) {
|
||||
|
@ -217,7 +217,8 @@ class Rss extends AbstractFeed
|
|||
'Could not load date due to unrecognised'
|
||||
.' format (should follow RFC 822 or 2822):'
|
||||
. $e->getMessage(),
|
||||
0, $e
|
||||
0,
|
||||
$e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -226,15 +227,15 @@ class Rss extends AbstractFeed
|
|||
}
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getExtension('DublinCore')->getDate();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getExtension('Atom')->getDateModified();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = null;
|
||||
}
|
||||
|
||||
|
@ -277,7 +278,8 @@ class Rss extends AbstractFeed
|
|||
'Could not load date due to unrecognised'
|
||||
.' format (should follow RFC 822 or 2822):'
|
||||
. $e->getMessage(),
|
||||
0, $e
|
||||
0,
|
||||
$e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +288,7 @@ class Rss extends AbstractFeed
|
|||
}
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = null;
|
||||
}
|
||||
|
||||
|
@ -313,7 +315,7 @@ class Rss extends AbstractFeed
|
|||
$description = $this->xpath->evaluate('string(/rdf:RDF/rss:channel/rss:description)');
|
||||
}
|
||||
|
||||
if (!$description && $this->getExtension('DublinCore') !== null) {
|
||||
if (! $description && $this->getExtension('DublinCore') !== null) {
|
||||
$description = $this->getExtension('DublinCore')->getDescription();
|
||||
}
|
||||
|
||||
|
@ -321,7 +323,7 @@ class Rss extends AbstractFeed
|
|||
$description = $this->getExtension('Atom')->getDescription();
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -348,7 +350,7 @@ class Rss extends AbstractFeed
|
|||
$id = $this->xpath->evaluate('string(/rss/channel/guid)');
|
||||
}
|
||||
|
||||
if (!$id && $this->getExtension('DublinCore') !== null) {
|
||||
if (! $id && $this->getExtension('DublinCore') !== null) {
|
||||
$id = $this->getExtension('DublinCore')->getId();
|
||||
}
|
||||
|
||||
|
@ -356,7 +358,7 @@ class Rss extends AbstractFeed
|
|||
$id = $this->getExtension('Atom')->getId();
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
if ($this->getLink()) {
|
||||
$id = $this->getLink();
|
||||
} elseif ($this->getTitle()) {
|
||||
|
@ -443,7 +445,7 @@ class Rss extends AbstractFeed
|
|||
$language = $this->xpath->evaluate('string(/rss/channel/language)');
|
||||
}
|
||||
|
||||
if (!$language && $this->getExtension('DublinCore') !== null) {
|
||||
if (! $language && $this->getExtension('DublinCore') !== null) {
|
||||
$language = $this->getExtension('DublinCore')->getLanguage();
|
||||
}
|
||||
|
||||
|
@ -451,11 +453,11 @@ class Rss extends AbstractFeed
|
|||
$language = $this->getExtension('Atom')->getLanguage();
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = $this->xpath->evaluate('string(//@xml:lang[1])');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
|
@ -486,7 +488,7 @@ class Rss extends AbstractFeed
|
|||
$link = $this->getExtension('Atom')->getLink();
|
||||
}
|
||||
|
||||
if (!$link) {
|
||||
if (! $link) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
|
@ -535,7 +537,7 @@ class Rss extends AbstractFeed
|
|||
$generator = $this->xpath->evaluate('string(/rss/channel/generator)');
|
||||
}
|
||||
|
||||
if (!$generator) {
|
||||
if (! $generator) {
|
||||
if ($this->getType() !== Reader\Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Reader\Reader::TYPE_RSS_090) {
|
||||
$generator = $this->xpath->evaluate('string(/rss/channel/atom:generator)');
|
||||
|
@ -548,7 +550,7 @@ class Rss extends AbstractFeed
|
|||
$generator = $this->getExtension('Atom')->getGenerator();
|
||||
}
|
||||
|
||||
if (!$generator) {
|
||||
if (! $generator) {
|
||||
$generator = null;
|
||||
}
|
||||
|
||||
|
@ -575,15 +577,15 @@ class Rss extends AbstractFeed
|
|||
$title = $this->xpath->evaluate('string(/rdf:RDF/rss:channel/rss:title)');
|
||||
}
|
||||
|
||||
if (!$title && $this->getExtension('DublinCore') !== null) {
|
||||
if (! $title && $this->getExtension('DublinCore') !== null) {
|
||||
$title = $this->getExtension('DublinCore')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = $this->getExtension('Atom')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,14 +41,14 @@ class FeedSet extends ArrayObject
|
|||
{
|
||||
foreach ($links as $link) {
|
||||
if (strtolower($link->getAttribute('rel')) !== 'alternate'
|
||||
|| !$link->getAttribute('type') || !$link->getAttribute('href')) {
|
||||
|| ! $link->getAttribute('type') || ! $link->getAttribute('href')) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($this->rss) && $link->getAttribute('type') == 'application/rss+xml') {
|
||||
if (! isset($this->rss) && $link->getAttribute('type') == 'application/rss+xml') {
|
||||
$this->rss = $this->absolutiseUri(trim($link->getAttribute('href')), $uri);
|
||||
} elseif (!isset($this->atom) && $link->getAttribute('type') == 'application/atom+xml') {
|
||||
} elseif (! isset($this->atom) && $link->getAttribute('type') == 'application/atom+xml') {
|
||||
$this->atom = $this->absolutiseUri(trim($link->getAttribute('href')), $uri);
|
||||
} elseif (!isset($this->rdf) && $link->getAttribute('type') == 'application/rdf+xml') {
|
||||
} elseif (! isset($this->rdf) && $link->getAttribute('type') == 'application/rdf+xml') {
|
||||
$this->rdf = $this->absolutiseUri(trim($link->getAttribute('href')), $uri);
|
||||
}
|
||||
$this[] = new static([
|
||||
|
@ -61,33 +61,73 @@ class FeedSet extends ArrayObject
|
|||
|
||||
/**
|
||||
* Attempt to turn a relative URI into an absolute URI
|
||||
*
|
||||
* @param string $link
|
||||
* @param string $uri OPTIONAL
|
||||
* @return string|null absolutised link or null if invalid
|
||||
*/
|
||||
protected function absolutiseUri($link, $uri = null)
|
||||
{
|
||||
$linkUri = Uri::factory($link);
|
||||
if (!$linkUri->isAbsolute() or !$linkUri->isValid()) {
|
||||
if ($uri !== null) {
|
||||
$uri = Uri::factory($uri);
|
||||
|
||||
if ($link[0] !== '/') {
|
||||
$link = $uri->getPath() . '/' . $link;
|
||||
}
|
||||
|
||||
$link = sprintf(
|
||||
'%s://%s/%s',
|
||||
($uri->getScheme() ?: 'http'),
|
||||
$uri->getHost(),
|
||||
$this->canonicalizePath($link)
|
||||
);
|
||||
|
||||
if (!Uri::factory($link)->isValid()) {
|
||||
$link = null;
|
||||
}
|
||||
}
|
||||
if ($linkUri->isAbsolute()) {
|
||||
// invalid absolute link can not be recovered
|
||||
return $linkUri->isValid() ? $link : null;
|
||||
}
|
||||
|
||||
$scheme = 'http';
|
||||
if ($uri !== null) {
|
||||
$uri = Uri::factory($uri);
|
||||
$scheme = $uri->getScheme() ?: $scheme;
|
||||
}
|
||||
|
||||
if ($linkUri->getHost()) {
|
||||
$link = $this->resolveSchemeRelativeUri($link, $scheme);
|
||||
} elseif ($uri !== null) {
|
||||
$link = $this->resolveRelativeUri($link, $scheme, $uri->getHost(), $uri->getPath());
|
||||
}
|
||||
|
||||
if (! Uri::factory($link)->isValid()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves scheme relative link to absolute
|
||||
*
|
||||
* @param string $link
|
||||
* @param string $scheme
|
||||
* @return string
|
||||
*/
|
||||
private function resolveSchemeRelativeUri($link, $scheme)
|
||||
{
|
||||
$link = ltrim($link, '/');
|
||||
return sprintf('%s://%s', $scheme, $link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves relative link to absolute
|
||||
*
|
||||
* @param string $link
|
||||
* @param string $scheme
|
||||
* @param string $host
|
||||
* @param string $uriPath
|
||||
* @return string
|
||||
*/
|
||||
private function resolveRelativeUri($link, $scheme, $host, $uriPath)
|
||||
{
|
||||
if ($link[0] !== '/') {
|
||||
$link = $uriPath . '/' . $link;
|
||||
}
|
||||
return sprintf(
|
||||
'%s://%s/%s',
|
||||
$scheme,
|
||||
$host,
|
||||
$this->canonicalizePath($link)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Canonicalize relative path
|
||||
*/
|
||||
|
@ -117,8 +157,8 @@ class FeedSet extends ArrayObject
|
|||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
if ($offset == 'feed' && !$this->offsetExists('feed')) {
|
||||
if (!$this->offsetExists('href')) {
|
||||
if ($offset == 'feed' && ! $this->offsetExists('feed')) {
|
||||
if (! $this->offsetExists('href')) {
|
||||
return;
|
||||
}
|
||||
$feed = Reader::import($this->offsetGet('href'));
|
||||
|
|
33
web/vendor/zendframework/zend-feed/src/Reader/Http/HeaderAwareClientInterface.php
vendored
Normal file
33
web/vendor/zendframework/zend-feed/src/Reader/Http/HeaderAwareClientInterface.php
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
interface HeaderAwareClientInterface extends ClientInterface
|
||||
{
|
||||
/**
|
||||
* Allow specifying headers to use when fetching a feed.
|
||||
*
|
||||
* Headers MUST be in the format:
|
||||
*
|
||||
* <code>
|
||||
* [
|
||||
* 'header-name' => [
|
||||
* 'header',
|
||||
* 'values'
|
||||
* ]
|
||||
* ]
|
||||
* </code>
|
||||
*
|
||||
* @param string $uri
|
||||
* @param array $headers
|
||||
* @return HeaderAwareResponseInterface
|
||||
*/
|
||||
public function get($uri, array $headers = []);
|
||||
}
|
28
web/vendor/zendframework/zend-feed/src/Reader/Http/HeaderAwareResponseInterface.php
vendored
Normal file
28
web/vendor/zendframework/zend-feed/src/Reader/Http/HeaderAwareResponseInterface.php
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
interface HeaderAwareResponseInterface extends ResponseInterface
|
||||
{
|
||||
/**
|
||||
* Retrieve a header (as a single line) from the response.
|
||||
*
|
||||
* Header name lookups MUST be case insensitive.
|
||||
*
|
||||
* Since the only header values the feed reader consumes are singular
|
||||
* in nature, this method is expected to return a string, and not
|
||||
* an array of values.
|
||||
*
|
||||
* @param string $name Header name to retrieve.
|
||||
* @param mixed $default Default value to use if header is not present.
|
||||
* @return string
|
||||
*/
|
||||
public function getHeaderLine($name, $default = null);
|
||||
}
|
68
web/vendor/zendframework/zend-feed/src/Reader/Http/Psr7ResponseDecorator.php
vendored
Normal file
68
web/vendor/zendframework/zend-feed/src/Reader/Http/Psr7ResponseDecorator.php
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface as Psr7ResponseInterface;
|
||||
|
||||
/**
|
||||
* ResponseInterface wrapper for a PSR-7 response.
|
||||
*/
|
||||
class Psr7ResponseDecorator implements HeaderAwareResponseInterface
|
||||
{
|
||||
/**
|
||||
* @var Psr7ResponseInterface
|
||||
*/
|
||||
private $decoratedResponse;
|
||||
|
||||
/**
|
||||
* @param Psr7ResponseInterface $response
|
||||
*/
|
||||
public function __construct(Psr7ResponseInterface $response)
|
||||
{
|
||||
$this->decoratedResponse = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original PSR-7 response being decorated.
|
||||
*
|
||||
* @return Psr7ResponseInterface
|
||||
*/
|
||||
public function getDecoratedResponse()
|
||||
{
|
||||
return $this->decoratedResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getBody()
|
||||
{
|
||||
return (string) $this->decoratedResponse->getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->decoratedResponse->getStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getHeaderLine($name, $default = null)
|
||||
{
|
||||
if (! $this->decoratedResponse->hasHeader($name)) {
|
||||
return $default;
|
||||
}
|
||||
return $this->decoratedResponse->getHeaderLine($name);
|
||||
}
|
||||
}
|
175
web/vendor/zendframework/zend-feed/src/Reader/Http/Response.php
vendored
Normal file
175
web/vendor/zendframework/zend-feed/src/Reader/Http/Response.php
vendored
Normal file
|
@ -0,0 +1,175 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
use Zend\Feed\Reader\Exception;
|
||||
|
||||
class Response implements HeaderAwareResponseInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $body;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $headers;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $statusCode;
|
||||
|
||||
/**
|
||||
* @param int $statusCode
|
||||
* @param string|object $body
|
||||
* @param array $headers
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function __construct($statusCode, $body = '', array $headers = [])
|
||||
{
|
||||
$this->validateStatusCode($statusCode);
|
||||
$this->validateBody($body);
|
||||
$this->validateHeaders($headers);
|
||||
|
||||
$this->statusCode = (int) $statusCode;
|
||||
$this->body = (string) $body;
|
||||
$this->headers = $this->normalizeHeaders($headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getHeaderLine($name, $default = null)
|
||||
{
|
||||
$normalizedName = strtolower($name);
|
||||
return isset($this->headers[$normalizedName])
|
||||
? $this->headers[$normalizedName]
|
||||
: $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that we have a status code argument that will work for our context.
|
||||
*
|
||||
* @param mixed $body
|
||||
* @throws Exception\InvalidArgumentException for arguments not castable
|
||||
* to integer HTTP status codes.
|
||||
*/
|
||||
private function validateStatusCode($statusCode)
|
||||
{
|
||||
if (! is_numeric($statusCode)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects a numeric status code; received %s',
|
||||
__CLASS__,
|
||||
(is_object($statusCode) ? get_class($statusCode) : gettype($statusCode))
|
||||
));
|
||||
}
|
||||
|
||||
if (100 > $statusCode || 599 < $statusCode) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects an integer status code between 100 and 599 inclusive; received %s',
|
||||
__CLASS__,
|
||||
$statusCode
|
||||
));
|
||||
}
|
||||
|
||||
if (intval($statusCode) != $statusCode) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects an integer status code; received %s',
|
||||
__CLASS__,
|
||||
$statusCode
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that we have a body argument that will work for our context.
|
||||
*
|
||||
* @param mixed $body
|
||||
* @throws Exception\InvalidArgumentException for arguments not castable
|
||||
* to strings.
|
||||
*/
|
||||
private function validateBody($body)
|
||||
{
|
||||
if (is_string($body)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_object($body) && method_exists($body, '__toString')) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects a string body, or an object that can cast to string; received %s',
|
||||
__CLASS__,
|
||||
(is_object($body) ? get_class($body) : gettype($body))
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate header values.
|
||||
*
|
||||
* @param array $headers
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
private function validateHeaders(array $headers)
|
||||
{
|
||||
foreach ($headers as $name => $value) {
|
||||
if (! is_string($name) || is_numeric($name) || empty($name)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Header names provided to %s must be non-empty, non-numeric strings; received %s',
|
||||
__CLASS__,
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
if (! is_string($value) && ! is_numeric($value)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Individual header values provided to %s must be a string or numeric; received %s for header %s',
|
||||
__CLASS__,
|
||||
(is_object($value) ? get_class($value) : gettype($value)),
|
||||
$name
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize header names to lowercase.
|
||||
*
|
||||
* @param array $headers
|
||||
* @return array
|
||||
*/
|
||||
private function normalizeHeaders(array $headers)
|
||||
{
|
||||
$normalized = [];
|
||||
foreach ($headers as $name => $value) {
|
||||
$normalized[strtolower($name)] = $value;
|
||||
}
|
||||
return $normalized;
|
||||
}
|
||||
}
|
118
web/vendor/zendframework/zend-feed/src/Reader/Http/ZendHttpClientDecorator.php
vendored
Normal file
118
web/vendor/zendframework/zend-feed/src/Reader/Http/ZendHttpClientDecorator.php
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
use Zend\Http\Client as ZendHttpClient;
|
||||
use Zend\Http\Headers;
|
||||
use Zend\Feed\Reader\Exception;
|
||||
|
||||
class ZendHttpClientDecorator implements HeaderAwareClientInterface
|
||||
{
|
||||
/**
|
||||
* @var ZendHttpClient
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @param ZendHttpClient $client
|
||||
*/
|
||||
public function __construct(ZendHttpClient $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ZendHttpClient
|
||||
*/
|
||||
public function getDecoratedClient()
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get($uri, array $headers = [])
|
||||
{
|
||||
$this->client->resetParameters();
|
||||
$this->client->setMethod('GET');
|
||||
$this->client->setHeaders(new Headers());
|
||||
$this->client->setUri($uri);
|
||||
if (! empty($headers)) {
|
||||
$this->injectHeaders($headers);
|
||||
}
|
||||
$response = $this->client->send();
|
||||
|
||||
return new Response(
|
||||
$response->getStatusCode(),
|
||||
$response->getBody(),
|
||||
$this->prepareResponseHeaders($response->getHeaders())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject header values into the client.
|
||||
*
|
||||
* @param array $headerValues
|
||||
*/
|
||||
private function injectHeaders(array $headerValues)
|
||||
{
|
||||
$headers = $this->client->getRequest()->getHeaders();
|
||||
foreach ($headerValues as $name => $values) {
|
||||
if (! is_string($name) || is_numeric($name) || empty($name)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Header names provided to %s::get must be non-empty, non-numeric strings; received %s',
|
||||
__CLASS__,
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
if (! is_array($values)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Header values provided to %s::get must be arrays of values; received %s',
|
||||
__CLASS__,
|
||||
(is_object($values) ? get_class($values) : gettype($values))
|
||||
));
|
||||
}
|
||||
|
||||
foreach ($values as $value) {
|
||||
if (! is_string($value) && ! is_numeric($value)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Individual header values provided to %s::get must be strings or numbers; '
|
||||
. 'received %s for header %s',
|
||||
__CLASS__,
|
||||
(is_object($value) ? get_class($value) : gettype($value)),
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
$headers->addHeaderLine($name, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize headers to use with HeaderAwareResponseInterface.
|
||||
*
|
||||
* Ensures multi-value headers are represented as a single string, via
|
||||
* comma concatenation.
|
||||
*
|
||||
* @param Headers $headers
|
||||
* @return array
|
||||
*/
|
||||
private function prepareResponseHeaders(Headers $headers)
|
||||
{
|
||||
$normalized = [];
|
||||
foreach ($headers->toArray() as $name => $value) {
|
||||
$normalized[$name] = is_array($value) ? implode(', ', $value) : $value;
|
||||
}
|
||||
return $normalized;
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ use DOMXPath;
|
|||
use Zend\Cache\Storage\StorageInterface as CacheStorage;
|
||||
use Zend\Http as ZendHttp;
|
||||
use Zend\Stdlib\ErrorHandler;
|
||||
use Zend\Feed\Reader\Exception\InvalidHttpClientException;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -57,7 +58,7 @@ class Reader implements ReaderImportInterface
|
|||
/**
|
||||
* HTTP client object to use for retrieving feeds
|
||||
*
|
||||
* @var ZendHttp\Client
|
||||
* @var Http\ClientInterface
|
||||
*/
|
||||
protected static $httpClient = null;
|
||||
|
||||
|
@ -117,23 +118,30 @@ class Reader implements ReaderImportInterface
|
|||
*
|
||||
* Sets the HTTP client object to use for retrieving the feeds.
|
||||
*
|
||||
* @param ZendHttp\Client $httpClient
|
||||
* @param ZendHttp\Client | Http\ClientInterface $httpClient
|
||||
* @return void
|
||||
*/
|
||||
public static function setHttpClient(ZendHttp\Client $httpClient)
|
||||
public static function setHttpClient($httpClient)
|
||||
{
|
||||
if ($httpClient instanceof ZendHttp\Client) {
|
||||
$httpClient = new Http\ZendHttpClientDecorator($httpClient);
|
||||
}
|
||||
|
||||
if (! $httpClient instanceof Http\ClientInterface) {
|
||||
throw new InvalidHttpClientException();
|
||||
}
|
||||
static::$httpClient = $httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HTTP client object. If none is set, a new ZendHttp\Client will be used.
|
||||
*
|
||||
* @return ZendHttp\Client
|
||||
* @return Http\ClientInterface
|
||||
*/
|
||||
public static function getHttpClient()
|
||||
{
|
||||
if (!static::$httpClient instanceof ZendHttp\Client) {
|
||||
static::$httpClient = new ZendHttp\Client();
|
||||
if (! static::$httpClient) {
|
||||
static::$httpClient = new Http\ZendHttpClientDecorator(new ZendHttp\Client());
|
||||
}
|
||||
|
||||
return static::$httpClient;
|
||||
|
@ -189,17 +197,16 @@ class Reader implements ReaderImportInterface
|
|||
*/
|
||||
public static function import($uri, $etag = null, $lastModified = null)
|
||||
{
|
||||
$cache = self::getCache();
|
||||
$client = self::getHttpClient();
|
||||
$client->resetParameters();
|
||||
$headers = new ZendHttp\Headers();
|
||||
$client->setHeaders($headers);
|
||||
$client->setUri($uri);
|
||||
$cache = self::getCache();
|
||||
$client = self::getHttpClient();
|
||||
$cacheId = 'Zend_Feed_Reader_' . md5($uri);
|
||||
|
||||
if (static::$httpConditionalGet && $cache) {
|
||||
$data = $cache->getItem($cacheId);
|
||||
if ($data) {
|
||||
$headers = [];
|
||||
$data = $cache->getItem($cacheId);
|
||||
if ($data && $client instanceof Http\HeaderAwareClientInterface) {
|
||||
// Only check for ETag and last modified values in the cache
|
||||
// if we have a client capable of emitting headers in the first place.
|
||||
if ($etag === null) {
|
||||
$etag = $cache->getItem($cacheId . '_etag');
|
||||
}
|
||||
|
@ -207,26 +214,31 @@ class Reader implements ReaderImportInterface
|
|||
$lastModified = $cache->getItem($cacheId . '_lastmodified');
|
||||
}
|
||||
if ($etag) {
|
||||
$headers->addHeaderLine('If-None-Match', $etag);
|
||||
$headers['If-None-Match'] = [$etag];
|
||||
}
|
||||
if ($lastModified) {
|
||||
$headers->addHeaderLine('If-Modified-Since', $lastModified);
|
||||
$headers['If-Modified-Since'] = [$lastModified];
|
||||
}
|
||||
}
|
||||
$response = $client->send();
|
||||
$response = $client->get($uri, $headers);
|
||||
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 304) {
|
||||
throw new Exception\RuntimeException('Feed failed to load, got response code ' . $response->getStatusCode());
|
||||
throw new Exception\RuntimeException(
|
||||
'Feed failed to load, got response code ' . $response->getStatusCode()
|
||||
);
|
||||
}
|
||||
if ($response->getStatusCode() == 304) {
|
||||
$responseXml = $data;
|
||||
} else {
|
||||
$responseXml = $response->getBody();
|
||||
$cache->setItem($cacheId, $responseXml);
|
||||
if ($response->getHeaders()->get('ETag')) {
|
||||
$cache->setItem($cacheId . '_etag', $response->getHeaders()->get('ETag')->getFieldValue());
|
||||
}
|
||||
if ($response->getHeaders()->get('Last-Modified')) {
|
||||
$cache->setItem($cacheId . '_lastmodified', $response->getHeaders()->get('Last-Modified')->getFieldValue());
|
||||
|
||||
if ($response instanceof Http\HeaderAwareResponseInterface) {
|
||||
if ($response->getHeaderLine('ETag', false)) {
|
||||
$cache->setItem($cacheId . '_etag', $response->getHeaderLine('ETag'));
|
||||
}
|
||||
if ($response->getHeaderLine('Last-Modified', false)) {
|
||||
$cache->setItem($cacheId . '_lastmodified', $response->getHeaderLine('Last-Modified'));
|
||||
}
|
||||
}
|
||||
}
|
||||
return static::importString($responseXml);
|
||||
|
@ -235,17 +247,21 @@ class Reader implements ReaderImportInterface
|
|||
if ($data) {
|
||||
return static::importString($data);
|
||||
}
|
||||
$response = $client->send();
|
||||
$response = $client->get($uri);
|
||||
if ((int) $response->getStatusCode() !== 200) {
|
||||
throw new Exception\RuntimeException('Feed failed to load, got response code ' . $response->getStatusCode());
|
||||
throw new Exception\RuntimeException(
|
||||
'Feed failed to load, got response code ' . $response->getStatusCode()
|
||||
);
|
||||
}
|
||||
$responseXml = $response->getBody();
|
||||
$cache->setItem($cacheId, $responseXml);
|
||||
return static::importString($responseXml);
|
||||
} else {
|
||||
$response = $client->send();
|
||||
$response = $client->get($uri);
|
||||
if ((int) $response->getStatusCode() !== 200) {
|
||||
throw new Exception\RuntimeException('Feed failed to load, got response code ' . $response->getStatusCode());
|
||||
throw new Exception\RuntimeException(
|
||||
'Feed failed to load, got response code ' . $response->getStatusCode()
|
||||
);
|
||||
}
|
||||
$reader = static::importString($response->getBody());
|
||||
$reader->setOriginalSourceUri($uri);
|
||||
|
@ -270,7 +286,7 @@ class Reader implements ReaderImportInterface
|
|||
public static function importRemoteFeed($uri, Http\ClientInterface $client)
|
||||
{
|
||||
$response = $client->get($uri);
|
||||
if (!$response instanceof Http\ResponseInterface) {
|
||||
if (! $response instanceof Http\ResponseInterface) {
|
||||
throw new Exception\RuntimeException(sprintf(
|
||||
'Did not receive a %s\Http\ResponseInterface from the provided HTTP client; received "%s"',
|
||||
__NAMESPACE__,
|
||||
|
@ -279,7 +295,9 @@ class Reader implements ReaderImportInterface
|
|||
}
|
||||
|
||||
if ((int) $response->getStatusCode() !== 200) {
|
||||
throw new Exception\RuntimeException('Feed failed to load, got response code ' . $response->getStatusCode());
|
||||
throw new Exception\RuntimeException(
|
||||
'Feed failed to load, got response code ' . $response->getStatusCode()
|
||||
);
|
||||
}
|
||||
$reader = static::importString($response->getBody());
|
||||
$reader->setOriginalSourceUri($uri);
|
||||
|
@ -297,7 +315,7 @@ class Reader implements ReaderImportInterface
|
|||
public static function importString($string)
|
||||
{
|
||||
$trimmed = trim($string);
|
||||
if (!is_string($string) || empty($trimmed)) {
|
||||
if (! is_string($string) || empty($trimmed)) {
|
||||
throw new Exception\InvalidArgumentException('Only non empty strings are allowed as input');
|
||||
}
|
||||
|
||||
|
@ -315,7 +333,7 @@ class Reader implements ReaderImportInterface
|
|||
libxml_disable_entity_loader($oldValue);
|
||||
libxml_use_internal_errors($libxmlErrflag);
|
||||
|
||||
if (!$status) {
|
||||
if (! $status) {
|
||||
// Build error message
|
||||
$error = libxml_get_last_error();
|
||||
if ($error && $error->message) {
|
||||
|
@ -371,11 +389,12 @@ class Reader implements ReaderImportInterface
|
|||
*/
|
||||
public static function findFeedLinks($uri)
|
||||
{
|
||||
$client = static::getHttpClient();
|
||||
$client->setUri($uri);
|
||||
$response = $client->send();
|
||||
$client = static::getHttpClient();
|
||||
$response = $client->get($uri);
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
throw new Exception\RuntimeException("Failed to access $uri, got response code " . $response->getStatusCode());
|
||||
throw new Exception\RuntimeException(
|
||||
"Failed to access $uri, got response code " . $response->getStatusCode()
|
||||
);
|
||||
}
|
||||
$responseHtml = $response->getBody();
|
||||
$libxmlErrflag = libxml_use_internal_errors(true);
|
||||
|
@ -384,7 +403,7 @@ class Reader implements ReaderImportInterface
|
|||
$status = $dom->loadHTML(trim($responseHtml));
|
||||
libxml_disable_entity_loader($oldValue);
|
||||
libxml_use_internal_errors($libxmlErrflag);
|
||||
if (!$status) {
|
||||
if (! $status) {
|
||||
// Build error message
|
||||
$error = libxml_get_last_error();
|
||||
if ($error && $error->message) {
|
||||
|
@ -416,8 +435,8 @@ class Reader implements ReaderImportInterface
|
|||
$dom = $feed->getDomDocument();
|
||||
} elseif ($feed instanceof DOMDocument) {
|
||||
$dom = $feed;
|
||||
} elseif (is_string($feed) && !empty($feed)) {
|
||||
ErrorHandler::start(E_NOTICE|E_WARNING);
|
||||
} elseif (is_string($feed) && ! empty($feed)) {
|
||||
ErrorHandler::start(E_NOTICE | E_WARNING);
|
||||
ini_set('track_errors', 1);
|
||||
$oldValue = libxml_disable_entity_loader(true);
|
||||
$dom = new DOMDocument;
|
||||
|
@ -432,8 +451,8 @@ class Reader implements ReaderImportInterface
|
|||
libxml_disable_entity_loader($oldValue);
|
||||
ini_restore('track_errors');
|
||||
ErrorHandler::stop();
|
||||
if (!$status) {
|
||||
if (!isset($phpErrormsg)) {
|
||||
if (! $status) {
|
||||
if (! isset($phpErrormsg)) {
|
||||
if (function_exists('xdebug_is_enabled')) {
|
||||
$phpErrormsg = '(error message not available, when XDebug is running)';
|
||||
} else {
|
||||
|
@ -543,7 +562,7 @@ class Reader implements ReaderImportInterface
|
|||
*/
|
||||
public static function getExtensionManager()
|
||||
{
|
||||
if (!isset(static::$extensionManager)) {
|
||||
if (! isset(static::$extensionManager)) {
|
||||
static::setExtensionManager(new StandaloneExtensionManager());
|
||||
}
|
||||
return static::$extensionManager;
|
||||
|
@ -567,7 +586,7 @@ class Reader implements ReaderImportInterface
|
|||
}
|
||||
}
|
||||
|
||||
if (!$manager->has($feedName) && !$manager->has($entryName)) {
|
||||
if (! $manager->has($feedName) && ! $manager->has($entryName)) {
|
||||
throw new Exception\RuntimeException('Could not load extension: ' . $name
|
||||
. ' using Plugin Loader. Check prefix paths are configured and extension exists.');
|
||||
}
|
||||
|
|
16
web/vendor/zendframework/zend-feed/src/Uri.php
vendored
16
web/vendor/zendframework/zend-feed/src/Uri.php
vendored
|
@ -76,13 +76,13 @@ class Uri
|
|||
return;
|
||||
}
|
||||
|
||||
$this->scheme = isset($parsed['scheme']) ? $parsed['scheme'] : null;
|
||||
$this->host = isset($parsed['host']) ? $parsed['host'] : null;
|
||||
$this->port = isset($parsed['port']) ? $parsed['port'] : null;
|
||||
$this->user = isset($parsed['user']) ? $parsed['user'] : null;
|
||||
$this->pass = isset($parsed['pass']) ? $parsed['pass'] : null;
|
||||
$this->path = isset($parsed['path']) ? $parsed['path'] : null;
|
||||
$this->query = isset($parsed['query']) ? $parsed['query'] : null;
|
||||
$this->scheme = isset($parsed['scheme']) ? $parsed['scheme'] : null;
|
||||
$this->host = isset($parsed['host']) ? $parsed['host'] : null;
|
||||
$this->port = isset($parsed['port']) ? $parsed['port'] : null;
|
||||
$this->user = isset($parsed['user']) ? $parsed['user'] : null;
|
||||
$this->pass = isset($parsed['pass']) ? $parsed['pass'] : null;
|
||||
$this->path = isset($parsed['path']) ? $parsed['path'] : null;
|
||||
$this->query = isset($parsed['query']) ? $parsed['query'] : null;
|
||||
$this->fragment = isset($parsed['fragment']) ? $parsed['fragment'] : null;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class Uri
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($this->scheme && !in_array($this->scheme, $this->validSchemes)) {
|
||||
if ($this->scheme && ! in_array($this->scheme, $this->validSchemes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,26 +61,29 @@ class AbstractFeed
|
|||
public function addAuthor(array $author)
|
||||
{
|
||||
// Check array values
|
||||
if (!array_key_exists('name', $author)
|
||||
if (! array_key_exists('name', $author)
|
||||
|| empty($author['name'])
|
||||
|| !is_string($author['name'])
|
||||
|| ! is_string($author['name'])
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: author array must include a "name" key with a non-empty string value');
|
||||
'Invalid parameter: author array must include a "name" key with a non-empty string value'
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($author['email'])) {
|
||||
if (empty($author['email']) || !is_string($author['email'])) {
|
||||
if (empty($author['email']) || ! is_string($author['email'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "email" array value must be a non-empty string');
|
||||
'Invalid parameter: "email" array value must be a non-empty string'
|
||||
);
|
||||
}
|
||||
}
|
||||
if (isset($author['uri'])) {
|
||||
if (empty($author['uri']) || !is_string($author['uri']) ||
|
||||
!Uri::factory($author['uri'])->isValid()
|
||||
if (empty($author['uri']) || ! is_string($author['uri']) ||
|
||||
! Uri::factory($author['uri'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI');
|
||||
'Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +117,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setCopyright($copyright)
|
||||
{
|
||||
if (empty($copyright) || !is_string($copyright)) {
|
||||
if (empty($copyright) || ! is_string($copyright)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['copyright'] = $copyright;
|
||||
|
@ -135,7 +138,7 @@ class AbstractFeed
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp'
|
||||
. ' passed as parameter');
|
||||
}
|
||||
|
@ -157,7 +160,7 @@ class AbstractFeed
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp'
|
||||
. ' passed as parameter');
|
||||
}
|
||||
|
@ -179,7 +182,7 @@ class AbstractFeed
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp'
|
||||
. ' passed as parameter');
|
||||
}
|
||||
|
@ -197,7 +200,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
if (empty($description) || !is_string($description)) {
|
||||
if (empty($description) || ! is_string($description)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['description'] = $description;
|
||||
|
@ -218,36 +221,44 @@ class AbstractFeed
|
|||
{
|
||||
if (is_array($name)) {
|
||||
$data = $name;
|
||||
if (empty($data['name']) || !is_string($data['name'])) {
|
||||
if (empty($data['name']) || ! is_string($data['name'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "name" must be a non-empty string');
|
||||
}
|
||||
$generator = ['name' => $data['name']];
|
||||
if (isset($data['version'])) {
|
||||
if (empty($data['version']) || !is_string($data['version'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "version" must be a non-empty string');
|
||||
if (empty($data['version']) || ! is_string($data['version'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "version" must be a non-empty string'
|
||||
);
|
||||
}
|
||||
$generator['version'] = $data['version'];
|
||||
}
|
||||
if (isset($data['uri'])) {
|
||||
if (empty($data['uri']) || !is_string($data['uri']) || !Uri::factory($data['uri'])->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI');
|
||||
if (empty($data['uri']) || ! is_string($data['uri']) || ! Uri::factory($data['uri'])->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$generator['uri'] = $data['uri'];
|
||||
}
|
||||
} else {
|
||||
if (empty($name) || !is_string($name)) {
|
||||
if (empty($name) || ! is_string($name)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "name" must be a non-empty string');
|
||||
}
|
||||
$generator = ['name' => $name];
|
||||
if (isset($version)) {
|
||||
if (empty($version) || !is_string($version)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "version" must be a non-empty string');
|
||||
if (empty($version) || ! is_string($version)) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "version" must be a non-empty string'
|
||||
);
|
||||
}
|
||||
$generator['version'] = $version;
|
||||
}
|
||||
if (isset($uri)) {
|
||||
if (empty($uri) || !is_string($uri) || !Uri::factory($uri)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI');
|
||||
if (empty($uri) || ! is_string($uri) || ! Uri::factory($uri)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$generator['uri'] = $uri;
|
||||
}
|
||||
|
@ -266,11 +277,15 @@ class AbstractFeed
|
|||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
if ((empty($id) || !is_string($id) || !Uri::factory($id)->isValid())
|
||||
&& !preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", $id)
|
||||
&& !$this->_validateTagUri($id)
|
||||
// @codingStandardsIgnoreStart
|
||||
if ((empty($id) || ! is_string($id) || ! Uri::factory($id)->isValid())
|
||||
&& ! preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", $id)
|
||||
&& ! $this->_validateTagUri($id)
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string and valid URI/IRI');
|
||||
// @codingStandardsIgnoreEnd
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: parameter must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$this->data['id'] = $id;
|
||||
|
||||
|
@ -283,9 +298,15 @@ class AbstractFeed
|
|||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _validateTagUri($id)
|
||||
{
|
||||
if (preg_match('/^tag:(?P<name>.*),(?P<date>\d{4}-?\d{0,2}-?\d{0,2}):(?P<specific>.*)(.*:)*$/', $id, $matches)) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (preg_match(
|
||||
'/^tag:(?P<name>.*),(?P<date>\d{4}-?\d{0,2}-?\d{0,2}):(?P<specific>.*)(.*:)*$/',
|
||||
$id,
|
||||
$matches
|
||||
)) {
|
||||
$dvalid = false;
|
||||
$date = $matches['date'];
|
||||
$d6 = strtotime($date);
|
||||
|
@ -319,8 +340,8 @@ class AbstractFeed
|
|||
*/
|
||||
public function setImage(array $data)
|
||||
{
|
||||
if (empty($data['uri']) || !is_string($data['uri'])
|
||||
|| !Uri::factory($data['uri'])->isValid()
|
||||
if (empty($data['uri']) || ! is_string($data['uri'])
|
||||
|| ! Uri::factory($data['uri'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter \'uri\''
|
||||
. ' must be a non-empty string and valid URI/IRI');
|
||||
|
@ -339,7 +360,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setLanguage($language)
|
||||
{
|
||||
if (empty($language) || !is_string($language)) {
|
||||
if (empty($language) || ! is_string($language)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['language'] = $language;
|
||||
|
@ -356,8 +377,10 @@ class AbstractFeed
|
|||
*/
|
||||
public function setLink($link)
|
||||
{
|
||||
if (empty($link) || !is_string($link) || !Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string and valid URI/IRI');
|
||||
if (empty($link) || ! is_string($link) || ! Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: parameter must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$this->data['link'] = $link;
|
||||
|
||||
|
@ -374,11 +397,15 @@ class AbstractFeed
|
|||
*/
|
||||
public function setFeedLink($link, $type)
|
||||
{
|
||||
if (empty($link) || !is_string($link) || !Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "link"" must be a non-empty string and valid URI/IRI');
|
||||
if (empty($link) || ! is_string($link) || ! Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "link"" must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
if (!in_array(strtolower($type), ['rss', 'rdf', 'atom'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "type"; You must declare the type of feed the link points to, i.e. RSS, RDF or Atom');
|
||||
if (! in_array(strtolower($type), ['rss', 'rdf', 'atom'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "type"; You must declare the type of feed the link points to, i.e. RSS, RDF or Atom'
|
||||
);
|
||||
}
|
||||
$this->data['feedLinks'][strtolower($type)] = $link;
|
||||
|
||||
|
@ -394,7 +421,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
if (empty($title) || !is_string($title)) {
|
||||
if (empty($title) || ! is_string($title)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['title'] = $title;
|
||||
|
@ -411,7 +438,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setEncoding($encoding)
|
||||
{
|
||||
if (empty($encoding) || !is_string($encoding)) {
|
||||
if (empty($encoding) || ! is_string($encoding)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['encoding'] = $encoding;
|
||||
|
@ -428,7 +455,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setBaseUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "url" array value'
|
||||
. ' must be a non-empty string and valid URI/IRI');
|
||||
}
|
||||
|
@ -446,11 +473,11 @@ class AbstractFeed
|
|||
*/
|
||||
public function addHub($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "url" array value'
|
||||
. ' must be a non-empty string and valid URI/IRI');
|
||||
}
|
||||
if (!isset($this->data['hubs'])) {
|
||||
if (! isset($this->data['hubs'])) {
|
||||
$this->data['hubs'] = [];
|
||||
}
|
||||
$this->data['hubs'][] = $url;
|
||||
|
@ -482,21 +509,21 @@ class AbstractFeed
|
|||
*/
|
||||
public function addCategory(array $category)
|
||||
{
|
||||
if (!isset($category['term'])) {
|
||||
if (! isset($category['term'])) {
|
||||
throw new Exception\InvalidArgumentException('Each category must be an array and '
|
||||
. 'contain at least a "term" element containing the machine '
|
||||
. ' readable category name');
|
||||
}
|
||||
if (isset($category['scheme'])) {
|
||||
if (empty($category['scheme'])
|
||||
|| !is_string($category['scheme'])
|
||||
|| !Uri::factory($category['scheme'])->isValid()
|
||||
|| ! is_string($category['scheme'])
|
||||
|| ! Uri::factory($category['scheme'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('The Atom scheme or RSS domain of'
|
||||
. ' a category must be a valid URI');
|
||||
}
|
||||
}
|
||||
if (!isset($this->data['categories'])) {
|
||||
if (! isset($this->data['categories'])) {
|
||||
$this->data['categories'] = [];
|
||||
}
|
||||
$this->data['categories'][] = $category;
|
||||
|
@ -541,7 +568,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (!array_key_exists('authors', $this->data)) {
|
||||
if (! array_key_exists('authors', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['authors'];
|
||||
|
@ -554,7 +581,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getCopyright()
|
||||
{
|
||||
if (!array_key_exists('copyright', $this->data)) {
|
||||
if (! array_key_exists('copyright', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['copyright'];
|
||||
|
@ -567,7 +594,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
if (!array_key_exists('dateCreated', $this->data)) {
|
||||
if (! array_key_exists('dateCreated', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['dateCreated'];
|
||||
|
@ -580,7 +607,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
if (!array_key_exists('dateModified', $this->data)) {
|
||||
if (! array_key_exists('dateModified', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['dateModified'];
|
||||
|
@ -593,7 +620,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getLastBuildDate()
|
||||
{
|
||||
if (!array_key_exists('lastBuildDate', $this->data)) {
|
||||
if (! array_key_exists('lastBuildDate', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['lastBuildDate'];
|
||||
|
@ -606,7 +633,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (!array_key_exists('description', $this->data)) {
|
||||
if (! array_key_exists('description', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['description'];
|
||||
|
@ -619,7 +646,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getGenerator()
|
||||
{
|
||||
if (!array_key_exists('generator', $this->data)) {
|
||||
if (! array_key_exists('generator', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['generator'];
|
||||
|
@ -632,7 +659,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (!array_key_exists('id', $this->data)) {
|
||||
if (! array_key_exists('id', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['id'];
|
||||
|
@ -645,7 +672,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getImage()
|
||||
{
|
||||
if (!array_key_exists('image', $this->data)) {
|
||||
if (! array_key_exists('image', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['image'];
|
||||
|
@ -658,7 +685,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getLanguage()
|
||||
{
|
||||
if (!array_key_exists('language', $this->data)) {
|
||||
if (! array_key_exists('language', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['language'];
|
||||
|
@ -671,7 +698,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getLink()
|
||||
{
|
||||
if (!array_key_exists('link', $this->data)) {
|
||||
if (! array_key_exists('link', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['link'];
|
||||
|
@ -684,7 +711,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getFeedLinks()
|
||||
{
|
||||
if (!array_key_exists('feedLinks', $this->data)) {
|
||||
if (! array_key_exists('feedLinks', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['feedLinks'];
|
||||
|
@ -697,7 +724,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (!array_key_exists('title', $this->data)) {
|
||||
if (! array_key_exists('title', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['title'];
|
||||
|
@ -710,7 +737,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
if (!array_key_exists('encoding', $this->data)) {
|
||||
if (! array_key_exists('encoding', $this->data)) {
|
||||
return 'UTF-8';
|
||||
}
|
||||
return $this->data['encoding'];
|
||||
|
@ -723,7 +750,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getBaseUrl()
|
||||
{
|
||||
if (!array_key_exists('baseUrl', $this->data)) {
|
||||
if (! array_key_exists('baseUrl', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['baseUrl'];
|
||||
|
@ -736,7 +763,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getHubs()
|
||||
{
|
||||
if (!array_key_exists('hubs', $this->data)) {
|
||||
if (! array_key_exists('hubs', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['hubs'];
|
||||
|
@ -749,7 +776,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getCategories()
|
||||
{
|
||||
if (!array_key_exists('categories', $this->data)) {
|
||||
if (! array_key_exists('categories', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['categories'];
|
||||
|
@ -830,14 +857,18 @@ class AbstractFeed
|
|||
* @throws Exception\RuntimeException
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _loadExtensions()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$all = Writer::getExtensions();
|
||||
$manager = Writer::getExtensionManager();
|
||||
$exts = $all['feed'];
|
||||
foreach ($exts as $ext) {
|
||||
if (!$manager->has($ext)) {
|
||||
throw new Exception\RuntimeException(sprintf('Unable to load extension "%s"; could not resolve to class', $ext));
|
||||
if (! $manager->has($ext)) {
|
||||
throw new Exception\RuntimeException(
|
||||
sprintf('Unable to load extension "%s"; could not resolve to class', $ext)
|
||||
);
|
||||
}
|
||||
$this->extensions[$ext] = $manager->get($ext);
|
||||
$this->extensions[$ext]->setEncoding($this->getEncoding());
|
||||
|
|
|
@ -41,7 +41,7 @@ class Deleted
|
|||
*/
|
||||
public function setEncoding($encoding)
|
||||
{
|
||||
if (empty($encoding) || !is_string($encoding)) {
|
||||
if (empty($encoding) || ! is_string($encoding)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['encoding'] = $encoding;
|
||||
|
@ -56,7 +56,7 @@ class Deleted
|
|||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
if (!array_key_exists('encoding', $this->data)) {
|
||||
if (! array_key_exists('encoding', $this->data)) {
|
||||
return 'UTF-8';
|
||||
}
|
||||
return $this->data['encoding'];
|
||||
|
@ -110,7 +110,7 @@ class Deleted
|
|||
*/
|
||||
public function setReference($reference)
|
||||
{
|
||||
if (empty($reference) || !is_string($reference)) {
|
||||
if (empty($reference) || ! is_string($reference)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: reference must be a non-empty string');
|
||||
}
|
||||
$this->data['reference'] = $reference;
|
||||
|
@ -123,7 +123,7 @@ class Deleted
|
|||
*/
|
||||
public function getReference()
|
||||
{
|
||||
if (!array_key_exists('reference', $this->data)) {
|
||||
if (! array_key_exists('reference', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['reference'];
|
||||
|
@ -142,7 +142,7 @@ class Deleted
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp'
|
||||
. ' passed as parameter');
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ class Deleted
|
|||
*/
|
||||
public function getWhen()
|
||||
{
|
||||
if (!array_key_exists('when', $this->data)) {
|
||||
if (! array_key_exists('when', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['when'];
|
||||
|
@ -172,16 +172,16 @@ class Deleted
|
|||
public function setBy(array $by)
|
||||
{
|
||||
$author = [];
|
||||
if (!array_key_exists('name', $by)
|
||||
if (! array_key_exists('name', $by)
|
||||
|| empty($by['name'])
|
||||
|| !is_string($by['name'])
|
||||
|| ! is_string($by['name'])
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: author array must include a'
|
||||
. ' "name" key with a non-empty string value');
|
||||
}
|
||||
$author['name'] = $by['name'];
|
||||
if (isset($by['email'])) {
|
||||
if (empty($by['email']) || !is_string($by['email'])) {
|
||||
if (empty($by['email']) || ! is_string($by['email'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "email" array'
|
||||
. ' value must be a non-empty string');
|
||||
}
|
||||
|
@ -189,8 +189,8 @@ class Deleted
|
|||
}
|
||||
if (isset($by['uri'])) {
|
||||
if (empty($by['uri'])
|
||||
|| !is_string($by['uri'])
|
||||
|| !Uri::factory($by['uri'])->isValid()
|
||||
|| ! is_string($by['uri'])
|
||||
|| ! Uri::factory($by['uri'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "uri" array value must'
|
||||
. ' be a non-empty string and valid URI/IRI');
|
||||
|
@ -207,7 +207,7 @@ class Deleted
|
|||
*/
|
||||
public function getBy()
|
||||
{
|
||||
if (!array_key_exists('by', $this->data)) {
|
||||
if (! array_key_exists('by', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['by'];
|
||||
|
@ -228,7 +228,7 @@ class Deleted
|
|||
*/
|
||||
public function getComment()
|
||||
{
|
||||
if (!array_key_exists('comment', $this->data)) {
|
||||
if (! array_key_exists('comment', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['comment'];
|
||||
|
|
|
@ -64,26 +64,29 @@ class Entry
|
|||
public function addAuthor(array $author)
|
||||
{
|
||||
// Check array values
|
||||
if (!array_key_exists('name', $author)
|
||||
if (! array_key_exists('name', $author)
|
||||
|| empty($author['name'])
|
||||
|| !is_string($author['name'])
|
||||
|| ! is_string($author['name'])
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: author array must include a "name" key with a non-empty string value');
|
||||
'Invalid parameter: author array must include a "name" key with a non-empty string value'
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($author['email'])) {
|
||||
if (empty($author['email']) || !is_string($author['email'])) {
|
||||
if (empty($author['email']) || ! is_string($author['email'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "email" array value must be a non-empty string');
|
||||
'Invalid parameter: "email" array value must be a non-empty string'
|
||||
);
|
||||
}
|
||||
}
|
||||
if (isset($author['uri'])) {
|
||||
if (empty($author['uri']) || !is_string($author['uri']) ||
|
||||
!Uri::factory($author['uri'])->isValid()
|
||||
if (empty($author['uri']) || ! is_string($author['uri']) ||
|
||||
! Uri::factory($author['uri'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI');
|
||||
'Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +120,7 @@ class Entry
|
|||
*/
|
||||
public function setEncoding($encoding)
|
||||
{
|
||||
if (empty($encoding) || !is_string($encoding)) {
|
||||
if (empty($encoding) || ! is_string($encoding)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['encoding'] = $encoding;
|
||||
|
@ -132,7 +135,7 @@ class Entry
|
|||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
if (!array_key_exists('encoding', $this->data)) {
|
||||
if (! array_key_exists('encoding', $this->data)) {
|
||||
return 'UTF-8';
|
||||
}
|
||||
return $this->data['encoding'];
|
||||
|
@ -147,7 +150,7 @@ class Entry
|
|||
*/
|
||||
public function setCopyright($copyright)
|
||||
{
|
||||
if (empty($copyright) || !is_string($copyright)) {
|
||||
if (empty($copyright) || ! is_string($copyright)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['copyright'] = $copyright;
|
||||
|
@ -164,7 +167,7 @@ class Entry
|
|||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
if (empty($content) || !is_string($content)) {
|
||||
if (empty($content) || ! is_string($content)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['content'] = $content;
|
||||
|
@ -185,8 +188,10 @@ class Entry
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp passed as parameter');
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid DateTime object or UNIX Timestamp passed as parameter'
|
||||
);
|
||||
}
|
||||
$this->data['dateCreated'] = $date;
|
||||
|
||||
|
@ -206,8 +211,10 @@ class Entry
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp passed as parameter');
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid DateTime object or UNIX Timestamp passed as parameter'
|
||||
);
|
||||
}
|
||||
$this->data['dateModified'] = $date;
|
||||
|
||||
|
@ -223,7 +230,7 @@ class Entry
|
|||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
if (empty($description) || !is_string($description)) {
|
||||
if (empty($description) || ! is_string($description)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['description'] = $description;
|
||||
|
@ -240,7 +247,7 @@ class Entry
|
|||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
if (empty($id) || !is_string($id)) {
|
||||
if (empty($id) || ! is_string($id)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['id'] = $id;
|
||||
|
@ -257,8 +264,10 @@ class Entry
|
|||
*/
|
||||
public function setLink($link)
|
||||
{
|
||||
if (empty($link) || !is_string($link) || !Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string and valid URI/IRI');
|
||||
if (empty($link) || ! is_string($link) || ! Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: parameter must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$this->data['link'] = $link;
|
||||
|
||||
|
@ -274,8 +283,10 @@ class Entry
|
|||
*/
|
||||
public function setCommentCount($count)
|
||||
{
|
||||
if (!is_numeric($count) || (int) $count != $count || (int) $count < 0) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "count" must be a positive integer number or zero');
|
||||
if (! is_numeric($count) || (int) $count != $count || (int) $count < 0) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "count" must be a positive integer number or zero'
|
||||
);
|
||||
}
|
||||
$this->data['commentCount'] = (int) $count;
|
||||
|
||||
|
@ -291,8 +302,10 @@ class Entry
|
|||
*/
|
||||
public function setCommentLink($link)
|
||||
{
|
||||
if (empty($link) || !is_string($link) || !Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "link" must be a non-empty string and valid URI/IRI');
|
||||
if (empty($link) || ! is_string($link) || ! Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "link" must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$this->data['commentLink'] = $link;
|
||||
|
||||
|
@ -308,14 +321,16 @@ class Entry
|
|||
*/
|
||||
public function setCommentFeedLink(array $link)
|
||||
{
|
||||
if (!isset($link['uri']) || !is_string($link['uri']) || !Uri::factory($link['uri'])->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "link" must be a non-empty string and valid URI/IRI');
|
||||
if (! isset($link['uri']) || ! is_string($link['uri']) || ! Uri::factory($link['uri'])->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "link" must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
if (!isset($link['type']) || !in_array($link['type'], ['atom', 'rss', 'rdf'])) {
|
||||
if (! isset($link['type']) || ! in_array($link['type'], ['atom', 'rss', 'rdf'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "type" must be one'
|
||||
. ' of "atom", "rss" or "rdf"');
|
||||
}
|
||||
if (!isset($this->data['commentFeedLinks'])) {
|
||||
if (! isset($this->data['commentFeedLinks'])) {
|
||||
$this->data['commentFeedLinks'] = [];
|
||||
}
|
||||
$this->data['commentFeedLinks'][] = $link;
|
||||
|
@ -349,7 +364,7 @@ class Entry
|
|||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
if (empty($title) || !is_string($title)) {
|
||||
if (empty($title) || ! is_string($title)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['title'] = $title;
|
||||
|
@ -364,7 +379,7 @@ class Entry
|
|||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (!array_key_exists('authors', $this->data)) {
|
||||
if (! array_key_exists('authors', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['authors'];
|
||||
|
@ -377,7 +392,7 @@ class Entry
|
|||
*/
|
||||
public function getContent()
|
||||
{
|
||||
if (!array_key_exists('content', $this->data)) {
|
||||
if (! array_key_exists('content', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['content'];
|
||||
|
@ -390,7 +405,7 @@ class Entry
|
|||
*/
|
||||
public function getCopyright()
|
||||
{
|
||||
if (!array_key_exists('copyright', $this->data)) {
|
||||
if (! array_key_exists('copyright', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['copyright'];
|
||||
|
@ -403,7 +418,7 @@ class Entry
|
|||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
if (!array_key_exists('dateCreated', $this->data)) {
|
||||
if (! array_key_exists('dateCreated', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['dateCreated'];
|
||||
|
@ -416,7 +431,7 @@ class Entry
|
|||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
if (!array_key_exists('dateModified', $this->data)) {
|
||||
if (! array_key_exists('dateModified', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['dateModified'];
|
||||
|
@ -429,7 +444,7 @@ class Entry
|
|||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (!array_key_exists('description', $this->data)) {
|
||||
if (! array_key_exists('description', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['description'];
|
||||
|
@ -442,7 +457,7 @@ class Entry
|
|||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (!array_key_exists('id', $this->data)) {
|
||||
if (! array_key_exists('id', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['id'];
|
||||
|
@ -455,7 +470,7 @@ class Entry
|
|||
*/
|
||||
public function getLink()
|
||||
{
|
||||
if (!array_key_exists('link', $this->data)) {
|
||||
if (! array_key_exists('link', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['link'];
|
||||
|
@ -469,7 +484,7 @@ class Entry
|
|||
*/
|
||||
public function getLinks()
|
||||
{
|
||||
if (!array_key_exists('links', $this->data)) {
|
||||
if (! array_key_exists('links', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['links'];
|
||||
|
@ -482,7 +497,7 @@ class Entry
|
|||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (!array_key_exists('title', $this->data)) {
|
||||
if (! array_key_exists('title', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['title'];
|
||||
|
@ -495,7 +510,7 @@ class Entry
|
|||
*/
|
||||
public function getCommentCount()
|
||||
{
|
||||
if (!array_key_exists('commentCount', $this->data)) {
|
||||
if (! array_key_exists('commentCount', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['commentCount'];
|
||||
|
@ -508,7 +523,7 @@ class Entry
|
|||
*/
|
||||
public function getCommentLink()
|
||||
{
|
||||
if (!array_key_exists('commentLink', $this->data)) {
|
||||
if (! array_key_exists('commentLink', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['commentLink'];
|
||||
|
@ -522,7 +537,7 @@ class Entry
|
|||
*/
|
||||
public function getCommentFeedLinks()
|
||||
{
|
||||
if (!array_key_exists('commentFeedLinks', $this->data)) {
|
||||
if (! array_key_exists('commentFeedLinks', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['commentFeedLinks'];
|
||||
|
@ -537,21 +552,21 @@ class Entry
|
|||
*/
|
||||
public function addCategory(array $category)
|
||||
{
|
||||
if (!isset($category['term'])) {
|
||||
if (! isset($category['term'])) {
|
||||
throw new Exception\InvalidArgumentException('Each category must be an array and '
|
||||
. 'contain at least a "term" element containing the machine '
|
||||
. ' readable category name');
|
||||
}
|
||||
if (isset($category['scheme'])) {
|
||||
if (empty($category['scheme'])
|
||||
|| !is_string($category['scheme'])
|
||||
|| !Uri::factory($category['scheme'])->isValid()
|
||||
|| ! is_string($category['scheme'])
|
||||
|| ! Uri::factory($category['scheme'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('The Atom scheme or RSS domain of'
|
||||
. ' a category must be a valid URI');
|
||||
}
|
||||
}
|
||||
if (!isset($this->data['categories'])) {
|
||||
if (! isset($this->data['categories'])) {
|
||||
$this->data['categories'] = [];
|
||||
}
|
||||
$this->data['categories'][] = $category;
|
||||
|
@ -581,7 +596,7 @@ class Entry
|
|||
*/
|
||||
public function getCategories()
|
||||
{
|
||||
if (!array_key_exists('categories', $this->data)) {
|
||||
if (! array_key_exists('categories', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['categories'];
|
||||
|
@ -599,10 +614,10 @@ class Entry
|
|||
*/
|
||||
public function setEnclosure(array $enclosure)
|
||||
{
|
||||
if (!isset($enclosure['uri'])) {
|
||||
if (! isset($enclosure['uri'])) {
|
||||
throw new Exception\InvalidArgumentException('Enclosure "uri" is not set');
|
||||
}
|
||||
if (!Uri::factory($enclosure['uri'])->isValid()) {
|
||||
if (! Uri::factory($enclosure['uri'])->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Enclosure "uri" is not a valid URI/IRI');
|
||||
}
|
||||
$this->data['enclosure'] = $enclosure;
|
||||
|
@ -617,7 +632,7 @@ class Entry
|
|||
*/
|
||||
public function getEnclosure()
|
||||
{
|
||||
if (!array_key_exists('enclosure', $this->data)) {
|
||||
if (! array_key_exists('enclosure', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['enclosure'];
|
||||
|
@ -752,8 +767,10 @@ class Entry
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _loadExtensions()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$all = Writer::getExtensions();
|
||||
$manager = Writer::getExtensionManager();
|
||||
$exts = $all['entry'];
|
||||
|
|
|
@ -160,5 +160,7 @@ abstract class AbstractRenderer implements RendererInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
abstract protected function _appendNamespaces();
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
|
|
|
@ -52,10 +52,14 @@ class Feed extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:atom',
|
||||
'http://www.w3.org/2005/Atom');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:atom',
|
||||
'http://www.w3.org/2005/Atom'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,10 +69,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setFeedLinks(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$flinks = $this->getDataContainer()->getFeedLinks();
|
||||
if (!$flinks || empty($flinks)) {
|
||||
if (! $flinks || empty($flinks)) {
|
||||
return;
|
||||
}
|
||||
foreach ($flinks as $type => $href) {
|
||||
|
@ -91,10 +97,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setHubs(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$hubs = $this->getDataContainer()->getHubs();
|
||||
if (!$hubs || empty($hubs)) {
|
||||
if (! $hubs || empty($hubs)) {
|
||||
return;
|
||||
}
|
||||
foreach ($hubs as $hubUrl) {
|
||||
|
|
|
@ -47,10 +47,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:content',
|
||||
'http://purl.org/rss/1.0/modules/content/');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:content',
|
||||
'http://purl.org/rss/1.0/modules/content/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,10 +64,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setContent(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$content = $this->getDataContainer()->getContent();
|
||||
if (!$content) {
|
||||
if (! $content) {
|
||||
return;
|
||||
}
|
||||
$element = $dom->createElement('content:encoded');
|
||||
|
|
|
@ -47,10 +47,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:dc',
|
||||
'http://purl.org/dc/elements/1.1/');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:dc',
|
||||
'http://purl.org/dc/elements/1.1/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,10 +64,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->getDataContainer()->getAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $data) {
|
||||
|
|
|
@ -47,10 +47,14 @@ class Feed extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:dc',
|
||||
'http://purl.org/dc/elements/1.1/');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:dc',
|
||||
'http://purl.org/dc/elements/1.1/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,10 +64,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->getDataContainer()->getAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $data) {
|
||||
|
|
|
@ -76,7 +76,7 @@ class Entry
|
|||
*/
|
||||
public function setItunesBlock($value)
|
||||
{
|
||||
if (!ctype_alpha($value) && strlen($value) > 0) {
|
||||
if (! ctype_alpha($value) && strlen($value) > 0) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only'
|
||||
. ' contain alphabetic characters');
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ class Entry
|
|||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "author" may only'
|
||||
. ' contain a maximum of 255 characters each');
|
||||
}
|
||||
if (!isset($this->data['authors'])) {
|
||||
if (! isset($this->data['authors'])) {
|
||||
$this->data['authors'] = [];
|
||||
}
|
||||
$this->data['authors'][] = $value;
|
||||
|
@ -132,9 +132,9 @@ class Entry
|
|||
public function setItunesDuration($value)
|
||||
{
|
||||
$value = (string) $value;
|
||||
if (!ctype_digit($value)
|
||||
&& !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
|
||||
&& !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
|
||||
if (! ctype_digit($value)
|
||||
&& ! preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
|
||||
&& ! preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
|
||||
) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "duration" may only'
|
||||
. ' be of a specified [[HH:]MM:]SS format');
|
||||
|
@ -152,7 +152,7 @@ class Entry
|
|||
*/
|
||||
public function setItunesExplicit($value)
|
||||
{
|
||||
if (!in_array($value, ['yes', 'no', 'clean'])) {
|
||||
if (! in_array($value, ['yes', 'no', 'clean'])) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "explicit" may only'
|
||||
. ' be one of "yes", "no" or "clean"');
|
||||
}
|
||||
|
@ -229,14 +229,14 @@ class Entry
|
|||
public function __call($method, array $params)
|
||||
{
|
||||
$point = lcfirst(substr($method, 9));
|
||||
if (!method_exists($this, 'setItunes' . ucfirst($point))
|
||||
&& !method_exists($this, 'addItunes' . ucfirst($point))
|
||||
if (! method_exists($this, 'setItunes' . ucfirst($point))
|
||||
&& ! method_exists($this, 'addItunes' . ucfirst($point))
|
||||
) {
|
||||
throw new Writer\Exception\BadMethodCallException(
|
||||
'invalid method: ' . $method
|
||||
);
|
||||
}
|
||||
if (!array_key_exists($point, $this->data)
|
||||
if (! array_key_exists($point, $this->data)
|
||||
|| empty($this->data[$point])
|
||||
) {
|
||||
return;
|
||||
|
|
|
@ -14,8 +14,6 @@ use Zend\Feed\Writer;
|
|||
use Zend\Stdlib\StringUtils;
|
||||
use Zend\Stdlib\StringWrapper\StringWrapperInterface;
|
||||
|
||||
/**
|
||||
*/
|
||||
class Feed
|
||||
{
|
||||
/**
|
||||
|
@ -79,7 +77,7 @@ class Feed
|
|||
*/
|
||||
public function setItunesBlock($value)
|
||||
{
|
||||
if (!ctype_alpha($value) && strlen($value) > 0) {
|
||||
if (! ctype_alpha($value) && strlen($value) > 0) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only'
|
||||
. ' contain alphabetic characters');
|
||||
}
|
||||
|
@ -118,7 +116,7 @@ class Feed
|
|||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "author" may only'
|
||||
. ' contain a maximum of 255 characters each');
|
||||
}
|
||||
if (!isset($this->data['authors'])) {
|
||||
if (! isset($this->data['authors'])) {
|
||||
$this->data['authors'] = [];
|
||||
}
|
||||
$this->data['authors'][] = $value;
|
||||
|
@ -134,11 +132,11 @@ class Feed
|
|||
*/
|
||||
public function setItunesCategories(array $values)
|
||||
{
|
||||
if (!isset($this->data['categories'])) {
|
||||
if (! isset($this->data['categories'])) {
|
||||
$this->data['categories'] = [];
|
||||
}
|
||||
foreach ($values as $key => $value) {
|
||||
if (!is_array($value)) {
|
||||
if (! is_array($value)) {
|
||||
if ($this->stringWrapper->strlen($value) > 255) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "category" may only'
|
||||
. ' contain a maximum of 255 characters each');
|
||||
|
@ -171,11 +169,11 @@ class Feed
|
|||
*/
|
||||
public function setItunesImage($value)
|
||||
{
|
||||
if (!Uri::factory($value)->isValid()) {
|
||||
if (! Uri::factory($value)->isValid()) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "image" may only'
|
||||
. ' be a valid URI/IRI');
|
||||
}
|
||||
if (!in_array(substr($value, -3), ['jpg', 'png'])) {
|
||||
if (! in_array(substr($value, -3), ['jpg', 'png'])) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "image" may only'
|
||||
. ' use file extension "jpg" or "png" which must be the last three'
|
||||
. ' characters of the URI (i.e. no query string or fragment)');
|
||||
|
@ -194,9 +192,9 @@ class Feed
|
|||
public function setItunesDuration($value)
|
||||
{
|
||||
$value = (string) $value;
|
||||
if (!ctype_digit($value)
|
||||
&& !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
|
||||
&& !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
|
||||
if (! ctype_digit($value)
|
||||
&& ! preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
|
||||
&& ! preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
|
||||
) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "duration" may only'
|
||||
. ' be of a specified [[HH:]MM:]SS format');
|
||||
|
@ -214,7 +212,7 @@ class Feed
|
|||
*/
|
||||
public function setItunesExplicit($value)
|
||||
{
|
||||
if (!in_array($value, ['yes', 'no', 'clean'])) {
|
||||
if (! in_array($value, ['yes', 'no', 'clean'])) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "explicit" may only'
|
||||
. ' be one of "yes", "no" or "clean"');
|
||||
}
|
||||
|
@ -254,7 +252,7 @@ class Feed
|
|||
*/
|
||||
public function setItunesNewFeedUrl($value)
|
||||
{
|
||||
if (!Uri::factory($value)->isValid()) {
|
||||
if (! Uri::factory($value)->isValid()) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "newFeedUrl" may only'
|
||||
. ' be a valid URI/IRI');
|
||||
}
|
||||
|
@ -285,7 +283,7 @@ class Feed
|
|||
*/
|
||||
public function addItunesOwner(array $value)
|
||||
{
|
||||
if (!isset($value['name']) || !isset($value['email'])) {
|
||||
if (! isset($value['name']) || ! isset($value['email'])) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "owner" must'
|
||||
. ' be an array containing keys "name" and "email"');
|
||||
}
|
||||
|
@ -295,7 +293,7 @@ class Feed
|
|||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "owner" may only'
|
||||
. ' contain a maximum of 255 characters each for "name" and "email"');
|
||||
}
|
||||
if (!isset($this->data['owners'])) {
|
||||
if (! isset($this->data['owners'])) {
|
||||
$this->data['owners'] = [];
|
||||
}
|
||||
$this->data['owners'][] = $value;
|
||||
|
@ -347,14 +345,14 @@ class Feed
|
|||
public function __call($method, array $params)
|
||||
{
|
||||
$point = lcfirst(substr($method, 9));
|
||||
if (!method_exists($this, 'setItunes' . ucfirst($point))
|
||||
&& !method_exists($this, 'addItunes' . ucfirst($point))
|
||||
if (! method_exists($this, 'setItunes' . ucfirst($point))
|
||||
&& ! method_exists($this, 'addItunes' . ucfirst($point))
|
||||
) {
|
||||
throw new Writer\Exception\BadMethodCallException(
|
||||
'invalid method: ' . $method
|
||||
);
|
||||
}
|
||||
if (!array_key_exists($point, $this->data) || empty($this->data[$point])) {
|
||||
if (! array_key_exists($point, $this->data) || empty($this->data[$point])) {
|
||||
return;
|
||||
}
|
||||
return $this->data[$point];
|
||||
|
|
|
@ -50,10 +50,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:itunes',
|
||||
'http://www.itunes.com/dtds/podcast-1.0.dtd');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:itunes',
|
||||
'http://www.itunes.com/dtds/podcast-1.0.dtd'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,10 +67,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->getDataContainer()->getItunesAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $author) {
|
||||
|
@ -85,8 +91,10 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBlock(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$block = $this->getDataContainer()->getItunesBlock();
|
||||
if ($block === null) {
|
||||
return;
|
||||
|
@ -105,10 +113,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDuration(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$duration = $this->getDataContainer()->getItunesDuration();
|
||||
if (!$duration) {
|
||||
if (! $duration) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:duration');
|
||||
|
@ -125,8 +135,10 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setExplicit(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$explicit = $this->getDataContainer()->getItunesExplicit();
|
||||
if ($explicit === null) {
|
||||
return;
|
||||
|
@ -145,10 +157,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setKeywords(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$keywords = $this->getDataContainer()->getItunesKeywords();
|
||||
if (!$keywords || empty($keywords)) {
|
||||
if (! $keywords || empty($keywords)) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:keywords');
|
||||
|
@ -165,10 +179,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setSubtitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$subtitle = $this->getDataContainer()->getItunesSubtitle();
|
||||
if (!$subtitle) {
|
||||
if (! $subtitle) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:subtitle');
|
||||
|
@ -185,10 +201,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setSummary(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$summary = $this->getDataContainer()->getItunesSummary();
|
||||
if (!$summary) {
|
||||
if (! $summary) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:summary');
|
||||
|
|
|
@ -54,10 +54,14 @@ class Feed extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:itunes',
|
||||
'http://www.itunes.com/dtds/podcast-1.0.dtd');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:itunes',
|
||||
'http://www.itunes.com/dtds/podcast-1.0.dtd'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,10 +71,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->getDataContainer()->getItunesAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $author) {
|
||||
|
@ -89,8 +95,10 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBlock(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$block = $this->getDataContainer()->getItunesBlock();
|
||||
if ($block === null) {
|
||||
return;
|
||||
|
@ -109,14 +117,16 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$cats = $this->getDataContainer()->getItunesCategories();
|
||||
if (!$cats || empty($cats)) {
|
||||
if (! $cats || empty($cats)) {
|
||||
return;
|
||||
}
|
||||
foreach ($cats as $key => $cat) {
|
||||
if (!is_array($cat)) {
|
||||
if (! is_array($cat)) {
|
||||
$el = $dom->createElement('itunes:category');
|
||||
$el->setAttribute('text', $cat);
|
||||
$root->appendChild($el);
|
||||
|
@ -141,10 +151,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setImage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$image = $this->getDataContainer()->getItunesImage();
|
||||
if (!$image) {
|
||||
if (! $image) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:image');
|
||||
|
@ -160,10 +172,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDuration(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$duration = $this->getDataContainer()->getItunesDuration();
|
||||
if (!$duration) {
|
||||
if (! $duration) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:duration');
|
||||
|
@ -180,8 +194,10 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setExplicit(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$explicit = $this->getDataContainer()->getItunesExplicit();
|
||||
if ($explicit === null) {
|
||||
return;
|
||||
|
@ -200,10 +216,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setKeywords(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$keywords = $this->getDataContainer()->getItunesKeywords();
|
||||
if (!$keywords || empty($keywords)) {
|
||||
if (! $keywords || empty($keywords)) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:keywords');
|
||||
|
@ -220,10 +238,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setNewFeedUrl(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$url = $this->getDataContainer()->getItunesNewFeedUrl();
|
||||
if (!$url) {
|
||||
if (! $url) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:new-feed-url');
|
||||
|
@ -240,10 +260,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setOwners(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$owners = $this->getDataContainer()->getItunesOwners();
|
||||
if (!$owners || empty($owners)) {
|
||||
if (! $owners || empty($owners)) {
|
||||
return;
|
||||
}
|
||||
foreach ($owners as $owner) {
|
||||
|
@ -268,10 +290,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setSubtitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$subtitle = $this->getDataContainer()->getItunesSubtitle();
|
||||
if (!$subtitle) {
|
||||
if (! $subtitle) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:subtitle');
|
||||
|
@ -288,10 +312,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setSummary(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$summary = $this->getDataContainer()->getItunesSummary();
|
||||
if (!$summary) {
|
||||
if (! $summary) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:summary');
|
||||
|
|
|
@ -47,10 +47,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:slash',
|
||||
'http://purl.org/rss/1.0/modules/slash/');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:slash',
|
||||
'http://purl.org/rss/1.0/modules/slash/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,10 +64,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentCount(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$count = $this->getDataContainer()->getCommentCount();
|
||||
if (!$count) {
|
||||
if (! $count) {
|
||||
$count = 0;
|
||||
}
|
||||
$tcount = $this->dom->createElement('slash:comments');
|
||||
|
|
|
@ -49,10 +49,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:thr',
|
||||
'http://purl.org/syndication/thread/1.0');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:thr',
|
||||
'http://purl.org/syndication/thread/1.0'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,10 +66,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$link = $this->getDataContainer()->getCommentLink();
|
||||
if (!$link) {
|
||||
if (! $link) {
|
||||
return;
|
||||
}
|
||||
$clink = $this->dom->createElement('link');
|
||||
|
@ -87,10 +93,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentFeedLinks(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$links = $this->getDataContainer()->getCommentFeedLinks();
|
||||
if (!$links || empty($links)) {
|
||||
if (! $links || empty($links)) {
|
||||
return;
|
||||
}
|
||||
foreach ($links as $link) {
|
||||
|
@ -114,8 +122,10 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentCount(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$count = $this->getDataContainer()->getCommentCount();
|
||||
if ($count === null) {
|
||||
return;
|
||||
|
|
|
@ -47,10 +47,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:wfw',
|
||||
'http://wellformedweb.org/CommentAPI/');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:wfw',
|
||||
'http://wellformedweb.org/CommentAPI/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,10 +64,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentFeedLinks(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$links = $this->getDataContainer()->getCommentFeedLinks();
|
||||
if (!$links || empty($links)) {
|
||||
if (! $links || empty($links)) {
|
||||
return;
|
||||
}
|
||||
foreach ($links as $link) {
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Zend\Feed\Writer;
|
|||
/**
|
||||
* Default implementation of ExtensionManagerInterface
|
||||
*
|
||||
* Decorator of ExtensionPluginManager.
|
||||
* Decorator for an ExtensionManagerInstance.
|
||||
*/
|
||||
class ExtensionManager implements ExtensionManagerInterface
|
||||
{
|
||||
|
@ -22,14 +22,14 @@ class ExtensionManager implements ExtensionManagerInterface
|
|||
* Constructor
|
||||
*
|
||||
* Seeds the extension manager with a plugin manager; if none provided,
|
||||
* creates an instance.
|
||||
* creates and decorates an instance of StandaloneExtensionManager.
|
||||
*
|
||||
* @param null|ExtensionPluginManager $pluginManager
|
||||
* @param null|ExtensionManagerInterface $pluginManager
|
||||
*/
|
||||
public function __construct(ExtensionPluginManager $pluginManager = null)
|
||||
public function __construct(ExtensionManagerInterface $pluginManager = null)
|
||||
{
|
||||
if (null === $pluginManager) {
|
||||
$pluginManager = new ExtensionPluginManager();
|
||||
$pluginManager = new StandaloneExtensionManager();
|
||||
}
|
||||
$this->pluginManager = $pluginManager;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class ExtensionManager implements ExtensionManagerInterface
|
|||
/**
|
||||
* Method overloading
|
||||
*
|
||||
* Proxy to composed ExtensionPluginManager instance.
|
||||
* Proxy to composed ExtensionManagerInterface instance.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
|
@ -46,7 +46,7 @@ class ExtensionManager implements ExtensionManagerInterface
|
|||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (!method_exists($this->pluginManager, $method)) {
|
||||
if (! method_exists($this->pluginManager, $method)) {
|
||||
throw new Exception\BadMethodCallException(sprintf(
|
||||
'Method by name of %s does not exist in %s',
|
||||
$method,
|
||||
|
|
|
@ -10,50 +10,129 @@
|
|||
namespace Zend\Feed\Writer;
|
||||
|
||||
use Zend\ServiceManager\AbstractPluginManager;
|
||||
use Zend\ServiceManager\Exception\InvalidServiceException;
|
||||
use Zend\ServiceManager\Factory\InvokableFactory;
|
||||
|
||||
/**
|
||||
* Plugin manager implementation for feed writer extensions
|
||||
*
|
||||
* Validation checks that we have an Entry, Feed, or Extension\AbstractRenderer.
|
||||
*/
|
||||
class ExtensionPluginManager extends AbstractPluginManager
|
||||
class ExtensionPluginManager extends AbstractPluginManager implements ExtensionManagerInterface
|
||||
{
|
||||
/**
|
||||
* Default set of extension classes
|
||||
* Aliases for default set of extension classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $invokableClasses = [
|
||||
'atomrendererfeed' => 'Zend\Feed\Writer\Extension\Atom\Renderer\Feed',
|
||||
'contentrendererentry' => 'Zend\Feed\Writer\Extension\Content\Renderer\Entry',
|
||||
'dublincorerendererentry' => 'Zend\Feed\Writer\Extension\DublinCore\Renderer\Entry',
|
||||
'dublincorerendererfeed' => 'Zend\Feed\Writer\Extension\DublinCore\Renderer\Feed',
|
||||
'itunesentry' => 'Zend\Feed\Writer\Extension\ITunes\Entry',
|
||||
'itunesfeed' => 'Zend\Feed\Writer\Extension\ITunes\Feed',
|
||||
'itunesrendererentry' => 'Zend\Feed\Writer\Extension\ITunes\Renderer\Entry',
|
||||
'itunesrendererfeed' => 'Zend\Feed\Writer\Extension\ITunes\Renderer\Feed',
|
||||
'slashrendererentry' => 'Zend\Feed\Writer\Extension\Slash\Renderer\Entry',
|
||||
'threadingrendererentry' => 'Zend\Feed\Writer\Extension\Threading\Renderer\Entry',
|
||||
'wellformedwebrendererentry' => 'Zend\Feed\Writer\Extension\WellFormedWeb\Renderer\Entry',
|
||||
protected $aliases = [
|
||||
'atomrendererfeed' => Extension\Atom\Renderer\Feed::class,
|
||||
'atomRendererFeed' => Extension\Atom\Renderer\Feed::class,
|
||||
'AtomRendererFeed' => Extension\Atom\Renderer\Feed::class,
|
||||
'AtomRenderer\Feed' => Extension\Atom\Renderer\Feed::class,
|
||||
'contentrendererentry' => Extension\Content\Renderer\Entry::class,
|
||||
'contentRendererEntry' => Extension\Content\Renderer\Entry::class,
|
||||
'ContentRendererEntry' => Extension\Content\Renderer\Entry::class,
|
||||
'ContentRenderer\Entry' => Extension\Content\Renderer\Entry::class,
|
||||
'dublincorerendererentry' => Extension\DublinCore\Renderer\Entry::class,
|
||||
'dublinCoreRendererEntry' => Extension\DublinCore\Renderer\Entry::class,
|
||||
'DublinCoreRendererEntry' => Extension\DublinCore\Renderer\Entry::class,
|
||||
'DublinCoreRenderer\Entry' => Extension\DublinCore\Renderer\Entry::class,
|
||||
'dublincorerendererfeed' => Extension\DublinCore\Renderer\Feed::class,
|
||||
'dublinCoreRendererFeed' => Extension\DublinCore\Renderer\Feed::class,
|
||||
'DublinCoreRendererFeed' => Extension\DublinCore\Renderer\Feed::class,
|
||||
'DublinCoreRenderer\Feed' => Extension\DublinCore\Renderer\Feed::class,
|
||||
'itunesentry' => Extension\ITunes\Entry::class,
|
||||
'itunesEntry' => Extension\ITunes\Entry::class,
|
||||
'iTunesEntry' => Extension\ITunes\Entry::class,
|
||||
'ItunesEntry' => Extension\ITunes\Entry::class,
|
||||
'Itunes\Entry' => Extension\ITunes\Entry::class,
|
||||
'itunesfeed' => Extension\ITunes\Feed::class,
|
||||
'itunesFeed' => Extension\ITunes\Feed::class,
|
||||
'iTunesFeed' => Extension\ITunes\Feed::class,
|
||||
'ItunesFeed' => Extension\ITunes\Feed::class,
|
||||
'Itunes\Feed' => Extension\ITunes\Feed::class,
|
||||
'itunesrendererentry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'itunesRendererEntry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'iTunesRendererEntry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'ItunesRendererEntry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'ItunesRenderer\Entry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'itunesrendererfeed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'itunesRendererFeed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'iTunesRendererFeed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'ItunesRendererFeed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'ItunesRenderer\Feed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'slashrendererentry' => Extension\Slash\Renderer\Entry::class,
|
||||
'slashRendererEntry' => Extension\Slash\Renderer\Entry::class,
|
||||
'SlashRendererEntry' => Extension\Slash\Renderer\Entry::class,
|
||||
'SlashRenderer\Entry' => Extension\Slash\Renderer\Entry::class,
|
||||
'threadingrendererentry' => Extension\Threading\Renderer\Entry::class,
|
||||
'threadingRendererEntry' => Extension\Threading\Renderer\Entry::class,
|
||||
'ThreadingRendererEntry' => Extension\Threading\Renderer\Entry::class,
|
||||
'ThreadingRenderer\Entry' => Extension\Threading\Renderer\Entry::class,
|
||||
'wellformedwebrendererentry' => Extension\WellFormedWeb\Renderer\Entry::class,
|
||||
'wellFormedWebRendererEntry' => Extension\WellFormedWeb\Renderer\Entry::class,
|
||||
'WellFormedWebRendererEntry' => Extension\WellFormedWeb\Renderer\Entry::class,
|
||||
'WellFormedWebRenderer\Entry' => Extension\WellFormedWeb\Renderer\Entry::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Do not share instances
|
||||
* Factories for default set of extension classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $factories = [
|
||||
Extension\Atom\Renderer\Feed::class => InvokableFactory::class,
|
||||
Extension\Content\Renderer\Entry::class => InvokableFactory::class,
|
||||
Extension\DublinCore\Renderer\Entry::class => InvokableFactory::class,
|
||||
Extension\DublinCore\Renderer\Feed::class => InvokableFactory::class,
|
||||
Extension\ITunes\Entry::class => InvokableFactory::class,
|
||||
Extension\ITunes\Feed::class => InvokableFactory::class,
|
||||
Extension\ITunes\Renderer\Entry::class => InvokableFactory::class,
|
||||
Extension\ITunes\Renderer\Feed::class => InvokableFactory::class,
|
||||
Extension\Slash\Renderer\Entry::class => InvokableFactory::class,
|
||||
Extension\Threading\Renderer\Entry::class => InvokableFactory::class,
|
||||
Extension\WellFormedWeb\Renderer\Entry::class => InvokableFactory::class,
|
||||
// Legacy (v2) due to alias resolution; canonical form of resolved
|
||||
// alias is used to look up the factory, while the non-normalized
|
||||
// resolved alias is used as the requested name passed to the factory.
|
||||
'zendfeedwriterextensionatomrendererfeed' => InvokableFactory::class,
|
||||
'zendfeedwriterextensioncontentrendererentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensiondublincorerendererentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensiondublincorerendererfeed' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionitunesentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionitunesfeed' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionitunesrendererentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionitunesrendererfeed' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionslashrendererentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionthreadingrendererentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionwellformedwebrendererentry' => InvokableFactory::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Do not share instances (v2)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $shareByDefault = false;
|
||||
|
||||
/**
|
||||
* Validate the plugin
|
||||
* Do not share instances (v3)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $sharedByDefault = false;
|
||||
|
||||
/**
|
||||
* Validate the plugin (v3)
|
||||
*
|
||||
* Checks that the extension loaded is of a valid type.
|
||||
*
|
||||
* @param mixed $plugin
|
||||
* @return void
|
||||
* @throws Exception\InvalidArgumentException if invalid
|
||||
* @throws InvalidServiceException if invalid
|
||||
*/
|
||||
public function validatePlugin($plugin)
|
||||
public function validate($plugin)
|
||||
{
|
||||
if ($plugin instanceof Extension\AbstractRenderer) {
|
||||
// we're okay
|
||||
|
@ -70,11 +149,32 @@ class ExtensionPluginManager extends AbstractPluginManager
|
|||
return;
|
||||
}
|
||||
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
throw new InvalidServiceException(sprintf(
|
||||
'Plugin of type %s is invalid; must implement %s\Extension\RendererInterface '
|
||||
. 'or the classname must end in "Feed" or "Entry"',
|
||||
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
|
||||
__NAMESPACE__
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate plugin (v2)
|
||||
*
|
||||
* @param mixed $plugin
|
||||
* @return void
|
||||
* @throws Exception\InvalidArgumentException when invalid
|
||||
*/
|
||||
public function validatePlugin($plugin)
|
||||
{
|
||||
try {
|
||||
$this->validate($plugin);
|
||||
} catch (InvalidServiceException $e) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Plugin of type %s is invalid; must implement %s\Extension\RendererInterface '
|
||||
. 'or the classname must end in "Feed" or "Entry"',
|
||||
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
|
||||
__NAMESPACE__
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ class Feed extends AbstractFeed implements Iterator, Countable
|
|||
*/
|
||||
public function removeEntry($index)
|
||||
{
|
||||
if (!isset($this->entries[$index])) {
|
||||
if (! isset($this->entries[$index])) {
|
||||
throw new Exception\InvalidArgumentException('Undefined index: ' . $index . '. Entry does not exist.');
|
||||
}
|
||||
unset($this->entries[$index]);
|
||||
|
|
|
@ -22,7 +22,7 @@ abstract class FeedFactory
|
|||
*/
|
||||
public static function factory($data)
|
||||
{
|
||||
if (!is_array($data) && !$data instanceof Traversable) {
|
||||
if (! is_array($data) && ! $data instanceof Traversable) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects an array or Traversable argument; received "%s"',
|
||||
__METHOD__,
|
||||
|
@ -39,11 +39,11 @@ abstract class FeedFactory
|
|||
if (method_exists($feed, $method)) {
|
||||
switch ($method) {
|
||||
case 'setfeedlink':
|
||||
if (!is_array($value)) {
|
||||
if (! is_array($value)) {
|
||||
// Need an array
|
||||
break;
|
||||
}
|
||||
if (!array_key_exists('link', $value) || !array_key_exists('type', $value)) {
|
||||
if (! array_key_exists('link', $value) || ! array_key_exists('type', $value)) {
|
||||
// Need both keys to set this correctly
|
||||
break;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ abstract class FeedFactory
|
|||
*/
|
||||
protected static function createEntries($entries, Feed $feed)
|
||||
{
|
||||
if (!is_array($entries) && !$entries instanceof Traversable) {
|
||||
if (! is_array($entries) && ! $entries instanceof Traversable) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s::factory expects the "entries" value to be an array or Traversable; received "%s"',
|
||||
get_called_class(),
|
||||
|
@ -97,7 +97,7 @@ abstract class FeedFactory
|
|||
}
|
||||
|
||||
foreach ($entries as $data) {
|
||||
if (!is_array($data) && !$data instanceof Traversable && !$data instanceof Entry) {
|
||||
if (! is_array($data) && ! $data instanceof Traversable && ! $data instanceof Entry) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects an array, Traversable, or Zend\Feed\Writer\Entry argument; received "%s"',
|
||||
__METHOD__,
|
||||
|
@ -116,7 +116,7 @@ abstract class FeedFactory
|
|||
foreach ($data as $key => $value) {
|
||||
$key = static::convertKey($key);
|
||||
$method = 'set' . $key;
|
||||
if (!method_exists($entry, $method)) {
|
||||
if (! method_exists($entry, $method)) {
|
||||
continue;
|
||||
}
|
||||
$entry->$method($value);
|
||||
|
|
|
@ -146,8 +146,10 @@ class AbstractRenderer
|
|||
*/
|
||||
public function ignoreExceptions($bool = true)
|
||||
{
|
||||
if (!is_bool($bool)) {
|
||||
throw new Writer\Exception\InvalidArgumentException('Invalid parameter: $bool. Should be TRUE or FALSE (defaults to TRUE if null)');
|
||||
if (! is_bool($bool)) {
|
||||
throw new Writer\Exception\InvalidArgumentException(
|
||||
'Invalid parameter: $bool. Should be TRUE or FALSE (defaults to TRUE if null)'
|
||||
);
|
||||
}
|
||||
$this->ignoreExceptions = $bool;
|
||||
return $this;
|
||||
|
@ -213,8 +215,10 @@ class AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _loadExtensions()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
Writer\Writer::registerCoreExtensions();
|
||||
$manager = Writer\Writer::getExtensionManager();
|
||||
$all = Writer\Writer::getExtensions();
|
||||
|
|
|
@ -71,13 +71,15 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setTitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'Atom 1.0 entry elements MUST contain exactly one'
|
||||
. ' atom:title element but a title has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -98,9 +100,11 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDescription(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()) {
|
||||
return; // unless src content or base64
|
||||
}
|
||||
$subtitle = $dom->createElement('summary');
|
||||
|
@ -120,13 +124,15 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateModified(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$message = 'Atom 1.0 entry elements MUST contain exactly one'
|
||||
. ' atom:updated element but a modification date has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -149,9 +155,11 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateCreated()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateCreated()) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('published');
|
||||
|
@ -169,10 +177,12 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->container->getAuthors();
|
||||
if ((!$authors || empty($authors))) {
|
||||
if ((! $authors || empty($authors))) {
|
||||
/**
|
||||
* This will actually trigger an Exception at the feed level if
|
||||
* a feed level author is not set.
|
||||
|
@ -208,10 +218,12 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setEnclosure(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$data = $this->container->getEnclosure();
|
||||
if ((!$data || empty($data))) {
|
||||
if ((! $data || empty($data))) {
|
||||
return;
|
||||
}
|
||||
$enclosure = $this->dom->createElement('link');
|
||||
|
@ -226,9 +238,11 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
$root->appendChild($enclosure);
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getLink()) {
|
||||
return;
|
||||
}
|
||||
$link = $dom->createElement('link');
|
||||
|
@ -246,16 +260,18 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setId(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getId()
|
||||
&& !$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getId()
|
||||
&& ! $this->getDataContainer()->getLink()) {
|
||||
$message = 'Atom 1.0 entry elements MUST contain exactly one '
|
||||
. 'atom:id element, or as an alternative, we can use the same '
|
||||
. 'value as atom:link however neither a suitable link nor an '
|
||||
. 'id have been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -263,17 +279,17 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
}
|
||||
}
|
||||
|
||||
if (!$this->getDataContainer()->getId()) {
|
||||
if (! $this->getDataContainer()->getId()) {
|
||||
$this->getDataContainer()->setId(
|
||||
$this->getDataContainer()->getLink()
|
||||
);
|
||||
}
|
||||
if (!Uri::factory($this->getDataContainer()->getId())->isValid()
|
||||
&& !preg_match(
|
||||
if (! Uri::factory($this->getDataContainer()->getId())->isValid()
|
||||
&& ! preg_match(
|
||||
"#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#",
|
||||
$this->getDataContainer()->getId()
|
||||
)
|
||||
&& !$this->_validateTagUri($this->getDataContainer()->getId())
|
||||
&& ! $this->_validateTagUri($this->getDataContainer()->getId())
|
||||
) {
|
||||
throw new Writer\Exception\InvalidArgumentException('Atom 1.0 IDs must be a valid URI/IRI');
|
||||
}
|
||||
|
@ -289,8 +305,10 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _validateTagUri($id)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (preg_match(
|
||||
'/^tag:(?P<name>.*),(?P<date>\d{4}-?\d{0,2}-?\d{0,2}):(?P<specific>.*)(.*:)*$/',
|
||||
$id,
|
||||
|
@ -325,23 +343,25 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setContent(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$content = $this->getDataContainer()->getContent();
|
||||
if (!$content && !$this->getDataContainer()->getLink()) {
|
||||
if (! $content && ! $this->getDataContainer()->getLink()) {
|
||||
$message = 'Atom 1.0 entry elements MUST contain exactly one '
|
||||
. 'atom:content element, or as an alternative, at least one link '
|
||||
. 'with a rel attribute of "alternate" to indicate an alternate '
|
||||
. 'method to consume the content.';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!$content) {
|
||||
if (! $content) {
|
||||
return;
|
||||
}
|
||||
$element = $dom->createElement('content');
|
||||
|
@ -356,8 +376,10 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
/**
|
||||
* Load a HTML string and attempt to normalise to XML
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _loadXhtml($content)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (class_exists('tidy', false)) {
|
||||
$tidy = new \tidy;
|
||||
$config = [
|
||||
|
@ -391,10 +413,12 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$categories = $this->getDataContainer()->getCategories();
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $cat) {
|
||||
|
@ -419,10 +443,12 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setSource(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$source = $this->getDataContainer()->getSource();
|
||||
if (!$source) {
|
||||
if (! $source) {
|
||||
return;
|
||||
}
|
||||
$renderer = new Renderer\Feed\AtomSource($source);
|
||||
|
|
|
@ -55,9 +55,11 @@ class Deleted extends Renderer\AbstractRenderer implements Renderer\RendererInte
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setComment(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getComment()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getComment()) {
|
||||
return;
|
||||
}
|
||||
$c = $dom->createElement('at:comment');
|
||||
|
@ -74,10 +76,12 @@ class Deleted extends Renderer\AbstractRenderer implements Renderer\RendererInte
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBy(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$data = $this->container->getBy();
|
||||
if ((!$data || empty($data))) {
|
||||
if ((! $data || empty($data))) {
|
||||
return;
|
||||
}
|
||||
$author = $this->dom->createElement('at:by');
|
||||
|
|
|
@ -57,9 +57,11 @@ class AtomDeleted extends Renderer\AbstractRenderer implements Renderer\Renderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setComment(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getComment()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getComment()) {
|
||||
return;
|
||||
}
|
||||
$c = $dom->createElement('at:comment');
|
||||
|
@ -76,10 +78,12 @@ class AtomDeleted extends Renderer\AbstractRenderer implements Renderer\Renderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBy(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$data = $this->container->getBy();
|
||||
if ((!$data || empty($data))) {
|
||||
if ((! $data || empty($data))) {
|
||||
return;
|
||||
}
|
||||
$author = $this->dom->createElement('at:by');
|
||||
|
|
|
@ -71,15 +71,17 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setTitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()
|
||||
&& !$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()
|
||||
&& ! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'RSS 2.0 entry elements SHOULD contain exactly one'
|
||||
. ' title element but a title has not been set. In addition, there'
|
||||
. ' is no description as required in the absence of a title.';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -100,23 +102,25 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDescription(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()
|
||||
&& !$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()
|
||||
&& ! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'RSS 2.0 entry elements SHOULD contain exactly one'
|
||||
. ' description element but a description has not been set. In'
|
||||
. ' addition, there is no title element as required in the absence'
|
||||
. ' of a description.';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!$this->getDataContainer()->getDescription()) {
|
||||
if (! $this->getDataContainer()->getDescription()) {
|
||||
return;
|
||||
}
|
||||
$subtitle = $dom->createElement('description');
|
||||
|
@ -132,9 +136,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateModified(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -153,12 +159,14 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateCreated()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateCreated()) {
|
||||
return;
|
||||
}
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$this->getDataContainer()->setDateModified(
|
||||
$this->getDataContainer()->getDateCreated()
|
||||
);
|
||||
|
@ -172,10 +180,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->container->getAuthors();
|
||||
if ((!$authors || empty($authors))) {
|
||||
if ((! $authors || empty($authors))) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $data) {
|
||||
|
@ -198,34 +208,36 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setEnclosure(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$data = $this->container->getEnclosure();
|
||||
if ((!$data || empty($data))) {
|
||||
if ((! $data || empty($data))) {
|
||||
return;
|
||||
}
|
||||
if (!isset($data['type'])) {
|
||||
if (! isset($data['type'])) {
|
||||
$exception = new Writer\Exception\InvalidArgumentException('Enclosure "type" is not set');
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!isset($data['length'])) {
|
||||
if (! isset($data['length'])) {
|
||||
$exception = new Writer\Exception\InvalidArgumentException('Enclosure "length" is not set');
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((int) $data['length'] < 0 || !ctype_digit((string) $data['length'])) {
|
||||
if ((int) $data['length'] < 0 || ! ctype_digit((string) $data['length'])) {
|
||||
$exception = new Writer\Exception\InvalidArgumentException('Enclosure "length" must be an integer'
|
||||
. ' indicating the content\'s length in bytes');
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -246,9 +258,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getLink()) {
|
||||
return;
|
||||
}
|
||||
$link = $dom->createElement('link');
|
||||
|
@ -264,22 +278,25 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setId(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getId()
|
||||
&& !$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getId()
|
||||
&& ! $this->getDataContainer()->getLink()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$id = $dom->createElement('guid');
|
||||
$root->appendChild($id);
|
||||
if (!$this->getDataContainer()->getId()) {
|
||||
if (! $this->getDataContainer()->getId()) {
|
||||
$this->getDataContainer()->setId(
|
||||
$this->getDataContainer()->getLink());
|
||||
$this->getDataContainer()->getLink()
|
||||
);
|
||||
}
|
||||
$text = $dom->createTextNode($this->getDataContainer()->getId());
|
||||
$id->appendChild($text);
|
||||
if (!Uri::factory($this->getDataContainer()->getId())->isValid()) {
|
||||
if (! Uri::factory($this->getDataContainer()->getId())->isValid()) {
|
||||
$id->setAttribute('isPermaLink', 'false');
|
||||
}
|
||||
}
|
||||
|
@ -291,10 +308,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$link = $this->getDataContainer()->getCommentLink();
|
||||
if (!$link) {
|
||||
if (! $link) {
|
||||
return;
|
||||
}
|
||||
$clink = $this->dom->createElement('comments');
|
||||
|
@ -310,10 +329,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$categories = $this->getDataContainer()->getCategories();
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $cat) {
|
||||
|
|
|
@ -37,8 +37,10 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLanguage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if ($this->getDataContainer()->getLanguage()) {
|
||||
$root->setAttribute('xml:lang', $this->getDataContainer()
|
||||
->getLanguage());
|
||||
|
@ -53,13 +55,15 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setTitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one'
|
||||
. ' atom:title element but a title has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -81,9 +85,11 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDescription(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()) {
|
||||
return;
|
||||
}
|
||||
$subtitle = $dom->createElement('subtitle');
|
||||
|
@ -101,13 +107,15 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateModified(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one'
|
||||
. ' atom:updated element but a modification date has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -130,11 +138,16 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getGenerator()) {
|
||||
$this->getDataContainer()->setGenerator('Zend_Feed_Writer',
|
||||
Version::VERSION, 'http://framework.zend.com');
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getGenerator()) {
|
||||
$this->getDataContainer()->setGenerator(
|
||||
'Zend_Feed_Writer',
|
||||
Version::VERSION,
|
||||
'http://framework.zend.com'
|
||||
);
|
||||
}
|
||||
|
||||
$gdata = $this->getDataContainer()->getGenerator();
|
||||
|
@ -157,9 +170,11 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getLink()) {
|
||||
return;
|
||||
}
|
||||
$link = $dom->createElement('link');
|
||||
|
@ -177,16 +192,18 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setFeedLinks(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$flinks = $this->getDataContainer()->getFeedLinks();
|
||||
if (!$flinks || !array_key_exists('atom', $flinks)) {
|
||||
if (! $flinks || ! array_key_exists('atom', $flinks)) {
|
||||
$message = 'Atom 1.0 feed elements SHOULD contain one atom:link '
|
||||
. 'element with a rel attribute value of "self". This is the '
|
||||
. 'preferred URI for retrieving Atom Feed Documents representing '
|
||||
. 'this Atom feed but a feed link has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -211,10 +228,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->container->getAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
/**
|
||||
* Technically we should defer an exception until we can check
|
||||
* that all entries contain an author. If any entry is missing
|
||||
|
@ -252,16 +271,18 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setId(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getId()
|
||||
&& !$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getId()
|
||||
&& ! $this->getDataContainer()->getLink()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one '
|
||||
. 'atom:id element, or as an alternative, we can use the same '
|
||||
. 'value as atom:link however neither a suitable link nor an '
|
||||
. 'id have been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -269,9 +290,10 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
}
|
||||
}
|
||||
|
||||
if (!$this->getDataContainer()->getId()) {
|
||||
if (! $this->getDataContainer()->getId()) {
|
||||
$this->getDataContainer()->setId(
|
||||
$this->getDataContainer()->getLink());
|
||||
$this->getDataContainer()->getLink()
|
||||
);
|
||||
}
|
||||
$id = $dom->createElement('id');
|
||||
$root->appendChild($id);
|
||||
|
@ -286,10 +308,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCopyright(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$copyright = $this->getDataContainer()->getCopyright();
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
return;
|
||||
}
|
||||
$copy = $dom->createElement('rights');
|
||||
|
@ -305,10 +329,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setImage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$image = $this->getDataContainer()->getImage();
|
||||
if (!$image) {
|
||||
if (! $image) {
|
||||
return;
|
||||
}
|
||||
$img = $dom->createElement('logo');
|
||||
|
@ -324,12 +350,14 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateCreated()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateCreated()) {
|
||||
return;
|
||||
}
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$this->getDataContainer()->setDateModified(
|
||||
$this->getDataContainer()->getDateCreated()
|
||||
);
|
||||
|
@ -343,10 +371,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBaseUrl(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$baseUrl = $this->getDataContainer()->getBaseUrl();
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
return;
|
||||
}
|
||||
$root->setAttribute('xml:base', $baseUrl);
|
||||
|
@ -359,10 +389,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setHubs(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$hubs = $this->getDataContainer()->getHubs();
|
||||
if (!$hubs) {
|
||||
if (! $hubs) {
|
||||
return;
|
||||
}
|
||||
foreach ($hubs as $hubUrl) {
|
||||
|
@ -380,10 +412,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$categories = $this->getDataContainer()->getCategories();
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $cat) {
|
||||
|
|
|
@ -34,7 +34,7 @@ class Atom extends AbstractAtom implements Renderer\RendererInterface
|
|||
*/
|
||||
public function render()
|
||||
{
|
||||
if (!$this->container->getEncoding()) {
|
||||
if (! $this->container->getEncoding()) {
|
||||
$this->container->setEncoding('UTF-8');
|
||||
}
|
||||
$this->dom = new DOMDocument('1.0', $this->container->getEncoding());
|
||||
|
@ -75,7 +75,7 @@ class Atom extends AbstractAtom implements Renderer\RendererInterface
|
|||
if ($entry instanceof Writer\Entry) {
|
||||
$renderer = new Renderer\Entry\Atom($entry);
|
||||
} else {
|
||||
if (!$this->dom->documentElement->hasAttribute('xmlns:at')) {
|
||||
if (! $this->dom->documentElement->hasAttribute('xmlns:at')) {
|
||||
$this->dom->documentElement->setAttribute(
|
||||
'xmlns:at',
|
||||
'http://purl.org/atompub/tombstones/1.0'
|
||||
|
|
|
@ -34,8 +34,10 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLanguage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if ($this->getDataContainer()->getLanguage()) {
|
||||
$root->setAttribute('xml:lang', $this->getDataContainer()
|
||||
->getLanguage());
|
||||
|
@ -50,13 +52,15 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Feed\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setTitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one'
|
||||
. ' atom:title element but a title has not been set';
|
||||
$exception = new Feed\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -78,9 +82,11 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDescription(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()) {
|
||||
return;
|
||||
}
|
||||
$subtitle = $dom->createElement('subtitle');
|
||||
|
@ -98,13 +104,15 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Feed\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateModified(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one'
|
||||
. ' atom:updated element but a modification date has not been set';
|
||||
$exception = new Feed\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -127,11 +135,16 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getGenerator()) {
|
||||
$this->getDataContainer()->setGenerator('Zend_Feed_Writer',
|
||||
Version::VERSION, 'http://framework.zend.com');
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getGenerator()) {
|
||||
$this->getDataContainer()->setGenerator(
|
||||
'Zend_Feed_Writer',
|
||||
Version::VERSION,
|
||||
'http://framework.zend.com'
|
||||
);
|
||||
}
|
||||
|
||||
$gdata = $this->getDataContainer()->getGenerator();
|
||||
|
@ -154,9 +167,11 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getLink()) {
|
||||
return;
|
||||
}
|
||||
$link = $dom->createElement('link');
|
||||
|
@ -174,16 +189,18 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Feed\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setFeedLinks(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$flinks = $this->getDataContainer()->getFeedLinks();
|
||||
if (!$flinks || !array_key_exists('atom', $flinks)) {
|
||||
if (! $flinks || ! array_key_exists('atom', $flinks)) {
|
||||
$message = 'Atom 1.0 feed elements SHOULD contain one atom:link '
|
||||
. 'element with a rel attribute value of "self". This is the '
|
||||
. 'preferred URI for retrieving Atom Feed Documents representing '
|
||||
. 'this Atom feed but a feed link has not been set';
|
||||
$exception = new Feed\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -208,10 +225,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->container->getAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
/**
|
||||
* Technically we should defer an exception until we can check
|
||||
* that all entries contain an author. If any entry is missing
|
||||
|
@ -249,16 +268,18 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Feed\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setId(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getId()
|
||||
&& !$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getId()
|
||||
&& ! $this->getDataContainer()->getLink()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one '
|
||||
. 'atom:id element, or as an alternative, we can use the same '
|
||||
. 'value as atom:link however neither a suitable link nor an '
|
||||
. 'id have been set';
|
||||
$exception = new Feed\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -266,9 +287,10 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
}
|
||||
}
|
||||
|
||||
if (!$this->getDataContainer()->getId()) {
|
||||
if (! $this->getDataContainer()->getId()) {
|
||||
$this->getDataContainer()->setId(
|
||||
$this->getDataContainer()->getLink());
|
||||
$this->getDataContainer()->getLink()
|
||||
);
|
||||
}
|
||||
$id = $dom->createElement('id');
|
||||
$root->appendChild($id);
|
||||
|
@ -283,10 +305,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCopyright(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$copyright = $this->getDataContainer()->getCopyright();
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
return;
|
||||
}
|
||||
$copy = $dom->createElement('rights');
|
||||
|
@ -294,6 +318,7 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
$text = $dom->createTextNode($copyright);
|
||||
$copy->appendChild($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set feed level logo (image)
|
||||
*
|
||||
|
@ -301,10 +326,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setImage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$image = $this->getDataContainer()->getImage();
|
||||
if (!$image) {
|
||||
if (! $image) {
|
||||
return;
|
||||
}
|
||||
$img = $dom->createElement('logo');
|
||||
|
@ -320,12 +347,14 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateCreated()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateCreated()) {
|
||||
return;
|
||||
}
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$this->getDataContainer()->setDateModified(
|
||||
$this->getDataContainer()->getDateCreated()
|
||||
);
|
||||
|
@ -339,10 +368,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBaseUrl(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$baseUrl = $this->getDataContainer()->getBaseUrl();
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
return;
|
||||
}
|
||||
$root->setAttribute('xml:base', $baseUrl);
|
||||
|
@ -355,10 +386,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setHubs(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$hubs = $this->getDataContainer()->getHubs();
|
||||
if (!$hubs) {
|
||||
if (! $hubs) {
|
||||
return;
|
||||
}
|
||||
foreach ($hubs as $hubUrl) {
|
||||
|
@ -376,10 +409,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$categories = $this->getDataContainer()->getCategories();
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $cat) {
|
||||
|
|
|
@ -33,7 +33,7 @@ class Source extends AbstractAtom implements Renderer\RendererInterface
|
|||
*/
|
||||
public function render()
|
||||
{
|
||||
if (!$this->container->getEncoding()) {
|
||||
if (! $this->container->getEncoding()) {
|
||||
$this->container->setEncoding('UTF-8');
|
||||
}
|
||||
$this->dom = new DOMDocument('1.0', $this->container->getEncoding());
|
||||
|
@ -71,9 +71,11 @@ class Source extends AbstractAtom implements Renderer\RendererInterface
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getGenerator()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getGenerator()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class AtomSource extends AbstractAtom implements Renderer\RendererInterface
|
|||
*/
|
||||
public function render()
|
||||
{
|
||||
if (!$this->container->getEncoding()) {
|
||||
if (! $this->container->getEncoding()) {
|
||||
$this->container->setEncoding('UTF-8');
|
||||
}
|
||||
$this->dom = new DOMDocument('1.0', $this->container->getEncoding());
|
||||
|
@ -73,9 +73,11 @@ class AtomSource extends AbstractAtom implements Renderer\RendererInterface
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getGenerator()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getGenerator()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,10 +99,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLanguage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$lang = $this->getDataContainer()->getLanguage();
|
||||
if (!$lang) {
|
||||
if (! $lang) {
|
||||
return;
|
||||
}
|
||||
$language = $dom->createElement('language');
|
||||
|
@ -118,13 +120,15 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setTitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'RSS 2.0 feed elements MUST contain exactly one'
|
||||
. ' title element but a title has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -146,13 +150,15 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDescription(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()) {
|
||||
$message = 'RSS 2.0 feed elements MUST contain exactly one'
|
||||
. ' description element but one has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -172,9 +178,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateModified(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -193,9 +201,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getGenerator()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getGenerator()) {
|
||||
$this->getDataContainer()->setGenerator(
|
||||
'Zend_Feed_Writer',
|
||||
Version::VERSION,
|
||||
|
@ -225,14 +235,16 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$value = $this->getDataContainer()->getLink();
|
||||
if (!$value) {
|
||||
if (! $value) {
|
||||
$message = 'RSS 2.0 feed elements MUST contain exactly one'
|
||||
. ' link element but one has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -243,7 +255,7 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
$root->appendChild($link);
|
||||
$text = $dom->createTextNode($value);
|
||||
$link->appendChild($text);
|
||||
if (!Uri::factory($value)->isValid()) {
|
||||
if (! Uri::factory($value)->isValid()) {
|
||||
$link->setAttribute('isPermaLink', 'false');
|
||||
}
|
||||
}
|
||||
|
@ -255,10 +267,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->getDataContainer()->getAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $data) {
|
||||
|
@ -280,10 +294,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCopyright(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$copyright = $this->getDataContainer()->getCopyright();
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
return;
|
||||
}
|
||||
$copy = $dom->createElement('copyright');
|
||||
|
@ -300,19 +316,21 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setImage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$image = $this->getDataContainer()->getImage();
|
||||
if (!$image) {
|
||||
if (! $image) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($image['title']) || empty($image['title'])
|
||||
|| !is_string($image['title'])
|
||||
if (! isset($image['title']) || empty($image['title'])
|
||||
|| ! is_string($image['title'])
|
||||
) {
|
||||
$message = 'RSS 2.0 feed images must include a title';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -320,13 +338,13 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($image['link']) || !is_string($image['link'])
|
||||
|| !Uri::factory($image['link'])->isValid()
|
||||
if (empty($image['link']) || ! is_string($image['link'])
|
||||
|| ! Uri::factory($image['link'])->isValid()
|
||||
) {
|
||||
$message = 'Invalid parameter: parameter \'link\''
|
||||
. ' must be a non-empty string and valid URI/IRI';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -354,11 +372,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
$img->appendChild($link);
|
||||
|
||||
if (isset($image['height'])) {
|
||||
if (!ctype_digit((string) $image['height']) || $image['height'] > 400) {
|
||||
if (! ctype_digit((string) $image['height']) || $image['height'] > 400) {
|
||||
$message = 'Invalid parameter: parameter \'height\''
|
||||
. ' must be an integer not exceeding 400';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -371,11 +389,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
$img->appendChild($height);
|
||||
}
|
||||
if (isset($image['width'])) {
|
||||
if (!ctype_digit((string) $image['width']) || $image['width'] > 144) {
|
||||
if (! ctype_digit((string) $image['width']) || $image['width'] > 144) {
|
||||
$message = 'Invalid parameter: parameter \'width\''
|
||||
. ' must be an integer not exceeding 144';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -388,11 +406,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
$img->appendChild($width);
|
||||
}
|
||||
if (isset($image['description'])) {
|
||||
if (empty($image['description']) || !is_string($image['description'])) {
|
||||
if (empty($image['description']) || ! is_string($image['description'])) {
|
||||
$message = 'Invalid parameter: parameter \'description\''
|
||||
. ' must be a non-empty string';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -413,12 +431,14 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateCreated()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateCreated()) {
|
||||
return;
|
||||
}
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$this->getDataContainer()->setDateModified(
|
||||
$this->getDataContainer()->getDateCreated()
|
||||
);
|
||||
|
@ -432,9 +452,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLastBuildDate(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getLastBuildDate()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getLastBuildDate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -453,10 +475,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBaseUrl(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$baseUrl = $this->getDataContainer()->getBaseUrl();
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
return;
|
||||
}
|
||||
$root->setAttribute('xml:base', $baseUrl);
|
||||
|
@ -469,10 +493,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$categories = $this->getDataContainer()->getCategories();
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $cat) {
|
||||
|
|
50
web/vendor/zendframework/zend-feed/src/Writer/StandaloneExtensionManager.php
vendored
Normal file
50
web/vendor/zendframework/zend-feed/src/Writer/StandaloneExtensionManager.php
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Writer;
|
||||
|
||||
class StandaloneExtensionManager implements ExtensionManagerInterface
|
||||
{
|
||||
private $extensions = [
|
||||
'Atom\Renderer\Feed' => Extension\Atom\Renderer\Feed::class,
|
||||
'Content\Renderer\Entry' => Extension\Content\Renderer\Entry::class,
|
||||
'DublinCore\Renderer\Entry' => Extension\DublinCore\Renderer\Entry::class,
|
||||
'DublinCore\Renderer\Feed' => Extension\DublinCore\Renderer\Feed::class,
|
||||
'ITunes\Entry' => Extension\ITunes\Entry::class,
|
||||
'ITunes\Feed' => Extension\ITunes\Feed::class,
|
||||
'ITunes\Renderer\Entry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'ITunes\Renderer\Feed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'Slash\Renderer\Entry' => Extension\Slash\Renderer\Entry::class,
|
||||
'Threading\Renderer\Entry' => Extension\Threading\Renderer\Entry::class,
|
||||
'WellFormedWeb\Renderer\Entry' => Extension\WellFormedWeb\Renderer\Entry::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Do we have the extension?
|
||||
*
|
||||
* @param string $extension
|
||||
* @return bool
|
||||
*/
|
||||
public function has($extension)
|
||||
{
|
||||
return array_key_exists($extension, $this->extensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the extension
|
||||
*
|
||||
* @param string $extension
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($extension)
|
||||
{
|
||||
$class = $this->extensions[$extension];
|
||||
return new $class();
|
||||
}
|
||||
}
|
|
@ -76,7 +76,7 @@ class Writer
|
|||
*/
|
||||
public static function getExtensionManager()
|
||||
{
|
||||
if (!isset(static::$extensionManager)) {
|
||||
if (! isset(static::$extensionManager)) {
|
||||
static::setExtensionManager(new ExtensionManager());
|
||||
}
|
||||
return static::$extensionManager;
|
||||
|
@ -105,13 +105,16 @@ class Writer
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (!$manager->has($feedName)
|
||||
&& !$manager->has($entryName)
|
||||
&& !$manager->has($feedRendererName)
|
||||
&& !$manager->has($entryRendererName)
|
||||
if (! $manager->has($feedName)
|
||||
&& ! $manager->has($entryName)
|
||||
&& ! $manager->has($feedRendererName)
|
||||
&& ! $manager->has($entryRendererName)
|
||||
) {
|
||||
throw new Exception\RuntimeException('Could not load extension: ' . $name
|
||||
. 'using Plugin Loader. Check prefix paths are configured and extension exists.');
|
||||
throw new Exception\RuntimeException(sprintf(
|
||||
'Could not load extension "%s" using Plugin Loader. '
|
||||
. 'Check prefix paths are configured and extension exists.',
|
||||
$name
|
||||
));
|
||||
}
|
||||
if ($manager->has($feedName)) {
|
||||
static::$extensions['feed'][] = $feedName;
|
||||
|
|
Reference in a new issue