[TYPO3-german] extbase add new eintrag ohne formular

Cedric Ziel cedric at cedric-ziel.com
Fri Feb 7 16:04:15 CET 2014


  Ich glaube, du ziehst das ganze falsch auf...

1.) Repositories lassen sich prima injizieren:

/**
* @var \TYPO3\JobsDfu\Domain\Repository\OccupationcategoryRepository
* @inject
*/
protected $occupationcategoryRepository;

Das setzt voraus, das du ein solches Repository auch besitzt.

Dann kannst du mit $this->occupationcategoryRepository->find* dein Repo
abfragen.

2.) Kein makeInstance für einfache Klassen. Benutze 
$newCat = new \TYPO3\JobsDfu\Domain\Model\Occupationcategory();
$newCat->setName('hallo');

Schau dir mal die Flow Doku, oder das Extbase Buch auf forge an, um dich
mit den grundlegenden Paradigmen vertraut zu machen. Ich glaube, du hast
grundsätzliche Probleme beim Gebrauch.

Zitat von arianesardinas <asardinas at gmx.de>:

> hm...
>
> ich habe versucht das objekt zu  instanziieren und zwar so:
>
> $repository =
>
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\TYPO3\JobsDfu\Domain\Model\Occupationcategory');
>
> aber ich bekomme ein error: Fatal error: Class
> '\\TYPO3\JobsDfu\Domain\Model\Occupationcategory' not found meine ganze
> action sieht so aus jetzt:
>
> public function newAction(\TYPO3\JobsDfu\Domain\Model\Occupationcategory
> $newOccupationcategory = NULL) {
>
> $repository =
>
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\TYPO3\JobsDfu\Domain\Model\Occupationcategory');
>
> $repository ->:setProperty($newOccupationcategory, 'name', 'hallo');
>
> }
> es geht auch nicht, jemand eine idee?
> _______________________________________________
> TYPO3-german mailing list
>
TYPO3-german at lists.typo3.orghttp://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-german


More information about the TYPO3-german mailing list