Domain/DomainUtil.php
public static function getIdentifier(ObjectManager $om, $object)
    {
        $propertyAccess = PropertyAccess::createPropertyAccessor();
        $meta = $om->getClassMetadata(ClassUtils::getClass($object));
        $ids = $meta->getIdentifier();
        $value = null;

        foreach ($ids as $id) {
            $idVal = $propertyAccess->getValue($object, $id);

            if (null !== $idVal) {
                $value = $idVal;

                break;
            }
        }

        return $value;
    }
public static function getIdentifier(ObjectManager $om, $object)
    {
        $propertyAccess = PropertyAccess::createPropertyAccessor();
        $meta = $om->getClassMetadata(ClassUtils::getClass($object));
        $ids = $meta->getIdentifier();
        $value = null;

        foreach ($ids as $id) {
            $idVal = $propertyAccess->getValue($object, $id);

            if (null !== $idVal) {
                $value = $idVal;

                break;
            }
        }

        return $value;
    }
public static function getIdentifier ( ObjectManager $ om , $ object ) { $ propertyAccess = PropertyAccess :: createPropertyAccessor ( ) ; $ meta = $ om -> getClassMetadata ( ClassUtils :: getClass ( $ object ) ) ; $ ids = $ meta -> getIdentifier ( ) ; $ value = null ; foreach ( $ ids as $ id ) { $ idVal = $ propertyAccess -> getValue ( $ object , $ id ) ; if ( null !== $ idVal ) { $ value = $ idVal ; break ; } } return $ value ; }
Get the value of resource identifier.

@param ObjectManager $om     The doctrine object manager
@param object        $object The resource object

@return null|int|string
Get the value of resource identifier .