Skip to content

Instantly share code, notes, and snippets.

@AmyStephen
Created May 19, 2012 13:32
Show Gist options
  • Save AmyStephen/2730868 to your computer and use it in GitHub Desktop.
Save AmyStephen/2730868 to your computer and use it in GitHub Desktop.
Molajo Data Sources
<?xml version="1.0" encoding="utf-8"?>
<model
name="Messages"
catalog_type_id="0"
table="#__dummy"
primary_key=""
primary_prefix=""
get_customfields="0"
get_item_children="0"
use_special_joins="0"
check_view_level_access="0"
data_source="Message">
</model>
@AmyStephen
Copy link
Author

One of the problems with standardizing data flow and processing all Views the same is that not all data used to render Views comes out of databases. That was one of the problems I wanted to tackle in Molajo -- to process all input, regardless of what type of data it is, in the Model so that there is maximum separation between the Views and data, and so that security and other processing could be standardized across the board.

This is an example of how that integration takes place -- the data_source line translates to a Class name. In this case, I am declaring the Message Service Class as a data source. The ModelController uses those XML files (passing the information to the Configuration Service) to instruct the Model how to interact with this data.

ModelController - https://gist.github.com/2728964

In the Message Services class, methods named like the Database Query class, are (minimally) created, to mock up what is needed to simulate a dbo connection, to retrieve the data needed so that the model can interact with it just like it does a "normal" database query. The query results are requested and received by the Controller and treated like an other database query.

A list view is a list view -- whether it's listing files in a folder -- or article titles in a blog -- or entries in a menu -- or application messages -- each data are managed differently but displayed the same. That's the beauty of the MVC.

Here's a link to a method in the Messages class that retrieves Message data needed for display on the View:
https://github.com/Molajo/Molajo/blob/master/source/Molajo/Service/Services/Message/MessageService.php#L132

I like how that is turning out in Molajo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment