本文整理汇总了PHP中Nette\Callback::invoke方法的典型用法代码示例。如果您正苦于以下问题:PHP Callback::invoke方法的具体用法?PHP Callback::invoke怎么用?PHP Callback::invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Callback
的用法示例。
在下文中一共展示了Callback::invoke方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createComponentForm
/**
* @return MailControl
*/
protected function createComponentForm()
{
/** @var $control MailControl */
$control = $this->mailControlFactory->invoke($this->extendedPage->mailform);
$control->onSuccess[] = $this->formSuccess;
return $control;
}
示例2: render
/**
* @param Entity $row
*/
public function render(Entity $row)
{
$button = Html::el('a');
$button->class[] = 'btn';
$button->class[] = 'btn-mini';
$button->class[] = $this->class;
// Check if disabled
if ($this->disabled !== NULL) {
if ($this->disabled->invoke($row) === true) {
return;
}
}
if ($this->ajax === true) {
$button->class[] = 'ajax';
}
if ($this->confirmation !== NULL) {
$button->data['confirm'] = is_callable($this->confirmation) ? $this->confirmation->invoke($row) : $this->confirmation;
}
if ($this->callback !== NULL) {
$primaryKey = $this->getGrid()->getPrimaryKey();
$button->href($this->link('click', ['row' => $row->__get($primaryKey)]));
}
$button->setText($this->label);
echo $button;
}
示例3: prepareFilters
public function prepareFilters(Template $template)
{
$this->latte = $this->latteFactory->invoke();
foreach ($this->macroFactories as $factory) {
$this->container->{Container::getMethodName($factory, FALSE)}($this->latte->getCompiler());
}
$template->registerFilter($this->latte);
}
示例4: confirmRedirect
/**
* Asks for confirmation whether to manually follow redirect
* @param Response $response
*
* @return boolean
*/
protected function confirmRedirect(Response $response)
{
if ($this->confirmRedirect !== NULL) {
return (bool) $this->confirmRedirect->invoke($response);
}
return TRUE;
}
示例5: setPermissionsByRole
/**
* Setup permission by role
*
* @param Permission $permission
* @param string $role
* @return Permission
*/
protected function setPermissionsByRole(Permission $permission, $role)
{
if ($role == 'admin') {
$permission->allow('admin', Permission::ALL);
return $permission;
}
if ($this->checkConnection->invoke()) {
$roleEntity = $this->roleRepository->findOneByName($role);
if ($roleEntity) {
if ($roleEntity->parent) {
$this->setPermissionsByRole($permission, $roleEntity->parent->name);
}
if ($roleEntity && !$permission->hasRole($role)) {
$permission->addRole($role, $roleEntity->parent ? $roleEntity->parent->name : NULL);
}
// allow/deny
foreach ($roleEntity->permissions as $perm) {
if ($permission->hasResource($perm->resource)) {
if ($perm->allow) {
$permission->allow($role, $perm->resource, $perm->privilege ? $perm->privilege : NULL);
} else {
$permission->deny($role, $perm->resource, $perm->privilege ? $perm->privilege : NULL);
}
}
}
}
}
return $permission;
}
示例6: invoke
/**
* @param null $data
* @return Form
* @throws \Nette\InvalidStateException
*/
public function invoke($data = NULL)
{
if (!$this->factory) {
throw new InvalidStateException('Form factory has not been set');
}
/** @var $form Form */
$form = $this->factory->invoke();
if ($data) {
$form->setData($data);
}
$form->setMapper($this->getMapper());
foreach ($this->getControlExtensions() as $controlExtension) {
$form->addControlExtension($controlExtension);
}
$this->configure($form);
$this->attachHandlers($form);
return $form;
}
示例7: render
/**
* @param Entity $row
*/
public function render(Entity $row)
{
$el = Html::el('i');
if ($row->{$this->column} === true) {
$el->class[] = 'icon-ok';
} else {
$el->class[] = 'icon-remove';
}
if ($this->callback !== NULL) {
$icon = $el;
$primaryKey = $this->getGrid()->getPrimaryKey();
if ($this->disabled !== NULL && $this->disabled->invoke($row) === true || $this->disabled === NULL) {
$el = Html::el('a')->href($this->link('click', ['row' => $row->__get($primaryKey)]));
$el->class[] = $this->ajax === true ? 'ajax' : NULL;
$el->add($icon);
}
}
echo $el;
}
示例8: authenticate
/**
* Performs an authentication
*
* @param array
* @return \Nette\Security\Identity
* @throws AuthenticationException
*/
public function authenticate(array $credentials)
{
try {
return parent::authenticate($credentials);
} catch (AuthenticationException $ex) {
list($username, $password) = $credentials;
if ($this->checkConnection->invoke()) {
$user = $this->userRepository->findOneBy(array('email' => $username, 'published' => 1));
if (!$user) {
throw $ex;
}
if (!$user->verifyByPassword($password)) {
throw new AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL);
}
return new Identity($user->id, $user->getRoles());
}
throw $ex;
}
}
示例9: 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;
}
示例10: createComponent
protected function createComponent($name)
{
return $this->factory->invoke($name, $this);
}
示例11: createComponent
/**
* Creates WebPay control for handling WebPay requests/responses
*
* @param vStore\Shop\Order
* @param Nette\Callback callback for successful payment handling
* @param Nette\Callback callback for unsuccessful payment handling
*
* @return vStore\Application\UI\Controls\WebPay
*/
function createComponent(Order $order, Nette\Callback $onSuccessCallback, Nette\Callback $onErrorCallback)
{
$wp = new WebPay();
$wp->setRequestUrl($this->_muzoGatewayUrl);
$wp->setMerchantNumber($this->_muzoMerchantNumber);
$wp->setPublicKey($this->_muzoGatewayPublicKey);
$wp->setPrivateKey($this->_muzoMerchantPrivateKey, $this->_muzoMerchantPasspharse);
// Vytvareni pozadavku
$wp->onCreate[] = function (WebPay $webPay, WebPayRequest $request) use($order) {
// Pořadové číslo objednávky. Je potřeba při každém i nepovedeném požadavku změnit.
// Maximální délka je 15 číslic (YYMM NNNN SSSSSSS)
$orderNumber = $order->timestamp->format('ym') . str_pad(mb_substr($order->id, 6), 4, "0", STR_PAD_LEFT);
// 2*Y + 2*M + {1..4}N => 8 cifer
$timeDiff = abs(time() - $order->timestamp->getTimestamp());
// Pokud je objednavka starsi jak cca 115 dni, tak by doslo k preteceni citace (Mame k dispozici jen 7 cifer)
if ($timeDiff > 9999999) {
throw new Nette\InvalidStateException("Order is too old for direct payment.");
}
$request->setOrderNumber($orderNumber . str_pad($timeDiff, 7, "0", STR_PAD_LEFT));
// Cena objednavky v halirich
$request->setAmount(($order->total + $order->ceiling) * 100, 'CZK', true);
};
// Pri uspesne dokoncene objednavce (PRCODE = 0, SRCODE = 0, overeno verejnym certifikatem)
$wp->onResponse = array();
$wp->onResponse[] = function (WebPay $webPay, WebPayResponse $response) use($onSuccessCallback, $order) {
$order->isPaid = true;
$order->save();
$onSuccessCallback->invoke($order);
};
// Pri chybe (PRCODE <> 0 || SRCODE <> 0)
$wp->onError = array();
$wp->onError[] = function (WebPay $webPay, WebPayException $exception) use($onErrorCallback, $order) {
$msg = $exception->getMessage();
// Překlad chybových zpráv
if ($exception->getPrimaryCode() == 30) {
switch ($exception->getSecondaryCode()) {
case 1001:
$msg = "Neúspěšná autorizace – karta blokovaná.";
break;
case 1002:
$msg = "Autorizace zamítnuta.";
break;
case 1003:
$msg = "Neúspěšná autorizace – problém karty. Kontaktujte vydavatele karty.";
break;
case 1004:
$msg = "Neúspěšná autorizace – technický problém v autorizačním centru.";
break;
case 1005:
$msg = "Neúspěšná autorizace – problém účtu. Kontaktujte vydavatele karty.";
break;
default:
Nette\Diagnostics\Debugger::log($exception);
}
} elseif ($exception->getPrimaryCode() == 28) {
switch ($exception->getSecondaryCode()) {
case 3000:
$msg = "Neúspěšné ověření držitele karty. Kontaktujte vydavatele karty.";
break;
case 3001:
$msg = "Autorizace zamítnuta.";
break;
case 3002:
$msg = "Vydavatel karty nebo karta není zapojena do 3D. Kontaktujte vydavatele karty.";
break;
case 3004:
$msg = "Vydavatel karty není zapojen do 3D nebo karta\nnebyla aktivována. Kontaktujte vydavatele.";
break;
case 3005:
$msg = "Technický problém při ověření držitele karty.\nKontaktujte vydavatele karty.";
break;
case 3006:
$msg = "Technický problém při ověření držitele karty.";
break;
case 3007:
$msg = "Technický problém v systému zúčtující banky. Kontaktujte obchodníka.";
break;
case 3008:
$msg = "Použit nepodporovaný karetní produkt. Kontaktujte vydavatele karty.";
break;
default:
Nette\Diagnostics\Debugger::log($exception);
}
} elseif ($exception->getPrimaryCode() == 17) {
$msg = "Částka k úhradě překročila autorizovanou částku.";
} elseif ($exception->getPrimaryCode() == 18) {
$msg = "Součet kreditovaných částek překročil uhrazenou částku.";
} elseif ($exception->getPrimaryCode() == 35) {
$msg = "Vypršel časový limit pro provedení platby.";
} else {
Nette\Diagnostics\Debugger::log($exception);
//.........这里部分代码省略.........
示例12: constructUrl
/**
* Constructs absolute URL from Request object.
*
* @param Nette\Application\Request
* @param Nette\Http\Url
* @return string|NULL
*/
public function constructUrl(Request $appRequest, Url $refUrl)
{
if (!$this->checkConnectionFactory->invoke()) {
return NULL;
}
$parameters = $appRequest->getParameters();
$key = (array) $parameters;
unset($key['_route']);
unset($key['_page']);
if (isset($key['route']) && is_object($key['route'])) {
$key['route'] = $key['route'] instanceof RouteEntity ? $key['route']->id : $key['route']->route->id;
}
unset($key['page']);
$data = $this->cache->load($key);
if ($data) {
return $data;
}
if (isset($parameters['special'])) {
$special = $parameters['special'];
unset($parameters['special']);
if (count($this->languages) > 1) {
if (!isset($parameters['lang'])) {
$parameters['lang'] = $this->defaultLanguage;
}
try {
if ($special === 'main') {
$route = $this->getRouteRepository()->createQueryBuilder('a')->leftJoin('a.page', 'm')->leftJoin('m.language', 'p')->andWhere('p.alias = :lang OR a.language IS NULL')->andWhere('m.mainRoute = a.id AND a.url = :url')->setParameter('lang', $parameters['lang'])->setParameter('url', '')->getQuery()->getSingleResult();
} else {
$route = $this->getRouteRepository()->createQueryBuilder('a')->leftJoin('a.page', 'm')->leftJoin('m.language', 'p')->where('m.special = :special')->andWhere('p.alias = :lang OR a.language IS NULL')->andWhere('m.mainRoute = a.id')->setParameter('special', $special)->setParameter('lang', $parameters['lang'])->getQuery()->getSingleResult();
}
} catch (NoResultException $e) {
return NULL;
}
} else {
try {
if ($special === 'main') {
$route = $this->getRouteRepository()->createQueryBuilder('a')->andWhere('a.url = :url')->setParameter('url', '')->getQuery()->getSingleResult();
} else {
$route = $this->getRouteRepository()->createQueryBuilder('a')->leftJoin('a.page', 'm')->andWhere('m.special = :special')->andWhere('m.mainRoute = a.id')->setParameter('special', $special)->getQuery()->getSingleResult();
}
} catch (NoResultException $e) {
return NULL;
}
}
$route = $route->id;
} elseif (isset($parameters['route'])) {
$route = is_object($parameters['route']) ? $parameters['route'] instanceof ExtendedRouteEntity ? $parameters['route']->route->id : $parameters['route']->id : $parameters['route'];
unset($parameters['route']);
} elseif (isset($parameters['_route'])) {
$route = $parameters['_route']->id;
} elseif (isset($parameters['routeId'])) {
$route = $parameters['routeId'];
} else {
return NULL;
}
$domain = $parameters['_domain'];
unset($parameters['_route']);
unset($parameters['_page']);
unset($parameters['_domain']);
unset($parameters['routeId']);
unset($parameters['pageId']);
$this->modifyConstructRequest($appRequest, $this->getRouteRepository()->find($route), $parameters, $domain);
$data = parent::constructUrl($appRequest, $refUrl);
$this->cache->save($key, $data, array(Cache::TAGS => array(RouteEntity::CACHE)));
return $data;
}