setValidator(function ($value) { if (!preg_match('/^[a-z][a-z0-9_\.]*[a-z0-9]$/', $value)) { throw new \UnexpectedValueException('The value is not correct service name.'); } return $value; }); $default_class = function ($vars) { return Utils::camelize($vars['service_name']); }; $questions['class'] = new Question('Class', $default_class); $this->collectVars($input, $output, $questions); $this->addFile() ->path('src/{class}.php') ->template('d8/service/custom.twig'); $this->addServicesFile() ->template('d8/service/custom.services.twig'); } }