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);
 }
Example #2
0
 /**
  * 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();
 }
 /**
  * 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.');
 }
 /**
  * @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');
 }