plip
This commit is contained in:
parent
d0a7b38d86
commit
14bc069aec
|
@ -15,10 +15,11 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
Class PadController extends AbstractController
|
Class PadController extends AbstractController
|
||||||
{
|
{
|
||||||
private function get_padform(){
|
private function get_padform($name = null){
|
||||||
return $this->createFormBuilder()
|
return $this->createFormBuilder()
|
||||||
->add('content', TextareaType::class)
|
->add('content', TextareaType::class)
|
||||||
->add('save', SubmitType::class, ['label' => 'Enregistrer'])
|
->add('save', SubmitType::class, ['label' => 'Enregistrer'])
|
||||||
|
->add('name',HiddenType::class,[ 'attr' => ['value' => is_null($name)? '' : $name ]])
|
||||||
->add('crypt_iv', HiddenType::class,[])
|
->add('crypt_iv', HiddenType::class,[])
|
||||||
->add('crypt_v', HiddenType::class,[])
|
->add('crypt_v', HiddenType::class,[])
|
||||||
->add('crypt_iter', HiddenType::class,[])
|
->add('crypt_iter', HiddenType::class,[])
|
||||||
|
@ -32,12 +33,12 @@ Class PadController extends AbstractController
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
}
|
}
|
||||||
public function showForm(){
|
public function showForm($name = null){
|
||||||
|
|
||||||
return $this->render('pad.html.twig', [
|
return $this->render('pad.html.twig', [
|
||||||
'head_title' => 'Créer un nouveau PAD',
|
'head_title' => is_null($name) ? 'Créer un nouveau PAD' : 'Créer le pad id ' . $name ,
|
||||||
'page_title' => 'Simple Pad',
|
'page_title' => 'Simple Pad',
|
||||||
'form' => $this->get_padform()->createView()
|
'form' => $this->get_padform($name)->createView()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
public function view($name)
|
public function view($name)
|
||||||
|
@ -49,7 +50,10 @@ Class PadController extends AbstractController
|
||||||
|
|
||||||
if(count($pads) == 0 )
|
if(count($pads) == 0 )
|
||||||
{
|
{
|
||||||
throw new NotFoundHttpException('This pad does not exist');
|
|
||||||
|
|
||||||
|
return $this->showForm($name);
|
||||||
|
//throw new NotFoundHttpException('This pad does not exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
$pad = $pads[0];
|
$pad = $pads[0];
|
||||||
|
@ -104,7 +108,7 @@ Class PadController extends AbstractController
|
||||||
$entityManager = $this->getDoctrine()->getManager();
|
$entityManager = $this->getDoctrine()->getManager();
|
||||||
$pad = new PAD();
|
$pad = new PAD();
|
||||||
$pad->setContent($data["content"])
|
$pad->setContent($data["content"])
|
||||||
->setName( $this-> get_free_name() )
|
->setName(( $data["name"] == '' )? $this-> get_free_name() : $data["name"] )
|
||||||
->setCryptIv( $data["crypt_iv"] )
|
->setCryptIv( $data["crypt_iv"] )
|
||||||
->setCryptMode( $data["crypt_mode"] )
|
->setCryptMode( $data["crypt_mode"] )
|
||||||
->setCryptAdata( is_null( $data["crypt_adata"])? "" : $data["crypt_adata"] )
|
->setCryptAdata( is_null( $data["crypt_adata"])? "" : $data["crypt_adata"] )
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
</em>
|
</em>
|
||||||
</nav>
|
</nav>
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
|
{{ form_widget(form.name, {}) }}
|
||||||
{{ form_widget(form.crypt_iv, {}) }}
|
{{ form_widget(form.crypt_iv, {}) }}
|
||||||
{{ form_widget(form.crypt_v, {}) }}
|
{{ form_widget(form.crypt_v, {}) }}
|
||||||
{{ form_widget(form.crypt_iter, {}) }}
|
{{ form_widget(form.crypt_iter, {}) }}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user