我运行了 TYPO3 v9.5 的本地游乐场设置,突然有一天后端在标签旁边显示字段名称(参见屏幕截图),这非常有用!
现在我想在我所有的 TYPO3 安装中启用此功能,但找不到此选项(在我的 Playground 中我安装并尝试了很多扩展,所以我猜有一个扩展启用了它)。当前的应用程序上下文是“生产”。
由于zend-mvc的2.7.0版本已ServiceLocatorAwareInterface被删除,因此$this->serviceLocator->get()控制器内部的调用也是如此.
这就是为什么几天前我对我的所有模块进行了大量重构,通过构造函数注入所需的服务/对象,使用工厂来处理大部分内容.
当然,我理解为什么这是更好/更清洁的做事方式,因为现在更容易看到家属.但另一方面:
这会导致繁重的开销和更多从未使用过的类实例,不是吗?
我们来看一个例子:
因为我的所有控制器都有依赖关系,所以我为所有控制器创建了工厂.
CustomerControllerFactory.php
namespace Admin\Factory\Controller;
class CustomerControllerFactory implements FactoryInterface {
public function createService(ServiceLocatorInterface $controllerManager) {
$serviceLocator = $controllerManager->getServiceLocator();
$customerService = $serviceLocator->get('Admin\Service\CustomerService');
$restSyncService = $serviceLocator->get('Admin\Service\SyncRestClientService');
return new \Admin\Controller\CustomerController($customerService, $restSyncService);
}
}
Run Code Online (Sandbox Code Playgroud)
CustomerController.php
namespace Admin\Controller;
class CustomerController extends AbstractRestfulController {
public function __construct($customerService, $restSyncService) {
$this->customerService = $customerService;
$this->restSyncService = $restSyncService;
}
}
Run Code Online (Sandbox Code Playgroud)
module.config.php
'controllers' => [
'factories' => [
'Admin\Controller\CustomerController' => 'Admin\Factory\Controller\CustomerControllerFactory',
]
],
'service_manager' => [
'factories' => [
'Admin\Service\SyncRestClientService' …Run Code Online (Sandbox Code Playgroud) php dependency-injection overhead zend-framework2 zend-framework3
我尝试更改通过后端定义包装每个内容元素的布局。不幸的是,似乎变量 for{data}仅在<f:section>元素内部可用。更有问题的是,<f:if>条件 ViewHelper 在 之外没有影响<f:section>,两个<f:layout>语句都被执行,并且只有最后一个被应用于渲染。那没有用……而且文档确实只讨论了该部分内的 ViewHelper。你知道任何其他方法来实现这一目标吗?提前致谢!
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:if condition="{data.layout} == 101"><!-- if-condition has no effect here -->
<f:then>
<f:layout name="FullWidth" />
</f:then>
<f:else>
<f:layout name="Default" />
</f:else>
</f:if>
<f:debug>TEST1: {data.layout}</f:debug><!-- THIS DOES NOT SHOW UP AT ALL! -->
<f:section name="Main">
<f:debug>TEST2: {data.layout}</f:debug><!-- Output is TEST2: 101 (integer) -->
[...]
</f:section>
</html>
Run Code Online (Sandbox Code Playgroud) 我想知道现代扩展中如何解决这个问题,但无法弄清楚。他们中的大多数人只是神奇地使用例如{data.uid}在他们的视图中没有任何$view->assign('data',...)
在我以前的行动中,我使用过这样的东西:
public function myAction() {
$data = $this->configurationManager->getContentObject()->data;
$this->view->assign('data', $data);
}
Run Code Online (Sandbox Code Playgroud)
由于getContentObject()在 v8 中被标记为已弃用,因此应该将其替换为getContentObjectRenderer(),但配置管理器没有这样的功能。