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


PHP Framework::fixNamespace方法代码示例

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


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

示例1: getService

 /**
  * Gets the service object of the specified type.
  * @param  string service name
  * @param  array  options in case service is not singleton
  * @return mixed
  */
 public static function getService($name, array $options = NULL)
 {
     if (!is_string($name) || $name === '') {
         throw new InvalidArgumentException("Service name must be a non-empty string, " . gettype($name) . " given.");
     }
     $session = Environment::getSession('MokujiServiceLocator');
     $lower = strtolower($name);
     if (isset($session->{$lower})) {
         // instantiated singleton
         if ($options) {
             throw new InvalidArgumentException("Service named '{$name}' is singleton and therefore can not have options.");
         }
         return $session->{$lower};
     } elseif (isset($session->factories[$lower])) {
         list($factory, $singleton, $defOptions) = $session->factories[$lower];
         if ($singleton && $options) {
             throw new InvalidArgumentException("Service named '{$name}' is singleton and therefore can not have options.");
         } elseif ($defOptions) {
             $options = $options ? $options + $defOptions : $defOptions;
         }
         if (is_string($factory) && strpos($factory, ':') === FALSE) {
             // class name
             Framework::fixNamespace($factory);
             if (!class_exists($factory)) {
                 throw new AmbiguousServiceException("Cannot instantiate service '{$name}', class '{$factory}' not found.");
             }
             $service = new $factory();
             if ($options && method_exists($service, 'setOptions')) {
                 $service->setOptions($options);
                 // TODO: better!
             }
         } else {
             // factory callback
             $factory = callback($factory);
             if (!$factory->isCallable()) {
                 throw new InvalidStateException("Cannot instantiate service '{$name}', handler '{$factory}' is not callable.");
             }
             $service = $factory->invoke($options);
             if (!is_object($service)) {
                 throw new AmbiguousServiceException("Cannot instantiate service '{$name}', value returned by '{$factory}' is not object.");
             }
         }
         if ($singleton) {
             $session->{$lower} = $service;
             unset($session->factories[$lower]);
         }
         return $service;
     }
     if ($this->parent !== NULL) {
         return $this->parent->getService($name, $options);
     } else {
         throw new InvalidStateException("Service '{$name}' not found.");
     }
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:60,代码来源:MokujiServiceLocator.php

示例2: getMailer

 /**
  * Returns mailer.
  * @return IMailer
  */
 public function getMailer()
 {
     if ($this->mailer === NULL) {
         Framework::fixNamespace(self::$defaultMailer);
         $this->mailer = is_object(self::$defaultMailer) ? self::$defaultMailer : new self::$defaultMailer();
     }
     return $this->mailer;
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:12,代码来源:Mail.php

示例3: unmonitor

 /**
  * Stops monitoring.
  * @param  string class/interface type
  * @return void
  */
 public function unmonitor($type)
 {
     Framework::fixNamespace($type);
     unset($this->monitors[$type]);
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:10,代码来源:Component.php

示例4: getComponents

 /**
  * Iterates over a components.
  * @param  bool    recursive?
  * @param  string  class types filter
  * @return ArrayIterator
  */
 public final function getComponents($deep = FALSE, $filterType = NULL)
 {
     $iterator = new RecursiveComponentIterator($this->components);
     if ($deep) {
         $deep = $deep > 0 ? RecursiveIteratorIterator::SELF_FIRST : RecursiveIteratorIterator::CHILD_FIRST;
         $iterator = new RecursiveIteratorIterator($iterator, $deep);
     }
     if ($filterType) {
         Framework::fixNamespace($filterType);
         $iterator = new InstanceFilterIterator($iterator, $filterType);
     }
     return $iterator;
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:19,代码来源:ComponentContainer.php


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