original_string: public function hasOne($model, $our_field = null, $display_field = null, $as_field = null)
      {
  
          // register reference, but don't create any fields there
          // parent::hasOne($model,null);
          // model, our_field
          $this->_references[null] = $model;
  
          if (!$our_field) {
              if (!is_object($model)) {
                  $tmp = $this->app->normalizeClassName($model, 'Model');
                  $tmp = new $tmp(); // avoid recursion
              } else {
                  $tmp = $model;
              }
              $our_field = ($tmp->table).'_id';
          }
  
          /** @type Field_Reference $r */
          $r = $this->add('Field_Reference', array('name' => $our_field, 'dereferenced_field' => $as_field));
          $r->setModel($model, $display_field);
          $r->system(true)->editable(true);
  
          return $r;
      }
code: public function hasOne($model, $our_field = null, $display_field = null, $as_field = null)
      {
  
          // register reference, but don't create any fields there
          // parent::hasOne($model,null);
          // model, our_field
          $this->_references[null] = $model;
  
          if (!$our_field) {
              if (!is_object($model)) {
                  $tmp = $this->app->normalizeClassName($model, 'Model');
                  $tmp = new $tmp(); // avoid recursion
              } else {
                  $tmp = $model;
              }
              $our_field = ($tmp->table).'_id';
          }
  
          /** @type Field_Reference $r */
          $r = $this->add('Field_Reference', array('name' => $our_field, 'dereferenced_field' => $as_field));
          $r->setModel($model, $display_field);
          $r->system(true)->editable(true);
  
          return $r;
      }
code_tokens: public function hasOne ( $ model , $ our_field = null , $ display_field = null , $ as_field = null ) { // register reference, but don't create any fields there // parent::hasOne($model,null); // model, our_field $ this -> _references [ null ] = $ model ; if ( ! $ our_field ) { if ( ! is_object ( $ model ) ) { $ tmp = $ this -> app -> normalizeClassName ( $ model , 'Model' ) ; $ tmp = new $ tmp ( ) ; // avoid recursion } else { $ tmp = $ model ; } $ our_field = ( $ tmp -> table ) . '_id' ; } /** @type Field_Reference $r */ $ r = $ this -> add ( 'Field_Reference' , array ( 'name' => $ our_field , 'dereferenced_field' => $ as_field ) ) ; $ r -> setModel ( $ model , $ display_field ) ; $ r -> system ( true ) -> editable ( true ) ; return $ r ; }
docstring: Defines one to many association
docstring_tokens: Defines one to many association