-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSilexProof.php
55 lines (46 loc) · 1.53 KB
/
SilexProof.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Plugin Name: Silex Proof
* Description: Silex Proof of Concept as a micro framework for developping a .... a WordPress plugin!
* Version: 1.0
* Author: .Fay Labs
*/
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Silex\Application;
use Silex\Provider\MonologServiceProvider;
use SilexProof\SettingsProvider;
use SilexProof\Events;
use SilexProof\SettingsEvent;
use Silex\Provider\TwigServiceProvider;
use SilexProof\SomeService;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
require_once __DIR__.'/vendor/autoload.php';
$app = new Application();
$app['debug'] = false;
$request = Request::createFromGlobals();
$app['request'] = $request;
$app->register(new MonologServiceProvider(), array(
'monolog.logfile' => __DIR__.'/dev.log',
));
$app->register(new TwigServiceProvider(), array(
'twig.path' => __DIR__.'/views',
));
$app->register(new SettingsProvider());
$app->register(new SomeService());
//Just to get ride from an ugly exception in my pretty log
$app->match('/', function () use ($app) {
return new Response();
});
//Manual app->run()
$app->handle($request);
//WP actions
add_action('wp_ajax_my_ajax', array($app['some_service'], 'sayHello'));
if (!$request->isXmlHttpRequest()) {
add_action('admin_menu', array($app['settings_provider'], 'registerPage'));
/**
* @var EventDispatcherInterface $dispatcher
*/
$dispatcher = $app['dispatcher'];
$dispatcher->dispatch(Events::SETTING_PAGE_RENDERED, new SettingsEvent('WP!!!!'));
}