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


PHP XmlUtils::phpize方法代码示例

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


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

示例1: phpize

 /**
  * Note that the following features are not supported:
  *  * strings with escaped quotes are not supported "foo\"bar";
  *  * string concatenation ("foo" "bar").
  */
 private function phpize($value)
 {
     // trim on the right as comments removal keep whitespaces
     $value = rtrim($value);
     $lowercaseValue = strtolower($value);
     switch (true) {
         case defined($value):
             return constant($value);
         case 'yes' === $lowercaseValue || 'on' === $lowercaseValue:
             return true;
         case 'no' === $lowercaseValue || 'off' === $lowercaseValue || 'none' === $lowercaseValue:
             return false;
         case isset($value[1]) && ("'" === $value[0] && "'" === $value[strlen($value) - 1] || '"' === $value[0] && '"' === $value[strlen($value) - 1]):
             // quoted string
             return substr($value, 1, -1);
         default:
             return XmlUtils::phpize($value);
     }
 }
开发者ID:yceruto,项目名称:symfony,代码行数:24,代码来源:IniFileLoader.php

示例2: getArgumentsAsPhp

 /**
  * Returns arguments as valid php types.
  *
  * @param \DOMElement $node
  * @param string      $name
  * @param bool        $lowercase
  *
  * @return mixed
  */
 private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true)
 {
     $arguments = array();
     foreach ($this->getChildren($node, $name) as $arg) {
         if ($arg->hasAttribute('name')) {
             $arg->setAttribute('key', $arg->getAttribute('name'));
         }
         if (!$arg->hasAttribute('key')) {
             $key = !$arguments ? 0 : max(array_keys($arguments)) + 1;
         } else {
             $key = $arg->getAttribute('key');
         }
         // parameter keys are case insensitive
         if ('parameter' == $name && $lowercase) {
             $key = strtolower($key);
         }
         // this is used by DefinitionDecorator to overwrite a specific
         // argument of the parent definition
         if ($arg->hasAttribute('index')) {
             $key = 'index_' . $arg->getAttribute('index');
         }
         switch ($arg->getAttribute('type')) {
             case 'service':
                 $onInvalid = $arg->getAttribute('on-invalid');
                 $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
                 if ('ignore' == $onInvalid) {
                     $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
                 } elseif ('null' == $onInvalid) {
                     $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
                 }
                 if ($strict = $arg->getAttribute('strict')) {
                     $strict = XmlUtils::phpize($strict);
                 } else {
                     $strict = true;
                 }
                 $arguments[$key] = new Reference($arg->getAttribute('id'), $invalidBehavior, $strict);
                 break;
             case 'expression':
                 $arguments[$key] = new Expression($arg->nodeValue);
                 break;
             case 'collection':
                 $arguments[$key] = $this->getArgumentsAsPhp($arg, $name, false);
                 break;
             case 'string':
                 $arguments[$key] = $arg->nodeValue;
                 break;
             case 'constant':
                 $arguments[$key] = constant($arg->nodeValue);
                 break;
             default:
                 $arguments[$key] = XmlUtils::phpize($arg->nodeValue);
         }
     }
     return $arguments;
 }
开发者ID:ABaldwinHunter,项目名称:symfony-clone,代码行数:64,代码来源:XmlFileLoader.php

示例3: parseOptions

 /**
  * Parses a collection of "option" XML nodes.
  *
  * @param \SimpleXMLElement $nodes The XML nodes
  *
  * @return array The options
  */
 protected function parseOptions(\SimpleXMLElement $nodes)
 {
     $options = array();
     foreach ($nodes as $node) {
         if (count($node) > 0) {
             if (count($node->value) > 0) {
                 $value = $this->parseValues($node->value);
             } elseif (count($node->constraint) > 0) {
                 $value = $this->parseConstraints($node->constraint);
             } else {
                 $value = array();
             }
         } else {
             $value = XmlUtils::phpize($node);
             if (is_string($value)) {
                 $value = trim($value);
             }
         }
         $options[(string) $node['name']] = $value;
     }
     return $options;
 }
开发者ID:mkemiche,项目名称:Annuaire,代码行数:29,代码来源:XmlFileLoader.php

示例4: testPhpize

 /**
  * @dataProvider getDataForPhpize
  */
 public function testPhpize($expected, $value)
 {
     $this->assertSame($expected, XmlUtils::phpize($value));
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:7,代码来源:XmlUtilsTest.php

示例5: phpize

 /**
  * Converts an xml value to a PHP type.
  *
  * @param mixed $value
  *
  * @return mixed
  */
 public static function phpize($value)
 {
     return XmlUtils::phpize($value);
 }
开发者ID:NivalM,项目名称:VacantesJannaMotors,代码行数:11,代码来源:SimpleXMLElement.php

示例6: phpize

 /**
  * Transforms an XML attribute's value in a PHP value.
  *
  * @param \SimpleXMLElement $array
  * @param string            $key
  * @param string            $type
  *
  * @return bool|string|null
  */
 private function phpize(\SimpleXMLElement $array, string $key, string $type)
 {
     if (!isset($array[$key])) {
         return;
     }
     switch ($type) {
         case 'string':
             return (string) $array[$key];
         case 'bool':
             return (bool) XmlUtils::phpize($array[$key]);
     }
 }
开发者ID:api-platform,项目名称:core,代码行数:21,代码来源:XmlExtractor.php

示例7: getArgumentsAsPhp

 /**
  * Returns arguments as valid php types.
  *
  * @param \DOMElement $node
  * @param string      $name
  * @param bool        $lowercase
  *
  * @return mixed
  */
 private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true)
 {
     $arguments = [];
     foreach ($this->getChildren($node, $name) as $arg) {
         if ($arg->hasAttribute('name')) {
             $arg->setAttribute('key', $arg->getAttribute('name'));
         }
         if (!$arg->hasAttribute('key')) {
             $key = !$arguments ? 0 : max(array_keys($arguments)) + 1;
         } else {
             $key = $arg->getAttribute('key');
         }
         // parameter keys are case insensitive
         if ('parameter' == $name && $lowercase) {
             $key = strtolower($key);
         }
         // this is used by DefinitionDecorator to overwrite a specific
         // argument of the parent definition
         if ($arg->hasAttribute('index')) {
             $key = 'index_' . $arg->getAttribute('index');
         }
         switch ($arg->getAttribute('type')) {
             case 'service':
                 $arguments[$key] = $this->containerConfiguration->createReferenceFor($arg->getAttribute('id'), $arg->getAttribute('container') ?: null);
                 break;
             case 'expression':
                 $arguments[$key] = new Expression($arg->nodeValue);
                 break;
             case 'collection':
                 $arguments[$key] = $this->getArgumentsAsPhp($arg, $name, false);
                 break;
             case 'string':
                 $arguments[$key] = $arg->nodeValue;
                 break;
             case 'constant':
                 $arguments[$key] = constant($arg->nodeValue);
                 break;
             default:
                 $arguments[$key] = XmlUtils::phpize($arg->nodeValue);
         }
     }
     return $arguments;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:52,代码来源:XmlFileLoader.php

示例8: getReferenceByParameters

 public function getReferenceByParameters($parameters)
 {
     $viewReference = array();
     $arguments = array();
     foreach ($parameters as $key => $value) {
         $arguments[$key] = '@' . $key . '="' . $value . '"';
     }
     if ($xmlReference = $this->readCache()->xpath("//viewReference[" . implode(' and ', $arguments) . "]")) {
         $viewReference['id'] = XmlUtils::phpize($xmlReference[0]['id']);
         $viewReference['locale'] = XmlUtils::phpize($xmlReference[0]['locale']);
         $viewReference['entityId'] = XmlUtils::phpize($xmlReference[0]['entityId']);
         $viewReference['entityNamespace'] = XmlUtils::phpize($xmlReference[0]['entityNamespace']);
         $viewReference['url'] = XmlUtils::phpize($xmlReference[0]['url']);
         $viewReference['viewId'] = XmlUtils::phpize($xmlReference[0]['viewId']);
         $viewReference['viewNamespace'] = XmlUtils::phpize($xmlReference[0]['viewNamespace']);
         $viewReference['patternId'] = XmlUtils::phpize($xmlReference[0]['patternId']);
         $viewReference['name'] = XmlUtils::phpize($xmlReference[0]['name']);
     } else {
         $viewReference = null;
     }
     return $viewReference;
 }
开发者ID:Atc-it,项目名称:victoire,代码行数:22,代码来源:ViewCacheHelper.php

示例9: getAttributeAsPhp

 /**
  * Converts an attribute as a PHP type.
  *
  * @param SimpleXMLElement $xml
  * @param $name
  * @return mixed
  */
 public function getAttributeAsPhp(SimpleXMLElement $xml, $name)
 {
     return XmlUtils::phpize($xml[$name]);
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:11,代码来源:XmlFileLoader.php

示例10: phpize

 /**
  * Converts an xml value to a PHP type.
  *
  * @param mixed $value
  *
  * @return mixed
  */
 public static function phpize($value)
 {
     return \Symfony\Component\Config\Util\XmlUtils::phpize($value);
 }
开发者ID:ehough,项目名称:iconic,代码行数:11,代码来源:SimpleXMLElement.php

示例11: parseOptionNode

 protected function parseOptionNode(\DOMNodeList $nodes, $path)
 {
     $options = array();
     foreach ($nodes as $node) {
         $options[$this->readAttribute($node, 'name', sprintf('in "%s"', $path))] = XmlUtils::phpize($node->nodeValue);
     }
     return $options;
 }
开发者ID:viral810,项目名称:ngSimpleCMS,代码行数:8,代码来源:XmlFileLoader.php


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