Skip to content

Commit

Permalink
[generate:entity:content] Fixed coding standard errors (#4070)
Browse files Browse the repository at this point in the history
* [update:execute] Fixed update table

* Revert "Merge remote-tracking branch 'upstream/master'"

This reverts commit ddf7739, reversing
changes made to a95b7e6.

* [generate:entity:content] Fixed coding standard
  • Loading branch information
hjuarez20 authored and enzolutions committed May 30, 2019
1 parent f6981bc commit 4734956
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
6 changes: 2 additions & 4 deletions src/Command/Generate/ControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ protected function execute(InputInterface $input, OutputInterface $output)

$module = $this->validateModule($input->getOption('module'));
$class = $this->validator->validateControllerName($input->getOption('class'));
$this->validator->validateControllerClassExists($class, $module);
$routes = $input->getOption('routes');
$test = $input->getOption('test');
$services = $input->getOption('services');
Expand Down Expand Up @@ -177,9 +176,8 @@ protected function interact(InputInterface $input, OutputInterface $output)
$class = $this->getIo()->ask(
$this->trans('commands.generate.controller.questions.class'),
'DefaultController',
function ($class) use($module) {
$class = $this->validator->validateControllerName($class);
return $this->validator->validateControllerClassExists($class, $module);
function ($class) {
return $this->validator->validateControllerName($class);
}
);
$input->setOption('class', $class);
Expand Down
17 changes: 0 additions & 17 deletions src/Utils/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,6 @@ public function validateControllerName($class_name)
}
}

public function validateControllerClassExists($class_name, $module_name)
{
$class_exists = $this->extensionManager->getModule($module_name)->getControllerPath() . '/' . $class_name . '.php';

if (!$class_exists) {
return $class_name;
} else {
throw new \InvalidArgumentException(
sprintf(
'Controller file with the name "%s.php" is already exist. Enter a different controller class name',
$class_name,
$module_name
)
);
}
}

public function validateMachineName($machine_name)
{
if (preg_match(self::REGEX_MACHINE_NAME, $machine_name)) {
Expand Down
4 changes: 2 additions & 2 deletions templates/module/src/Entity/entity-content.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use Drupal\user\UserInterface;
* "route_provider" = {
* "html" = "Drupal\{{ module }}\{{ entity_class }}HtmlRouteProvider",
* },
{% endif %}
{% endif %}
* "access" = "Drupal\{{ module }}\{{ entity_class }}AccessControlHandler",
* },
* base_table = "{{ entity_name }}",
Expand Down Expand Up @@ -84,7 +84,7 @@ use Drupal\user\UserInterface;
* "published" = "status",
* },
{% if has_forms %}
* links = {
* links = {
* "canonical" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}",
{% if bundle_entity_type %}
* "add-page" = "{{ base_path }}/{{ entity_name }}/add",
Expand Down

0 comments on commit 4734956

Please sign in to comment.