Пример #1
0
 /**
  * Deletes gallery from the database from the HTTP request
  *
  * @param Rsc_Http_Request $request An instance of the HTTP request
  * @param Rsc_Lang $lang An instance of the translation class
  * @param string $hooksPrefix The prefix for the plugin hooks
  * @throws RuntimeException
  * @throws UnexpectedValueException
  */
 public function deleteFromRequest(Rsc_Http_Request $request, Rsc_Lang $lang, $hooksPrefix = null)
 {
     $galleryId = $request->query->get('gallery_id');
     if (!is_numeric($galleryId)) {
         throw new UnexpectedValueException($lang->translate('Invalid gallery identifier specified'));
     }
     if (!$this->delete($galleryId, $hooksPrefix)) {
         throw new RuntimeException($lang->translate('Failed to delete the gallery'));
     }
 }
Пример #2
0
 /**
  * Attaches resources to the gallery from the HTTP request
  *
  * @param Rsc_Http_Request $request The HTTP request
  * @param Rsc_Lang $lang The instance of the language class
  *
  * @return mixed
  * @throws GridGallery_Galleries_Exception_AttachException If not enough input data
  */
 public function attachFromRequest(Rsc_Http_Request $request, Rsc_Lang $lang)
 {
     if (!($resources = $request->post->get('resources'))) {
         if ($this->logger) {
             $this->logger->error('The POST request is not contain \'resources\' value in {method}', array('method' => __METHOD__));
         }
         throw new GridGallery_Galleries_Exception_AttachException($lang->translate('Resources are does not exists'));
     }
     if (!($galleryId = $request->post->get('gallery_id'))) {
         if ($this->logger) {
             $this->logger->error('The POST request is not contain \'gallery_id\' value in {method}', array('method' => __METHOD__));
         }
         throw new GridGallery_Galleries_Exception_AttachException($lang->translate('The identifier of the Gallery is not specified'));
     }
     foreach ($resources as $resource) {
         if (!$this->attach((int) $galleryId, $resource['type'], (int) $resource['id'])) {
             if ($this->logger) {
                 $this->logger->error('Resource {id} ({type}) was not attached to the gallery {gallery_id}: {error}', array('id' => $resource['id'], 'type' => $resource['type'], 'gallery_id' => $galleryId, 'error' => $this->getLastError()));
             }
         }
     }
     return $galleryId;
 }