You could create a public static property in your application like this
class Application extends BaseApplication
{
public static array $postTypes = ['draft', 'photo', 'live'];
}
and reference them in your Application class like
$types = self::$postTypes;
or in any other PHP class like this
$types = \App\Application::$postTypes;
This is just basic PHP class functionality, nothing really cakephp specific so you could also just create your own custom class inside your src folder and use it as a source for all your Post types.
I’d recommend you watch my video about re-using code from 2021 cakefest.
An even better alternative would to use an enum class of the types. Cake 5 will also have mapping of enum classes to table columns which would make using the enum class even more seamless.
Like Admad suggested, I would recommend using enums too. Example below, you will be able to get the String from it. eg :`
/**
* Storage classes available in S3
*/
enum AwsS3StorageClasses: string
{
case STANDARD = 'STANDARD';
case REDUCED_REDUNDANCY = 'REDUCED_REDUNDANCY';
case STANDARD_IA = 'STANDARD_IA';
case ONEZONE_IA = 'ONEZONE_IA';
}