public function save(Doctrine_Connection $conn = null) { $record = $this->getRecord(); if ($record) { $record->save(); } if ($this->isModified()) { if (!$this->isNew() && ($this->isFieldModified('module') || $this->isFieldModified('action'))) { if ($pageView = dmDb::table('DmPageView')->findOneByModuleAndAction($this->get('module'), $this->get('action'))) { $this->setPageView($pageView); } else { $this->getPageView()->fromArray(array('module' => $this->get('module'), 'action' => $this->get('action'))); } } $this->getPageView(); if ($this->getDmModule() && $this->getIsAutomatic() && !$record instanceof dmDoctrineRecord) { throw new dmException(sprintf('%s automatic page can not be saved because it has no object for record_id = %s', $this, $this->record_id)); } } parent::save($conn); if ($dispatcher = $this->getEventDispatcher()) { $dispatcher->notify(new sfEvent($this, 'dm.page.post_save')); } }
public function save(Doctrine_Connection $conn = null) { $record = $this->getRecord(); if ($record && $record->isModified()) { $record->save(); } if ($this->isModified()) { if (!$this->isNew() && ($this->isFieldModified('module') || $this->isFieldModified('action'))) { if ($pageView = dmDb::table('DmPageView')->findOneByModuleAndAction($this->get('module'), $this->get('action'))) { $this->setPageView($pageView, false); } else { $this->getPageView()->fromArray(array('module' => $this->get('module'), 'action' => $this->get('action'))); } } $this->getPageView(); if ($this->getDmModule() && $this->getIsAutomatic() && !$record instanceof dmDoctrineRecord) { throw new dmException(sprintf('%s automatic page can not be saved because it has no object for record_id = %s', $this, $this->record_id)); } } $translationModifiedFields = $this->hasCurrentTranslation() ? $this->getCurrentTranslation()->getModified() : array(); parent::save($conn); if (array_key_exists('slug', $translationModifiedFields)) { if (!$this->getTable()->isSlugUnique($this->get('slug'), $this->get('id'))) { $this->set('slug', $this->getTable()->createUniqueSlug($this->get('slug'), $this->get('id'))); return $this->save(); } } if ($dispatcher = $this->getEventDispatcher()) { $dispatcher->notify(new sfEvent($this, 'dm.page.post_save')); } }