Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/2.9 #42

Merged
merged 3 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Generator/PicoDatabaseDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public function dumpStructure($entity, $databaseType, $createIfNotExists = false
$tool = new PicoDatabaseUtilPostgreSql();
return $tool->dumpStructure($tableInfo, $picoTableName, $createIfNotExists, $dropIfExists, $engine, $charset);
}
else if($databaseType == PicoDatabaseType::DATABASE_TYPE_SQLITE)
{
$tool = new PicoDatabaseUtilSqlite();
return $tool->dumpStructure($tableInfo, $picoTableName, $createIfNotExists, $dropIfExists, $engine, $charset);
}
return "";
}

/**
Expand Down Expand Up @@ -103,6 +109,7 @@ public function dumpStructureTable($tableInfo, $databaseType, $createIfNotExists
$tool = new PicoDatabaseUtilSqlite();
return $tool->dumpStructure($tableInfo, $picoTableName, $createIfNotExists, $dropIfExists, $engine, $charset);
}
return "";
}

/**
Expand Down
25 changes: 18 additions & 7 deletions src/MagicDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -828,34 +828,45 @@ public function arrayToXml($dataArray, $xml) {
}
}

/**
* Check if a method is overridden in a child class.
*
* This method uses reflection to determine if a given method is overridden in the specified child class.
* It compares the methods of the child class with those of its parent class, checking if the method
* is present in both classes but has been redefined in the child class.
*
* @param string $childClass The child class name or instance to check for method override.
* @param string $methodName The name of the method to check for overriding.
* @return bool Returns true if the method is overridden in the child class, false otherwise.
*/
private function isMethodOverridden($childClass, $methodName) {
// Buat instance ReflectionClass untuk kelas anak
// Create a ReflectionClass instance for the child class
$childReflection = new ReflectionClass($childClass);

// Dapatkan kelas induk
// Get the parent class
$parentClass = $childReflection->getParentClass();

if ($parentClass) {
// Dapatkan metode dari kelas anak
// Get the public methods of the child class
$childMethods = $childReflection->getMethods(ReflectionMethod::IS_PUBLIC);

// Dapatkan metode dari kelas induk
// Get the public methods of the parent class
$parentMethods = $parentClass->getMethods(ReflectionMethod::IS_PUBLIC);

// Ambil nama metode dari metode induk
// Get the method names of the parent class
$parentMethodNames = array_map(function($method) {
return $method->getName();
}, $parentMethods);

// Cek apakah metode ada di kelas anak dan juga di kelas induk
// Check if the method is present in both the child and parent class
foreach ($childMethods as $method) {
if ($method->getName() === $methodName && in_array($methodName, $parentMethodNames)) {
return true; // Metode telah di-override
}
}
}

return false; // Jika tidak ada kelas induk atau metode tidak di-override
return false;// No parent class or method is not overridden
}

}
Loading
Loading