Skip to content

Commit

Permalink
Merge pull request #23 from NicolasBarbey/fix_redirections
Browse files Browse the repository at this point in the history
fix module configurations
  • Loading branch information
zawaze authored Mar 20, 2023
2 parents 89b95ec + 2cd56d1 commit 27d2a54
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>2.0.0</version>
<version>2.0.1</version>
<authors>
<author>
<name>Maxime BRUCHET</name>
Expand Down
2 changes: 1 addition & 1 deletion Controller/ImageUploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public function toggleVisibilityFileAction(FileManager $fileManager, Request $re
);
}
$this->adminUpadteLogAppend($parentType, $message, $documentId);
return $this->generateRedirectFromRoute('selection.update', [], ['selectionId' => $parentId], null);
return $this->generateRedirect(URL::getInstance()->absoluteUrl('/admin/selection/update/'.$parentId));
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Controller/SelectionRelatedContentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ public function addContentRelated(Request $request)
);
$search->find();
}
return $this->render('related/contentRelated', ['selection_id' => $selectionID]);
return $this->render('related/contentRelated', [
'selection_id' => $selectionID,
'locale' => $this->getCurrentEditionLocale()
]);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Controller/SelectionRelatedProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ public function addProductRelated(Request $request)
);
$search->find();
}
return $this->render('related/productRelated', ['selection_id' => $selectionID]);
return $this->render('related/productRelated', [
'selection_id' => $selectionID,
'locale' => $this->getCurrentEditionLocale()
]);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Controller/SelectionUpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function saveSelection()
return $this->render("electionlist");
}

return $this->generateRedirectFromRoute('selection.update', [], ['selectionId' => $selectionID], null);
return $this->generateRedirect('/admin/selection/update/'.$selectionID);
}

public function createSelection()
Expand Down Expand Up @@ -190,7 +190,7 @@ public function deleteRelatedProduct(Request $request)
Tlog::getInstance()->error($e->getMessage());
}

return $this->generateRedirectFromRoute('selection.update', [], ['selectionId' => $selectionID], null);
return $this->generateRedirect('/admin/selection/update/'.$selectionID);
}

public function deleteRelatedContent(Request $request)
Expand All @@ -209,7 +209,7 @@ public function deleteRelatedContent(Request $request)
Tlog::getInstance()->error($e->getMessage());
}

return $this->generateRedirectFromRoute('selection.update', [], ['selectionId' => $selectionID], null);
return $this->generateRedirect('/admin/selection/update/'.$selectionID);
}

/*-------------------------- Part Controller SEO */
Expand Down Expand Up @@ -444,7 +444,7 @@ protected function performAdditionalUpdatePositionAction($positionEvent)
{
$selectionID = $this->getRequest()->get('selection_id');

return $this->generateRedirectFromRoute('selection.update', [], ['selectionId' => $selectionID], null);
return $this->generateRedirect(URL::getInstance()->absoluteUrl('/admin/selection/update/'.$selectionID));
}

protected function performAdditionalDeleteAction($deleteEvent)
Expand Down
6 changes: 1 addition & 5 deletions Form/SelectionContainerUpdateForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ protected function buildForm()
array(
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Callback([
"methods" => [
[$this, "checkDuplicateCode"],
]
]),
new Constraints\Callback([$this, "checkDuplicateCode"]),
),
"label" => Translator::getInstance()->trans('Selection code', [], Selection::DOMAIN_NAME),
)
Expand Down
17 changes: 9 additions & 8 deletions Form/SelectionUpdateForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Selection\Model\SelectionQuery;
use Selection\Selection;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
Expand Down Expand Up @@ -36,14 +37,13 @@ protected function buildForm()
$this->formBuilder
->add(
'selection_id',
TextType::class,
HiddenType::class,
array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans('Selection reference', [], Selection::DOMAIN_NAME),
"required" => false,
"disabled" => true,
"disabled" => false,
)
)
->add(
Expand All @@ -53,9 +53,7 @@ protected function buildForm()
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Callback([
"methods" => [
[$this, "checkDuplicateCode"],
]
$this, "checkDuplicateCode"
]),
),
"label" => Translator::getInstance()->trans('Selection code', [], Selection::DOMAIN_NAME),
Expand Down Expand Up @@ -130,8 +128,11 @@ protected function buildForm()
function (FormEvent $event) {
$data = $event->getData();
$selectionContainerWrongValue = $data['selection_container'];
$selectionContainerValue = $this->containersArray[$selectionContainerWrongValue];
$data['selection_container_id'] = $selectionContainerValue;
$data['selection_container_id'] = null;
if (null !== $selectionContainerWrongValue) {
$selectionContainerValue = $this->containersArray[$selectionContainerWrongValue];
$data['selection_container_id'] = $selectionContainerValue;
}
$event->setData($data);
}
);
Expand Down
5 changes: 3 additions & 2 deletions Loop/SelectionContentRelated.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ protected function getArgDefinitions()
Argument::createIntListTypeArgument('content_id'),
Argument::createIntListTypeArgument('selection_id'),
Argument::createAnyTypeArgument('content_title'),
Argument::createIntListTypeArgument('position')
Argument::createIntListTypeArgument('position'),
Argument::createAnyTypeArgument('locale')
);
}

Expand Down Expand Up @@ -78,7 +79,7 @@ public function parseResults(LoopResult $loopResult)

$loopResultRow
->set("CONTENT_ID", $content->getContentId())
->set("CONTENT_TITLE", $content->getContent()->getTitle())
->set("CONTENT_TITLE", $content->getContent()->setLocale($this->getLocale())->getTitle())
->set("POSITION", $content->getPosition())
->set("selection_id", $content->getSelectionId());

Expand Down
6 changes: 4 additions & 2 deletions Loop/SelectionProductRelated.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @method int[] getSelectionId()
* @method string getProductTitle()
* @method int[] getPosition()
* @method string getLocale()
*/
class SelectionProductRelated extends BaseLoop implements PropelSearchLoopInterface
{
Expand All @@ -38,7 +39,8 @@ protected function getArgDefinitions()
Argument::createIntListTypeArgument('product_id'),
Argument::createAnyTypeArgument('product_title'),
Argument::createIntListTypeArgument('selection_id'),
Argument::createIntListTypeArgument('position')
Argument::createIntListTypeArgument('position'),
Argument::createAnyTypeArgument('locale')
);
}

Expand Down Expand Up @@ -90,7 +92,7 @@ public function parseResults(LoopResult $loopResult)
$loopResultRow = new LoopResultRow($product);
$loopResultRow
->set("PRODUCT_ID", $product->getProductId())
->set("PRODUCT_TITLE", $product->getProduct()->getTitle())
->set("PRODUCT_TITLE", $product->getProduct()->setLocale($this->getLocale())->getTitle())
->set("POSITION", $product->getPosition())
->set("selection_id", $product->getSelectionId());

Expand Down
2 changes: 1 addition & 1 deletion Selection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Selection extends BaseModule
{
/** @var string */
const DOMAIN_NAME = 'selection';
const ROUTER = 'router.selection';
const ROUTER = 'module.Selection';

const RESOURCES_SELECTION = 'admin.selection';
const CONFIG_ALLOW_PROFILE_ID = 'admin_profile_id';
Expand Down
2 changes: 1 addition & 1 deletion templates/backOffice/default/related/contentRelated.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{loop name="selection_content_related" type="selection_content_related" selection_id=$selection_id}
{loop name="selection_content_related" type="selection_content_related" selection_id=$selection_id locale=$locale}
<tr id="contentValue">
<td>{$CONTENT_ID}</td>
<td>{$CONTENT_TITLE}</td>
Expand Down
2 changes: 1 addition & 1 deletion templates/backOffice/default/related/productRelated.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{loop name="selection_product_related" type="selection_product_related" selection_id=$selection_id}
{loop name="selection_product_related" type="selection_product_related" selection_id=$selection_id locale=$locale}
<tr id="contentValue">
<td>{$PRODUCT_ID}</td>
<td>{$PRODUCT_TITLE}</td>
Expand Down
2 changes: 0 additions & 2 deletions templates/backOffice/default/selection-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,13 @@
}
<div class="row">
<div class="col-md-6">

{render_form_field field="selection_id"}
{render_form_field field="selection_code"}
{render_form_field field="selection_container"}
{render_form_field field="selection_title"}
{render_form_field field="selection_chapo"}
{render_form_field field="selection_description" extra_class="wysiwyg"}
{render_form_field field="selection_postscriptum"}

</div>
<div class="col-md-5 col-md-offset-1">
<div class="row">
Expand Down

0 comments on commit 27d2a54

Please sign in to comment.