[TYPO3-german] Problem extbase bidirektionale mm Beziehung

Eike Starkmann starkmann at undkonsorten.com
Wed Mar 13 17:54:40 CET 2013


Ich habe dazu mal ein Ticket gemacht, da ich glaube das das Problem in 
extbase liegt:
http://forge.typo3.org/issues/46243

Bis denne, Eike

On 08.03.2013 14:00, Eike Starkmann wrote:
>
> Hallo,
> ich habe ein Problem mit einer Extbase Extension die ich gerade schreibe.
> Folgende Situation:
>
> Ich habe ein Objekt Media und ein Objekt Playlist
> Zwischen diesen besteht eine bidirektionale M:M Beziehung.
>
> Ich möchte jetzt zu einem bestimmten Medium (M) alle anderen Medien
> ausgeben, die in der gleichen Playliste (P) sind.
>
> Naive Vorgehensweise (pseudocode):
>
> //alle Playlisten zu dem das Medium gehört
> for M.paylist as playlistItem {
>
>      //alle Medien in der aktuellen playliste
>      for playlistItem.media as mediaItem{
>          ausgabe mediaItem
>      }
> }
> Und genau die innere Schleife funktioniert nicht und liefert einen
> SQL-Fehler.
>
> Hier ist der relevante Code:
>
> class Tx_Medialibrary_Domain_Model_Playlist extends
> Tx_Extbase_DomainObject_AbstractEntity {
>
>      /**
>       * Media of the playlist
>       *
>       * @var
> Tx_Extbase_Persistence_ObjectStorage<Tx_Medialibrary_Domain_Model_Media>
>       * @lazy
>       */
>      protected $media;
>
>      /**
>       * Adds a Media
>       *
>       * @param Tx_Medialibrary_Domain_Model_Media $media
>       * @return void
>       */
>      public function addMedia(Tx_Medialibrary_Domain_Model_Media $media) {
>          $this->media->attach($media);
>      }
>
>      /**
>       * Removes a Media
>       *
>       * @param Tx_Medialibrary_Domain_Model_Media $mediaToRemove The
> Category to be removed
>       * @return void
>       */
>      public function removeMedia(Tx_Medialibrary_Domain_Model_Media
> $mediaToRemove) {
>          $this->media->detach($mediaToRemove);
>      }
>
>      /**
>       * Returns the Media
>       *
>       * @return
> Tx_Extbase_Persistence_ObjectStorage<Tx_Medialibrary_Domain_Model_Media>
> $media
>       */
>      public function getMedia() {
>          return $this->media;
>      }
>
>      /**
>       * Sets the media
>       *
>       * @param
> Tx_Extbase_Persistence_ObjectStorage<Tx_Medialibrary_Domain_Model_Media>
> $media
>       * @return void
>       */
>      public function setMedia(Tx_Extbase_Persistence_ObjectStorage
> $media) {
>          $this->media = $media;
>      }
>
> }
>
> TCA:
>
> $TCA['tx_medialibrary_domain_model_playlist'] = array(
> ...
> "media" => Array (
>                      "exclude" => 1,
>                      "label" =>
> "LLL:EXT:medialibrary/Resources/Private/Language/locallang_db.xml:tx_medialibrary_domain_model_playlist.media",
>
>                      "l10n_mode" => "exclude",
>                      "config" => Array (
>                              "type" => "group",
>                              "internal_type" => "db",
>                              "allowed" =>
> "tx_medialibrary_domain_model_media",
>                              "size" => 10,
>                              "minitems" => 0,
>                              "maxitems" => 100,
>                              "MM" => "tx_medialibrary_media_playlist_mm",
>                              "MM_opposite_field" => "media",
>                      )
>              ),
> ...
>
> $TCA['tx_medialibrary_domain_model_media'] = array(
> ...
>      "playlist" => Array (
>                      "exclude" => 1,
>                      "label" => "playlist",
>                      "l10n_mode" => "exclude",
>                      "config" => Array (
>                              "type" => "select",
>                              "allowed" =>
> "tx_medialibrary_domain_model_playlist",
>                              'foreign_table' =>
> 'tx_medialibrary_domain_model_playlist',
>                              "size" => 10,
>                              "minitems" => 0,
>                              "maxitems" => 100,
>                              "MM" => "tx_medialibrary_media_playlist_mm",
>                      )
>              ),
> ...
>
> Fluid showAction von Media:
>
> <f:for each="{media.playlist}" as="playlistItem">
>          {playlistItem}
>          <f:for each="{playlistItem.media}" as="mediaItem">
>              {mediaItem}
>          </f:for>
>      </f:for>
>
> SQL Fehler:
>
> SELECT .* FROM tx_medialibrary_media_playlist_mm LEFT JOIN ON
> tx_medialibrary_media_playlist_mm.uid_local = .uid WHERE
> tx_medialibrary_media_playlist_mm.uid_foreign = '1' AND
> (tx_medialibrary_domain_model_media.type='Tx_Medialibrary_Domain_Model_Media'
> OR
> tx_medialibrary_domain_model_media.type='Tx_Medialibrary_Domain_Model_Media_Video'
> OR
> tx_medialibrary_domain_model_media.type='Tx_Medialibrary_Domain_Model_Media_Audio')
> ORDER BY tx_medialibrary_media_playlist_mm.sorting_foreign ASC
>
>
> Es scheint also so, das bei tx_medialibrary_media_playlist_mm.uid_local
> = .uid Tx_Medialibrary_Domain_Model_Media nicht aufgelöst wird.
>
> Es müsste doch tx_medialibrary_media_playlist_mm.uid_local =
> Tx_Medialibrary_Domain_Model_Media.uid heissen, oder?
>
>
> Ist das jetzt ein Bug ober mache ich hier grundlegend was Falsch?
>
> Bis denne, Eike
>


-- 
EIKE STARKMANN
  starkmann at undkonsorten.com
  +49.30.20236354 [fon]

UNDKONSORTEN GBR
  Waldemarstr. 38
  10999 Berlin

  www.undkonsorten.com
  +49.30.20236354 [fon]
  +49.30.20236354-9 [fax]

  thomas alboth, felix althaus + jochen biedermann  [gesellschafter]


More information about the TYPO3-german mailing list