private function insertOneValidationToken(EntityManager $em, \Pimple $DI)
 {
     $user = $DI['user'];
     $token = new Token();
     $token->setValue($this->container['random.low']->generateString(12, TokenManipulator::LETTERS_AND_NUMBERS));
     $token->setUser($user);
     $token->setType(TokenManipulator::TYPE_VALIDATE);
     $token->setData($DI['basket_1']->getId());
     $DI['token_validation'] = $token;
     $em->persist($token);
 }
Exemple #2
0
 /**
  *
  * @param Application $app
  * @param String      $token
  * @param Array       $list
  * @param string      $zipFile
  *
  * @return string
  */
 public static function build_zip(Application $app, Token $token, array $list, $zipFile)
 {
     if (isset($list['complete']) && $list['complete'] === true) {
         return;
     }
     $files = $list['files'];
     $list['complete'] = false;
     $token->setData(serialize($list));
     $app['manipulator.token']->update($token);
     $toRemove = [];
     $archiveFiles = [];
     foreach ($files as $record) {
         if (isset($record["subdefs"])) {
             foreach ($record["subdefs"] as $o => $obj) {
                 $path = p4string::addEndSlash($obj["path"]) . $obj["file"];
                 if (is_file($path)) {
                     $name = $obj["folder"] . $record["export_name"] . $obj["ajout"] . '.' . $obj["exportExt"];
                     $archiveFiles[$app['unicode']->remove_diacritics($name)] = $path;
                     if ($o == 'caption') {
                         if (!in_array(dirname($path), $toRemove)) {
                             $toRemove[] = dirname($path);
                         }
                         $toRemove[] = $path;
                     }
                 }
             }
         }
     }
     $app['zippy']->create($zipFile, $archiveFiles);
     $list['complete'] = true;
     $token->setData(serialize($list));
     $app['manipulator.token']->update($token);
     $app['filesystem']->remove($toRemove);
     $app['filesystem']->chmod($zipFile, 0760);
     return $zipFile;
 }