HosipLan

Untitled

Nov 3rd, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. class IdentityTest extends Nette\Object
  2. {
  3.     private $identityDir;
  4.     private $user;
  5.  
  6.     public function __construct($tempDir, Nette\Http\User $user)
  7.     {
  8.         $this->user = $user;
  9.         $this->identityDir = $tempDir . '/saveIdentity';
  10.         if (false === file_exists($tempDir)) {
  11.             mkdir($tempDir);
  12.         }
  13.     }
  14.  
  15.  
  16.     public function startTest()
  17.     {
  18.         do {
  19.             $file = $this->identityDir . '/' . Nette\Utils\Strings::random();
  20.         } while (file_exists($file));
  21.  
  22.         file_put_contents($file, $this->user->getId());
  23.         return array("test" => "test", "token" => basename($name)));
  24.     }
  25.  
  26.    
  27. }
  28.  
  29. /// config.neon
  30.  
  31. services:
  32.     identityTest: IdentityTest(%tempDir%)
  33.  
  34.  
  35. // FrontModule/BasePresenter
  36.  
  37. public function injectIdenityTest(IdentityTest $it)
  38. {
  39.     $this->identityTest = $it;
  40. }
  41.  
  42. public function handleStartTesting()
  43. {
  44.     $this->redirect(":CustomerAdmin:Sign:getIdentity", $this->identityTest->startTest());
  45. }
  46.  
  47. // CustomerAdmin/SignPresenter
  48. // tohle se mi už přepisovat nechce
Advertisement
Add Comment
Please, Sign In to add comment