Skip to content

Instantly share code, notes, and snippets.

@meze
Created June 3, 2013 19:51
Show Gist options
  • Save meze/5700832 to your computer and use it in GitHub Desktop.
Save meze/5700832 to your computer and use it in GitHub Desktop.
<?php
/**
* Extracts the identifier values of an entity of this class.
*
* For composite identifiers, the identifier values are returned as an array
* with the same order as the field order in {@link identifier}.
*
* @param object $entity
* @return array
*/
public function getIdentifierValues($entity)
{
if ($this->isIdentifierComposite) {
$id = array();
foreach ($this->identifier as $idField) {
$value = $this->reflFields[$idField]->getValue($entity);
if ($value !== null) {
$id[$idField] = $value;
}
}
return $id;
}
$value = $this->reflFields[$this->identifier[0]]->getValue($entity);
if ($value !== null) {
return array($this->identifier[0] => $value);
}
return array();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment