/** * @param Pimple\Container $container [description] */ public function register(Container $container) { parent::register($container); /* * Inject app config */ $container['config'] = function ($c) { $configuration = new Configuration(); if (false !== $configuration->load()) { return $configuration->getConfiguration(); } else { throw new NoConfigurationFoundException(); } }; return $container; }
/** * Build forms * @param Symfony\Component\HttpFoundation\Request $request * @param RZ\Roadiz\Console\Tools\Configuration $conf * * @return Symfony\Component\Form\Forms */ protected function buildDatabaseForm(Request $request, Configuration $conf) { if (isset($conf->getConfiguration()['doctrine'])) { $defaults = $conf->getConfiguration()['doctrine']; } else { $defaults = []; } $builder = $this->createFormBuilder($defaults)->add('driver', 'choice', ['choices' => ['pdo_mysql' => 'pdo_mysql', 'pdo_pgsql' => 'pdo_pgsql', 'pdo_sqlite' => 'pdo_sqlite', 'oci8' => 'oci8'], 'label' => $this->getTranslator()->trans('driver'), 'constraints' => [new NotBlank()], 'attr' => ["id" => "choice"]])->add('host', 'text', ["required" => false, 'label' => $this->getTranslator()->trans('host'), 'attr' => ["autocomplete" => "off", 'id' => "host"]])->add('port', 'integer', ["required" => false, 'label' => $this->getTranslator()->trans('port'), 'attr' => ["autocomplete" => "off", 'id' => "port"]])->add('unix_socket', 'text', ["required" => false, 'label' => $this->getTranslator()->trans('unix_socket'), 'attr' => ["autocomplete" => "off", 'id' => "unix_socket"]])->add('path', 'text', ["required" => false, 'label' => $this->getTranslator()->trans('path'), 'attr' => ["autocomplete" => "off", 'id' => "path"]])->add('user', 'text', ['attr' => ["autocomplete" => "off", 'id' => "user"], 'label' => $this->getTranslator()->trans('username'), 'constraints' => [new NotBlank()]])->add('password', 'password', ["required" => false, 'label' => $this->getTranslator()->trans('password'), 'attr' => ["autocomplete" => "off", 'id' => 'password']])->add('dbname', 'text', ["required" => false, 'label' => $this->getTranslator()->trans('dbname'), 'attr' => ["autocomplete" => "off", 'id' => 'dbname']]); return $builder->getForm(); }