The last few days I've been working on adding tables to devtools. This opens up a lot of possibilities, because the moment you know the data the component is working with, you can create a lot of code for working with that data automatically.


I've written a test-script to test this which shows off the functionality added:

// Get the basic script
$script        = DevTools::script();

// Define the component we are working on
$component    = $script->component("Biographies","Samuel Jackson");

// Setup Table
$table    = $component->table("Bio")
        ->varchar("name",120)    // Adds a name field
        ->text("story")            // Adds a text field
        ->published()            // Adds a published field
        ->order()                // Adds an ordering field
        ->checked()                // Adds a checked_out field
        ->modified();            // Adds a modified field

// Setup Item Model with table
$list    = $component->model("list",$table)
        ->getList()                // Adds a function for getting a list of item
        ->publish()                // Adds a function for publishing items
        ->delete()                // Adds a function for deleting items
        ->order();                // Adds a function for ordering items
   
// Setup List Model
$item    = $component->model("item",$table)
        ->getItem()                // Adds a function for getting an item
        ->store()                // Adds a function for storing an item
        ->checked()                // Adds a function for checking in/out an item
        ->move();                // Adds a function for moving an item
       
// Setup Controller (The argument to the methods is the model)
$contr    = $component->controller()
        ->cancel('list')        // Adds cancel
        ->move('item')            // Adds moving an item
        ->order('list')            // Adds moving a bunch of items
        ->publish('list')        // Adds publishing a bunch of items
        ->remove('list')        // Adds deleting a bunch of items
        ->save('item');            // Adds saving an item

// Setup View
$component->view("item")->tmpl();

It's very verbose for the sake of testing, but from here it's simple to generate this code when a table is added.

What the script does is adding a table with a few fields to the database. I've added a group of the most used database fields as methods (varchar, text, int, etc...), together with a group of fields that are used often together with Joomla. Order, for example adds the field 'ordering' to the database, but also indicates that the component created contains fields that can be ordered, which means that I by looking at the table automatically can add ordering functions to the model and controller. The same goes for 'published', 'checked', and 'modified'.

So to round it up, devtools will rock :)