Introduction to Components 2.0
The Component
Components are blocks, or bricks, with which the whole public section is
built. The components fully implement the Carrier Rider Mapper
pattern.
- Carrier
- Persistent object containing information which can be accessed by more
than one client simultaneously.
- Rider
- Riders (Reader or Writer) are objects created by
Carrier thereby providing access to persisted data. Clients can read
and write information only via Reader or Writer. Thus,
Reader and Writer are data access interfaces.
- Mapper
- Mappers (Scanner or Formatter) are wrappers for
Reader and Writer functionality. Mappers are able to
convert data to formats required by client.
Read flow is as follows: Carrier -> Reader -> Scanner
-> Client.
Write flow is as follows: Carrier <- Writer <-
Formatter <- Client.
Adding a mapping tier between Carrier/Rider and clients allows to connect a
single Carrier/Rider to different clients by means of appropriate mappers.
Components allow developers to reuse their once created and tested code. The
visual editor empowers site administrators with handy tools to add components to
pages and and configure them without having to change the source code. The
standard set of visual components is constantly updated.
What's so special about Components 2.0
- Components 2.0 can segregate view from logic. A "logic" object can have
more than one views attached to it which may depend on site template
conditions. A view (display template) can be created in any templating
language recognizable by PHP (e.g. PHP, Smarty, XSL etc.). A developer can
thereby avoid changing the component logic code to alter the display. The view
code is generally smaller than the component in the whole.
In other
words, a "logic" is the component core, while a "view" is the component
display template.
- All components are stored in a single folder. This makes the site
structure more robust and comprehensive. This folder is available to
components; they can easily access their or shared resources if required.
Attention!
Files access to which is forbidden must
start with the following code:
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
- The component stores all the private files in its own folder; you can
easily share components between projects by copying. Component is atom
(indivisible entity).
- Compound components (e.g. Forum or
Catalog) has the following distinctions.
- Developers do not have to create many pages manually to add all the
required child components. Common properties can be specified once for all
subcomponents.
- Developers avoid establishing complex relationships between
subcomponents. For example, in forum message pages, you do not need to worry
about links to forum topic list and user profile pages.
- You can add a new page even to a component with customized display
template. For example, if you enhance the forum with a top ten users page
(subcomponent), this page will be available in the public section.
- Changing a display template can be a single call instead of altering the
visual aspect for every subcomponent.