我正在尝试为我的TYPO 3添加EXT:form的完成器。我没有找到最新的示例。大多数都是关于TYPO 3 v8的。
我用这个“解释”https://docs.typo3.org/c/typo3/cms-form/main/en-us/I/Concepts/Finishers/Index.html#write-a-custom-finisher
这是我的状态:
/Configuration/Finishers/Smtp.yaml
TYPO3:
CMS:
Form:
prototypes:
standard:
finishersDefinition:
SmtpFinisher:
implementationClassName: 'Vendor\personal\Domain\Finishers\SmtpFinisher'
options:
yourCustomOption: 'Ralf'
/Classes/Domain/Finishers/SmtpFinisher.php
<?php declare(strict_types=1);
namespace VENDOR\personal\Domain\Finishers;
use PHPMailer\PHPMailer\PHPMailer;
use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;
final class SmtpFinisher extends AbstractFinisher
{
protected $shortFinisherIdentifier = 'smtp';
public function executeInternal() : void{
$senderOptoins = $this->parseOptions("sender");
$mailer = new PHPMailer();
$mailer->isSMTP();
$mailer->SMTPAuth =true;
$mailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mailer->Port = $senderOptoins["smtpPort"];
$mailer->Host = $senderOptoins["smtpServer"];
$mailer->Username = $senderOptoins["username"];
$mailer->Password = $senderOptoins["password"];
$mailer->setFrom($senderOptoins["senderAddress"]) ;
foreach($this->parseOptions("recipents") as $recipent){
$mailer->addAddress($recipent);
}
$mailer->isHTML();
$mailer->Subject = "Hello, World!";
$mailer->Body = "Hi Test Email";
$mailer->AltBody = "Hi Test Email";
$mailer->Send();
}
}
?>
/ext_localconf.php
if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('form')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(trim('
module.tx_form {
settings {
yamlConfigurations {
311 = EXT:personal/Configuration/Finishers/Smtp.yaml
}
}
}
plugin.tx_form {
settings {
yamlConfigurations {
311 = EXT:personal/Configuration/Finishers/Smtp.yaml
}
}
}
'));
}
但我还没看到我的终结者:
此外,我不知道如何包含php库。我如何将它们“运送”到我的扩展名/TYPO 3?
1条答案
按热度按时间mv1qrgav1#
您必须将新的完成程序包含到选项列表中。请参见此处:
https://docs.typo3.org/c/typo3/cms-form/11.5/en-us/I/Concepts/Finishers/Index.html#add-finisher-to-backend-ui
其次:
为了包含外部自定义PHP库,您可以在扩展中使用vendor文件夹。PHP库应该是具有命名空间的类。
如果您通过composer安装扩展,则还必须在扩展的composer.json中包含PSR4。然后在安装后可以使用类名。
在finisher中,您设置了一个包含类的构造函数(为此,扩展中必须存在service.yaml)。
示例:
service.yaml
composer.json
YourMailFinisher.php
未经测试,只是一个快速的代码片段。