Created
August 26, 2019 08:12
-
-
Save smarek/4eb45ff9abc64627dcf6d42301d3ebef to your computer and use it in GitHub Desktop.
cakephp remove all associated fields from entity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function entityStripAssociations(Entity &$entity) | |
{ | |
/** @var Table $table */ | |
$table = TableRegistry::getTableLocator()->get($entity->getSource()); | |
foreach ($table->associations() as $asoc) { | |
$entity->unsetProperty($asoc->getProperty()); | |
} | |
return $entity; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment