5.3 Alternative Views

Description

TYPO3 CD 2020 (zweite Auflage) Quiz on 5.3 Alternative Views, created by Pascal Bartl on 09/04/2021.
Pascal Bartl
Quiz by Pascal Bartl, updated more than 1 year ago
Pascal Bartl
Created by Pascal Bartl about 3 years ago
0
0

Resource summary

Question 1

Question
How is the JSON view used? (1)
Answer
  • The template filename must end in .json
  • The third parameter of method assign() of the view must be true
  • The initializeAction() in the controller requires the parameter $json = true
  • The property $defaultViewObjectName can be used to create a JSON response by default
  • A directory View must exist inside Classes, which contains a file JsonView.php

Question 2

Question
What is the output of the following code snippet that uses Extbase’s JSON view? (1) use \TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use \TYPO3\CMS\Extbase\Mvc\View\JsonView; class ExampleController extends ActionController { /** * @var \TYPO3\CMS\Extbase\Mvc\View\JsonView */ protected $defaultViewObjectName = JsonView::class; public function showAction() { $data = ['foo' => 'bar']; $this->view->assign('value', $data); } }
Answer
  • The JSON payload: {"value": ["foo": "bar"]}
  • The JSON payload: {"foo": "bar"}
  • The JSON payload: [foo = "bar"]
  • A serialized array: a:1:{s:3:"foo";s:3:"bar";}
  • An empty serialized array: a:0:{}

Question 3

Question
What is the purpose of the function call setVariablesToRender() of the JSON view in Extbase? (1)
Answer
  • This is required to instruct the JSON view to render variable names other than value
  • This is required to instruct the JSON view to render multidimensional arrays
  • This is required to instruct the JSON view to render data types other than arrays
  • This can be used to switch between JSON, HTML, XML, etc. formats on a case-by-case basis
Show full summary Hide full summary

Similar

Characteristics and Climate of a hot desert
Adam Collinge
GCSE Revision: Christianity
Andrea Leyden
Religious Studies- Matters of life and death
Emma Samieh-Tucker
Edexcel Biology chapter 1
Anna Bowring
Of Mice & Men Themes - Key essay points
Lilac Potato
Health and Social Care Flashcards
Kelsey Phillips
GCSE REVISION TIMETABLE
nimraa422
untitled 2
lola_smily
EXAM 1 - ENABLING FEATURES
kristinephil558
General Pathoanatomy Final MCQs (111-200)- 3rd Year- PMU
Med Student
3MA114 Management_test 1/2
Jakub Beyr