Esempio n. 1
0
 /**
  * @param InputInterface $input
  * @return array
  */
 private function getFilter($input)
 {
     $filter = array();
     $filter['all'] = $input->getOption('all') ? true : false;
     $filter['unused'] = $input->getOption('unused') ? true : false;
     $filter['template'] = $input->getOption('template') ? $input->getOption('template') : '';
     $filter['tag'] = $input->getOption('tag') ? $input->getOption('tag') : '';
     $filter['type'] = $input->getOption('type') ? PwTools::getProperFieldtypeName($input->getOption('type')) : '';
     return (object) $filter;
 }
Esempio n. 2
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::bootstrapProcessWire($output);
     $name = $input->getArgument('name');
     $label = $input->getOption('label') !== "" ? $input->getOption('label') : $name;
     $type = PwTools::getProperFieldtypeName($input->getOption('type'));
     $check = $this->checkFieltype($type);
     if ($check === true) {
         $field = new Field();
         $field->type = \ProcessWire\wire('modules')->get($type);
         $field->name = $name;
         $field->label = $label;
         $field->description = $input->getOption('desc');
         if ($input->getOption('tag')) {
             $field->tags = $input->getOption('tag');
         }
         $field->save();
         $output->writeln("<info>Field '{$name}' ({$type}) created successfully!</info>");
     } else {
         $output->writeln("<error>This fieldtype `{$type}` does not exists.</error>");
     }
 }