Giter VIP home page Giter VIP logo

wmscaffold's Introduction

wmscaffold

Latest Stable Version Total Downloads License

Provides Drupal services and Drush 9 commands for easy creation of fields & entity types, code style fixing, model & controller generating and more.

Development of this project is moved to Drupal.org: https://www.drupal.org/project/entity_bundle_scaffold.

wmscaffold's People

Contributors

dieterholvoet avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

drupallabs

wmscaffold's Issues

Add annotation to generated controllers

Summary

In the new major version of wmcontroller, discovery happens through annotations, same as wmmodel. We should add these annotations to generated controllers.

Basic example

<?php

namespace Drupal\wmcustom\Controller\Node;

use Drupal\wmcontroller\Controller\ControllerBase;
use Drupal\wmcustom\Entity\Model\Node\Page;

/**
 * @Controller(
 *     entity_type = "node",
 *     bundle = "page",
 * )
 */
class PageController extends ControllerBase
{
    public function show(Page $page)
    {
        return $this->view('node.page', ['page' => $page]);
    }
}

Interact hooks not triggered

Description

In the latest dev version of this module, usage of the @interact hook was removed in a couple commands. Since a couple of hooks also use this kind of hook, they are not triggered anymore.

Steps to reproduce

Create a new text field. The Allowed formats option is no longer there.

Expected result

Make sure all hooks are functioning again.

Actual result

Hooks are not triggered anymore.

Environment

Latest dev version of the module, latest version of Drupal.

Clean up branches

Description

  • Clean up unused branches (check Sourcegraph to make sure the branch is not directly required in a composer.json file)
  • Switch default branch to main

Remove QuestionTrait & ChoiceQuestion

  • Remove usages of ChoiceQuestion
  • QuestionTrait::choice should be replaced with something like this:
$question = (new ChoiceQuestion($question, $choices))
            ->setMultiselect(true);

        return $this->io()->askQuestion($question);
  • QuestionTrait::confirm should be replaced with $this->io()->confirm($question, $default)
  • QuestionTrait::askOptional is not necessary anymore. $this->io()->ask now asks optional answers by default. However, previously these were required. So go through the code and add required validation everywhere $this->io()->ask is currently used:
$answer = $this->io()->ask($question, $default, [static::class, 'validateRequired']);
public static function validateRequired(?string $value): string
    {
        // FALSE is not considered as empty value because question helper use
        // it as negative answer on confirmation questions.
        if ($value === NULL || $value === '') {
            throw new \UnexpectedValueException('This value is required.');
        }

        return $value;
    }

Create a translatable field using field:create

Summary

Add a new option is-translatable to the field:create command.

Motivation

All fields are created with the translatable property set to false. In some cases it would be useful to be able to create translatable fields.

Error when calling field:create with the --existing option

field:meta produces the following command:

drush field:create node page --existing --field-name=field_meta --field-label=Meta --field-widget=inline_entity_form_simple --is-required=1 --target-type=meta --target-bundle=meta

which produces the following error:

 [error]  TypeError: Argument 2 passed to Drupal\wmscaffold\Commands\FieldCreateCommands::createField() must be of the type string

When calling field:create with the --existing option, the field type should be derived from the existing field storage.

Add PHPStan to coding standard fixers

  • Add phpstan.neon config file referencing the wmcodestyle rule files (example)
  • Add phpstan analyse to the coding-standards composer script
  • Add autoload-dev entry to ensure autoloading during analysis

The "taxonomy_vocabulary" entity type does not exist.

Description

We should check whether the taxonomy module is enabled when running drush vocabulary:create because now, after filling all inputs and without the module enabled, you get the following error:

The "taxonomy_vocabulary" entity type does not exist.

'field_config' entity with ID 'xxx' already exists.

Description

When calling field-create to create a field based on an existing field storage, but the field already exists, you don't get an error until after you enter the remaining info.

Steps to reproduce

drush field:create node page --existing --field-name=field_meta --field-label=Meta --field-widget=inline_entity_form_simple --is-required=1 --target-type=meta --target-bundle=meta

Expected result

Add validation and a nicer error message.

Actual result

In EntityStorageBase.php line 499:

  'field_config' entity with ID 'xxx' already exists.

Environment

Latest dev version of this module, latest version of Drupal.

Change model generator for latest development version of wmmodel

Summary

The wmmodel module removed its custom class discovery in favour of the annotation-supported Drupal 8 plugin system. The model generator should be changed to add the required annotation. Additionally, we could now customize in what namespace the classes should be placed.

Basic example

<?php

namespace Drupal\wmcustom\Entity\Item;

/**
 * @Model(
 *     entity_type = "item",
 *     bundle = "call_to_action"
 * )
 */
class CallToAction extends Item
{
}

Motivation

Support the latest version of wmmodel.

field:meta fails without existing field storage

Summary

All the current command does is call the field:create command with a couple of options. If this issue can't be fixed within the field:create command, maybe we should create a custom command instead of calling that one.

Motivation

When using the field:meta command with an entity type without an existing field storage for this field, the command fails.

Set the field description using field:create

Summary

Add a new option field-description to the field:create command.

Motivation

Right now, it's not possible to set the field description when creating fields using the field:create command. In some cases it would be useful to be able to do that.

Generate field setters

Summary

Allow ModelMethodGenerator plugins to provide a buildSetter method. Add support for generating these methods to ModelClassGenerator.

A non-functional, non-used method with this name has been present on ModelMethodGeneratorInterface and ModelMethodGeneratorBase for quite some time.

Motivation

Just like having getters on modules can be useful, sometimes we need setters for fields.

Clean up module

  • Cleanup code using wieni/wmcodestyle
  • Normalise composer.json
  • Add LICENSE in case it's missing. Also add the license to composer.json.
  • Add CHANGELOG.md (and UPGRADING.md, if applicable)
  • Add issue & pull request templates
  • Update repo description & tags
  • Update README
  • Update .gitignore
  • Check dependencies: ensure composer.json has a php & drupal/core version requirements and add missing requirements to the .info file

Add module to Drupal.org

  • Rename module to entity_bundle_scaffold
  • Create the Drupal project (example)
  • Change the license to GPLv2 to comply with Drupal.org requirements (example)
  • Update the composer install command in the README
  • Add contributing section to the README (example)
  • Create releases for existing tags on Drupal.org

Add an option to the config to choose the output module

Summary

Add an option to the wmscaffold.settings config to choose the output module instead of having to specify it as an argument in every command.

Motivation

Now you have to pass the wmmodel-output-module argument in every command that generates models. This creates a lot of unnecessary duplication.

Apart from that, passing default values for dynamic arguments in drush.yml broke in Drush 10, so automatically generating models after commands like eck:bundle:create is currently broken.

Consider removing phpcs:fix

This command doesn't provide much added value. I don't think drush phpcs:fix is being used internally at Wieni. @RobinHoutevelts could you check SourceGraph to make sure this isn't being used anywhere?

Add return type to show method of generated controllers

Summary

ViewBuilder can be added as return type for the show method, but only in supported PHP versions.

Basic example

<?php

namespace Drupal\wmcustom\Controller\Node;

use Drupal\wmcontroller\Controller\ControllerBase;
use Drupal\wmcustom\Entity\Model\Node\Page;
use Drupal\wmtwig\ViewBuilder;

/**
 * @Controller(
 *     entity_type = "node",
 *     bundle = "page",
 * )
 */
class PageController extends ControllerBase
{
    public function show(Page $page): ViewBuilder
    {
        return $this->view(
            'node.page',
            ['page' => $page]
        );
    }
}

Add description to all command options and arguments

Summary

Make sure all options and arguments are documented with descriptions.

Motivation

Multiple command help screens are broken because a description is missing for their options and/or arguments:

Notice: Undefined index: description in Drush\Commands\help\HelpCLIFormatter->write()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.