Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function getItems()
 {
     $items = [];
     foreach ($this->contents as $content) {
         if (isset($content['type']) === false) {
             continue;
         }
         if (isset($content['permalink']) === false) {
             continue;
         }
         $item = new Item($content['type'], $content['permalink']);
         if (isset($content['content']) === true) {
             $item->setContent($content['content']);
         }
         if (isset($content['content_extension']) === true) {
             $item->setContentExtension($content['content_extension']);
         }
         if (isset($content['title']) === true) {
             $item->setTitle($content['title']);
         }
         if (isset($content['date']) === true) {
             $item->setDate(new \DateTime($content['date']));
         }
         if (isset($content['attributes']) === true) {
             $item->setAttributes($content['attributes']);
         }
         $items[] = $item;
     }
     return $items;
 }
Beispiel #2
0
 public function testGetDate()
 {
     $datetime = new \DateTime();
     $item = new Item(Item::TYPE_PAGE, '/date');
     $item->setDate($datetime);
     $this->assertEquals($datetime, $item->getDate());
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function getItems()
 {
     $line = 1;
     $items = [];
     $isFirstRow = true;
     $reader = $this->buildCsvReader();
     $rows = $reader->fetchAssoc(['title', 'permalink', 'content', 'published_at', 'categories', 'tags', 'markup']);
     foreach ($rows as $row) {
         if ($this->options['not_header'] == false && $isFirstRow == true) {
             ++$line;
             $isFirstRow = false;
             continue;
         }
         $data = $this->resolveCsvRow($row, $line);
         $item = new Item(Item::TYPE_POST, $data['permalink']);
         $item->setDate($data['published_at']);
         $item->setContent($data['content']);
         $item->setTitle($data['title']);
         $item->setContentExtension($data['markup']);
         $attributes = [];
         if (count($data['categories']) > 0) {
             $attributes['categories'] = $data['categories'];
         }
         if (count($data['tags']) > 0) {
             $attributes['tags'] = $data['tags'];
         }
         $item->setAttributes($attributes);
         $items[] = $item;
         ++$line;
     }
     return $items;
 }