コード例 #1
0
ファイル: ElementTest.php プロジェクト: luisbrito/Phraseanet
 public function setUp()
 {
     parent::setUp();
     $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"';
     $stmt = self::$DI['app']->getApplicationBox()->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $this->api = Bridge_Api::create(self::$DI['app'], 'Apitest');
     $this->dist_id = 'EZ1565loPP';
     $this->named = 'Fête à pinpins';
     $this->account = Bridge_Account::create(self::$DI['app'], $this->api, self::$DI['user'], $this->dist_id, $this->named);
     $this->title = 'GOGACKO';
     $this->status = 'Processing';
     $element = Bridge_Element::create(self::$DI['app'], $this->account, self::$DI['record_1'], $this->title, $this->status, $this->account->get_api()->get_connector()->get_default_element_type());
     $this->id = $element->get_id();
     $this->object = new Bridge_Element(self::$DI['app'], $this->account, $this->id);
 }
コード例 #2
0
ファイル: Bridge.php プロジェクト: nlegoff/Phraseanet
 public function doPostUpload(Application $app, Request $request)
 {
     $errors = [];
     $account = \Bridge_Account::load_account($app, $request->request->get('account_id'));
     $this->requireConnection($app, $account);
     $route = new RecordHelper\Bridge($app, $request);
     $route->grep_records($account->get_api()->acceptable_records());
     $connector = $account->get_api()->get_connector();
     // check constraints
     foreach ($route->get_elements() as $record) {
         $datas = $connector->get_upload_datas($request, $record);
         $errors = array_merge($errors, $connector->check_upload_constraints($datas, $record));
     }
     if (count($errors) > 0) {
         $params = ['route' => $route, 'account' => $account, 'error_message' => $app->trans('Request contains invalid datas'), 'constraint_errors' => $errors, 'notice_message' => $request->request->get('notice'), 'adapter_action' => 'upload'];
         return $app['twig']->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params);
     }
     foreach ($route->get_elements() as $record) {
         $datas = $connector->get_upload_datas($request, $record);
         $title = isset($datas["title"]) ? $datas["title"] : '';
         $default_type = $connector->get_default_element_type();
         \Bridge_Element::create($app, $account, $record, $title, \Bridge_Element::STATUS_PENDING, $default_type, $datas);
     }
     return $app->redirect('/prod/bridge/adapter/' . $account->get_id() . '/load-records/?notice=' . $app->trans('%quantity% elements en attente', ['%quantity%' => count($route->get_elements())]));
 }