当前位置: 首页>>代码示例>>PHP>>正文


PHP ORMExecutor::execute方法代码示例

本文整理汇总了PHP中Doctrine\Common\DataFixtures\Executor\ORMExecutor::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP ORMExecutor::execute方法的具体用法?PHP ORMExecutor::execute怎么用?PHP ORMExecutor::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\DataFixtures\Executor\ORMExecutor的用法示例。


在下文中一共展示了ORMExecutor::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: should_find_group_by_slug

 /** @test */
 public function should_find_group_by_slug()
 {
     $this->executor->execute($this->loader->getFixtures());
     $group = $this->repository->groupOfSlug('cribbb');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Groups\\Group', $group);
     $this->assertEquals('cribbb', $group->slug());
 }
开发者ID:kfuchs,项目名称:cribbb,代码行数:8,代码来源:GroupDoctrineORMRepositoryTest.php

示例2: should_find_post_by_id

 /** @test */
 public function should_find_post_by_id()
 {
     $this->executor->execute($this->loader->getFixtures());
     $post = $this->repository->threadOfId(PostId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'));
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\Post', $post);
     $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', $post->id());
 }
开发者ID:kfuchs,项目名称:cribbb,代码行数:8,代码来源:PostDoctrineORMRepository.php

示例3: load

 /**
  * @param FixtureInterface[] $fixtures
  * @param string $mode
  */
 public function load(array $fixtures, $mode = self::MODE_APPEND)
 {
     $append = $this->isAppendMode($mode);
     if (!$append) {
         $this->executor->setPurger($this->purger);
     }
     $this->executor->execute($this->getLoadedFixtures($fixtures), $append);
 }
开发者ID:feeltr,项目名称:fixture-loader-bundle,代码行数:12,代码来源:FixtureLoader.php

示例4: should_update_existing_user

 /** @test */
 public function should_update_existing_user()
 {
     $this->executor->execute($this->loader->getFixtures());
     $user = $this->repository->userOfUsername(new Username('username'));
     $username = new Username('new_username');
     $user->updateUsername($username);
     $this->repository->update($user);
     $this->em->clear();
     $user = $this->repository->userOfUsername($username);
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user);
     $this->assertEquals($username, $user->username());
 }
开发者ID:kfuchs,项目名称:cribbb,代码行数:13,代码来源:UserDoctrineORMRepositoryTest.php

示例5: adminRefreshDatabaseAction

 public function adminRefreshDatabaseAction(Request $request, Application $app)
 {
     $conn = $app['db'];
     $em = $app['doctrine.orm.entity_manager'];
     $params = $conn->getParams();
     $name = isset($params['path']) ? $params['path'] : (isset($params['dbname']) ? $params['dbname'] : false);
     try {
         $conn->getSchemaManager()->dropDatabase($name);
         $conn->getSchemaManager()->createDatabase($name);
         $conn->close();
     } catch (\Exception $e) {
         return 1;
     }
     $classes = [];
     foreach ($app['authbucket_oauth2.model'] as $class) {
         $classes[] = $em->getClassMetadata($class);
     }
     PersistentObject::setObjectManager($em);
     $tool = new SchemaTool($em);
     $tool->dropSchema($classes);
     $tool->createSchema($classes);
     $purger = new ORMPurger();
     $executor = new ORMExecutor($em, $purger);
     $loader = new Loader();
     $loader->loadFromDirectory(__DIR__ . '/../DataFixtures/ORM');
     $executor->execute($loader->getFixtures());
     return $app->redirect($app['url_generator']->generate('index'));
 }
开发者ID:miguelbemartin,项目名称:oauth2-php,代码行数:28,代码来源:DefaultController.php

示例6: setUp

 /**
  * Initializes the database (once).
  *
  * @throws \Doctrine\DBAL\DBALException
  * @throws \Doctrine\ORM\ORMException
  * @throws \Doctrine\ORM\Tools\ToolsException
  */
 protected function setUp()
 {
     if (null === static::$_conn) {
         $dbPath = __DIR__ . '/../../../db.sqlite';
         if (file_exists($dbPath)) {
             unlink($dbPath);
         }
         $params = ['driver' => 'pdo_sqlite', 'path' => $dbPath];
         static::$_conn = DriverManager::getConnection($params);
         static::$_conn->getConfiguration()->setSQLLogger(null);
     }
     if (null === static::$_em) {
         $paths = [__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/ORM/Resources/mapping'];
         $isDevMode = true;
         $config = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
         $em = EntityManager::create(static::$_conn, $config);
         $classes = [];
         foreach (static::$_classes as $class) {
             array_push($classes, $em->getClassMetadata($class));
         }
         $schemaTool = new SchemaTool($em);
         $schemaTool->dropSchema($classes);
         $schemaTool->createSchema($classes);
         // Load fixtures
         $loader = new Loader();
         $loader->loadFromDirectory(__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/Fixtures');
         $purger = new ORMPurger();
         $executor = new ORMExecutor($em, $purger);
         $executor->execute($loader->getFixtures());
         static::$_em = $em;
     }
 }
开发者ID:ekyna,项目名称:commerce,代码行数:39,代码来源:DatabaseTestCase.php

示例7: execute

 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $app = $this->getApplication()->getApp();
     $em = $app['em'];
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = isset($app['em.fixtures']) ? $app['em.fixtures'] : array();
     }
     $loader = new Loader();
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- " . implode("\n- ", $paths)));
     }
     $purger = new ORMPurger($em);
     $purger->setPurgeMode($input->getOption('purge-with-truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
开发者ID:digitas,项目名称:digex-core,代码行数:31,代码来源:LoadDataFixturesDoctrineCommand.php

示例8: setUp

 public function setUp()
 {
     static::$kernel = static::createKernel();
     static::$kernel->boot();
     $this->application = new Application(static::$kernel);
     //drop the database
     $command = new DropDatabaseDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:database:drop', '--force' => true));
     $command->run($input, new NullOutput());
     //"no database selected" error
     $connection = $this->application->getKernel()->getContainer()->get('doctrine')->getConnection();
     if ($connection->isConnected()) {
         $connection->close();
     }
     //create database
     $command = new CreateDatabaseDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:database:create'));
     $command->run($input, new NullOutput());
     //create schema
     $command = new CreateSchemaDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:schema:create'));
     $command->run($input, new NullOutput());
     //get entity manager
     $this->em = static::$kernel->getContainer()->get('doctrine')->getManager();
     //load fixtures;
     $client = static::createClient();
     $loader = new ContainerAwareLoader($client->getContainer());
     $loader->loadFromDirectory(static::$kernel->locateResource('@IbwJobeetBundle/DataFixtures/ORM'));
     $purger = new ORMPurger($this->em);
     $executor = new ORMExecutor($this->em, $purger);
     $executor->execute($loader->getFixtures());
 }
开发者ID:rikon,项目名称:jobeet,代码行数:35,代码来源:ApiControllerTest.php

示例9: populateTestAction

 /**
  * Napolni podatke iz Fixtures
  */
 public function populateTestAction()
 {
     $logger = function ($message) {
         echo $message . PHP_EOL;
     };
     $em = $this->serviceLocator->get("\\Doctrine\\ORM\\EntityManager");
     $config = new Config($this->serviceLocator->get('config'));
     $loader = new Loader();
     $fixtures = isset($config->test_fixtures) ? $config->test_fixtures : [];
     $fixturename = $this->params('fixturename');
     if (!empty($fixturename)) {
         foreach ($fixtures as $dir) {
             $loader->loadFromFile($dir . '/' . $fixturename . 'Fixture.php');
             /**
              * če je dependent naj ne izvede nobenega
              */
             if (count($loader->getFixtures()) > 1) {
                 throw new \InvalidArgumentException('Loadanih več fixtur-jev -verjetno zaradi dependencies. Kot parameter možen le fixture brez odvisnosti.');
             }
         }
     } else {
         foreach ($fixtures as $dir) {
             $loader->loadFromDirectory($dir);
         }
     }
     $executor = new ORMExecutor($em);
     $executor->setLogger($logger);
     $executor->execute($loader->getFixtures(), true);
 }
开发者ID:ifigenija,项目名称:server,代码行数:32,代码来源:InstallController.php

示例10: loadFixtures

 private function loadFixtures(OutputInterface $output, EntityManager $em, array $loaded)
 {
     $logger = function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     };
     $executor = new ORMExecutor($em);
     $paths = [];
     foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
         $paths[] = $bundle->getPath() . '/Fixture';
     }
     $loader = new DataFixturesLoader($this->getContainer());
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $env = $this->getContainer()->getParameter('kernel.environment');
     $output->writeln("Loading <comment>fixtures</comment>...");
     $has = array_map(function (Fixture $fixture) {
         return $fixture->getName();
     }, $loaded);
     $fixtures = array_filter($loader->getFixtures(), function (FixtureInterface $fixture) use($has) {
         return !in_array(get_class($fixture), $has);
     });
     if (!$fixtures) {
         $output->writeln("  Could not find any new <comment>fixtures</comment> to load..");
         return [];
     }
     $executor->setLogger($logger);
     $executor->execute($fixtures, true);
     return $fixtures;
 }
开发者ID:TomasJancauskas,项目名称:HR,代码行数:32,代码来源:FixturesCommand.php

示例11: execute

 /**
  * Executes the current command.
  *
  * This method is not abstract because you can use this class
  * as a concrete class. In this case, instead of defining the
  * execute() method, you set the code to execute by passing
  * a Closure to the setCode() method.
  *
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|int null or 0 if everything went fine, or an error code
  *
  * @throws LogicException When this abstract method is not implemented
  *
  * @see setCode()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var QuestionHelper $helper */
     $helper = $this->getHelper('question');
     $question = new ConfirmationQuestion('All data in User table will be purged before inserting default data.
          Are you sure you want to continue?', false);
     if (!$helper->ask($input, $output, $question)) {
         return;
     }
     try {
         $loader = new Loader();
         $loader->loadFromDirectory(__DIR__ . '/../fixtures');
         $fixtures = $loader->getFixtures();
         $purger = new ORMPurger($this->em);
         $executor = new ORMExecutor($this->em, $purger);
         $executor->setLogger(function ($message) use($output) {
             $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
         });
         $executor->execute($fixtures);
         $output->writeln('Default users have been successfully loaded!');
         return 0;
     } catch (\Exception $e) {
         $output->writeLn("That's bad. An Error occurred: <error>{$e->getMessage()}</error>");
         return 1;
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:43,代码来源:DefaultDataCommand.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $emName = $input->getOption('em');
     $emName = $emName ? $emName : 'default';
     $emServiceName = sprintf('doctrine.orm.%s_entity_manager', $emName);
     $em = $this->container->get($emServiceName);
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = array();
         foreach ($this->application->getKernel()->getBundles() as $bundle) {
             $paths[] = $bundle->getPath() . '/DataFixtures/ORM';
         }
     }
     $loader = new DataFixturesLoader($this->container);
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     $purger = new ORMPurger($em);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
开发者ID:rooster,项目名称:symfony,代码行数:29,代码来源:LoadDataFixturesDoctrineCommand.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $emName = $input->getOption('em');
     $emName = $emName ? $emName : 'default';
     $emServiceName = sprintf('doctrine.orm.%s_entity_manager', $emName);
     if (!$this->getContainer()->has($emServiceName)) {
         throw new InvalidArgumentException(sprintf('Could not find an entity manager configured with the name "%s". Check your ' . 'application configuration to configure your Doctrine entity managers.', $emName));
     }
     $em = $this->getContainer()->get($emServiceName);
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = array();
         foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
             $paths[] = $bundle->getPath() . '/DataFixtures/ORM';
         }
     }
     $loader = new DataFixturesLoader($this->getContainer());
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- " . implode("\n- ", $paths)));
     }
     $purger = new ORMPurger($em);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
开发者ID:raginghadron,项目名称:DoctrineFixturesBundle,代码行数:35,代码来源:LoadDataFixturesDoctrineCommand.php

示例14: testExecuteTransaction

 public function testExecuteTransaction()
 {
     $em = $this->getMockSqliteEntityManager();
     $executor = new ORMExecutor($em);
     $fixture = $this->getMockFixture($em);
     $executor->execute(array($fixture), true);
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:7,代码来源:ORMExecutorTest.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getEntityManager();
     if ($input->isInteractive() && !$input->getOption('append')) {
         if (!$this->askConfirmation($input, $output, '<question>Careful, database will be purged. Do you want to continue y/N ?</question>', false)) {
             return;
         }
     }
     $app = $this->getApp();
     $path = $app->getApplicationBase($app->getAppNamespace()) . '/DataFixture';
     $loader = new DataFixturesLoader();
     $loader->loadFromDirectory($path);
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- {$path}"));
     }
     foreach ($fixtures as $fixture) {
         if ($fixture instanceof ContainerAwareInterface) {
             $fixture->setContainer($this->getContainer());
         }
     }
     $purger = new ORMPurger($em);
     if ($input->getOption('truncate-only')) {
         $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
         $purger->purge();
         exit(0);
     }
     $purger->setPurgeMode($input->getOption('truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
开发者ID:NightWarriorbg,项目名称:zaralab-api,代码行数:34,代码来源:LoadDatafixturesCommand.php


注:本文中的Doctrine\Common\DataFixtures\Executor\ORMExecutor::execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。