/** * validate & save module * @return void */ public function execute() { $response = $this->umcFactory->create(); $response->setGlue(self::ERROR_GLUE); try { /** @var \Zend\Stdlib\Parameters $data */ $data = $this->getRequest()->getPost(); $module = $this->moduleFactory->create(); $module->initFromData($data->toArray()); $errors = $module->validate(); if (count($errors) == 0) { $xml = $module->toXml([], $module->getEntityCode(), true, true); $this->writer->setPath($module->getSettings()->getXmlRootPath()); $this->writer->write($module->getExtensionName() . '.xml', $xml); $this->builder->setModule($module)->build(); $response->setError(false); $response->setMessage(__('Done!!! Check you var folder')); } else { if (isset($errors[''])) { $response->setMessage(implode(self::ERROR_GLUE, $errors[''])); unset($errors['']); } $response->setError(true); $response->setAttributes($errors); } } catch (\Exception $e) { $response->setError(true); $response->setMessage($e->getMessage()); } $this->getResponse()->setBody($response->toJson()); }
public function writeLog() { $files = array_keys($this->files); asort($files); $content = implode("\n", $files) . "\n"; $oldPath = $this->writer->getPath(); $newPath = $this->module->getSettings()->getXmlRootPath() . '/' . Settings::MODULES_DIR_NAME . '/'; $destination = $this->module->getNamespace() . '_' . $this->module->getModuleName() . '/files.log'; $this->writer->setPath($newPath); $this->writer->write($destination, $content); $this->writer->setPath($oldPath); return $this; }