Пример #1
0
 /**
  * Find single entry by slug
  * @param  string $slug
  * @return EntryEntity
  */
 public function findBySlug($slug, $channel = null, $options = array())
 {
     // Start query
     $this->query = Entry::with(array('author', 'fields'))->where('slug', $slug);
     // Channel
     if ($channel) {
         // Get channel config
         $this->channel = $this->channels->find($channel);
         $this->query->inChannel($this->channel->name);
     }
     // Status
     $this->query = $this->options($options);
     // Run query
     return $this->item();
 }
Пример #2
0
 /**
  * Try to resolve current content channel
  * @param  string $channel
  * @return mixed
  */
 public function resolveChannel($channel = null)
 {
     Profiler::start('FINDER - RESOLVE CHANNEL');
     if (!$channel) {
         $channel = Request::segment(1);
     }
     // Find and share channel
     $this->channel = $this->channelRepository->find($channel);
     // If channel is not found default to "Pages channel"
     if (!$this->channel) {
         $this->channel = $this->channelRepository->find('pages');
     }
     // Share with all views
     View::share('channel', $this->channel);
     Profiler::end('FINDER - RESOLVE CHANNEL');
     return $this->channel;
 }
Пример #3
0
 /**
  * Save all entry fields
  * @param  integer $entryId
  * @param  mixed   $data
  * @return mixed
  */
 public function saveAllForEntry($entryId, $data)
 {
     // Get entry and channel
     $entry = Entry::with(array('author', 'fields'))->where('id', $entryId)->first();
     $entry = new Entities\EntryEntity($entry->toArray());
     $channel = $this->channels->find($entry->channel);
     // Add specific entry fields
     $channel->addEntryFields($entry);
     foreach ($channel->fields as $field) {
         if ($field->save != 'direct') {
             // Get value from form
             $value = array_get($data, $field->name);
             // Set field entry
             $field->set('entry', $entry);
             // Pass through to field save method
             $value = $field->save($value);
             // And save accordinly
             $this->createOrUpdate($entryId, $field->name, $value, $field);
         }
     }
 }