예제 #1
0
 /**
  * Deletes a named attribute from the credential. Returns TRUE if successful,
  * else FALSE. If Edge SDK is not recent enough to support this
  * functionality, FALSE will consistently be returned.
  *
  * @param string $name
  * @return bool
  */
 public function deleteCredentialAttribute($name)
 {
     return \DeveloperAppController::deleteCredentialAttribute($this, $name);
 }
예제 #2
0
 /**
  * Implements DrupalEntityControllerInterface::load().
  *
  * @param array $names
  * @param array $conditions
  * @return array
  */
 public function load($ids = array(), $conditions = array())
 {
     $orgs = self::getOrgs($conditions);
     $disableLogging = isset($conditions['disableLogging']) && $conditions['disableLogging'] === TRUE;
     $list = array();
     foreach ($orgs as $org) {
         $config = devconnect_default_org_config($org);
         if ($disableLogging) {
             $config->logger = new \Psr\Log\NullLogger();
             $config->subscribers = array();
         }
         if (array_key_exists('mail', $conditions)) {
             $identifier = $conditions['mail'];
         } elseif (array_key_exists('developerId', $conditions)) {
             $identifier = $conditions['developerId'];
         } else {
             $identifier = NULL;
         }
         if (isset($identifier) && empty($ids)) {
             $dev_app = new DeveloperApp($config, $identifier);
             if (variable_get('devconnect_paging_enabled', FALSE) && method_exists($dev_app, 'usePaging')) {
                 $dev_app->usePaging();
             }
             if (array_key_exists('name', $conditions)) {
                 try {
                     $dev_app->load($conditions['name']);
                     $list += array($dev_app);
                 } catch (ResponseException $e) {
                     self::$lastException = $e;
                 }
             } else {
                 try {
                     $list += $dev_app->getListDetail();
                 } catch (ResponseException $e) {
                     self::$lastException = $e;
                 }
             }
         } elseif (empty($ids)) {
             // Fetch all apps in the org.
             $dev_app = new DeveloperApp($config, '');
             if (variable_get('devconnect_paging_enabled', FALSE) && method_exists($dev_app, 'usePaging')) {
                 $dev_app->usePaging();
             }
             try {
                 $list += $dev_app->listAllApps();
                 $this->addListToCache($list, $ids);
             } catch (ResponseException $e) {
                 self::$lastException = $e;
             }
         } else {
             $sub_list = array();
             // We have a list of appIds. Fetch them now.
             foreach ($ids as $id) {
                 if (isset($this->appCache[$id])) {
                     $sub_list[$id] = $this->appCache[$id];
                 }
             }
             if (count($list) < count($ids)) {
                 $remaining_ids = array_diff($ids, array_keys($list));
                 $dev_app = new DeveloperApp($config, '');
                 foreach ($remaining_ids as $id) {
                     $app = clone $dev_app;
                     try {
                         $app->loadByAppId($id, TRUE);
                         $sub_list[] = $app;
                     } catch (ResponseException $e) {
                         self::$lastException = $e;
                     } catch (ParameterException $e) {
                         self::$lastException = $e;
                     }
                 }
             }
             $list += array_values($sub_list);
         }
     }
     $this->addListToCache($list, $ids);
     $uids = array();
     foreach ($list as $dev_app) {
         if ($dev_app instanceof Apigee\ManagementAPI\DeveloperApp) {
             $email = $dev_app->getDeveloperMail();
             if (!array_key_exists($email, $uids)) {
                 $uids[strtolower($email)] = NULL;
             }
         }
     }
     if (!empty($uids)) {
         $stmt = db_select('users', 'u');
         $stmt->addExpression('LOWER(mail)', 'mail');
         $uids = $stmt->fields('u', array('uid'))->condition('mail', array_keys($uids))->execute()->fetchAllKeyed();
     }
     $uids = array_flip($uids);
     $app_entities = array();
     $include_debug_data = count($list) == 1;
     foreach ($list as $dev_app) {
         if ($dev_app instanceof Apigee\ManagementAPI\DeveloperApp) {
             $id = $dev_app->getAppId();
             $mail = strtolower($dev_app->getDeveloperMail());
             $array = $dev_app->toArray($include_debug_data);
             $array['orgName'] = $dev_app->getConfig()->orgName;
             $array['uid'] = array_key_exists($mail, $uids) ? $uids[$mail] : NULL;
             $app_entity = new DeveloperAppEntity($array);
             $app_entity->checkStatusChange();
             $app_entities[$id] = $app_entity;
         }
     }
     return $app_entities;
 }