Hallo Zusammen,
ich hab in meinem Controller zwei Actions (listAction, Ausgabe aller Daten) und testAction(Ausgabe bestimmter Daten)
Im Repository habe ich folgende Funktion zur Einzelabfrage erstellt:
class Tx_Inventory_Domain_Repository_ProductRepository extends Tx_Extbase_Persistence_Repository {
public function findProduct($product) {
$query = $this->createQuery();
return $query->matching($query->equals('name',$product))->execute();
}
}
und hier mein Controller der diese Funktion beim Klick auf den Link aufrufen soll:
<?php
class Tx_Inventory_Controller_InventoryController extends Tx_Extbase_MVC_Controller_ActionController {
public function listAction() {
$productRepository = t3lib_div::makeInstance('Tx_Inventory_Domain_Repository_ProductRepository');
$products = $productRepository->findAll();
$this->view->assign('products', $products);
}
public function testAction() {
$this->productRepository = t3lib_div::makeInstance('Tx_Inventory_Domain_Repository_ProductRepository');
$this->view->assign('products', $this->productRepository->findProduct('produkt1'));
}
}
testAction() wird aufgerufen aber ncihts ausgegeben.
Wenn ich die Funktion findProduct() in listAction aufrufe, dann klappt es.
Woran kann das liegen, dass in testAction meine erstellte Funktion nicht aufgerufen wird?
habe ich etwas vergessen?
Also die Daten werden mit var_dump() ausgegeben aber nicht mit "$this->view->assign
Danke schon mal :-)
Hallo,
bist du dir sicher, dass produkt1 existiert?
Auch ist mir aufgefallen, dass du einmal schreibst
$productRepository = t3lib_div::makeInstance('Tx_Inventory_Domain_Repository_ProductRepository');
// und einmal
$this->productRepository = t3lib_div::makeInstance('Tx_Inventory_Domain_Repository_ProductRepository');
mach aus $this->productRepository mal $productRepository.
Gruß typonewbe
hallo,
klappt irgendwie alles nicht...
bekomme z.b. per echo in meiner selbsterstellten methode was ausgegeben, aber wenn ich den code aus listAction in meine showAction eingebe, dann kommt gar nichts aus...
es wird zwar die methode aufgerufen aber nichts ausgegben, woran kann das liegen?
<?php
class Tx_Inventory_Controller_InventoryController extends Tx_Extbase_MVC_Controller_ActionController {
/**
* @var Tx_Inventory_Domain_Model_InventoryRepository
*/
protected $inventoryRepository;
/**
* Initializes the current action
*
* @return void
*/
public function initializeAction() {
$this->productRepository = t3lib_div::makeInstance('Tx_Inventory_Domain_Repository_ProductRepository');
}
public function listAction() {
$products = $this->productRepository->findAll();
$this->view->assign('products', $products);
}
/**
* @param Tx_Inventory_Domain_Model_Product $products The offer to be displayed
* @return string The rendered HTML string
*/
public function showAction(Tx_Inventory_Domain_Model_Product $products) {
$products = $this->productRepository->findAll();
$this->view->assign('products', $products);
}
}
?>
Gelöst:
Es muss ein Template mit dem gleichen Dateiname + .html estellt werden wie der Name der Action.
Also Methode: testAction()
Template: test.html
ich denke daran lag es....