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


PHP StringHelper::slotVar方法代码示例

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


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

示例1: setAttribute

 /** Sets the named attribute. */
 function setAttribute(Project $project, $element, $attributeName, &$value)
 {
     // we want to check whether the value we are setting looks like
     // a slot-listener variable:  %{task.current_file}
     //
     // slot-listener variables are not like properties, in that they cannot be mixed with
     // other text values.  The reason for this disparity is that properties are only
     // set when first constructing objects from XML, whereas slot-listeners are always dynamic.
     //
     // This is made possible by PHP5 (objects automatically passed by reference) and PHP's loose
     // typing.
     if (StringHelper::isSlotVar($value)) {
         $as = "setlistening" . strtolower($attributeName);
         if (!isset($this->slotListeners[$as])) {
             $msg = $this->getElementName($project, $element) . " doesn't support a slot-listening '{$attributeName}' attribute.";
             throw new BuildException($msg);
         }
         $method = $this->slotListeners[$as];
         $key = StringHelper::slotVar($value);
         $value = Register::getSlot($key);
         // returns a RegisterSlot object which will hold current value of that register (accessible using getValue())
     } else {
         // Traditional value options
         $as = "set" . strtolower($attributeName);
         if (!isset($this->attributeSetters[$as])) {
             $msg = $this->getElementName($project, $element) . " doesn't support the '{$attributeName}' attribute.";
             throw new BuildException($msg);
         }
         $method = $this->attributeSetters[$as];
         if ($as == "setrefid") {
             $value = new Reference($value);
         } else {
             // decode any html entities in string
             $value = html_entity_decode($value);
             // value is a string representation of a boolean type,
             // convert it to primitive
             if (StringHelper::isBoolean($value)) {
                 $value = StringHelper::booleanValue($value);
             }
             // does method expect a PhingFile object? if so, then
             // pass a project-relative file.
             $params = $method->getParameters();
             $classname = null;
             if (($hint = $params[0]->getClass()) !== null) {
                 $classname = $hint->getName();
             }
             // there should only be one param; we'll just assume ....
             if ($classname !== null) {
                 switch (strtolower($classname)) {
                     case "phingfile":
                         $value = $project->resolveFile($value);
                         break;
                     case "path":
                         $value = new Path($project, $value);
                         break;
                     case "reference":
                         $value = new Reference($value);
                         break;
                         // any other object params we want to support should go here ...
                 }
             }
             // if hint !== null
         }
         // if not setrefid
     }
     // if is slot-listener
     try {
         $project->log("    -calling setter " . $method->getDeclaringClass()->getName() . "::" . $method->getName() . "()", PROJECT_MSG_DEBUG);
         $method->invoke($element, $value);
     } catch (Exception $exc) {
         throw new BuildException($exc);
     }
 }
开发者ID:taryono,项目名称:school,代码行数:74,代码来源:IntrospectionHelper.php


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