mirror of
https://github.com/moparisthebest/wallabag
synced 2024-12-18 05:32:23 -05:00
[add] preparing to poche a new link
This commit is contained in:
parent
5da399d98e
commit
f0a5115a23
@ -2,6 +2,8 @@
|
|||||||
use Knp\Provider\ConsoleServiceProvider;
|
use Knp\Provider\ConsoleServiceProvider;
|
||||||
use Poche\Api\EntryApi;
|
use Poche\Api\EntryApi;
|
||||||
|
|
||||||
|
use Silex\Provider\FormServiceProvider;
|
||||||
|
|
||||||
$app = new Silex\Application();
|
$app = new Silex\Application();
|
||||||
|
|
||||||
$app->register(new Silex\Provider\TwigServiceProvider(), array(
|
$app->register(new Silex\Provider\TwigServiceProvider(), array(
|
||||||
@ -25,6 +27,12 @@ $app->register(new Silex\Provider\DoctrineServiceProvider(), array(
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$app->register(new FormServiceProvider());
|
||||||
|
|
||||||
|
$app->register(new Silex\Provider\TranslationServiceProvider(), array(
|
||||||
|
'translator.messages' => array(),
|
||||||
|
));
|
||||||
|
|
||||||
$app['entry_api'] = $app->share(function ($app) {
|
$app['entry_api'] = $app->share(function ($app) {
|
||||||
return new EntryApi($app['db']);
|
return new EntryApi($app['db']);
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
use Poche\Model\Entry;
|
use Poche\Model\Entry;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
$front = $app['controllers_factory'];
|
$front = $app['controllers_factory'];
|
||||||
$front->get('/', function () use ($app) {
|
$front->get('/', function () use ($app) {
|
||||||
|
|
||||||
@ -9,4 +11,25 @@ $front->get('/', function () use ($app) {
|
|||||||
return $app['twig']->render('index.twig', array('entry' => $entry));
|
return $app['twig']->render('index.twig', array('entry' => $entry));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$front->match('/add', function (Request $request) use ($app) {
|
||||||
|
$data = array('url');
|
||||||
|
|
||||||
|
$form = $app['form.factory']->createBuilder('form', $data)
|
||||||
|
->add('url')
|
||||||
|
->getForm();
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isValid()) {
|
||||||
|
$data = $form->getData();
|
||||||
|
|
||||||
|
// do something with the url
|
||||||
|
|
||||||
|
return $app->redirect('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
// display the form
|
||||||
|
return $app['twig']->render('add.twig', array('form' => $form->createView()));
|
||||||
|
});
|
||||||
|
|
||||||
return $front;
|
return $front;
|
||||||
|
11
app/views/add.twig
Normal file
11
app/views/add.twig
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{% extends layout %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<form action="#" method="post">
|
||||||
|
{{ form_widget(form) }}
|
||||||
|
|
||||||
|
<input type="submit" name="submit" />
|
||||||
|
</form>
|
||||||
|
<p><a href="/">back to home</a></p>
|
||||||
|
{% endblock %}
|
@ -1,6 +1,6 @@
|
|||||||
{% extends layout %}
|
{% extends layout %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
Poche v2<br/>
|
|
||||||
{{ entry.id }} - {{ entry.title }}
|
{{ entry.id }} - {{ entry.title }}
|
||||||
|
<p><a href="index.php/add">poche a new link</a></p>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -6,7 +6,12 @@
|
|||||||
"symfony/twig-bridge": "~2.3",
|
"symfony/twig-bridge": "~2.3",
|
||||||
"knplabs/console-service-provider": "dev-master",
|
"knplabs/console-service-provider": "dev-master",
|
||||||
"doctrine/dbal": "2.2.*",
|
"doctrine/dbal": "2.2.*",
|
||||||
"symfony/browser-kit": ">=2.3,<2.4-dev"
|
"symfony/browser-kit": ">=2.3,<2.4-dev",
|
||||||
|
"symfony/form": "~2.3",
|
||||||
|
"symfony/validator": "~2.3",
|
||||||
|
"symfony/config": "~2.3",
|
||||||
|
"symfony/translation": "~2.3",
|
||||||
|
"symfony/locale": "~2.3"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": { "Poche\\": "src/" }
|
"psr-0": { "Poche\\": "src/" }
|
||||||
|
Loading…
Reference in New Issue
Block a user