flattenFileReferences does not work in IRRE collection of sys_file_references

Issue #31 resolved
Martin Keller created an issue

settings.globalDistillers.flattenFileReferences = 1 works great on direct sys_file_references.

Great concept for reducing the size of the resulting JSON!
But as soon as the content element has more than one image attached in a IRRE element, the functionality does not look into the array of file references and you still get all the many unwanted details of the images.
My example calendarize event model

Comments (4)

  1. David Bascom

    This might now be fixed with the commit for Issue #29.

    I have tested flattenFileReference with the following settings and it seems to work for many images attached to an IREE element. Here is my example:

    Code for API endpoint:

        // This is my API endpoint:
    
        /**
         * # Test
         * 
         * @Api\Access("public")
         * 
         * @param int $uid
         * @return array
         */
        public function getNewsAction()
        {
            $repo = \nn\t3::injectClass( \HDNET\Calendarize\Domain\Repository\IndexRepository::class );
            \nn\t3::Db()->ignoreEnableFields( $repo );
            $data = $repo->findAll();
    
            return $data;
        }
    

    TypoScript-Setup defining the distiller:

    plugin.tx_nnrestapi {
        settings {      
            globalDistillers {
                GeorgRinger\News\Domain\Model\NewsDefault {
                    flattenFileReferences = 1
                }
            }
        }
    }
    

    Results in the FAL-Media-Object of the News-Model:

    "falMedia": [
      "fileadmin/apidemo/variante-a-01.jpg",
      "fileadmin/apidemo/variante-a-03.jpg"
    ],
    

  2. Martin Keller reporter

    I had flattenFileReferences as a key under plugin.tx_nnrestapi.settings.globalDistillers thinking it then works for all models.

    The new TS of v1.40 shows it (commented out) as a key of the model which gives it a new sense. Updating my TS to
    plugin.tx_nnrestapi.settings.globalDistillers.<model>.flattenFileReferences =1
    works as expected.
    Documentation looks good except here: where we should mention the flattenFileReference to be setten to globalDistillers.<model>

  3. David Bascom

    Ah – ok, thanks for the hint. You’re totally right. This should be made more clear in the docs.

  4. Log in to comment