Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ignores = array(
- "bas_contato" => array("tipo"),
- "bas_endereco" => array("complemento")
- )
- function checkSameEntity($from, $to) {} // verifica se é o mesmo tipo (classe) de entity
- function getPrimaryKey($entity) {}
- function getPesCodColumn($entity) {}
- function getColumnList($entity) {}
- function getIgnoreList($entity) {
- $tableName = $entity->Table();
- return $this->ignoreList[$tableName];
- }
- function checkDuplicidade($from, $to){
- checkSameEntity($from, $to);
- $ignoreList = getIgnoreList($from);
- $ignoreList[] = getPrimaryKey($from);
- $ignoreList[] = getPesCodColumn($from);
- $columnList = getColumnList($from);
- $ignoreList = array_map("strtoupper", $ignoreList);
- $columnList = array_map("strtoupper", $columnList);
- $columnList = array_filter($columnList, static function($column) use($ignoreList) {
- return in_array($column, $ignoreList);
- });
- $fromData = $from->LoadObjectData();
- $toData = $to->LoadObjectData();
- // aplicar trim, remover acento e toupper em ambos "data"
- $registroDuplicado = true;
- foreach ($columnList as $column) {
- if ($fromData[$column] !== $toData[$column]) {
- $registroDuplicado = false;
- }
- }
- return $registroDuplicado;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement