Ordog23

Untitled

Jan 16th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. public function action_details($id = NULL) {
  2.         if (is_null($id)) {
  3.             throw new \MissingParamException('Missing book ID');
  4.         }
  5.         $book = $this->books->get_details($id, 'array');
  6.         $this->data['id'] = $id;
  7.         $this->data['title'] = $book['title'];
  8.         if (\Arr::in_array_recursive('authors', $book)) {
  9.             $author = $book['authors'];
  10.             foreach ($author as $a) {
  11.                 \Arr::insert($tmp_a, $a->name, 0);
  12.             }
  13.             $this->data['authors'] = implode(',', $tmp_a);
  14.         }
  15.         if (\Arr::in_array_recursive('tags', $book)) {
  16.             $tags = $book['tags'];
  17.             $tmp_t = array();
  18.             foreach ($tags as $t) {
  19.                 \Arr::insert($tmp_t, $t->name, 0);
  20.             }
  21.             $this->data['tags'] = implode(',', $tmp_t);
  22.         }
  23.         if (\Arr::in_array_recursive('genres', $book)) {
  24.             $tmp_g = array();
  25.             $genre = $book['genres'];
  26.             foreach ($genre as $g) {
  27.                 \Arr::insert($tmp_g, $g->name, 0);
  28.             }
  29.             $this->data['genres'] = implode(',', $tmp_g);
  30.         }
  31.         \Debug::dump($book);
  32.         \Debug::dump($this->data);
  33.        
  34.         return View::forge('owmx5/books/details.twig', $this->data);
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment