DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

Domain

Model and Repositories

The extension comes with a set of models and repositories for the most basic doktypes. We recommend to check them and to extend them if needed. Check especially

form4_pages/src/Classes/Domain/Model/AbstractPage.php
form4_pages/src/Classes/Domain/Model/AbstractLargePage.php

and

form4_pages/src/Classes/Domain/Repository/AbstractPageRepository.php

The other models and repositories of the doktypes are extended from these base classes. If you have extended the pages records you have to use these to expand your classes.

Doktype Manager

The extension contains a class named DoktypeManager which acts as an repository for all doktypes and possible doktype entities.

It reads the Extbase persistance configuration to map doktypes on domain model classes.

Following an excerpt from the ext_typoscript_setup.txt of the extension.

config.tx_extbase.persistence.classes {

    FORM4\Form4Pages\Domain\Model\AbstractPage {
        mapping.tableName = pages
    }

    FORM4\Form4Pages\Domain\Model\AbstractLargePage < .FORM4\Form4Pages\Domain\Model\AbstractPage
    FORM4\Form4Pages\Domain\Model\Page < .FORM4\Form4Pages\Domain\Model\AbstractPage
    FORM4\Form4Pages\Domain\Model\LargePage < .FORM4\Form4Pages\Domain\Model\AbstractLargePage

    FORM4\Form4Pages\Domain\Model\Standard < .FORM4\Form4Pages\Domain\Model\AbstractLargePage
    FORM4\Form4Pages\Domain\Model\Standard {
        mapping.recordType = 1
    }

    FORM4\Form4Pages\Domain\Model\Shortcut < .FORM4\Form4Pages\Domain\Model\AbstractLargePage
    FORM4\Form4Pages\Domain\Model\Shortcut {
        mapping.recordType = 4
    }

    FORM4\Form4Pages\Domain\Model\External < .FORM4\Form4Pages\Domain\Model\AbstractLargePage
    FORM4\Form4Pages\Domain\Model\External {
        mapping.recordType = 3
    }

}

This configuration causes the doktype manager to create the following mapping.

When the DoktypeManager is as a repository it will return instances of different classes for the doktype 1, 4 and 3. For other doktypes 'LargePage' will be used.

[
    'default' => [
        0 => 'FORM4\Form4Pages\Domain\Model\LargePage'
    ],
    '1' => [
        0 => 'FORM4\Form4Pages\Domain\Model\Standard'
    ],
    '4' => [
        0 => 'FORM4\Form4Pages\Domain\Model\Shortcut'
    ],
    '3' => [
        0 => 'FORM4\Form4Pages\Domain\Model\External'
    ]
]

If you want to use this feature in one of your own repositories, inject the DoktypeManager and overwrite the method "createQuery".

class YourPageRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {

     /**
     * doktypeManager
     *
     * @var \FORM4\Form4Pages\Helper\DoktypeManager
     * @inject
     */
    protected $doktypeManager;

    /**
     * Returns a query for objects of this repository.
     *
     * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
     * @api
     */
    public function createQuery() {
        return $this->doktypeManager->createQuery();
    }

}