Esempio n. 1
0
 /**
  * Deletes location from the tree
  *
  *
  */
 public static function delete($primary, $behaviour = array('REBALANCE' => true, 'DELETE_SUBTREE' => true, 'RESET_LEGACY' => true))
 {
     $primary = Assert::expectIntegerPositive($primary, '$primary');
     if (!is_array($behaviour)) {
         $behaviour = array();
     }
     if (!isset($behaviour['REBALANCE'])) {
         $behaviour['REBALANCE'] = true;
     }
     if (!isset($behaviour['RESET_LEGACY'])) {
         $behaviour['RESET_LEGACY'] = true;
     }
     if (!isset($behaviour['DELETE_SUBTREE'])) {
         $behaviour['DELETE_SUBTREE'] = true;
     }
     // delete connected data of sub-nodes
     if ($behaviour['DELETE_SUBTREE']) {
         $rangeSql = parent::getSubtreeRangeSqlForNode($primary);
         Name\LocationTable::deleteMultipleByParentRangeSql($rangeSql);
         ExternalTable::deleteMultipleByParentRangeSql($rangeSql);
     }
     if ($behaviour['RESET_LEGACY']) {
         $data = static::getList(array('filter' => array('=ID' => $primary), 'select' => array('TYPE_ID')))->fetch();
     }
     $delResult = parent::delete($primary, $behaviour);
     // delete connected data
     if ($delResult->isSuccess()) {
         Name\LocationTable::deleteMultipleForOwner($primary);
         ExternalTable::deleteMultipleForOwner($primary);
         if ($behaviour['RESET_LEGACY'] && intval($data['TYPE_ID'])) {
             $type = TypeTable::getList(array('filter' => array('=ID' => $data['TYPE_ID']), 'select' => array('CODE')))->fetch();
             if (strlen($type['CODE']) && in_array($type['CODE'], array('COUNTRY', 'REGION', 'CITY'))) {
                 static::resetLegacyPath();
             }
         }
         $GLOBALS['CACHE_MANAGER']->ClearByTag('sale-location-data');
         Search\Finder::setIndexInvalid();
     }
     return $delResult;
 }
Esempio n. 2
0
 /**
  * Deletes location from the tree
  *
  *
  */
 public static function delete($primary, $behaviour = array('REBALANCE' => true, 'DELETE_SUBTREE' => true))
 {
     $primary = Assert::expectIntegerPositive($primary, false, Loc::getMessage('SALE_LOCATION_LOCATION_ENTITY_BAD_ARGUMENT_PRIMARY_UNSET_EXCEPTION'));
     // delete connected data of sub-nodes
     if ($behaviour['DELETE_SUBTREE']) {
         $rangeSql = parent::getSubtreeRangeSqlForNode($primary);
         Name\LocationTable::deleteMultipleByParentRangeSql($rangeSql);
         ExternalTable::deleteMultipleByParentRangeSql($rangeSql);
     }
     $delResult = parent::delete($primary, $behaviour);
     // delete connected data
     if ($delResult->isSuccess()) {
         Name\LocationTable::deleteMultipleForOwner($primary);
         ExternalTable::deleteMultipleForOwner($primary);
     }
     $GLOBALS['CACHE_MANAGER']->ClearByTag('sale-location-data');
     return $delResult;
 }