Skip to content

Instantly share code, notes, and snippets.

@msanroman
Created July 3, 2012 13:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msanroman/3039826 to your computer and use it in GitHub Desktop.
Save msanroman/3039826 to your computer and use it in GitHub Desktop.
tdd-ed code
public function findMetasFor($photo = null) {
if ($photo != null)
return $this->findMetasForShow($photo);
else return $this->findMetasForCategory();
}
private function findMetasForCategory() {
if ($this->category != null)
return $this->metainformation[$this->category];
else return $this->metainformation["all_{$this->locale}"];
}
private function findMetasForShow($photo) {
$album = $this->galleries->findGalleryAlbumByCategoryAndAlbumPermalink($this->category, $this->permalink);
$metas = $this->metainformation["shots_{$this->locale}"];
foreach($metas as $key => $meta) {
if ($key == 'og:image')
$meta->setEntity($photo);
else $meta->setEntity($album);
}
return $metas;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment