1 <?php
2
3 /*
4 * This file is part of the Icybee package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Icybee;
13
14 /**
15 * Path to the directory of the Icybee package.
16 *
17 * The path includes a trailing directory separator.
18 *
19 * @var string
20 */
21 define('Icybee\DIR', rtrim(__DIR__, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
22
23 /**
24 * Assets path for the Icybee package.
25 *
26 * @var string
27 */
28 define('Icybee\ASSETS', DIR . 'assets' . DIRECTORY_SEPARATOR);
29
30 /**
31 * Operation save mode constants.
32 *
33 * @var string
34 */
35 const OPERATION_SAVE_MODE = '_operation_save_mode';
36 const OPERATION_SAVE_MODE_CONTINUE = 'continue';
37 const OPERATION_SAVE_MODE_LIST = 'list';
38 const OPERATION_SAVE_MODE_NEW = 'new';
39 const OPERATION_SAVE_MODE_DISPLAY = 'display';
40
41 /**
42 * Starts Icybee.
43 *
44 * The function instantiates a {@link Core} instance with the ICanBoogie's auto-config and patches
45 * the following helpers:
46 *
47 * - ICanBoogie\I18n\get_cldr
48 * - Brickrouge\t
49 * - Brickrouge\render_exception
50 * - Brickrouge\get_document
51 * - Brickrouge\check_session
52 *
53 * <pre>
54 * <?php
55 *
56 * // index.php
57 *
58 * $core = Icybee\start();
59 * $request = $core();
60 * $response = $request();
61 * $response();
62 * </pre>
63 *
64 * @return \Icybee\Core
65 */
66 function start()
67 {
68 /**
69 * The core instance is the heart of the ICanBoogie framework.
70 *
71 * @var Core
72 */
73 $core = new Core( \ICanBoogie\get_autoconfig() );
74
75 \ICanBoogie\I18n\Helpers::patch('get_cldr', function() use($core) { return $core->cldr; });
76
77 \Brickrouge\Helpers::patch('t', 'ICanBoogie\I18n\t');
78 \Brickrouge\Helpers::patch('render_exception', 'ICanBoogie\Debug::format_alert');
79 \Brickrouge\Helpers::patch('get_document', function() use($core) { return $core->document; });
80 \Brickrouge\Helpers::patch('check_session', function() use($core) { return $core->session; });
81
82 return $core;
83 }
84
85 /*
86 * Helpers
87 */
88 require_once DIR . 'lib/helpers.php';
89 require_once DIR . 'lib/helpers-compat.php';