<?php /** * Do not edit this file. If you need to do any framework bootstrapping you should * do it in the bootstrap.php file that lives within the application directory. */ // Aliasing rules use Nerd\Autoloader; // Definitions define('DS', DIRECTORY_SEPARATOR); define('LIBRARY_PATH', dirname(__DIR__)); define('VENDOR_PATH', dirname(LIBRARY_PATH) . '/vendor'); define('DOCROOT', dirname(LIBRARY_PATH) . '/public'); /** * Get and register the Nerd autoloader. */ require LIBRARY_PATH . '/nerd/classes/autoloader.php'; Autoloader::register(); /** * Test for CLI, load either application or Geek bootstrap. */ if (PHP_SAPI === 'cli') { require LIBRARY_PATH . DS . 'geek/bootstrap.php'; } else { require LIBRARY_PATH . DS . 'application/bootstrap.php'; }
/** * @covers \Nerd\Autoloader::unregister */ public function testAutoloaderUnregister() { $this->assertTrue(Autoloader::unregister()); }
/** * Provides the most *basic* form for a given model. This doesn't do much to figure * out what fields to use, and where to put them, but it does provide _very_ basic * scaffolding to get you up an running. * * [!!] In most instances you will wish to overload this method. * * @param \Nerd\Form Form instance to attach fields to, if null one is created * @return \Nerd\Form Form instance */ public function form(Form $form = null) { $form === null and $form = (new Form())->method('post'); $class = strtolower(Autoloader::denamespace(get_class($this))); $fieldset = $form->fieldset(); self::$columns->each(function ($column) use(&$form, &$fieldset, $class) { $type = 'text'; if ($column->is(Column::TYPE_DATE)) { $type = "datetime"; } elseif ($column->is(Column::TYPE_TEXT)) { $type = 'textarea'; } elseif ($column->is(Column::TYPE_TINYINT) and $column->constraint == 1) { $type = 'select'; } elseif ($column->is(Column::TYPE_NUMBER)) { $type = 'number'; } elseif ($column->is(Column::TYPE_ENUM)) { $type = 'select'; } if ($column->automatic) { $type = 'hidden'; } $field = $form->field($type, ['name' => "{$class}[{$column->field}]", 'id' => "{$class}_{$column->field}"], null); isset($this->_values[$column->field]) and $field->value($this->_values[$column->field]); if ($type === 'select') { if ($column->constraint == 1) { $field->options = [0 => 'false', 1 => 'true']; } else { $field->options = $column->options(); } if (isset($this->_values[$column->field])) { $field->selected = $this->_values[$column->field]; } } $field->label(Str::humanize($column->field)); if ($column->automatic) { $field->wrap(false)->wrapField(false); $field->label = null; } if ($type === 'text') { $field->maxlength($column->constraint); } if (!$column->nullable and !$type === 'datetime') { $field->required(true); } $fieldset->field($field); }); return $form; }
<?php /** * Do not edit this file. If you need to do any framework bootstrapping you should * do it in the bootstrap.php file that lives within the application directory. */ // Aliasing rules use Nerd\Autoloader; define('DS', DIRECTORY_SEPARATOR); define('LIBRARY_PATH', dirname(dirname(__DIR__))); define('VENDOR_PATH', dirname(LIBRARY_PATH) . DS . 'vendor'); define('DOCROOT', dirname(LIBRARY_PATH) . DS . 'public'); /** * Get and register the Nerd autoloader. */ require join(DS, [LIBRARY_PATH, 'nerd', 'classes', 'autoloader.php']); Autoloader::register(true);