Open Takika opened 8 years ago
This could be problematic if an user doesn't need BackendCombined, but another of the backends.
For instance, if I only use BackendIMAP its constructor would require an argument (the configuration variable), and Z-Push core won't pass it, it just call the constructor (normal operations won't even call the constructor and directly hit the Logon method).
My solution from the caldav.php:
public function BackendCalDAV($config = array()) {
if (sizeof($config) > 0) {
$this->config = $config;
}
else {
$this->config['protocol'] = CALDAV_PROTOCOL;
$this->config['host'] = CALDAV_SERVER;
$this->config['port'] = CALDAV_PORT;
$this->config['path'] = CALDAV_PATH;
$this->config['personal'] = CALDAV_PERSONAL;
$this->config['sync'] = CALDAV_SUPPORTS_SYNC;
$this->config['debug'] = true;
}
}
And after this everywhere I use $this->config array.
But, as I said you could be creating instances of your backend without passing config array. You would be using defaults values. I don't see the benefit, since you also have to define the constants CALDAV...
Yes, if a user doesn't want to use the BackendCombined backend he/she have to set the correct config variables in the backend specific config.php .
I have a very strange Z-Push and webmail setup with Z-Push-contrib, Roundcube, LDAP addressbook, Dovecot IMAP and SabreDAV as CalDAV. I made a Roundcube plugin where my users can control what they want to sync (globally and per device). To use this config from RC I modified the BackendCombinedConfig class, which sends not just the name of the backend but a config variable to the backend class too. Changed this:
to this:
And modified my backend classes to use this new config parameter (if it isn't empty) instead of hardcoded define-s. What do you think about these changes? :) If you want I can show some examples from any backend class :)