Пример #1
0
 /**
  * Send video off to YouTube after saving.
  */
 public function onAfterElementSave()
 {
     // Proceed when there's something new
     if ($this->hasChanged()) {
         // Let AssetsFieldType handle the default upload logics
         parent::onAfterElementSave();
         // Get logged-in user
         $user = craft()->userSession->getUser();
         // Now its our turn
         craft()->tasks->createTask('YouTube_Upload', Craft::t('Uploading video(s) to YouTube'), array('id' => $this->element->id, 'model' => $this->model, 'assets' => $this->elementIds, 'user' => $user->id));
         // Or proceed if we have to remove the relations
     } elseif (!$this->attribute->total()) {
         // Let AssetsFieldType handle the removal of upload/relations
         parent::onAfterElementSave();
     }
 }