class GetValueCommand in Config Pages 8.3
Same name and namespace in other branches
- 8.2 src/Command/GetValueCommand.php \Drupal\config_pages\Command\GetValueCommand
Class GetValueCommand.
@DrupalCommand ( extension="config_pages", extensionType="module" )
Hierarchy
- class \Drupal\config_pages\Command\GetValueCommand extends \Drupal\Console\Core\Command\ContainerAwareCommand
Expanded class hierarchy of GetValueCommand
1 string reference to 'GetValueCommand'
1 service uses GetValueCommand
File
- src/
Command/ GetValueCommand.php, line 20
Namespace
Drupal\config_pages\CommandView source
class GetValueCommand extends ContainerAwareCommand {
/**
* @var \Drupal\Core\Logger\LoggerChannelInterface
*/
protected $logger;
/**
* Constructs a new GetValueCommand object.
* @param LoggerChannelFactoryInterface $loggerChannelFactory
*/
public function __construct(LoggerChannelFactoryInterface $loggerChannelFactory) {
$this->logger = $loggerChannelFactory
->get('config_pages');
parent::__construct();
}
/**
* {@inheritdoc}
*/
protected function configure() {
$this
->setName('config_pages:get_value')
->setDescription($this
->trans('commands.config_pages.get_value.description'))
->addArgument('bundle', InputArgument::REQUIRED, $this
->trans('commands.user.login.url.options.bundle'), NULL)
->addArgument('field_name', InputArgument::REQUIRED, $this
->trans('commands.user.login.url.options.field_name'), NULL)
->addArgument('context', InputArgument::OPTIONAL, $this
->trans('commands.user.login.url.options.context'), NULL)
->setAliases([
'cpgfv',
]);
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) {
$bundle = $input
->getArgument('bundle');
$field_name = $input
->getArgument('field_name');
$context = $input
->getArgument('context');
try {
$config_page = config_pages_config($bundle, $context);
if (!empty($config_page)) {
$output
->writeln($config_page
->get($field_name)->value);
}
} catch (\Exception $e) {
$this->logger
->error($e
->getMessage());
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GetValueCommand:: |
protected | property | ||
GetValueCommand:: |
protected | function | ||
GetValueCommand:: |
protected | function | ||
GetValueCommand:: |
public | function | Constructs a new GetValueCommand object. |