Categories


Archives


Recent Posts


Categories


Ultimate Module Creator with C.R.U.D. Scaffolding

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

I reviewed the original Magento Ultimate Module Creator almost — six?! — years ago. Its creator, Marius Strajeru, just announced a new project that we’ll call Ultimate Modules Creator for C.R.U.D.

This looks like it’s a Magento module (Umc_Crud) that provides a set of base classes and interfaces with a standard, opinionated way of building Magento’s data modules. These are the modules that allow you to edit objects (i.e. your data) via admin UI forms.

Marius also wrote a sample module that shows how you might use these base classes and interfaces. If we take a look at one of the sample controller files

<?php
declare(strict_types=1);

namespace Umc\Sample\Controller\Adminhtml\Something;

use Magento\Framework\App\Action\HttpGetActionInterface;

class Edit extends \Umc\Crud\Controller\Adminhtml\Edit implements HttpGetActionInterface
{
    public const ADMIN_RESOURCE = 'Umc_Sample::sample_something';
}

we see what Umc_Crud does for us. Instead of having an Edit controller that contains the code for interacting with Magento’s data objects, all a programmer needs to do is define the class, assign it an ACL resource, and extends the base Umc\Crud\Controller\Adminhtml\Edit class. (shout out to inheritance, still useful despite what you read in the trades)

I was a little disappointed to see that UI Components were still a babel like tower of XML. I was never happy that my own efforts with pestle only handle the initial generation, and I hold out hope someone might build solid tooling around UI Components. Still a missed almost oppurtunity all these years later.

Regardless, it’s an interesting project if you’re doing a lot custom CRUD work in your Magento projects. By limiting the amount of code you and your team need to write you’ll avoid a whole class of subtle inconsistencies that can creep in when lots of people are touching the same files.

Copyright © Alan Storm 1975 – 2020 All Rights Reserved

Originally Posted: 6th April 2020