fix issue, default foler is set on content creation
This commit is contained in:
@@ -47,8 +47,7 @@ class Content extends BaseAction implements EventSubscriberInterface
|
||||
->setVisible($event->getVisible())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->addFolder(FolderQuery::create()->findPk($event->getDefaultFolder()))
|
||||
->save()
|
||||
->create($event->getDefaultFolder())
|
||||
;
|
||||
|
||||
$event->setContent($content);
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Core\Event\Content\ContentEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Base\Content as BaseContent;
|
||||
use Thelia\Model\Map\ContentTableMap;
|
||||
use Thelia\Tools\URL;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
|
||||
@@ -43,6 +45,34 @@ class Content extends BaseContent
|
||||
return $default_folder == null ? 0 : $default_folder->getFolderId();
|
||||
}
|
||||
|
||||
public function create($defaultFolderId)
|
||||
{
|
||||
$con = Propel::getWriteConnection(ContentTableMap::DATABASE_NAME);
|
||||
|
||||
$con->beginTransaction();
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATECONTENT, new ContentEvent($this));
|
||||
|
||||
try {
|
||||
$this->save($con);
|
||||
|
||||
$cf = new ContentFolder();
|
||||
$cf->setContentId($this->getId())
|
||||
->setFolderId($defaultFolderId)
|
||||
->setDefaultFolder(1)
|
||||
->save($con);
|
||||
|
||||
$this->setPosition($this->getNextPosition())->save($con);
|
||||
|
||||
$con->commit();
|
||||
} catch(\Exception $ex) {
|
||||
|
||||
$con->rollback();
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
||||
@@ -100,10 +100,10 @@
|
||||
<select id="{$label_attr.for}" required="required" name="{$name}" class="form-control">
|
||||
<option value="0">{intl l="Top level"}</option>
|
||||
|
||||
{$myparent=$PARENT}
|
||||
{* loop name="fold-parent" type="folder-tree" visible="*" folder="0"}
|
||||
{$myparent=$DEFAULT_FOLDER}
|
||||
{loop name="fold-parent" type="folder-tree" visible="*" folder="0"}
|
||||
<option value="{$ID}" style="padding-left: {3 + $LEVEL * 20}px" {if $myparent == $ID}selected="selected"{/if} {if $folder_id == $ID}disabled="disabled"{/if}>{$TITLE}</option>
|
||||
{/loop *}
|
||||
{/loop }
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user