-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from SMillerDev/release/3.0
Add support for language/lang
- Loading branch information
Showing
9 changed files
with
102 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/* | ||
* This file is part of the feed-io package. | ||
* | ||
* (c) Alexandre Debril <alex.debril@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FeedIo\Rule; | ||
|
||
use FeedIo\Feed\NodeInterface; | ||
use FeedIo\FeedInterface; | ||
use FeedIo\RuleAbstract; | ||
|
||
class Language extends RuleAbstract | ||
{ | ||
const NODE_NAME = 'language'; | ||
|
||
/** | ||
* @param NodeInterface $node | ||
* @param \DOMElement $element | ||
* @return $this | ||
*/ | ||
public function setProperty(NodeInterface $node, \DOMElement $element) | ||
{ | ||
if ($node instanceof FeedInterface) { | ||
$node->set(static::NODE_NAME, $element->nodeValue); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* creates the accurate DomElement content according to the $item's property | ||
* | ||
* @param \DomDocument $document | ||
* @param NodeInterface $node | ||
* @return \DomElement | ||
*/ | ||
public function createElement(\DomDocument $document, NodeInterface $node) | ||
{ | ||
if (!($node instanceof FeedInterface) || is_null($node->getLanguage())) { | ||
return; | ||
} | ||
|
||
return $document->createElement($this->getNodeName(), $node->getLanguage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters