有没有人有一个工作示例如何在TYPO3 8.7上扩展femanager 3.3.0?
我创建了一个新的扩展,它可以完成所有工作(fe_user,TCA,Partials等的新数据库字段)。我在femanager插件中有新字段,可以为前端选择它们。
注册IS WORKING:新字段保存在数据库中。 日志中有警告:
Core: Error handler (FE):
PHP Warning: Declaration of TOCO3\TocoLedes\Controller\NewController::createAction(TOCO3\TocoLedes\Domain\Model\User $user)
should be compatible with In2code\Femanager\Controller\NewController::createAction(In2code\Femanager\Domain\Model\User $user) in \www\typo3conf\ext\toco_ledes\Classes\Controller\NewController.php line 0
然而,这似乎不是问题。
但是:编辑
“配置文件编辑”页面显示我的所有新字段(在插件中选择)但不加载这些字段的值(它们为空)。如果我尝试保存配置文件,我会收到以下错误:
Core: Exception handler (WEB):
Uncaught TYPO3 Exception: #1297759968:
Exception while property mapping at property path "":
Property "newfield" was not found in target object of type
"In2code\Femanager\Domain\Model\User". |
TYPO3\CMS\Extbase\Property\Exception thrown in file
\www\typo3_src-8.7.8\typo3\sysext\extbase\Classes\Property\PropertyMapper.php in line 127.
创建(注册)工作非常奇怪,但编辑没有!
我认为有趣的部分是
config.tx_extbase{
persistence{
classes{
In2code\Femanager\Domain\Model\User {
subclasses {
0 = TOCO3\TocoLedes\Domain\Model\User
}
}
TOCO3\TocoLedes\Domain\Model\User {
mapping {
tableName = fe_users
recordType = 0
}
}
}
}
objects {
In2code\Femanager\Controller\NewController.className = TOCO3\TocoLedes\Controller\NewController
In2code\Femanager\Controller\EditController.className = TOCO3\TocoLedes\Controller\EditController
}
}
EditController.php
namespace TOCO3\TocoLedes\Controller;
class EditController extends \In2code\Femanager\Controller\EditController {
/**
* action update
*
* @param TOCO3\TocoLedes\Domain\Model\User $user
* @validate $user In2code\Femanager\Domain\Validator\ServersideValidator
* @validate $user In2code\Femanager\Domain\Validator\PasswordValidator
* @return void
*/
public function updateAction(\TOCO3\TocoLedes\Domain\Model\User $user) {
parent::updateAction($user);
}
}
我期待任何想法或 - 这将是伟大的 - 一个工作的样本扩展(不幸的是femanagerextended ist过时:-()
答案 0 :(得分:5)
为了帮助其他人遇到同样的问题,也许我有一个PHP 7警告的解决方案(在Steffen Kamper的帮助下,以及这里的一些提示:https://github.com/einpraegsam/femanagerextended/issues/1):
创建XCLASS
myext / XClass / Extbase / Mvc / Controller / Argument.php
<?php
namespace TOCO3\MyExt\Xclass\Extbase\Mvc\Controller;
class Argument extends \TYPO3\CMS\Extbase\Mvc\Controller\Argument
{
/**
* Set data type for femanager workaround.
* Workaround to avoid php7 warnings of wrong type hint.
*
* @param $dataType
* @return $this
*/
public function setDataType($dataType) {
$this->dataType = $dataType;
return $this;
}
}
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument'] = array('className' => 'TOCO3\\MyExt\\Xclass\\Extbase\\Mvc\\Controller\\Argument');
<?php
namespace TOCO3\MyExt\Controller;
use TOCO3\MYExt\Domain\Model\User;
class NewController extends \In2code\Femanager\Controller\NewController {
/**
* @return void
*/
public function initializeCreateAction()
{
if ($this->arguments->hasArgument('user')) {
// Workaround to avoid php7 warnings of wrong type hint.
/** @var \TOCO3\MyExt\Xclass\Extbase\Mvc\Controller\Argument $user */
$user = $this->arguments['user'];
$user->setDataType(\TOCO3\MyExt\Domain\Model\User::class);
}
}
/**
* action create
*
* @param User $user
* @validate $user In2code\Femanager\Domain\Validator\ServersideValidator
* @validate $user In2code\Femanager\Domain\Validator\PasswordValidator
* @validate $user In2code\Femanager\Domain\Validator\CaptchaValidator
* @return void
*/
public function createAction(\In2code\Femanager\Domain\Model\User $user) {
parent::createAction($user);
}
}
<?php
namespace TOCO3\MyExt\Controller;
use \TOCO3\MyExt\Domain\Model\User;
class EditController extends \In2code\Femanager\Controller\EditController {
/**
* @return void
*/
public function initializeUpdateAction()
{
if ($this->arguments->hasArgument('user')) {
// Workaround to avoid php7 warnings of wrong type hint.
/** @var \TOCO3\MyExt\Xclass\Extbase\Mvc\Controller\Argument $user */
$user = $this->arguments['user'];
$user->setDataType(\TOCO3\MyExt\Domain\Model\User::class);
}
}
/**
* action update
*
* @param User $user
* @validate $user In2code\Femanager\Domain\Validator\ServersideValidator
* @validate $user In2code\Femanager\Domain\Validator\PasswordValidator
* @validate $user In2code\Femanager\Domain\Validator\CaptchaValidator
* @return void
*/
public function updateAction(\In2code\Femanager\Domain\Model\User $user) {
parent::updateAction($user);
}
}
答案 1 :(得分:2)
只需在github上使用该示例 https://github.com/einpraegsam/femanagerextended
与femananger 3.3.0完美配合
答案 2 :(得分:1)
问题是通过Extension include未正确包含以下TypoScript。如果我在个人资料编辑页面直接添加它作为扩展模板,它可以工作!?
config.tx_extbase{
persistence{
classes{
In2code\Femanager\Domain\Model\User {
subclasses {
0 = TOCO3\TocoLedes\Domain\Model\User
}
}
TOCO3\TocoLedes\Domain\Model\User {
mapping {
tableName = fe_users
recordType = 0
}
}
}
}
objects {
In2code\Femanager\Controller\NewController.className = TOCO3\TocoLedes\Controller\NewController
In2code\Femanager\Controller\EditController.className = TOCO3\TocoLedes\Controller\EditController
}
}
我需要调查一段时间才能找到原因; - )
答案 3 :(得分:0)
更多信息,请参见 How to extend femanager controller under php 7
也请查看我的评论。.过时的扩展名femanagerextended
没有问题
https://github.com/einpraegsam/femanagerextended
祝你好运。