ここの情報は古いです。ご理解頂いた上でお取り扱いください。

source: OpenPNE3/trunk/config/ProjectConfiguration.class.php.sample @ 12228

Last change on this file since 12228 was 12228, checked in by ebihara, 11 years ago

#3970:メンバーのメール投稿アドレスにハッシュを含められるようにした

File size: 3.2 KB
Line 
1<?php
2
3require_once '##SYMFONY_LIB_DIR##/autoload/sfCoreAutoload.class.php';
4sfCoreAutoload::register();
5
6define('OPENPNE_CONFIGURAIOTN_SAMPLE_HASH', 'ffc9f45bbeb1cb8832c211b87f225c8d');
7
8class ProjectConfiguration extends sfProjectConfiguration
9{
10  public function setup()
11  {
12    $this->enableAllPluginsExcept(array('sfCompat10Plugin', 'sfPropelPlugin'));
13    $this->setIncludePath();
14
15    $this->setOpenPNEConfiguration();
16
17    sfConfig::set('sfDoctrinePlugin_doctrine_lib_path', sfConfig::get('sf_lib_dir').'/vendor/doctrine/Doctrine.php');
18    sfConfig::set('doctrine_model_builder_options', array(
19      'baseClassName' => 'opDoctrineRecord',
20    ));
21
22    $this->dispatcher->connect('command.pre_command', array('opActivateBehavior', 'disable'));
23  }
24
25  protected function configureSessionStorage($name, $options = array())
26  {
27    $sessionName = 'OpenPNE_'.sfConfig::get('sf_app', 'default');
28    $params = array('session_name' => $sessionName);
29
30    if ('memcache' === $name)
31    {
32      sfConfig::set('sf_factory_storage', 'opMemcacheSessionStorage');
33      sfConfig::set('sf_factory_storage_parameters', array_merge((array)$options, $params));
34    }
35    elseif ('database' === $name)
36    {
37      sfConfig::set('sf_factory_storage', 'opPDODatabaseSessionStorage');
38      sfConfig::set('sf_factory_storage_parameters', array_merge(array(
39        'db_table'    => 'session',
40        'database'    => 'doctrine',
41        'db_id_col'   => 'id',
42        'db_data_col' => 'data',
43        'db_time_col' => 'time',
44      ), (array)$options, $params));
45    }
46    elseif ('file' !== $name)
47    {
48      sfConfig::set('sf_factory_storage', $name);
49      sfConfig::set('sf_factory_storage_parameters', array_merge((array)$options, $params));
50    }
51  }
52
53  public function setIncludePath()
54  {
55    sfToolkit::addIncludePath(array(
56      //PEAR
57      dirname(__FILE__).'/../lib/vendor/PEAR/',
58      dirname(__FILE__).'/../lib/vendor/OAuth/',
59    ));
60  }
61
62  public function configureDoctrine($manager)
63  {
64    $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
65    $manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
66    $manager->setAttribute(Doctrine::ATTR_RECURSIVE_MERGE_FIXTURES, true);
67    $manager->setAttribute(Doctrine::ATTR_QUERY_CLASS, 'opDoctrineQuery');
68
69    if (extension_loaded('apc'))
70    {
71      $cacheDriver = new Doctrine_Cache_Apc();
72      $manager->setAttribute(Doctrine::ATTR_QUERY_CACHE, $cacheDriver);
73    }
74  }
75
76  protected function setOpenPNEConfiguration()
77  {
78    $path = dirname(__FILE__).'/OpenPNE.yml';
79
80    if (md5_file($path.'.sample') !== OPENPNE_CONFIGURAIOTN_SAMPLE_HASH)
81    {
82      die('You must use original '.dirname(__FILE__).DIRECTORY_SEPARATOR.'OpenPNE.yml.sample or you must use new '.dirname(__FILE__).DIRECTORY_SEPARATOR.'ProjectConfiguration.class.php');
83    }
84
85    $config = sfYaml::load($path.'.sample');
86    if (is_readable($path))
87    {
88      $config = array_merge($config, sfYaml::load($path));
89    }
90
91    $this->configureSessionStorage($config['session_storage']['name'], (array)$config['session_storage']['options']);
92    unset($config['session_storage']);
93
94    foreach ($config as $key => $value)
95    {
96      sfConfig::set('op_'.$key, $value);
97    }
98  }
99}
Note: See TracBrowser for help on using the repository browser.