[FLOW3-general] Beginners question: Objects are not persisted / saved in DB

Susanne Moog typo3 at susanne-moog.de
Sun Jan 31 08:36:07 CET 2010


Hi,

Michael Sauter wrote:
> On 30.01.10 13:58, Susanne Moog wrote:
>> If I var_dump($account) it shows up correctly with the wanted
>> properties, however if I call $this->accountRepository->findAll() after
>> adding the account to the repository it is always empty.
> 
> When are you calling findAll()? The models are not persisted immediately
> after you add them to the repository (see
> http://flow3.typo3.org/documentation/manuals/flow3/flow3.persistenceframework/,
> section 12.3)
> 
> If that's not the problem: Does the blog example work?

I'm calling findAll() in the indexAction of my Account controller. So it
should already be there. The blog example works as expected, that's why
I think I'm just missing some detail.

Here a bit more infos:

My Account model is of scope "prototype" and now declared as an entity.
My repository just consists of:
class AccountRepository extends \F3\FLOW3\Persistence\Repository {

}

And my controller looks like:

class AccountController extends \F3\FLOW3\MVC\Controller\ActionController {

	/**
	 * @inject
	 * @var \F3\Accounts\Domain\Repository\AccountRepository
	 */
	protected $accountRepository;

	/**
	 * Index action
	 *
	 * @return void
	 */
	public function indexAction() {
		$accounts = $this->accountRepository->findAll();

		$this->view->assign('foos', $accounts);
	}
	
	/**
	 * Displays a form for creating a new account
	 *
	 * @param \F3\Accounts\Domain\Model\Account $newAccount A fresh account
object taken as a basis for the rendering
	 * @return string An HTML form for creating a new account
	 * @dontvalidate $newAccount
	 */
	public function newAction(\F3\Accounts\Domain\Model\Account $newAccount
= NULL) {
		$this->view->assign('newAccount', $newAccount);
	}

	/**
	 * Creates a new post
	 *
	 * @param \F3\Accounts\Domain\Model\Account $newAccount A fresh Account
object which has not yet been added to the repository
	 * @return void
	 */
	public function createAction(\F3\Accounts\Domain\Model\Account
$newAccount) {
		$this->accountRepository->add($newAccount);
		$this->redirect('index');
	}
	
}


Now since I declared the Account to be an entity, I get a new error. If
I do a findAll() and debug the contents afterwards, my browser kills
itself after showing lots and lots of things, like server variables etc.
and I get an error on calling the indexAction in the browser
"#1248356140: Cannot cast object of type
"F3\Accounts\Domain\Model\Account_AOPProxy_Development" to string."

Perhaps somebody can help me based on these infos?

Thanks a lot,

Susanne


More information about the FLOW3-general mailing list