You are here

protected function ServicesEntityResourceControllerClean::propertyHasValue in Services Entity API 7.2

Determine whether a wrapper property has a specified value.

Parameters

\EntityMetadataWrapper $wrapper: The wrapper whose property is to be checked.

$name: The name of the property to check.

mixed $value: The value to compare it to. May be a wrapper, identifier or raw value.

Return value

boolean TRUE if the property's current value is equal to the given value. FALSE if they are different.

1 call to ServicesEntityResourceControllerClean::propertyHasValue()
ServicesEntityResourceControllerClean::update in plugins/services_entity_resource_clean.inc
Implements ServicesResourceControllerInterface::update().

File

plugins/services_entity_resource_clean.inc, line 317

Class

ServicesEntityResourceControllerClean
This class is designed to create a very clean API that integrates with the services and entity modules. We want to strip all "drupalisms" out of the API. For example, there should be no [LANGUAGE_NONE][0][value] or field_ in the API.

Code

protected function propertyHasValue(EntityMetadataWrapper $wrapper, $name, $value) {
  $property = $wrapper->{$name};
  if ($property instanceof EntityDrupalWrapper) {
    if ($value instanceof EntityDrupalWrapper) {
      return $value
        ->getIdentifier() == $property
        ->getIdentifier();
    }
    elseif (is_numeric($value)) {
      return $value == $property
        ->getIdentifier();
    }
  }
  return $value == $property
    ->value();
}