/**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $database = $databaseManager->getDatabase($arguments['database']);
     $conn = $database->getDoctrineConnection();
     $data = $conn->fetchAll('SELECT * FROM ' . $arguments['table']);
     $model = $arguments['model'];
     $modelTable = Doctrine_Core::getTable($model);
     $isContentType = $modelTable->hasTemplate('sfSympalContentType');
     foreach ($data as $row) {
         if ($isContentType) {
             $record = sfSympalContent::createNew($model);
             $record->CreatedBy = Doctrine_Core::getTable(sfSympalConfig::get('user_model'))->findOneByIsSuperAdmin(true);
             $record->getRecord()->fromArray($row);
             $record->date_published = new Doctrine_Expression('NOW()');
             $record->slug = (string) $record;
         } else {
             $record = new $model();
             $record->fromArray($row);
         }
         $record->save();
     }
 }
<?php

$app = 'sympal';
require_once dirname(__FILE__) . '/../../../../bootstrap/unit.php';
$t = new lime_test(2);
$page = sfSympalContent::createNew('sfSympalPage');
$page->date_published = date('Y-m-d h:i:s', time() + 86400);
// tomorrow
$page->save();
$pageContentType = Doctrine_Core::getTable('sfSympalContentType')->findOneByName('sfSympalPage');
$contentList = sfSympalContent::createNew('sfSympalContentList');
$contentList->ContentType = $pageContentType;
$contentList->save();
/**
 * This will test PluginsfSympalContentList, but buildDataGrid() currently
 * has an sfWebRequest dependency on it, which needs to be removed.
 * See ticket #23
 */
예제 #3
0
8<?php 
$app = 'sympal';
require_once dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new lime_test(17);
// Setup sample content record and menu item to test with
$user = new sfGuardUser();
$user->first_name = 'test';
$user->last_name = 'test';
$user->email_address = '*****@*****.**';
$user->username = rand();
$user->password = '******';
$user->save();
$content = sfSympalContent::createNew('sfSympalPage');
$content->slug = 'testing-this-out';
$content->date_published = date('Y-m-d', time() - 3600);
$content->CreatedBy = $user;
$content->Site = Doctrine_Core::getTable('sfSympalSite')->findOneBySlug('sympal');
$content->title = 'Testing this out';
$content->save();
$menuItem = new sfSympalMenuItem();
$menuItem->name = 'test';
$menuItem->RelatedContent = $content;
$menuItem->Site = Doctrine_Core::getTable('sfSympalSite')->findOneBySlug('sympal');
$menuItem->save();
$content->save();
// Test that $content was setup successfully
$t->is($content->sfSympalPage instanceof sfSympalPage, true, 'Test that content type was instantiated properly');
$t->is($content->sfSympalPage->title, 'Testing this out', 'Test that content type instance title was set from content record');
// Query for new content
$q = Doctrine_Core::getTable('sfSympalContent')->getFullTypeQuery('sfSympalPage')->andWhere('c.slug = ?', 'testing-this-out');
$content = $q->fetchOne();
 /**
  * Handles the create processing, which submits from create_type
  */
 public function executeCreate(sfWebRequest $request)
 {
     $content = $request->getParameter('sf_sympal_content');
     $contentTypeId = $content['content_type_id'];
     $type = Doctrine_Core::getTable('sfSympalContentType')->find($contentTypeId);
     $this->sf_sympal_content = sfSympalContent::createNew($type);
     $this->sf_sympal_content->Site = $this->getSympalContext()->getSite();
     $this->form = new sfSympalContentForm($this->sf_sympal_content);
     $this->processForm($request, $this->form);
     $this->setTemplate('new');
 }