Skip to content

Instantly share code, notes, and snippets.

@jeremyboggs
Created August 21, 2012 13:57
Show Gist options
  • Save jeremyboggs/3415676 to your computer and use it in GitHub Desktop.
Save jeremyboggs/3415676 to your computer and use it in GitHub Desktop.
findNeatline method to find a Neatline record by slug or ID
<?php
/**
* Finds a Neatline record by slug or ID.
*
* Checks for existence of 'slug' in URL, then tries to find a Neatline
* record with that slug. If there is no 'slug' parameter, it falls back
* to Omeka_Controller_Action::findById()
*
* @throws Omeka_Controller_Exception_404
* @return NeatlineExhibit
*/
public function findNeatline()
{
if ($slug = $this->getRequest()->getParam('slug')) {
$record = $this->_table->findBySlug($slug);
if (!$record) {
throw new Omeka_Controller_Exception_404(get_class($this) . ": No record with Slug '$slug' exists" );
}
} else {
$record = $this->findById();
}
return $record;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment