GravityView  2.10.1
The best, easiest way to display Gravity Forms entries on your website.
class-gv-renderer-field.php
Go to the documentation of this file.
1 <?php
2 namespace GV;
3 
4 /** If this file is called directly, abort. */
5 if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
6  die();
7 }
8 
9 /**
10  * The \GV\Field_Renderer class.
11  *
12  * Houses some preliminary \GV\Field rendering functionality.
13  */
14 class Field_Renderer extends Renderer {
15 
16  /**
17  * Renders a \GV\Field instance.
18  *
19  * @param \GV\Field $request The field.
20  * @param \GV\View $view The view for this context if applicable.
21  * @param \GV\Source $source The source (form) for this context if applicable.
22  * @param \GV\Entry $entry The entry for this context if applicable.
23  * @param \GV\Request $request The request for this context if applicable.
24  * @param string $class The field template class. Default: \GV\Field_HTML_Template'.
25  *
26  * @api
27  * @since 2.0
28  * @since 2.1 Added Field Template class $class parameter
29  *
30  * @return string The rendered Field
31  */
32  public function render( Field $field, View $view = null, Source $source = null, Entry $entry = null, Request $request = null, $class = '\GV\Field_HTML_Template' ) {
33  if ( is_null( $request ) ) {
34  $request = &gravityview()->request;
35  }
36 
37  if ( ! $request->is_renderable() ) {
38  gravityview()->log->error( 'Renderer unable to render View in {request_class} context', array( 'request_class' => get_class( $request ) ) );
39  return null;
40  }
41 
42  /**
43  * @filter `gravityview/template/field/class` Filter the template class that is about to be used to render the view.
44  * @since 2.0
45  * @param string $class The chosen class - Default: \GV\Field_HTML_Template.
46  * @param \GV\Field $field The field about to be rendered.
47  * @param \GV\View $view The view in this context, if applicable.
48  * @param \GV\Source $source The source (form) in this context, if applicable.
49  * @param \GV\Entry $entry The entry in this context, if applicable.
50  * @param \GV\Request $request The request in this context, if applicable.
51  */
52  $class = apply_filters( 'gravityview/template/field/class', $class, $field, $view, $source, $entry, $request );
53  if ( ! $class || ! class_exists( $class ) ) {
54  gravityview()->log->error( '{template_class} not found', array( 'template_class' => $class ) );
55  return null;
56  }
57 
58  /** @var \GV\Field_Template $class */
59  $renderer = new $class( $field, $view, $source, $entry, $request );
60  ob_start();
61  $renderer->render();
62  return ob_get_clean();
63  }
64 }
If this file is called directly, abort.
If this file is called directly, abort.
$class
If this file is called directly, abort.
gravityview()
Definition: _stubs.php:26
If this file is called directly, abort.
If this file is called directly, abort.
If this file is called directly, abort.
If this file is called directly, abort.
$entry
Definition: notes.php:27
$field
Definition: gquiz_grade.php:11