@@ -6,61 +6,61 @@ TwitterBootstrapBundle
66##Add theses lines into your deps
77
88```
9- [RuianTwitterBootstrapBundle]
10- git=git://github.com/ruian/TwitterBootstrapBundle.git
11- version=origin/master
12- target=/bundles/Ruian/TwitterBootstrapBundle
13-
14- [TwitterBootstrap1]
15- git=git://github.com/twitter/bootstrap.git
16- target=/twitter/bootstrap/v1/
17- version=origin/master
18-
19- [TwitterBootstrap2]
20- git=git://github.com/twitter/bootstrap.git
21- target=/twitter/bootstrap/v2/
22- version=origin/2.0-wip
23-
24- [lessphp]
25- git=git://github.com/leafo/lessphp.git
26- target=/lessphp/
27- version=origin/master
9+ [RuianTwitterBootstrapBundle]
10+ git=git://github.com/ruian/TwitterBootstrapBundle.git
11+ version=origin/master
12+ target=/bundles/Ruian/TwitterBootstrapBundle
13+
14+ [TwitterBootstrap1]
15+ git=git://github.com/twitter/bootstrap.git
16+ target=/twitter/bootstrap/v1/
17+ version=origin/master
18+
19+ [TwitterBootstrap2]
20+ git=git://github.com/twitter/bootstrap.git
21+ target=/twitter/bootstrap/v2/
22+ version=origin/2.0-wip
23+
24+ [lessphp]
25+ git=git://github.com/leafo/lessphp.git
26+ target=/lessphp/
27+ version=origin/master
2828```
2929
3030##Add autoloading
3131
3232``` php
3333#app/autoload.php
34- <?php
35- $loader->registerNamespaces(array(
36- #...
37- 'Ruian' => __DIR__.'/../vendor/bundles',
38- ));
34+ <?php
35+ $loader->registerNamespaces(array(
36+ #...
37+ 'Ruian' => __DIR__.'/../vendor/bundles',
38+ ));
3939
40- #some code...
40+ #some code...
4141
42- // Add support for lessc
43- require __DIR__.'/../vendor/lessphp/lessc.inc.php';
42+ // Add support for lessc
43+ require __DIR__.'/../vendor/lessphp/lessc.inc.php';
4444
4545```
4646
4747##Register this bundle
4848
4949``` php
5050#app/AppKernel.php
51- <?php
52- $bundles = array(
53- #...
54- new Ruian\TwitterBootstrapBundle\RuianTwitterBootstrapBundle(),
55- );
51+ <?php
52+ $bundles = array(
53+ #...
54+ new Ruian\TwitterBootstrapBundle\RuianTwitterBootstrapBundle(),
55+ );
5656```
5757
5858##Update and install all the deps
5959
6060``` shell
61- ./bin/vendors update
62- or
63- ./bin/vendors install --reinstall
61+ ./bin/vendors update
62+ or
63+ ./bin/vendors install --reinstall
6464```
6565
6666#How to use it ?
6969Remplace VERSION by the supported version you want, v1 or v2
7070
7171``` shell
72- php5 app/console twitter-bootstrap:clear
73- php5 app/console twitter-bootstrap:compile VERSION
74- php5 app/console assets:install web/
72+ php5 app/console twitter-bootstrap:clear
73+ php5 app/console twitter-bootstrap:compile VERSION
74+ php5 app/console assets:install web/
7575```
7676
7777##Add your bootstrap to your layout
7878Remplace VERSION by the supported version you want, v1 or v2
7979
8080``` html
81- <!DOCTYPE html>
82- <html >
83- <head >
84- <title >Twitter Bootstrap</title >
85- <link rel =" stylesheet" type =" text/css" href =" {{ asset('bundles/ruiantwitterbootstrap/css/bootstrapVERSION.css') }}" >
86- </head >
87- <body >
88- <!-- Some code -->
89- <script type =" text/javascript" src =" http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" ></script >
90- <script type =" text/javascript" src =" {{ asset('bundles/ruiantwitterbootstrap/js/bootstrapVERSION.js') }}" ></script >
91- </body >
92- </html >
81+ <!DOCTYPE html>
82+ <html >
83+ <head >
84+ <title >Twitter Bootstrap</title >
85+ <link rel =" stylesheet" type =" text/css" href =" {{ asset('bundles/ruiantwitterbootstrap/css/bootstrapVERSION.css') }}" >
86+ </head >
87+ <body >
88+ <!-- Some code -->
89+ <script type =" text/javascript" src =" http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" ></script >
90+ <script type =" text/javascript" src =" {{ asset('bundles/ruiantwitterbootstrap/js/bootstrapVERSION.js') }}" ></script >
91+ </body >
92+ </html >
9393```
9494
9595##Use bootstrap form style
@@ -103,85 +103,87 @@ Remplace VERSION by the supported version you want, v1 or v2
103103##Example
104104
105105``` html
106- #Ruian/DemoBundle/Resources/view/new.html.twig
107- <!DOCTYPE html>
108- <html >
109- <head >
110- <title >New article</title >
111- <link rel =" stylesheet" type =" text/css" href =" {{ asset('bundles/ruiantwitterbootstrap/css/bootstrapv2.css') }}" >
112- <link rel =" stylesheet" type =" text/css" href =" {{ asset('bundles/ruiantwitterbootstrap/css/bootstrapv2-responsive.css') }}" >
113- </head >
114- <body >
115- <div class =" container" >
116- <div class =" row" >
117- <div class =" offset2 span8" >
118-
119- {% include 'RuianTwitterBootstrapBundle:Alert:bootstrap_v2.html.twig' %}
120-
121- {% form_theme form_view 'RuianTwitterBootstrapBundle:Form:bootstrap_v2.html.twig' %}
122- <form novalidate class =" form-horizontal well" method =" post" action =" {{ path('RuianDemoBundle_new') }}" >
123- {{ form_widget(form_view) }}
124- <div class =" well" >
125- <input type =" submit" value =" Save" class =" btn" />
126- </div >
127- </form >
106+ #Ruian/DemoBundle/Resources/view/new.html.twig
107+
108+ <!DOCTYPE html>
109+ <html >
110+ <head >
111+ <title >New article</title >
112+ <link rel =" stylesheet" type =" text/css" href =" {{ asset('bundles/ruiantwitterbootstrap/css/bootstrapv2.css') }}" >
113+ <link rel =" stylesheet" type =" text/css" href =" {{ asset('bundles/ruiantwitterbootstrap/css/bootstrapv2-responsive.css') }}" >
114+ </head >
115+ <body >
116+ <div class =" container" >
117+ <div class =" row" >
118+ <div class =" offset2 span8" >
119+
120+ {% include 'RuianTwitterBootstrapBundle:Alert:bootstrap_v2.html.twig' %}
121+
122+ {% form_theme form_view 'RuianTwitterBootstrapBundle:Form:bootstrap_v2.html.twig' %}
123+ <form novalidate class =" form-horizontal well" method =" post" action =" {{ path('RuianDemoBundle_new') }}" >
124+ {{ form_widget(form_view) }}
125+ <div class =" well" >
126+ <input type =" submit" value =" Save" class =" btn" />
127+ </div >
128+ </form >
129+ </div >
128130 </div >
129131 </div >
130- </div >
131- <script type =" text/javascript" src =" {{ asset('bundles/ruiandemo/js/jquery.js') }}" ></script >
132- <script type =" text/javascript" src =" {{ asset('bundles/ruiantwitterbootstrap/js/bootstrapv2.js') }}" ></script >
133- </body >
134- </html >
132+ <script type =" text/javascript" src =" {{ asset('bundles/ruiandemo/js/jquery.js') }}" ></script >
133+ <script type =" text/javascript" src =" {{ asset('bundles/ruiantwitterbootstrap/js/bootstrapv2.js') }}" ></script >
134+ </body >
135+ </html >
135136```
136137
137138``` php
138- #Ruian/DemoBundle/Controller/ArticleController.php
139- <?php
140- /**
141- * Controller used for Article
142- *
143- * @author jgalenski
144- */
145- class ArticleController extends Controller
146- {
147- # some code ...
148-
149- public function newAction()
139+ #Ruian/DemoBundle/Controller/ArticleController.php
140+
141+ <?php
142+ /**
143+ * Controller used for Article
144+ *
145+ * @author jgalenski
146+ */
147+ class ArticleController extends Controller
150148 {
151- $entity = new Article();
152- $form = $this->createForm(new ArticleType(), $entity);
153-
154- $request = $this->get('request');
155- if ('POST' === $request->getMethod()) {
156- $form->bindRequest($request);
157- if (true === $form->isValid()) {
158- $em = $this->get('doctrine.orm.default_entity_manager');
159- $em->persist($entity);
160- $em->flush();
161-
162- $this->setFlashSuccess('Congratulation, your article has been saved.');
163- return $this->redirect($this->generateUrl('RuianDemoBundle_new'));
164- } else {
165- $this->setFlashError('Warning, your article can\'t be saved due to some errors.');
149+ # some code ...
150+
151+ public function newAction()
152+ {
153+ $entity = new Article();
154+ $form = $this->createForm(new ArticleType(), $entity);
155+
156+ $request = $this->get('request');
157+ if ('POST' === $request->getMethod()) {
158+ $form->bindRequest($request);
159+ if (true === $form->isValid()) {
160+ $em = $this->get('doctrine.orm.default_entity_manager');
161+ $em->persist($entity);
162+ $em->flush();
163+
164+ $this->setFlashSuccess('Congratulation, your article has been saved.');
165+ return $this->redirect($this->generateUrl('RuianDemoBundle_new'));
166+ } else {
167+ $this->setFlashError('Warning, your article can\'t be saved due to some errors.');
168+ }
166169 }
170+
171+ return $this->render('RuianDemoBundle:Article:new.html.twig', array(
172+ 'form_view' => $form->createView(),
173+ ));
167174 }
168175
169- return $this->render('RuianDemoBundle:Article:new.html.twig', array(
170- 'form_view' => $form->createView(),
171- ) );
172- }
176+ protected function setFlashSuccess($message)
177+ {
178+ $this->get('session')->setFlash('alert-success', $message );
179+ }
173180
174- protected function setFlashSuccess ($message)
175- {
176- $this->get('session')->setFlash('alert-success ', $message);
177- }
181+ protected function setFlashError ($message)
182+ {
183+ $this->get('session')->setFlash('alert-error ', $message);
184+ }
178185
179- protected function setFlashError($message)
180- {
181- $this->get('session')->setFlash('alert-error', $message);
186+ # some code ...
182187 }
183188
184- # some code ...
185- }
186-
187189```
0 commit comments