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


PHP Container::buildObject方法代码示例

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


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

示例1: createModel

 public function createModel($name = null)
 {
     $name or $name = $this->getName();
     $className = 'Framework\\Models\\' . ucfirst($name) . 'Model';
     if (!class_exists($className)) {
         return false;
     }
     return $this->container->buildObject($className);
 }
开发者ID:beingsane,项目名称:com_framework,代码行数:9,代码来源:AbstractBaseController.php

示例2: execute

 /**
  * Dispatch the application.
  *
  * @param JApplicationCms $app
  *
  * @return string An rendered view from executing the controller.
  */
 public function execute()
 {
     $view = $this->app->input->get('view');
     if ($view === null) {
         throw new ControllerResolutionException('No view was specified.');
     }
     $fqcn = __NAMESPACE__ . '\\Controllers\\' . ($this->app->isAdmin() ? 'Admin\\' : '') . ucfirst($view) . 'Controller';
     if (!class_exists($fqcn)) {
         throw new ControllerResolutionException(sprintf('Controller for view (%s) cannot be found.', $view));
     }
     /** @var \Framework\Controllers\AbstractBaseController $controller */
     $controller = $this->container->buildObject($fqcn);
     $controller->setContainer($this->container);
     $controller->createDefaultModel();
     $controller->createDefaultView();
     return $controller->execute();
 }
开发者ID:beingsane,项目名称:com_framework,代码行数:24,代码来源:Dispatcher.php

示例3: testBuildObjectNonClass

 /**
  * Tests attempting to build a non-class.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function testBuildObjectNonClass()
 {
     $this->assertFalse($this->fixture->buildObject('asdf'), 'Attempting to build a non-class should return false.');
 }
开发者ID:ZerGabriel,项目名称:joomla-framework,代码行数:11,代码来源:ContainerTest.php

示例4: testGetMethodArgsResolvedIsNotInstanceOfHintedDependency

 /**
  * @testdox A DependencyResolutionException is thrown, if an object can not be built due to dependency on unknown interfaces
  * @expectedException  \Joomla\DI\Exception\DependencyResolutionException
  */
 public function testGetMethodArgsResolvedIsNotInstanceOfHintedDependency()
 {
     $container = new Container();
     $container->buildObject('Joomla\\Tests\\Unit\\DI\\Stub2');
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:9,代码来源:ObjectBuildingTest.php


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