Skip to content

Commit

Permalink
changed doctrine model approach to be more fitting of doctrine
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Dew committed Aug 12, 2010
1 parent 0223ab1 commit 1a19f4f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 51 deletions.
47 changes: 0 additions & 47 deletions lib/model/doctrine/PluginsfCombine.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,5 @@
*/
abstract class PluginsfCombine extends BasesfCombine
{
/**
* Get an instance by key
*
* @param string $key
* @return sfCombine
*/
static public function getByKey($key)
{
return Doctrine::getTable('sfCombine')
->find($key)
;
}

/**
* Check if a key exists in the db
*
* @param string $key
* @return bool
*/
static public function hasKey($key)
{
return self::getByKey($key) == true;
}

/**
* Get all instances
*
* @return DoctrineCollection
*/
static public function getAll()
{
return Doctrine::getTable('sfCombine')
->findAll()
;
}

/**
*
* @return int
*/
static public function deleteAll()
{
return Doctrine::getTable('sfCombine')
->createQuery()
->delete()
->execute()
;
}
}
14 changes: 14 additions & 0 deletions lib/model/doctrine/PluginsfCombineTable.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,18 @@ public static function getInstance()
{
return Doctrine_Core::getTable('PluginsfCombine');
}

/**
* Delete all the records in the db
*
* @return int
*/
public function deleteAll()
{
return $this
->createQuery()
->delete()
->execute()
;
}
}
4 changes: 2 additions & 2 deletions lib/sfCombineUrl.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static public function getKey(array $files, $separator = ' ')
throw new Exception('Call the task `doctrine:build-model` or use base64 url');
}

$keyExists = sfCombine::hasKey($key);
$keyExists = Doctrine::getTable('sfCombine')->find($key);
if (!$keyExists)
{
$combine = new sfCombine();
Expand Down Expand Up @@ -187,7 +187,7 @@ static public function getFilesByKey($key, $separator = ' ')
// check db
if (!$base64 && class_exists('sfCombine'))
{
$combine = sfCombine::getByKey($key);
$combine = Doctrine::getTable('sfCombine')->find($key);
$base64 = $combine ? $combine->getFiles() : false;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/task/sfCombineTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ protected function execute($arguments = array(), $options = array())
return false;
}

$results = sfCombine::getAll();
$results = Doctrine::getTable('sfCombine')->findAll();
foreach ($results as $result)
{
$cache->remove($result->getAssetKey());
}

$this->logSection('combine', 'Cleanup cache complete', null, 'INFO');
$deleted = sfCombine::deleteAll();
$deleted = Doctrine::getTable('sfCombine')->deleteAll();
$this->logSection(
'combine',
sprintf(
Expand Down

0 comments on commit 1a19f4f

Please sign in to comment.