当前位置: 首页>>代码示例>>PHP>>正文


PHP FileUtils::classFromFile方法代码示例

本文整理汇总了PHP中FileUtils::classFromFile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtils::classFromFile方法的具体用法?PHP FileUtils::classFromFile怎么用?PHP FileUtils::classFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileUtils的用法示例。


在下文中一共展示了FileUtils::classFromFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testClassFromFile

 function testClassFromFile()
 {
     $this->assertEquals("Bang", FileUtils::classFromFile("/this/is/a/path/to/a/class/named/Bang.php"));
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:4,代码来源:FileUtilsTest.php

示例2: __construct

 /**
  * Construct the action definition from the contents of the ubar.xml file.
  *
  * NOTE: If no path is defined for the action, a dummy action that always
  * returns GlobalConstants::SUCCESS will be used.
  *
  * @param class $actionXML - XML representation of an action definition.
  *
  * @see ActionMapper::getAction()
  */
 public function __construct($actionXML)
 {
     $path = (string) $actionXML['path'];
     // use dummy action if no action defined
     if ($path != '') {
         $this->actionLocation = FileUtils::dotToPath($path);
         $this->actionClassName = FileUtils::classFromFile($this->actionLocation);
     } else {
         $this->actionClassName = GlobalConstants::DUMMY_ACTION;
     }
     if (!is_null($actionXML['template'])) {
         $this->templateName = (string) $actionXML['template'];
     }
     if (!is_null($actionXML['view'])) {
         $this->viewLocation = FileUtils::dotToPath((string) $actionXML['view']);
     }
     $this->results = $actionXML->results->result;
     $this->permissionGroup = $actionXML->permissionGroup;
     $this->permissions = $actionXML->permissions;
     $this->name = (string) $actionXML['name'];
     // add params
     foreach ($actionXML->param as $param) {
         $attribs = $param->attributes();
         $name = (string) $attribs->name;
         $value = (string) $attribs->value;
         $this->addParam($name, $value);
     }
     // display values
     $this->title = (string) $actionXML['title'];
     $this->titleKey = (string) $actionXML['titleKey'];
     // TODO: page mostly makes sense as action name, consider decoupling however
     $this->page = (string) $actionXML['name'];
     $this->section = (string) $actionXML['section'];
     $this->subSection = (string) $actionXML['subSection'];
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:45,代码来源:ActionDef.php

示例3: getAction

 /**
  * Get action definition and instance using the requested URL or using an
  * overriding action name. The override is typically only used for testing
  * purposes and it is not recommended that it be used elsewhere.
  *
  * NOTE: This is a public method so that it may be called from tests. It is
  * not recommended that you call it directly elsewhere.
  *
  * @param string $actionString Overriding action string. Use not
  * recommended outside of testing.
  *
  * @returns class The action instance.
  *
  * @throws ActionNotFoundException If the action file was not found.
  * @throws Exception if the action def was not found and no default was
  * found.
  */
 public function getAction($actionString = null)
 {
     global $UBAR_GLOB;
     // no override to action name, get from url
     if (is_null($actionString)) {
         // match action part of the URI
         preg_match(self::ACTION_REGEX, $_SERVER['REQUEST_URI'], $matches);
         // get action string from url
         if (isset($matches[1])) {
             $actionString = $matches[1];
         } else {
             // didn't match format despite .htaccess rule, assume empty and get default
             $this->actionDef = $this->actionMapper->getDefaultAction();
         }
     }
     // get action from action name if not already set to default
     if (is_null($this->actionDef)) {
         try {
             $this->actionDef = $this->actionMapper->getAction($actionString);
         } catch (Exception $e) {
             // TODO: look for error def, render that after setting error in session
             throw new Exception($e->getMessage());
         }
     }
     // if still null die saying can't do action mapping
     if (is_null($this->actionDef)) {
         throw new Exception("Unable to find a default action");
     }
     // verify that action exists
     $actionRealPath = null;
     // if no action name was provided, use a dummy to always return success
     if ($this->actionDef->getActionLocation() == '') {
         // see if overriding dummy provided, used to expose common methods
         // to tempates and similar
         $dummyOverride = $this->actionMapper->getDummyActionPath();
         if (is_null($dummyOverride)) {
             $actionRealPath = $UBAR_GLOB['UBAR_ROOT'] . '/core/' . GlobalConstants::DUMMY_ACTION . '.php';
         } else {
             // mostly set for debugging purposes
             $this->actionDef->setActionLocation($dummyOverride);
             $actionRealPath = $UBAR_GLOB['BASE_ACTION_PATH'] . $dummyOverride;
             $actionClassName = FileUtils::classFromFile($dummyOverride);
             $this->actionDef->setClassName($actionClassName);
         }
     } else {
         $actionRealPath = $UBAR_GLOB['BASE_ACTION_PATH'] . $this->actionDef->getActionLocation();
     }
     if (!file_exists($actionRealPath)) {
         throw new ActionNotFoundException($this->actionDef);
     } else {
         require_once $actionRealPath;
     }
     // instantiate specific action - class name may have been overridden
     $actionClassName = $this->actionDef->getClassName();
     $this->action = new $actionClassName($this->actionDef);
     return $this->action;
 }
开发者ID:Rkandel23,项目名称:ubar,代码行数:74,代码来源:Dispatcher.php


注:本文中的FileUtils::classFromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。