extbase , Extbase: inject repository into domain model

Extbase: inject repository into domain model


Tag: extbase

I am currently working with Typo3 6.2.10 and Extbase.

I am trying to inject a repository into my domain model like this:

class MyModel extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
     * @inject
     * @var \Vendor\Package\Domain\Repository\SomeRepository
    protected $someRepository;

However, $this->someRepository is always null. Injecting repositories into controllers always works though.

Thank you in advance!


Sorry, I found the solution myself.

I tried to instantiate the model using new keyword which (ofc) doesn't work.

I had to use $this->objectManager->get('\Vendor\Package\Domain\Model\MyModel'); instead.


extbase extension - howto update breadcrumbs

I created an extension with extbase which displays different content dependning on the GET parameters. Is there a way to update the breadcrumbs to reflect this? My breadcrumbs look like this in typoscript: temp.breadcrumb = HMENU temp.breadcrumb { special = rootline special.range = 0|-1 1 = TMENU 1 { noBlur...

TYPO3 extbase create url in repository (not controller)

There are good tutorials on how to create URL's in the controllers like this one. Examples are: $this->uriBuilder->reset()->setTargetPageUid($page_uid)->setCreateAbsoluteUri(TRUE)->build(); $this->controllerContext->getUriBuilder()->reset()->setTargetPageUid($page_uid)->setArguments(array('person'=>$person->getUid())->buildFrontendUri(); In works from the controller. But I cannot do the same work in a repository. Error log say that reset() in first example and getUriBuilder in second example is called on...

Typoscript USER / USER_INT objects in powermail input fields

I've a custom extension to render a value from database. I want to prefill the returned value of the extension using powermail prefill typoscript. But when I add the plugin as userfunction, then it will display strange output in frontend. See my typoscript code below; lib.companyname = USER_INT lib.companyname {...

Typo3 FE User assign to FEUserGroup

I'm creating a FEUser programmatically (works fine) in the second Step I want to assign this FE User to an existing FEUsergroup. I Thought it works fine but it didn't. In database the entry is set and the counter goes up. But If i check the usergroup in List-View there...

Typo3 extbase database query

I have an extbase database query like below. $query = $this->createQuery(); $result = $query->statement("Select * FROM table1 WHERE hidden = 0 AND deleted = 0 AND (".$PublicationYears.") AND logo != '' ORDER BY uid ASC LIMIT 0, ".$iLimit." ")->execute(); return $result; $PublicationYears = "ttra = '12' or ttra = '13'...

How to get typo3 settings in the utility files?

plugin.tx_xxx { setting { storagePid = 23 } } I want this typo3 settings in utility file. Please help me....

How to use Hook “processDatamap_postProcFieldArray” in TYPO3 6.x

Use case: When saving an object (in backend, maybe in frontend too later) I want to manipulate values before saving to database. Problem: The file seems to get included (shows an error on save if I choose a wrong file path) but the function does not seem to be executed...

Get String of n:1 Domain Model Object

I made an extension for typo3 with the extension builder. In there I have a relation called "sex" that refers to another model object from type n:1 (of course, everyone can only just have one sex). Now I want to present that in a table. When I use {person.sex} I...

typo3 extbase - bidirectional relation

I have two tables: fe_users (for my frontend users) and tx_somethingarticles_domain_model_article. A user should be able to "like" an article, so for every user I need the information if he already liked an article or not, but also do I need the information how many likes an article already has....

TYPO3 Extbase build own Sitemap

There are a lot of sitemap Generators for TYPO3 in the TER available. But none of them can handle Sites created by Extbase, which are not shown in the TYPO3 page tree. Edit Thanks to biesior, detailed informations: Unconventional I switch in TypoScript the GET Parameter for my Extbase extension[globalVar...

Typo3 6.2 fluid pagination not working as expected

My typo3 6.2(Upgraded from Typo3 4.5) fluid paginate displays all the items instead of 5 items. My Repository Method : public function getRandomLocation($iLimit) { $query = $this->createQuery(); $result = $query->statement("Select * FROM tx_sfel_domain_model_ttblocationsproduktegruppen WHERE hidden = 0 AND deleted = 0 AND logo != '' ORDER BY uid LIMIT 0,...

How can I render preview of FE plugin diplayed in Page module

I have developed TYPO3 (6.2) extensions with some FE plugins. I need to change informations about plugin, which is displayed in the backend on page view. Now only Title and name of plugin is displayed ... I have used flexforms for configure the plugin and I would like to show...

Typo3 - extbase - Missing type information, probably no @param annotation for parameter “$currentPage”

I get the following error in Typo3 Backend: Missing type information, probably no @param annotation for parameter "$currentPage" in Tx_OptivoBm_Controller_NewsletterController->newAction() The function is set up like that: /** * action new * * @param $currentPage * @param $newNewsletter * @dontvalidate $newNewsletter * @return void */ public function newAction($currentPage) { if...

findAll on non object in extbase

I just created an extension in typo3 4.5 with one model (product). I created the "productRepository" then injected it in the ProductController but I still get the Call to a member function findAll() on a non-object here is how the ProductController looks like : /** * @var Tx_PiProductDetail_Domain_Repository_ProductRepository */ protected...

Using FAL in Extbase correctly

Domain model class Image extends AbstractContent { /** * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference */ protected $file; /** * Gets the image file * * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference */ public function getFile() { return $this->file; } /** * Sets the image file * * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file * @return void */ public function setFile($file)...

How to get filename in Typo3 solr extension with FAL and own Extbase extension

Before FAL, I can get the filename of an image from my own Extbase extension in the solr config file "typo3/ext/solr/Configuration/TypoScript/Solr/setup.txt" via index { queue { tx_myextension = 1 tx_myextension { fields { ... myimage_stringS = articleimage ... } } } } Where "articleimage" was a database field with the...

can't create files in typo3 inside fileadmin

I am building an extension with extbase where I need to create a pdf file inside fileadmin folder with php from a controller : fopen("/fileadmin/pdf/anass.pdf", "w") or die('could not create file'); The permission is granted to write files ... so I think I made a mistake writing the path. Could...

How can I use an injected object in the constructor?

I have a service class in my Extbase extension and want to use the ObjectManager to create an instance of an object in the constructor. /** * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface * @inject */ protected $objectManager; public function __construct() { $this->standaloneView = $this->objectManager->get('TYPO3\CMS\Fluid\View\StandaloneView'); $this->standaloneView->setFormat('html'); } Unfortunately this doesn't fails with an error...

Extbase: inject repository into domain model

I am currently working with Typo3 6.2.10 and Extbase. I am trying to inject a repository into my domain model like this: class MyModel extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { /** * @inject * @var \Vendor\Package\Domain\Repository\SomeRepository */ protected $someRepository; } However, $this->someRepository is always null. Injecting repositories into controllers always works though. Thank...

How to get all FAL File Objects which are referenced?

I'm trying to make a extbase extension for TYPO3 to get alle file objects with mimetype image/... which referenced by any content, plugin or fluid in typo3. But i don't know which is the best way to get these data. How should i create a model in my extension and...

PHP-Unit Tests: how to implement a TYPO3 Extbase object interface

I have some problems with the PHP UnitTests for my Controller: this is the function in my controller code that has to be tested public function newAction(\ReRe\Rere\Domain\Model\Fach $newFach = NULL) { // Holt die übergebene Modulnummer if ($this->request->hasArgument('modul')) { // Holt das Modul-Objekt aus dem Repository $modul = $this->modulRepository->findByUid($this->request->getArgument('modul')); }...

Display Extbase FileReference with Fluid

In an extbase extension, I have a FileReference Object. It was created with extension_builder originally. From The Model: /** * apprenticeshipDocument * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference */ protected $apprenticeshipDocument = NULL; etc. In the frontend, <f:debug>{institution.apprenticeshipDocument}</f:debug> gives me this: First Thing: originalResource is missing. Second: When calling {institution.apprenticeshipDocument.uidLocal} directly, the value is...

PHP error “Cannot redeclare class” in extbase-based extension of Typo3 4.7

I have created an extension for Typo3 4.7 (actually, it was created for Typo3 6.2, but I am trying to backport it) using the extbase framework. I have already removed all namespaces from the core and also checked TYPO3 - Call another repository. However, I have the problem that calling...

How to disable cache for a image carousel in TYPO3

My TYPO3 extension has a lib that generates random 5 images from the total stock, for example out of the 100 images. This is done randomly every time the page is loaded. Only default the TYPO3 cache is enabled so every time the same 5 images are showed. As the...

How does my frontend usergroup list get lost between Extbase action controller and Fluid template partial in TYPO3 6.2?

I'm using TYPO3 CMS 6.2.12 and Extension Builder 6.2.0 to model a Report class and build an extension to manage it. One of the domain driven design requirements is that a report author be a logged-in front end user. A second requirement is that the author choose a single group...

In extbase, how to access item by another value than uid

In a custom extbase extension, I need to call a show action, passing it another value than uid (this is a continuation of Use other than primary key as RealURL id_field). As the value "other than uid" is not resolved, it results in the exception http://wiki.typo3.org/Exception/CMS/1297759968 EDIT: here's the current...