现在我正在尝试捕获这样的异常事件:
try {
echo 1 / 0;
} catch (\Exception $e){
$subs = new ExceptionSubscriber();
$this->dispatcher->addSubscriber($subs);
};
Run Code Online (Sandbox Code Playgroud)
我定义了 ExceptionSubscriber ,如下所示:
class ExceptionSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
KernelEvents::EXCEPTION => [
['processException', 10],
['exception', -10],
],
];
}
public function exception(ExceptionEvent $event)
{
echo 'test321';
}
public function processException(ExceptionEvent $event)
{
echo 'test123';
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 services.yaml
App\EventSubscriber\ExceptionSubscriber:
tags:
- { name: kernel.event_subscriber, event: kernel.exception }
Run Code Online (Sandbox Code Playgroud)
我知道我捕获的常规 PHP 异常不是内核异常事件之一,在这种情况下我必须创建自定义异常事件,对吧?
我使用而不是侦听器调度事件的方式EventSubscriber很好
我是否必须分派这些事件,或者它们以某种神奇的方式传递给订阅者?
我试图将插槽传递到插槽中,但需要向下传递插槽的子组件看不到它。
在子项(TheTable)中,我有来自 Vue Core UI(CDataTable)的表组件,它需要我想从父项传递的某些插槽:
<CDataTable
class="overflow-auto"
:items="this.items"
:fields="fieldData"
:sorter="{ external: true, resetable: true }"
:sorter-value="this.sorterValue"
:table-filter="{ external: true, lazy: false, placeholder: 'Enter here', label: 'Search:'}"
:responsive="false"
:loading="this.loading"
:hover="true"
:items-per-page-select="true"
:items-per-page="this.perPage"
@pagination-change="paginationChanged"
@update:sorter-value="sorterUpdated"
@update:table-filter-value="filterUpdated"
>
<slot name="requiredTableFields"></slot>
</CDataTable>
Run Code Online (Sandbox Code Playgroud)
在父组件中我有:
<TheTable
v-bind:fields="fields"
v-bind:endpoint-url="endpointUrl"
>
<template slot="requiredTableFields">
<td slot="name" slot-scope="{item}">
<div>{{ item['attributes.email'] }}</div>
<div class="small text-muted">
{{ item['attributes.firstname'] }} {{ item['attributes.lastname'] }}
</div>
</td>
<td slot="registered" slot-scope="{item}">
<template v-if="item['attributes.created_at']">{{ item['attributes.created_at'] }}</template>
<template v-else>Not setup yet</template>
</td>
</template>
</TheTable>
Run Code Online (Sandbox Code Playgroud)
有什么办法让它发挥作用吗?干杯,卡斯帕
我在想是否有一种方法可以使用常规下划线翻译来识别 Laravel 中未使用的翻译键?