Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate:entity:content is allowing duplicated "machine_name" to be entered #170

Closed
vacho opened this issue Jul 17, 2014 · 4 comments
Closed
Assignees
Milestone

Comments

@vacho
Copy link
Contributor

vacho commented Jul 17, 2014

when I generate the entity "name_entity" and later I generate other entity with same name "name_entity" the code generated has duplicate.

And several other issues arise for failing at validate the id of the entity

@jmolivas jmolivas added the bug label Jul 17, 2014
@jmolivas jmolivas changed the title unvalidate entity "machine" name at generate:entity:content generate:entity:content is allowing duplicated "machine_name" to be entered Jul 17, 2014
@jmolivas jmolivas modified the milestones: v0.2.11 - 2014 September, v0.3.0 Sep 13, 2014
@jmolivas jmolivas self-assigned this Oct 31, 2014
@jmolivas
Copy link
Member

After some research this is the proposed resolution

ContainerAwareCommand

  • Add getEntityManager method
  public function getEntityManager(){
    return $this->getContainer()->get('entity.manager');
  }
  • Update validateMachineName method
  public function validateMachineName($machine_name)
  {
    $machine_name = $this->getValidator()->validateMachineName($machine_name);

    if ($this->getEntityManager()->hasDefinition($machine_name)) {
      throw new \InvalidArgumentException(sprintf('Machine name "%s" is duplicated.', $machine_name));
    }

    return $machine_name;
  }

GeneratorEntityCommand

  • Update interact method
if (!$entity_name) {
  $entity_name = $dialog->askAndValidate(
    $output,
    $dialog->getQuestion('Enter the entity name', $machine_name),
    function ($machine_name) {
      return $this->validateMachineName($machine_name);
    },
    false,
    $machine_name,
    null
  );
}

@jmolivas
Copy link
Member

This is how the console looks like on execution

entity-content-machine-name-

jmolivas added a commit that referenced this issue Oct 31, 2014
@jmolivas
Copy link
Member

Fixed with PR #229

@jmolivas
Copy link
Member

jmolivas commented Nov 1, 2014

Fixed on release V0.2.19 https://github.com/hechoendrupal/DrupalAppConsole/releases/tag/0.2.19

Try updating project

$ composer update drupal/console

@jmolivas jmolivas closed this as completed Nov 1, 2014
g3r4 pushed a commit to g3r4/drupal-console that referenced this issue Jul 19, 2017
* [console] Fix package.

* [chain] Improve placeholder definition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants