Esempio n. 1
0
 /**
  * @param string $className
  * @return mixed
  */
 protected function getObject($className)
 {
     if (empty($className) || !is_string($className)) {
         throw new \RuntimeException('Invalid class name');
     }
     if (!class_exists($className)) {
         return null;
     }
     return $this->factory->factory($className);
 }
Esempio n. 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $object = $this->factory->factory($input->getArgument('class'));
     if ($object instanceof ConfigurableInterface) {
         $elementFactory = new Form\ElementFactory($this->actionRepository, $this->connectionRepository);
         $builder = new Form\Builder();
         $object->configure($builder, $elementFactory);
         $fields = $builder->getForm();
         $rows = [];
         foreach ($fields->getElements() as $element) {
             $type = substr(strrchr(get_class($element), '\\'), 1);
             $details = $this->getDetails($element);
             if (strlen($details) > 32) {
                 $details = substr($details, 0, 32) . ' [...]';
             }
             $rows[] = [$element->name, $type, $details];
         }
         $table = new Table($output);
         $table->setHeaders(['Name', 'Type', 'Details'])->setRows($rows);
         $table->render($output);
     } else {
         $output->writeln('The object is not configurable');
     }
 }