Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PatternGenerator.php
Go to the documentation of this file.
1 <?php
7 
19 {
23  private $template;
24 
28  private $requiredParams;
29 
36  public function __construct($template, array $requiredParams = [])
37  {
38  $this->template = $template;
39  $this->requiredParams = $requiredParams;
40  }
41 
45  public function generate(array $data)
46  {
47  $placeholders = [];
48  foreach ($this->requiredParams as $param) {
49  if (empty($data[$param])) {
50  throw new GeneratorException(__('The "%1" should not be empty.', $param));
51  }
52  $placeholders[] = $data[$param];
53  }
54  return __($this->template, ...$placeholders);
55  }
56 }
__()
Definition: __.php:13