当前位置: 首页>>代码示例>>PHP>>正文


PHP Version::save方法代码示例

本文整理汇总了PHP中Version::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Version::save方法的具体用法?PHP Version::save怎么用?PHP Version::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Version的用法示例。


在下文中一共展示了Version::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: registerUser

 /**
  * This function will create a new user object and return the newly created user object.
  *
  * @param array $userInfo This should have the properties: username, firstname, lastname, password, ui_language
  *
  * @return mixed
  */
 public function registerUser(array $userInfo, $userLanguage)
 {
     $user = \User::create($userInfo);
     //make the first user an admin
     if (\User::all()->count() <= 1) {
         $user->is_admin = 1;
     }
     // Trim trailing whitespace from user first and last name.
     $user->firstname = trim($user->firstname);
     $user->lastname = trim($user->lastname);
     $user->save();
     \Setting::create(['ui_language' => $userLanguage, 'user_id' => $user->id]);
     /* Add welcome note to user - create notebook, tag and note */
     //$notebookCreate = Notebook::create(array('title' => Lang::get('notebooks.welcome_notebook_title')));
     $notebookCreate = new \Notebook();
     $notebookCreate->title = Lang::get('notebooks.welcome_notebook_title');
     $notebookCreate->save();
     $notebookCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
     //$tagCreate = Tag::create(array('title' => Lang::get('notebooks.welcome_note_tag'), 'visibility' => 0));
     $tagCreate = new \Tag();
     $tagCreate->title = Lang::get('notebooks.welcome_note_tag');
     $tagCreate->visibility = 0;
     $tagCreate->user_id = $user->id;
     $tagCreate->save();
     //$tagCreate->users()->attach($user->id);
     $noteCreate = new \Note();
     $versionCreate = new \Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $user->id]);
     $versionCreate->save();
     $noteCreate->version()->associate($versionCreate);
     $noteCreate->notebook_id = $notebookCreate->id;
     $noteCreate->save();
     $noteCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
     $noteCreate->tags()->sync([$tagCreate->id]);
     return $user;
 }
开发者ID:jinchen891021,项目名称:paperwork,代码行数:42,代码来源:UserRegistrator.php

示例2: wiki_install

/**
 * Wiki for phpWebSite
 *
 * See docs/CREDITS for copyright information
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @package Wiki
 * @author Greg Meiste <greg.meiste+github@gmail.com>
 */
function wiki_install(&$content)
{
    PHPWS_Core::initModClass('wiki', 'WikiManager.php');
    PHPWS_Core::initModClass('wiki', 'WikiPage.php');
    PHPWS_Core::initModClass('version', 'Version.php');
    // Adding pages that ship with the module
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/frontpage.txt')) {
        $frontpage = new WikiPage('FrontPage');
        $frontpage->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/frontpage.txt')));
        $frontpage->setOwnerId(Current_User::getId());
        $frontpage->setEditorId(Current_User::getId());
        $frontpage->setCreated(mktime());
        $frontpage->setUpdated(mktime());
        $frontpage->setComment('Provided by Wiki install');
        $frontpage->save();
        $version1 = new Version('wiki_pages');
        $version1->setSource($frontpage);
        $version1->setApproved(1);
        $version1->save();
    }
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/samplepage.txt')) {
        $samplepage = new WikiPage('SamplePage');
        $samplepage->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/samplepage.txt')));
        $samplepage->setOwnerId(Current_User::getId());
        $samplepage->setEditorId(Current_User::getId());
        $samplepage->setCreated(mktime());
        $samplepage->setUpdated(mktime());
        $samplepage->setComment('Provided by Wiki install');
        $samplepage->allow_edit = 0;
        $samplepage->save();
        $version2 = new Version('wiki_pages');
        $version2->setSource($samplepage);
        $version2->setApproved(1);
        $version2->save();
    }
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/sandbox.txt')) {
        $sandbox = new WikiPage('WikiSandBox');
        $sandbox->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/sandbox.txt')));
        $sandbox->setOwnerId(Current_User::getId());
        $sandbox->setEditorId(Current_User::getId());
        $sandbox->setCreated(mktime());
        $sandbox->setUpdated(mktime());
        $sandbox->setComment('Provided by Wiki install');
        $sandbox->save();
        $version3 = new Version('wiki_pages');
        $version3->setSource($sandbox);
        $version3->setApproved(1);
        $version3->save();
    }
    // Adding first interwiki link
    PHPWS_Core::initModClass('wiki', 'InterWiki.php');
    $interwiki = new InterWiki();
    $interwiki->setLabel('Wikipedia');
    $interwiki->setUrl('http://en.wikipedia.org/wiki/%s');
    $interwiki->save(FALSE);
    return TRUE;
}
开发者ID:Jopperi,项目名称:wiki,代码行数:79,代码来源:install.php

示例3: actionIndex

 public function actionIndex()
 {
     $model = new Version();
     if (isset($_POST['Version'])) {
         $model->setAttributes($_POST['Version'], false);
         if ($model->save()) {
             echo '成功';
         }
     } else {
         $data = $model->findAll(null);
         $this->send(ERROR_NONE, $data[0]);
     }
     $this->render('index', array('model' => $model));
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:14,代码来源:VersionController.php

示例4: createNote

 /**
  * Create Note and Version instances
  *
  * $created_at and $updated_at values we have from parsed xml
  *
  * @param $title
  * @param $content
  * @param $created_at
  * @param $updated_at
  * @return \Note
  */
 protected function createNote($title, $content, $created_at, $updated_at)
 {
     $noteCreate = new \Note();
     $noteCreate->created_at = $created_at;
     $noteCreate->updated_at = $updated_at;
     // Add spaces for strip_tags
     $contentPreview = preg_replace('/(<[^>]+>)/', '$1 ', $content);
     $contentPreview = strip_tags($contentPreview);
     $versionCreate = new \Version(['title' => $title, 'content' => $content, 'content_preview' => mb_substr($contentPreview, 0, 255), 'created_at' => $created_at, 'updated_at' => $updated_at, 'user_id' => \Auth::user()->id]);
     $versionCreate->save();
     $noteCreate->version()->associate($versionCreate);
     $noteCreate->notebook_id = $this->notebook->id;
     $noteCreate->save();
     $noteCreate->users()->attach(\Auth::user()->id, array('umask' => \PaperworkHelpers::UMASK_OWNER));
     return $noteCreate;
 }
开发者ID:Liongold,项目名称:paperwork,代码行数:27,代码来源:AbstractImport.php

示例5: store

 /**
  * Store a newly created resource in storage.
  * POST /version
  *
  * @return Response
  */
 public function store($pluginid)
 {
     $rules = ['name' => 'required|min:1', 'risk' => 'required|min:1'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator->messages());
     }
     $version = new Version();
     $version->name = Input::get('name');
     $version->plugin_id = intval($pluginid);
     $version->js = Input::get('js');
     $version->css = Input::get('css');
     $version->risk = Input::get('risk');
     $version->save();
     return Redirect::action('plugin.show', [$pluginid])->withSuccess('Plugin created.');
 }
开发者ID:Devided,项目名称:Versions,代码行数:22,代码来源:VersionController.php

示例6: clearXMLfiles

 public function clearXMLfiles()
 {
     global $mod_strings;
     if ($this->show_output) {
         echo "<h3>{$mod_strings['LBL_QR_XMLFILES']}</h3>";
     }
     $this->_clearCache(sugar_cached("xml"), '.xml');
     include 'modules/Versions/ExpectedVersions.php';
     global $expect_versions;
     if (isset($expect_versions['Chart Data Cache'])) {
         $version = new Version();
         $version->retrieve_by_string_fields(array('name' => 'Chart Data Cache'));
         $version->name = $expect_versions['Chart Data Cache']['name'];
         $version->file_version = $expect_versions['Chart Data Cache']['file_version'];
         $version->db_version = $expect_versions['Chart Data Cache']['db_version'];
         $version->save();
     }
 }
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:18,代码来源:QuickRepairAndRebuild.php

示例7: saveVersion

 /**
  * $directCall is true when the method is called from outside (eg. directly in the controller "save only version")
  * it is false when the method is called by $this->update()
  * @param bool $setModificationDate
  * @param bool $directCall
  * @return Version
  */
 public function saveVersion($setModificationDate = true, $directCall = true)
 {
     if ($setModificationDate) {
         $this->setO_modificationDate(time());
     }
     // hook should be also called if "save only new version" is selected
     if ($directCall) {
         Pimcore_API_Plugin_Broker::getInstance()->preUpdateObject($this);
     }
     // scheduled tasks are saved always, they are not versioned!
     if ($directCall) {
         $this->saveScheduledTasks();
     }
     $version = null;
     // only create a new version if there is at least 1 allowed
     if (Pimcore_Config::getSystemConfig()->objects->versions) {
         // create version
         $version = new Version();
         $version->setCid($this->getO_Id());
         $version->setCtype("object");
         $version->setDate($this->getO_modificationDate());
         $version->setUserId($this->getO_userModification());
         $version->setData($this);
         $version->save();
     }
     // hook should be also called if "save only new version" is selected
     if ($directCall) {
         Pimcore_API_Plugin_Broker::getInstance()->postUpdateObject($this);
     }
     return $version;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:38,代码来源:Concrete.php

示例8: saveVersion

 /**
  * Save the current object as version
  *
  * @return void
  */
 public function saveVersion($setModificationDate = true, $callPluginHook = true)
 {
     // hook should be also called if "save only new version" is selected
     if ($callPluginHook) {
         Pimcore_API_Plugin_Broker::getInstance()->preUpdateDocument($this);
     }
     // set date
     if ($setModificationDate) {
         $this->setModificationDate(time());
     }
     // scheduled tasks are saved always, they are not versioned!
     $this->saveScheduledTasks();
     // create version
     $version = new Version();
     $version->setCid($this->getId());
     $version->setCtype("document");
     $version->setDate($this->getModificationDate());
     $version->setUserId($this->getUserModification());
     $version->setData($this);
     $version->save();
     // hook should be also called if "save only new version" is selected
     if ($callPluginHook) {
         Pimcore_API_Plugin_Broker::getInstance()->postUpdateDocument($this);
     }
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:30,代码来源:PageSnippet.php

示例9: run

 public function run()
 {
     $version = new Version();
     $version->versions = 'First version';
     $version->save();
 }
开发者ID:sprov03,项目名称:blog.dev,代码行数:6,代码来源:VersionTableSeeder.php

示例10: versionablePostSave

 /**
  * Save a new version
  */
 public function versionablePostSave()
 {
     /**
      * We'll save new versions on updating and first creation
      */
     if ((!isset($this->versioningEnabled) || $this->versioningEnabled === true) && $this->updating && $this->validForVersioning() || (!isset($this->versioningEnabled) || $this->versioningEnabled === true) && !$this->updating) {
         // Save a new version
         $version = new Version();
         $version->versionable_id = $this->getKey();
         $version->versionable_type = get_class($this);
         $version->user_id = $this->getAuthUserId();
         $version->model_data = serialize($this->getAttributes());
         $version->save();
     }
 }
开发者ID:badsoft,项目名称:versionable,代码行数:18,代码来源:VersionableTrait.php

示例11: update

 public function update($notebookId, $noteId)
 {
     $validator = Validator::make(Input::all(), ["title" => "required"]);
     if (!$validator->passes()) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, $validator->getMessageBag()->toArray());
     }
     $updateNote = Input::json();
     $user = User::find(Auth::user()->id);
     if (is_null($user)) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('item' => 'user'));
     }
     //only a read-writer or owner of the note can update it. however the private tags can be saved whatever the status
     $note = $user->notes()->where('notes.id', '=', $noteId)->first();
     if (is_null($note)) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('item' => 'note', 'id' => $noteId));
     }
     $tagIds = ApiTagsController::createOrGetTags($updateNote->get('tags'), $noteId, $note->pivot->umask);
     if (!is_null($tagIds)) {
         $note->tags()->sync($tagIds);
     }
     if ($note->pivot->umask < PaperworkHelpers::UMASK_READWRITE) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Permission error. The private tags have been saved though.'));
     }
     $previousVersion = $note->version()->first();
     $previousAttachments = $previousVersion->attachments()->get();
     if ($previousVersion->title != $updateNote->get("title") || $previousVersion->content != $updateNote->get("content")) {
         $pureContent = PaperworkHelpers::purgeHtml($updateNote->get("content"));
         // TODO: This is a temporary workaround for the content_preview. We need to check, whether there is content or at least one attachment.
         // If there's no content, parse the attachment and set the result as content_preview. This should somehow be done within the DocumentParser, I guess.
         $version = new Version(array('title' => $updateNote->get("title"), 'content' => $pureContent, 'content_preview' => substr(strip_tags($pureContent), 0, 255), 'user_id' => $user->id));
         $version->save();
         $previousVersion->next()->associate($version);
         $previousVersion->save();
         $version->previous()->associate($previousVersion);
         if (!is_null($previousAttachments) && $previousAttachments->count() > 0) {
             foreach ($previousAttachments as $previousAttachment) {
                 $version->attachments()->attach($previousAttachment);
             }
         }
         $version->save();
         $note->version_id = $version->id;
         $note->save();
     }
     return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $note);
 }
开发者ID:netesheng,项目名称:paperwork,代码行数:45,代码来源:ApiNotesController.php

示例12: convertPage

function convertPage($page)
{
    PHPWS_Core::initModClass('wiki', 'WikiManager.php');
    PHPWS_Core::initModClass('wiki', 'WikiPage.php');
    PHPWS_Core::initModClass('version', 'Version.php');
    PHPWS_Core::initModClass('search', 'Search.php');
    $newpage = new WikiPage($page['label']);
    $newpage->setPagetext($page['pagetext']);
    $newpage->setOwnerId(Current_User::getId());
    $newpage->setEditorId(Current_User::getId());
    $newpage->setCreated($page['created']);
    $newpage->setUpdated(mktime());
    $newpage->setComment(dgettext('wiki', 'Converted from previous wiki install'));
    $newpage->allow_edit = $page['allow_edit'];
    $result = $newpage->save();
    if (PEAR::isError($result)) {
        PHPWS_Error::log($result);
        return FALSE;
    }
    $version = new Version('wiki_pages');
    $version->setSource($newpage);
    $version->setApproved(1);
    $version->save();
    return TRUE;
}
开发者ID:Jopperi,项目名称:wiki,代码行数:25,代码来源:convert.php

示例13: checkSandstormUsers

 public function checkSandstormUsers()
 {
     if (Config::get('paperwork.emergency_export') && DB::table('migrations')->where('batch', '=', 1)->count() == Config::get('paperwork.emergency_export_count')) {
         $credentials = ["username" => "sandstorm_dummy", "password" => "sandstorm_dummy"];
         if (Auth::attempt($credentials)) {
             $settings = Setting::where('user_id', '=', Auth::user()->id)->first();
             Session::put('ui_language', $settings->ui_language);
             return View::make('user.emergency_export');
         }
     } else {
         // get permission via HTTP_X_SANDSTORM header
         $sandstorm_permissions = $_SERVER['HTTP_X_SANDSTORM_PERMISSIONS'];
         // Only when we are admin, we check and create users
         if ($sandstorm_permissions == "admin,write,read") {
             // check for admin user
             if (User::where('username', '=', 'sandstorm_admin')->count() == 0) {
                 $sandstorm_admin = User::create(Input::except('_token', 'password_confirmation', 'ui_language'));
                 if ($sandstorm_admin) {
                     //make the first user an admin
                     $sandstorm_admin->firstname = "sandstorm_admin";
                     $sandstorm_admin->lastname = " ";
                     $sandstorm_admin->username = "sandstorm_admin";
                     $sandstorm_admin->password = "sandstorm_admin";
                     $sandstorm_admin->is_admin = 1;
                     $sandstorm_admin->save();
                     $setting_sandstorm_admin = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_admin->id]);
                 }
             } else {
                 $sandstorm_admin = User::where('username', '=', 'sandstorm_admin');
             }
             // Then the read & write  user
             if (User::where('username', '=', 'sandstorm_readwrite')->count() == 0) {
                 $sandstorm_readwrite = User::create(Input::except('_token', 'password_confirmation', 'ui_language'));
                 if ($sandstorm_readwrite) {
                     $sandstorm_readwrite->firstname = "sandstorm_readwrite";
                     $sandstorm_readwrite->lastname = " ";
                     $sandstorm_readwrite->username = "sandstorm_readwrite";
                     $sandstorm_readwrite->password = "sandstorm_readwrite";
                     $sandstorm_readwrite->save();
                     $setting_sandstorm_readwrite = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_readwrite->id]);
                 }
             } else {
                 $sandstorm_readwrite = User::where('username', '=', 'sandstorm_readwrite');
             }
             // Then the read only  user
             if (User::where('username', '=', 'sandstorm_readonly')->count() == 0) {
                 $sandstorm_readonly = User::create(Input::except('_token', 'password_confirmation', 'ui_language'));
                 if ($sandstorm_readonly) {
                     $sandstorm_readonly->firstname = "sandstorm_readonly";
                     $sandstorm_readonly->lastname = " ";
                     $sandstorm_readonly->username = "sandstorm_readonly";
                     $sandstorm_readonly->password = "sandstorm_readonly";
                     $sandstorm_readonly->save();
                     $setting_sandstorm_readonly = Setting::create(['ui_language' => 'en', 'user_id' => $sandstorm_readonly->id]);
                 }
             } else {
                 $sandstorm_readonly = User::where('username', '=', 'sandstorm_readonly');
             }
         }
         // Now that the required users are there we create the default
         if (Notebook::all()->count() == 0 && Tag::all()->count() == 0 && Note::all()->count() == 0) {
             // Notebook ...
             $notebookCreate = new Notebook();
             $notebookCreate->title = Lang::get('notebooks.welcome_notebook_title');
             $notebookCreate->save();
             $notebookCreate->users()->attach($sandstorm_readonly->id, ['umask' => PaperworkHelpers::UMASK_READONLY]);
             $notebookCreate->users()->attach($sandstorm_readwrite->id, ['umask' => PaperworkHelpers::UMASK_READWRITE]);
             $notebookCreate->users()->attach($sandstorm_admin->id, ['umask' => PaperworkHelpers::UMASK_OWNER]);
             // Tag ...
             $tagCreate = new Tag();
             $tagCreate->title = Lang::get('notebooks.welcome_note_tag');
             $tagCreate->visibility = 1;
             $tagCreate->user_id = $sandstorm_admin->id;
             $tagCreate->save();
             // Note ...
             $noteCreate = new Note();
             $versionCreate = new Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $sandstorm_admin->id]);
             $versionCreate->save();
             $noteCreate->version()->associate($versionCreate);
             $noteCreate->notebook_id = $notebookCreate->id;
             $noteCreate->save();
             $noteCreate->users()->attach($sandstorm_readonly->id, ['umask' => PaperworkHelpers::UMASK_READONLY]);
             $noteCreate->users()->attach($sandstorm_readwrite->id, ['umask' => PaperworkHelpers::UMASK_READWRITE]);
             $noteCreate->users()->attach($sandstorm_admin->id, ['umask' => PaperworkHelpers::UMASK_OWNER]);
             $noteCreate->tags()->sync([$tagCreate->id]);
         }
         // login
         if ($sandstorm_permissions == "read") {
             $credentials = ["username" => "sandstorm_readonly", "password" => "sandstorm_readonly"];
         }
         if ($sandstorm_permissions == "write,read") {
             $credentials = ["username" => "sandstorm_readwrite", "password" => "sandstorm_readwrite"];
         }
         if ($sandstorm_permissions == "admin,write,read") {
             $credentials = ["username" => "sandstorm_admin", "password" => "sandstorm_admin"];
         }
         if (Auth::attempt($credentials)) {
             $settings = Setting::where('user_id', '=', Auth::user()->id)->first();
             Session::put('ui_language', $settings->ui_language);
             return Redirect::route("/");
//.........这里部分代码省略.........
开发者ID:neynah,项目名称:paperwork,代码行数:101,代码来源:UserController.php

示例14: saveVersion

 /**
  * Save the current object as version
  *
  * @return void
  */
 public function saveVersion($setModificationDate = true)
 {
     // set date
     if ($setModificationDate) {
         $this->setModificationDate(time());
     }
     // scheduled tasks are saved always, they are not versioned!
     $this->saveScheduledTasks();
     // create version
     $version = new Version();
     $version->setCid($this->getId());
     $version->setCtype("document");
     $version->setDate($this->getModificationDate());
     $version->setUserId($this->getUserModification());
     $version->setData($this);
     $version->save();
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:22,代码来源:PageSnippet.php

示例15: update

 /**
  * @return void
  */
 protected function update()
 {
     if (!$this->getFilename() && $this->getId() != 1) {
         $this->delete();
         throw new Exception("Asset requires filename, asset with id " . $this->getId() . " deleted");
     }
     // set date
     $this->setModificationDate(time());
     // save data
     $conf = Pimcore_Config::getSystemConfig();
     // create foldertree
     $destinationPath = $this->getFileSystemPath();
     if (!is_dir(dirname($destinationPath))) {
         mkdir(dirname($destinationPath), self::$chmod, true);
     }
     if ($this->_oldPath) {
         rename(PIMCORE_ASSET_DIRECTORY . $this->_oldPath, $this->getFileSystemPath());
     }
     if ($this->getType() != "folder") {
         // get data
         $this->getData();
         // remove if exists
         if (is_file($destinationPath)) {
             unlink($destinationPath);
         }
         file_put_contents($destinationPath, $this->getData());
         chmod($destinationPath, self::$chmod);
         // check file exists
         if (!is_file($destinationPath)) {
             throw new Exception("couldn't create new asset");
         }
         // set mime type
         $mimetype = MIME_Type::autoDetect($this->getFileSystemPath());
         $this->setMimetype($mimetype);
         // set type
         $this->setTypeFromMapping();
         // update scheduled tasks
         $this->saveScheduledTasks();
         // create version
         $this->getData();
         // load data from filesystem to put it into the version
         $version = new Version();
         $version->setCid($this->getId());
         $version->setCtype("asset");
         $version->setDate($this->getModificationDate());
         $version->setUserId($this->getUserModification());
         $version->setData($this);
         $version->save();
     }
     // save properties
     $this->getProperties();
     $this->getResource()->deleteAllProperties();
     if (is_array($this->getProperties()) and count($this->getProperties()) > 0) {
         foreach ($this->getProperties() as $property) {
             if (!$property->getInherited()) {
                 $property->setResource(null);
                 $property->setCid($this->getId());
                 $property->setCpath($this->getPath() . $this->getKey());
                 $property->save();
             }
         }
     }
     // save permissions
     $this->getPermissions();
     if (is_array($this->permissions)) {
         // remove all permissions
         $this->getResource()->deleteAllPermissions();
         foreach ($this->permissions as $permission) {
             $permission->setId(null);
             $permission->setCid($this->getId());
             $permission->setCpath($this->getFullPath());
             $permission->save();
         }
     }
     // save dependencies
     $d = $this->getDependencies();
     $d->clean();
     foreach ($this->resolveDependencies() as $requirement) {
         if ($requirement["id"] == $this->getId() && $requirement["type"] == "asset") {
             // dont't add a reference to yourself
             continue;
         } else {
             $d->addRequirement($requirement["id"], $requirement["type"]);
         }
     }
     $d->save();
     $this->getResource()->update();
     if ($this->_oldPath) {
         $this->getResource()->updateChildsPaths($this->_oldPath);
     }
     $this->clearDependedCache();
     //set object to registry
     Zend_Registry::set("asset_" . $this->getId(), $this);
     Pimcore_API_Plugin_Broker::getInstance()->postUpdateAsset($this);
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:98,代码来源:Asset.php


注:本文中的Version::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。