X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fviews%2Ftests%2Fmodules%2Fviews_test_data%2Fsrc%2FPlugin%2Fviews%2Fstyle%2FStyleTest.php;fp=web%2Fcore%2Fmodules%2Fviews%2Ftests%2Fmodules%2Fviews_test_data%2Fsrc%2FPlugin%2Fviews%2Fstyle%2FStyleTest.php;h=9c0c3d707bdee5500fb521caf470dc63a26aa919;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php b/web/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php new file mode 100644 index 000000000..9c0c3d707 --- /dev/null +++ b/web/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php @@ -0,0 +1,118 @@ + '']; + + return $options; + } + + /** + * {@inheritdoc} + */ + public function buildOptionsForm(&$form, FormStateInterface $form_state) { + parent::buildOptionsForm($form, $form_state); + + $form['test_option'] = [ + '#title' => $this->t('Test option'), + '#type' => 'textfield', + '#description' => $this->t('This is a textfield for test_option.'), + '#default_value' => $this->options['test_option'], + ]; + } + + /** + * Sets the usesRowPlugin property. + * + * @param bool $status + * TRUE if this style plugin should use rows. + */ + public function setUsesRowPlugin($status) { + $this->usesRowPlugin = $status; + } + + /** + * Sets the output property. + * + * @param string $output + * The string to output by this plugin. + */ + public function setOutput($output) { + $this->output = $output; + } + + /** + * Returns the output property. + * + * @return string + */ + public function getOutput() { + return $this->output; + } + + /** + * {@inheritdoc} + */ + public function render() { + $output = ''; + if (!$this->usesRowPlugin()) { + $output = $this->getOutput(); + } + else { + foreach ($this->view->result as $index => $row) { + $this->view->row_index = $index; + $output .= $this->view->rowPlugin->render($row) . "\n"; + } + } + + return $output; + } + + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + return [ + 'content' => ['StyleTest'], + ]; + } + +}