public static function getRequests($requestsId, $accesToken)
 {
     $ch = curl_init();
     $url = 'https://graph.facebook.com/?ids=' . $requestsId . '&method=get&access_token=' . $accesToken;
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $object = json_decode(curl_exec($ch));
     return $array = \FWM\ServicesBundle\Services\ArrayService::objectToArray($object);
 }
 public function createVersion($request, $componentData, $component, $versionType = false, $branch = 'master')
 {
     $em = $this->_em;
     /**
      * manage versionType name
      * 
      * If is additional branch add brnach name at end.
      */
     if ($branch != 'master' && $branch != false) {
         if ($versionType) {
             $versionType = $versionType . '-' . $branch;
         } else {
             $versionType = $componentData['version']['value'] . '-' . $branch;
         }
     } else {
         if ($versionType) {
             $versionType = $versionType;
         } else {
             $versionType = $componentData['version']['value'];
         }
     }
     if (!$versionType) {
         $version = new \FWM\CraftyComponentsBundle\Entity\Versions();
         $version->setValue($versionType);
     } else {
         $componentData['version']['value'] = $versionType;
         $version = $em->getRepository('FWMCraftyComponentsBundle:Versions')->findOneBy(array('component' => $component->getId(), 'value' => $versionType));
         if (!$version) {
             $version = new \FWM\CraftyComponentsBundle\Entity\Versions();
             $version->setValue($versionType);
         }
     }
     $version->setSha($componentData['version']['sha']);
     $version->setComponent($component);
     $version->setFileContent($componentData['componentFilesValue']);
     $version->setCreatedAt(new \DateTime());
     //complete all files
     foreach (ArrayService::objectToArray(json_decode($componentData['componentFilesValue'])) as $value) {
         $tempFileContent[] = base64_decode($value);
     }
     $file = implode(' ', $tempFileContent);
     $path = $request->server->get('DOCUMENT_ROOT') . '/uploads/components/' . strtolower($componentData['name']) . '-' . strtolower($versionType);
     //create uncompressed version
     file_put_contents($path . '-uncompressed.js', $file);
     //minify uncompressed version
     try {
         $js = new AssetCollection(array(new FileAsset($path . '-uncompressed.js')), array(new Yui\JsCompressorFilter($request->server->get('DOCUMENT_ROOT') . '/../app/Resources/java/yuicompressor.jar')));
         $minifidedFile = $js->dump();
     } catch (\Exception $e) {
         $minifidedFile = $file;
     }
     // create minified version
     file_put_contents($path . '.js', $minifidedFile);
     return $version;
 }
 private function _getFilesFromDirs($componentFilesValue, $data, $dirs, $namespace = '/')
 {
     foreach ($data as $key => $element) {
         if ($element['type'] == 'tree' && array_key_exists($element['path'], $dirs)) {
             $ch = curl_init();
             $url = $element['url'];
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_HEADER, false);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             $packageFile = ArrayService::objectToArray(json_decode(curl_exec($ch)));
             $dirData = $packageFile['tree'];
             $componentFilesValue = $this->_getFilesFromDirs($componentFilesValue, $dirData, $dirs[$element['path']], $element['path']);
         } else {
             if ($element['type'] == 'blob' && in_array($element['path'], $dirs)) {
                 $componentFilesValue = $this->_loadFileContentFromGithub($componentFilesValue, $element['url'], array_search($element['path'], $dirs));
             }
         }
     }
     ksort($componentFilesValue);
     return $componentFilesValue;
 }