original_string: protected function _calculateHash($entity)
      {
          $hash = [];
          foreach ($entity->visibleProperties() as $property) {
              if (strpos($property, 'created') === false &&
                  strpos($property, 'created_by') === false &&
                  strpos($property, 'modified') === false &&
                  strpos($property, 'modified_by') === false
              ) {
                  if ($property == '_fields') {
                      foreach ($entity->get('_fields') as $field) {
                          if ($field instanceof \Field\Model\Entity\Field) {
                              $hash[] = is_object($field->value) || is_array($field->value) ? md5(serialize($field->value)) : md5($field->value);
                          }
                      }
                  } else {
                      $hash[] = $entity->get($property);
                  }
              }
          }
  
          return md5(serialize($hash));
      }
code: protected function _calculateHash($entity)
      {
          $hash = [];
          foreach ($entity->visibleProperties() as $property) {
              if (strpos($property, 'created') === false &&
                  strpos($property, 'created_by') === false &&
                  strpos($property, 'modified') === false &&
                  strpos($property, 'modified_by') === false
              ) {
                  if ($property == '_fields') {
                      foreach ($entity->get('_fields') as $field) {
                          if ($field instanceof \Field\Model\Entity\Field) {
                              $hash[] = is_object($field->value) || is_array($field->value) ? md5(serialize($field->value)) : md5($field->value);
                          }
                      }
                  } else {
                      $hash[] = $entity->get($property);
                  }
              }
          }
  
          return md5(serialize($hash));
      }
code_tokens: protected function _calculateHash ( $ entity ) { $ hash = [ ] ; foreach ( $ entity -> visibleProperties ( ) as $ property ) { if ( strpos ( $ property , 'created' ) === false && strpos ( $ property , 'created_by' ) === false && strpos ( $ property , 'modified' ) === false && strpos ( $ property , 'modified_by' ) === false ) { if ( $ property == '_fields' ) { foreach ( $ entity -> get ( '_fields' ) as $ field ) { if ( $ field instanceof \ Field \ Model \ Entity \ Field ) { $ hash [ ] = is_object ( $ field -> value ) || is_array ( $ field -> value ) ? md5 ( serialize ( $ field -> value ) ) : md5 ( $ field -> value ) ; } } } else { $ hash [ ] = $ entity -> get ( $ property ) ; } } } return md5 ( serialize ( $ hash ) ) ; }
docstring: Generates a unique hash for the given entity.
  
  Used by revision system to detect if an entity has changed or not.
  
  @param \Cake\Datasource\EntityInterface $entity The entity for which calculate its hash
  @return string MD5 hash for this particular entity
docstring_tokens: Generates a unique hash for the given entity .