public function index(Request $request, Response $response) { $helper = $this->helper; if ($helper->hasAccessToken()) { $client = new \GuzzleHttp\Client(); $fileResponse = $client->get('https://www.googleapis.com/drive/v2/files', ['headers' => $helper->getAuthorizedHeaders()]); $files = new Files($fileResponse->getBody()); return $this->view->render($response, 'files.twig', ['files' => $files->formatData(), 'area' => self::AREA]); } else { return $response->withStatus(301)->withHeader('Location', '/' . self::AREA . '/auth'); } }
public static function fillModelByFormFromRequest($model, $form, $module = 'default') { $request = \Phalcon\DI::getDefault()->get('request'); foreach ($form->getElements() as $property => $element) { $method = sprintf('set%s', ucfirst($property)); if (method_exists($model, $method)) { if ($element instanceof \Phalcon\Forms\Element\File) { if ($_picture = static::getFileByName($property)) { call_user_func(array($model, $method), \Models\Files::upload($_picture, $module, false)); } } else { if ($request->getPost($property)) { call_user_func(array($model, $method), $request->getPost($property)); } } } } return $model; }