/** * @param array $comment */ public function add($comment) { // TODO: this is not the right place to catch the exception and build the errors list... try { $this->storage->addComment($this->getNormalized($comment)); return true; } catch (\Aoloe\Senape\Exception\FileNotWritable $e) { // TODO: make the error messages translatable $this->error[] = 'The comment could not be written in ' . basename($e->getFileNotWritten()); \Aoloe\debug('error', $this->error); return false; } }
public function getSiteList() { $list = null; $path = $this->settings['senape-basepath-data'] . $this->settings['storage-json-data-path'] . 'site.json'; if (!file_exists($path)) { if (is_writable(dirname($path))) { $list = array(); file_put_contents($path, json_encode($list)); } else { throw new \Aoloe\Senape\Exception\FileNotWritable($path); } } else { $list = file_get_contents($path); $list = json_decode($list, true); \Aoloe\debug('list', $list); if ($list === false) { throw new \Aoloe\Senape\Exception\FileInvalid($path); } } return $list; }