[TYPO3-mvc] Extbase mapping to foreign table doesn't work

David Greiner davidgreiner at gmx.net
Wed Feb 29 19:24:13 CET 2012


Hi boys and girls!

I'm trying to list some entries from a foreign table (tx_powermail_mails) in
an extbase-extension. But something is going wrong. 
I have created a blank extension with the new extension_builder (v2.2.0) and
"map to existing table" --> tx_powermail_mails. Further I have created a
property called "recipients" (like the column in table tx_powermail_mails)
and added the following typoscript. 


-----------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-------------



The model looks like this:
-----------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-------------


The repository like this:
-----------Repo-------------

class Tx_Test_Domain_Repository_ListRepository extends
Tx_Extbase_Persistence_Repository { }

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


and the controller like this:
-----------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-------------


I've thought that now it should be possible to connect to the foreign table
and list their entries in my fluid-template. 
But $lists is still empty. Whats going wrong? 

It would be great if somebody take some minutes to help me :) 

Google shows almost only tutorials for how to mapping to fe_user-table with
the possibilities which are already included in extbase.


PS: Sorry for my bad english ;)

Greets, David. 









More information about the TYPO3-project-typo3v4mvc mailing list