0

Flow3 の Security Account/Party モジュールに問題があります。

パーティとして個人の姓名を変更しようとしました:

$person = $account->getParty();
$name = $person->getName();
$name->setFirstName($firstName);
$name->setLastName($lastName);
$this->accountRepository->update($account);
$this->partyRepository->update($person);

$account は有効な\TYPO3\FLOW3\Security\Accountオブジェクトです。

このコードを使用して $firstName と $lastname を変更すると、flow3 はロールバックを実行します。

回避策を見つけました:

$personName = new \TYPO3\Party\Domain\Model\PersonName('', $firstName,'', $lastName);
$person->setName($personName);

これは正しく動作しますが、なぜですか??

4

1 に答える 1

1

これは、参照ではなくPerson::getName()コピーを返すためです。PersonNameつまり、PersonName は、外側 ( ) で変更した場合、内側 ( $this->name) で更新されません。$person$name

これは1つの解決策です:

$person = $account->getParty();
$name = $person->getName();
$name->setFirstName($firstName);
$name->setLastName($lastName);
$person->setName($name);
$this->accountRepository->update($account);
$this->partyRepository->update($person);

PersonName をもう一度設定するだけです。

このアンサーもいいです:https://stackoverflow.com/a/746322/782920

PHP: 参照による戻り: http://php.net/manual/en/language.references.return.php

于 2012-06-11T09:50:09.783 に答える