PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/web/core/modules/views/src/Plugin/views/field/FieldHandlerInterface.php

https://gitlab.com/mohamed_hussein/prodt
PHP | 270 lines | 28 code | 26 blank | 216 comment | 0 complexity | f10d4e6dd4e50e645d4556ffdbac1c7a MD5 | raw file
  1. <?php
  2. namespace Drupal\views\Plugin\views\field;
  3. use Drupal\views\ResultRow;
  4. use Drupal\views\Plugin\views\ViewsHandlerInterface;
  5. /**
  6. * Base field handler that has no options and renders an unformatted field.
  7. */
  8. interface FieldHandlerInterface extends ViewsHandlerInterface {
  9. /**
  10. * Adds an ORDER BY clause to the query for click sort columns.
  11. *
  12. * @param string $order
  13. * Either ASC or DESC
  14. */
  15. public function clickSort($order);
  16. /**
  17. * Determines if this field is click sortable.
  18. *
  19. * @return bool
  20. * The value of 'click sortable' from the plugin definition, this defaults
  21. * to TRUE if not set.
  22. */
  23. public function clickSortable();
  24. /**
  25. * Gets this field's label.
  26. */
  27. public function label();
  28. /**
  29. * Returns an HTML element based upon the field's element type.
  30. *
  31. * @param bool $none_supported
  32. * Whether or not this HTML element is supported.
  33. * @param bool $default_empty
  34. * Whether or not this HTML element is empty by default.
  35. * @param bool $inline
  36. * Whether or not this HTML element is inline.
  37. */
  38. public function elementType($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE);
  39. /**
  40. * Returns an HTML element for the label based upon the field's element type.
  41. *
  42. * @param bool $none_supported
  43. * Whether or not this HTML element is supported.
  44. * @param bool $default_empty
  45. * Whether or not this HTML element is empty by default.
  46. */
  47. public function elementLabelType($none_supported = FALSE, $default_empty = FALSE);
  48. /**
  49. * Returns an HTML element for the wrapper based upon the field's element type.
  50. *
  51. * @param bool $none_supported
  52. * Whether or not this HTML element is supported.
  53. * @param bool $default_empty
  54. * Whether or not this HTML element is empty by default.
  55. */
  56. public function elementWrapperType($none_supported = FALSE, $default_empty = FALSE);
  57. /**
  58. * Provides a list of elements valid for field HTML.
  59. *
  60. * This function can be overridden by fields that want more or fewer
  61. * elements available, though this seems like it would be an incredibly
  62. * rare occurrence.
  63. */
  64. public function getElements();
  65. /**
  66. * Returns the class of the field.
  67. *
  68. * @param bool $row_index
  69. * The index of current row.
  70. */
  71. public function elementClasses($row_index = NULL);
  72. /**
  73. * Replaces a value with tokens from the last field.
  74. *
  75. * This function actually figures out which field was last and uses its
  76. * tokens so they will all be available.
  77. *
  78. * @param string $value
  79. * The raw string.
  80. * @param bool $row_index
  81. * The index of current row.
  82. */
  83. public function tokenizeValue($value, $row_index = NULL);
  84. /**
  85. * Returns the class of the field's label.
  86. *
  87. * @param bool $row_index
  88. * The index of current row.
  89. */
  90. public function elementLabelClasses($row_index = NULL);
  91. /**
  92. * Returns the class of the field's wrapper.
  93. *
  94. * @param bool $row_index
  95. * The index of current row.
  96. */
  97. public function elementWrapperClasses($row_index = NULL);
  98. /**
  99. * Gets the entity matching the current row and relationship.
  100. *
  101. * @param \Drupal\views\ResultRow $values
  102. * An object containing all retrieved values.
  103. *
  104. * @return \Drupal\Core\Entity\EntityInterface|null
  105. * Returns the entity matching the values or NULL if there is no matching
  106. * entity.
  107. */
  108. public function getEntity(ResultRow $values);
  109. /**
  110. * Gets the value that's supposed to be rendered.
  111. *
  112. * This api exists so that other modules can easy set the values of the field
  113. * without having the need to change the render method as well.
  114. *
  115. * @param \Drupal\views\ResultRow $values
  116. * An object containing all retrieved values.
  117. * @param string $field
  118. * Optional name of the field where the value is stored.
  119. */
  120. public function getValue(ResultRow $values, $field = NULL);
  121. /**
  122. * Determines if this field will be available as an option to group the result
  123. * by in the style settings.
  124. *
  125. * @return bool
  126. * TRUE if this field handler is groupable, otherwise FALSE.
  127. */
  128. public function useStringGroupBy();
  129. /**
  130. * Runs before any fields are rendered.
  131. *
  132. * This gives the handlers some time to set up before any handler has
  133. * been rendered.
  134. *
  135. * @param \Drupal\views\ResultRow[] $values
  136. * An array of all ResultRow objects returned from the query.
  137. */
  138. public function preRender(&$values);
  139. /**
  140. * Renders the field.
  141. *
  142. * @param \Drupal\views\ResultRow $values
  143. * The values retrieved from a single row of a view's query result.
  144. *
  145. * @return string|\Drupal\Component\Render\MarkupInterface
  146. * The rendered output. If the output is safe it will be wrapped in an
  147. * object that implements MarkupInterface. If it is empty or unsafe it
  148. * will be a string.
  149. */
  150. public function render(ResultRow $values);
  151. /**
  152. * Runs after every field has been rendered.
  153. *
  154. * This is meant to be used mainly to deal with field handlers whose output
  155. * cannot be cached at row level but can be cached at display level. The
  156. * typical example is the row counter. For completely uncacheable field output
  157. * placeholders should be used.
  158. *
  159. * @param \Drupal\views\ResultRow $row
  160. * An array of all ResultRow objects returned from the query.
  161. * @param $output
  162. * The field rendered output.
  163. *
  164. * @return string[]
  165. * An associative array of post-render token values keyed by placeholder.
  166. *
  167. * @see \Drupal\views\Plugin\views\field\UncacheableFieldHandlerTrait
  168. */
  169. public function postRender(ResultRow $row, $output);
  170. /**
  171. * Renders a field using advanced settings.
  172. *
  173. * This renders a field normally, then decides if render-as-link and
  174. * text-replacement rendering is necessary.
  175. *
  176. * @param \Drupal\views\ResultRow $values
  177. * The values retrieved from a single row of a view's query result.
  178. *
  179. * @return string|\Drupal\Component\Render\MarkupInterface
  180. * The advanced rendered output. If the output is safe it will be wrapped in
  181. * an object that implements MarkupInterface. If it is empty or unsafe
  182. * it will be a string.
  183. */
  184. public function advancedRender(ResultRow $values);
  185. /**
  186. * Checks if a field value is empty.
  187. *
  188. * @param $value
  189. * The field value.
  190. * @param bool $empty_zero
  191. * Whether or not this field is configured to consider 0 as empty.
  192. * @param bool $no_skip_empty
  193. * Whether or not to use empty() to check the value.
  194. *
  195. * @return bool
  196. * TRUE if the value is considered empty, FALSE otherwise.
  197. */
  198. public function isValueEmpty($value, $empty_zero, $no_skip_empty = TRUE);
  199. /**
  200. * Performs an advanced text render for the item.
  201. *
  202. * This is separated out as some fields may render lists, and this allows
  203. * each item to be handled individually.
  204. *
  205. * @param array $alter
  206. * The alter array of options to use.
  207. * - max_length: Maximum length of the string, the rest gets truncated.
  208. * - word_boundary: Trim only on a word boundary.
  209. * - ellipsis: Show an ellipsis (…) at the end of the trimmed string.
  210. * - html: Make sure that the html is correct.
  211. *
  212. * @return string|\Drupal\Component\Render\MarkupInterface
  213. * The rendered output. If the output is safe it will be wrapped in an
  214. * object that implements MarkupInterface. If it is empty or unsafe it
  215. * will be a string.
  216. */
  217. public function renderText($alter);
  218. /**
  219. * Gets the 'render' tokens to use for advanced rendering.
  220. *
  221. * This runs through all of the fields and arguments that
  222. * are available and gets their values. This will then be
  223. * used in one giant str_replace().
  224. *
  225. * @param mixed $item
  226. * The item to render.
  227. *
  228. * @return array
  229. * An array of available tokens
  230. */
  231. public function getRenderTokens($item);
  232. /**
  233. * Renders row values using $this->themeFunctions() as #theme.
  234. *
  235. * @param \Drupal\views\ResultRow $values
  236. * Holds single row of a view's result set.
  237. *
  238. * @return string|\Drupal\Component\Render\MarkupInterface
  239. * Returns rendered output of the given theme implementation. If the output
  240. * is safe it will be wrapped in an object that implements
  241. * MarkupInterface. If it is empty or unsafe it will be a string.
  242. */
  243. public function theme(ResultRow $values);
  244. }