public function cmdDeleteCity()
    {
        $id = $this->getParam(0);

        if (empty($id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        $options = null;

        if ($this->getParam('state')) {
            $options = array('state_id' => $id);
        } else if ($this->getParam('country')) {
            $options = array('country' => $id);
        }

        if (isset($options)) {

            $deleted = $count = 0;
            foreach ($this->city->getList($options) as $item) {
                $count++;
                $deleted += (int) $this->city->delete($item['city_id']);
            }

            $result = $count && $count == $deleted;
        } else {
            $result = $this->city->delete($id);
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
public function cmdDeleteCity()
    {
        $id = $this->getParam(0);

        if (empty($id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        $options = null;

        if ($this->getParam('state')) {
            $options = array('state_id' => $id);
        } else if ($this->getParam('country')) {
            $options = array('country' => $id);
        }

        if (isset($options)) {

            $deleted = $count = 0;
            foreach ($this->city->getList($options) as $item) {
                $count++;
                $deleted += (int) $this->city->delete($item['city_id']);
            }

            $result = $count && $count == $deleted;
        } else {
            $result = $this->city->delete($id);
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
public function cmdDeleteCity ( ) { $ id = $ this -> getParam ( 0 ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ options = null ; if ( $ this -> getParam ( 'state' ) ) { $ options = array ( 'state_id' => $ id ) ; } else if ( $ this -> getParam ( 'country' ) ) { $ options = array ( 'country' => $ id ) ; } if ( isset ( $ options ) ) { $ deleted = $ count = 0 ; foreach ( $ this -> city -> getList ( $ options ) as $ item ) { $ count ++ ; $ deleted += ( int ) $ this -> city -> delete ( $ item [ 'city_id' ] ) ; } $ result = $ count && $ count == $ deleted ; } else { $ result = $ this -> city -> delete ( $ id ) ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
Callback for "city-delete" command
Callback for city - delete command