|
|
|
@ -15,10 +15,11 @@ use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
|
|
|
|
|
|
Class PadController extends AbstractController
|
|
|
|
|
{
|
|
|
|
|
private function get_padform(){
|
|
|
|
|
private function get_padform($name = null){
|
|
|
|
|
return $this->createFormBuilder()
|
|
|
|
|
->add('content', TextareaType::class)
|
|
|
|
|
->add('save', SubmitType::class, ['label' => 'Enregistrer'])
|
|
|
|
|
->add('name',HiddenType::class,[ 'attr' => ['value' => is_null($name)? '' : $name ]])
|
|
|
|
|
->add('crypt_iv', HiddenType::class,[])
|
|
|
|
|
->add('crypt_v', HiddenType::class,[])
|
|
|
|
|
->add('crypt_iter', HiddenType::class,[])
|
|
|
|
@ -32,12 +33,12 @@ Class PadController extends AbstractController
|
|
|
|
|
->getForm();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public function showForm(){
|
|
|
|
|
public function showForm($name = null){
|
|
|
|
|
|
|
|
|
|
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',
|
|
|
|
|
'form' => $this->get_padform()->createView()
|
|
|
|
|
'form' => $this->get_padform($name)->createView()
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
public function view($name)
|
|
|
|
@ -49,7 +50,10 @@ Class PadController extends AbstractController
|
|
|
|
|
|
|
|
|
|
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];
|
|
|
|
@ -104,7 +108,7 @@ Class PadController extends AbstractController
|
|
|
|
|
$entityManager = $this->getDoctrine()->getManager();
|
|
|
|
|
$pad = new PAD();
|
|
|
|
|
$pad->setContent($data["content"])
|
|
|
|
|
->setName( $this-> get_free_name() )
|
|
|
|
|
->setName(( $data["name"] == '' )? $this-> get_free_name() : $data["name"] )
|
|
|
|
|
->setCryptIv( $data["crypt_iv"] )
|
|
|
|
|
->setCryptMode( $data["crypt_mode"] )
|
|
|
|
|
->setCryptAdata( is_null( $data["crypt_adata"])? "" : $data["crypt_adata"] )
|
|
|
|
|