本文整理汇总了PHP中Nette\Utils\Callback::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Callback::check方法的具体用法?PHP Callback::check怎么用?PHP Callback::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\Callback
的用法示例。
在下文中一共展示了Callback::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param string $name
* @param string $caption
* @param callable $callback
*/
public function __construct($name, $caption, $callback)
{
$this->name = $name;
$this->caption = $caption;
Callback::check($callback);
$this->callback = $callback;
}
示例2: getHeaderContent
public function getHeaderContent()
{
if (array_key_exists(self::CALLBACK, $this->option)) {
Callback::check($this->option[self::CALLBACK]);
}
return $this->getTranslator() ? $this->getTranslator()->translate($this->option[self::HEADER]) : $this->option[self::HEADER];
}
示例3: addCallbackItem
public function addCallbackItem($name, $description, $callback)
{
$this->check($name);
Callback::check($callback);
$item = new CallbackItem($this, $name, $description, $callback);
$this->items[$name] = $item;
return $item;
}
示例4: setQueues
public function setQueues(array $queues)
{
$this->queues = array();
foreach ($queues as $name => $queue) {
if (!isset($queue['callback'])) {
throw new InvalidArgumentException("The queue '{$name}' is missing a callback.");
}
Callback::check($queue['callback']);
$this->queues[$name] = $queue;
}
}
示例5: addMacro
public function addMacro($name, $begin, $end = NULL, $attr = NULL)
{
foreach (array($begin, $end, $attr) as $arg) {
if ($arg && !is_string($arg)) {
Nette\Utils\Callback::check($arg);
}
}
$this->macros[$name] = array($begin, $end, $attr);
$this->compiler->addMacro($name, $this);
return $this;
}
示例6: __construct
/**
* @param NSelection $selection
* @param string|callable $entity
* @param string $refTable
* @param string $refColumn
*/
public function __construct(NSelection $selection, $entity, $refTable = NULL, $refColumn = NULL)
{
$this->selection = $selection;
$this->refTable = $refTable;
$this->refColumn = $refColumn;
try {
NCallback::check($entity);
$this->entity = NCallback::closure($entity);
} catch (\Exception $e) {
$this->entity = $entity;
}
}
示例7: getBodyContent
public function getBodyContent($data)
{
$template = $this->getTemplate();
if (array_key_exists(self::CALLBACK, $this->option)) {
Callback::check($this->option[self::CALLBACK]);
$args = array($data, $template);
if (isset($this->option[self::CALLBACK_ARGS]) && is_array($this->option[self::CALLBACK_ARGS])) {
$args = array_merge($args, $this->option[self::CALLBACK_ARGS]);
}
Callback::invokeArgs($this->option[self::CALLBACK], $args);
}
return trim($template);
}
示例8: run
/**
* @return Nette\Application\IResponse
*/
public function run(Application\Request $request)
{
$this->request = $request;
if ($this->httpRequest && $this->router && !$this->httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
$refUrl = clone $this->httpRequest->getUrl();
$url = $this->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
if ($url !== NULL && !$this->httpRequest->getUrl()->isEqual($url)) {
return new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
}
}
$params = $request->getParameters();
if (!isset($params['callback'])) {
throw new Application\BadRequestException('Parameter callback is missing.');
}
$params['presenter'] = $this;
$callback = $params['callback'];
$reflection = Nette\Utils\Callback::toReflection(Nette\Utils\Callback::check($callback));
$params = Application\UI\PresenterComponentReflection::combineArgs($reflection, $params);
if ($this->context) {
foreach ($reflection->getParameters() as $param) {
if ($param->getClassName()) {
unset($params[$param->getPosition()]);
}
}
$params = Nette\DI\Helpers::autowireArguments($reflection, $params, $this->context);
$params['presenter'] = $this;
}
$response = call_user_func_array($callback, $params);
if (is_string($response)) {
$response = array($response, array());
}
if (is_array($response)) {
list($templateSource, $templateParams) = $response;
$response = $this->createTemplate()->setParameters($templateParams);
if (!$templateSource instanceof \SplFileInfo) {
$response->getLatte()->setLoader(new Latte\Loaders\StringLoader);
}
$response->setFile($templateSource);
}
if ($response instanceof Application\UI\ITemplate) {
return new Responses\TextResponse($response);
} else {
return $response;
}
}
示例9: closure
/**
* @param mixed class, object, callable
* @param string method
* @return \Closure
*/
public static function closure($callable, $m = NULL)
{
if ($m !== NULL) {
$callable = array($callable, $m);
} elseif ($callable instanceof \Closure) {
return $callable;
}
self::check($callable, TRUE);
$_callable_ = $callable;
return function () use($_callable_) {
Callback::check($_callable_);
return call_user_func_array($_callable_, func_get_args());
};
}
示例10: flatMapAssoc
/**
* @param array|\Traversable $array
* @param callable $callback
* @return array
*/
public static function flatMapAssoc($array, $callback)
{
Callback::check($callback);
$result = array();
$walker = function ($array, $keys = array()) use(&$walker, &$result, $callback) {
foreach ($array as $key => $value) {
$currentKeys = $keys + array(count($keys) => $key);
if (is_array($value)) {
$walker($value, $currentKeys);
continue;
}
$result[] = $callback($value, $currentKeys);
}
return $result;
};
return $walker($array);
}
示例11: addFilter
/**
* Adds a filter callback.
* @param callable
* @return self
*/
public function addFilter($filter)
{
Nette\Utils\Callback::check($filter);
$this->rules[] = $rule = new Rule();
$rule->control = $this->control;
$rule->validator = function (IControl $control) use($filter) {
$control->setValue(call_user_func($filter, $control->getValue()));
return TRUE;
};
return $this;
}
示例12: setRowIdentifierCallback
/**
* @param string|callable $callback
* @return self
*/
public function setRowIdentifierCallback($callback)
{
Callback::check($callback);
$this->rowIdentifierCallback = $callback;
return $this;
}
示例13: setPagination
public function setPagination($itemsPerPage, $itemsCountCallback = NULL)
{
if ($itemsPerPage === FALSE) {
$this->paginator = NULL;
$this->paginatorItemsCountCallback = NULL;
} else {
if ($itemsCountCallback === NULL) {
throw new \InvalidArgumentException('Items count callback must be set.');
}
Callback::check($itemsCountCallback);
$this->paginator = new Paginator();
$this->paginator->itemsPerPage = $itemsPerPage;
$this->paginatorItemsCountCallback = $itemsCountCallback;
}
}
示例14: __construct
/**
* @param string $caption column's textual caption
* @param string $format date format supported by $func
* @param string $func function to format date
*/
public function __construct($caption = NULL, $format = '%x', $func = 'strftime')
{
parent::__construct($caption);
$this->format = $format;
$this->func = \Nette\Utils\Callback::check($func);
}
示例15: setFilterFormFactory
public function setFilterFormFactory($filterFormFactory)
{
Callback::check($filterFormFactory);
$this->filterFormFactory = $filterFormFactory;
}