当前位置: 首页>>代码示例>>PHP>>正文


PHP Callback::create方法代码示例

本文整理汇总了PHP中Nette\Callback::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Callback::create方法的具体用法?PHP Callback::create怎么用?PHP Callback::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Callback的用法示例。


在下文中一共展示了Callback::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: macroUse

 /**
  * {use class MacroSet}
  */
 public function macroUse(MacroNode $node, PhpWriter $writer)
 {
     Nette\Callback::create($node->tokenizer->fetchWord(), 'install')->invoke($this->getCompiler())->initialize();
 }
开发者ID:vrtak-cz,项目名称:nette-doctrine-sandbox,代码行数:7,代码来源:CoreMacros.php

示例9: compile

 /**
  * Generates code.
  * @return string
  */
 private function compile(MacroNode $node, $def)
 {
     $node->tokenizer->reset();
     $writer = Latte\PhpWriter::using($node, $this->compiler);
     if (is_string($def)) {
         return $writer->write($def);
     } else {
         return Nette\Callback::create($def)->invoke($node, $writer);
     }
 }
开发者ID:genextwebs,项目名称:dropbox-sample,代码行数:14,代码来源:MacroSet.php

示例10: createComponentNavbarForm

 protected function createComponentNavbarForm()
 {
     $_this = $this;
     $form = $this->navbarForms[$this->formName];
     $entity = $form->getEntityFactory() ? Callback::create($form->getEntityFactory())->invoke() : $this->repository->createNew();
     $form = $form->getFactory()->invoke($entity);
     $form->onSuccess[] = $this->navbarFormSuccess;
     $form->onError[] = $this->navbarFormError;
     if ($this->mode == self::MODE_PLACE) {
         $form->addSubmit('_cancel', 'Cancel')->setValidationScope(FALSE)->onClick[] = function () use($_this) {
             $_this->redirect('this', array('formName' => NULL, 'mode' => NULL));
         };
     }
     return $form;
 }
开发者ID:venne,项目名称:cms-module,代码行数:15,代码来源:AdminGrid.php

示例11: 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

示例12: addAction

 /**
  * @param $name
  * @param $label
  * @param $callback
  * @throws \movi\InvalidArgumentException
  */
 public function addAction($name, $label, $callback)
 {
     if (isset($this->actions[$name])) {
         throw new InvalidArgumentException("Action '{$name}' is already added.'");
     }
     if (!is_callable($callback)) {
         throw new InvalidArgumentException('Callback is not callable');
     }
     $this->actions[$name] = Callback::create($callback);
     // Add submit
     $this['form']['action']->addSubmit($name, $label);
 }
开发者ID:peterzadori,项目名称:movi,代码行数:18,代码来源:Grid.php

示例13: setup

 /**
  * Helper function which is called before the first query
  *
  * @return void
  */
 protected function setup()
 {
     // Basic roles
     $this->addRole('guest');
     $this->addRole('user', 'guest');
     $this->addRole('psk', 'guest');
     // Trigger registered initializators
     foreach ($this->onSetup as $cb) {
         Nette\Callback::create($cb)->invokeArgs(array($this));
     }
 }
开发者ID:vbuilder,项目名称:framework,代码行数:16,代码来源:AclAuthorizator.php

示例14: invoke

 /**
  * @return LoginControl
  */
 public function invoke()
 {
     return Callback::create($this->loginControlFactory)->invoke();
 }
开发者ID:svobodni,项目名称:web,代码行数:7,代码来源:LoginControlFactory.php

示例15: handleSetParent

 public function handleSetParent($from = NULL, $to = NULL, $dropmode = NULL)
 {
     Callback::create($this->dropCallback)->invoke($from, $to, $dropmode);
 }
开发者ID:svobodni,项目名称:web,代码行数:4,代码来源:BrowserControl.php


注:本文中的Nette\Callback::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。