當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。