Overview

Namespaces

  • PHP
  • Thelia
    • Action
    • Controller
    • Core
      • Bundle
      • Event
      • EventListener
      • Template
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools

Classes

  • Thelia
  • TheliaHttpKernel
  • Overview
  • Namespace
  • Class
  • Tree
  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:      * Gets the cache directory.
 83:      *
 84:      * @return string The cache directory
 85:      *
 86:      * @api
 87:      */
 88:     public function getCacheDir()
 89:     {
 90:         if (defined('THELIA_ROOT')) {
 91:             return THELIA_ROOT.'cache/'.$this->environment;
 92:         } else {
 93:             return parent::getCacheDir();
 94:         }
 95: 
 96:     }
 97: 
 98:     /**
 99:      * Gets the log directory.
100:      *
101:      * @return string The log directory
102:      *
103:      * @api
104:      */
105:     public function getLogDir()
106:     {
107:         if (defined('THELIA_ROOT')) {
108:             return THELIA_ROOT.'log/';
109:         } else {
110:             return parent::getLogDir();
111:         }
112:     }
113: 
114:     /**
115:      * Builds the service container.
116:      *
117:      * @return ContainerBuilder The compiled service container
118:      */
119: //    protected function buildContainer()
120: //    {
121: //        $container = $this->getContainerBuilder();
122: //        $container->set('kernel', $this);
123: //
124: //        foreach ($this->bundles as $bundle) {
125: //            $bundle->build($container);
126: //        }
127: //
128: //        return $container;
129: //    }
130: 
131:     /**
132:      * return available bundle
133:      *
134:      * Part of Symfony\Component\HttpKernel\KernelInterface
135:      *
136:      * @return array An array of bundle instances.
137:      *
138:      */
139:     public function registerBundles()
140:     {
141:         $bundles = array(
142:             /* TheliaBundle contain all the dependency injection description */
143:             new Bundle\TheliaBundle()
144:         );
145: 
146:         /**
147:          * OTHER CORE BUNDLE CAN BE DECLARE HERE AND INITIALIZE WITH SPECIFIC CONFIGURATION
148:          *
149:          * HOW TO DECLARE OTHER BUNDLE ? ETC
150:          */
151: 
152:         return $bundles;
153: 
154:     }
155: 
156:     /**
157:      * Loads the container configuration
158:      *
159:      * part of Symfony\Component\HttpKernel\KernelInterface
160:      *
161:      * @param LoaderInterface $loader A LoaderInterface instance
162:      *
163:      * @api
164:      */
165:     public function registerContainerConfiguration(LoaderInterface $loader)
166:     {
167:         //Nothing is load here but it's possible to load container configuration here.
168:         //exemple in sf2 : $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
169:     }
170: 
171: }
172: 
thelia API documentation generated by ApiGen 2.8.0