Skip to content

MelisEngine

Shared CMS data foundation — page model, sites, languages, templating-plugin base class and the render cache. Package melisplatform/melis-engine.

Purpose

MelisEngine owns the entire CMS database model (pages, page tree, sites, templates, languages, domains, SEO, styles) and exposes it through table gateways, services and a multi-tier cache. Both MelisFront (front-end rendering) and MelisCms (back-office editing) read and write exclusively through MelisEngine — neither sibling owns tables. It also defines MelisTemplatingPlugin, the abstract base class every content plugin in the platform extends.

Role in the React back-office

MelisEngine has no React back-office tool and no UI of its own — no brick, no config/react-api.php, no capabilities, no sidebar entry in /melis-react. It is not migrated to React and is not meant to be: it is platform infrastructure, not a back-office tool. Its relationship to the React shell is entirely behind the scenes, on two paths:

  • Data path — the React CMS controllers (MelisReactApi*, which live in the CMS modules, not here) read and write pages, sites, languages, templates and SEO only through MelisEngine's MelisEngineTable* gateways and services (MelisEnginePage, MelisEngineTree, MelisEngineLang, …). The React layer never touches the CMS schema directly.
  • Render path — the CMS content shown in the React page editor and in the legacy iframe tools is rendered server-side (pages → templates → zones → plugins). The engine resolves the page model and defines the plugin base class; MelisFront runs the actual render. React embeds the server-rendered result rather than re-rendering CMS content client-side.

Because it is invisible but load-bearing, engine problems surface inside the React CMS tools — an empty page tree, a language dropdown that stays empty, a page editor that errors on load — typically caused by a missing/behind CMS table or a failing engine service, never by an engine screen (there is none).

Enable it

MelisEngine is loaded automatically as a dependency. Load order in config/melis.module.load.php is:

php
// config/melis.module.load.php
return [
    'MelisCore',
    'MelisFront',
    'MelisEngine',   // requires melis-core + melis-front
    'MelisCms',
];

Composer dependencies: melisplatform/melis-core ^6.0, melisplatform/melis-front ^6.0, laminas/laminas-cache (filesystem + memory adapters). Runs on PHP ^8.3 | ^8.5.

Key services

Registered as service_manager aliases in config/module.config.php:

Service aliasRole
MelisEnginePage / MelisPageServiceResolve a page by id and mode (published / saved): getDatasPage($idPage, $mode) — returns hydrated page tree, page data, SEO, template and style objects
MelisEngineTree / MelisTreeServicePage tree navigation: getPageChildren(), getPageFather(), getPageBreadcrumb(), getPageLink(), search
MelisEngineTemplateServiceTemplate lookup: getTemplate($tplId)
MelisEngineSiteServiceSite catalogue
MelisEngineSiteDomainServiceDomain → site resolution: getSiteByDomain()
MelisEngineLang / MelisEngineLangServiceLanguages: available languages, locale ↔ id, site language
MelisEngineSEOServicePer-page SEO data: getSEOById()
MelisEnginePageDefaultUrlsServicePre-computed / canonical page URL lookups
MelisEngineStyle / MelisEngineStyleServiceSite styles and per-page CSS
MelisEngineCacheSystemCache orchestrator: getCacheByKey(), setCacheByKey(), deleteCacheByPrefix()
MelisSearchFull-text (Lucene-style) page index used by front-end search
MelisEngineSendMailEmail utility
MelisGdprService / MelisGdprAutoDeleteServiceGDPR banner texts and auto-delete framework
MelisEngineComposerComposer / dependency operations

All services that extend MelisGeneralService fire *_start / *_end events (e.g. melisengine_service_get_available_languages_start / _end) that other modules can hook.

React consumers (verified)

These are the sanctioned data-path entry points the React CMS tools call into the engine through:

Engine service / gateway (alias)Used by (React BO)
MelisEnginePage (MelisPageService)melis-cms MelisReactApiPageController — page data for the React page editor
MelisEngineTree (MelisTreeService)melis-cms MelisReactApiPageController — page tree navigation
MelisEngineLang (MelisEngineLangService)melis-cms MelisReactApiCmsSitesController, MelisReactApiCmsMenuManagerController — available CMS languages
MelisEngineTableCmsLang (MelisCmsLangTable)melis-cms-tags, melis-cms-user-account, melis-core (GDPR) — React language dropdowns

The alias MelisEngineTableCmsLang => MelisCmsLangTable::class is registered in config/module.config.php.

Backoffice

MelisEngine has no end-user tool of its own, in the legacy back-office or in /melis-react. It registers two form-element factories used across the back-office:

FactoryPurpose
MelisEnginePluginTemplateSelectTemplate select element for plugin forms
MelisEngineSiteSelectSite select element for plugin forms

Setup and maintenance controllers (MelisSetup*) are also present but are invoked by the installer, not by editors.

Front office

The base class for every content plugin lives here:

ItemDescription
MelisEngine\Controller\Plugin\MelisTemplatingPluginAbstract base for all content plugins. Defines front() (live render, abstract), back() (back-office container/edit view), config XML persistence (loadDbXmlToPluginConfig() / savePluginConfigToXml()), GET/POST loading, preview mode and responsive width.

Every platform content plugin (News, Slider, Menu, Breadcrumb, …) subclasses this. Implement front() for live output; the base handles back() automatically. The same plugin pipeline feeds the React page editor: MelisFront renders each zone's plugins server-side and React displays the result.

Two micro-service listeners hook melis_core_microservice_amend_data to expose tree and page methods (getPageChildren, getPageFather, getDomainByPageId, getDatasPage) over the platform micro-service layer.

Database tables

MelisEngine is the single source of truth for the CMS schema (install/sql/setup_structure.sql + install/dbdeploy/ deltas):

TableHolds
melis_cms_page_treePage hierarchy (tree_father_page_id, order)
melis_cms_page_publishedPublished (live) version of each page
melis_cms_page_savedSaved / draft version (edited in the back-office)
melis_cms_page_langPage ↔ language links
melis_cms_langCMS languages / locales
melis_cms_siteSites (root of the page tree)
melis_cms_templateTemplates (layout / controller / action or PHP path)
melis_cms_page_seoPer-page SEO (URL, 301 redirect, meta title/description, canonical)
melis_cms_site_domainSite domains per environment
melis_cms_site_301 / melis_cms_site_404Site-wide 301 redirects / 404 mapping
melis_cms_page_default_urlsPre-computed page URLs (cache table)
melis_cms_style / melis_cms_page_styleCSS styles and page ↔ style links
melis_cms_platform_idsPage-id allocation ranges per environment
melis_cms_site_config / _home / _langsSite config, home page per language, active languages
melis_cms_site_robotrobots.txt per domain
melis_cms_mini_tpl_*Mini-template categories, templates and flags
melis_cms_gdpr_textsGDPR banner texts per site / language
melis_site_translation / _textSite-wide translation strings

Table gateways

Every table is wrapped by a MelisEngineTable* gateway registered in the service manager (e.g. MelisEngineTablePageTree, MelisEngineTablePagePublished, MelisEngineTablePageSeo). Other modules — legacy or React — must always use these gateways, never raw SQL. The base gateway provides getEntryById(), getEntryByField(), save(), deleteById(), fetchAll().

Example

Read a page and navigate the tree:

php
$pageSvc = $sm->get('MelisEnginePage');
$page    = $pageSvc->getDatasPage($idPage);            // 'published' (live) by default
$draft   = $pageSvc->getDatasPage($idPage, 'saved');   // draft shown in the React page editor

$tree       = $sm->get('MelisEngineTree');
$children   = $tree->getPageChildren($idPage, 1);       // 1 = published only
$breadcrumb = $tree->getPageBreadcrumb($idPage);
$url        = $tree->getPageLink($idPage, true);        // true = absolute URL

Fill a React language dropdown from a CMS controller (server-side, delegating to the engine):

php
// Inside a MelisReactApi* controller of a CMS module — the React JSON layer
// delegates to the engine; MelisEngine exposes no react-api of its own.
$langTable = $sm->get('MelisEngineTableCmsLang');
$langs     = $langTable->fetchAll()->toArray();   // fills a React language dropdown

Read/write through a table gateway (never raw SQL):

php
$seoTable = $sm->get('MelisEngineTablePageSeo');
$seo      = $seoTable->getEntryByField('plang_page_id', $idPage)->current();
$seoTable->save(['seo_meta_title' => 'New title'], $existingSeoId);  // upsert

Cache a computed result:

php
$cache = $sm->get('MelisEngineCacheSystem');
$cache->setCacheByKey('mykey', 'my_cache_config', $value);
$value = $cache->getCacheByKey('mykey', 'my_cache_config');
$cache->deleteCacheByPrefix('page_' . $idPage, 'meliscms_page');   // invalidate a page

Listen to a service event:

php
$sharedEvents->attach('MelisEngine', 'melisengine_page_getdatas_end', function ($e) {
    $p = $e->getParams();   // includes page id and 'results'
    // alter $p['results'] before it is returned
}, 50);

Build a content plugin:

php
// Subclass MelisTemplatingPlugin, implement front() for live render.
// The base class handles back() (BO container), config XML persistence and preview.
class MyPlugin extends MelisEngine\Controller\Plugin\MelisTemplatingPlugin
{
    public function front(): string
    {
        return $this->getView()->render('my-module/plugin/my-plugin', $this->pluginConfig);
    }
}

The trio Core / Engine / Front

The React back-office does not change the trio; it sits on top of it:

  • MelisEngine (this module) — owns the entire CMS DB model and exposes it via table gateways + services + cache; defines MelisTemplatingPlugin.
  • MelisFront — renders pages from the engine's data (runs the content plugins) and powers the editable preview used inside the back-office (legacy and the React page editor / iframe tools).
  • MelisCms — the CMS back-office; it owns no tables and edits everything through the engine. Its React CMS tools (MelisReactApiPage, MelisReactApiCmsSites, MelisReactApiCmsMenuManager, …) are the React consumers listed above.

Key files

ConcernPath
Service & gateway aliases, cachesvendor/melisplatform/melis-engine/config/module.config.php
Page data servicevendor/melisplatform/melis-engine/src/Service/MelisPageService.php
Tree / links servicevendor/melisplatform/melis-engine/src/Service/MelisTreeService.php
Cache orchestratorvendor/melisplatform/melis-engine/src/Service/ (MelisEngineCacheSystem*)
Templating-plugin base classvendor/melisplatform/melis-engine/src/Controller/Plugin/MelisTemplatingPlugin.php
Table gatewaysvendor/melisplatform/melis-engine/src/Model/Tables/
Schema + delta migrationsvendor/melisplatform/melis-engine/install/sql/

See also: MelisFront · MelisCms · MelisCore