1. Go to this page and download the library: Download psb/psb-foundation library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
psb / psb-foundation example snippets
declare(strict_types=1);
/** copyright... */
namespace Vendor\ExtensionName\Data;
use PSB\PsbFoundation\Data\AbstractExtensionInformation;
class ExtensionInformation extends AbstractExtensionInformation
{
}
use PSB\PsbFoundation\Attribute\TCA\Column;
use PSB\PsbFoundation\Attribute\TCA\ColumnType\Input;
use PSB\PsbFoundation\Attribute\TCA\Ctrl;
#[Ctrl(label: 'name', searchFields: ['description', 'name')]
class YourClass
{
#[Column(rue)]
#[Check]
protected bool $adminOnly = true;
...
}
use PSB\PsbFoundation\Attribute\TCA\Column;
use PSB\PsbFoundation\Attribute\TCA\ColumnType\Inline;
use PSB\PsbFoundation\Attribute\TCA\ColumnType\Select;
use PSB\PsbFoundation\Attribute\TCA\ColumnType\Text;
use PSB\PsbFoundation\Attribute\TCA\Ctrl;
#[Ctrl(
hideTable: true,
label: 'richText',
labelAlt: [
'someProperty',
'anotherProperty',
],
labelAltForce: true,
sortBy: 'customSortField',
type: 'myType',
)]
class YourModel
{
/*
* This constant is used as value for TCA-property "items". The keys will be used as label identifiers - converted
* to lowerCamelCase:
* EXT:your_extension/Resources/Private/Language/Backend/Configuration/TCA/(Overrides/)[modelName].xlf:myType.default
* EXT:your_extension/Resources/Private/Language/Backend/Configuration/TCA/(Overrides/)[modelName].xlf:myType.recordWithImage
*/
public const TYPES = [
'DEFAULT' => 'default',
'RECORD_WITH_IMAGE' => 'recordWithImage',
];
#[Select(items: self::TYPES)]
protected string $myType = self::TYPES['DEFAULT'];
#[Text(
cols: 40,
enableRichtext: true,
rows: 10,
)]
protected string $richText = '';
/**
* @var ObjectStorage<AnotherModel>
*/
#[Inline(
linkedModel: AnotherModel::class,
foreignField: 'yourModel',
)]
protected ObjectStorage $inlineRelation;
#[Column(position: 'before:propertyName2')]
#[Select(linkedModel: AnotherModel::class)]
protected ?AnotherModel $simpleSelectField = null;
// This field is only added to the types 'interview' and 'profile'.
#[Column(typeList: 'interview, profile')]
#[File(
allowed: [
'jpeg',
'jpg',
],
maxItems: 1,
)]
protected ?FileReference $image = null;
...
}
public function __construct()
{
parent::__construct();
$this->addPlugin(GeneralUtility::makeInstance(PluginConfiguration::class,
controllers: [MyController::class],
name: 'MyPlugin',
));
$this->addPlugin(GeneralUtility::makeInstance(PluginConfiguration::class,
controllers: [
MyController::class => [
'specificAction',
],
AnotherController::class => [
'specificAction', // This is not necessarily the default action!
'anotherSpecificAction',
],
]],
group: 'customTabInContentElementWizard'
name: 'AnotherPlugin',
));
}
use PSB\PsbFoundation\Attribute\PluginAction;
class YourController extends ActionController
{
#[PluginAction]
public function simpleAction(): ResponseInterface
{
...
}
#[PluginAction(default: true)]
public function mainAction(): ResponseInterface
{
...
}
#[PluginAction(uncached: true)]
public function uncachedAction(): ResponseInterface
{
...
}
}
public function __construct()
{
parent::__construct();
$this->addPlugin(GeneralUtility::makeInstance(PluginConfiguration::class,
controllers: [
MyController::class
],
name: 'MyPlugin',
typeNum: 1589385441,
));
}
declare(strict_types=1);
use PSB\PsbFoundation\Data\ExtensionInformation; // <-- Change this to your namespace!
use PSB\PsbFoundation\Service\Configuration\ModuleService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
return GeneralUtility::makeInstance(ModuleService::class)
->buildModuleConfiguration(GeneralUtility::makeInstance(ExtensionInformation::class));
use PSB\PsbFoundation\Attribute\ModuleAction;
use PSB\PsbFoundation\Controller\Backend\AbstractModuleController;
class YourModuleController extends AbstractModuleController
{
#[ModuleAction(default: true)]
public function mainAction(): ResponseInterface
{
...
return $this->htmlResponse();
}
#[ModuleAction]
public function simpleAction(): ResponseInterface
{
...
return $this->htmlResponse();
}
}
public function __construct()
{
parent::__construct();
$this->addPageType(GeneralUtility::makeInstance(PageTypeConfiguration::class,
allowedTables: ['*'],
iconIdentifier: 'page-type-your-page-type-name',
label: 'Your page type name',
name: 'yourPageTypeName',
doktype: 1691492222,
));
}
// get SiteConfiguration
GlobalVariableService::get(SiteConfigurationProvider::class);
// get all request parameters
GlobalVariableService::get(RequestParameterProvider::class);
// get specific request parameter
GlobalVariableService::get(RequestParameterProvider::class . '.formData.hiddenInput');
// get all TypoScript
$this->typoScriptProviderService->get();
// get specific part
$this->typoScriptProviderService->get('config');
// get all settings from extension
$this->typoScriptProviderService->get(null, ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'extensionName', 'pluginName');
// get specific setting from extension
$this->typoScriptProviderService->get('displayOptions.showPreview', ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'extensionName', 'pluginName');
public function fromRequest(AbstractEntity $domainModel, Request $request): void
html
<!-- Template file -->
<f:translate arguments="{0: 'myVar', 1: 123}" id="myLabel" />
<!-- Language file -->
<source>My two variables are %1$s and %2$s.</source>
html
<!-- Template file -->
<psb:translate arguments="{myVar: 'myVar', anotherVar: 123} id="myLabel" />
<!-- Language file -->
<source>My two variables are {myVar} and {anotherVar}.</source>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.