1: <?php
2: /*************************************************************************************/
3: /* */
4: /* Thelia */
5: /* */
6: /* Copyright (c) OpenStudio */
7: /* email : info@thelia.net */
8: /* web : http://www.thelia.net */
9: /* */
10: /* This program is free software; you can redistribute it and/or modify */
11: /* it under the terms of the GNU General Public License as published by */
12: /* the Free Software Foundation; either version 3 of the License */
13: /* */
14: /* This program is distributed in the hope that it will be useful, */
15: /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
16: /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
17: /* GNU General Public License for more details. */
18: /* */
19: /* You should have received a copy of the GNU General Public License */
20: /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
21: /* */
22: /*************************************************************************************/
23:
24: namespace Thelia\Core;
25:
26: /**
27: * Root class of Thelia
28: *
29: * It extends Symfony\Component\HttpKernel\Kernel for changing some fonctionnality
30: *
31: *
32: * @author Manuel Raynaud <mraynaud@openstudio.fr>
33: */
34:
35: use Symfony\Component\HttpKernel\Kernel;
36: use Symfony\Component\Config\Loader\LoaderInterface;
37: use Thelia\Core\Bundle;
38: use Thelia\Log\Tlog;
39: use Propel;
40: use PropelConfiguration;
41:
42: class Thelia extends Kernel
43: {
44:
45: public function init()
46: {
47: parent::init();
48:
49: $this->initPropel();
50: }
51:
52: protected function initPropel()
53: {
54: if (file_exists(THELIA_ROOT . '/local/config/config_db.php') === false) {
55: return ;
56: }
57: Propel::init(THELIA_CONF_DIR . "/config_thelia.php");
58:
59: if ($this->isDebug()) {
60: Propel::setLogger(Tlog::getInstance());
61: $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
62: $config->setParameter('debugpdo.logging.details.method.enabled', true);
63: $config->setParameter('debugpdo.logging.details.time.enabled', true);
64: $config->setParameter('debugpdo.logging.details.mem.enabled', true);
65:
66: $con = Propel::getConnection("thelia");
67: $con->useDebug(true);
68: }
69: }
70:
71: /**
72: *
73: * Load some configuration
74: * Initialize all plugins
75: *
76: */
77: public function loadConfiguration()
78: {
79:
80: }
81:
82: /**
83: * Gets the cache directory.
84: *
85: * @return string The cache directory
86: *
87: * @api
88: */
89: public function getCacheDir()
90: {
91: if (defined('THELIA_ROOT')) {
92: return THELIA_ROOT.'cache/'.$this->environment;
93: } else {
94: return parent::getCacheDir();
95: }
96:
97: }
98:
99: /**
100: * Gets the log directory.
101: *
102: * @return string The log directory
103: *
104: * @api
105: */
106: public function getLogDir()
107: {
108: if (defined('THELIA_ROOT')) {
109: return THELIA_ROOT.'log/';
110: } else {
111: return parent::getLogDir();
112: }
113: }
114:
115: /**
116: * Builds the service container.
117: *
118: * @return ContainerBuilder The compiled service container
119: */
120: // protected function buildContainer()
121: // {
122: // $container = $this->getContainerBuilder();
123: // $container->set('kernel', $this);
124: //
125: // foreach ($this->bundles as $bundle) {
126: // $bundle->build($container);
127: // }
128: //
129: // return $container;
130: // }
131:
132: /**
133: * return available bundle
134: *
135: * Part of Symfony\Component\HttpKernel\KernelInterface
136: *
137: * @return array An array of bundle instances.
138: *
139: */
140: public function registerBundles()
141: {
142: $bundles = array(
143: /* TheliaBundle contain all the dependency injection description */
144: new Bundle\TheliaBundle()
145: );
146:
147: /**
148: * OTHER CORE BUNDLE CAN BE DECLARE HERE AND INITIALIZE WITH SPECIFIC CONFIGURATION
149: *
150: * HOW TO DECLARE OTHER BUNDLE ? ETC
151: */
152:
153: return $bundles;
154:
155: }
156:
157: /**
158: * Loads the container configuration
159: *
160: * part of Symfony\Component\HttpKernel\KernelInterface
161: *
162: * @param LoaderInterface $loader A LoaderInterface instance
163: *
164: * @api
165: */
166: public function registerContainerConfiguration(LoaderInterface $loader)
167: {
168: //Nothing is load here but it's possible to load container configuration here.
169: //exemple in sf2 : $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
170: }
171:
172: }
173: