FOF30\Generator\Command\Command::getComponentName PHP Méthode

getComponentName() protected méthode

Get the component's name from the user
protected getComponentName ( $composer ) : string
Résultat string The name of the component (com_foobar)
    protected function getComponentName($composer)
    {
        $extra = isset($composer->extra) && isset($composer->extra->fof) ? $composer->extra->fof : false;
        $default_name = $extra ? $extra->name : array_pop(explode("/", $composer->name));
        $default_name = $default_name ? $default_name : 'com_foobar';
        // Add com_ if necessary
        if (stripos($default_name, "com_") !== 0) {
            $default_name = "com_" . $default_name;
        }
        $name = false;
        if (!$extra) {
            /** @var \FofApp $app */
            $app = JFactory::getApplication();
            $app->out("What's your component name? (" . $default_name . ")");
            $name = $app->in();
        }
        if (!$name) {
            $name = $default_name;
        }
        // Keep asking while the name is not valid
        while (!$name) {
            $name = $this->getComponentName($composer);
        }
        // Add com_ if necessary
        if (stripos($name, "com_") !== 0) {
            $name = "com_" . $name;
        }
        return strtolower($name);
    }