Pascal Bartl
Test por , creado hace más de 1 año

TYPO3 CD 2020 (zweite Auflage) Test sobre 4.2 Extbase Controllers and Actions, creado por Pascal Bartl el 09/04/2021.

3
0
0
Pascal Bartl
Creado por Pascal Bartl hace más de 3 años
Cerrar

4.2 Extbase Controllers and Actions

Pregunta 1 de 19

1

Which statements about Extbase controllers are correct? (2)

Selecciona una o más de las siguientes respuestas posibles:

  • Extbase controllers are always interfaces

  • Every controller must directly extend the basis controller
    TYPO3\CMS\Extbase\Mvc\Controller\ActionController

  • The visibility of all properties should be protected

  • All method names in a controller must end in Action()

  • The logic implemented in controllers should be kept to a minimum

Explicación

Pregunta 2 de 19

1

What are the characteristics of the methods redirect() and forward() in a controller? (2)

Selecciona una o más de las siguientes respuestas posibles:

  • The redirect() method requires the controller name of the target as an argument

  • The redirect() method initiates a new HTTP request

  • The forward() method transfers the request to the target action automatically

  • The forward() method changes the URL in the way that the action name appears

  • The redirect() and forward() methods both clear the cache

Explicación

Pregunta 3 de 19

1

What are the differences between the controller methods forward() and redirect()? (2)

Selecciona una o más de las siguientes respuestas posibles:

  • There are no differences

  • Method $this->forward() is set as $this->request->setDispatched(false)

  • Method $this->redirect() initiates a new HTTP request; method $this->forward() does not

  • Method $this->forward() does not accept any arguments, $this->redirect() does

  • Method $this->redirect() renders a template by default; method $this->forward() does not

Explicación

Pregunta 4 de 19

1

How can you generate a HTTP status code 400? (2)

Selecciona una o más de las siguientes respuestas posibles:

  • die(400, null, 'Bad Request.')

  • $this->addError(400, null, 'Bad Request.')

  • new \TYPO3\CMS\Extbase\Error\Error(400, null, 'Bad Request.')

  • $this->throwStatus(400, null, 'Bad Request.')

  • Instantiate a response object and set the status code as \GuzzleHttp\Psr7\Response(400)

Explicación

Pregunta 5 de 19

1

What are the characteristics of controllers? (2)

Selecciona una o más de las siguientes respuestas posibles:

  • Controllers are the control and central processing unit in the MVC stack

  • Controllers are responsible for initialising domain models

  • The logic implemented in controllers should be kept to a minimum

  • All business logic should be implemented in controllers

  • Controllers validate all objects

Explicación

Pregunta 6 de 19

1

Which statements about “actions” in Extbase’s controller/action concept are correct? (3)

Selecciona una o más de las siguientes respuestas posibles:

  • Action methods are always static functions

  • Actions are public methods of a controller class

  • Names of action methods always end in Action, for example listAction()

  • Each action must be stored in a separate PHP file under Classes/Actions/

  • To be able to request an action of a plugin, the action has to be registered by using
    configurePlugin()

  • Action methods must always return a string (this is the content shown in the frontend)

Explicación

Pregunta 7 de 19

1

How can a fallback to the default action be achieved, in order to prevent an error if a non-configured action is
called? (1)

Selecciona una o más de las siguientes respuestas posibles:

  • This is the default behaviour of Extbase

  • An appropriate configuration in file ext_localconf.php is required

  • The TypoScript setting callDefaultActionIfActionCantBeResolved can be configured

  • An errorAction() method can be implemented in the controller

  • The key routing can be used in TypoScript

Explicación

Pregunta 8 de 19

1

How can a “Page Not Found” error message be displayed – HTTP code 404 – if a non-configured action is called? (1)

Selecciona una o más de las siguientes respuestas posibles:

  • This is the default behaviour of Extbase

  • An appropriate configuration in the ext_localconf.php file is required

  • The TypoScript setting exceptionHandler can be configured

  • An errorAction() method can be implemented in the controller

  • The TypoScript setting throwPageNotFoundExceptionIfActionCantBeResolved can be configured

Explicación

Pregunta 9 de 19

1

Which approach is officially recommended to get an object in a controller? (1)

Selecciona una o más de las siguientes respuestas posibles:

  • use \Vendor\MyExtension\Domain\Repository\TagRepository;
    ...
    $this->objectManager->get(TagRepository::class)

  • use \Vendor\MyExtension\Domain\Repository\TagRepository;
    ...
    $this->objectManager->create(TagRepository::class)

  • new \Vendor\MyExtension\Domain\Repository\TagRepository

  • use \Vendor\MyExtension\Domain\Repository\TagRepository;
    ...
    $this->instanceManager->make(TagRepository::class)

  • use \TYPO3\CMS\Core\Utility\GeneralUtility;
    use \Vendor\MyExtension\Domain\Repository\TagRepository;
    ...
    GeneralUtility::makeInstance(TagRepository::class);

Explicación

Pregunta 10 de 19

1

Where is the Object Manager available as $this->objectManager by default? (2)

Selecciona una o más de las siguientes respuestas posibles:

  • In repositories

  • In ViewHelpers

  • In Fluid templates

  • In controllers

  • In domain models

Explicación

Pregunta 11 de 19

1

Which statements about the view in a controller are correct? (2)

Selecciona una o más de las siguientes respuestas posibles:

  • You can access the output of a view by using the method render()

  • The view can only be rendered at the end of an action method

  • The view is available in the action as $this->view

  • To prevent rendering the view, the action must return false

  • It is not possible to render a different view than the default one

Explicación

Pregunta 12 de 19

1

How do you prevent an action from being executed? (2)

Selecciona una o más de las siguientes respuestas posibles:

  • The action can be omitted from the TypoScript key switchableControllerActions

  • The action can be omitted from the first array of the plugin configuration in file ext_localconf.php

  • The action can be omitted from the second array of the plugin configuration in file ext_localconf.php

  • By setting the attribute deactivate in file tables.php

  • By configuring the action in the page TS key deniedActions

Explicación

Pregunta 13 de 19

1

How can an invalid domain object $blog be accessed in an action new? (2)

Selecciona una o más de las siguientes respuestas posibles:

  • This is always possible

  • Via the initializeNewAction() method

  • Via the errorNewAction() method

  • Via the newAction() method if the annotation @ignorevalidation $blog is set

  • Via the __destruct() method

Explicación

Pregunta 14 de 19

1

What is the purpose of the method errorAction() in a controller? (1)

Selecciona una o más de las siguientes respuestas posibles:

  • This method is executed if an error in the controller occurs

  • This method is executed if an error in the view occurs

  • This method is executed before the primary action

  • This method is always executed after the primary action

  • This method is executed if a validation error in the controller occurs

Explicación

Pregunta 15 de 19

1

How can validation errors of an object $blog be accessed in a controller? (1)

Selecciona una o más de las siguientes respuestas posibles:

  • This is not possible

  • By $blog->getErrors()

  • By $this->getErrors()

  • By $this->controllerContext->getRequest()->getErrors()

  • By $this->errors

Explicación

Pregunta 16 de 19

1

How can a non-persisting object be created from a GET request? (1)

Selecciona una o más de las siguientes respuestas posibles:

  • This happens automatically if the object is passed to the method as a parameter in the action

  • By using the “Object Type Converter”

  • By manually executing convertArrayToObject() in the Property Mapper

  • By setting the property mapping in TypoScript

Explicación

Pregunta 17 de 19

1

What 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
);
}

Selecciona una o más de las siguientes respuestas posibles:

  • FlexForm settings are merged with TypoScript settings

  • Custom settings are merged with TypoScript settings

  • All empty values in the arrays, both $settings and $this->settings, are removed

  • Keys with a value __UNSET in the array $settings unset array keys with the same name in the array $this->settings

Explicación

Pregunta 18 de 19

1

How do you retrieve the data of the current content object in Extbase? (1)

Selecciona una o más de las siguientes respuestas posibles:

  • By accessing getContentObject()->data of the ConfigurationManager

  • By accessing $this->request->getContentObjectData()

  • By accessing $this->cObj->data

  • By accessing $this->cObj->cObjGetSingle()

Explicación

Pregunta 19 de 19

1

In which file are custom Type Converters registered? (1)

Selecciona una o más de las siguientes respuestas posibles:

  • File ext_tables.php

  • File ext_localconf.php

  • The controller

  • File Configuration/TCA/table.php

  • File Configuration/TypoScript/setup.typoscript

Explicación