Model 类型3 Extbase型号n:1双向

Model 类型3 Extbase型号n:1双向,model,typo3,many-to-one,extbase,bidirectional,Model,Typo3,Many To One,Extbase,Bidirectional,我有以下型号: FilePackage - ID - Name FileGroup - ID - Name - filePackage File - ID - Path - fileGroup 如果我想获取一个组的所有文件,我目前会进行如下查询 $groups = $this->fileGroupRepository->findByPacka

我有以下型号:

 FilePackage
      - ID
      - Name

 FileGroup
      - ID
      - Name
      - filePackage              

 File
      - ID 
      - Path   
      - fileGroup
如果我想获取一个组的所有文件,我目前会进行如下查询

$groups = $this->fileGroupRepository->findByPackage($package);
foreach($groups as $group){
     $files = $this->fileRepository->findByFilegroup($group);
     foreach($files as $file){
         // Handle it...
     }
}
可以直接访问这些吗?喜欢 $groups=$this->fileGroupRepository->findByPackage($package); foreach($组作为$组){ $group->getFiles(); }


无需查询之前的所有内容,并根据TCA Extbase中的配置直接在模板中使用它,应注意获取所有相关对象

例如:

文件组

'files' => array(
    'label' => 'LLL:EXT:foo_myext/Resources/Private/Language/locallang_db.xml:tx_foomyext_domain_model_filegroup.files',
    'l10n_mode' => 'exclude',
    'config' => array(
        'type' => 'group',
        'internal_type' => 'db',
        'allowed' => 'tx_foomyext_domain_model_file',
        'foreign_table' => 'tx_foomyext_domain_model_file',
        'MM' => 'tx_foomyext_filegoup_file_mm',
        'maxitems'      => 10,
        'minitems'      => 0,
        'size'      => 10,
    ),
),
文件

'filegroups' => array(
    'exclude' => 0,
    'label' => 'LLL:EXT:tw_foomyext/Resources/Private/Language/locallang_db.xml:tx_foomyext_domain_model_file.filegroups',
    'config'  => array(
        'type' => 'select',
        'foreign_table' => 'tx_foomyext_domain_model_filegroup',
        'foreign_table_where' => 'ORDER BY tx_foomyext_domain_model_filegroup.id',
        'MM' => 'tx_foomyext_filegroup_file_mm',
        'MM_opposite_field' => 'files',
        'size' => 5,
        'minitems' => 0,
        'maxitems' => 10,
    )
),
在您的模型中,这些属性应该表示为ObjectStorage

如果选择一个文件组,Extbase将自动为您获取所有相关文件,您将有权访问这些文件