Mach-II for PHP: A Preview - Configuration
(Page 3 of 7 )
Programs that use implicit invocation are frequently referred to as event-driven or event-based. Events are announced, and listeners respond if they are subscribed to them. This is how Mach-II works.
In order to understand what is meant by this, we should begin with mach-ii.xml. This is the configuration file used to define event relationships in a Mach-II application.
<!--
phpMachII
config
mach-ii.xml
I define the basic control flow for this demo application.
-->
<mach-ii>
<!-- PROPERTIES -->
<properties>
<!-- MACH II REQUIRED -->
<property name="defaultEvent" value="showMain" />
<property name="exceptionEvent" value="exception" />
<property name="applicationRoot" value="/phpMachII" />
<property name="eventParameter" value="event" />
<property name="parameterPrecedence" value="form" />
<property name="maxEvents" value="10" />
</properties>
<!-- LISTENERS -->
<listeners>
<listener name="processForm" type="phpMachII.model.processForm">
<invoker type="MachII.framework.invokers.ObjectEvent" />
</listener>
</listeners>
<!-- EVENT FILTERS -->
<event-filters>
<event-filter name="GlobalsToEvent" type="phpMachII.filters.GlobalsToEvent" />
</event-filters>
<!-- EVENTS -->
<event-handlers>
<!-- Main (landing page) -->
<event-handler event="showMain" access="public">
<event-arg name="page" value="Main" />
<view-page name="main" />
</event-handler>
<!-- Process a few form variables for demonstration purposes -->
<event-handler event="processForm" access="public">
<event-mapping event="success" mapping="showResults" />
<event-mapping event="noSuccess" mapping="showMain" />
<notify listener="processForm" method="validateForm" resultKey="GLOBALS['results']" />
</event-handler>
<!-- Display results of form processing -->
<event-handler event="showResults" access="public">
<event-arg name="pageName" value="Success" />
<view-page name="results" />
</event-handler>
<event-handler event="exception">
<event-arg name="page" value="Failure" />
<view-page name="exception" />
</event-handler>
</event-handlers>
<!-- VIEWS -->
<page-views>
<page-view name="main" page="/views/main.php" />
<page-view name="results" page="/views/results.php" />
<!-- Exception -->
<page-view name="exception" page="/views/exception.php" />
</page-views>
<!-- PLUGINS -->
<plugins>
</plugins>
</mach-ii>
Figure 3 The demo app’s mach-ii.xml structure
This file is the control center of a Mach-II application. As you can see by looking at our example’s mach-ii.xml file, the application is composed of properties, listeners, event-handlers, plugins and filters. mach-ii.xml is where you define the properties and relationships that make up your application. It can be found in an application’s /configure/ directory.
Next: Properties >>
More PHP Articles
More By Mike Britton