original_string: public function setModel($model, $actual_fields = null)
      {
          parent::setModel($model);
  
          if ($this->model instanceof \atk4\data\Model) {
              // Switch to Agile Data implementation
              if (isset($this->default_controller)) {
                  $this->default_controller = str_replace('MVC', 'AD', $this->default_controller);
              } else {
                  $this->default_controller = 'ADView';
              }
          }
  
          // Some models will want default controller to be associated
          if (isset($this->model->default_controller)) {
              $this->controller
                  = $this->model->setController($this->model->default_controller);
          }
  
          // Use our default controller if present
          if ($this->default_controller) {
              $this->controller = $this->setController($this->default_controller);
          }
  
          if ($this->controller) {
              if ($this->controller->hasMethod('setActualFields')) {
                  $this->controller->setActualFields($actual_fields);
              }
              if ($this->controller->hasMethod('_bindView')) {
                  $this->controller->_bindView();
              }
          }
  
          if ($this->model instanceof SQL_Model) {
              $this->dq = $this->model->_dsql();    // compatibility
          }
  
          $this->hook('set-model', [$this->model, $actual_fields]);
  
          return $this->model;
      }
code: public function setModel($model, $actual_fields = null)
      {
          parent::setModel($model);
  
          if ($this->model instanceof \atk4\data\Model) {
              // Switch to Agile Data implementation
              if (isset($this->default_controller)) {
                  $this->default_controller = str_replace('MVC', 'AD', $this->default_controller);
              } else {
                  $this->default_controller = 'ADView';
              }
          }
  
          // Some models will want default controller to be associated
          if (isset($this->model->default_controller)) {
              $this->controller
                  = $this->model->setController($this->model->default_controller);
          }
  
          // Use our default controller if present
          if ($this->default_controller) {
              $this->controller = $this->setController($this->default_controller);
          }
  
          if ($this->controller) {
              if ($this->controller->hasMethod('setActualFields')) {
                  $this->controller->setActualFields($actual_fields);
              }
              if ($this->controller->hasMethod('_bindView')) {
                  $this->controller->_bindView();
              }
          }
  
          if ($this->model instanceof SQL_Model) {
              $this->dq = $this->model->_dsql();    // compatibility
          }
  
          $this->hook('set-model', [$this->model, $actual_fields]);
  
          return $this->model;
      }
code_tokens: public function setModel ( $ model , $ actual_fields = null ) { parent :: setModel ( $ model ) ; if ( $ this -> model instanceof \ atk4 \ data \ Model ) { // Switch to Agile Data implementation if ( isset ( $ this -> default_controller ) ) { $ this -> default_controller = str_replace ( 'MVC' , 'AD' , $ this -> default_controller ) ; } else { $ this -> default_controller = 'ADView' ; } } // Some models will want default controller to be associated if ( isset ( $ this -> model -> default_controller ) ) { $ this -> controller = $ this -> model -> setController ( $ this -> model -> default_controller ) ; } // Use our default controller if present if ( $ this -> default_controller ) { $ this -> controller = $ this -> setController ( $ this -> default_controller ) ; } if ( $ this -> controller ) { if ( $ this -> controller -> hasMethod ( 'setActualFields' ) ) { $ this -> controller -> setActualFields ( $ actual_fields ) ; } if ( $ this -> controller -> hasMethod ( '_bindView' ) ) { $ this -> controller -> _bindView ( ) ; } } if ( $ this -> model instanceof SQL_Model ) { $ this -> dq = $ this -> model -> _dsql ( ) ; // compatibility } $ this -> hook ( 'set-model' , [ $ this -> model , $ actual_fields ] ) ; return $ this -> model ; }
docstring: Associate view with a model. Additionally may initialize a controller
  which would copy fields from the model into the View.
  
  @param object|string $model Class without "Model_" prefix or object
  @param array|string|null $actual_fields List of fields in order to populate
  
  @return AbstractModel object
docstring_tokens: Associate view with a model . Additionally may initialize a controller which would copy fields from the model into the View .