Пример #1
0
 protected function setUserData(Request $request, User $user)
 {
     $data = json_decode($request->getContent());
     $user->setNN('username', $data->username);
     $user->setNN('path', $data->path);
     $user->setNN('email', $data->email);
     if (isset($data->password1)) {
         $user->setPlainPassword($data->password1);
     }
 }
Пример #2
0
 public function discover(User $user)
 {
     $return = new \stdClass();
     $stime = microtime(true);
     $info_service = $this->container->get('smp3.fileinfo');
     $finder = new Finder();
     $finder->files()->in($user->getPath());
     $em = $this->container->get('doctrine')->getManager();
     $repository = $em->getRepository('SMP3Bundle:LibraryFile');
     $this->removeOrphaned($user);
     $counter = 0;
     foreach ($finder as $file) {
         $this->debug_msg('Processing: ' . $user->getPath() . '/' . $file->getRelativePathname());
         if (!in_array($file->getExtension(), $this->exts)) {
             continue;
         }
         $contents = file_get_contents($user->getPath() . '/' . $file->getRelativePathname());
         $checksum = crc32($contents);
         $lf = $repository->findOneBy(array('checksum' => $checksum));
         if (!$lf) {
             $lf = new LibraryFile();
             /*
              * Checksum is the same so the info data is the same
              */
             $info_data = $info_service->getTagInfo($file);
         } else {
             $info_data = null;
         }
         $this->setLibraryFile($lf, $user, $file, $info_data, $checksum);
         ++$counter;
     }
     $em->flush();
     $etime = microtime(true);
     $return->time = $etime - $stime;
     $return->counter = $counter;
     return $return;
 }