public function testCreateViaForm() { $code = $this->fixCompile($this->compiler); eval($code); /** @var \Nette\DI\Container $container */ $container = new \Container(); $container->initialize(); $form = new \Nette\Forms\Container(); $this->assertInstanceOf('WebChemistry\\Forms\\Controls\\Multiplier', $form->addMultiplier('multiplier', function () { })); $form = new \Nette\Forms\Form(); $this->assertInstanceOf('WebChemistry\\Forms\\Controls\\Multiplier', $form->addMultiplier('multiplier', function () { })); }
* @param string * @param int plural form (positive number) * @param array for vsprintf * @return string */ function _nx($single, $plural, $number, array $args) { // trigger_error(__FUNCTION__ . '() is deprecated; use __(array(\$single, \$plural), array(\$number, $args[0], $args[1], ...) instead.', E_USER_DEPRECATED); return Nette\Environment::getService('translator')->translate(array($single, $plural), array_merge(array($number), $args)); } // ----------------------------------------------------------------------------- // Extension methods // ----------------------------------------------------------------------------- Nette\Application\UI\Form::extensionMethod('loadFromEntity', 'vBuilder\\Orm\\FormHelper::loadFromEntity'); Nette\Application\UI\Form::extensionMethod('fillInEntity', 'vBuilder\\Orm\\FormHelper::fillInEntity'); Nette\Forms\Container::extensionMethod('addBootstrapSelect', 'vBuilder\\Forms\\Controls\\BootstrapSelect::addToContainer'); // ----------------------------------------------------------------------------- // Some predefines Route classes // ----------------------------------------------------------------------------- Route::addStyle('#month'); /// @todo this should accept all translations (because we don't know the language yet) Route::setStyleProperty('#month', Route::FILTER_IN, function ($val) { if (preg_match('/^([a-z]+)-([1-9][0-9]{3})/i', $val, $m)) { $months = array_flip(array_map('Nette\\Utils\\Strings::webalize', vBuilder\Utils\DateTime::monthName())); if (isset($months[$m[1]])) { return $m[2] . '-' . str_pad($months[$m[1]], 2, "0", STR_PAD_LEFT); } } return NULL; }); // This knows the language so it's ok
return $s; }); $configurator->container->addService('authenticator', function ($cont) { return new \Authenticator($cont->database); }); $routes = $configurator->container->params['routes']; // Configure application $application = $configurator->container->application; $application->errorPresenter = 'Error'; //$application->catchExceptions = TRUE; // Setup router $application->onStartup[] = function () use($application, $routes) { $router = $application->getRouter(); foreach ($routes as $route) { $metadata = \FlatArray::toArray($route['metadata']); $router[] = new Route("//{$route['prefix']}/index.php", $metadata, Route::ONE_WAY); $mask = "//{$route['prefix']}/<presenter>/<action>[/<id>]"; if ($route['secured']) { $router[] = new Route($mask, $metadata, Route::SECURED); } else { $router[] = new Route($mask, $metadata); } } }; Nette\Forms\Container::extensionMethod('addDatePicker', function ($container, $name, $label = NULL) { return $container[$name] = new Forms\Controls\DatePicker($label); }); // Run the application! if (!$configurator->container->params['consoleMode']) { $application->run(); }
$configurator->enableDebugger(__DIR__ . '/../log'); //\Nette\Diagnostics\Debugger::enable(\Nette\Diagnostics\Debugger::DEVELOPMENT); // Enable RobotLoader - this will load all classes automatically $configurator->setTempDirectory(__DIR__ . '/../temp'); $configurator->createRobotLoader()->addDirectory(APP_DIR)->addDirectory(LIBS_DIR)->register(); $configurator->onCompile[] = function ($configurator, $compiler) { $compiler->addExtension('ajax', new VojtechDobes\NetteAjax\Extension()); }; $webloaderExtension = new \WebLoader\Nette\Extension(); $webloaderExtension->install($configurator); // Create Dependency Injection container from config.neon file $configurator->addConfig(__DIR__ . '/config/config.neon'); $container = $configurator->createContainer(); //Vodacek\Forms\Controls\DateInput::register(); Nette\Forms\Container::extensionMethod('addDatePicker', function (Nette\Forms\Container $container, $name, $label = NULL) { return $container[$name] = new JanTvrdik\Components\DatePicker($label); }); // get list of existing pages from configuration $existingPages = implode('|', array_keys($container->parameters['pageLayout'])); // Setup router $container->router[] = new Route('index.php', 'Homepage:default', Route::ONE_WAY); $container->router[] = new Route('', 'Homepage:default'); $container->router[] = new Route('style[/<item>]', 'Style:default'); if ($existingPages != "") { // this one route is for backward compatibility with old edit link format from emails $container->router[] = new Route('<item ' . $existingPages . '>/edit.php', 'Edit:default', Route::ONE_WAY); $container->router[] = new Route('<item ' . $existingPages . '>/novy_zaznam/', 'Item:new'); $container->router[] = new Route('<item ' . $existingPages . '>/[<vc-filter>/][strana/<vp-page>/][razeni/<vc-orderBy>/[<vc-order>/]]', 'Item:default'); } $container->router[] = new Route('kalendar/<page>/[<vc-filter>/][mesic/<calendar-year>/<calendar-month>/[<do>/]]', array('presenter' => 'Calendar', 'action' => 'default', 'do' => array(Route::VALUE => NULL, Route::FILTER_TABLE => array('zmen' => 'calendar-changeMonth')))); $container->router[] = new Route('<presenter>/<action>[/<hash>]', 'Homepage:default');