/** * Provides protections. * * @return array */ public function dataProvider() { $domain = new Domain(); $domain->setPath('/var/www/test.de'); $protection = new Protection($domain); $user1 = new ProtectionUser($domain, $protection); $user2 = new ProtectionUser($domain, $protection); $user1->setUsername('test1')->setPassword('pw1'); $user2->setUsername('test2')->setPassword('pw2'); $collection = new ArrayCollection(array($user1, $user2)); $protection->setProtectionuser($collection)->setId(1)->setPath('/var/www/test.de/htdocs/test'); return array(array($protection)); }
/** * Edits an existing ProtectionUser entity. * * @Route("/{entity}/update", name="config_protectionuser_update") * @Method("POST") * @Template("JeboehmLampcpCoreBundle:ProtectionUser:edit.html.twig") */ public function updateAction(Request $request, ProtectionUser $entity) { $oldPassword = $entity->getPassword(); $editForm = $this->createForm(new ProtectionUserType(), $entity); $editForm->bind($request); if ($editForm->isValid()) { $em = $this->getDoctrine()->getManager(); if (!$entity->getPassword()) { $entity->setPassword($oldPassword); } else { $entity->setPassword($this->_getCryptService()->encrypt($entity->getPassword())); } $em->persist($entity); $em->flush(); return $this->redirect($this->generateUrl('config_protectionuser_edit', array('entity' => $entity->getId()))); } return array('entity' => $entity, 'edit_form' => $editForm->createView()); }
/** * Test createAuthUserFile(). */ public function testCreateAuthUserFile() { $fs = new Filesystem(); $fs->mkdir(sys_get_temp_dir() . '/conf'); $domain = new Domain(); $protection = new Protection($domain); $protectionuser = new ProtectionUser($domain, $protection); $domain->setPath(sys_get_temp_dir()); $protection->setId(1)->setProtectionuser(new ArrayCollection(array($protectionuser))); $protectionuser->setUsername('test')->setPassword('tester')->setProtection($protection); $this->getService()->createAuthUserFile($protection); $this->assertFileExists(sys_get_temp_dir() . '/conf/authuser_1.passwd'); }