Skip to content

Instantly share code, notes, and snippets.

@smarek smarek/assoc.php
Created Aug 26, 2019

Embed
What would you like to do?
cakephp remove all associated fields from entity
<?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
You can’t perform that action at this time.