本文整理汇总了PHP中Nette\Utils\Callback::invokeArgs方法的典型用法代码示例。如果您正苦于以下问题:PHP Callback::invokeArgs方法的具体用法?PHP Callback::invokeArgs怎么用?PHP Callback::invokeArgs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\Callback
的用法示例。
在下文中一共展示了Callback::invokeArgs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBodyContent
public function getBodyContent($data)
{
if (array_key_exists(self::CALLBACK, $this->option) === FALSE) {
if (isset($data[$this->option[self::ID]]) === FALSE && is_null($data[$this->option[self::ID]]) === FALSE) {
throw new Grid_Exception('Column ' . $this->option[self::ID] . ' does not exists in DataSource.');
}
$src = $data[$this->option[self::ID]];
} else {
$args = array($data);
if (isset($this->option[self::CALLBACK_ARGS])) {
if (!is_array($this->option[self::CALLBACK_ARGS])) {
throw new Grid_Exception(__CLASS__ . '::CALLBACK_ARGS must be an array. ' . gettype($this->option[self::CALLBACK_ARGS]) . ' given.');
}
$args = array_merge($args, $this->option[self::CALLBACK_ARGS]);
}
$src = Callback::invokeArgs($this->option[self::CALLBACK], $args);
}
$img = Html::el('img', array('src' => $src));
if (isset($this->option[self::MAX_WIDTH]) === TRUE) {
$img->style('max-width:' . $this->fixPixels($this->option[self::MAX_WIDTH]), TRUE);
}
if (isset($this->option[self::MAX_HEIGHT]) === TRUE) {
$img->style('max-height:' . $this->fixPixels($this->option[self::MAX_HEIGHT]), TRUE);
}
return $img;
}
示例2: filter
/**
* Filter data
* @param array $filters
* @return static
*/
public function filter(array $filters)
{
foreach ($filters as $filter) {
if ($filter->isValueSet()) {
if ($filter->hasConditionCallback()) {
Callback::invokeArgs($filter->getConditionCallback(), [$this->data_source, $filter->getValue()]);
} else {
if ($filter instanceof Filter\FilterText) {
$this->applyFilterText($filter);
} else {
if ($filter instanceof Filter\FilterMultiSelect) {
$this->applyFilterMultiSelect($filter);
} else {
if ($filter instanceof Filter\FilterSelect) {
$this->applyFilterSelect($filter);
} else {
if ($filter instanceof Filter\FilterDate) {
$this->applyFilterDate($filter);
} else {
if ($filter instanceof Filter\FilterDateRange) {
$this->applyFilterDateRange($filter);
} else {
if ($filter instanceof Filter\FilterRange) {
$this->applyFilterRange($filter);
}
}
}
}
}
}
}
}
}
return $this;
}
示例3: formatValue
public function formatValue($row)
{
if ($this->callback) {
return Callback::invokeArgs($this->callback, [$row, $this]);
}
return $this->getChainedValue($row);
}
示例4: dispatch
/**
* @param AbstractRequest $request
* @return AbstractResponse
* @throws DispatcherException
*/
public function dispatch(AbstractRequest $request)
{
switch ($request->getType()) {
case AbstractRequest::TYPE_CONFIRM:
if (!$this->confirmCallback) {
throw new DispatcherException("Dispatcher: Confirm callback is not defined.");
}
$res = Callback::invokeArgs($this->confirmCallback, [$request, $this->prepareConfirmResponse()]);
if (!$res instanceof ConfirmResponse) {
throw new DispatcherException('Return value from callback is not ConfirmResponse type.');
}
return $res;
case AbstractRequest::TYPE_SMS:
if (!$this->smsCallback) {
throw new DispatcherException("Dispatcher: Info callback is not defined.");
}
$res = Callback::invokeArgs($this->smsCallback, [$request, $this->prepareResponse()]);
if (!$res instanceof Response) {
throw new DispatcherException('Return value from callback is not Response type.');
}
return $res;
default:
throw new DispatcherException("Dispatcher: Uknown request type.");
}
}
示例5: getValue
/**
* @param mixin $row
* @return mixin
*/
public function getValue($row)
{
if ($this->valueCallback === NULL) {
return is_array($row) ? $row[$this->name] : $row->{$this->name};
}
return Callback::invokeArgs($this->valueCallback, [$row]);
}
示例6: fetchObject
/**
* @param \Venne\DataTransfer\DataTransferQuery $query
* @return \Venne\DataTransfer\DataTransferObject
*/
public function fetchObject(DataTransferQuery $query)
{
$class = '\\' . trim($query->getClass(), '\\');
$values = $query->getValues();
if (!class_exists($class)) {
throw new InvalidArgumentException(sprintf('Class \'%s\' does not exist.', $class));
}
if (!is_subclass_of($class, 'Venne\\DataTransfer\\DataTransferObject')) {
throw new InvalidArgumentException(sprintf('Class \'%s\' must inherit from \'Venne\\DataTransfer\\DataTransferObject\'.', $class));
}
if (!$query->isCacheEnabled()) {
return new $class(function () use(&$values, $class) {
$values = is_callable($values) ? Callback::invokeArgs($values) : $values;
return $this->driver->getValuesByObject($values, $class::getKeys());
});
}
$cacheDependencies = $query->getCacheDependencies();
$primaryKeysCacheKey = $this->formatPrimaryKeysCacheKey($class, $query->getCacheKey());
$primaryKey = $this->cache->load($primaryKeysCacheKey, function (&$dependencies) use(&$values, &$cacheDependencies) {
$values = is_callable($values) ? Callback::invoke($values) : $values;
$dependencies = Arrays::mergeTree((array) $cacheDependencies, $this->driver->getCacheDependenciesByObject($values));
return $this->driver->getPrimaryKeyByObject($values);
});
$loadedValues = $this->cache->load(array($this->formatValuesCacheKey($class, $primaryKey), $primaryKeysCacheKey), function (&$dependencies) use(&$values, &$cacheDependencies, $class) {
$values = is_callable($values) ? Callback::invoke($values) : $values;
$dependencies = Arrays::mergeTree((array) $cacheDependencies, $this->driver->getCacheDependenciesByObject($values));
/** @var DataTransferObject $dto */
$dto = new $class($this->driver->getValuesByObject($values, $class::getKeys()));
return $dto->toArray();
});
return new $class($loadedValues, true);
}
示例7: handleAutocomplete
public function handleAutocomplete($q)
{
if (!$this->callback) {
throw new Nette\InvalidStateException('Undefined Typehad callback.');
}
$this->getPresenter()->sendJson(Nette\Utils\Callback::invokeArgs($this->callback, [$q]));
}
示例8: createRouter
/**
* @param string $mask example images/<format>/<month>/<image>
* @param IImageCallback $presenterCallback
* @return Route
*/
public static function createRouter($mask, IImageCallback $presenterCallback)
{
$filterIn = function ($params) {
if ($params['presenter'] != 'Nette:Micro' || !isset($params['image']) || !isset($params['format'])) {
return NULL;
}
return $params;
};
$filterOut = function ($params) use($mask) {
if ($params['presenter'] != 'Nette:Micro' || !isset($params['image']) || !isset($params['format'])) {
return NULL;
}
if ($params['image'] instanceof IFile) {
$image = $params['image'];
/* @var $file IFile */
$params['image'] = $image->getName() . '.' . $image->getExt();
if (preg_match('/<month>/', $mask)) {
$params['month'] = $image->getUploaded()->format('Ym');
}
}
if ($params['format'] instanceof IImageFormat) {
$params['format'] = $params['format']->getName();
}
return $params;
};
$callback = function ($image, $format) use($presenterCallback) {
return \Nette\Utils\Callback::invokeArgs($presenterCallback, [$image, $format]);
};
$route = new Route($mask, [Route::PRESENTER_KEY => 'Nette:Micro', 'callback' => $callback, NULL => [Route::FILTER_IN => $filterIn, Route::FILTER_OUT => $filterOut]]);
return $route;
}
示例9: __call
public function __call($name, $args)
{
if (isset($this->methods[strtolower($name)])) {
return Callback::invokeArgs($this->methods[strtolower($name)], $args);
} else {
return parent::__call($name, $args);
}
}
示例10: getLink
/**
* Returns final link for button or null.
*
* @param $row
*
* @return string|null
*/
public function getLink($row)
{
if (!empty($this->linkCallback)) {
return Callback::invokeArgs($this->linkCallback, [$row]);
} else {
return null;
}
}
示例11: __call
/**
* Allows calling $column->icon() instead of $column->setIcon (Same for title, class, ...)
* @param string $name
* @param array $args
* @return mixed
*/
public function __call($name, $args)
{
$method_setter = 'set' . ucfirst($name);
if (method_exists($this, $method_setter)) {
return Nette\Utils\Callback::invokeArgs([$this, $method_setter], $args);
}
parent::__call($name, $args);
}
示例12: handleRemote
/**
* @param $params
* @throws \Nette\InvalidStateException
*/
public function handleRemote($params)
{
if (!is_callable($this->remote)) {
throw new Nette\InvalidStateException('Undefined Typehad callback.');
}
$q = array_key_exists('q', $params) ? $params['q'] : NULL;
// call remote function with displayed key and query
$this->presenter->sendJson(Nette\Utils\Callback::invokeArgs($this->remote, [$this->display, $q]));
}
示例13: getCount
public function getCount($filter, $order)
{
if (!isset($this->limit)) {
throw new InvalidStateException('Property limit must be set.');
}
if (!isset($this->offset)) {
throw new InvalidStateException('Property offset must be set.');
}
$selection = Callback::invokeArgs($this->callback, [$filter, $order]);
return $selection->count();
}
示例14: formatValue
public function formatValue($row)
{
if ($this->callback) {
return Callback::invokeArgs($this->callback, [$row, $this]);
}
$value = $this->getChainedValue($row);
if (!is_numeric($value)) {
$type = is_object($value) ? get_class($value) : gettype($value);
throw new InvalidTypeException("Expected numeric value, but '{$type}' given from '{$this->getName()}'");
}
return number_format($value, $this->precision, $this->decimalSeparator, $this->thousandSeparator);
}
示例15: 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);
}