setExtra() public method

public setExtra ( $key, $value )
$key
$value
Ejemplo n.º 1
0
 public function testItem()
 {
     $item = new Item();
     $date = new DateTime();
     $item->setId('id');
     $item->setName('name');
     $item->setIntro('intro');
     $item->setContent('content');
     $item->setSource('source');
     $item->setAuthor('author');
     $item->setImage('image');
     $item->setDate($date);
     $item->setExtra('key', 'value');
     $item->setTags(array('tag'));
     $this->assertEquals('id', $item->getId());
     $this->assertEquals('name', $item->getName());
     $this->assertEquals('intro', $item->getIntro());
     $this->assertEquals('content', $item->getContent());
     $this->assertEquals('source', $item->getSource());
     $this->assertEquals('author', $item->getAuthor());
     $this->assertEquals('image', $item->getImage());
     $this->assertEquals($date, $item->getDate());
     $this->assertEquals('value', $item->getExtra('key'));
     $this->assertEquals(null, $item->getExtra('key-no-exist'));
     $this->assertEquals(array('tag'), $item->getTags());
 }
Ejemplo n.º 2
0
 /**
  * @param Item $item
  *
  * @return bool|string
  */
 protected function setImagesFromContent(Item $item)
 {
     $allImages = $this->getImages($item->getContent());
     $images = array();
     foreach ($allImages as $image) {
         if ($this->isOnIgnoredPatterns($image)) {
             continue;
         }
         $images[$image] = $image;
     }
     $item->setExtra('images', array_values($images));
 }
Ejemplo n.º 3
0
 /**
  * Execute the Aggregator
  *
  * @param DOMElement $node
  * @param Item       $item
  */
 public function process(DOMElement $node, Item $item)
 {
     foreach ($this->keys as $key) {
         $item->setExtra($key, $this->getValue($node, $key));
     }
 }