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


PHP Injector::execute方法代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 public function execute(callable $method, $arguments = [])
 {
     foreach ($arguments as $key => $value) {
         unset($arguments[$key]);
         $arguments[':' . $key] = $value;
     }
     try {
         return $this->auryn->execute($method, $arguments);
     } catch (InjectionException $e) {
         throw new DependencyInjectionException('Dependency injection failed while trying to execute ' . \var_export($method, true) . ', ' . $e->getMessage(), $e->getCode(), $e);
     } catch (ReflectionException $e) {
         throw new DependencyInjectionException('Dependency injection failed while trying to execute ' . \var_export($method, true) . ', ' . $e->getMessage(), $e->getCode(), $e);
     }
 }
开发者ID:opsbears,项目名称:piccolo-dic-auryn,代码行数:17,代码来源:AurynDependencyInjectionContainer.php

示例2: testStageRunning

 public function testStageRunning()
 {
     $functionsCalled = [];
     $tiersByStage = new ExecutableListByTier();
     $fn2 = function () use(&$functionsCalled) {
         $functionsCalled[2] = true;
     };
     $fn0 = function () use(&$functionsCalled, $tiersByStage, $fn2) {
         $functionsCalled[0] = true;
         $tiersByStage->addExecutableToTier(4, $fn2);
     };
     $fn1 = function () use(&$functionsCalled) {
         $functionsCalled[1] = true;
     };
     $tiersByStage->addExecutableToTier(2, $fn0);
     $tiersByStage->addExecutableToTier(2, $fn1);
     $injector = new Injector();
     foreach ($tiersByStage as $appStage => $executablesForTier) {
         foreach ($executablesForTier as $executable) {
             $injector->execute($executable->getCallable());
         }
     }
     $this->assertArrayHasKey(0, $functionsCalled);
     $this->assertArrayHasKey(1, $functionsCalled);
     $this->assertArrayHasKey(2, $functionsCalled);
 }
开发者ID:atawsports2,项目名称:Tier,代码行数:26,代码来源:TierStageTest.php

示例3: makeClient

 public function makeClient(Injector $injector)
 {
     if (empty($this->env['chamber_api_secret'])) {
         throw new \DomainException('Bad API configuration');
     }
     $handler = $injector->execute([$this, 'makeStack']);
     return new Client(compact('handler'));
 }
开发者ID:graphis,项目名称:cookcountycommunityfund,代码行数:8,代码来源:GuzzleConfiguration.php

示例4: testInclude

 /**
  * @group blah
  */
 public function testInclude()
 {
     $templateName = 'includeFile/includeTest';
     $className = $this->jigDispatcher->getFQCNFromTemplateName($templateName);
     $this->jigDispatcher->compile($templateName);
     $contents = $this->injector->execute([$className, 'render']);
     $this->assertContains("Included start", $contents);
     $this->assertContains("Included end", $contents);
     $this->assertContains("This is an include test.", $contents);
     $this->assertContains("This is a foo", $contents);
 }
开发者ID:danack,项目名称:jig,代码行数:14,代码来源:JigConverterTest.php

示例5: generateCompare

function generateCompare(\Auryn\Injector $injector, $functionFullname, $filename)
{
    global $imageType;
    echo "Function " . $functionFullname . "\n";
    ob_start();
    $injector->execute($functionFullname);
    $image = ob_get_contents();
    ob_end_clean();
    $fullFilename = $filename . "." . strtolower($imageType);
    @mkdir(dirname($filename), 0755, true);
    file_put_contents($fullFilename, $image);
}
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:12,代码来源:compare.php

示例6: testRouting405

 public function testRouting405()
 {
     $request = new CLIRequest("/introduction", 'example.com', 'POST');
     $this->injector->alias('Psr\\Http\\Message\\ServerRequestInterface', get_class($request));
     $this->injector->share($request);
     $renderCallable = $this->injector->execute('Tier\\Bridge\\JigFastRouter::routeRequest');
     $body = TierApp::executeExecutable($renderCallable, $this->injector);
     $this->assertInstanceOf('Room11\\HTTP\\Body\\TextBody', $body);
     /** @var $body \Room11\HTTP\Body\HtmlBody */
     $html = $body->getData();
     $this->assertContains("Method not allowed for route.", $html);
     $this->assertEquals(405, $body->getStatusCode());
 }
开发者ID:danack,项目名称:tier,代码行数:13,代码来源:JigFastRouterTest.php

示例7: directImageCallable

function directImageCallable(CategoryNav $categoryNav, \Auryn\Injector $injector, $params)
{
    $imageFunction = $categoryNav->getImageFunctionName();
    $filename = getImageCacheFilename($categoryNav->getPageInfo(), $params);
    global $imageType;
    ob_start();
    $injector->execute($imageFunction);
    if ($imageType == null) {
        ob_end_clean();
        throw new \Exception("imageType not set, can't cache image correctly.");
    }
    $imageData = ob_get_contents();
    ob_end_clean();
    return new \ImagickDemo\Response\ImageResponse($filename, "image/" . $imageType, $imageData);
}
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:15,代码来源:Image.php

示例8: directCustomImageCallable

 public function directCustomImageCallable(PageInfo $pageInfo, RouteParams $routeInfo, \Auryn\Injector $injector, $params)
 {
     App::setupCategoryExample($routeInfo);
     $imageFunction = CategoryInfo::getCustomImageFunctionName($pageInfo);
     global $imageType;
     ob_start();
     $injector->execute($imageFunction);
     if ($imageType == null) {
         ob_end_clean();
         throw new \Exception("imageType not set, can't cache image correctly.");
     }
     $imageData = ob_get_contents();
     ob_end_clean();
     $simpleNameWithExtension = $pageInfo->getSimpleName($params) . '.' . $imageType;
     return new BlobBody($simpleNameWithExtension, $imageData, "image/" . $imageType);
 }
开发者ID:danack,项目名称:imagick-demos,代码行数:16,代码来源:ImageGenerator.php

示例9: directImageFunction

 /**
  * @param $imageFunction
  * @param \Auryn\Injector $injector
  * @return \ImagickDemo\Response\ImageResponse
  * @throws \Exception
  */
 function directImageFunction($filename, $imageFunction, \Auryn\Injector $injector)
 {
     $imageCallable = function () use($imageFunction, $injector) {
         try {
             return $injector->execute($imageFunction);
         } catch (\Exception $e) {
             echo "Exception: " . $e->getMessage();
             exit(0);
         }
     };
     return createImageResponse($filename, $imageCallable);
 }
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:18,代码来源:bootstrap.php

示例10: directCustomImageCallable

function directCustomImageCallable(PageInfo $pageInfo, \Auryn\Injector $injector, $params)
{
    $imageFunction = CategoryInfo::getCustomImageFunctionName($pageInfo);
    $filename = getImageCacheFilename($pageInfo, $params);
    global $imageType;
    ob_start();
    $injector->execute($imageFunction);
    if ($imageType == null) {
        ob_end_clean();
        throw new \Exception("imageType not set, can't cache image correctly.");
    }
    $imageData = ob_get_contents();
    ob_end_clean();
    return new DataBody($filename, $imageData, "image/" . $imageType);
}
开发者ID:finelinePG,项目名称:imagick,代码行数:15,代码来源:appFunctions.php

示例11: execute

 public function execute(ControllerEvent $event)
 {
     try {
         $params = $event->getParams(true) ?? [];
         $ajaxReq = $params['_contentType'] === 'ajax';
         if ($params['_method'] === 'GET' && ($parents = $params['_parents'] ?? null)) {
             $alias = $ajaxReq ? $params['alias'] : null;
             if ($models = $this->modelLoader->loadModels($parents, $alias)) {
                 $event->setParam('_models', $models);
                 foreach ($models as $key => $value) {
                     $event->setParam($key, $value);
                 }
             }
             foreach ($parents as $key => $value) {
                 $event->setParam("_{$key}", $models[$key] ?? []);
             }
         }
         $args = array_merge([':event' => $event], $event->getParams() ?? []);
         $action = $this->getController($event->getController());
         $final = true;
         $response = $output = $this->injector->execute($action, $args);
         if ($response instanceof Redirection) {
             $this->dispatcher->fire(RedirectEvent::REDIRECT, new RedirectEvent($response));
             //chance to do something with redirection
             $response->redirect();
             //exists
         } else {
             if ($response instanceof HttpResponseEx) {
                 $event->setResponse($this->response);
             } else {
                 if ($response instanceof View) {
                     if ($ajaxReq && !empty($alias) && !empty($models)) {
                         $output = '{}';
                         /** @var CollectionEx $model */
                         foreach ($models as $tlp => $model) {
                             if ($array = $model->toArray()) {
                                 if ($child = $tlp === $alias ? $array : $this->findChildByAlias($array, $alias)) {
                                     $output = json_encode($child, JSON_PRETTY_PRINT);
                                 }
                             }
                         }
                     } else {
                         /** @var View $view */
                         $view = $response;
                         $final = $response->isFinal();
                         $this->viewParser->setHelpers($view->getHelpers());
                         $this->viewParser->setLayout($view->getLayout());
                         $this->viewParser->setAdditionalLayoutFiles($view->getAdditionalLayoutFiles());
                         $this->viewParser->setVars(array_merge($event->getParams(true) ?? [], $view->getVars() ?? []));
                         if ($content = $view->getContent()) {
                             if (!empty($view->getViewFile())) {
                                 trigger_error('You should only specify either content or view file');
                             }
                             $this->viewParser->setContent($content);
                         } elseif ($templatePath = $view->getViewFile()) {
                             $this->viewParser->loadViewFile($templatePath, $view->isPathLayouts());
                         } elseif (empty($view->getViewFile())) {
                             if (is_string($event->getController())) {
                                 @(list($class) = explode('@', $event->getController(), 2));
                                 $this->viewParser->loadViewFile($class, $view->isPathLayouts());
                             } else {
                                 throw new ControllerError("View must be explicitly set (when Controller is not a string)");
                             }
                         }
                         $output = $this->viewParser->render();
                     }
                 }
                 $this->response->setStatusCode(200);
                 $this->response->setContent(is_string($output) ? $output : '');
                 $this->response->setFinal($final);
                 $event->setResponse($this->response);
             }
         }
     } catch (InjectionException $e) {
         throw new ControllerError(sprintf("Unable to run controller: %s [%s]", $e->getMessage(), var_export($event->getController(), true)));
     }
 }
开发者ID:minutephp,项目名称:framework,代码行数:77,代码来源:Runnable.php

示例12: testAbstractExecute

 public function testAbstractExecute()
 {
     $injector = new Injector();
     $fn = function () {
         return new \Auryn\Test\ConcreteExexcuteTest();
     };
     $injector->delegate('Auryn\\Test\\AbstractExecuteTest', $fn);
     $result = $injector->execute(array('Auryn\\Test\\AbstractExecuteTest', 'process'));
     $this->assertEquals('Concrete', $result);
 }
开发者ID:barthelemy-ehui,项目名称:auryn,代码行数:10,代码来源:InjectorTest.php

示例13: realpath

<?php

use Auryn\Injector;
use Jig\JigConfig;
use Jig\Jig;
// Register some directories in the autoloader - we don't do this in composer.json
// to avoid any confusion with users of the library.
$autoloader = (require_once realpath(__DIR__) . '/../vendor/autoload.php');
$autoloader->add('JigDemo', [realpath(__DIR__) . '/']);
$autoloader->add('Jig', [realpath(__DIR__) . '/compile/']);
$injector = new Injector();
// Setting the Jig config
$jigConfig = new JigConfig(__DIR__ . "/templates/", __DIR__ . "/compile/", Jig::COMPILE_ALWAYS, "php.tpl");
// Tell the DIC that every class that needs an instance of JigConfig
// should use this one.
$injector->share($jigConfig);
// Alias an interface to a concrete class so that it can be found in
// the template.
$injector->alias('JigDemo\\Model\\ColorScheme', '\\JigDemo\\Model\\PrimaryColorscheme');
// This is the template we will be compiling.
$templateName = 'onePageExample';
// Create the Jig renderer
$jig = new Jig($jigConfig);
// Tell Jig to make sure the template is compiled.
$jig->compile($templateName);
// Get the classname that the template will be called
$className = $jig->getFQCNFromTemplateName($templateName);
// Call the template
$contents = $injector->execute([$className, 'render']);
echo $contents;
开发者ID:PeeHaa,项目名称:Jig,代码行数:30,代码来源:onePageExample.php

示例14: execute

 /**
  *
  */
 public function execute()
 {
     //Figure out what Command was requested.
     try {
         $parsedCommand = $this->console->parseCommandLine();
     } catch (ConfiguratorException $ce) {
         echo "Problem running configuration: " . $ce->getMessage();
         exit(-1);
     } catch (\Exception $e) {
         //@TODO change to just catch parseException when that's implemented
         $output = new BufferedOutput();
         $this->console->renderException($e, $output);
         echo $output->fetch();
         exit(-1);
     }
     //Run the command requested, or the help callable if no command was input
     try {
         $output = $parsedCommand->getOutput();
         $formatter = $output->getFormatter();
         $formatter->setStyle('question', new OutputFormatterStyle('blue'));
         $formatter->setStyle('info', new OutputFormatterStyle('blue'));
         $questionHelper = new QuestionHelper();
         $questionHelper->setHelperSet($this->console->getHelperSet());
         // We currently have no config, so fine to create this directly.
         $injector = new Injector();
         $injector->alias('Configurator\\Writer', 'Configurator\\Writer\\FileWriter');
         $injector->defineParam('originalArgs', $this->originalArgs);
         foreach ($parsedCommand->getParams() as $key => $value) {
             $injector->defineParam($key, $value);
         }
         $injector->execute($parsedCommand->getCallable());
     } catch (ConfiguratorException $ce) {
         echo "Error running task: \n";
         echo $ce->getMessage();
         exit(-1);
     } catch (\Exception $e) {
         echo "Unexpected exception of type " . get_class($e) . " running configurator`: " . $e->getMessage() . PHP_EOL;
         echo $e->getTraceAsString();
         exit(-2);
     }
 }
开发者ID:danack,项目名称:configurator,代码行数:44,代码来源:CliRunner.php

示例15:

 function __invoke(Injector $injector)
 {
     return $injector->execute($this->callable);
 }
开发者ID:zvax,项目名称:stepping,代码行数:4,代码来源:Action.php


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