FOF30\Factory\MagicSwitchFactory::model PHP Méthode

model() public méthode

Create a new Model object
public model ( string $viewName, array $config = [] ) : Model
$viewName string The name of the view we're getting a Model for.
$config array Optional MVC configuration values for the Model object.
Résultat FOF30\Model\Model
    public function model($viewName, array $config = array())
    {
        try {
            return parent::model($viewName, $config);
        } catch (ModelNotFound $e) {
            $magic = new Magic\ModelFactory($this->container);
            // Let's pass the section override (if any)
            $magic->setSection($this->getSection());
            return $magic->make($viewName, $config);
        }
    }

Usage Example

 /**
  * @group           MagicSwitchFactory
  * @covers          FOF30\Factory\MagicSwitchFactory::model
  * @dataProvider    MagicSwitchFactoryDataprovider::getTestModel
  */
 public function testModel($test, $check)
 {
     $msg = 'MagicSwitchFactory::model %s - Case: ' . $check['case'];
     $factory = new MagicSwitchFactory(static::$container);
     $result = $factory->model($test['view']);
     $this->assertEquals($check['result'], get_class($result), sprintf($msg, 'Returned the wrong result'));
 }