browse the blogs

[ 23 Mar 2017 ]

I’m working on adding DDL (data definition language) code generation to pestle – i.e. the code that ultimately creates your database tables that lives in the InstallSchema or UpgradeSchema classes. I came across this bit of weirdness

#File: vendor/magento/module-cms/Setup/InstallSchema.php

)->addColumn(
'identifier',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['nullable' => false],
'Block String Identifier'
)->addColumn(
'content',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'2M',
...

[ 28 Feb 2017 ]

Here’s a fun pestle command I forgot about.

pestle.phar magento2:search:search_controllers

This command accepts a file path as a single argument, searches through the specified folder for anything that looks like a Magento controller file, and then displays that controller file’s execute method along with its relative file path.

Pipe the resulting output to a file or text editor, and you can quickly search through all Magento’s controller files. For example, today I forgot the syntax for adding a custom handle to a layout update XML file – but with magento2:search:search_controllers the syntax was and a “Ctrl-F handle” away.

$ pestle.phar magento2:search:search_controllers
//...
vendor/magento/module-backend/Controller/Adminhtml/Denied.php
--------------------------------------------------
function execute()
{
if (!$this->_auth->isLoggedIn()) {
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
...

[ 24 Feb 2017 ]

UI Component Item `source` Nodes are Redundant:

I finally got an answer out of Magento engineering on those nodes and their best guess is as good as ours. i.e., they’re redundant/not-used.

There’s a few interesting points to make here for folks just learning to program, and just getting settled into the industry.

The first is software projects often grown beyond what any individual can understand, even (or especially) if that person works at the company responsible for that software. This is why programmers clammer for best-practices and consistency in their framework code. The ability to quickly trace out why something works a particular way is more important than any particular implementation, and inconsistent or over complex systems make …

[ 22 Feb 2017 ]

Although there’s no documentation stating this, based on system behavior it seems like the

Package/Module/Setup/InstallSchema.php

class files are sort of required by a Magento module.

I say sort of required because you can run a module without them. You can use that module to add features to Magento. However, a version number for that module will not be added to the setup_module table unless the InstallSchema class is present.

I discovered this when I tried adding an UpgradeSchema class to a module that didn’t have an InstallSchema. The UpgradeSchema still ran, but calling $context->getVersion()

public function upgrade(
SchemaSetupInterface $setup,
ModuleContextInterface $context
)
{
$setup->startSetup();

$version = '[' . $context->getVersion() . ']';
...

[ 21 Feb 2017 ]

While PHP production environments have long made use of extra systems like memcache, varnish, and redis, most successful PHP projects also let developers and technically savvy folks drop an archive of files on a server, point the web server at those files, configure the application to point to a traditional RDMS/database, and have a working application.

After a year or so of life with the Magento 2 non-beta-beta, it’s becoming clearer that this isn’t a priority for Magento’s engineering team. The first run experience remains dismal, and the company’s efforts seem focused on tools for Silicon Vally professionals, such as Docker.

For my on work, I’m still installing Magento directly on my OS X/macOS workstation. With out of the box performance …

[ 16 Feb 2017 ]

Tangentially Magento related: Magento uses the lusitanian/oauth composer package to handle some oAuth related tasks. In addition to the usual “create the cryptic Authorization: headers” code you’d expect to find in an oAuth library, there’s also these two folders of code

https://github.com/Lusitanian/PHPoAuthLib/tree/master/src/OAuth/OAuth1/Service

https://github.com/Lusitanian/PHPoAuthLib/tree/master/src/OAuth/OAuth2/Service

Each service class listed here attempts to capture each individual oAuth API’s unique take on how to authenticate, authorize, and call an API endpoint for a particular third party service.

Whenever someone like me quips that “oAuth is a tire fire”, what we’re really saying is “I wish oAuth was a protocol with a standard implementation for authentication, authorization, and method calling across corporate providers”. The effort David’s made to write and/or collect these …

[ 15 Feb 2017 ]

In a typical adminhtml UI Form Component, each individual form element has a corresponding view model object. For text input fields, these view models come from the constructor function returned by the Magento_Ui/js/form/element/abstract RequireJS module.

The view model’s value property, an Knockout observable object, contains the field’s value.

This value property is set with the uiElement’s links feature.

#File: vendor/magento/module-ui/view/base/web/js/form/element/abstract.js
defaults: {
    /* ... */
    links: {
        value: '${ $.provider }:${ $.dataScope }'
    }            
}

The links default will set observable values on an object at the time of instantiation by pulling items from the uiRegistry. …

[ 9 Feb 2017 ]

Keeping with UI Component form theme but drawing a wider circle, if you take a look at HTML source of a button on a backend Magento 2 HTML form, you’ll see something like the following

<button id="back"
title="Back"
type="button"
class="action- scalable back"
onclick="location.href = 'http://magento-2-1-3.dev/admin/cms/page/index/key/b202205a440f39f9cefe4724da28f8a6b1fa8b255f758f077cd9e8ef3181ca13/';"
data-ui-id="back-button">

<button id="save"
title="Save Page"
type="button"
class="action- scalable save primary ui-button ui-widget ui-state-default ...

[ 9 Feb 2017 ]

Merged Layout schema validation error in Magento 2:

A peek at the complexity deep in Magento 2’s layout rendering engine.