original_string: public function relation($field)
      {
          $associations = $this->associations();
          if (empty($associations['manyToOne'])) {
              return false;
          }
  
          $data = $this->getContext();
          if (empty($data)) {
              return false;
          }
  
          foreach ($associations['manyToOne'] as $alias => $details) {
              if ($field !== $details['foreignKey']) {
                  continue;
              }
  
              $entityName = $details['entity'];
              if (empty($data->$entityName)) {
                  return false;
              }
  
              $entity = $data->$entityName;
  
              return [
                  'alias' => $alias,
                  'output' => $this->Html->link($entity->{$details['displayField']}, [
                      'plugin' => $details['plugin'],
                      'controller' => $details['controller'],
                      'action' => 'view',
                      $entity->{$details['primaryKey']}
                  ])
              ];
          }
  
          return false;
      }
code: public function relation($field)
      {
          $associations = $this->associations();
          if (empty($associations['manyToOne'])) {
              return false;
          }
  
          $data = $this->getContext();
          if (empty($data)) {
              return false;
          }
  
          foreach ($associations['manyToOne'] as $alias => $details) {
              if ($field !== $details['foreignKey']) {
                  continue;
              }
  
              $entityName = $details['entity'];
              if (empty($data->$entityName)) {
                  return false;
              }
  
              $entity = $data->$entityName;
  
              return [
                  'alias' => $alias,
                  'output' => $this->Html->link($entity->{$details['displayField']}, [
                      'plugin' => $details['plugin'],
                      'controller' => $details['controller'],
                      'action' => 'view',
                      $entity->{$details['primaryKey']}
                  ])
              ];
          }
  
          return false;
      }
code_tokens: public function relation ( $ field ) { $ associations = $ this -> associations ( ) ; if ( empty ( $ associations [ 'manyToOne' ] ) ) { return false ; } $ data = $ this -> getContext ( ) ; if ( empty ( $ data ) ) { return false ; } foreach ( $ associations [ 'manyToOne' ] as $ alias => $ details ) { if ( $ field !== $ details [ 'foreignKey' ] ) { continue ; } $ entityName = $ details [ 'entity' ] ; if ( empty ( $ data -> $ entityName ) ) { return false ; } $ entity = $ data -> $ entityName ; return [ 'alias' => $ alias , 'output' => $ this -> Html -> link ( $ entity -> { $ details [ 'displayField' ] } , [ 'plugin' => $ details [ 'plugin' ] , 'controller' => $ details [ 'controller' ] , 'action' => 'view' , $ entity -> { $ details [ 'primaryKey' ] } ] ) ] ; } return false ; }
docstring: Returns a formatted relation output for a given field
  
  @param string $field Name of field.
  @return mixed Array of data to output, false if no match found
docstring_tokens: Returns a formatted relation output for a given field