Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. $ignores = array(
  2. "bas_contato" => array("tipo"),
  3. "bas_endereco" => array("complemento")
  4. )
  5.  
  6. function checkSameEntity($from, $to) {} // verifica se é o mesmo tipo (classe) de entity
  7.  
  8. function getPrimaryKey($entity) {}
  9.  
  10. function getPesCodColumn($entity) {}
  11.  
  12. function getColumnList($entity) {}
  13.  
  14. function getIgnoreList($entity) {
  15. $tableName = $entity->Table();
  16.  
  17. return $this->ignoreList[$tableName];
  18. }
  19.  
  20. function checkDuplicidade($from, $to){
  21. checkSameEntity($from, $to);
  22.  
  23. $ignoreList = getIgnoreList($from);
  24. $ignoreList[] = getPrimaryKey($from);
  25. $ignoreList[] = getPesCodColumn($from);
  26.  
  27. $columnList = getColumnList($from);
  28.  
  29. $ignoreList = array_map("strtoupper", $ignoreList);
  30. $columnList = array_map("strtoupper", $columnList);
  31.  
  32. $columnList = array_filter($columnList, static function($column) use($ignoreList) {
  33. return in_array($column, $ignoreList);
  34. });
  35.  
  36. $fromData = $from->LoadObjectData();
  37. $toData = $to->LoadObjectData();
  38.  
  39. // aplicar trim, remover acento e toupper em ambos "data"
  40.  
  41. $registroDuplicado = true;
  42. foreach ($columnList as $column) {
  43. if ($fromData[$column] !== $toData[$column]) {
  44. $registroDuplicado = false;
  45. }
  46. }
  47.  
  48. return $registroDuplicado;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement