fix portal isDefault
This commit is contained in:
@@ -52,10 +52,13 @@ class Portal extends \Espo\Core\ORM\Repositories\RDB
|
||||
if ($entity->has('isDefault')) {
|
||||
if ($entity->get('isDefault')) {
|
||||
$this->getConfig()->set('defaultPortalId', $entity->id);
|
||||
$this->getConfig()->save();
|
||||
} else {
|
||||
$this->getConfig()->set('defaultPortalId', null);
|
||||
if ($entity->isAttributeChanged('isDefault')) {
|
||||
$this->getConfig()->set('defaultPortalId', null);
|
||||
$this->getConfig()->save();
|
||||
}
|
||||
}
|
||||
$this->getConfig()->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ use \Espo\ORM\Entity;
|
||||
|
||||
class Portal extends Record
|
||||
{
|
||||
protected $getEntityBeforeUpdate = true;
|
||||
|
||||
public function loadAdditionalFields(Entity $entity)
|
||||
{
|
||||
parent::loadAdditionalFields($entity);
|
||||
@@ -51,8 +53,10 @@ class Portal extends Record
|
||||
$url = $siteUrl . '?entryPoint=portal';
|
||||
if ($entity->id === $this->getConfig()->get('defaultPortalId')) {
|
||||
$entity->set('isDefault', true);
|
||||
$entity->setFetched('isDefault', true);
|
||||
} else {
|
||||
$url .= '&id=' . $entity->id;
|
||||
$entity->setFetched('isDefault', false);
|
||||
}
|
||||
$entity->set('url', $url);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user