本文整理汇总了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;
}
示例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
}
}