Hey there,
I'm trying to extend the update command of doctrine in Symfony2 and I get
this error:
[InvalidArgumentException]
The helper "em" is not defined.
The code I've got is this:
In src/Webscoming/CoreBundle/Command/DoctrineUpdateCommand.php:
<?php
namespace Webscoming\CoreBundle\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Tools\SchemaTool;
class DoctrineUpdateCommand extends \Doctrine\ORM\Tools\Console\Command\
SchemaTool\UpdateCommand {
protected $name = 'orm:schema-tool:myupdate';
protected $ignoredEntities = array(
'Entity\Asset\Name'
);
protected function executeSchemaCommand(InputInterface $input,
OutputInterface $output, SchemaTool $schemaTool, array $metadatas) {
/** @var $metadata \Doctrine\ORM\Mapping\ClassMetadata */
$newMetadatas = array();
foreach ($metadatas as $metadata) {
if (!in_array($metadata->getName(), $this->ignoredEntities)) {
array_push($newMetadatas, $metadata);
}
}
parent::executeSchemaCommand($input, $output, $schemaTool, $newMetadatas
);
}
}
Any idea what am I missing? I'm following this post on Stackoverflow but it
seems I'm doing something wrong:
http://stackoverflow.com/questions/12563005/ignore-a-doctrine2-entity-when-running-schema-manager-update
Thanks!
On Tuesday, September 25, 2012 9:53:17 AM UTC+2, Marco Pivetta wrote:
>
> As you can see at
> https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php#L45-53
>
> , the schema-tool CLI command (
> https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php
>
> ) uses all the metadata collected across your mapping drivers.
>
> If you want to exclude particular classes, you may want to extend
> UpdateCommand so that it picks only metadata suiting your needs.
>
> You can then attach your command to your CLI and use that one instead of
> the one packaged with Doctrine2
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://marco-pivetta.com
>
>
>
> On 25 September 2012 09:42, Chris Ramakers <[email protected]
> <javascript:>> wrote:
>
>> I've got a Doctrine Entity defined that maps to a View in my database.
>> All works fine, the Entity relations work fine as expected.
>>
>> Problem now is that when running orm:schema-manager:update on the
>> commandline a table gets created for this entity which is something I want
>> to prevent. There already is a view for this Entity, no need to create a
>> table for it.
>>
>> Can I annotate the Entity so that a table won't be created while still
>> keeping access to all Entity related functionality (associations, ...)? Or
>> is it possible to do this with a plugin, listener, ...?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "doctrine-user" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/doctrine-user/-/8Gs3ZUwvob8J.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>.
>> For more options, visit this group at
>> http://groups.google.com/group/doctrine-user?hl=en.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.