Created
August 21, 2012 13:57
-
-
Save jeremyboggs/3415676 to your computer and use it in GitHub Desktop.
findNeatline method to find a Neatline record by slug or ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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