public function saveChanges() { $values = $this->getValues(); $target = $this->targetDao->findTarget($this->target); if (!$target) { $target = new Brabijan\SeoComponents\Entity\Target(); $target->targetPresenter = $this->target->presenter; $target->targetAction = $this->target->action; $target->targetId = $this->target->id; $this->targetDao->save($target); } if (!$target->meta) { $meta = new Brabijan\SeoComponents\Entity\Meta(); $meta->target = $target; $target->meta = $meta; $this->metaDao->save($meta); $this->targetDao->save($target); } $meta = $target->meta; $meta->seoTitle = $values->seoTitle; $meta->seoKeywords = $values->seoKeywords; $meta->seoDescription = $values->seoDescription; $meta->seoRobots = $values->seoRobots; $meta->sitemapChangeFreq = $values->sitemapChangeFreq; $meta->sitemapPriority = $values->sitemapPriority; $this->metaDao->save($meta); $currentRoute = $this->routeDao->findCurrentRouteByTarget($this->target); if ($values->route && (!$currentRoute || $currentRoute->slug !== $values->route)) { $this->routeDao->addRoute($target, $values->route); } }
/** * @param Target $target * @param array $values */ private function saveMeta(Target $target, array $values) { $meta = $target->meta; $meta->seoTitle = $values["seoTitle"]; $meta->seoKeywords = $values["seoKeywords"]; $meta->seoDescription = $values["seoDescription"]; $meta->seoRobots = $values["seoRobots"]; $meta->sitemapPriority = $values["sitemapPriority"]; $meta->sitemapChangeFreq = $values["sitemapChangeFreq"]; $this->metaDao->save($meta); }