Explorar o código

Bridge getExtraInfos (#432)

* add function getExtraInfos() to BridgeAbstract

* replace call to $bridge->getName() and $bridge->getURI() by $bridge->getExtraInfos()

replace call to $bridge->getName() and $bridge->getURI() by $bridge->getExtraInfos() defined by default in BridgeAbstract.
So we could pass additionals ExtraInfos from custom bridges to custom formats.
Badet Aurélien %!s(int64=7) %!d(string=hai) anos
pai
achega
c702a0e69f
Modificáronse 2 ficheiros con 10 adicións e 7 borrados
  1. 3 7
      index.php
  2. 7 0
      lib/BridgeAbstract.php

+ 3 - 7
index.php

@@ -159,13 +159,9 @@ try {
 		// Data transformation
 		try {
 			$format = Format::create($format);
-			$format
-				->setItems($bridge->getItems())
-				->setExtraInfos(array(
-					'name' => $bridge->getName(),
-					'uri' => $bridge->getURI(),
-				))
-				->display();
+			$format->setItems($bridge->getItems());
+			$format->setExtraInfos($bridge->getExtraInfos());
+			$format->display();
 		} catch(Exception $e){
 			echo "The bridge has crashed. You should report this to the bridges maintainer";
 		}

+ 7 - 0
lib/BridgeAbstract.php

@@ -194,6 +194,13 @@ abstract class BridgeAbstract implements BridgeInterface {
 	public function getURI(){
 		return static::URI;
 	}
+	
+	public function getExtraInfos(){
+		$extraInfos = array();
+		$extraInfos['name']= $this->getName();
+		$extraInfos['uri']= $this->getURI();
+		return $extraInfos;
+	}
 
 	public function setCache(\CacheInterface $cache){
 		$this->cache = $cache;