PHP code example of orange-hive / simplyment
1. Go to this page and download the library: Download orange-hive/simplyment 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/ */
orange-hive / simplyment example snippets
\OrangeHive\Simplyment\Loader::extLocalconf(
vendorName: 'MyVendorName',
extensionName: 'my_extension_key'
);
\OrangeHive\Simplyment\Loader::extTables(
vendorName: 'MyVendorName',
extensionName: 'my_extension_key'
);
\OrangeHive\Simplyment\Loader::tcaTtContentOverrides('MyVendorName', 'my_extension_key');
$base = \OrangeHive\Simplyment\Utility\ModelTcaUtility::getTca(\MyVendor\MyExtension\Domain\Model\MyModel::class);
$custom = [];
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($base, $custom);
return $base;
namespace MyVendor\MyExtension\Domain\Model;
use OrangeHive\Simplyment\Attributes\DatabaseField;
use OrangeHive\Simplyment\Attributes\DatabaseTable;
use OrangeHive\Simplyment\Attributes\TcaField;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
#[DatabaseTable(
tableName: 'pages' // extending table 'pages'
)]
class Page extends AbstractEntity
{
protected string $title = ''; // already existent field title
#[DatabaseField(type: 'text')]
#[TcaField]
protected string $txMyField; // custom field
/**
* @return string
*/
public function getTitle(): string
{
return $this->title;
}
/**
* @return string
*/
public function getTxMyField(): string
{
return $this->txMyField;
}
}
use OrangeHive\Simplyment\Utility\ModelTcaUtility;
$customColumnOverrides = [];
ModelTcaUtility::addColumnTcaOverrides(
fqcn: (\MyVendor\MyExtension\Domain\Model\MyModel::class,
tableName: 'givenTableName',
columnOverrides: $customColumnOverrides
);
ModelTcaUtility::addColumnsToAllTcaTypes(
fqcn: (\MyVendor\MyExtension\Domain\Model\MyModel::class,
tableName: 'givenTableName'
);
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\MyVendor\MyExtension\Domain\Model\MySubModel>
*/
#[DatabaseField(sql: 'int')]
#[TcaField(
label: 'Sub models',
type: TcaFieldTypeEnum::INLINE,
targetClass: TestSubModel::class
)]
protected ObjectStorage $subModels;
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
*/
#[DatabaseField(sql: 'int')]
#[TcaField(
label: 'My images',
type: TcaFieldTypeEnum::FILE_IMAGE
)]
protected ObjectStorage $images;
\OrangeHive\Simplyment\Loader::tcaTtContentOverrides('MyVendorName', 'my_extension_key');
$mapping = \OrangeHive\Simplyment\Loader::classes('##VENDOR_NAME##', '##EXTENSION_KEY##');
$custom = [];
return array_merge($mapping, $custom);
namespace MyVendor\MyExtension\Domain\Model\Content;
use OrangeHive\Simplyment\Attributes\ContentElement;
use OrangeHive\Simplyment\Attributes\DatabaseField;
use OrangeHive\Simplyment\Attributes\TcaField;
use OrangeHive\Simplyment\Enumeration\TcaFieldTypeEnum;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
#[ContentElement(
name: 'Teaser'
)]
class Teaser extends AbstractEntity
{
protected string $header = ''; // use already existent header field
#[TcaField(
type: TcaFieldTypeEnum::TEXT,
config: [
'enableRichtext' => true,
]
)]
protected string $bodytext = ''; // use already existent bodytext field and define it as type='text' with richtext enabled
#[TcaField(
type: TcaFieldTypeEnum::TEXT,
config: [
'enableRichtext' => true,
]
)]
#[DatabaseField(type: 'mediumtext')]
protected string $txAdditionalText = ''; // create custom field tx_additional_text and define it as type='text' with richtext enabled
/**
* @return string
*/
public function getHeader(): string
{
return $this->header;
}
/**
* @return string
*/
public function getBodytext(): string
{
return $this->bodytext;
}
/**
* @return string
*/
public function getTxAdditionalText(): string
{
return $this->txAdditionalText;
}
}
#[TcaField(
type: TcaFieldTypeEnum::FLEX
)]
protected string $piFlexform = '';
public function getPiFlexform(): array
{
return \OrangeHive\Simplyment\Utility\FlexFormUtility::xml2array((string)$this->piFlexform);
}
\OrangeHive\Simplyment\Loader::tcaTtContentOverrides('MyVendorName', 'my_extension_key');
namespace OrangeHive\Simplyment\Hook;
use OrangeHive\Simplyment\Attributes\Hook;
use TYPO3\CMS\Backend\View\BackendLayout\DataProviderInterface;
#[Hook(identifier: 'TYPO3_CONF_VARS/SC_OPTIONS/BackendLayoutDataProvider', key: 'simplyment')]
class BackendLayoutDataProvider implements DataProviderInterface
{
// not relevant
}
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['BackendLayoutDataProvider']['simplyment'] = 'OrangeHive\Simplyment\Hook\BackendLayoutDataProvider';