Zum Inhalt springen

yoububeapi: Fatal error: Call to a member function get() on a non-object

Erstellt am 10. April 2014 · 1 Antwort · letzte Antwort am 15. April 2014

Tags: PHP, TYPO3 6.x, Frage

freeatweb ·

Hallo,
ich möchte die Extension youtubeapi auf einer TYPO3 6.1.7-Installation verwenden.

Youtubeapi benötigt die Ext. div und lib.
Um lib auf 6.1.7 funktionsfähig zu machen, habe ich folgende Änderungen vorgenommen:

File class.tx_lib_t3loader.php:

function makeInstanceClassName($class, $alternativeKey='', $prefix = 'class.', $suffix = '.php') {
  if(tx_lib_t3Loader::load($class, $alternativeKey, $prefix, $suffix)) {
// diese Zeile   return t3lib_div::makeInstanceClassName($class);

// ersetzt durch: return t3lib_div::makeInstance($class);
  } else {
   return false;
  }
 }

class.tx_lib_parameters.php:

function tx_lib_parameters ($controller) {
  parent::tx_lib_object($controller);

// diese Zeile ersetzt 
  $this->setArray(t3lib_div::GParrayMerged($controller->getDesignator()));

// durch
$this->setArray(t3lib_div::_GPmerged($controller));


  // Initialize the cHash system if there are parameters available
  if ($GLOBALS['TSFE'] && count($parameters)) {
   $GLOBALS['TSFE']->reqCHash();
  }
 }

Die Extension lib funktioniert nun soweit.
Nur bekomme ich im Frontend den PHP-Error:

Fatal error: Call to a member function get() on a non-object in \ext\youtubeapi\models\class.tx_youtubeapi_models_retrieve.php on line 39

Hier ein Auszug aus dem PHP-File:

tx_div::load('tx_lib_controller');
tx_div::load('tx_lib_link');

class tx_youtubeapi_models_retrieve extends tx_lib_object {
   var $className = 'tx_youtubeapi_models_retrieve';
   var $extensionKey = 'tx_youtubeapi';

   // constructor
   function tx_youtubeapi_models_retrieve($controller = null, $parameter = null) {

         parent::tx_lib_object($controller,$parameter);

	 // get flexform-data
--> LINE 38:  $this->baseUrl = $this->controller->configurations->get('baseURL');

Leider weiß ich jetzt nicht wie ich das lösen könnte bzw. durch was ich $this->controller->configurations->get()
ersetzen könnte.

Ich freue mich auf Ideen und Rückmeldungen

Beste Grüße

freeatweb · · Beste Antwort

die controller aus der Ext. "lib" liefern keine Werte mehr :/
ich hab zeitgründen eine "russische" Lösung programmiert:

EXT: youtubeapi/models/class.tx_youtubeapi_models_retrieve.php

// get flexform-data
		$this->baseUrl = $this->controller->configurations->get('baseURL');
		$this->maxResults = $this->controller->configurations->get('maxResults');
		if(!$this->maxResults) $this->maxResults = 5;
		$this->orderBy = $this->controller->configurations->get('orderBy');
		$this->startIndex = 1;
		
		//$user = $this->controller->configurations->get('user');
		$this->channel = $this->controller->configurations->get('channel');
		$this->favorites = $this->controller->configurations->get('favorites');
		$this->searchTerm = $this->_searchable( $this->controller->configurations->get('searchTerm') );
		$this->category = $this->_categorized( $this->controller->configurations->get('category') );
		$this->keywords = $this->_keyworded( $this->controller->configurations->get('keywords') );
		$this->playlist = $this->controller->configurations->get('playList');

ersetzt durch:

$select = 'content.pi_flexform';
		$from = 'tt_content as content';
		$where = 'content.list_type = "tx_youtubeapi"';
		$where .= ' AND content.pid = ' . $GLOBALS['TSFE']->id;
		
		$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $from, $where);
		
		while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
		    $xml = t3lib_div::xml2array($row['pi_flexform']);
		    
		    $baseURL = 'http://gdata.youtube.com/feeds/api/';
		    $maxResults = $xml['data']['listParams']['lDEF']['maxResults'];
		    $orderBy = $xml['data']['listParams']['lDEF']['orderBy']['vDEF'];
		    
		    $channel = $xml['data']['userRelated']['lDEF']['channel']['vDEF'];
		//    $favorites =  $xml['data']['userRelated']['lDEF']['channel']['vDEF'];
		    $searchTerm =  $xml['data']['userRelated']['lDEF']['searchTerm']['vDEF'];
		    $category = $xml['data']['userRelated']['lDEF']['category']['vDEF'];
		    $keywords = $xml['data']['userRelated']['lDEF']['keywords']['vDEF'];
		    $playlist = $xml['data']['userRelated']['lDEF']['playList']['vDEF'];
		}
		
		$this->baseUrl = $baseURL;
		$this->maxResults = $maxResults;
		if(empty($maxResults)) $this->maxResults = 5;
		$this->orderBy = $orderBy;
		$this->startIndex = 1;
		$this->channel = $channel;
	//	$this->favorites = $this->controller->configurations->get('favorites');
		$this->searchTerm = $searchTerm;
		$this->category = $category;
		$this->keywords = $keywords;
		$this->playlist = $playlist;

Über elegantere Lösungswege bin ich natürlich sehr froh 😉