John Davidson

Problem of Curly Brackets in my controller Php Symfony

0 comments
Message:


I want to call my function but when I call it I have a problem with curly Brackets at the end of my code and i have this error Error SYMFONY ( {} ) in my Controller.


I have no idea where to put them for my code to work. I have this problem when I add my function that allows me to retrieve the
history of the action. The mentioned function goes as this:


$this->logHistory->addHistoryConnection($project->getId(), $user->getId(), 'Delete Local Suf', $sf_code);


Function Supp Suf


/**
* @Route("/creation/suf/supp", name="suf_supp")
*/
public function suf(
Request $request,
ShapesRepository $shapesRepository
) {
$params = $this->requestStack->getSession();
$projet = $params->get('projet');

$modules = $params->get('modules');
$fonctionnalites = $params->get('fonctionnalites');

$user = $this->getUser()->getUserEntity();
$manager = $this->graceManager;
$mapManager = $this->mapManager;

$countElements = $mapManager->getCount();
$shapes = $shapesRepository->findBy(array('projet' => $projet->getId()));

$adresseWeb = $this->getParameter('adresse_web');
$carto = $params->get('paramCarto');
$centrage = $params->get('centrage');
$cableColor = $params->get('cableColor');

$sf_code = '';
if ($request->get('suf') != '') {
$sf_code = $request->get('suf');
}

$suf = $manager->getSuf($sf_code);

$success = '';
$error = '';
$warning = '';

if ($request->query->get('success')) {
$success = $request->query->get('success');
} elseif ($request->query->get('error')) {
$error = $request->query->get('error');
} elseif ($request->query->get('warning')) {
$warning = $request->query->get('warning');
}

if ($request->isMethod('POST')) {
if ($request->request->get('sf_code') != '') {
$sf_code = $request->request->get('sf_code');
}

if ($request->get('val') != '') {
$val = $request->get('val');
}

$dir = $this->getparameter('client_directory');
$dossier = str_replace(' ', '_', $projet->getProjet());
$dir = $dir . $dossier . '/documents/';

$cable = $val[0];
$chem = $val[1];

$t_suf = $this->graceCreator->supprimeSuf($sf_code, $cable, $chem);

if ($t_suf[0][0] == '00000') {
$this->logHistorique->addHistoryConnection($projet->getId(), $user->getId(), 'Suppression Suf Local', $sf_code);


// $creator->delDirObjet( $st_code, $dir );
$data = new JsonResponse(array("success" => "create!"));
return $data;
} else {
$data = new JsonResponse(array("error" => "Error : " . $t_suf));
return $data;
}
return $this->render('Modifications/supSuf.html.twig', array(
'user' => $user,
'paramCarto' => $carto,
'cableColor' => $cableColor,
'suf' => $suf,
'adresseWeb' => $adresseWeb,
'centrage' => $centrage,
'shapes' => $shapes,
'projet' => $projet,
'modules' => $modules,
'fonctionnalites' => $fonctionnalites,
'countElements' => $countElements
));
}
}


My Answer:
>getDoctrine()->getRepository(History::class)->findBy(['action' => $action]);

To fix the issue with curly brackets in your controller, make sure that your code is properly formatted and all opening curly brackets have a corresponding closing curly bracket. Here is an example of how your controller code should look like:

php
public function yourFunctionName()
{
// Your code here
$action = 'your_action';
$history = $this->getDoctrine()->getRepository(History::class)->findBy(['action' => $action]);

// Return a response or do something with $history
}


Make sure to check for any missing or misplaced curly brackets in your code and ensure that they are properly matched. This should resolve the issue with the curly brackets in your controller.

Rate this post

3 of 5 based on 8711 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us