original_string: public function cmdDeleteRole()
      {
          $id = $this->getParam(0);
          $all = $this->getParam('all');
  
          if (!isset($id) && empty($all)) {
              $this->errorAndExit($this->text('Invalid command'));
          }
  
          $result = false;
  
          if (isset($id)) {
  
              if (empty($id) || !is_numeric($id)) {
                  $this->errorAndExit($this->text('Invalid argument'));
              }
  
              $result = $this->role->delete($id);
  
          } else if ($all) {
  
              $deleted = $count = 0;
              foreach ($this->role->getList() as $item) {
                  $count++;
                  $deleted += (int) $this->role->delete($item['role_id']);
              }
  
              $result = $count && $count == $deleted;
          }
  
          if (empty($result)) {
              $this->errorAndExit($this->text('Unexpected result'));
          }
  
          $this->output();
      }
code: public function cmdDeleteRole()
      {
          $id = $this->getParam(0);
          $all = $this->getParam('all');
  
          if (!isset($id) && empty($all)) {
              $this->errorAndExit($this->text('Invalid command'));
          }
  
          $result = false;
  
          if (isset($id)) {
  
              if (empty($id) || !is_numeric($id)) {
                  $this->errorAndExit($this->text('Invalid argument'));
              }
  
              $result = $this->role->delete($id);
  
          } else if ($all) {
  
              $deleted = $count = 0;
              foreach ($this->role->getList() as $item) {
                  $count++;
                  $deleted += (int) $this->role->delete($item['role_id']);
              }
  
              $result = $count && $count == $deleted;
          }
  
          if (empty($result)) {
              $this->errorAndExit($this->text('Unexpected result'));
          }
  
          $this->output();
      }
code_tokens: public function cmdDeleteRole ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = false ; if ( isset ( $ id ) ) { if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ result = $ this -> role -> delete ( $ id ) ; } else if ( $ all ) { $ deleted = $ count = 0 ; foreach ( $ this -> role -> getList ( ) as $ item ) { $ count ++ ; $ deleted += ( int ) $ this -> role -> delete ( $ item [ 'role_id' ] ) ; } $ result = $ count && $ count == $ deleted ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
docstring: Callback for "role-delete" command
docstring_tokens: Callback for role - delete command