working alternative for variable classes on the cloud

Hi,

since on the cloud we are prohibited to use certain classes or functions I was wondering how other people are working around a specific issue. We have certain functionality that uses variable classes. Since we can't use $class or Reflection we are bound to use 'factories'. Is there another way to instantiate classes in a way that is not blacklisted?

Parents
  • Not a solution, but a comment on the same line - We had the same situation and I don't think there is any way to bypass that restriction. Factories are probably the only solution here, but that also requires us to know all possible classes beforehand. We did it something like:

    public static function createClass($className)
    {
    switch ($className) {
    case 'Class1':
    return new Class1();
    case 'Class2':
    return new Class2();
    }
Reply
  • Not a solution, but a comment on the same line - We had the same situation and I don't think there is any way to bypass that restriction. Factories are probably the only solution here, but that also requires us to know all possible classes beforehand. We did it something like:

    public static function createClass($className)
    {
    switch ($className) {
    case 'Class1':
    return new Class1();
    case 'Class2':
    return new Class2();
    }
Children