Save an App
@throws \Exception
769747
public function save()
    {
        $appname = $this->name;
        $temp = "no";
        $temdirbase = FEnv::get("framework.root").
            "vendor/iumio-framework/Core/Additional/Manager/Module/App/AppTemplate";
        $tempdir = ($temp == "no")? $temdirbase.'/notemplate/{appname}/' : $temdirbase.'/template/{appname}/';
        Server::copy($tempdir, FEnv::get("framework.root")."apps/".$appname, 'directory');
        $napp = FEnv::get("framework.root")."apps/".$appname;

        // APP
        $f = file_get_contents($napp."/{appname}.php.local");
        $str = str_replace("{appname}", $appname, $f);
        file_put_contents($napp."/{appname}.php.local", $str);
        rename($napp."/{appname}.php.local", $napp."/$appname.php");

        // Mercure
        $f = file_get_contents($napp."/Routing/default.merc");
        $str = str_replace("{appname}", $appname, $f);
        file_put_contents($napp."/Routing/default.merc", $str);

        // MASTER
        $f = file_get_contents($napp."/Masters/DefaultMaster.php.local");
        $str = str_replace("{appname}", $appname, $f);
        file_put_contents($napp."/Masters/DefaultMaster.php.local", $str);
        rename($napp."/Masters/DefaultMaster.php.local", $napp."/Masters/DefaultMaster.php");

        // REGISTER TO APP CORE
        $f = json_decode(file_get_contents(FEnv::get("framework.root").
            "elements/config_files/core/apps.json"));
        $lastapp = 0;
        foreach ($f as $one => $val) {
            $lastapp++;
        }
        if ($this->params['isdefault'] == "yes") {
            foreach ($f as $one => $val) {
                if ($val->isdefault == "yes") {
                    $val->isdefault = "no";
                    break;
                }
            }
        }
        $f->$lastapp = new \stdClass();
        $f->$lastapp->name = $this->params['appname'];
        $f->$lastapp->isdefault = $this->params['isdefault'];
        $f->$lastapp->class = "\\".$this->params['appname']."\\".$this->params['appname'];
        $f = json_encode($f, JSON_PRETTY_PRINT);
        file_put_contents(FEnv::get("framework.root")."elements/config_files/core/apps.json", $f);
        if ($this->params['template'] == "yes") {
            new AM(array("core/manager", "assets-manager", "--copy", "--appname=". $this->params['appname'],
                "--symlink", "--noexit"));
        }
        Output::outputAsSuccess("\n Your app is ready to use. To test your app go to project location on your
         browser with parameter /hello. Enjoy ! \n", "none");
    }
148971
public function save()
    {
		$widgets = $this->getParam('widgets');
		if (is_array($widgets)) $this->widgets = $widgets;
		unset( $this->_params['widgets'] );
		
        parent::save();
		
        $this->getDbConnection()->delete('widgets_containers', array( 'container_id' => $this->getId() ));
        foreach($this->widgets as $i => $w)
            $this->getDbConnection()->insert('widgets_containers', array(
                'container_id' => $this->getId(),
                'widget_id'    => $w->getId(),
                'position'     => $i
            ));       
    }
403464
public function save()
    {
        parent::save();

        $action = oxNew(Actions::class);

        if ($this->isNewEditObject() !== true) {
            $action->load($this->getEditObjectId());
        }

        if ($this->checkAccessToEditAction($action) === true) {
            $action->assign($this->getActionFormData());
            $action->setLanguage($this->_iEditLang);
            $action = Registry::getUtilsFile()->processFiles($action);
            $action->save();

            $this->setEditObjectId($action->getId());
        }
    }
1170849
public function save()
    {
        /** @var CompiledYamlFile $file */
        $file = $this->file();
        if (!$file || !$file->filename()) {
            user_error(__CLASS__ . ': calling \$user = new ' . __CLASS__ . "() is deprecated since Grav 1.6, use \$grav['accounts']->load(\$username) or \$grav['accounts']->load('') instead", E_USER_DEPRECATED);
        }

        if ($file) {
            $username = $this->get('username');

            if (!$file->filename()) {
                $locator = Grav::instance()['locator'];
                $file->filename($locator->findResource('account://' . mb_strtolower($username) . YAML_EXT, true, true));
            }

            // if plain text password, hash it and remove plain text
            $password = $this->get('password');
            if ($password) {
                $this->set('hashed_password', Authentication::create($password));
                $this->undef('password');
            }

            $data = $this->items;
            unset($data['username'], $data['authenticated'], $data['authorized']);

            $file->save($data);
        }
    }
290273
public function save($chmod = null)
    {
        if ($this->modified) {
            if (false === @file_put_contents($this->filename, $this->generateIni())) {
                throw new \Exception('Impossible to write into '.$this->filename);
            } elseif ($chmod) {
                chmod($this->filename, $chmod);
            }
            $this->modified = false;
        }
    }
1360443
public function save()
    {
        if (Yii::$app instanceof Application) {
            Media::updateAll([
                'model_id' => $this->owner->getPrimaryKey(),
            ], [
                'AND',
                ['=', 'model', $this->owner::className()],
                ['IN', 'id', Yii::$app->request->post($this->name, [])],
            ]);
        }
    }
133045
public function save()
    {
        $str = $this->prepareForSave($this->toArray());
        if (empty($this->__path)) {
            throw new Exception('Empty path for config save');
        }
        file_put_contents($this->__path, '<?php' . PHP_EOL . PHP_EOL . 'return ' . $str . ';');
        return $this;
    }
1199851
public function save()
    {
        $render = new Renderer($this->configuration);
        $siteInstall = $render->render();
        $render = new Renderer([
            'userEmail' => $this->getUserEmail(),
            'userPasswordHash' => $this->getUserPasswordHash(),
            'startingPointHandle' => $this->getStartingPointHandle(),
            'siteName' => $this->getSiteName(),
            'siteLocaleId' => $this->getSiteLocaleId(),
            'uiLocaleId' => $this->getUiLocaleId(),
            'serverTimeZone' => $this->getServerTimeZoneId(),
            'privacyPolicy' => $this->isPrivacyPolicyAccepted()
        ]);
        $siteInstallUser = $render->render();
        if (@$this->filesystem->put(DIR_CONFIG_SITE . '/site_install.php', $siteInstall) === false) {
            throw new UserMessageException(t('Failed to write to file %s', DIRNAME_APPLICATION . '/' . DIRNAME_CONFIG . '/site_install.php'));
        }
        OpCache::clear(DIR_CONFIG_SITE . '/site_install_user.php');
        if (@$this->filesystem->put(DIR_CONFIG_SITE . '/site_install_user.php', $siteInstallUser) === false) {
            throw new UserMessageException(t('Failed to write to file %s', DIRNAME_APPLICATION . '/' . DIRNAME_CONFIG . '/site_install_user.php'));
        }
        OpCache::clear(DIR_CONFIG_SITE . '/site_install_user.php');
    }
1190595
final private function protectMethod()
    {
        if (!(
            App::environment('testing')
            || ($this->callerService instanceof Service)
            || (self::$callerServiceForNext instanceof Service)
        )) {
            throw new \Exception('You must use an Subbly\Api\Service\Service to save a Model');
        }

        $this->callerService = null;
    }
403793
public static void saveInstances( Application app ) {

		File targetFile = new File( app.getDirectory(), Constants.PROJECT_DIR_INSTANCES + "/" + INSTANCES_FILE );
		try {
			Utils.createDirectory( targetFile.getParentFile());
			RuntimeModelIo.writeInstances( targetFile, app.getRootInstances());

		} catch( IOException e ) {
			Logger logger = Logger.getLogger( ConfigurationUtils.class.getName());
			logger.severe( "Failed to save instances. " + e.getMessage());
			Utils.logException( logger, e );
		}
	}
1244426
public function save() {
		if($this->msg) {
			ksort($this->msg);
			
			$file = $this->folder."messages_".$this->language.".php";

			$old = umask(00002);

			if (file_exists($file) && !is_writable($file)) {
				throw new FileTranslatorException('Cannot write to file "'.$file.'".');
			} elseif (!file_exists($file)) {
				if (!is_dir($this->folder)) {
					$result = mkdir($this->folder, 0775, true);
					if (!$result) {
						throw new FileTranslatorException('Cannot create directory "'.$this->folder.'".');
					}
				}
				if (!is_writable($this->folder)) {
					throw new FileTranslatorException('Cannot write to directory "'.$this->folder.'".');
				}
			}


			$fp = fopen($file, "w");
			fwrite($fp, "<?php\n");
			fwrite($fp, 'return ');
			fwrite($fp, var_export($this->msg, true));
			fwrite($fp, ";\n");
			
			fclose($fp);
			umask($old);
		}
	}
243604
public function save() 
    {
        try {
            $m = self::getByAlias($this->alias);
        } catch (\Exception $e) {}
        
        if ($m && $m->id != $this->id) throw new Exception\CMS('Меню c таким алиасом уже существует.');
        
		self::getDbConnection()->update('menus',
			array(
				'alias' => $this->alias,
				'name'  => $this->name,
				'data'  => serialize($this->data),
			),
			array('id' => $this->id)
		);
  	}
1213082
protected function saveToCache()
    {
        if (!is_object($this->dataCache)) {
            throw new Exception('A cache must be injected before initializing the Reflection Service.', 1232044697);
        }
        $data = [];
        $propertyNames = [
            'reflectedClassNames',
            'classPropertyNames',
            'classMethodNames',
            'classTagsValues',
            'methodTagsValues',
            'methodParameters',
            'propertyTagsValues',
            'taggedClasses',
            'classSchemata'
        ];
        foreach ($propertyNames as $propertyName) {
            $data[$propertyName] = $this->{$propertyName};
        }
        $this->dataCache->set($this->cacheIdentifier, $data);
        $this->dataCacheNeedsUpdate = false;
    }
220682
public function save()
    {
        if (file_exists($this->getPath())) {
            $this->setContent($this->encode());
            
            file_put_contents($this->getPath(), $this->getContent());
            
            return;
        }
    }
329194
private function saveFile(): void
    {
        $sourceCode = Helpers::tabsToSpaces((string) $this->entityFile);
        $entityPath = dirname(__DIR__, 7) . '/src/' . $this->entityData['namespace'] . '/';

        $handle = fopen($entityPath . $this->entityData['class'] . '.php', 'w');
        fwrite($handle, $sourceCode);
        fclose($handle);
    }
861756
public function boot()
    {
        if ((php_sapi_name() === 'cli' || defined('STDIN'))) {
            return;
        }

        if (session_status() == PHP_SESSION_ACTIVE) {
            throw new Exception('Session is already started');
        }

        // save path
        if ($this->app->hasProp($this->sessionPropName.'.save_path')) {
            session_save_path($this->app->getProp($this->sessionPropName.'.save_path'));
        }

        // save handler class
        if ($this->app->hasProp($this->sessionPropName.'.save_handler')) {
            session_set_save_handler($this->app->getProp($this->sessionPropName.'.save_handler'));
        }

        // name the session
        if ($this->app->hasProp($this->sessionPropName.'.name')) {
            session_name($this->app->getProp($this->sessionPropName.'.name'));
        }

        // session options
        $options = [];
        if ($this->app->hasProp($this->sessionPropName.'.options')) {
            $options = $this->app->getProp($this->sessionPropName.'.options');
        }

        // start the session
        session_start($options);
    }
984960
public function save()
    {
        foreach ($this->_update as $mbox => $val) {
            try {
                if (!empty($val['u'])) {
                     $ptr = &$this->_data[$mbox];
                     foreach ($this->_getMsgCids($mbox, array_keys($val['u'])) as $k2 => $v2) {
                         try {
                             $this->_hash->set(
                                 $v2,
                                 $this->_pack->pack($ptr[$k2]),
                                 array('expire' => $this->_params['lifetime'])
                             );
                         } catch (Horde_Pack_Exception $e) {
                             $this->deleteMsgs($mbox, array($v2));
                             $val['d'][] = $v2;
                         }
                     }
                 }

                 if (!empty($val['d'])) {
                     $this->_hash->delete(array_values(
                         $this->_getMsgCids($mbox, $val['d'])
                     ));
                 }

                 if (!empty($val['m'])) {
                     try {
                         $this->_hash->set(
                             $this->_getCid($mbox),
                             $this->_pack->pack($this->_mbox[$mbox]),
                             array('expire' => $this->_params['lifetime'])
                         );
                     } catch (Horde_Pack_Exception $e) {}
                 }
            } catch (Horde_Exception $e) {
            }
        }

        $this->_update = array();
    }