Skip to content
This repository has been archived by the owner on May 28, 2021. It is now read-only.

Commit

Permalink
Fix traversable model base.
Browse files Browse the repository at this point in the history
  • Loading branch information
nielssp committed May 16, 2016
1 parent fc983d9 commit 14e65a6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/example1.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
$loader->setLogger($logger);

// Connect to "default":
$db = $loader->connect('default');
$db = new \Jivoo\Data\Database\DatabaseSchema($loader->connect('default'));

echo '<pre>';

Expand Down
2 changes: 1 addition & 1 deletion src/Database/DatabaseSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(Database $database)
public function __get($model)
{
if (!isset($this->models[$model])) {
$this->models[$model] = new SimpleModel(
$this->models[$model] = new \Jivoo\Data\SimpleModel(
$model,
$this->database->$model,
$this->definition->getDefinition($model)
Expand Down
16 changes: 15 additions & 1 deletion src/Database/LoadableDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* A database driver that can be loaded by the {@see Loader}.
*/
abstract class LoadableDatabase implements MigratableDatabase
abstract class LoadableDatabase implements MigratableDatabase, \Psr\Log\LoggerAwareInterface
{

/**
Expand All @@ -32,6 +32,11 @@ abstract class LoadableDatabase implements MigratableDatabase
* @var Table[] Tables.
*/
private $tables;

/**
* @var \Psr\Log\LoggerAwareInterface Logger.
*/
protected $logger;

/**
* Construct database.
Expand All @@ -43,6 +48,7 @@ abstract class LoadableDatabase implements MigratableDatabase
*/
final public function __construct(DatabaseDefinition $definition, $options = array())
{
$this->logger = new \Jivoo\Log\NullLogger;
$this->definition = new DatabaseDefinitionBuilder($definition);
$this->init($options);
$this->migrationAdapter = $this->getMigrationAdapter();
Expand All @@ -51,6 +57,14 @@ final public function __construct(DatabaseDefinition $definition, $options = arr
$this->tables[$table] = $this->getTable($table);
}
}

/**
* {@inheritdoc}
*/
public function setLogger(\Psr\Log\LoggerInterface $logger)
{
$this->logger = $logger;
}

/**
* Get table.
Expand Down
2 changes: 1 addition & 1 deletion src/ModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* A selectable data source with a schema.
*/
abstract class ModelBase implements Model
abstract class ModelBase implements \IteratorAggregate, Model
{
use SelectableTrait, UpdatableTrait, DeletableTrait, ReadableTrait;

Expand Down

0 comments on commit 14e65a6

Please sign in to comment.