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


PHP Container::callMethod方法代码示例

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


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

示例1: createPresenter

 /**
  * Create new presenter instance.
  * @param  string  presenter name
  * @return IPresenter
  */
 public function createPresenter($name)
 {
     $presenter = $this->container->createInstance($this->getPresenterClass($name));
     foreach (array_reverse(get_class_methods($presenter)) as $method) {
         if (substr($method, 0, 6) === 'inject') {
             $this->container->callMethod(array($presenter, $method));
         }
     }
     if ($presenter instanceof UI\Presenter && $presenter->invalidLinkMode === NULL) {
         $presenter->invalidLinkMode = $this->container->parameters['debugMode'] ? UI\Presenter::INVALID_LINK_WARNING : UI\Presenter::INVALID_LINK_SILENT;
     }
     return $presenter;
 }
开发者ID:JanVoracek,项目名称:nette,代码行数:18,代码来源:PresenterFactory.php

示例2: createPresenter

 /**
  * Create new presenter instance.
  * @param  string  presenter name
  * @return IPresenter
  */
 public function createPresenter($name)
 {
     $presenterName = $this->formatServiceNameFromPresenter($name);
     if (isset($this->presentersByName[$presenterName])) {
         $presenter = $this->container->getService($presenterName);
         $presenter = $presenter instanceof Callback ? $presenter->invoke() : $presenter;
     } else {
         if (isset($this->presentersByName[$presenterName . 'Factory'])) {
             $presenter = $this->container->getService($presenterName . 'Factory')->invoke();
         } else {
             return parent::createPresenter($name);
         }
     }
     foreach (array_reverse(get_class_methods($presenter)) as $method) {
         if (substr($method, 0, 6) === 'inject') {
             $this->container->callMethod(array($presenter, $method));
         }
     }
     return $presenter;
 }
开发者ID:svobodni,项目名称:web,代码行数:25,代码来源:PresenterFactory.php

示例3: onMessage

 /**
  * @param ConnectionInterface $from
  * @param string $msg
  * @throws BadRequestException
  * @throws InvalidArgumentException
  */
 public function onMessage(ConnectionInterface $from, $msg)
 {
     $request = $this->router->match($msg);
     if (is_null($request)) {
         throw new BadRequestException('Invalid message - router cant create request.');
     }
     if (!$request instanceof Request) {
         throw new InvalidArgumentException('Route must return Ale\\Ratchet\\Request.');
     }
     $className = $request->getControl();
     if (!$className || !class_exists($className)) {
         throw new BadRequestException('Control class "' . $className . '" not found.');
     }
     if (!is_subclass_of($className, 'Ale\\Ratchet\\UI\\Control')) {
         throw new BadRequestException($className . ' must be subclass of Ale\\Ratchet\\UI\\Control.');
     }
     $handleName = $request->getHandle();
     if (!$handleName) {
         throw new BadRequestException('Handle cannot be empty.');
     }
     if (!method_exists($className, $handleName)) {
         throw new BadRequestException('Method "' . $handleName . '" not found in class "' . $className . '".');
     }
     $control = new $className($this->connectionStorage);
     /** @var \Ale\Ratchet\UI\Control $control */
     foreach (array_reverse(get_class_methods($control)) as $method) {
         if (substr($method, 0, 6) === 'inject') {
             $this->container->callMethod(array($control, $method));
         }
     }
     $control->startup();
     if (!$this->tryCall($control, $handleName, $request->getParams())) {
         throw new InvalidArgumentException('Handle method "' . $handleName . '" of "' . $className . '" must be callable.');
     }
     $control->shutdown();
 }
开发者ID:frosty22,项目名称:ratchet,代码行数:42,代码来源:Application.php

示例4: callInjects

 /**
  * Calls all methods starting with with "inject" using autowiring.
  * @return void
  */
 public static function callInjects(DI\Container $container, $service)
 {
     if (!is_object($service)) {
         throw new Nette\InvalidArgumentException(sprintf('Service must be object, %s given.', gettype($service)));
     }
     foreach (array_reverse(self::getInjectMethods($service)) as $method) {
         $container->callMethod([$service, $method]);
     }
     foreach (self::getInjectProperties(get_class($service)) as $property => $type) {
         self::checkType($service, $property, $type, $container);
         $service->{$property} = $container->getByType($type);
     }
 }
开发者ID:kukulich,项目名称:di,代码行数:17,代码来源:InjectExtension.php


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