[TYPO3-german] Mal wieder Extbase-Mapping

David Greiner davidgreiner at gmx.net
Tue Feb 28 20:33:47 CET 2012


Hallo Liste!

Ich weiß nicht, ob ich mich einfach zu dumm anstelle, oder es einfach nicht
kapiere. Zweiteres kann genauso gut wie ersteres zu treffen. 
Es geht um folgendes. Ich möchte in einer Extbase-Extension lediglich die
"recipients" der in der DB gespeicherten Powermail-Mails ausgeben. Kann
eigentlich nicht so schwer sein. So dacht ich. 

Was ich bisher gemacht habe: 

- Extension im Builder inkl. FE-Plugin angelegt
- recipients als Property angelegt 
- "Map to existing table" --> tx_powermail_mails

Ich dachte zwar, dass der neue Extension_Builder jetzt auch das Typoscript
für das Mapping anlegt, scheint er aber nicht zu machen. Oder wird es
neuerdings nicht mehr benötigt? 
Wie dem auch sei, im Typoscript steht folgendes:

-----------TS-------------

plugin.tx_test {
	view {
		templateRootPath = {$plugin.tx_test.view.templateRootPath}
		partialRootPath = {$plugin.tx_test.view.partialRootPath}
		layoutRootPath = {$plugin.tx_test.view.layoutRootPath}
	}
	persistence {
		storagePid = {$plugin.tx_test.persistence.storagePid}
                classes {
                    Tx_Test_Domain_Model_List {
                        mapping {
                            tableName = tx_powermail_mails
                            recordType = Tx_Test_Domain_Model_List
                            columns {
                                recipient.mapOnProperty = recipient
                            }
                        }
                    }
                }
        }
}
config.tx_extbase.persistence.classes.Tx_Test_Domain_Model_List.mapping.tabl
eName = tx_powermail_mails

-----------TS-------------




Im Model: 
-----------Model-------------

class Tx_Test_Domain_Model_List extends
Tx_Extbase_DomainObject_AbstractEntity {

	/**
	 * recipient
	 *
	 * @var string
	 */
	protected $recipient;

	/**
	 * Returns the recipient
	 *
	 * @return string $recipient
	 */
	public function getRecipient() {
		return $this->recipient;
	}

	/**
	 * Sets the recipient
	 *
	 * @param string $recipient
	 * @return void
	 */
	public function setRecipient($recipient) {
		$this->recipient = $recipient;
	}

}

-----------Model-------------



im Repo:
-----------Repo-------------

class Tx_Test_Domain_Repository_ListRepository extends
Tx_Extbase_Persistence_Repository {
}

-----------Repo-------------


und letztlich im Controller:
-----------Controller-------------

class Tx_Test_Controller_ListController extends
Tx_Extbase_MVC_Controller_ActionController {

	/**
	 * listRepository
	 *
	 * @var Tx_Test_Domain_Repository_ListRepository
	 */
	protected $listRepository;

	/**
	 * injectListRepository
	 *
	 * @param Tx_Test_Domain_Repository_ListRepository $listRepository
	 * @return void
	 */
	public function
injectListRepository(Tx_Test_Domain_Repository_ListRepository
$listRepository) {
		$this->listRepository = $listRepository;
	}

	/**
	 * action list
	 *
	 * @return void
	 */
	public function listAction() {
		$lists = $this->listRepository->findAll();
		$this->view->assign('lists', $lists);
	}

}

-----------Controller-------------




Naiv wie ich bin, gehe ich jetzt davon aus, dass auf Grund des Mappings im
Typoscript die findAll() Methode im Controller/Repo nicht mehr auf die
(sowieso nicht vorhandene..) Extensioneigene Tabelle sondern auf die
Powermail-Tabelle zugreift und mir auf Grund der im Model definierten
Datentypen die recipients liefert. 
Aber mein Template bleibt leer. 

Wo ist der Fehler im Code bzw. in meinem Ansatz? 

Ps: Es wird doch einen schöneren Weg als
--------------------
$query = $this->createQuery();
	$query->getQuerySettings()->setReturnRawQueryResult(TRUE);
	$query->statement('SELECT recipient from tx_powermail_mails');
	return $query->execute();
--------------------
geben?


Grüße, David. 




More information about the TYPO3-german mailing list