-
-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make a db_driver configuration parameter optional with no_driver default value #1420
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\MediaBundle\Exception; | ||
|
||
/** | ||
* @author Andrey F. Mindubaev <[email protected]> | ||
*/ | ||
final class NoDriverException extends \RuntimeException | ||
{ | ||
public function __construct($message = null, $code = 0, \Exception $previous = null) | ||
{ | ||
parent::__construct( | ||
null === $message ? 'The child node "db_driver" at path "sonata_media" must be configured.' : $message, | ||
$code, | ||
$previous | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\MediaBundle\Generator; | ||
|
||
use Sonata\MediaBundle\Exception\NoDriverException; | ||
use Sonata\MediaBundle\Model\MediaInterface; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @author Andrey F. Mindubaev <[email protected]> | ||
*/ | ||
final class NoDriverGenerator implements GeneratorInterface | ||
{ | ||
public function generatePath(MediaInterface $media) | ||
{ | ||
throw new NoDriverException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\MediaBundle\Model; | ||
|
||
use Sonata\CoreBundle\Model\ManagerInterface; | ||
use Sonata\MediaBundle\Exception\NoDriverException; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @author Andrey F. Mindubaev <[email protected]> | ||
*/ | ||
final class NoDriverManager implements ManagerInterface | ||
{ | ||
public function getClass() | ||
{ | ||
throw new NoDriverException(); | ||
} | ||
|
||
public function findAll() | ||
{ | ||
throw new NoDriverException(); | ||
} | ||
|
||
/** | ||
* @param int|null $limit | ||
* @param int|null $offset | ||
*/ | ||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||
{ | ||
throw new NoDriverException(); | ||
} | ||
|
||
public function findOneBy(array $criteria, array $orderBy = null) | ||
{ | ||
throw new NoDriverException(); | ||
} | ||
|
||
/** | ||
* @param mixed $id | ||
*/ | ||
public function find($id) | ||
{ | ||
throw new NoDriverException(); | ||
} | ||
|
||
public function create() | ||
{ | ||
throw new NoDriverException(); | ||
} | ||
|
||
/** | ||
* @param object $entity | ||
* @param bool $andFlush | ||
*/ | ||
public function save($entity, $andFlush = true) | ||
{ | ||
throw new NoDriverException(); | ||
} | ||
|
||
/** | ||
* @param object $entity | ||
* @param bool $andFlush | ||
*/ | ||
public function delete($entity, $andFlush = true) | ||
{ | ||
throw new NoDriverException(); | ||
} | ||
|
||
public function getTableName() | ||
{ | ||
throw new NoDriverException(); | ||
} | ||
|
||
public function getConnection() | ||
{ | ||
throw new NoDriverException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="sonata.media.manager.media" class="Sonata\MediaBundle\Model\NoDriverManager" public="true"/> | ||
<service id="sonata.media.manager.gallery" class="Sonata\MediaBundle\Model\NoDriverManager" public="true"/> | ||
<service id="sonata.media.generator.default" class="Sonata\MediaBundle\Generator\NoDriverGenerator"/> | ||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<!-- | ||
This file will be loaded when SonataAdminBundle is enabled and db_driver has its default value, not corresponding | ||
to real persistence mechanism. | ||
--> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\MediaBundle\Tests\Generator; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Sonata\MediaBundle\Exception\NoDriverException; | ||
use Sonata\MediaBundle\Generator\NoDriverGenerator; | ||
use Sonata\MediaBundle\Model\MediaInterface; | ||
|
||
class NoDriverGeneratorTest extends TestCase | ||
{ | ||
public function testException() | ||
{ | ||
$this->expectException(NoDriverException::class); | ||
|
||
$manager = new NoDriverGenerator(); | ||
$manager->generatePath($this->createMock(MediaInterface::class)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\MediaBundle\Tests\Model; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Sonata\MediaBundle\Exception\NoDriverException; | ||
use Sonata\MediaBundle\Model\NoDriverManager; | ||
|
||
class NoDriverManagerTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider providerMethods | ||
*/ | ||
public function testException($method, array $arguments) | ||
{ | ||
$this->expectException(NoDriverException::class); | ||
|
||
call_user_func_array([new NoDriverManager(), $method], $arguments); | ||
} | ||
|
||
public function providerMethods() | ||
{ | ||
return [ | ||
['getClass', []], | ||
['findAll', []], | ||
['findBy', [[]]], | ||
['findOneBy', [[]]], | ||
['find', [1]], | ||
['create', []], | ||
['save', [null]], | ||
['delete', [null]], | ||
['getTableName', []], | ||
['getConnection', []], | ||
]; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a call to
info()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
->info('Choose persistence mechanism driver from the following list: "doctrine_orm", "doctrine_mongodb", "doctrine_phpcr"')