Skip to content

Commit

Permalink
ensure fields are using new interface before calling methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rossriley committed Mar 5, 2017
1 parent 006cc13 commit 1807ffe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Storage/Entity/Builder.php
Expand Up @@ -2,6 +2,7 @@

namespace Bolt\Storage\Entity;

use Bolt\Storage\Field\Type\FieldTypeInterface;
use Bolt\Storage\FieldManager;
use Bolt\Storage\Mapping\ClassMetadata;
use Bolt\Storage\Mapping\MetadataDriver;
Expand Down Expand Up @@ -162,7 +163,9 @@ public function createFromDatabaseValues($data, $entity = null)
// set fields
foreach ((array) $fields as $key => $mapping) {
$fieldType = $this->fieldManager->get($mapping['fieldtype'], $mapping);
call_user_func_array([$fieldType, 'hydrate'], [$data, $entity]);
if ($fieldType instanceof FieldTypeInterface) {
call_user_func_array([$fieldType, 'hydrate'], [$data, $entity]);
}
}

return $entity;
Expand Down
5 changes: 4 additions & 1 deletion src/Storage/Repository.php
Expand Up @@ -8,6 +8,7 @@
use Bolt\Events\StorageEvents;
use Bolt\Storage\Entity\Builder;
use Bolt\Storage\Entity\Entity;
use Bolt\Storage\Field\Type\FieldTypeInterface;
use Bolt\Storage\Mapping\ClassMetadata;
use Bolt\Storage\Query\QueryInterface;
use Doctrine\Common\Persistence\ObjectRepository;
Expand Down Expand Up @@ -307,7 +308,9 @@ protected function persist(QuerySet $queries, $entity, $exclusions = [])
}

$field = $this->getFieldManager()->get($field['fieldtype'], $field);
$field->persist($queries, $entity);
if ($field instanceof FieldTypeInterface) {
$field->persist($queries, $entity);
}
}
}

Expand Down

0 comments on commit 1807ffe

Please sign in to comment.