/**
* Since the core provide the pk as array('id' => 123) and not as array(123) we have to convert it for propel orm.
*
* @param array $pk
* @param string $objectKey
*
* @return mixed Propel PK
*/
public function getPropelPk($pk, $objectKey = null)
{
$definition = $this->getDefinition();
if ($objectKey) {
$definition = $this->objects->getDefinition($objectKey);
}
$result = [];
foreach ($definition->getPrimaryKeyNames() as $primaryKey) {
if (isset($pk[$primaryKey])) {
$result[] = $pk[$primaryKey];
}
}
if ($definition->getWorkspace()) {
$result[] = isset($pk['workspaceId']) ? $pk['workspaceId'] : WorkspaceManager::getCurrent();
}
return 1 === count($result) ? $result[0] : $result;
}