Question

A deleted object (deleteAction) can not be restored (restoreAction), brings up a exception:

Exception while property mapping at property path "": Object with identity "1" not found.

Controller:

/**
 * action delete
 *
 * @param \EXAPOINT\Exacallmanagement\Domain\Model\Calls $calls
 * @return void
 */
public function deleteAction(\EXAPOINT\Exacallmanagement\Domain\Model\Calls $calls) {
    $this->callsRepository->remove($calls);
    $this->flashMessageContainer->add('Call gelöscht.');
    $this->redirect('list');
}


/**
 * action restore
 *
 * @param \EXAPOINT\Exacallmanagement\Domain\Model\Calls $calls
 * @return void
 */
public function restoreAction(\EXAPOINT\Exacallmanagement\Domain\Model\Calls $calls) {
    $calls->setDeleted(0);
    $this->callsRepository->update($calls);
    $this->redirect('list');
}

Model:

/**
 * @var \integer
 */
protected $deleted;

/**
 * @return integer $deleted
 */
public function getDeleted() {
    return $this->deleted;
}

/**
 * @param integer $deleted
 * @return void
 */
public function setDeleted($deleted) {
    $this->deleted = $deleted;
}

Does the source of the problem is the fact that a deleted object is not "seen" by the repository? What would be the best way?

Was it helpful?

Solution

If the property mapper cant handle a deleted object, just pass the uid to your restoreAction and then

  • Check if a deletedObject with that ID exists
  • If thats the case, restore it
  • If not, redirect, flashMessage, whatever you like

Make sure you have the deleted field configured in your TCA:

'deleted' => array(
    'exclude' => 1,
    'label' => 'deleted',
    'config' => array(
        'type' => 'check',
    ),
),

You dont have to add it to any type, but if I remember correctly the field itself must be configured like this.

OTHER TIPS

The repository has to be configured to find entities that are normally ignored because of the enableFields. In your repository, try something like:

public function initializeObject() {
    $defaultQuerySettings = $this->objectManager->get('Tx_Extbase_Persistence_Typo3QuerySettings');
    $defaultQuerySettings->setRespectEnableFields(FALSE);
    $this->setDefaultQuerySettings($defaultQuerySettings);
}

In addition to the existing answer: This problem is well known and this is about to change for TYPO3 6.2. You can follow the issue and test an Extbase patch here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top