testTask.class.php 1.73 KB
Newer Older
Яков's avatar
first  
Яков committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

class testTask extends exchangeImportTask
{
    protected $con = null;
    protected function configure()
    {
        // // add your own arguments here
        $this->addArguments(array(
            new sfCommandArgument('action', sfCommandArgument::REQUIRED ),
        ));
    
        $this->addOptions(array(
            new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'www'),
            new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'arm'),
            new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'),
            // add your own options here
        ));
    
        $this->namespace        = 'test';
        $this->name             = 'app';
        $this->briefDescription = '';
        $this->detailedDescription = <<<EOF
The [exchange:import|INFO] task does things.
Call it with:

  [php symfony exchange:import|INFO]
EOF;
    }
    public function execute($arguments = array(), $options = array())
    {
    $databaseManager = new sfDatabaseManager($this->configuration);
    $this->con = $databaseManager->getDatabase($options['connection'])->getConnection();
    $instance = sfContext::createInstance($this->configuration);
      if(method_exists($this, $arguments['action'])) {
         
          $this->{$arguments['action']}();
      }
    }
    public function genBasketProducts()
    {
        /** @var Basket $basket */
        $basket = BasketTable::getInstance()->find(1);
        $product = ProductTable::getInstance()->find(7);
        $offer = OfferTable::getInstance()->find(3);
        
       $basket->addOrUpdate($product);
       $basket->addOrUpdate($offer);
       
    }
}