本文整理汇总了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);
}
示例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();
}
示例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.');
}
示例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');
}