Esempio n. 1
0
 /**
  * Attempt to destroy the page and
  * notify the $listener of the success or failure.  The
  * $attributes are passed in as a convenience in case they
  * are needed
  * 
  * @param  PageRepositoryInterface $page
  * @param  DestroyerInterface       $listener 
  * @param  mixed                    $identity
  * @param  array                    $attributes
  * @return mixed - returned value from the $listener 
  */
 public function destroy(PageRepositoryInterface $page, DestroyerInterface $listener, $identity, array $attributes = [])
 {
     $instance = $page->find($identity);
     if (Page::destroy($identity)) {
         return $listener->destroySucceeded($instance);
     } else {
         return $listener->destroyFailed($instance);
     }
 }
Esempio n. 2
0
 /**
  * Attempt to update the page with the given attributes and
  * notify the $listener of the success or failure
  * 
  * @param  PageRepositoryInterface $page
  * @param  UpdaterInterface         $listener 
  * @param  mixed                    $identity
  * @param  array                    $attributes
  * @return mixed - returned value from the $listener 
  */
 public function update(PageRepositoryInterface $page, UpdaterInterface $listener, $identity, array $attributes = [])
 {
     $instance = $page->find($identity);
     if ($this->validator->validate($attributes)) {
         $instance->update($attributes);
         return $listener->updateSucceeded($instance);
     } else {
         return $listener->updateFailed($instance, $this->validator);
     }
 }
Esempio n. 3
0
 /**
  * Attempt to create a new page with the given attributes and
  * notify the $listener of the success or failure
  * 
  * @param  PageRepositoryInterface $page     
  * @param  CreatorInterface         $listener  
  * @param  array                    $attributes
  * @return mixed - returned value from the $listener                        
  */
 public function create(PageRepositoryInterface $repository, CreatorInterface $listener, array $attributes = [])
 {
     if ($this->validator->validate($attributes)) {
         if ($instance = $repository->create($attributes)) {
             return $listener->creationSucceeded($instance);
         } else {
             return $listener->creationFailed();
         }
     } else {
         return $listener->creationFailed($this->validator);
     }
 }
Esempio n. 4
0
 /**
  * Show the form for editing the specified page.
  *
  * @param  int      $id
  * @return Response
  */
 public function edit($id)
 {
     $page = $this->page->find($id);
     $this->layout = View::make('backend::pages.edit', compact('page'));
     $this->layout->title = trans('pages.titles.list');
     $this->layout->breadcrumb = Config::get('breadcrumbs.pages');
 }