本文整理匯總了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
}
}