Quiz
4.2 Extbase Controllers and Actions
Perguntas do quiz (19)
1Which statements about Extbase controllers are correct? (2)
- AExtbase controllers are always interfaces
- BEvery controller must directly extend the basis controller
TYPO3\CMS\Extbase\Mvc\Controller\ActionController - CThe visibility of all properties should be protected
- DAll method names in a controller must end in Action()
- EThe logic implemented in controllers should be kept to a minimum
2What are the characteristics of the methods redirect() and forward() in a controller? (2)
- AThe redirect() method requires the controller name of the target as an argument
- BThe redirect() method initiates a new HTTP request
- CThe forward() method transfers the request to the target action automatically
- DThe forward() method changes the URL in the way that the action name appears
- EThe redirect() and forward() methods both clear the cache
3What are the differences between the controller methods forward() and redirect()? (2)
- AThere are no differences
- BMethod $this->forward() is set as $this->request->setDispatched(false)
- CMethod $this->redirect() initiates a new HTTP request; method $this->forward() does not
- DMethod $this->forward() does not accept any arguments, $this->redirect() does
- EMethod $this->redirect() renders a template by default; method $this->forward() does not
4How can you generate a HTTP status code 400? (2)
- Adie(400, null, 'Bad Request.')
- B$this->addError(400, null, 'Bad Request.')
- Cnew \TYPO3\CMS\Extbase\Error\Error(400, null, 'Bad Request.')
- D$this->throwStatus(400, null, 'Bad Request.')
- EInstantiate a response object and set the status code as \GuzzleHttp\Psr7\Response(400)
5What are the characteristics of controllers? (2)
- AControllers are the control and central processing unit in the MVC stack
- BControllers are responsible for initialising domain models
- CThe logic implemented in controllers should be kept to a minimum
- DAll business logic should be implemented in controllers
- EControllers validate all objects
6Which statements about “actions” in Extbase’s controller/action concept are correct? (3)
- AAction methods are always static functions
- BActions are public methods of a controller class
- CNames of action methods always end in Action, for example listAction()
- DEach action must be stored in a separate PHP file under Classes/Actions/
- ETo be able to request an action of a plugin, the action has to be registered by using
configurePlugin() - FAction methods must always return a string (this is the content shown in the frontend)
7How can a fallback to the default action be achieved, in order to prevent an error if a non-configured action is
called? (1)- AThis is the default behaviour of Extbase
- BAn appropriate configuration in file ext_localconf.php is required
- CThe TypoScript setting callDefaultActionIfActionCantBeResolved can be configured
- DAn errorAction() method can be implemented in the controller
- EThe key routing can be used in TypoScript
8How can a “Page Not Found” error message be displayed – HTTP code 404 – if a non-configured action is called? (1)
- AThis is the default behaviour of Extbase
- BAn appropriate configuration in the ext_localconf.php file is required
- CThe TypoScript setting exceptionHandler can be configured
- DAn errorAction() method can be implemented in the controller
- EThe TypoScript setting throwPageNotFoundExceptionIfActionCantBeResolved can be configured
9Which approach is officially recommended to get an object in a controller? (1)
- Ause \Vendor\MyExtension\Domain\Repository\TagRepository;
...
$this->objectManager->get(TagRepository::class) - Buse \Vendor\MyExtension\Domain\Repository\TagRepository;
...
$this->objectManager->create(TagRepository::class) - Cnew \Vendor\MyExtension\Domain\Repository\TagRepository
- Duse \Vendor\MyExtension\Domain\Repository\TagRepository;
...
$this->instanceManager->make(TagRepository::class) - Euse \TYPO3\CMS\Core\Utility\GeneralUtility;
use \Vendor\MyExtension\Domain\Repository\TagRepository;
...
GeneralUtility::makeInstance(TagRepository::class);
- Ause \Vendor\MyExtension\Domain\Repository\TagRepository;
10Where is the Object Manager available as $this->objectManager by default? (2)
- AIn repositories
- BIn ViewHelpers
- CIn Fluid templates
- DIn controllers
- EIn domain models
11Which statements about the view in a controller are correct? (2)
- AYou can access the output of a view by using the method render()
- BThe view can only be rendered at the end of an action method
- CThe view is available in the action as $this->view
- DTo prevent rendering the view, the action must return false
- EIt is not possible to render a different view than the default one
12How do you prevent an action from being executed? (2)
- AThe action can be omitted from the TypoScript key switchableControllerActions
- BThe action can be omitted from the first array of the plugin configuration in file ext_localconf.php
- CThe action can be omitted from the second array of the plugin configuration in file ext_localconf.php
- DBy setting the attribute deactivate in file tables.php
- EBy configuring the action in the page TS key deniedActions
13How can an invalid domain object $blog be accessed in an action new? (2)
- AThis is always possible
- BVia the initializeNewAction() method
- CVia the errorNewAction() method
- DVia the newAction() method if the annotation @ignorevalidation $blog is set
- EVia the __destruct() method
14What is the purpose of the method errorAction() in a controller? (1)
- AThis method is executed if an error in the controller occurs
- BThis method is executed if an error in the view occurs
- CThis method is executed before the primary action
- DThis method is always executed after the primary action
- EThis method is executed if a validation error in the controller occurs
15How can validation errors of an object $blog be accessed in a controller? (1)
- AThis is not possible
- BBy $blog->getErrors()
- CBy $this->getErrors()
- DBy $this->controllerContext->getRequest()->getErrors()
- EBy $this->errors
16How can a non-persisting object be created from a GET request? (1)
- AThis happens automatically if the object is passed to the method as a parameter in the action
- BBy using the “Object Type Converter”
- CBy manually executing convertArrayToObject() in the Property Mapper
- DBy setting the property mapping in TypoScript
17What is the purpose of the following method in a controller? (2)
use \TYPO3\CMS\Core\Utility\ArrayUtility;
...
public function initializeAction()
{
$settings = [
...
];
ArrayUtility::mergeRecursiveWithOverrule(
$this->settings,
$settings
);
}- AFlexForm settings are merged with TypoScript settings
- BCustom settings are merged with TypoScript settings
- CAll empty values in the arrays, both $settings and $this->settings, are removed
- DKeys with a value __UNSET in the array $settings unset array keys with the same name in the array $this->settings
18How do you retrieve the data of the current content object in Extbase? (1)
- ABy accessing getContentObject()->data of the ConfigurationManager
- BBy accessing $this->request->getContentObjectData()
- CBy accessing $this->cObj->data
- DBy accessing $this->cObj->cObjGetSingle()
19In which file are custom Type Converters registered? (1)
- AFile ext_tables.php
- BFile ext_localconf.php
- CThe controller
- DFile Configuration/TCA/table.php
- EFile Configuration/TypoScript/setup.typoscript
Informações
- Descrição
- O usuário eliminou as informações de disciplina Quiz sobre 4.2 Extbase Controllers and Actions, criado por Usuário eliminado em 27-04-2022.
- Autor
- Usuário eliminado
- Idioma
- English
- Visualizações
- 20
- Histórico
- Criado em 27 abr 2022 · atualizado em 27 abr 2022
- Etiquetas
- Avaliação
- Ainda sem avaliações Avalie este quiz