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


PHP Phing::getCurrentProject方法代码示例

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


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

示例1: createElement

 /**
  * Creates a named nested element.
  *
  * Valid creators can be in the form createFoo() or addFoo(Bar).
  *
  * @param  Project        $project
  * @param  object         $element     Object the XML tag is child of.
  *                                     Often a task object.
  * @param  string         $elementName XML tag name
  * @return object         Returns the nested element.
  * @throws BuildException
  */
 public function createElement(Project $project, $element, $elementName)
 {
     $addMethod = "add" . strtolower($elementName);
     $createMethod = "create" . strtolower($elementName);
     $nestedElement = null;
     if (isset($this->nestedCreators[$createMethod])) {
         $method = $this->nestedCreators[$createMethod];
         try {
             // try to invoke the creator method on object
             $project->log("    -calling creator " . $method->getDeclaringClass()->getName() . "::" . $method->getName() . "()", Project::MSG_DEBUG);
             $nestedElement = $method->invoke($element);
         } catch (Exception $exc) {
             throw new BuildException($exc);
         }
     } elseif (isset($this->nestedCreators[$addMethod])) {
         $method = $this->nestedCreators[$addMethod];
         // project components must use class hints to support the add methods
         try {
             // try to invoke the adder method on object
             $project->log("    -calling adder " . $method->getDeclaringClass()->getName() . "::" . $method->getName() . "()", Project::MSG_DEBUG);
             // we've already assured that correct num of params
             // exist and that method is using class hints
             $params = $method->getParameters();
             $classname = null;
             if (($hint = $params[0]->getClass()) !== null) {
                 $classname = $hint->getName();
             }
             // create a new instance of the object and add it via $addMethod
             $clazz = new ReflectionClass($classname);
             if ($clazz->getConstructor() !== null && $clazz->getConstructor()->getNumberOfRequiredParameters() === 1) {
                 $nestedElement = new $classname(Phing::getCurrentProject());
             } else {
                 $nestedElement = new $classname();
             }
             $method->invoke($element, $nestedElement);
         } catch (Exception $exc) {
             throw new BuildException($exc);
         }
     } elseif ($this->bean->implementsInterface("CustomChildCreator")) {
         $method = $this->bean->getMethod('customChildCreator');
         try {
             $nestedElement = $method->invoke($element, strtolower($elementName), $project);
         } catch (Exception $exc) {
             throw new BuildException($exc);
         }
     } else {
         //try the add method for the element's parent class
         $typedefs = $project->getDataTypeDefinitions();
         if (isset($typedefs[$elementName])) {
             $elementClass = Phing::import($typedefs[$elementName]);
             $parentClass = get_parent_class($elementClass);
             $addMethod = 'add' . strtolower($parentClass);
             if (isset($this->nestedCreators[$addMethod])) {
                 $method = $this->nestedCreators[$addMethod];
                 try {
                     $project->log("    -calling parent adder " . $method->getDeclaringClass()->getName() . "::" . $method->getName() . "()", Project::MSG_DEBUG);
                     $nestedElement = new $elementClass();
                     $method->invoke($element, $nestedElement);
                 } catch (Exception $exc) {
                     throw new BuildException($exc);
                 }
             }
         }
         if ($nestedElement === null) {
             $msg = $this->getElementName($project, $element) . " doesn't support the '{$elementName}' creator/adder.";
             throw new BuildException($msg);
         }
     }
     if ($nestedElement instanceof ProjectComponent) {
         $nestedElement->setProject($project);
     }
     return $nestedElement;
 }
开发者ID:alangalipaud,项目名称:ProjetQCM,代码行数:85,代码来源:IntrospectionHelper.php


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