Skip to content

Commit

Permalink
Delete and locale fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Salamek committed Sep 13, 2019
1 parent 3003902 commit 9e77307
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Dravencms/AdminModule/Components/Form/FormGrid/FormGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ public function handleDelete($id)
$forms = $this->formRepository->getById($id);
foreach ($forms AS $form)
{
foreach ($form->getItemGroups() AS $itemGroup)
{
foreach ($itemGroup->getItems() AS $item)
{
foreach ($item->getItemOptions() AS $itemOption)
{
$this->entityManager->remove($itemOption);
}
$this->entityManager->remove($item);
}
$this->entityManager->remove($itemGroup);
}
$this->entityManager->remove($form);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ public function handleDelete($id)
$items = $this->itemRepository->getById($id);
foreach ($items AS $item)
{
foreach ($item->getItemOptions() AS $itemOption)
{
$this->entityManager->remove($itemOption);
}
$this->entityManager->remove($item);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ public function handleDelete($id)
$itemGroups = $this->itemGroupRepository->getById($id);
foreach ($itemGroups AS $itemGroup)
{
foreach ($itemGroup->getItems() AS $item)
{
foreach ($item->getItemOptions() AS $itemOption)
{
$this->entityManager->remove($itemOption);
}
$this->entityManager->remove($item);
}
$this->entityManager->remove($itemGroup);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public function render()
$template = $this->template;

$template->formInfo = $this->formInfo;
$template->currentLocale = $this->currentLocale;

if ($this->formInfoTranslation->getLatteTemplate())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<li n:foreach="$form->errors as $error">{$error}</li>
</ul>
{foreach $formInfo->getItemGroups() AS $formsItemsGroups}
{if $formsItemsGroups->isShowName()}
<fieldset>
<legend>{$formsItemsGroups->translate($currentLocale)->getName()}</legend>
{/if}
{foreach $formsItemsGroups->getItems() AS $formsItems}
<div class="form-group control-group">
{if $formsItems->getType() == 'select'}
Expand All @@ -14,6 +18,9 @@
{/if}
</div>
{/foreach}
{if $formsItemsGroups->isShowName()}
</fieldset>
{/if}
{/foreach}

<div n:if="$formInfo->isAntispam()" class="form-group control-group">
Expand Down
12 changes: 12 additions & 0 deletions src/Dravencms/Model/Form/Entities/ItemGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
namespace Dravencms\Model\Form\Entities;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use Dravencms\Model\Locale\Entities\ILocale;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Kdyby\Doctrine\Entities\Attributes\Identifier;
Expand Down Expand Up @@ -154,5 +156,15 @@ public function getTranslations()
{
return $this->translations;
}

/**
* @param ILocale $locale
* @return GalleryTranslation
*/
public function translate(ILocale $locale)
{
$criteria = Criteria::create()->where(Criteria::expr()->eq("locale", $locale));
return $this->getTranslations()->matching($criteria)->first();
}
}

0 comments on commit 9e77307

Please sign in to comment.