get(DocumentRoot::class); $this->_directory = $filesystem->getDirectoryWrite($documentRoot->getPath()); $this->_file = 'robots.txt'; } /** * Return content of default robot.txt * * @return bool|string */ protected function _getDefaultValue() { if ($this->_directory->isFile($this->_file)) { return $this->_directory->readFile($this->_file); } return false; } /** * Load default content from robots.txt if customer does not define own * * @return $this */ protected function _afterLoad() { if (!(string)$this->getValue()) { $this->setValue($this->_getDefaultValue()); } return parent::_afterLoad(); } /** * Check and process robots file * * @return $this */ public function afterSave() { if ($this->getValue()) { $this->_directory->writeFile($this->_file, $this->getValue()); } return parent::afterSave(); } }