Beispiel #1
0
 /**
  * Forgery constructor
  *
  * @param string $entity
  */
 public function __forge($entity)
 {
     $this->entity = $entity;
     $this->scaffold = \Magelight\Admin\Models\Scaffold\Scaffold::forge();
     $this->scaffold->loadEntities();
     $this->setConfigs('scaffold-' . $entity, $this->url(self::URL_PATTERN, ['entity' => $entity]));
     $this->setHorizontal();
     $fieldSet = \Magelight\Webform\Blocks\Fieldset::forge();
     $this->model = $this->scaffold->getEntityModel($this->entity);
     foreach ($this->scaffold->getEntityFields($this->entity) as $field) {
         $fieldConfig = $this->scaffold->getEntityFieldConfig($this->entity, $field);
         $row = \Magelight\Webform\Blocks\Row::forge();
         /** @var $fieldInput  \Magelight\Webform\Blocks\Elements\Input */
         $fields = [];
         $fieldInput = self::callStaticLate([(string) $fieldConfig->class, 'forge']);
         $fieldInput->setName($field);
         $label = !empty($fieldConfig->label) ? (string) $fieldConfig->label : $field;
         $hint = !empty($fieldConfig->hint) ? (string) $fieldConfig->hint : '';
         $fields[] = $fieldInput;
         if ((bool) (string) $fieldConfig->allow_null) {
             $checkboxNull = \Magelight\Webform\Blocks\Elements\LabeledCheckbox::forge();
             $checkboxNull->setName("set-null[{$field}]");
             $checkboxNull->setContent('Set NULL');
             $fields[] = $checkboxNull;
         }
         $row->addField($fields, $label, $hint);
         $fieldSet->addRow($row);
     }
     $this->addFieldset($fieldSet);
     $this->createResultRow(true);
     $this->addButtonsRow([\Magelight\Webform\Blocks\Elements\Button::forge()->setType('submit')->setContent('Save')]);
 }
Beispiel #2
0
 /**
  * Get entity collection
  *
  * @return \Magelight\Db\Collection
  */
 public function getCollection()
 {
     return \Magelight\Db\Collection::forge($this->scaffold->getEntityModel($this->entity)->getOrm())->setLimit(10)->setPage($this->page);
 }