Skip to content

Commit

Permalink
Be more defensive.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Ghita committed May 19, 2012
1 parent 61b1d41 commit 1033bdb
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions extension.driver.php
Expand Up @@ -290,12 +290,36 @@ private function _enable($callback){
return true;
}

private function _fetchEntryID(){
EntryManager::setFetchSortingDirection('DESC');
$entry = EntryManager::fetch(NULL, $this->_section->get('id'), 1);

if( is_array($entry) && !empty($entry) ){
$entry = current($entry);
return (int)$entry->get('id');
}

return null;
}

private function _fetchMaxEntries(){
$count = (int) $this->_section->get('max_entries');

return $count;
}

private function _fetchSection($callback){
if( !isset($callback['context']['section_handle']) ) return null;

$section_id = (int) SectionManager::fetchIDFromHandle($callback['context']['section_handle']);

$section = SectionManager::fetch($section_id);

if( !$section instanceof Section ) return null;

return $section;
}

private function _fetchTotalEntries(){
try{
$count = Symphony::Database()->fetch(sprintf(
Expand All @@ -314,28 +338,6 @@ private function _fetchTotalEntries(){
return (int) $count;
}

private function _fetchEntryID(){
EntryManager::setFetchSortingDirection('DESC');
$entry = EntryManager::fetch(NULL, $this->_section->get('id'), 1);

if( is_array($entry) && !empty($entry) ){
$entry = current($entry);
return (int)$entry->get('id');
}

return null;
}

private function _fetchSection($callback){
$section_id = SectionManager::fetchIDFromHandle($callback['context']['section_handle']);

$section = SectionManager::fetch($section_id);

if( !$section instanceof Section ) return null;

return $section;
}

private function _fetchUrlParams(){
if( count($_GET) > 2 ){
$params = "?";
Expand Down

0 comments on commit 1033bdb

Please sign in to comment.