當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Nette\Callback類代碼示例

本文整理匯總了PHP中Nette\Callback的典型用法代碼示例。如果您正苦於以下問題:PHP Callback類的具體用法?PHP Callback怎麽用?PHP Callback使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Callback類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * @return Nette\Application\IResponse
  */
 public function run(Application\Request $request)
 {
     $this->request = $request;
     $httpRequest = $this->context->getByType('Nette\\Http\\IRequest');
     if (!$httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
         $refUrl = clone $httpRequest->getUrl();
         $url = $this->context->getService('router')->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
         if ($url !== NULL && !$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 = new Nette\Callback($params['callback']);
     $response = $callback->invokeArgs(Application\UI\PresenterComponentReflection::combineArgs($callback->toReflection(), $params));
     if (is_string($response)) {
         $response = array($response, array());
     }
     if (is_array($response)) {
         if ($response[0] instanceof \SplFileInfo) {
             $response = $this->createTemplate('Nette\\Templating\\FileTemplate')->setParameters($response[1])->setFile($response[0]);
         } else {
             $response = $this->createTemplate('Nette\\Templating\\Template')->setParameters($response[1])->setSource($response[0]);
         }
     }
     if ($response instanceof Nette\Templating\ITemplate) {
         return new Responses\TextResponse($response);
     } else {
         return $response;
     }
 }
開發者ID:svobodni,項目名稱:web,代碼行數:37,代碼來源:MicroPresenter.php

示例2: attached

 public function attached($presenter)
 {
     parent::attached($presenter);
     $this->column = $this->lookup('Brabijan\\Datagrid\\Renderer')->getColumn($this->columnId);
     if ($this->templateRowCallback) {
         $this->templateRowCallback->invokeArgs(array($this));
     }
 }
開發者ID:brabijan,項目名稱:datagrid,代碼行數:8,代碼來源:Column.php

示例3: setDisabled

 /**
  * @param $callback
  * @return $this
  * @throws \movi\InvalidArgumentException
  */
 public function setDisabled($callback)
 {
     if (!is_callable($callback)) {
         throw new InvalidArgumentException('Callback is not callable');
     }
     $this->disabled = Callback::create($callback);
     return $this;
 }
開發者ID:peterzadori,項目名稱:movi,代碼行數:13,代碼來源:Boolean.php

示例4: loader

 /**
  * @param $helper
  * @return callable
  * @throws \movi\InvalidArgumentException
  */
 public function loader($helper)
 {
     if (isset($this->helpers[$helper])) {
         return Callback::create($this->helpers[$helper], 'process');
     } else {
         return false;
     }
 }
開發者ID:peterzadori,項目名稱:movi,代碼行數:13,代碼來源:Helpers.php

示例5: onSuccess

 public function onSuccess(Form $form)
 {
     if (!Callback::create($this->checkConnection)->invoke() || !$this->schemaManager->tablesExist('users')) {
         return;
     }
     $presenter = $form->presenter;
     $logEntity = new LogEntity($this->user instanceof UserEntity ? $this->user : NULL, 'Venne\\Forms\\Form', NULL, LogEntity::ACTION_OTHER);
     $logEntity->setType($presenter->link('this'));
     $logEntity->setMessage('Configuration has been updated');
     $this->logRepository->save($logEntity);
 }
開發者ID:svobodni,項目名稱:web,代碼行數:11,代碼來源:FormLogListener.php

示例6: signalReceived

 public function signalReceived($signal)
 {
     $query = $this->form->presenter->request->parameters['q'];
     if (!$this->suggestCallback) {
         throw new InvalidArgumentException("Property 'suggestCallback' is not defined.");
     }
     $data = Callback::create($this->suggestCallback)->invoke($query);
     if (!is_array($data)) {
         throw new InvalidArgumentException("Data from suggestCallback must be array.");
     }
     $this->form->getPresenter()->sendResponse(new JsonResponse(array('results' => $data, 'more' => FALSE)));
 }
開發者ID:svobodni,項目名稱:web,代碼行數:12,代碼來源:TagsInput.php

示例7: 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;
	}
開發者ID:Johnik010,項目名稱:rezervace,代碼行數:17,代碼來源:PDFResponse.php

示例8: log

 /**
  * Logs message or exception to file and sends email notification.
  * @param  string|array
  * @param  int     one of constant INFO, WARNING, ERROR (sends email), CRITICAL (sends email)
  * @return bool    was successful?
  */
 public function log($message, $priority = self::INFO)
 {
     if (!is_dir($this->directory)) {
         throw new Nette\DirectoryNotFoundException("Directory '{$this->directory}' is not found or is not directory.");
     }
     if (is_array($message)) {
         $message = implode(' ', $message);
     }
     $res = error_log(trim($message) . PHP_EOL, 3, $this->directory . '/' . strtolower($priority) . '.log');
     if (($priority === self::ERROR || $priority === self::CRITICAL) && $this->email && $this->mailer && @filemtime($this->directory . '/email-sent') + self::$emailSnooze < time() && @file_put_contents($this->directory . '/email-sent', 'sent')) {
         Nette\Callback::create($this->mailer)->invoke($message, $this->email);
     }
     return $res;
 }
開發者ID:anagio,項目名稱:woocommerce,代碼行數:20,代碼來源:Logger.php

示例9: render

 public function render()
 {
     if ($this->customTemplate === NULL) {
         $this->template->setFile(__DIR__ . '/control.latte');
     } else {
         $this->template->setFile($this->customTemplate);
         $this->template->extend = __DIR__ . '/control.latte';
     }
     $this->template->rows = array_keys($this->getData());
     if ($this->isPaginatorEnabled()) {
         $this->template->paginationPosition = $this->paginationPositions;
         $this->template->paginator = $this->paginator;
     } else {
         $this->template->paginationPosition = Renderer::PAGINATION_NONE;
     }
     if ($this->templateHelpersCallback) {
         $this->templateHelpersCallback->invokeArgs(array($this->template));
     }
     $this->template->showFilter = ($this->filterManualRender == FALSE and $this->filterFormFactory !== NULL);
     $this->template->showHeaders = !$this->hideDatagridHeaders;
     $this->template->render();
 }
開發者ID:brabijan,項目名稱:datagrid,代碼行數:22,代碼來源:Renderer.php

示例10: call

 /**
  * __call() implementation.
  * @param  object
  * @param  string
  * @param  array
  * @return mixed
  * @throws MemberAccessException
  */
 public static function call($_this, $name, $args)
 {
     $class = get_class($_this);
     $isProp = self::hasProperty($class, $name);
     if ($name === '') {
         throw new MemberAccessException("Call to class '{$class}' method without name.");
     } elseif ($isProp === 'event') {
         // calling event handlers
         if (is_array($_this->{$name}) || $_this->{$name} instanceof \Traversable) {
             foreach ($_this->{$name} as $handler) {
                 Nette\Callback::create($handler)->invokeArgs($args);
             }
         } elseif ($_this->{$name} !== NULL) {
             throw new UnexpectedValueException("Property {$class}::\${$name} must be array or NULL, " . gettype($_this->{$name}) . " given.");
         }
     } elseif ($cb = Reflection\ClassType::from($_this)->getExtensionMethod($name)) {
         // extension methods
         array_unshift($args, $_this);
         return $cb->invokeArgs($args);
     } else {
         throw new MemberAccessException("Call to undefined method {$class}::{$name}().");
     }
 }
開發者ID:cujan,項目名稱:atlas-mineralov-a-hornin,代碼行數:31,代碼來源:ObjectMixin.php

示例11: handleSave

 public function handleSave(Form $form)
 {
     if ($form->hasSaveButton() && $form->isSubmitted() === $form->getSaveButton()) {
         try {
             $this->mapper->entityManager->getRepository(get_class($form->data))->save($form->data);
         } catch (\Exception $e) {
             $ok = true;
             if (is_array($this->onCatchError) || $this->onCatchError instanceof \Traversable) {
                 foreach ($this->onCatchError as $handler) {
                     if (\Nette\Callback::create($handler)->invokeArgs(array($form, $e))) {
                         $ok = false;
                         break;
                     }
                 }
             } elseif ($this->onCatchError !== NULL) {
                 $class = get_class($this);
                 throw new \Nette\UnexpectedValueException("Property {$class}::onCatchError must be array or NULL, " . gettype($this->onCatchError) . " given.");
             }
             if ($ok) {
                 throw $e;
             }
         }
     }
 }
開發者ID:svobodni,項目名稱:web,代碼行數:24,代碼來源:FormFactory.php

示例12: handleSetParent

 public function handleSetParent($from = NULL, $to = NULL, $dropmode = NULL)
 {
     Callback::create($this->dropCallback)->invoke($from, $to, $dropmode);
 }
開發者ID:svobodni,項目名稱:web,代碼行數:4,代碼來源:BrowserControl.php

示例13: ucfirst

 /**
  * __get() implementation.
  *
  * @param  object
  * @param  string  property name
  *
  * @return mixed   property value
  * @throws MemberAccessException if the property is not defined.
  */
 public static function &get($_this, $name)
 {
     $class = get_class($_this);
     $uname = ucfirst($name);
     if (!isset(self::$methods[$class])) {
         self::$methods[$class] = array_flip(get_class_methods($class));
         // public (static and non-static) methods
     }
     if ($name === '') {
         throw new MemberAccessException("Cannot read a class '{$class}' property without name.");
     } elseif (isset(self::$methods[$class][$m = 'get' . $uname]) || isset(self::$methods[$class][$m = 'is' . $uname])) {
         // property getter
         $val = $_this->{$m}();
         return $val;
     } elseif (isset(self::$methods[$class][$name])) {
         // public method as closure getter
         $val = Callback::create($_this, $name);
         return $val;
     } else {
         // strict class
         $type = isset(self::$methods[$class]['set' . $uname]) ? 'a write-only' : 'an undeclared';
         throw new MemberAccessException("Cannot read {$type} property {$class}::\${$name}.");
     }
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:33,代碼來源:ObjectMixin.php

示例14: callMethod

 /**
  * Calls method using autowiring.
  * @param  mixed   class, object, function, callable
  * @param  array   arguments
  * @return mixed
  */
 public function callMethod($function, array $args = array())
 {
     $callback = new Nette\Callback($function);
     return $callback->invokeArgs(Helpers::autowireArguments($callback->toReflection(), $args, $this));
 }
開發者ID:vrtak-cz,項目名稱:nette-doctrine-sandbox,代碼行數:11,代碼來源:Container.php

示例15: createComponentForm

 /**
  * @return MailControl
  */
 protected function createComponentForm()
 {
     /** @var $control MailControl */
     $control = $this->mailControlFactory->invoke($this->extendedPage->mailform);
     $control->onSuccess[] = $this->formSuccess;
     return $control;
 }
開發者ID:svobodni,項目名稱:web,代碼行數:10,代碼來源:RoutePresenter.php


注:本文中的Nette\Callback類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。