Beispiel #1
0
/**
* Generates a Magento 2.1 ui grid listing and support classes.
*
* @command magento2:generate:ui:add-column-sections
* @argument listing_file Which Listing File? []
* @argument column_name Column Name? [ids]
* @argument index_field Index Field/Primary Key? [entity_id]
*/
function pestle_cli($argv)
{
    $xml = simplexml_load_file($argv['listing_file']);
    validateAsListing($xml);
    $columns = getOrCreateColumnsNode($xml);
    $sectionsColumn = $columns->addChild('selectionsColumn');
    $sectionsColumn->addAttribute('name', $argv['column_name']);
    $argument = addArgument($sectionsColumn, 'data', 'array');
    $configItem = addItem($argument, 'config', 'array');
    $indexField = addItem($configItem, 'indexField', 'string', $argv['index_field']);
    writeStringToFile($argv['listing_file'], formatXmlString($xml->asXml()));
}
Beispiel #2
0
/**
* Generates a Magento 2.1 ui grid listing and support classes.
*
* @command magento2:generate:ui:add-column-actions
* @argument listing_file Which Listing File? []
* @argument index_field Index Field/Primary Key? [entity_id]
*/
function pestle_cli($argv)
{
    $xml = simplexml_load_file($argv['listing_file']);
    validateAsListing($xml);
    $actionsClass = generatePageActionsClassFromListingXmlFileAndXml($argv['listing_file'], $xml);
    $columns = getOrCreateColumnsNode($xml);
    $actionsColumn = $columns->addChild('actionsColumn');
    $actionsColumn->addAttribute('name', 'actions');
    $actionsColumn->addAttribute('class', $actionsClass);
    $argument = addArgument($actionsColumn, 'data', 'array');
    $configItem = addItem($argument, 'config', 'array');
    $indexField = addItem($configItem, 'indexField', 'string', $argv['index_field']);
    output(formatXmlString($xml->asXml()));
    // <actionsColumn name="actions" class="Pulsestorm\ToDoCrud\Ui\Component\Listing\Column\Pulsestormtodolisting\PageActions">
    //     <argument name="data" xsi:type="array">
    //         <item name="config" xsi:type="array">
    //             <item name="resizeEnabled" xsi:type="boolean">false</item>
    //             <item name="resizeDefaultWidth" xsi:type="string">107</item>
    //             <item name="indexField" xsi:type="string">pulsestorm_todocrud_todoitem_id</item>
    //         </item>
    //     </argument>
    // </actionsColumn>
}