[TYPO3-mvc] Define a PID per object, not by configuration

Adrien Crivelli adrien.crivelli at gmail.com
Tue Aug 9 18:29:05 CEST 2011


Hi,

I believe your sample would work for update/select query. But in my case
(insert) I don't event have query object as my whole code is:

$this->newsletterRepository->add($newNewsletter);

Thanks anyway,

Adrien



On 8 August 2011 22:29, Thomas Layh <thomas at layh.com> wrote:

> Hi,
>
> as far as I know you can pass the PID to your repository and set it there:
>
> $query->getQuerySettings()->setStoragePageIds(array $storagePageIds);
>
> Have not tried it, but I guess this should work. Correct me if I am wrong.
>
> Greetings,
> Thomas
>
>
> On Tue, Aug 9, 2011 at 03:37, Adrien Crivelli <adrien.crivelli at gmail.com
> >wrote:
>
> > Hello list,
> >
> > I'v struggled for a few days with PID storage. I am at the point where I
> > need advice before doing some very ugly things.
> >
> > I need to read and create objects on many several PIDs. For a while I
> > manage
> > reading what I needed by extending Tx_Extbase_Persistence_Repository
> with:
> >
> > abstract class My_AbstractRepository
> > {
> >  public function createQuery()
> > {
> >  $query = parent::createQuery();
> > $query->getQuerySettings()->setRespectStoragePage(FALSE);
> >  return $query;
> >  }
> > }
> >
> > Now I need to create object and it is not as simple as that. According to
> > the latest documentation <http://forge.typo3.org/issues/3698#note-15> I
> > found, PID are set by configuration. In several ways, but always
> > configuration. That means PIDs are kind of static data. It doesn't fit my
> > needs as I usually want to store object on the current page (as my
> project
> > is a BE extension using ExtJs, "current page" isn't necessarily so
> > straightforward).
> >
> > Of course I tried things like:
> > $newNewsletter->setPid(12345);
> >  $this->newsletterRepository->add($newNewsletter);
> >
> > But, as many before me, it wasn't long before I figured out that the PID
> is
> > always overwritten by the configuration
> > (via
> Tx_Extbase_Persistence_Backend::determineStoragePageIdForNewRecord()).
> >
> >
> > So the first question is simple: Why can't we manually set a PID without
> > being overwritten ?
> >
> > Cheers,
> > _______________________________________________
> > TYPO3-project-typo3v4mvc mailing list
> > TYPO3-project-typo3v4mvc at lists.typo3.org
> > http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
> >
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>


More information about the TYPO3-project-typo3v4mvc mailing list