<?php
namespace App\Doctrine\Platform;
use Doctrine\DBAL\Platforms\MySQL57Platform;
/**
* Custom platform class extending MySQL57Platform to handle ENUM types.
*/
class CustomMySQL57Platform extends MySQL57Platform
{
/**
* Overrides the default Doctrine type mapping to handle ENUM types.
*
* Doctrine does not natively support ENUM types in MySQL.
* This method ensures that ENUM types are treated as strings in Doctrine's internal mapping.
*
* @param string $dbType The database type (e.g., 'enum').
* @return string The Doctrine type mapped from the database type.
*/
public function getDoctrineTypeMapping($dbType)
{
// Check if the database type is 'enum'
if ($dbType === 'enum') {
// Map 'enum' database type to Doctrine's 'string' type for compatibility
return 'string';
}
// For all other types, use the default Doctrine mapping
return parent::getDoctrineTypeMapping($dbType);
}
}