3ev/typo3-utils

此包已被废弃且不再维护。未建议替代包。

TYPO3 工具带

v1.2.1 2016-01-29 10:50 UTC

This package is not auto-updated.

Last update: 2023-11-23 16:11:09 UTC


README

#TYPO3 Utils

Latest Stable Version License

提供更简单的 API 以简化常见 TYPO3 任务的工具类。

##安装

您可以通过 Composer 将此库包含在您的任何 TYPO3 扩展中

$ composer require "3ev/typo3-utils"

##使用

TYPO3 Utils 提供以下工具类以帮助简化构建 TYPO3 扩展

####Tev\Typo3Utils\Domain\Model

此命名空间提供了一些有用的特性,用于可重用模型功能,例如为 crdatetstamphidden 添加获取器和设置器。

####Tev\Typo3Utils\Generators

此命名空间包含 'generators',这是对 TYPO3 的 DataHandler API 的包装。

生成器可用于从后端或 CLI 脚本(需要 BE_USER)创建页面、内容和模板记录。

####Tev\Typo3Utils\Hook\EntityHook & Tev\Typo3Utils\Hook\EntityRegistrar

EntityHookEntityRegistrar 类使您能够轻松监听数据库实体的后端 TYPO3 生命周期事件。

只需扩展 EntityHook,并在父构造函数中指定要监听的表。然后,您可以按需实现 creatingcreatedupdatingupdated-savingsaveddeleted 方法,这些方法将在 TYPO3 后端的相关动作发生时被调用。

您可以通过简单地将以下内容添加到扩展的 ext_tables.php 文件中来注册您的钩子类。

\Tev\Typo3Utils\Hook\EntityRegistrar::register('Path\\To\\Hook\\Class');

这可以节省您编写复杂的 TYPO3 钩子定义。

####Tev\Typo3Utils\Log\Writer\FileWriter

默认的 TYPO3 日志文件写入器不允许将日志文件写入公开提供的目录之外的目录。

这可能会不安全,因此这个简单的写入器类允许您将日志文件写入文件系统的任何位置。

####Tev\Typo3Utils\Plugin\WizIcon

此类使注册扩展中插件的 wizicons 变得非常简单。

只需扩展基本 wizicon 类,并在父构造函数中配置图标详细信息

namespace My\Extension;

class MyIcon extends \Tev\Typo3Utils\Plugin\WizIcon
{
    public function __construct()
    {
        parent::__construct(
            // Your extension's name, with underscores

            'my_ext',

            // The plugin name(s) you'd like the wizicon to be used for

            ['myplugin', 'myotherplugin],

            // Optional. The icon file name

            'ext_icon.png'

            // Optional. The language file you'd like to use

            'locallang.xlf'
        );
    }
}

然后,只需在 ext_tables.php 中按正常方式注册图标类即可

if (TYPO3_MODE === 'BE') {
    $TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses']['My\\Extension\\WizIcon'] =
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Classes/WizIcon.php';
}

####Tev\Typo3Utils\Services\GeocodingService

此类提供了一个与 Extbase 兼容的包装器,用于 Geocoder PHP 库。

####Tev\Typo3Utils\TCA\Label

此实用工具类提供了一种 TCA userfunc,允许您设置由多个字段组成的标签,并使用自定义分隔符。

例如

'crtl' => [
    'label_userFunc' => 'Tev\\Typo3Utils\\TCA\\Label->run',
    'label_userFunc_options' => [
        // Required, single field name of array of field names

        'fields' => [
            'first_name',
            'last_name'
        ],

        // Optional, defaults to ' '

        'glue' => ', '
     ]
]

####Tev\Typo3Utils\Utility\Dump

此类提供了一些用于转储数据的实用工具。目前,唯一可用的方法允许您转储 Extbase 查询对象,以便您可以检查生成的查询并运行。

####Tev\Typo3Utils\Utility\ExtConf

此类提供了一种简单的 API,用于访问 extconf 变量

$conf = new \Tev\Typo3Utils\Utility\ExtConf('my_ext');
$conf->get('config_key');

####Tev\Typo3Utils\Utility\Page

此类提供了一些用于检索 TYPO3 页面数据的方法。

有关更多信息,请参阅 该类

####Tev\Typo3Utils\Utility\Tsfe

此类提供了一种简单的 API,用于初始化 CLI 或 TYPO3 后端的 TSFE。您只需设置根页面 ID,并可选地提供主机名

$tsfe = \Tev\Typo3Utils\Utility\Tsfe;
$tsfe->create(1 /*, www.hostname.com */);

##许可证

MIT © 3ev