有没有办法在 TYPO3 的扩展安装期间创建对象/ table 条目?

Is there a way to create objects/ table entries during the extension installation in TYPO3?

我想在安装扩展的过程中创建对象。例如我有以下两个简单的域模型:

class Product extends AbstractEntity
{
   protected $name = '';
   protected $sku = '';
   ...
}

class Location extends AbstractEntity
{
   protected $name = '';
   protected $city = '';
   ...
}

和第三个域模型,如:

class Mapper extends AbstractEntity
{
   protected $domainModelName = '';
   protected $domainModelProperty = '';
}

现在我也想添加这样的条目:

domain_model_name | domain_model_property
Product           | name
Product           | sku
Location          | city
....

在安装扩展的过程中或者安装之后,tx_foxexample_domain_model_mapper table 会自动填充,这样可以吗?

我知道我可以使用 initializeAction,但是只有当我添加插件并访问页面等时才会生成条目,但我希望在使用插件之前条目/对象已经存在,或者添加一些对象。

您可以将静态数据存储在文件 ext_tables_static+adt.sql 中,该文件必须位于扩展程序的根文件夹中。

根据TYPO3 API,你必须使用下面的命令来导出你的静态数据

mysqldump --password=[password] [database name] [tablename] --add-drop-table > ./ext_tables_static.sql

还要确保静态 tables 的 table 结构存在于 ext_tables.sql 文件中。

扩展 static_info_tables 使用了这种技术。您可以查看扩展程序 here 了解更多详情。