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


PHP Callback::invoke方法代码示例

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


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

示例1: createComponent

 protected function createComponent($name)
 {
     $class = $this->containerClass;
     $this[$name] = $container = new $class();
     $this->containerFactory->invoke($container, $this->parent);
     return $container;
 }
开发者ID:kuba1999,项目名称:DoctrineForms,代码行数:7,代码来源:ToManyContainer.php

示例2: deny

 /**
  * Denies one or more Roles access to [certain $privileges upon] the specified Resource(s).
  * If $assertion is provided, then it must return TRUE in order for rule to apply.
  *
  * @param string|array|Permission::ALL $roles
  * @param string|array|Permission::ALL $resources
  * @param string|array|Permission::ALL $privileges
  * @param callable $assertion
  * @return self
  */
 public function deny($roles = self::ALL, $resources = self::ALL, $privileges = self::ALL, $assertion = null)
 {
     if ($assertion !== null) {
         $assertion = function () use($assertion) {
             return Callback::invoke($assertion, $this->identity, $this->getQueriedResource(), $this->getQueriedRole());
         };
     }
     return parent::deny($roles, $resources, $privileges, $assertion);
 }
开发者ID:arachne,项目名称:security,代码行数:19,代码来源:Permission.php

示例3: loadRows

 private function loadRows()
 {
     if (is_callable($this->rows)) {
         $this->rows = Callback::invoke($this->rows);
         if (!is_array($this->rows)) {
             throw new \Nette\InvalidStateException(sprintf('Rows must be array of values or callable array source, %s given.', gettype($this->rows)));
         }
     }
 }
开发者ID:venne,项目名称:data-transfer,代码行数:9,代码来源:DataTransferObjectIterator.php

示例4: validate

 public function validate(array $controls = NULL)
 {
     foreach ($this->beforeValidate ?: [] as $handler) {
         $params = Callback::toReflection($handler)->getParameters();
         $values = isset($params[1]) ? $this->getValues($params[1]->isArray()) : NULL;
         $this->values = Callback::invoke($handler, $this, $values);
     }
     parent::validate($controls);
 }
开发者ID:sw2eu,项目名称:form-factory,代码行数:9,代码来源:Form.php

示例5: invokeGetter

 /**
  * Get throw getter
  *
  * @param string $propertyName
  * @param object $entity
  * @return null
  */
 protected function invokeGetter($propertyName, $entity)
 {
     $getterName = ['get' . ucfirst($propertyName), 'is' . ucfirst($propertyName)];
     $value = NULL;
     foreach ($getterName as $getter) {
         if (method_exists($entity, $getter) && $value === NULL) {
             $value = Callback::invoke([$entity, $getter]);
         }
     }
     return $value;
 }
开发者ID:pecinaon,项目名称:doctrine-mapper,代码行数:18,代码来源:BaseMapper.php

示例6: save

 /**
  * @param \Nette\Application\UI\Form $form
  * @param callable $resetLinkCallback
  */
 protected function save(Form $form, $resetLinkCallback)
 {
     /** @var \Venne\Security\User $user */
     $user = $this->userRepository->findOneBy(array('email' => $form['email']->value));
     if (!$user) {
         $form->addError($form->getTranslator()->translate('User with email %email% does not exist.', null, array('email' => $form['email']->value)));
         return;
     }
     $key = $user->resetPassword();
     $url = Callback::invoke($resetLinkCallback, $key);
     $this->entityManager->persist($user);
     $this->entityManager->flush($user);
     $this->securityManager->sendRecoveryUrl($user, $url);
 }
开发者ID:venne,项目名称:venne,代码行数:18,代码来源:ResetFormService.php

示例7: __call

 /**
  * @return mixed
  * @throws MemberAccessException
  */
 public function __call($name, $args)
 {
     $class = get_class($this);
     $isProp = ObjectMixin::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) {
                 Callback::invokeArgs($handler, $args);
             }
         } elseif ($this->{$name} !== NULL) {
             throw new UnexpectedValueException("Property {$class}::\${$name} must be array or NULL, " . gettype($this->{$name}) . ' given.');
         }
     } elseif ($isProp && $this->{$name} instanceof \Closure) {
         // closure in property
         trigger_error("Invoking closure in property via \$obj->{$name}() is deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED);
         return call_user_func_array($this->{$name}, $args);
     } elseif (($methods =& ObjectMixin::getMethods($class)) && isset($methods[$name]) && is_array($methods[$name])) {
         // magic @methods
         trigger_error("Magic methods such as {$class}::{$name}() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED);
         list($op, $rp, $type) = $methods[$name];
         if (count($args) !== ($op === 'get' ? 0 : 1)) {
             throw new InvalidArgumentException("{$class}::{$name}() expects " . ($op === 'get' ? 'no' : '1') . ' argument, ' . count($args) . ' given.');
         } elseif ($type && $args && !ObjectMixin::checkType($args[0], $type)) {
             throw new InvalidArgumentException("Argument passed to {$class}::{$name}() must be {$type}, " . gettype($args[0]) . ' given.');
         }
         if ($op === 'get') {
             return $rp->getValue($this);
         } elseif ($op === 'set') {
             $rp->setValue($this, $args[0]);
         } elseif ($op === 'add') {
             $val = $rp->getValue($this);
             $val[] = $args[0];
             $rp->setValue($this, $val);
         }
         return $this;
     } elseif ($cb = ObjectMixin::getExtensionMethod($class, $name)) {
         // extension methods
         trigger_error("Extension methods such as {$class}::{$name}() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED);
         return Callback::invoke($cb, $this, ...$args);
     } else {
         ObjectMixin::strictCall($class, $name);
     }
 }
开发者ID:nette,项目名称:utils,代码行数:50,代码来源:SmartObject.php

示例8: loadData

 /** @return void */
 private function loadData()
 {
     if ($this->data === NULL) {
         if ($this->entity instanceof \Closure) {
             $factory = $this->entity;
         } else {
             $class = $this->entity;
             $factory = function ($record) use($class) {
                 return new $class($record);
             };
         }
         $this->data = [];
         foreach ($this->selection as $row) {
             $record = $this->refTable === NULL ? $row : $row->ref($this->refTable, $this->refColumn);
             $this->data[] = NCallback::invoke($factory, $record);
         }
     }
 }
开发者ID:uestla,项目名称:yetorm,代码行数:19,代码来源:EntityCollection.php

示例9: fireEvents

 public function fireEvents()
 {
     /** @var ObjectForm|UI\Form $this */
     if (!($submittedBy = $this->isSubmitted())) {
         return;
     }
     foreach ($this->onReceiveData ?: array() as $handler) {
         $params = Nette\Utils\Callback::toReflection($handler)->getParameters();
         Nette\Utils\Callback::invoke($handler, $this);
     }
     $this->validate();
     if ($this->object !== NULL) {
         $this->getObjectMapper()->save($this->object, $this);
     }
     if ($submittedBy instanceof Nette\Forms\ISubmitterControl) {
         if ($this->isValid()) {
             $submittedBy->onClick($submittedBy);
         } else {
             $submittedBy->onInvalidClick($submittedBy);
         }
     }
     if ($this->object !== NULL) {
         $validateControls = $submittedBy instanceof Nette\Forms\ISubmitterControl ? $submittedBy->getValidationScope() : NULL;
         if ($validateControls === NULL || count($validateControls) > 0) {
             $this->getViolationsMapper()->validateContainer($this->object, $this, $validateControls);
         }
     }
     if ($this->onSuccess) {
         foreach ($this->onSuccess as $handler) {
             if (!$this->isValid()) {
                 $this->onError($this);
                 break;
             }
             $params = Nette\Utils\Callback::toReflection($handler)->getParameters();
             $values = isset($params[1]) ? $this->getValues($params[1]->isArray()) : NULL;
             Nette\Utils\Callback::invoke($handler, $this, $values);
         }
     } elseif (!$this->isValid()) {
         $this->onError($this);
     }
     $this->onSubmit($this);
 }
开发者ID:mike227,项目名称:n-forms,代码行数:42,代码来源:TObjectForm.php

示例10: startup

 protected function startup()
 {
     $name = $this->getAction(TRUE);
     if ($this->db->table(self::CRON_TABLE)->where('name = ? AND stop IS NULL', $name)->count() > 0) {
         $this->terminate();
     }
     $startTime = new DateTime();
     $startTime->setTimestamp($_SERVER['REQUEST_TIME']);
     $row = $this->db->table(self::CRON_TABLE)->insert(array('server' => php_uname('n'), 'name' => $name, 'start' => $startTime));
     $table = $this->db->table(self::CRON_TABLE);
     $callback = function ($result) use($table, $row) {
         /** @var \Nette\Database\Table\ActiveRow $row */
         $row->update(array('stop' => new DateTime(), 'result' => $result, 'time' => round((microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000), 'memory' => memory_get_peak_usage(TRUE) / 1024));
     };
     $this->onShutdown[] = function () use($callback) {
         Callback::invoke($callback, 'done');
     };
     $this->application->onError[] = function () use($callback) {
         Callback::invoke($callback, 'error');
     };
     parent::startup();
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:22,代码来源:BasePresenter.php

示例11: fireEvents

 public function fireEvents()
 {
     $originalOnSuccess = $this->onSuccess;
     $this->onSuccess = [];
     $this->onSuccess[] = function () use($originalOnSuccess) {
         $events = [];
         $events[] = $this->onBeforeSuccess;
         $events[] = [function ($form) {
             if ($this->mapper) {
                 $this->mapper->save($form);
             }
         }];
         $events[] = $originalOnSuccess;
         $events[] = $this->onAfterSuccess;
         try {
             foreach ($events as $event) {
                 if (!is_array($event) && !$event instanceof \Traversable) {
                     continue;
                 }
                 foreach ($event as $handler) {
                     if (!$this->isValid()) {
                         $this->onError($this);
                         $this->abort();
                     }
                     \Nette\Utils\Callback::invoke($handler, $this);
                 }
             }
         } catch (StopExecutionException $e) {
         }
     };
     if ($this->mapper && $this->mapper instanceof IValidationMapper) {
         $this->onValidate[] = [$this->mapper, 'validate'];
     }
     parent::fireEvents();
     $this->onSuccess = $originalOnSuccess;
 }
开发者ID:librette,项目名称:forms,代码行数:36,代码来源:TFormWithMapper.php

示例12: handleMarkers

 /**
  * Send markers to template as JSON
  * @internal
  */
 public function handleMarkers()
 {
     foreach ($this->onMarkers as $handler) {
         $params = Nette\Utils\Callback::toReflection($handler)->getParameters();
         Nette\Utils\Callback::invoke($handler, $this, $params);
     }
     $this->getPresenter()->sendResponse(new JsonResponse((array) $this->markers));
 }
开发者ID:jasin755,项目名称:maps,代码行数:12,代码来源:MapAPI.php

示例13: macroUse

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

示例14: 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) {
                 Callback::invokeArgs($handler, $args);
             }
         } elseif ($_this->{$name} !== NULL) {
             throw new Nette\UnexpectedValueException("Property {$class}::\${$name} must be array or NULL, " . gettype($_this->{$name}) . ' given.');
         }
     } elseif ($isProp && $_this->{$name} instanceof \Closure) {
         // closure in property
         return call_user_func_array($_this->{$name}, $args);
     } elseif (($methods =& self::getMethods($class)) && isset($methods[$name]) && is_array($methods[$name])) {
         // magic @methods
         list($op, $rp, $type) = $methods[$name];
         if (count($args) !== ($op === 'get' ? 0 : 1)) {
             throw new Nette\InvalidArgumentException("{$class}::{$name}() expects " . ($op === 'get' ? 'no' : '1') . ' argument, ' . count($args) . ' given.');
         } elseif ($type && $args && !self::checkType($args[0], $type)) {
             throw new Nette\InvalidArgumentException("Argument passed to {$class}::{$name}() must be {$type}, " . gettype($args[0]) . ' given.');
         }
         if ($op === 'get') {
             return $rp->getValue($_this);
         } elseif ($op === 'set') {
             $rp->setValue($_this, $args[0]);
         } elseif ($op === 'add') {
             $val = $rp->getValue($_this);
             $val[] = $args[0];
             $rp->setValue($_this, $val);
         }
         return $_this;
     } elseif ($cb = self::getExtensionMethod($class, $name)) {
         // extension methods
         return Callback::invoke($cb, $_this, ...$args);
     } else {
         self::strictCall($class, $name, array_keys(self::getExtensionMethods($class)));
     }
 }
开发者ID:nette,项目名称:utils,代码行数:51,代码来源:ObjectMixin.php

示例15: send

 /**
  * Sends response to output.
  * @return void
  */
 public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setContentType($this->contentType);
     $httpResponse->setHeader('Content-Disposition', ($this->forceDownload ? 'attachment' : 'inline') . '; filename="' . $this->name . '"');
     $output = NULL;
     if ($this->precalculateFileSize) {
         ob_start();
         Nette\Utils\Callback::invokeArgs($this->outputGenerator);
         $output = ob_get_clean();
         $filesize = $length = strlen($output);
     }
     if ($this->resuming && $this->precalculateFileSize) {
         $httpResponse->setHeader('Accept-Ranges', 'bytes');
         if (preg_match('#^bytes=(\\d*)-(\\d*)\\z#', $httpRequest->getHeader('Range'), $matches)) {
             list(, $start, $end) = $matches;
             if ($start === '') {
                 $start = max(0, $filesize - $end);
                 $end = $filesize - 1;
             } elseif ($end === '' || $end > $filesize - 1) {
                 $end = $filesize - 1;
             }
             if ($end < $start) {
                 $httpResponse->setCode(416);
                 // requested range not satisfiable
                 return;
             }
             $httpResponse->setCode(206);
             $httpResponse->setHeader('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $filesize);
             $length = $end - $start + 1;
         } else {
             $httpResponse->setHeader('Content-Range', 'bytes 0-' . ($filesize - 1) . '/' . $filesize);
         }
     }
     if ($this->precalculateFileSize) {
         $httpResponse->setHeader('Content-Length', $length);
     }
     if (isset($start)) {
         echo substr($output, $start, $length);
     } elseif (isset($output)) {
         echo $output;
     } else {
         Nette\Utils\Callback::invoke($this->outputGenerator);
     }
 }
开发者ID:instante,项目名称:responses,代码行数:48,代码来源:VirtualFileResponse.php


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