创建一个锁
@param string $name 锁名称
@param string $type 锁类型
@param string $filename 锁定文件 文件锁必须传入
436829
public function add($name, $type, $filename = null): void
    {
        if (!isset($this->list[$name])) {
            $lock = new Lock($type, $filename);
            $this->list[$name] = $lock;
        }
    }
62896
public function loadFilter($type, $name)
    {
        $_plugin = "smarty_{$type}filter_{$name}";
        $_filter_name = $_plugin;
        if ($this->smarty->loadPlugin($_plugin)) {
            if (class_exists($_plugin, false)) {
                $_plugin = array($_plugin, 'execute');
            }
            if (is_callable($_plugin)) {
                $this->smarty->registered_filters[$type][$_filter_name] = $_plugin;
                return true;
            }
        }
        throw new SmartyException("{$type}filter \"{$name}\" not callable");
        return false;
    }
457910
public function delete(String $name, String $type = 'controller', String $app = NULL) : Bool
    {
        if( ! empty($app) )
        {
            $this->settings['application'] = $app;
        }

        $file = $this->path($name, $type);

        if( is_file($file) )
        {
            return unlink($file);
        }

        return false;
    }
528398
private static function write($name = '', $type = '', $message = '', $data = array(), $other = array())
    {
        $filePath = isset(self::$config[$name]) ? self::$config[$name] : '';
        if (empty($filePath)) {
            return false;
        }
        $directory = dirname($filePath);
        if (!file_exists($directory)) {
            mkdir($directory, 0777, true);
        }
        $string = sprintf(
            '[%s] %s.%s: %s %s %s%s',
            date('Y-m-d H:i:s'),
            $name,
            $type,
            $message,
            json_encode($data),
            json_encode($other),
            PHP_EOL
        );
        file_put_contents($filePath, $string, FILE_APPEND);
        return true;
    }
634231
public function revoke(string $type, string $name,
                           int $mode = WebAclRule::READ) {
        $this->checkParam($type, $mode);

        $toDel         = array();
        $hasSomeRights = false;
        foreach ($this->resRules as $i) {
            if ($i->hasRole($type, $name) && $i->getMode() >= $mode) {
                $hasSomeRights = true;
                if ($i->getRolesCount() == 1) {
                    $toDel[] = $i;
                } else {
                    $i->deleteRole($type, $name);
                    if (self::$autosave) {
                        $i->save($this->res->getAclUrl());
                    }
                }
            }
        }
        $this->resRules = array_diff($this->resRules, $toDel);
        $this->extRules = array_diff($this->extRules, $toDel);
        foreach ($toDel as $i) {
            $i->delete(true);
        }

        if ($mode === WebAclRule::WRITE && $hasSomeRights) {
            $this->grant($type, $name, WebAclRule::READ, 0);
        }
    }
864365
public static function isAdded($type, $name)
    {
        if (isset(self::$data[$type]['header'][$name])) {
            return true;
        } elseif (isset(self::$data[$type]['footer'][$name])) {
            return true;
        }

        return false;
    }
526158
public function setType(string $filename, $type = null): AssetFileInterface
    {
        if (! is_null($type) && in_array($type, $this->extensions, true)) {
            // We first listen to a defined asset type.
            // If no type is defined, let's try to discover it.
            $this->type = $this->findType($type);

            return $this;
        }

        $ext = $this->files->extension($filename);

        if (! empty($ext) && in_array($ext, $this->extensions, true)) {
            $this->type = $this->findType($ext);
        }

        return $this;
    }
911616
public function mediaUpload($filename, $type){
        $param = array(
            'access_token' => $this->accessToken,
            'type'         => $type
        );

        $filename = realpath($filename);
        if(!$filename) throw new \Exception('资源路径错误！');

        $file = array('media' => "@{$filename}");
        $url  = "{$this->mediaURL}/media/upload";
        $data = self::http($url, $param, $file, 'POST');

        return json_decode($data, true);
    }
300025
public function has($name, $type = 'param', $checkEmpty = false)
    {
        if (empty($this->$type)) {
            $param = $this->$type();
        } else {
            $param = $this->$type;
        }
        // 按.拆分成多维数组进行判断
        foreach (explode('.', $name) as $val) {
            if (isset($param[$val])) {
                $param = $param[$val];
            } else {
                return false;
            }
        }
        return ($checkEmpty && '' === $param) ? false : true;
    }
744819
public void removeFile(String name) {
        if(files.containsKey(name)) {
            files.remove(name);
        }

        if(fileStreams.containsKey(name)) {
            fileStreams.remove(name);
        }
    }
623173
public function get($filename,$name,$type=''){
        switch(strtolower($type)){
            case 'html':
                if(!isset($this->htmls[$filename])){
                    $kv = $this->getKv();
                    $this->htmls[$filename] = $kv->get($filename);
                }
                $content = $this->htmls[$filename];
                break;
            default:
                if(!isset($this->contents[$filename])){
                    $this->contents[$filename] = $this->mc->get($filename);
                }
                $content =  $this->contents[$filename];
        }
        if(false===$content){
            return false;
        }
        $info   =   array(
            'mtime'     =>  substr($content,0,10),
            'content'   =>  substr($content,10)
        );
        return $info[$name];        
    }
1214687
public function remove( $type, $name ) {
		if ( ! $this->exists( $type, $name ) ) {
			return false;
		}

		$pattern  = sprintf( '/(?<=^|;|<\?php\s|<\?\s)%s\s*(\S|$)/m', preg_quote( $this->wp_configs[ $type ][ $name ]['src'], '/' ) );
		$contents = preg_replace( $pattern, '$1', $this->wp_config_src );

		return $this->save( $contents );
	}
1034857
public function addThemeCSSFile($filename, $type=null) {
		$this->addCSSURL($this->getCSSURL().$filename, $type);
	}
1084546
public function isset(string $name, int $type = null): bool
    {
        if (is_null($type)) {
            return array_key_exists($name, $this->options) || array_key_exists($name, self::$globalOptions);
        } else {
            if ($type == self::TYPE_GLOBAL) {
                return array_key_exists($name, self::$globalOptions);
            } else {
                return array_key_exists($name, $this->options);
            }
        }
    }
755456
public function removeMigrationFile($name, $type)
    {
        $class_name = $this->getMigrationName($type, $name);

        $removed = false;
        $migration_file = $this->getMigrationPath().$class_name.'.php';
        if (file_exists($migration_file)) {
            if (unlink($migration_file)) {
                $removed = true;
                $migration = $this->modx->getObject($this->blend_class_object, ['name' => $class_name]);
                if (is_object($migration) && $migration->remove()) {
                    $this->out($class_name.' migration has been removed from the blend_migrations table', Blender::VERBOSITY_VERY_VERBOSE);

                }
            } else {
                $this->outError($class_name.' migration has not been removed from the blend_migrations table');
            }

        } else {
            $this->outError($this->getMigrationPath().$class_name.'.php migration could not be found to remove');
        }

        return $removed;
    }
730333
private function getKey(string $name, string $type = self::TYPE_QUEUE) : string
    {
        return $name . ':' . $type;
    }
1180160
protected function setTable($type, $name)
    {
        Validate::table($name)->exists();
        $this->tables[$type] = $name;
    }