本文整理汇总了PHP中Path::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::instance方法的具体用法?PHP Path::instance怎么用?PHP Path::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
示例2: __construct
public function __construct()
{
parent::__construct(\Path::instance()->currentProject('etc.conf.@database.xml'));
$this->collection = new \DB\Config();
$config = $this->dom;
$connection_nodes = $config->getElementsByTagNameNS('http://lab.zigmoyd.net/xmlns/bong', 'connection');
$connections = array();
foreach ($connection_nodes as $connection_node) {
/*{ Connection attributes*/
$name = $connection_node->getAttribute('name');
$dsn = $connection_node->getAttribute('dsn');
$user = $connection_node->getAttribute('user');
$pass = $connection_node->getAttribute('pass');
$connection = new \DB\Connection($name, $dsn, $user, $pass);
/*}*/
/*{ PDO Params*/
$params = array();
$param_nodes = $connection_node->getElementsByTagNameNS('http://lab.zigmoyd.net/xmlns/bong', 'param');
foreach ($param_nodes as $param_node) {
$name = $param_node->getAttribute('name');
$value = $param_node->getAttribute('value');
$param = new \DB\ConnectionParam($name, $value);
$connection->addParam($param);
}
/*}*/
$this->collection->addConnection($connection);
}
$model_nodes = $config->getElementsByTagNameNS('http://lab.zigmoyd.net/xmlns/bong', 'model');
$model_node = $model_nodes->item(0);
$default_connection = $model_node->getAttribute('default');
$autoconnect = constant($model_node->getAttribute('autoconnect'));
$this->collection->setDefault($default_connection);
$this->collection->setAutoconnect($autoconnect);
//echo ">> DatabaseConfig::__construct()\n";
}
示例3: _createFromReflection
/**
* @load
* @param ReflectionMethod $reflection
*/
protected function _createFromReflection($reflection)
{
$this->_type = Method::SpiritMethod;
parent::_createFromReflection($reflection);
//{ Add Views
if ($this->isPublic()) {
$viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.*' . $this->controller()->name() . '.view.-' . $this->name());
if (file_exists($viewPath)) {
$dh = opendir($viewPath);
$viewsFound = array();
while (false !== ($file = readdir($dh))) {
if ($file != "." && $file != ".." && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') {
$viewFilePath = rtrim($viewPath, '/') . "/{$file}";
$viewsFound[$file] = $viewFilePath;
$this->addView(SpiritView::create($this, pathinfo($file, PATHINFO_FILENAME)));
}
}
closedir($dh);
if (array_key_exists('view.php', $viewsFound)) {
$this->setHasDefaultView();
}
}
}
//}
}
示例4: go_to
public static function go_to($url)
{
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$root_path . $url;
}
示例5: _createFromReflection
private function _createFromReflection($projectName)
{
$this->_name = $projectName;
$this->_dir = \Fstab::instance()->projectDirectory($projectName);
$controllerBasePath = rtrim(\Path::instance()->evaluate(":{$this->_name}.apps.controller"), "/\\");
foreach (glob($controllerBasePath . "/*.php") as $filePath) {
$fileName = pathinfo($filePath, PATHINFO_FILENAME);
$controllerClassName = $fileName . 'Controller';
if (!class_exists($controllerClassName)) {
require $filePath;
}
if (class_exists($controllerClassName)) {
$reflection = new \ReflectionClass($controllerClassName);
$this->_controllers[] = AppController::create($this, $reflection);
}
}
$spiritBasePath = rtrim(\Path::instance()->evaluate(":{$this->_name}.spiritPath"), "/\\");
foreach (glob($spiritBasePath . "/*", GLOB_ONLYDIR) as $dirName) {
$spiritName = pathinfo($dirName, PATHINFO_FILENAME);
$spiritFileName = rtrim($dirName, "/\\") . '/abstractor.php';
$spiritAbstractorClassName = $spiritName . 'Abstractor';
if (!class_exists($spiritAbstractorClassName) && file_exists($spiritFileName)) {
require $spiritFileName;
}
if (class_exists($spiritAbstractorClassName)) {
$reflection = new \ReflectionClass($spiritAbstractorClassName);
$this->_spirits[] = SpiritController::create($this, $reflection);
}
}
}
示例6: run
public function run()
{
$fsm = \FSM\Engine::parse('site');
$path = Path::instance()->evaluate('common') . '/fsm.php';
ob_start();
require $path;
$this->responseBuffer = ob_get_contents();
ob_end_clean();
}
示例7: __construct
public function __construct($controllerName)
{
$controllerPath = Path::instance()->currentProject("apps.+&{$controllerName}.@&{$controllerName}.php");
parent::__construct($controllerPath);
$this->registerParam(new BongExceptionParam("controllerName", "controller Name", true));
$this->registerParam(new BongExceptionParam("controllerPath", "controller Path", true));
$this->setParam("controllerName", $controllerName);
$this->setParam("controllerPath", $controllerPath);
}
示例8: genParams
public function genParams()
{
if (!$this->_params) {
$viewPath = \Path::instance()->evaluate(':' . $this->project()->name() . ".apps.layout.+{$this->name()}.@params.php");
$this->_params = Params::create($viewPath . '/params.php');
return $this->_params->generate();
}
return false;
}
示例9: genParams
public function genParams()
{
if (!$this->_hasParams) {
$viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.apps.view.+' . $this->controller()->name() . '.-' . $this->name());
$this->_params = Params::create($viewPath . '/params.php');
$this->setHasParams();
return $this->_params->generate();
}
return false;
}
示例10: __construct
public function __construct($controllerName, $controllerPath = null)
{
if (!$controllerPath) {
$controllerPath = Path::instance()->currentProject("apps.+&{$controllerName}.@&{$controllerName}.php");
}
if (!$controllerPath) {
!($controllerPath = 'Unknown/could/not/determine/path');
}
parent::__construct($controllerPath);
$this->registerParam(new BongExceptionParam("controllerName", "controller Name", true));
$this->registerParam(new BongExceptionParam("controllerPath", "controller Path", true));
$this->setParam("controllerName", $controllerName);
$this->setParam("controllerPath", $controllerPath);
}
示例11: createProject
public function createProject($projectName, $projectDir)
{
ControllerTray::instance()->renderLayout = false;
$this->data->success = false;
$this->data->projectName = $projectName;
if (!\Fstab::instance()->addProject($projectName, $projectDir)) {
return false;
}
\Fstab::instance()->save();
$commonProject = \Path::instance()->evaluate("common.template.prj");
$projectPath = \Path::instance()->evaluate(":{$projectName}.root") . "{$projectDir}";
if (!is_dir($projectPath)) {
if (!recurse_copy($commonProject, $projectPath)) {
$this->data->success = false;
} else {
$this->data->success = true;
}
}
}
示例12: module
public function module($moduleName)
{
$modulePath = Path::instance()->evaluate('lib.module');
if (file_exists($modulePath . "/{$moduleName}") && is_dir($modulePath . "/{$moduleName}")) {
if (file_exists($modulePath . "/{$moduleName}/{$moduleName}.xml")) {
if (is_readable($modulePath . "/{$moduleName}/{$moduleName}.xml")) {
foreach (ModuleConf::instance()->dependencies() as $dep) {
Loader::instance()->module($dep);
}
foreach (ModuleConf::instance()->includes() as $inc) {
Loader::instance()->inc($modulePath . "/{$moduleName}/" . trim($inc, '/'));
}
} else {
return -2;
}
} else {
return -1;
}
}
return 0;
}
示例13: _createFromReflection
/**
* @load
* @param ReflectionMethod $reflection
*/
private function _createFromReflection($reflection)
{
$this->_name = $reflection->getName();
$this->_public = $reflection->isPublic();
$this->_inherited = !($reflection->getDeclaringClass()->getName() == $this->_controller->className());
foreach ($reflection->getParameters() as $paramReflection) {
//Argument::create($this, $paramReflection);
$this->addArgument(Argument::create($this, $paramReflection));
}
//{ Add Views
if ($this->isAction()) {
$viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.apps.view.+' . $this->controller()->name() . '.-' . $this->name());
if (file_exists($viewPath)) {
$this->setViewDirectoryCreated();
$dh = opendir($viewPath);
$viewsFound = array();
while (false !== ($file = readdir($dh))) {
if ($file != "." && $file != ".." && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') {
$viewFilePath = rtrim($viewPath, '/') . "/{$file}";
if ($file == 'layout.php') {
$this->setHasLayout();
} else {
if ($file == 'params.php') {
$this->setHasParams();
} else {
$viewsFound[$file] = $viewFilePath;
$this->addView(ControllerView::create($this, pathinfo($file, PATHINFO_FILENAME)));
}
}
}
}
closedir($dh);
if (array_key_exists('view.php', $viewsFound)) {
$this->setHasDefaultView();
}
}
}
//}
}
示例14: _basePath
private static function _basePath()
{
return rtrim(Path::instance()->currentProject('keys'), "/");
}
示例15: controller
private function controller()
{
$controllerPath = Path::instance()->currentProject('apps.+&controller.@&controller.php');
if (!$controllerPath || !file_exists($controllerPath)) {
throw new ControllerNotFoundException(MemPool::instance()->get('bong.mvc.controller'), $controllerPath);
} else {
if (is_readable($controllerPath)) {
return $controllerPath;
} else {
throw new ControllerNotReadableException(MemPool::instance()->get('bong.mvc.controller'));
}
}
}