/** * Override modResourceUpdateProcessor::beforeSave to provide archiving * * {@inheritDoc} * @return boolean */ public function beforeSave() { $afterSave = parent::beforeSave(); if ($this->object->get('published') && ($this->object->isDirty('alias') || $this->object->isDirty('published'))) { if (!$this->setArchiveUri()) { $this->modx->log(modX::LOG_LEVEL_ERROR, 'Failed to set date URI.'); } } /** @var ArticlesContainer $container */ $container = $this->modx->getObject('ArticlesContainer', $this->object->get('parent')); if ($container) { $this->object->setProperties($container->getProperties('articles'), 'articles'); } $this->isPublishing = $this->object->isDirty('published') && $this->object->get('published'); return $afterSave; }
/** * Override modResourceUpdateProcessor::beforeSave to provide archiving * * {@inheritDoc} * @return boolean */ public function beforeSave() { $afterSave = parent::beforeSave(); $container = $this->modx->getObject('ArticlesContainer', $this->object->get('parent')); if ($this->object->get('published') && ($this->object->isDirty('alias') || $this->object->isDirty('published'))) { if (!$this->setArchiveUri()) { $this->modx->log(modX::LOG_LEVEL_ERROR, 'Failed to set date URI.'); } } else { if ($this->object->get('pub_date') && $this->object->isDirty('pub_date') || $this->object->isDirty('pub_date')) { if (!$this->setArchiveUri()) { $this->modx->log(modX::LOG_LEVEL_ERROR, 'Failed to set date URI pub_date.'); } } else { if (!$this->object->get('published') && !$this->object->get('pub_date')) { // we need to always do this because the url may have been set previously by pub_date /*$containerUri = $container->get('uri'); if (empty($containerUri)) { $containerUri = $container->get('alias'); }*/ $uri = rtrim($this->object->get('alias')); $this->object->set('uri', $uri); $this->object->set('uri_override', true); } } } /** @var ArticlesContainer $container */ if ($container) { $this->object->setProperties($container->getProperties('articles'), 'articles'); } $this->isPublishing = $this->object->isDirty('published') && $this->object->get('published'); return $afterSave; }