Пример #1
0
 /**
  * Test the account deletion with the required SSO token.
  */
 public function testDeletingAccountWithToken()
 {
     $account = new NostoAccount('platform-test');
     $token = new NostoApiToken('sso', '123');
     $account->addApiToken($token);
     $this->specify('account is deleted', function () use($account) {
         $account->delete();
     });
 }
Пример #2
0
 /**
  * Deletes a Nosto account from the PS config.
  * Also sends a notification to Nosto that the account has been deleted.
  *
  * @param NostoAccount $account the account to delete.
  * @param int $id_lang the ID of the language model to delete the account for.
  * @param null|int $id_shop_group the ID of the shop context.
  * @param null|int $id_shop the ID of the shop.
  * @return bool true if successful, false otherwise.
  */
 public function delete(NostoAccount $account, $id_lang, $id_shop_group = null, $id_shop = null)
 {
     /** @var NostoTaggingHelperConfig $helper_config */
     $helper_config = Nosto::helper('nosto_tagging/config');
     $success = $helper_config->deleteAllFromContext($id_lang, $id_shop_group, $id_shop);
     if ($success) {
         $token = $account->getApiToken('sso');
         if ($token) {
             try {
                 $account->delete();
             } catch (NostoException $e) {
                 Nosto::helper('nosto_tagging/logger')->error(__CLASS__ . '::' . __FUNCTION__ . ' - ' . $e->getMessage(), $e->getCode());
             }
         }
     }
     return $success;
 }
Пример #3
0
 /**
  * Removes an account with associated api tokens for the store view scope.
  *
  * @param NostoAccount               $account the account to remove.
  * @param Mage_Core_Model_Store|null $store   the store view to remove it for.
  *
  * @return bool true on success, false otherwise.
  */
 public function remove(NostoAccount $account, Mage_Core_Model_Store $store = null)
 {
     if ($store === null) {
         $store = Mage::app()->getStore();
     }
     if ((int) $store->getId() < 1) {
         return false;
     }
     /** @var Mage_Core_Model_Config $config */
     $config = Mage::getModel('core/config');
     $config->saveConfig(self::XML_PATH_ACCOUNT, null, 'stores', $store->getId());
     $config->saveConfig(self::XML_PATH_TOKENS, null, 'stores', $store->getId());
     Mage::app()->getCacheInstance()->cleanType('config');
     try {
         // Notify Nosto that the account was deleted.
         $account->delete();
     } catch (NostoException $e) {
         // Failures are logged but not shown to the user.
         Mage::log("\n" . $e->__toString(), Zend_Log::ERR, 'nostotagging.log');
     }
     return true;
 }