comparison vendor/chi-teck/drupal-code-generator/src/Command/BaseGenerator.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
301 * The answer. 301 * The answer.
302 * 302 *
303 * @see \DrupalCodeGenerator\InputHandler::collectVars() 303 * @see \DrupalCodeGenerator\InputHandler::collectVars()
304 */ 304 */
305 protected function ask(InputInterface $input, OutputInterface $output, Question $question, array $vars = []) { 305 protected function ask(InputInterface $input, OutputInterface $output, Question $question, array $vars = []) {
306 $answers = $this->getHelper('dcg_input_handler')->collectVars($input, $output, ['key' => $question], $vars); 306 $key = mt_rand();
307 return $answers['key']; 307 $answers = $this->getHelper('dcg_input_handler')->collectVars($input, $output, [$key => $question], $vars);
308 return $answers[$key];
308 } 309 }
309 310
310 /** 311 /**
311 * Creates an asset. 312 * Creates an asset.
312 * 313 *
323 } 324 }
324 325
325 /** 326 /**
326 * Creates file asset. 327 * Creates file asset.
327 * 328 *
329 * @param string $path
330 * (Optional) File path.
331 *
328 * @return \DrupalCodeGenerator\Asset 332 * @return \DrupalCodeGenerator\Asset
329 * The asset. 333 * The asset.
330 */ 334 */
331 protected function addFile() { 335 protected function addFile($path = NULL) {
332 return $this->addAsset('file'); 336 return $this->addAsset('file')->path($path);
333 } 337 }
334 338
335 /** 339 /**
336 * Creates directory asset. 340 * Creates directory asset.
341 *
342 * @param string $path
343 * (Optional) Directory path.
337 * 344 *
338 * @return \DrupalCodeGenerator\Asset 345 * @return \DrupalCodeGenerator\Asset
339 * The asset. 346 * The asset.
340 */ 347 */
341 protected function addDirectory() { 348 protected function addDirectory($path = NULL) {
342 return $this->addAsset('directory'); 349 return $this->addAsset('directory')->path($path);
343 } 350 }
344 351
345 /** 352 /**
346 * Creates service file asset. 353 * Creates service file asset.
354 *
355 * @param string $path
356 * (Optional) File path.
347 * 357 *
348 * @return \DrupalCodeGenerator\Asset 358 * @return \DrupalCodeGenerator\Asset
349 * The asset. 359 * The asset.
350 */ 360 */
351 protected function addServicesFile() { 361 protected function addServicesFile($path = NULL) {
352 return $this->addFile() 362 return $this->addFile()
353 ->path('{machine_name}.services.yml') 363 ->path($path ?: '{machine_name}.services.yml')
354 ->action('append') 364 ->action('append')
355 ->headerSize(1); 365 ->headerSize(1);
356 } 366 }
357 367
358 /** 368 /**