1
0
mirror of synced 2025-02-20 22:23:14 +03:00

#1178 - moved private method to the bottom of the class

This commit is contained in:
Marco Pivetta 2015-01-17 06:44:01 +01:00
parent edf054cd0c
commit 584839d38a

View File

@ -35,42 +35,6 @@ use Doctrine\ORM\Query\QueryException;
*/
class PersisterHelper
{
/**
* @param mixed $value
* @param EntityManagerInterface $em
*
* @return mixed
*/
public static function getValue($value, EntityManagerInterface $em)
{
if ( ! is_array($value)) {
return self::getIndividualValue($value, $em);
}
$newValue = array();
foreach ($value as $fieldName => $fieldValue) {
$newValue[$fieldName] = self::getIndividualValue($fieldValue, $em);
}
return $newValue;
}
/**
* @param mixed $value
* @param EntityManagerInterface $em
*
* @return mixed
*/
private static function getIndividualValue($value, EntityManagerInterface $em)
{
if ( ! is_object($value) || ! $em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value))) {
return $value;
}
return $em->getUnitOfWork()->getSingleIdentifierValue($value);
}
/**
* @param string $fieldName
* @param ClassMetadata $class
@ -169,4 +133,40 @@ class PersisterHelper
$class->getName()
));
}
/**
* @param mixed $value
* @param EntityManagerInterface $em
*
* @return mixed
*/
public static function getValue($value, EntityManagerInterface $em)
{
if ( ! is_array($value)) {
return self::getIndividualValue($value, $em);
}
$newValue = array();
foreach ($value as $fieldName => $fieldValue) {
$newValue[$fieldName] = self::getIndividualValue($fieldValue, $em);
}
return $newValue;
}
/**
* @param mixed $value
* @param EntityManagerInterface $em
*
* @return mixed
*/
private static function getIndividualValue($value, EntityManagerInterface $em)
{
if ( ! is_object($value) || ! $em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value))) {
return $value;
}
return $em->getUnitOfWork()->getSingleIdentifierValue($value);
}
}