nemo64/typo3api

安装数: 13,420

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 4

分支: 6

开放问题: 20

类型:typo3-cms-extension

v3.0.4 2024-08-08 09:17 UTC

README

Latest Stable Version Total Downloads Monthly Downloads License

简化TYPO3 TCA处理的API

此扩展抽象了在TYPO3中完成任务所需的某些数组配置。这将导致更快、更简单、更不烦人的工作流程。

如何安装

使用composer require infabo/typo3api安装此扩展。对于不使用composer的人:首先让您的项目使用composer。真的,这个扩展是为了简化您的工作流程,但如果您还在使用非composer模式,您的工作流程问题可能更大。

如何使用

Typo3Api\Builder\TableBuilder替换您的TCA数组。

TableBuilder

在您的扩展中创建TCA文件,例如Configuration/TCA/tx_ext_person.php。然后,您可以使用TableBuilder而不是返回TCA数组。

\Typo3Api\Builder\TableBuilder::create('tx_ext_person')
    ->configure(new \Typo3Api\Tca\LanguageConfiguration())
    ->configure(new \Typo3Api\Tca\EnableColumnsConfiguration())
    ->configure(new \Typo3Api\Tca\SortingConfiguration())

    // configure cache clearing so you don't need to provide cache clear capabilities to your backend users
    ->configure(new \Typo3Api\Tca\CacheTagConfiguration('tx_ext_person_###UID###'))
    ->configure(new \Typo3Api\Tca\CacheTagConfiguration('tx_ext_person'))

    // the actual fields
    ->configure(new \Typo3Api\Tca\Field\InputField('first_name', ['required' => true, 'localize' => false]))
    ->configure(new \Typo3Api\Tca\Field\InputField('last_name', ['required' => true, 'localize' => false]))
    ->configure(new \Typo3Api\Tca\Field\DateField('birthday'))
    ->configure(new \Typo3Api\Tca\Field\EmailField('email'))
    ->configure(new \Typo3Api\Tca\Field\ImageField('image', ['cropVariants' => ['default' => ['1:1']]]))

    // easily allow multiple phone numbers
    ->configure(new \Typo3Api\Tca\Field\InlineRelationField('phone_numbers', [
        'foreign_table' => \Typo3Api\Builder\TableBuilder::create('tx_ext_person_phone')
            ->configure(new \Typo3Api\Tca\SortingConfiguration())
            ->configure(new \Typo3Api\Tca\Field\SelectField('type', ['values' => ['business', 'private', 'other']]))
            ->configure(new \Typo3Api\Tca\Field\PhoneField('value'))
    ]))

    // use or create complex configurations and reuse them across tables
    ->configure(new \Typo3Api\Tca\Util\Address('Address'))

    // create new tabs (aka --div--) on the fly
    ->configureInTab('Notice', new \Typo3Api\Tca\Field\TextareaField('notice'))
;

就是这样。现在您可以开始使用tx_ext_person表了。

内容元素

要创建内容元素,请在Configuration/TCA/Override/tt_content.php中使用TableBuilder。

\Typo3Api\Builder\TableBuilder::create('tt_content', 'carousel')
    ->configure(new \Typo3Api\Tca\ContentElementConfiguration())
    // add more fields as you like
;

或者有更多选项。

\Typo3Api\Builder\TableBuilder::create('tt_content', 'quote')
    ->configure(new \Typo3Api\Tca\ContentElementConfiguration([
        'name' => 'Quote element',
        'description' => 'Tell what other peaple are saying',
        'icon' => 'content-quote',
        'headline' => 'hidden', // adds only the headline field
    ]))
;

运行单元测试

运行vendor/bin/phpunit