original_string: public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
      {
          $query->formatResults(function ($results) {
              return $results->map(function ($revision) {
                  try {
                      if (isset($revision->data->content_type_id)) {
                          $contentType = TableRegistry::get('Content.ContentTypes')
                              ->find()
                              ->where(['id' => $revision->data->content_type_id])
                              ->first();
                          $revision->data->set('content_type', $contentType);
                      }
                  } catch (\Exception $e) {
                      $revision->data->set('content_type', false);
                  }
  
                  return $revision;
              });
          });
  
          return $query;
      }
code: public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
      {
          $query->formatResults(function ($results) {
              return $results->map(function ($revision) {
                  try {
                      if (isset($revision->data->content_type_id)) {
                          $contentType = TableRegistry::get('Content.ContentTypes')
                              ->find()
                              ->where(['id' => $revision->data->content_type_id])
                              ->first();
                          $revision->data->set('content_type', $contentType);
                      }
                  } catch (\Exception $e) {
                      $revision->data->set('content_type', false);
                  }
  
                  return $revision;
              });
          });
  
          return $query;
      }
code_tokens: public function beforeFind ( Event $ event , Query $ query , ArrayObject $ options , $ primary ) { $ query -> formatResults ( function ( $ results ) { return $ results -> map ( function ( $ revision ) { try { if ( isset ( $ revision -> data -> content_type_id ) ) { $ contentType = TableRegistry :: get ( 'Content.ContentTypes' ) -> find ( ) -> where ( [ 'id' => $ revision -> data -> content_type_id ] ) -> first ( ) ; $ revision -> data -> set ( 'content_type' , $ contentType ) ; } } catch ( \ Exception $ e ) { $ revision -> data -> set ( 'content_type' , false ) ; } return $ revision ; } ) ; } ) ; return $ query ; }
docstring: Attaches ContentType information to each content revision.
  
  @param \Cake\Event\Event $event The event that was triggered
  @param \Cake\ORM\Query $query The query object
  @param \ArrayObject $options Additional options given as an array
  @param bool $primary Whether this find is a primary query or not
  @return Query
docstring_tokens: Attaches ContentType information to each content revision .