/** * run single api call for one remote app * * @param $id * * @return \Symfony\Component\HttpFoundation\Response * @throws \Exception * @throws \PropelException */ public function runSingleApiCallAction($id) { $sLico = SystemSettings::get("lico"); $iLvdc = SystemSettings::get("lvdc"); if ($iLvdc < strtotime("-7 days")) { $aRemoteApps = RemoteAppQuery::create()->filterByWebsiteHash(null, \Criteria::ISNOTNULL); $lico = $sLico . "/api/lvdc/" . base64_encode($this->_getSiteURL()) . "/" . $aRemoteApps->count(); try { $res = @file_get_contents($lico); if ($res === false) { throw new \Exception($this->get("translator")->trans("license.update.failed_lico")); } $oResult = json_decode($res); if ($oResult->valid !== true) { $aResponse = array("error" => true, "message" => $oResult->message); } else { SystemSettings::set("lvdc", time()); } } catch (\Exception $e) { $aResponse = array("error" => true, "message" => $e->getMessage()); } } try { if (!isset($aResponse)) { $command = new ApiCommand(); $command->setContainer($this->container); $input = new ArgvInput(array('control:remote:cron', '--app=' . $id, '--force')); $output = new NullOutput(); // Run the command $retval = $command->run($input, $output); $oRemoteApp = RemoteAppQuery::create()->findOneById($id); $sJsonData = $this->renderView('SlashworksAppBundle:RemoteApp:data.json.twig', array('entities' => array($oRemoteApp))); $aData = json_decode($sJsonData, true); if (!$retval) { $aResponse = $aData; } else { $aResponse = array("error" => true); } } } catch (\Exception $e) { $aResponse = array("error" => true, "message" => $e->getMessage()); } $response = new Response(json_encode($aResponse)); $response->headers->set('Content-Type', 'application/json'); return $response; }