Three months have passed in no time since I have started the project. I guess that is what happens when the work is fun, you learn a lot and have great mentors. As for the content of this blogpost, we will start with a description of the project and what value it adds to Joomla, finishing on a personal note with my impressions of this year’s project.
The basic idea for the project is to rebuild Joomla models with an Active Record Implementation. This will be a cross implementation of ideas from our existing Model and Table implementations combined with ideas from Laravel's Eloquent Framework which contains a much improved Active Record Implementation.
The need for this project comes from the limitations of the current Model architecture which have been reached during the last year GSoC Webservices project.
Because by reaching these limitations, it was clear that the Model layer had to be redone. Taking it a step further, with the desire to make development in Joomla easier, the Entities project was born.
The scope of the entity project is to make the database interaction easier than writing full sql queries from scratch. All the developer needs to do is to define the entities classes for each tables, along with the following:
- Mutators - custom fields for the object
- Casts - making sure raw data is handled in php with the desired type
- Aliases - making Joomla different column names in different components unifor
- Relations - last, but the best, define the relations of the table in order to make accessing the related data as simple as accessing an attribute.
Example for an Entity class:
Now, moving on to the improvements that this project brings to the table, let’s simply compare the two ways of doing queries.
This is not the same query, but it is easy to get the idea. There is no need for handling the database object, table names, aliases, etc.
Moving one to the integration of this project in Joomla CMS, there are two stages of integration:
- By changing the current Tables implementation in your component to Entities. This is done in the users component for the UserNote as an example.
- Full integration, by changing all the Models to Entities, and getting rid of all the old Tables. This part is work in progress and has complex implications in Joomla MVC and errors handling. A current work in progress for this is available here.
I would like to start by comparing this project with last year Parallel Testing project. For example last year project was kind of more into research. A log of emphasis was on what can be done or not, so I had more of a free hand. The end result was not sure.
This year, we new what was needed, but the development was hard, so a scope was needed to be defined, otherwise the project was never going to be finished in 3 months. So like, we don't have events in the Models yet, no batch processing, only one to one and one to many relations. Also, the project has an impact on Joomla Core, so it's a bit different, I had to follow Joomla standards much more closely.
Overall, I would say this project was and is really amazing. If I had to choose between one of them, I am not sure, they are very different and I learned a lot from both.
From an organizational point of view, this year was amazing, thanks to George Wilson, my main mentor, as he always provided the big picture and quick feedback on PR's. I have really enjoyed our discussions, especially for the many design choices we had to make in this project.
Last, but not least, I would like to say that this project brought another light on open source and Joomla for me. Seeing how many people you can affect with your knowledge, I will definitely continue to contribute to this project over time, hoping for it to reach maturity as soon as possible.