/** * Persists the given model on the backend. * * Creates a language dir if not presented, and writes a file into it. * Filename is the page alias. * * @param Default_Model_Page $page Page model to save * @return bool true * @throws Light_Exception_InvalidParameter * If language or alias not presented in the model */ public function save(Default_Model_Page $page) { if ("" == $page->getLanguage()) { require_once 'Light/Exception/InvalidParameter.php'; throw new Light_Exception_InvalidParameter("Language not provided"); } if ("" == $page->getAlias()) { require_once 'Light/Exception/InvalidParameter.php'; throw new Light_Exception_InvalidParameter("Alias not provided"); } $fileUri = $this->getDirectoryRoot() . DIRECTORY_SEPARATOR . $page->getLanguage() . DIRECTORY_SEPARATOR . $page->getAlias(); $fileContent = $this->_contentFromTitleAndContent($page->getTitle(), $page->getContent()); $this->_createDirIfNeeded($page->getLanguage()); file_put_contents($fileUri, $fileContent); return true; }