完整答案/教程...
femanager
您可以使用以下教程扩展 TYPO3 。旧的扩展femanagerextended
是不必要的。这适用于TYPO3
and PHP 5.x
。这是解决方法PHP 7.x
:
添加一个新的 XCLASS 文件 fe typo3conf/ext/yourext/Classes/Xclass/Extbase/Mvc/Controller/Argument.php
:
namespace Yournamespace\Yourext\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;
}
}
更改文件typo3conf/ext/yourext/Classes/Controller/EditController.php
:
namespace Yournamespace\Yourext\Controller;
use \Yournamespace\Yourext\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 \Yournamespace\Yourext\Xclass\Extbase\Mvc\Controller\Argument $user */
$user = $this->arguments['user'];
$user->setDataType(\Yournamespace\yourext\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);
}
}
更改文件typo3conf/ext/yourext/Classes/Controller/NewController.php
:
namespace Yournamespace\Yourext\Controller;
use Yournamespace\Yourext\Domain\Model\User;
class NewController extends \In2code\Femanager\Controller\NewController {
/**
* Initialize create action for setting the right custom data type for the user.
*/
public function initializeCreateAction() {
if ($this->arguments->hasArgument('user')) {
// Workaround to avoid php7 warnings of wrong type hint.
/** @var \Yournamespace\Yourext\Xclass\Extbase\Mvc\Controller\Argument $user */
$user = $this->arguments['user'];
$user->setDataType(\Yournamespace\Yourext\Domain\Model\User::class);
}
}
/**
* action create
*
* @param User $user
* @validate $user In2code\Femanager\Domain\Validator\ServersideValidator
* @validate $user In2code\Femanager\Domain\Validator\PasswordValidator
* @return void
*/
public function createAction(User $user)
{
parent::createAction($user);
}
}
将您的 XCLASS 注册到ext_localconf.php
:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument'] = array('className' => 'Yournamespace\\Yourext\\Xclass\\Extbase\\Mvc\\Controller\\Argument');
通过安装工具清除缓存和清除自动加载器!
这个问题也有帮助。