/** * Create new RSS file after project creation * @param $project * @return bool */ public function storeProjectRssFile(Project $project) { $fileName = $this->rssDir . $this->pKey . ".rss"; $rssLog = new Rss_log(); $rssLog->setPid($project->getId()); if (!$this->checkFileExists($fileName)) { // Create new one RSS file $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"></rss>', null, false); $channel = $xml->addChild("channel"); $channel->addChild("title", $project->getName()); $channel->addChild("description", $project->getDescription()); $channel->addChild("link", $this->partnerUrl . $project->getCruid()); $rssLog->setTitle($project->getName()); $rssLog->setDescription($project->getDescription()); $rssLog->setLink($this->partnerUrl . $project->getCruid()); $rssLog->setType("project create"); } else { // Update existing RSS file libxml_use_internal_errors(true); try { $xml = new SimpleXMLElement($fileName, NULL, TRUE); } catch (Exception $er) { return false; } $xml = $this->openRssFile($fileName); if ($xml === false) { return false; } unset($xml->channel->title); unset($xml->channel->description); unset($xml->channel->link); $xml->channel->addChild("title", $project->getName()); $xml->channel->addChild("description", $project->getDescription()); $xml->channel->addChild("link", $this->partnerUrl . $project->getCruid()); $rssLog->setTitle($project->getName()); $rssLog->setDescription($project->getDescription()); $rssLog->setLink($this->partnerUrl . $project->getCruid()); $rssLog->setType("project update"); } try { $xml->asXML($fileName); } catch (Exception $er) { return false; } $rssLog->setR_date(\Carbon\Carbon::Now()->toDateTimeString()); $this->storeRssLog($rssLog); return true; }