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

feat: one generator command could have multiple views #8119

Merged
merged 3 commits into from
Nov 3, 2023

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Oct 29, 2023

Description
Closes #7524

  • add $templatePath property

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added enhancement PRs that improve existing functionalities 4.5 labels Oct 29, 2023
Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess if the user wants to generate multiple view files it won't help, but the initial issue is fixed.

BTW is there a way to generate multiple view files with the generator right now?

@kenjis
Copy link
Member Author

kenjis commented Oct 31, 2023

You can do it, just repeat something like the following code:

$this->templatePath = config(Generators::class)->views[$this->name]['view'];
$this->template = 'cell_view.tpl.php';
$this->classNameLang = 'CLI.generator.viewName.cell';
$className = $this->qualifyClassName();
$viewName = decamelize(class_basename($className));
$viewName = preg_replace(
'/([a-z][a-z0-9_\/\\\\]+)(_cell)$/i',
'$1',
$viewName
) ?? $viewName;
$namespace = substr($className, 0, strrpos($className, '\\') + 1);
$this->generateView($namespace . $viewName, $params);

@kenjis kenjis merged commit d4388f0 into codeigniter4:4.5 Nov 3, 2023
45 checks passed
@kenjis kenjis deleted the feat-generator-multiple-views branch November 3, 2023 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.5 enhancement PRs that improve existing functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants