扩展TYPO3功能 [英] Extend TYPO3 femanager
问题描述
有人能在TYPO3 8.7上扩展femanager 3.3.0的例子吗?
Does anyone have a working example how to extend femanager 3.3.0 on TYPO3 8.7?
我创建了一个新的扩展程序,它可以完成所有工作(fe_user,TCA,Partials等的新数据库字段).我在femanager插件中有新字段,可以为前端选择它们.
I created a new Extension which does all the stuff (new database fields for fe_user, TCA, Partials,....). I have the new fields in the femanager plugin and can select them for the frontend.
正在注册:新字段保存在数据库中. 日志中有一个警告:
Registering IS WORKING: the new fields are saved in the database. There is a Warning in the Log:
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
尽管如此,这似乎不是问题.
Nevertheless this seems not be a problem.
但是:编辑
个人资料编辑页面"显示了我所有的新字段(在插件中选择),但未加载这些字段的值(它们为空).如果我尝试保存配置文件,则会出现以下错误:
The Profile Edit Page shows all my new fields (as selected in the Plugin) but does NOT load the values of these fields (they are empty). If I try to save the profile I get the following error:
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.
创建(注册)正在工作,但编辑没有工作,这很奇怪!
It is very strange that the creating (register) is working, but the editing does not!
我认为有趣的部分是
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
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已过时:-()
I'm looking forward any ideas or - this would be great - a working sample extension (Unfortunately femanagerextended ist outdated :-( )
推荐答案
为帮助其他有相同问题的人,也许我也有针对PHP 7警告的解决方案(借助Steffen Kamper以及此处的一些提示: https://github.com/einpraegsam/femanagerextended/issues/1 ):
To help others having the same problem perhaps I have a solution for the PHP 7 warnings too (with help of Steffen Kamper and some hints from here: https://github.com/einpraegsam/femanagerextended/issues/1):
-
创建XCLASS
Create an XCLASS
myext/XClass/Extbase/Mvc/Controller/Argument.php
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;
}
}
- 注册此XClass myext/ext_localconf.php
- Register this XClass myext/ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument'] = array('className' => 'TOCO3\\MyExt\\Xclass\\Extbase\\Mvc\\Controller\\Argument');
- 在NewController.php中
<?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);
}
}
- 在EditController.php中
<?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);
}
}
这篇关于扩展TYPO3功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!