Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #337 from wcluijt/patch-1
Browse files Browse the repository at this point in the history
Updated the PhpcrOdmTree to allow other compatible classes to be injecte...
  • Loading branch information
dbu committed Apr 29, 2015
2 parents 7a99def + b93ca7a commit f2d2b02
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Tree/PhpcrOdmTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PHPCR\Util\NodeHelper;

use PHPCR\Util\PathHelper;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException;
use Symfony\Component\Translation\TranslatorInterface;
Expand Down Expand Up @@ -102,7 +103,7 @@ class PhpcrOdmTree implements TreeInterface
* @param ModelManager $defaultModelManager to use with documents that have no manager
* @param Pool $pool to get admin classes for documents from
* @param TranslatorInterface $translator
* @param CoreAssetsHelper $assetHelper
* @param CoreAssetsHelper|AssetsHelper $assetHelper
* @param array $validClasses list of the valid class names that may be
* used as tree "ref" fields
* $param integer $depth depth to which grand children should be fetched,
Expand All @@ -114,7 +115,7 @@ public function __construct(
ModelManager $defaultModelManager,
Pool $pool,
TranslatorInterface $translator,
CoreAssetsHelper $assetHelper,
$assetHelper,
array $validClasses,
array $options
) {
Expand All @@ -127,6 +128,23 @@ public function __construct(

$this->depth = $options['depth'];
$this->preciseChildren = $options['precise_children'];

if (!$this->assetHelper instanceof CoreAssetsHelper) {
// check for the AssetsHelper class introduced in Symfony 2.7
if (!$this->assetHelper instanceof AssetsHelper) {
throw new \InvalidArgumentException(sprintf(
'The asset helper input for the %s class is not valid.'
.' The current asset helper is an instance of %s.'
.' It should be an instance of one of the following classes: %s',
__CLASS__,
get_class($this->assetHelper),
implode(', ', array(
'Symfony\Component\Templating\Helper\CoreAssetsHelper',
'Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper',
))
));
}
}
}

/**
Expand Down

0 comments on commit f2d2b02

Please sign in to comment.