TYPO3 Utils
, (*1)
Utility classes to provide simpler APIs to common TYPO3 tasks., (*2)
Installation
You can include this library in any of your TYPO3 extensions via Composer:, (*3)
$ composer require "3ev/typo3-utils"
Usage
TYPO3 Utils provides the following utility classes to help ease building TYPO3
extensions:, (*4)
Tev\Typo3Utils\Domain\Model
This namespace provides a few useful traits for re-usable model functionality,
such as adding getters and setters for crdate
, tstamp
and hidden
., (*5)
Tev\Typo3Utils\Generators
This namespace contains 'generators', which are wrappers around TYPO3's
DataHandler API., (*6)
Generators can be used to create page, content and template and records from the
backend or CLI scripts (a BE_USER
is required)., (*7)
Tev\Typo3Utils\Hook\EntityHook & Tev\Typo3Utils\Hook\EntityRegistrar
The EntityHook
and EntityRegistrar
classes make it easy to listen to backend
TYPO3 lifecycle events on database entities., (*8)
Just extend EntityHook
, and specify the table you want to listen to in the
parent constructor. You'll then be able to implement creating
, created
, updating
,
updated
, saving
, saved
and deleted
methods as you wish, which will be called
when the relevant action happens from the TYPO3 backend., (*9)
You can register your hook class by simply adding:, (*10)
\Tev\Typo3Utils\Hook\EntityRegistrar::register('Path\\To\\Hook\\Class');
to your extension's ext_tables.php
file. This saves you writing a complex
TYPO3 hook definition., (*11)
Tev\Typo3Utils\Log\Writer\FileWriter
The default TYPO3 log file writer doesn't let you write to log files outside of the publicly served directory., (*12)
This can be insecure, so this simple writer class allows you to write log files
anywhere on the filesystem., (*13)
Tev\Typo3Utils\Plugin\WizIcon
This class makes it trivial to register wizicons for plugins in your extension., (*14)
Just extend the base wizicon class and configure the icon details in the parent
constructor:, (*15)
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'
);
}
}
then, just register the icon class as normal in ext_tables.php
:, (*16)
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
This class provides an Extbase-compatible wrapper around the Geocoder PHP
library., (*17)
Tev\Typo3Utils\TCA\Label
This utility class provides a TCA userfunc to allow you to set labels consisting
of multiple fields, with a custom separator., (*18)
For example:, (*19)
'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
This class provides a few utilities for dumping out data. Currently, the only
available method allows you to dump a an Extbase query object so that you can
examine the query being generated and run., (*20)
Tev\Typo3Utils\Utility\ExtConf
This class provides a simple API for accessing extconf variables:, (*21)
$conf = new \Tev\Typo3Utils\Utility\ExtConf('my_ext');
$conf->get('config_key');
Tev\Typo3Utils\Utility\Page
This class provides a few methods for retrieving data on TYPO3 pages., (*22)
See the class for
more information., (*23)
Tev\Typo3Utils\Utility\Tsfe
This class provides a simple API for initialising the TSFE
on the CLI or TYPO3
backend. You just need to set the root page ID an optionally provide a host name:, (*24)
$tsfe = \Tev\Typo3Utils\Utility\Tsfe;
$tsfe->create(1 /*, www.hostname.com */);
License
MIT © 3ev, (*25)