public function Feed::orderByDate in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/zendframework/zend-feed/src/Writer/Feed.php \Zend\Feed\Writer\Feed::orderByDate()
Orders all indexed entries by date, thus offering date ordered readable content where a parser (or Homo Sapien) ignores the generic rule that XML element order is irrelevant and has no intrinsic meaning.
Using this method will alter the original indexation.
Return value
File
- vendor/
zendframework/ zend-feed/ src/ Writer/ Feed.php, line 134
Class
Namespace
Zend\Feed\WriterCode
public function orderByDate() {
/**
* Could do with some improvement for performance perhaps
*/
$timestamp = time();
$entries = [];
foreach ($this->entries as $entry) {
if ($entry
->getDateModified()) {
$timestamp = (int) $entry
->getDateModified()
->getTimestamp();
}
elseif ($entry
->getDateCreated()) {
$timestamp = (int) $entry
->getDateCreated()
->getTimestamp();
}
$entries[$timestamp] = $entry;
}
krsort($entries, SORT_NUMERIC);
$this->entries = array_values($entries);
return $this;
}