Пример #1
0
 /**
  * 清理缓存
  * @return boolean
  */
 public static function cacheclear()
 {
     $fileManager = Singleton::getInstance('tfc\\util\\FileManager');
     $dirs = $fileManager->scanDir(DIR_DATA_RUNTIME);
     foreach ($dirs as $directory) {
         if (is_file($directory)) {
             continue;
         }
         if (!$fileManager->rmDir($directory)) {
             Log::warning(sprintf('Tools Cache clear Failed, Directory: "%s"', $directory), ErrorNo::ERROR_CACHE_DELETE, __METHOD__);
             return false;
         }
     }
     return true;
 }
Пример #2
0
 /**
  * 获取创建简单的DB执行命令类
  * @return \tdo\CommandBuilder
  */
 public function getCommandBuilder()
 {
     return Singleton::getInstance('tdo\\CommandBuilder');
 }
Пример #3
0
 /**
  * 获取创建简单的执行命令类
  * @return \tdo\CommandBuilder
  */
 public function getCommandBuilder()
 {
     if ($this->_commandBuilder === null) {
         $this->_commandBuilder = Singleton::getInstance('tdo\\CommandBuilder');
     }
     return $this->_commandBuilder;
 }
Пример #4
0
 /**
  * 获取页面辅助类
  * @return \tfc\mvc\Html
  */
 public function getHtml()
 {
     return Singleton::getInstance('tfc\\mvc\\Html');
 }
Пример #5
0
 /**
  * 获取页面辅助类
  * @return tfc\mvc\Html
  */
 public function getHtml()
 {
     if ($this->_html === null) {
         $this->_html = Singleton::getInstance('tfc\\mvc\\Html');
     }
     return $this->_html;
 }
Пример #6
0
 /**
  * 通过表的实体类,获取表的概要描述,包括:表名、主键、自增字段、字段、默认值
  * 应该根据不同的数据库类型创建对应的TableSchema类:$dbType = $this->getDriver(false)->getDbType();
  * 这里只用到MySQL数据库,暂时不做多数据库类型
  * @param string $tableName
  * @return \tfc\db\TableSchema
  */
 public function getTableSchema($tableName)
 {
     $className = 'tfc\\db\\TableSchema::' . strtolower($tableName);
     if (Singleton::has($className)) {
         return Singleton::get($className);
     }
     $ref = $this->getRefClass($tableName);
     $attributes = $ref->getDefaultProperties();
     $tableSchema = new TableSchema();
     $tableSchema->name = $ref->hasConstant('TABLE_NAME') ? $ref->getConstant('TABLE_NAME') : $ref->getShortName();
     $tableSchema->autoIncrement = $ref->hasConstant('AUTO_INCREMENT') ? $ref->getConstant('AUTO_INCREMENT') : null;
     if (isset($attributes['primaryKey'])) {
         $tableSchema->primaryKey = $attributes['primaryKey'];
         unset($attributes['primaryKey']);
     }
     $tableSchema->columnNames = array_keys($attributes);
     if ($tableSchema->primaryKey === null) {
         $tableSchema->primaryKey = $tableSchema->columnNames[0];
     }
     foreach ($attributes as $key => $value) {
         if ($value === null) {
             unset($attributes[$key]);
         }
     }
     $tableSchema->attributeDefaults = $attributes;
     Singleton::set($className, $tableSchema);
     return $tableSchema;
 }
Пример #7
0
 /**
  * 获取DbProxy
  * @return tfc\saf\DbProxy
  */
 public function getDbProxy()
 {
     $clusterName = \builders\library\Constant::DB_CLUSTER;
     $className = 'tfc\\saf\\DbProxy::' . $clusterName;
     if (($dbProxy = Singleton::get($className)) === null) {
         $dbProxy = new DbProxy($clusterName);
         Singleton::set($className, $dbProxy);
     }
     return $dbProxy;
 }
Пример #8
0
 /**
  * 获取URL管理类
  * @return \tfc\mvc\UrlManager
  */
 public function getUrlManager()
 {
     if ($this->_urlManager === null) {
         $this->_urlManager = Singleton::getInstance('tfc\\mvc\\UrlManager');
     }
     return $this->_urlManager;
 }