/** * Check if server has slaves * Dispatch DeleteFileOnSlave Event for each slave * * @param FileWasDeleted $event */ public function handle(FileWasDeleted $event) { if (hasSlaves()) { foreach (getSlaves() as $slave) { $this->dispatch(new DeleteFileOnSlave($slave, $event->filename)); } } }
/** * Check if server has slaves * Dispatch RenameFileOnSlave Event for each slave * * @param FileWasRenamed $event */ public function handle(FileWasRenamed $event) { if (hasSlaves()) { foreach (getSlaves() as $slave) { $this->dispatch(new RenameFileOnSlave($slave, $event->from, $event->to)); } } }
/** * Check if server has slaves * Dispatch UploadFileToSlave Event for each slave * * @param FileWasSaved $event */ public function handle(FileWasSaved $event) { if (hasSlaves()) { foreach (getSlaves() as $slave) { $this->dispatch(new UploadFileToSlave($slave, $event->filename, $event->force)); } } }
/** * Build the Server Matrix * * @return array */ public function build() { $self = ['alias' => getServerAlias(), 'url' => getServerUrl(), 'type' => getServerType()]; $servers = []; if (hasSlaves()) { $servers['servers'] = []; foreach (getSlaves() as $slave) { $servers['servers'][] = $this->getSlaveInformations($slave); } } return array_merge($self, $servers); }
/** * Collect and return serverinfos as json * * @return array */ public function info() { return ['alias' => getServerAlias(), 'url' => getServerUrl(), 'type' => getServerType(), 'slaves' => getSlaves(), "whitelisted_ips" => getWhitelistedIps()]; }
/** * Check if server has slaves * * @return bool */ function hasSlaves() { return (getServerType() == 'master' || getServerType() == 'submaster') && getSlaves(); }