Skip to content

Advisable Services Newsfeed

Flow ID: AD-57 | Module(s): core (admin), settings | Complexity: Low Last Updated: 2026-04-04

Business Context

The Advisable Services newsfeed is a notification/news widget displayed in the admin panel header. It integrates with the external Advisable Services API to show platform news, service updates, support status, billing information, and other account-level data to admin users. The newsfeed is part of a broader "Advisable Services" integration that also surfaces lease status, unpaid services, deadlines, OTP, and support hour consumption.

The feature is controlled by the OTHER/ENABLE_NEWSFEED registry key and requires the OTHER/SERVICES_ENABLED and OTHER/SERVICES_API_KEY registry keys to be configured. It is only visible to users with Advisable or Admin roles.


API Reference

REST Endpoints

No REST API. The newsfeed data is fetched server-side during admin page load and injected as JSON state.

External API

The Adv_advisable_services library communicates with an external Advisable Services API:

Endpoint (via library)Description
customerLeaseStatusWhether the client is on a lease plan
customerUnpaidServicesCount of unpaid services
customerDeadlineAccount deadline date
customerRecurringServicesRecurring service subscriptions
customerOTPOne-time password or token
customerSupportStatusWhether support hours are active
customerConsumedHoursSupport hours consumed and last paid date
News feed dataPlatform news items (when enabled)

Code Flow

Admin Page Load (Every Admin Page)

Adv_admin_controller::__construct()
  |
  +--> render['enable_news'] = registry->value('OTHER', 'ENABLE_NEWSFEED')
  |
  +--> setupAdvisableServicesJsonState()
       |
       +--> Check: user must be Advisable or Admin role
       +--> Check: registry 'OTHER/SERVICES_ENABLED' must be truthy
       |    (If either check fails, return with disabled state)
       |
       +--> Load registry values:
       |    - enable_news = registry->value('OTHER', 'ENABLE_NEWSFEED')
       |    - serviceAuthKey = registry->value('OTHER', 'SERVICES_API_KEY')
       |
       +--> Load advisable_services library with:
       |    - serviceAuthKey
       |    - config->item('advisableServicesUrl')
       |    - config->item('advisableServicesTimeoutSeconds')
       |
       +--> pscache->library('advisable_services',
       |        'buildAdvisableServicesJsonState', [$enable_news],
       |        config->item('advisableServicesCacheTTLSeconds'))
       |    (Cached API call -- avoids hitting external API on every page load)
       |
       +--> render['advisableServicesJsonState'] = JSON state object
       +--> render['advisableServicesEnabledCssClass'] = 'services-enabled'

Building the JSON State

Adv_advisable_services::buildAdvisableServicesJsonState($enableNews)
  |
  +--> Create AdvisableServicesJsonState value object
  +--> Fetch customer aggregate data from external API
  +--> Populate state:
  |    - areNewsEnabled, baseUrl, isLease, unpaidServices
  |    - deadline, recurringServices, OTP
  |    - areSupportHoursEnabled, supportHoursConsumed, lastPaidDate
  |
  +--> If news enabled: fetch and attach news feed items
  +--> Return state object (serialized as JSON for frontend)

Settings Toggle

Adv_settings::other() (settings controller)
  |
  +--> On POST: registry->setValue('OTHER', 'ENABLE_NEWSFEED', (int)post('other_enable_news'))
  +--> On GET: load current value for form display

Domain Layer

Modern Classes (src/)

FileResponsibility
src/Services/State/ValueObject/AdvisableServicesJsonState.phpJSON state value object
src/Services/State/ValueObject/AdvisableServicesHttpClientConfig.phpHTTP client configuration
src/Services/Traits/AdvisableServicesHttpClientTrait.phpHTTP client trait for API calls

Legacy Layer (ecommercen/)

FileResponsibility
ecommercen/libraries/Adv_advisable_services.phpServices library (API client)
ecommercen/core/Adv_admin_controller.phpBase admin controller (lines 126, 287-325)
ecommercen/settings/controllers/Adv_settings.phpSettings controller (enable/disable toggle)

Data Model

No dedicated tables. Configuration stored in the registry table:

Registry GroupKeyDescription
OTHERENABLE_NEWSFEEDEnable/disable the newsfeed widget (1/0)
OTHERSERVICES_ENABLEDMaster switch for Advisable Services integration
OTHERSERVICES_API_KEYAuthentication key for the external API

Seeded in database/seeders/InitialSeed.php with ENABLE_NEWSFEED = 1 as default.


Configuration

SourceKeyDescription
ConfigadvisableServicesUrlBase URL of the external Advisable Services API
ConfigadvisableServicesTimeoutSecondsHTTP timeout for API requests
ConfigadvisableServicesCacheTTLSecondsCache TTL for the aggregated services state
RegistryOTHER/ENABLE_NEWSFEEDToggle newsfeed on/off
RegistryOTHER/SERVICES_ENABLEDMaster toggle for all Advisable Services
RegistryOTHER/SERVICES_API_KEYAPI authentication key

Required roles: AUTH_ROLE_ADVISABLE or AUTH_ROLE_ADMIN (checked at runtime in setupAdvisableServicesJsonState()).


Client Extension Points

  • Disable entirely: Set OTHER/SERVICES_ENABLED to 0 in the registry
  • Toggle newsfeed only: Set OTHER/ENABLE_NEWSFEED to 0 to hide the news widget while keeping other services data

Business Rules

  1. Double gate: The newsfeed requires both SERVICES_ENABLED and the user having Advisable/Admin role. ENABLE_NEWSFEED further controls whether news items specifically are fetched.
  2. Cached API calls: The external API response is cached using pscache with a configurable TTL to avoid repeated HTTP calls on every admin page load.
  3. Graceful degradation: If the external API call fails (network error, timeout), the error is logged and the admin panel continues to function with the services widget in a disabled state.
  4. Per-page load: The services state is evaluated on every admin page load (in the base controller constructor), not just on a specific page.
  5. Frontend JSON: The state is serialized as JSON and injected into the admin view for client-side rendering of the services widget.