public function cmdDeleteCountry()
    {
        $code = $this->getParam(0);
        $all = $this->getParam('all');

        if (empty($code) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $result = null;

        if (!empty($code)) {
            $result = $this->country->delete($code);
        } else if (!empty($all)) {

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

            $result = $count && $count == $deleted;
        }

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

        $this->output();
    }
public function cmdDeleteCountry()
    {
        $code = $this->getParam(0);
        $all = $this->getParam('all');

        if (empty($code) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $result = null;

        if (!empty($code)) {
            $result = $this->country->delete($code);
        } else if (!empty($all)) {

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

            $result = $count && $count == $deleted;
        }

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

        $this->output();
    }
public function cmdDeleteCountry ( ) { $ code = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( empty ( $ code ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = null ; if ( ! empty ( $ code ) ) { $ result = $ this -> country -> delete ( $ code ) ; } else if ( ! empty ( $ all ) ) { $ deleted = $ count = 0 ; foreach ( $ this -> country -> getList ( ) as $ item ) { $ count ++ ; $ deleted += ( int ) $ this -> country -> delete ( $ item [ 'code' ] ) ; } $ result = $ count && $ count == $ deleted ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
Callback for "country-delete" command
Callback for country - delete command