示例#1
0
 public function testLoadContainers()
 {
     self::$account->get_settings()->set("auth_token", "somethingNotNull");
     //connected
     $url = sprintf("/prod/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
     $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]);
     $elements = \Bridge_Element::get_elements_by_account(self::$DI['app'], self::$account);
     $this->assertTrue(self::$DI['client']->getResponse()->isOk());
     $this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent());
 }
示例#2
0
 public function testGet_elements_by_account()
 {
     $elements = Bridge_Element::get_elements_by_account(self::$DI['app'], $this->account);
     $this->assertTrue(is_array($elements));
     $this->assertGreaterThan(0, count($elements));
     foreach ($elements as $element) {
         $this->assertInstanceOf('Bridge_Element', $element);
     }
 }
示例#3
0
 public function doGetloadRecords(Application $app, Request $request, $account_id)
 {
     $page = max((int) $request->query->get('page'), 0);
     $quantity = 10;
     $offset_start = max(($page - 1) * $quantity, 0);
     $account = \Bridge_Account::load_account($app, $account_id);
     $elements = \Bridge_Element::get_elements_by_account($app, $account, $offset_start, $quantity);
     $this->requireConnection($app, $account);
     $params = ['adapter_action' => 'load-records', 'account' => $account, 'elements' => $elements, 'error_message' => $request->query->get('error'), 'notice_message' => $request->query->get('notice')];
     return $app['twig']->render('prod/actions/Bridge/records_list.html.twig', $params);
 }
示例#4
0
 /**
  *
  * @return Void
  */
 public function delete()
 {
     do {
         $elements = Bridge_Element::get_elements_by_account($this->app, $this);
         foreach ($elements as $element) {
             $element->delete();
         }
     } while (count($elements) > 0);
     $sql = 'DELETE FROM bridge_accounts WHERE id = :id';
     $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
     $stmt->execute([':id' => $this->id]);
     $stmt->closeCursor();
     return;
 }