diff --git a/core/command/ContentTypeCreateCmd.php b/core/command/ContentTypeCreateCmd.php index ea1c588..d014de1 100644 --- a/core/command/ContentTypeCreateCmd.php +++ b/core/command/ContentTypeCreateCmd.php @@ -83,11 +83,17 @@ protected function configure() { 'commands.create.content-type.options.description' ) ->addOption( - 'entity_support', - '', - InputOption::VALUE_REQUIRED, - 'commands.create.content-type.options.entity_support' + 'entity_support', + '', + InputOption::VALUE_REQUIRED, + 'commands.create.content-type.options.entity_support' ) + ->addOption( + 'token_support', + '', + InputOption::VALUE_REQUIRED, + 'commands.create.content-type.options.token_support' + ) ->addOption( 'fields', '', @@ -113,11 +119,13 @@ protected function execute(InputInterface $input, OutputInterface $output) { $lable_name = $ct_cache['lable_name']; $description = $ct_cache['description']; $entity_support = (bool) $ct_cache['entity_support']; + $token_support = (bool) $ct_cache['token_support']; $fields = $ct_cache['fields']; }else { $lable_name = $input->getOption('lable_name'); $description = $input->getOption('description'); $entity_support = (bool) $input->getOption('entity_support'); + $token_support = (bool) $input->getOption('token_support'); $fields = $input->getOption('fields'); } @@ -138,6 +146,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { '--create-composer' => FALSE, 'isContentType' => TRUE, 'supportEntity' => $entity_support, + 'supportToken' => $token_support, 'fields' => $fields, ); @@ -286,6 +295,14 @@ protected function interact(InputInterface $input, OutputInterface $output) { $input->setOption('entity_support', $entity_support); } + // --support token option + $token_support = $input->getOption('token_support'); + if (!$token_support) { + $token_support_question = new ConfirmationQuestion('Enable support Token (y/n) [No]? ', FALSE); + $token_support = $helper->ask($input, $output, $token_support_question); + $input->setOption('token_support', $token_support); + } + // --fields option $fields = $input->getOption('fields'); if (!$fields) { @@ -445,6 +462,7 @@ protected function interact(InputInterface $input, OutputInterface $output) { 'lable_name' => $lable_name, 'description' => $description, 'entity_support' => $entity_support, + 'token_support' => $token_support, 'fields' => $fields ); diff --git a/core/command/ModuleCreateCmd.php b/core/command/ModuleCreateCmd.php index 5b731b8..a227e90 100644 --- a/core/command/ModuleCreateCmd.php +++ b/core/command/ModuleCreateCmd.php @@ -119,6 +119,11 @@ protected function configure() { InputArgument::OPTIONAL, 'Is this suppport entity?' ) + ->addArgument( + 'supportToken', + InputArgument::OPTIONAL, + 'Is this suppport token?' + ) ->addArgument( 'fields', InputArgument::OPTIONAL, @@ -143,6 +148,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $create_composer = $input->getOption('create-composer'); $isContentType = $input->getArgument('isContentType'); $supportEntity = $input->getArgument('supportEntity'); + $supportToken = $input->getArgument('supportToken'); $fields = $input->getArgument('fields'); $dir .= '/'.$machineName; @@ -184,6 +190,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { 'dependencies' => $dependencies, 'isContentType' => $isContentType, 'supportEntity' => $supportEntity, + 'supportToken' => $supportToken, 'fields' => $fields ); diff --git a/core/command/templates/module.html b/core/command/templates/module.html index 4c0461d..d096713 100644 --- a/core/command/templates/module.html +++ b/core/command/templates/module.html @@ -15,6 +15,45 @@ } + +/** + * Implements hook_tokens(). + */ +function _tokens($type, $tokens, array $data = [], array $options = []) { + $replacements = array(); + if ($type == '') { + $ = reset($data); + foreach ($tokens as $name => $original) { + switch ($name) { + case 'id': + $replacements[$original] = $->id; + break; + + + case '': + $replacements[$original] = $->; + break; + + + case 'uid': + $replacements[$original] = $->uid; + break; + + case 'created': + $replacements[$original] = date("Y-m-d H:i:s", $->created); + break; + + case 'updated': + $replacements[$original] = date("Y-m-d H:i:s", $->updated); + break; + } + } + } + + return $replacements; +} + + /** * get by id */