\
str_replace('-', '_', 'api_' .
$hook . '_response'
) );
} private function validate(ApiHook
$hook, Context
$context): void
{ $scripts =
$this->loader->
get($hook->
getName());
/** @var Script $script */
foreach ($scripts as $script) { // todo@dr after implementing UI in admin, we can allow "private scripts"
if (!
$script->
isAppScript()) { throw new PermissionDeniedException();
} /** @var ScriptAppInformation $appInfo */
$appInfo =
$script->
getScriptAppInformation();
$source =
$context->
getSource();
if ($source instanceof AdminApiSource &&
$source->
getIntegrationId() ===
$appInfo->
getIntegrationId()) { // allow access to app endpoints from the integration of the same app
continue;
}