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


PHP Callback::isCallable方法代码示例

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


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

示例1: getMPDF

	/**
	 * Returns mPDF object
	 * @return mPDFExtended
	 */
	public function getMPDF() {
		if(!$this->mPDF instanceof mPDF) {
			if($this->createMPDF instanceof Callback && $this->createMPDF->isCallable()) {
				$mpdf = $this->createMPDF->invoke($this);
				if(!($mpdf instanceof \mPDF)) {
					throw new \Nette\InvalidStateException("Callback function createMPDF must return mPDF object!");
				}
				$this->mPDF = $mpdf;
			}else
				throw new \Nette\InvalidStateException("Callback createMPDF is not callable or is not instance of Nette\Callback!");
		}
		return $this->mPDF;
	}
开发者ID:Johnik010,项目名称:rezervace,代码行数:17,代码来源:PDFResponse.php

示例2: resolveClass

 private function resolveClass($name, $recursive = array())
 {
     if (isset($recursive[$name])) {
         throw new Nette\InvalidArgumentException('Circular reference detected for services: ' . implode(', ', array_keys($recursive)) . '.');
     }
     $recursive[$name] = TRUE;
     $def = $this->definitions[$name];
     $factory = $this->normalizeEntity($this->expand($def->factory->entity));
     if ($def->class) {
         return $def->class;
     } elseif (is_array($factory)) {
         // method calling
         if ($service = $this->getServiceName($factory[0])) {
             if (Strings::contains($service, '\\')) {
                 // @\Class
                 throw new ServiceCreationException("Unable resolve class name for service '{$name}'.");
             }
             $factory[0] = $this->resolveClass($service, $recursive);
             if (!$factory[0]) {
                 return;
             }
         }
         $factory = new Nette\Callback($factory);
         if (!$factory->isCallable()) {
             throw new Nette\InvalidStateException("Factory '{$factory}' is not callable.");
         }
         try {
             $reflection = $factory->toReflection();
             $def->class = preg_replace('#[|\\s].*#', '', $reflection->getAnnotation('return'));
             if ($def->class && !class_exists($def->class) && $def->class[0] !== '\\' && $reflection instanceof \ReflectionMethod) {
                 $def->class = $reflection->getDeclaringClass()->getNamespaceName() . '\\' . $def->class;
             }
         } catch (\ReflectionException $e) {
         }
     } elseif ($service = $this->getServiceName($factory)) {
         // alias or factory
         if (Strings::contains($service, '\\')) {
             // @\Class
             $def->autowired = FALSE;
             return $def->class = $service;
         }
         if ($this->definitions[$service]->shared) {
             $def->autowired = FALSE;
         }
         return $def->class = $this->resolveClass($service, $recursive);
     } else {
         return $def->class = $factory;
         // class name
     }
 }
开发者ID:BroukPytlik,项目名称:agility,代码行数:50,代码来源:ContainerBuilder.php


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