requirePermission($request, 'api.access'); $type = $this->getRouteParam($request, 'type'); /** @var Flex $flex */ $flex = $this->grav['flex_objects']; $directory = $flex->getDirectory($type); if (!$directory || !$directory->isEnabled()) { throw new NotFoundException("Flex directory '{$type}' not found or not enabled."); } $blueprint = $directory->getBlueprint(); $data = $this->serializeBlueprint($blueprint, $type); // Fire event to allow plugins to modify the serialized blueprint fields $event = new Event([ 'fields' => $data['fields'], 'template' => 'flex-objects/' . $type, 'user' => $this->getUser($request), ]); $this->grav->fireEvent('onApiBlueprintResolved', $event); $data['fields'] = $event['fields']; return ApiResponse::create($data); } }