Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/c2is/BigfootContentBundle
Browse files Browse the repository at this point in the history
Conflicts:
	Twig/Extension/ContentExtension.php
  • Loading branch information
gmanen committed Mar 31, 2014
2 parents 9d5f871 + a69a928 commit 98cb704
Show file tree
Hide file tree
Showing 14 changed files with 207 additions and 161 deletions.
8 changes: 4 additions & 4 deletions Controller/BlockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ public function newAction(Request $request, $template)
)
);

$blocksForm = $this->renderView('BigfootContentBundle:'.ucfirst($contentType).':Block/list.html.twig', array('form' => $contentForm->createView()));
$prototype = $this->renderView('BigfootContentBundle:'.ucfirst($contentType).':Block/prototype.html.twig', array('form' => $contentForm->createView()));

$content = array(
'prototype' => $blocksForm,
'prototype' => $prototype,
'option' => array(
'label' => $block->getName().' - '.$block->getParentTemplate(),
'value' => $block->getId()
Expand Down Expand Up @@ -213,10 +213,10 @@ public function editAction(Request $request, $id)
)
);

$blocksForm = $this->renderView('BigfootContentBundle:'.ucfirst($contentType).':Block/list.html.twig', array('form' => $contentForm->createView()));
$prototype = $this->renderView('BigfootContentBundle:'.ucfirst($contentType).':Block/prototype.html.twig', array('form' => $contentForm->createView()));

$content = array(
'prototype' => $blocksForm,
'prototype' => $prototype,
'option' => array(
'id' => $block->getId(),
'label' => $block->getName().' - '.$block->getParentTemplate(),
Expand Down
122 changes: 25 additions & 97 deletions Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,117 +157,45 @@ public function editAction(Request $request, $id)
$dbSidebars4 = new ArrayCollection();
$dbSidebars5 = new ArrayCollection();

foreach ($page->getBlocks() as $block) {
$dbBlocks->add($block);
}

foreach ($page->getBlocks2() as $block2) {
$dbBlocks2->add($block2);
}

foreach ($page->getBlocks3() as $block3) {
$dbBlocks3->add($block3);
}

foreach ($page->getBlocks4() as $block4) {
$dbBlocks4->add($block4);
}

foreach ($page->getBlocks5() as $block5) {
$dbBlocks5->add($block5);
}

foreach ($page->getSidebars() as $sidebar) {
$dbSidebars->add($sidebar);
}

foreach ($page->getSidebars2() as $sidebar2) {
$dbSidebars2->add($sidebar2);
}
for ($i = 1; $i <= 5; $i++) {
$j = ($i > 1) ? $i : '';

foreach ($page->getSidebars3() as $sidebar3) {
$dbSidebars3->add($sidebar3);
foreach ($page->{'getBlocks'.$j}() as ${'block'.$j}) {
${'dbBlocks'.$j}->add(${'block'.$j});
}
}

foreach ($page->getSidebars4() as $sidebar4) {
$dbSidebars4->add($sidebar4);
}
for ($i = 1; $i <= 5; $i++) {
$j = ($i > 1) ? $i : '';

foreach ($page->getSidebars5() as $sidebar5) {
$dbSidebars5->add($sidebar5);
foreach ($page->{'getSidebars'.$j}() as ${'sidebar'.$j}) {
${'dbSidebars'.$j}->add(${'sidebar'.$j});
}
}

if ('POST' === $request->getMethod()) {
$form->handleRequest($request);

if ($form->isValid()) {
foreach ($dbBlocks as $block) {
if ($page->getBlocks()->contains($block) === false) {
$page->getBlocks()->removeElement($block);
$this->getEntityManager()->remove($block);
for ($i = 1; $i <= 5; $i++) {
$j = ($i > 1) ? $i : '';

foreach (${'dbBlocks'.$j} as ${'block'.$j}) {
if ($page->{'getBlocks'.$j}()->contains(${'block'.$j}) === false) {
$page->{'getBlocks'.$j}()->removeElement(${'block'.$j});
$this->getEntityManager()->remove(${'block'.$j});
}
}
}

foreach ($dbBlocks2 as $block2) {
if ($page->getBlocks2()->contains($block2) === false) {
$page->getBlocks2()->removeElement($block2);
$this->getEntityManager()->remove($block2);
}
}

foreach ($dbBlocks3 as $block3) {
if ($page->getBlocks3()->contains($block3) === false) {
$page->getBlocks3()->removeElement($block3);
$this->getEntityManager()->remove($block3);
}
}

foreach ($dbBlocks4 as $block4) {
if ($page->getBlocks4()->contains($block4) === false) {
$page->getBlocks4()->removeElement($block4);
$this->getEntityManager()->remove($block4);
}
}

foreach ($dbBlocks5 as $block5) {
if ($page->getBlocks5()->contains($block5) === false) {
$page->getBlocks5()->removeElement($block5);
$this->getEntityManager()->remove($block5);
}
}

foreach ($dbSidebars as $sidebar) {
if ($page->getSidebars()->contains($sidebar) === false) {
$page->getSidebars()->removeElement($sidebar);
$this->getEntityManager()->remove($sidebar);
}
}

foreach ($dbSidebars2 as $sidebar2) {
if ($page->getSidebars2()->contains($sidebar2) === false) {
$page->getSidebars2()->removeElement($sidebar2);
$this->getEntityManager()->remove($sidebar2);
}
}

foreach ($dbSidebars3 as $sidebar3) {
if ($page->getSidebars3()->contains($sidebar3) === false) {
$page->getSidebars3()->removeElement($sidebar3);
$this->getEntityManager()->remove($sidebar3);
}
}

foreach ($dbSidebars4 as $sidebar4) {
if ($page->getSidebars4()->contains($sidebar4) === false) {
$page->getSidebars4()->removeElement($sidebar4);
$this->getEntityManager()->remove($sidebar4);
}
}
for ($i = 1; $i <= 5; $i++) {
$j = ($i > 1) ? $i : '';

foreach ($dbSidebars5 as $sidebar5) {
if ($page->getSidebars5()->contains($sidebar5) === false) {
$page->getSidebars5()->removeElement($sidebar5);
$this->getEntityManager()->remove($sidebar5);
foreach (${'dbSidebars'.$j} as ${'sidebar'.$j}) {
if ($page->{'getSidebars'.$j}()->contains(${'sidebar'.$j}) === false) {
$page->{'getSidebars'.$j}()->removeElement(${'sidebar'.$j});
$this->getEntityManager()->remove(${'sidebar'.$j});
}
}
}

Expand Down
Loading

0 comments on commit 98cb704

Please sign in to comment.