public function run(array $config) { $actionName = $config['actionName']; $fileExists = false; $classPath = str_replace('_', '/', $actionName); $classPath = str_replace('\\', '/', $classPath); foreach (explode(PATH_SEPARATOR, ini_get('include_path')) as $path) { if (file_exists($path . "/{$classPath}.php")) { $fileExists = true; break; } } if (!$fileExists) { return; } $methodName = $config['methodName']; $config = Configure::get('laiz.action.Validator'); $handleByMethod = (bool) $config['handleByMethod']; if ($handleByMethod) { if (isset($this->validatorResult->_success)) { if ($this->validatorResult->_success) { $methodName = 'valid'; } else { $methodName = 'invalid'; } } } $ret = Component_Runner::run($actionName, $config, $methodName); if (isset($config['result']['*']) && !$ret) { $ret = 'action:' . $config['result']['*']; } return $ret; }
public static function laze($projectDir = '../') { /** setting base include path */ $laizDir = dirname(__FILE__) . '/'; ini_set('include_path', $laizDir . PATH_SEPARATOR . ini_get('include_path')); /** autoload */ require_once 'laiz/autoloader/BasicLoader.php'; BasicLoader::init(); /** get base setting */ Configure::setProjectDir($projectDir); $configs = Configure::get('base'); $appDir = rtrim($configs['APP_DIR'], '/'); ini_set('include_path', $appDir . PATH_SEPARATOR . ini_get('include_path')); /** php.ini */ $phpIniConfigs = Configure::get('ini'); foreach ($phpIniConfigs as $key => $value) { ini_set($key, $value); } /** setting timezone by configure */ date_default_timezone_set($configs['TIMEZONE']); /** error class used by laiz */ /** not include by command line */ if (!isset($_SERVER['argv']) && $configs['USING_LAIZ_ERROR_UTILS']) { require_once 'laiz/error/Creator.php'; Creator::register(); } /* start controller of laiz framework */ $controller = new Controller(); try { $controller->execute(); } catch (Exception $e) { trigger_error($e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine(), E_USER_ERROR); } }
public function __construct(Validators $validators, Ini $parser, Request $req, Validator_Result $res) { $this->validators = $validators; $this->parser = $parser; $this->request = $req; $this->result = $res; $config = Configure::get('laiz.action.Validator'); $this->handleByMethod = (bool) $config['handleByMethod']; }
public function buildComponents(Container $container) { parent::buildComponents($container); /** * Building and Setting Request Object */ if ($container->get('laiz.action.Request')) { return; } $req = $container->create('laiz.action.Request_Web', 'laiz.action.Request'); $reqArgs = Configure::get('laiz.action.Request'); $req->setActionKey($reqArgs['ACTION_KEY']); $req->setPathInfoAction($reqArgs['PATH_INFO_ACTION']); }
public function __construct() { $base = Configure::get('base'); $this->FLEXY_COMPILE_DIR = $base['CACHE_DIR']; //$configs = Configure::get(__CLASS__); $configs = Configure::get(__NAMESPACE__); parent::__construct($configs); $this->FLEXY_FORM_SET_VALUE = $configs['FLEXY_FORM_SET_VALUE']; $this->FLEXY_FORM_SELECTED = $configs['FLEXY_FORM_SELECTED']; $this->FLEXY_FORCE_COMPILE = $configs['FLEXY_FORCE_COMPILE']; if (isset($configs['FLEXY_FORM_DEFAULT_ACTION'])) { $this->FLEXY_FORM_DEFAULT_ACTION = $configs['FLEXY_FORM_DEFAULT_ACTION']; } if (isset($configs['FLEXY_FORM_DEFAULT_METHOD'])) { $this->FLEXY_FORM_DEFAULT_METHOD = $configs['FLEXY_FORM_DEFAULT_METHOD']; } $this->_elements = array(); }
/** * Return factory by name * * @param string $name * @return Db_Factory */ public function select($name) { if (!$this->config) { $this->config = Configure::get(__NAMESPACE__); } switch (true) { case $name === 'transaction': case $name === 'trans': $factory = new Factory_Transaction($this->config); break; case preg_match('/[A-Z]/', $name): $factory = new Factory_View($this->config); break; default: $factory = new Factory_Orm($this->config); break; } return $factory; }
public function setDsn(array $dsn) { if (!isset($dsn['scope'])) { trigger_error('scope option is not set.'); return false; } $configs = Configure::get('base'); $basePath = $configs['CACHE_DIR'] . $dsn['scope']; $ormConfig = array('dsn' => 'sqlite:' . $basePath . '.sq3', 'autoConfig' => true, 'configFile' => $basePath . '.ini'); $factory = new Factory_Orm($ormConfig); $orm = $factory->create(self::TABLE_NAME); if (!$orm->existsTable()) { // create table and configs $query = 'create table ' . self::TABLE_NAME . '(datastore_id primary key, value, expire)'; $orm->query($query); $orm->createTableConfigs($ormConfig['configFile']); $orm->setTableConfigs($ormConfig['configFile'], true); // clear cache } $this->orm = $orm; // ==TODO== clear cache of over expire return true; }
private function initInterfaces() { /* * Initialize Aggregatable Interfaces. */ $base = Configure::get('base'); if ($base['INTERFACES_CACHE']) { $cacheFile = $base['CACHE_DIR'] . self::CACHE_FILENAME; if (file_exists($cacheFile)) { // using cache. // Delete cache file to clear caching. $this->interfaces = unserialize(file_get_contents($cacheFile)); return; } } // ==debug== //$start = microtime(true); $projectDir = $base['APP_DIR']; if (!is_dir($projectDir)) { trigger_error("APP_DIR: {$projectDir} is not directory. " . "APP_DIR is configurable in config.ini", E_USER_ERROR); return; } $laizDir = dirname(dirname(__FILE__)); // if not parsed $interfaces = array(); $interfaces = $this->getAggregatable($projectDir, $interfaces); $interfaces = $this->getAggregatable($laizDir, $interfaces); $this->registerInterfaces($interfaces); if ($base['INTERFACES_CACHE']) { file_put_contents($cacheFile, serialize($this->interfaces)); } // ==debug== //$end = microtime(true); //var_dump($end-$start);exit; }
/** * 外部からのnewの禁止 * * @access private */ private function __construct() { $conf = Configure::get(__CLASS__); $this->configs = $conf; }
public static function getCacheDir() { $base = Core::get('base'); return $base['CACHE_DIR']; }
/** * テンプレートのディレクトリ設定 * * @param string $dir */ protected function setTemplateDir($dir) { $frameworkBase = dirname(__FILE__) . '/'; $config = Configure::get('base'); $projectBase = $config['APP_DIR']; $dirs = array(); foreach ((array) $dir as $d) { $dirs[] = $projectBase . $d . '/'; } $dirs[] = dirname(__FILE__) . '/Base/templates/'; $this->TEMPLATE_DIR = $dirs; }