|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Symfony package. |
|
|
5 |
* |
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
7 |
* |
|
|
8 |
* For the full copyright and license information, please view the LICENSE |
|
|
9 |
* file that was distributed with this source code. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Sensio\Bundle\GeneratorBundle\Command; |
|
|
13 |
|
|
|
14 |
use Symfony\Bundle\DoctrineBundle\Mapping\MetadataFactory; |
|
|
15 |
use Symfony\Bundle\DoctrineBundle\Command\DoctrineCommand; |
|
|
16 |
|
|
|
17 |
abstract class GenerateDoctrineCommand extends DoctrineCommand |
|
|
18 |
{ |
|
|
19 |
protected function parseShortcutNotation($shortcut) |
|
|
20 |
{ |
|
|
21 |
$entity = str_replace('/', '\\', $shortcut); |
|
|
22 |
|
|
|
23 |
if (false === $pos = strpos($entity, ':')) { |
|
|
24 |
throw new \InvalidArgumentException(sprintf('The entity name must contain a : ("%s" given, expecting something like AcmeBlogBundle:Blog/Post)', $entity)); |
|
|
25 |
} |
|
|
26 |
|
|
|
27 |
return array(substr($entity, 0, $pos), substr($entity, $pos + 1)); |
|
|
28 |
} |
|
|
29 |
|
|
|
30 |
protected function getEntityMetadata($entity) |
|
|
31 |
{ |
|
|
32 |
$factory = new MetadataFactory($this->getContainer()->get('doctrine')); |
|
|
33 |
|
|
|
34 |
return $factory->getClassMetadata($entity)->getMetadata(); |
|
|
35 |
} |
|
|
36 |
} |