Skip to content

Instantly share code, notes, and snippets.

@seutje
Created September 1, 2016 12:47
Show Gist options
  • Save seutje/975188a3da8558d3d14d7ff0c9487308 to your computer and use it in GitHub Desktop.
Save seutje/975188a3da8558d3d14d7ff0c9487308 to your computer and use it in GitHub Desktop.
conditional extension
class Bar extends DsFieldBase {
public function __construct($foo) {
// do some other stuff...
}
}
class Foo extends DsFieldBase {
public function __construct($foo) {
// do some stuff...
}
}
class Foo extends DsFieldBase {
public function __construct($foo) {
if ($condition) {
return new Foo($foo);
}
else {
return new Bar($foo);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment