Exemplo n.º 1
0
/**
* Short Description
* Long
* Description
* @command check_registration
*/
function pestle_cli($argv)
{
    $path = 'app/code';
    if (count($argv) > 0) {
        $Path = $argv[0];
    }
    foreach (glob($path . '/*/*') as $file) {
        $parts = explode('/', $file);
        $module = implode('_', array_slice($parts, count($parts) - 2));
        $file = $file . '/' . 'registration.php';
        if (file_exists($file)) {
            output("Registration Exists");
            $contents = file_get_contents($file);
            if (strpos($contents, "'" . $module . "'") !== false) {
                output("Registration contains {$module} string");
                continue;
            }
            output("However, it's missing single quoted '{$module}' string");
            output("");
            continue;
        }
        output("No {$file}");
        $answer = input("Create? [Y/n]", 'n');
        if ($answer !== 'Y') {
            continue;
        }
        file_put_contents($file, templateRegistrationPhp($module));
        output("Created {$file}");
        output("");
    }
}
Exemplo n.º 2
0
/**
* Generates new module XML, adds to file system
* This command generates the necessary files and configuration
* to add a new module to a Magento 2 system.
*
*    pestle.phar Pulsestorm TestingCreator 0.0.1
*
* @argument namespace Vendor Namespace? [Pulsestorm]
* @argument name Module Name? [Testbed]
* @argument version Version? [0.0.1]
* @command generate_module
*/
function pestle_cli($argv)
{
    $namespace = $argv['namespace'];
    $name = $argv['name'];
    $version = $argv['version'];
    $full_module_name = implode('_', [$namespace, $name]);
    $config = simplexml_load_string(getBlankXml('module'));
    $module = $config->addChild('module');
    $module->addAttribute('name', $full_module_name);
    $module->addAttribute('setup_version', $version);
    $xml = $config->asXml();
    $base_dir = getBaseMagentoDir();
    $module_dir = implode('/', [$base_dir, 'app/code', $namespace, $name]);
    $etc_dir = $module_dir . '/etc';
    $reg_path = $module_dir . '/registration.php';
    if (is_dir($etc_dir)) {
        output("Module directory [{$etc_dir}] already exists, bailing");
        return;
    }
    mkdir($etc_dir, 0777, $etc_dir);
    writeStringToFile($etc_dir . '/module.xml', $xml);
    output("Created: " . $etc_dir . '/module.xml');
    $register = templateRegistrationPhp($full_module_name);
    writeStringToFile($reg_path, $register);
    output("Created: " . $reg_path);
}
Exemplo n.º 3
0
function createRegistrationPhpFile($base_folder, $package, $theme, $area)
{
    $path = $base_folder . '/registration.php';
    $registration_string = $area . '/' . $package . '/' . $theme;
    $registration = templateRegistrationPhp($registration_string, 'THEME');
    output("Creating: {$path}");
    writeStringToFile($path, $registration);
}
Exemplo n.º 4
0
/**
* Generates registration.php
* This command generates the PHP code for a 
* Magento module registration.php file.
* 
*     $ pestle.phar generate_registration Foo_Bar
*     <?php
*         \Magento\Framework\Component\ComponentRegistrar::register(
*             \Magento\Framework\Component\ComponentRegistrar::MODULE,
*             'Foo_Bar',
*             __DIR__
*         );
* 
* @command generate_registration
* @argument module_name Which Module? [Vendor_Module] 
*/
function pestle_cli($argv)
{
    $module_name = $argv['module_name'];
    output(templateRegistrationPhp($module_name));
}