Documentation


SEARCH

TABLE OF CONTENT

    1. Getting started 2. Basic concepts 3. Request dispatching 4. Context container 5. Dual MVC 6. Component model: 7. Security 8. Configuration 9. Session handling 10. I18n 11. Cache 12. Logging 13. Error handling 14. Advanced Topics 15. API reference

      Tutorials: Frequently Asqued Questions

      See also:


      Accessing the configuration

      Getting configuration values

      Table of Contents

      Accessing the configuration

      In Lion, each context has his own configuration. The way to access to the configuration within a context is by ussing the __Context::getConfiguration() method, which returns a reference to the associated context __Configuration instance.

      The __Configuration class represents a configuration file applicable to a particular application and provides accessors to get any configuration value.

      i.e.

      1. <?php
      2.  
      3. //get a reference to the application configuration:
      4. $app_config __ApplicationContext::getInstance()->
      5.                                     getConfiguration();

      Getting a configuration section

      A section within the configuration can be retrieved by ussing the getSection method.

      i.e., imagine the following configuration content:

      1. <?xml version "1.0" standalone="yes"?>
      2.  
      3. <foobars>
      4.   <foo bar="lion"/>
      5.   <foo bar="rocks"/>
      6. </foobars>

      To access to the foobars section, we should need a code like the following one:

      1. <?php
      2.  
      3. //get an array of Foo instances according
      4. //to the configuration:
      5.                               getConfiguration()->
      6.                               getSection('foobars');

      Getting a property value

      Some configuration files are structured to just define property values (property files).

      i.e.,

      1. ;----------------------------------
      2. DATABASE CONNECTION PARAMETERS:
      3. ;----------------------------------
      4.  
      5. DATABASE_HOST "127.0.0.1"
      6. DATABASE_NAME "foobar"
      7. DATABASE_USERNAME "root"
      8. DATABASE_PASSWORD "secret"

      For those files, the __Configuration class define a really usefull method to access to the property values: __Configuration::getPropertyContent().

      i.e.

      1. <?php
      2.  
      3.                                  getConfiguration()->
      4.                                  getPropertyContent('DATABASE_NAME');