gpt4 book ai didi

typo3 - 扩展 TYPO3 管理员

转载 作者:行者123 更新时间:2023-12-01 09:14:37 29 4
gpt4 key购买 nike

有没有人有一个工作示例如何在 TYPO3 8.7 上扩展 femanager 3.3.0?

我创建了一个新的扩展,它可以做所有的事情(fe_user、TCA、Partials 的新数据库字段......)。我在femanager 插件中有新字段,可以为前端选择它们。

正在注册:新字段已保存在数据库中。日志中有警告:

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 is outdated :-()

最佳答案

为了帮助遇到同样问题的其他人,也许我也有 PHP 7 警告的解决方案(在 Steffen Kamper 的帮助下,以及来自这里的一些提示:https://github.com/einpraegsam/femanagerextended/issues/1):

  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;
}
}
  1. 注册这个 XClassmyext/ext_localconf.php
    $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument'] = array('className' => 'TOCO3\\MyExt\\Xclass\\Extbase\\Mvc\\Controller\\Argument');
  1. 在 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);
}
}
  1. 在 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 - 扩展 TYPO3 管理员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47836944/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com