Closed DanielNemanic closed 8 years ago
I tested it with femanager 2.5.0, TYPO3 7.6, PHP 7 and femanagerextended 1.1.0 - I can't see a problem with the updateAction() declaration. Maybe you're using a very old version of femanagerextended. Note: the version in TER is supported by another author and the version here on github is a different one.
Maybe you can find the error. I also used this git version, and received the error above.
Caches cleared. Folders deleted under typo3temp. Composer dump-autoload done
Clean installation of Typo3 7.6.9. PHP 7.0.6 No other Extensions installed just a std ts for fluid. Downloaded femanger 2.5 via TER. Using femanagerextended 1.1 via zip from this repository.
Getting this error: Could not analyse class: "In2code\Femanagerextended\Controller\NewController" maybe not loaded or no autoloader? PHP Warning: Declaration of In2code\Femanagerextended\Controller\NewController::createAction(In2code\Femanagerextended\Domain\Model\User $user) should be compatible with In2code\Femanager\Controller\NewController::createAction(In2code\Femanager\Domain\Model\User $user) in PATH\T3Test\typo3conf\ext\femanagerextended\Classes\Controller\NewController.php line 21
For all with the same problem:
https://forge.typo3.org/issues/76290 does not exist, how can this be solved? The same issue comes by using https://github.com/einpraegsam/femanagerextended
Have you checked: https://github.com/einpraegsam/femanagerextended/issues/3 ?
Checked this:
Registered xclass in
ext_localconf.php:
<?php $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument'] = array( 'className' => 'vendor\\extension\\Xclass\\Extbase\\Mvc\\Controller\\Argument' );
This error-message is the result:
#1289386765: Could not analyse class: "vendor\extension\Controller\NewController" maybe not loaded or no autoloader? PHP Warning: Declaration of vendor\extension\Controller\NewController::createAction($user) should be compatible with In2code\Femanager\Controller\NewController::createAction(In2code\Femanager\Domain\Model\User $user) in /html/typo3/typo3conf/ext/extension/Classes/Controller/NewController.php line 0
Is there some other code necessary to register xclass, I did not need it before?
But I don´t understand what is wrong with inheritance in php7 and typo3?
Can you post your custom NewController?
I started today with import of Femanagerextended and added three parts:
Xclass: Argument.php
<?php
namespace In2code\Femanagerextended\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;
}
}
ext_localconf.php
<?php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument'] = array(
'className' => 'In2code\\Femanagerextended\\Xclass\\Extbase\\Mvc\\Controller\\Argument'
);
Xclass is registered:
TYPO3\CMS\Extbase\Mvc\Controller\Argument registriert eine XCLASS von In2code\Femanagerextended\Xclass\Extbase\Mvc\Controller\Argument
NewController.php
<?php
namespace In2code\Femanagerextended\Controller;
use In2code\Femanagerextended\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 \In2code\Femanagerextended\Xclass\Extbase\Mvc\Controller\Argument $user */
$user = $this->arguments['user'];
$user->setDataType(\In2code\Femanagerextended\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);
}
}
Can you try replacing the user in your createAction?
public function createAction(\In2code\Femanager\Domain\Model\User $user) {...}
This works for me.
Thank you, That works for me too.
Hi, I've answered to this stack overflow post https://stackoverflow.com/questions/45563671/how-to-extend-femanager-controller-under-php-7/51130418#51130418 Now it works with PHP7 and TYPO3 8.7.
I started today with import of Femanagerextended and added three parts:
- Xclass
- register Xlass in ext_localconf.php
- Added code to NewController
Xclass: Argument.php
<?php namespace In2code\Femanagerextended\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; } }
ext_localconf.php
<?php $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument'] = array( 'className' => 'In2code\\Femanagerextended\\Xclass\\Extbase\\Mvc\\Controller\\Argument' );
Xclass is registered:
TYPO3\CMS\Extbase\Mvc\Controller\Argument registriert eine XCLASS von In2code\Femanagerextended\Xclass\Extbase\Mvc\Controller\Argument
NewController.php
<?php namespace In2code\Femanagerextended\Controller; use In2code\Femanagerextended\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 \In2code\Femanagerextended\Xclass\Extbase\Mvc\Controller\Argument $user */ $user = $this->arguments['user']; $user->setDataType(\In2code\Femanagerextended\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); } }
This not working for my TYPO3 10.4, femanagaer 6.3.4 and PHP 7.4
Getting this error:
1: PHP Warning: Declaration of In2code\Femanagerextended\Controller\EditController::updateAction(In2code\Femanagerextended\Domain\Model\User $user) should be compatible with In2code\Femanager\Controller\EditController::updateAction(In2code\Femanager\Domain\Model\User $user) in PATH\typo3conf\ext\femanagerextended\Classes\Controller\EditController.php line 27
Is use femanager 2.5.