Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FactoryGenerator.php
Go to the documentation of this file.
1 <?php
8 
10 
15 {
22  public function generate($className)
23  {
24  if (!$this->isFactory($className)) {
25  return false;
26  }
27  $methods = [[
28  'name' => 'create',
29  'parameters' => [['name' => 'data', 'type' => 'array', 'defaultValue' => []]],
30  'body' => '',
31  ]];
32  $classGenerator = new ClassGenerator();
33  $classGenerator->setName($className)
34  ->addMethods($methods);
35  return $classGenerator->generate();
36  }
37 
44  private function isFactory($className)
45  {
46  $sourceName = rtrim(substr($className, 0, -strlen('Factory')), '\\');
47  return $sourceName . 'Factory' == $className;
48  }
49 }
$methods
Definition: billing.phtml:71
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31