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


PHP Reference::getInvalidBehavior方法代码示例

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


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

示例1: getServiceCall

 protected function getServiceCall($id, Reference $reference = null)
 {
     if ('service_container' === $id) {
         return '$this';
     }
     if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
         return sprintf('$this->get(\'%s\', ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id);
     } else {
         if ($this->container->hasAlias($id)) {
             $id = $this->container->getAlias($id);
         }
         return sprintf('$this->get(\'%s\')', $id);
     }
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:14,代码来源:PhpDumper.php

示例2: getServiceCall

 /**
  * Gets the service call.
  *
  * @param string    $id
  * @param Reference $reference
  *
  * @return string
  */
 private function getServiceCall($id, Reference $reference = null)
 {
     if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
         return sprintf('@?%s', $id);
     }
     return sprintf('@%s', $id);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:15,代码来源:YamlDumper.php

示例3: getServiceCall

 /**
  * Gets a service call.
  *
  * @param string    $id
  * @param Reference $reference
  *
  * @return string
  */
 private function getServiceCall($id, Reference $reference = null)
 {
     if ('service_container' === $id) {
         return '$this';
     }
     if ($this->container->hasDefinition($id) && !$this->container->getDefinition($id)->isPublic()) {
         // The following is PHP 5.5 syntax for what could be written as "(\$this->services['$id'] ?? \$this->{$this->generateMethodName($id)}())" on PHP>=7.0
         return "\${(\$_ = isset(\$this->services['{$id}']) ? \$this->services['{$id}'] : \$this->{$this->generateMethodName($id)}()) && false ?: '_'}";
     }
     if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
         return sprintf('$this->get(\'%s\', ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id);
     } else {
         if ($this->container->hasAlias($id)) {
             $id = (string) $this->container->getAlias($id);
         }
         return sprintf('$this->get(\'%s\')', $id);
     }
 }
开发者ID:OndraM,项目名称:symfony,代码行数:26,代码来源:PhpDumper.php

示例4: getReferenceCall

 /**
  * Gets a service reference for a reference in a suitable PHP array format.
  *
  * The main difference is that this function treats references to private
  * services differently and returns a private service reference instead of
  * a normal reference.
  *
  * @param string $id
  *   The ID of the service to get a reference for.
  * @param \Symfony\Component\DependencyInjection\Reference|NULL $reference
  *   (optional) The reference object to process; needed to get the invalid
  *   behavior value.
  *
  * @return string|\stdClass
  *   A suitable representation of the service reference.
  */
 protected function getReferenceCall($id, Reference $reference = NULL)
 {
     $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
     if ($reference !== NULL) {
         $invalid_behavior = $reference->getInvalidBehavior();
     }
     // Private shared service.
     $definition = $this->container->getDefinition($id);
     if (!$definition->isPublic()) {
         // The ContainerBuilder does not share a private service, but this means a
         // new service is instantiated every time. Use a private shared service to
         // circumvent the problem.
         return $this->getPrivateServiceCall($id, $definition, TRUE);
     }
     return $this->getServiceCall($id, $invalid_behavior);
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:32,代码来源:OptimizedPhpArrayDumper.php

示例5: getXmlInvalidBehavior

 protected function getXmlInvalidBehavior(Reference $reference)
 {
     switch ($reference->getInvalidBehavior()) {
         case ContainerInterface::NULL_ON_INVALID_REFERENCE:
             return 'on-invalid="null" ';
         case ContainerInterface::IGNORE_ON_INVALID_REFERENCE:
             return 'on-invalid="ignore" ';
         default:
             return '';
     }
 }
开发者ID:spf13,项目名称:symfony,代码行数:11,代码来源:XmlDumper.php


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