protected function execute($arguments = array(), $options = array())
 {
     $app = $options['app'];
     $env = $options['env'];
     $this->bootstrapSymfony($app, $env, true);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase('doctrine')->getConnection();
     $this->logSection('import', 'initializing...');
     $plugins = SymfonyPluginApi::getPlugins();
     $count = 0;
     foreach ($plugins as $plugin) {
         $new = Doctrine::getTable('SymfonyPlugin')->findOneByTitle($plugin['id']);
         // if plugin exists update info.  Otherwise, create it
         if ($new) {
             // Nothing Yet
         } elseif ($plugin['id']) {
             $new = new SymfonyPlugin();
             $new['title'] = (string) $plugin['id'];
             $new['description'] = (string) $plugin->description;
             $new['repository'] = (string) $plugin->scm;
             $new['image'] = (string) $plugin->image;
             $new['homepage'] = (string) $plugin->homepage;
             $new['ticketing'] = (string) $plugin->ticketing;
             $new->saveNoIndex();
             $this->logSection('import', "added '{$new->title}'");
             $count++;
         }
     }
     $this->logSection('import', "Running Lucene Cleanup");
     $this->runLuceneRebuild();
     $this->logSection('import', "Completed.  Added {$count} new plugins(s)");
 }
Пример #2
0
<?php

include dirname(__FILE__) . '/../bootstrap/Doctrine.php';
include dirname(__FILE__) . '/../fixtures/fixtures.php';
$t = new lime_test(21, new lime_output_color());
include dirname(__FILE__) . '/../fixtures/fixtures.php';
// Doctrine::loadData(sfConfig::get('sf_test_dir').'/fixtures');
$t->comment('testing plugin');
$p = new SymfonyPlugin();
$p['title'] = 'sfThisIsATestPlugin';
$p->save();
$t->is($p->getIndexableTitle(), 'sf this is a test', 'correct string for Lucene indexing');
$t->is($p->isRegistered(), false, 'plugin is not registered');
$t->is($p['symfony_plugin_homepage'], 'http://www.symfony-project.org/plugins/sfThisIsATestPlugin', 'plugin URL matches Symfony Plugins URL');
$t->is($p['repository'], 'http://svn.symfony-project.com/plugins/sfThisIsATestPlugin', 'default repository set');
$t->is($p['num_votes'], 0, 'no votes');
$t->is($p['rating'], 0, 'no rating');
$t->comment('add a rating of 5');
$p->addRating(5);
$t->is($p['num_votes'], 1, 'number of votes is now 1');
$t->is($p['rating'], 5, 'rating is now 5');
$t->comment('add a rating of 3');
$p->addRating(3);
$t->is($p['num_votes'], 2, 'number of votes is now 2');
$t->is($p['rating'], 4, 'rating is now 4');
$t->comment('add another rating of 3');
$p->addRating(3);
$t->is($p['num_votes'], 3, 'number of votes is now 3');
$t->is($p['rating'], 3, '3.667 rating rounds down to 3');
$t->comment('add another rating of 4');
$p->addRating(4);
 public function setUp()
 {
     parent::setUp();
     $this->hasColumn('user_id', 'integer', '4', array('length' => '4', 'type' => 'integer'));
 }
Пример #4
0
<?php

Doctrine::getTable('PluginAuthor')->findAll()->delete();
Doctrine::getTable('SymfonyPlugin')->findAll()->delete();
Doctrine::getTable('CommunityList')->findAll()->delete();
Doctrine::getTable('sfGuardUser')->findAll()->delete();
$user = new sfGuardUser();
$user['username'] = '******';
$user['password'] = '******';
$user->save();
$plugin1 = new SymfonyPlugin();
$plugin1->fromArray(array('title' => 'sfFooPlugin'));
$plugin1->save();
$plugin2 = new SymfonyPlugin();
$plugin2->fromArray(array('title' => 'sfBarPlugin'));
$plugin2->save();
$plugin3 = new SymfonyPlugin();
$plugin3->fromArray(array('title' => 'sfChunkyPlugin'));
$plugin3->save();
$plugin4 = new SymfonyPlugin();
$plugin4->fromArray(array('title' => 'sfBaconPlugin'));
$plugin4->save();
$plugin5 = new SymfonyPlugin();
$plugin5->fromArray(array('title' => 'sfBetterPlugin', 'Ratings' => array(array('rating' => '5'), array('rating' => '5'))));
$plugin5->save();
$plugin6 = new SymfonyPlugin();
$plugin6->fromArray(array('title' => 'sfWorsePlugin', 'Ratings' => array(array('rating' => '1'), array('rating' => '1'), array('rating' => '1'))));
$plugin6->save();
Пример #5
0
<?php

class SymfonyPlugin extends ZAppsPlugin
{
    public function resolveMVCEnter($context)
    {
    }
    public function resolveMVCLeave($context)
    {
        if (!$this->resolved) {
            $request = $context['functionArgs'][0];
            $ctrl = $request->get('_controller');
            if (empty($ctrl)) {
                return;
            }
            $ctrl = explode(':', $ctrl);
            $controller = $ctrl[0];
            if (!empty($ctrl[2])) {
                $action = $ctrl[2];
            } else {
                $action = $ctrl[1];
            }
            $this->setRequestMVC(array($controller, $action));
            $this->resolved = true;
        }
    }
    private $resolved = false;
}
$symfonyPlugin = new SymfonyPlugin();
$symfonyPlugin->setWatchedFunction("Symfony\\Component\\HttpKernel\\HttpKernel::handle", array($symfonyPlugin, "resolveMVCEnter"), array($symfonyPlugin, "resolveMVCLeave"));