[TYPO3-mvc] DateTime Parsing with features.rewrittenPropertyMapper = 1 broken?
Matthias Krappitz
matthias at nospam.aemka.de
Tue Mar 6 19:28:59 CET 2012
Hi,
I found a solution to define the Date and Time format for DateTime Fields
some time ago for Extbase 1.4.x with
config.tx_extbase.features.rewrittenPropertyMapper = 1. Now, some months
later with TYPO3 4.6.4 it seems broken, I get a strange exception from the
property manager even though the entered values are valid. Could you see
from the (shortened) code and exception given below why this can be or tell
me what an exception message like "#1297759968: Exception while property
mapping at property path "":Method
Tx_Timetrack_Domain_Model_Worktime::__construct() does not exist (More
information)" could mean? How can there be not an __construct() method in
any class?
--------------------------------
This is my domain model:
--------------------------------
class Tx_Timetrack_Domain_Model_Worktime extends
Tx_Extbase_DomainObject_AbstractValueObject {
/**
* Begin Time
*
* @var DateTime
* @validate NotEmpty
*/
protected $begintime;
/**
* Duration
*
* @var float
* @validate NotEmpty
*/
protected $duration;
public function getBegintime() {
return $this->begintime;
}
function setBegintime($begintime) {
$this->begintime = $begintime;
}
public function getDuration() {
return $this->duration;
}
public function setDuration($duration) {
$this->duration = $duration;
}
}
--------------------------------
This is my controller:
--------------------------------
class Tx_Timetrack_Controller_WorktimeController extends
Tx_Extbase_MVC_Controller_ActionController {
// ...
/**
* action new
*
* @param $worktime
* @dontvalidate $worktime
* @return void
*/
public function newAction(Tx_Timetrack_Domain_Model_Worktime $worktime =
NULL) {
$this->view->assign('allEmployees',
$this->employeeRepository->findAll());
$this->view->assign('allProjects',
$this->projectRepository->findAll());
$this->view->assign('arguments',
$_REQUEST['tx_timetrack_worktimes']['worktime']);
$this->view->assign('worktime', $worktime);
}
/**
* action initializeCreate
*
* @return void
*/
public function initializeCreateAction() {
$this->arguments['worktime']
->getPropertyMappingConfiguration()
->forProperty('begintime')
->setTypeConverterOption(
'Tx_Extbase_Property_TypeConverter_DateTimeConverter',
Tx_Extbase_Property_TypeConverter_DateTimeConverter::CONFIGURATION_DATE_FORMAT,
'd.m.Y H:i:s' // 15.07.1985 10:10:10 //
1985-07-15T10:10:10+00:00
);
}
/**
* action create
*
* @param $worktime
* @return void
*/
public function createAction(Tx_Timetrack_Domain_Model_Worktime
$worktime) {
$this->worktimeRepository->add($worktime);
$this->flashMessageContainer->add('Your new Worktime was created.');
$this->redirect('list');
}
// ....
}
--------------------------------
When I submit inthe frontend plugin for creating new worktimes (more or less
like it was created by the extension_builder) with "15.07.1985 10:10:10" as
begintime and "3" as duration, I get the following Exception:
--------------------------------
Uncaught TYPO3 Exception
#1297759968: Exception while property mapping at property path "":Method
Tx_Timetrack_Domain_Model_Worktime::__construct() does not exist (More
information)
Tx_Extbase_Property_Exception thrown in file
/www/htdocs/krappitz/shared/typo3_src-4.6.latest/typo3/sysext/extbase/Classes/Property/PropertyMapper.php
in line 128.
15 Tx_Extbase_Property_PropertyMapper::convert(array,
"Tx_Timetrack_Domain_Model_Worktime",
Tx_Extbase_MVC_Controller_MvcPropertyMappingConfiguration)
/www/htdocs/krappitz/shared/typo3_src-4.6.latest/typo3/sysext/extbase/Classes/MVC/Controller/Argument.php:
00434: return $this;
00435: }
00436: $this->value = $this->propertyMapper->convert($rawValue,
$this->dataType, $this->propertyMappingConfiguration);
00437: $this->validationResults = $this->propertyMapper->getMessages();
00438: if ($this->validator !== NULL) {
14 Tx_Extbase_MVC_Controller_Argument::setValue(array)
/www/htdocs/krappitz/shared/typo3_src-4.6.latest/typo3/sysext/extbase/Classes/MVC/Controller/AbstractController.php:
00395:
00396: if ($this->request->hasArgument($argumentName)) {
00397: $argument->setValue($this->request->getArgument($argumentName));
00398: } elseif ($argument->isRequired()) {
00399: throw new
Tx_Extbase_MVC_Controller_Exception_RequiredArgumentMissingException('Required
argument "' . $argumentName . '" is not set.', 1298012500);
13
Tx_Extbase_MVC_Controller_AbstractController::mapRequestArgumentsToControllerArguments()
/www/htdocs/krappitz/shared/typo3_src-4.6.latest/typo3/sysext/extbase/Classes/MVC/Controller/ActionController.php:
00157: }
00158:
00159: $this->mapRequestArgumentsToControllerArguments();
00160: $this->checkRequestHash();
00161: $this->controllerContext = $this->buildControllerContext();
...
Cheers
Matthias
More information about the TYPO3-project-typo3v4mvc
mailing list