Saves a new folder
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base
439313
public function newFolder($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        //Ensure logged in
        if(!Permission::check('CODE_BANK_ACCESS')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
            
            return $response;
        }
        
        $language=SnippetLanguage::get()->byID(intval($data->languageID));
        if(empty($language) || $language===false || $language->ID==0) {
            $response['status']="EROR";
            $response['message']=_t('CodeBankAPI.LANGUAGE_NOT_FOUND', '_Language not found');
            return $response;
        }
        
        
        if($data->parentID>0) {
            $folder=SnippetFolder::get()->byID(intval($data->parentID));
            if(empty($folder) || $folder===false || $folder->ID==0) {
                $response['status']="EROR";
                $response['message']=_t('CodeBankAPI.FOLDER_DOES_NOT_EXIST', '_Folder does not exist');
                return $response;
            }
            
            if($folder->LanguageID!=$language->ID) {
                $response['status']="EROR";
                $response['message']=_t('CodeBankAPI.FOLDER_NOT_LANGUAGE', '_Folder is not in the same language as the snippet');
                return $response;
            }
        }
        
        
        
        //Check existing
        $existingCheck=SnippetFolder::get()->filter('Name:nocase', Convert::raw2sql($data->name))->filter('LanguageID', $language->ID)->filter('ParentID', $data->parentID);
        
        
        if($existingCheck->Count()>0) {
            $response['status']="EROR";
            $response['message']=_t('CodeBank.FOLDER_EXISTS', '_A folder already exists with that name');
            return $response;
        }
        
        
        try {
            $snippetFolder=new SnippetFolder();
            $snippetFolder->Name=$data->name;
            $snippetFolder->LanguageID=$data->languageID;
            $snippetFolder->ParentID=$data->parentID;
            $snippetFolder->write();
            
            
            $response['status']="HELO";
        }catch(Exception $e) {
            $response['status']="EROR";
            $response['message']="Internal Server error occured";
        }
        
        
        return $response;
    }
586222
public function put($data)
    {
        $this->data = array_merge($this->data, $data);
        return $this->save();
    }
624988
public function save($data = null)
    {
        if ($data !== null) {
            $this->data = $data;
        }

        return $this->getHandler()->renderPath($this->getPath(), $this->data);
    }
1079841
public function createNewRecord($data) {
        $list_email = new $this->model;

        $list_email->title      = $data['list_id']." ".$data['email_id'];
        $list_email->list_id    = $data['list_id'];
        $list_email->email_id   = $data['email_id'];
        $list_email->comments   = $data['comments'];
        $list_email->enabled    = $data['enabled'];
        $list_email->created_at = $data['created_at'];
        $list_email->created_by = $data['created_by'];
        $list_email->updated_at = $data['updated_at'];
        $list_email->updated_by = $data['updated_by'];
        $list_email->locked_at  = null;
        $list_email->locked_by  = null;

        if ($list_email->save()) {

            // Return the new ID
            return $list_email->id;
        }

        return false;
    }
1220690
public function createNew($data)
    {
        if ($data instanceof File) {
            /** @var $data File */
            $media = new Media();
            if (method_exists($data, 'getClientOriginalName')) {
                $media->setOriginalFilename($data->getClientOriginalName());
            } else {
                $media->setOriginalFilename($data->getFilename());
            }
            $media->setContent($data);

            $contentType = $this->mimeTypeGuesser->guess($media->getContent()->getPathname());
            $media->setContentType($contentType);

            return $media;
        }

        return null;
    }
1179172
public function insertNewRecord($data) {

        $emailMessage = new Email_message;

        $emailMessage->user_id             = $data['user_id'];
        $emailMessage->priority_id         = $data['priority_id'];
        $emailMessage->from_email_address  = $data['from_email_address'];
        $emailMessage->from_name           = $data['from_name'];
        $emailMessage->to_email_address    = $data['to_email_address'];
        $emailMessage->to_name             = $data['to_name'];
        $emailMessage->subject             = $data['subject'];
        $emailMessage->slug                = $data['slug'];
        $emailMessage->body                = $data['body'];
        $emailMessage->sent                = $data['sent'];
        $emailMessage->sent_timestamp      = $data['sent_timestamp'];
        $emailMessage->read                = $data['read'];
        $emailMessage->archived            = $data['archived'];
        $emailMessage->created_at          = $data['created_at'];
        $emailMessage->created_by          = $data['created_by'];
        $emailMessage->updated_at          = $data['updated_at'];
        $emailMessage->updated_by          = $data['updated_by'];

        if ($emailMessage->save()) {

            // Return the new ID
            return $emailMessage->id;
        }

        return false;
    }
980227
public function save(array $data)
    {
        return (bool) file_put_contents($this->file, $this->serializer->serialize($data));
    }
604725
public function save($data)
    {
        if (is_array($data)) {
            foreach ($data as $entity) {
                $this
                    ->manager
                    ->persist($entity);
            }
        } else {
            $this
                ->manager
                ->persist($data);
        }

        $this
            ->manager
            ->flush($data);

        return $data;
    }
608913
public function saveIPMessage($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        if(!Permission::check('ADMIN')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
            return $response;
        }
        
        
        try {
            $codeBankConfig=CodeBankConfig::CurrentConfig();
            $codeBankConfig->IPMessage=$data->message;
            $codeBankConfig->write();
            
            
            $response['status']='HELO';
            $response['message']=_t('CodeBankAPI.IP_MESSAGE_CHANGE', '_Intellectual Property message changed successfully');
        }catch (Exception $e) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
        }
        
        return $response;
    }
1042433
public function create($data = [])
    {
        // Create a random hash
        $hash = $this->hash();

        // Store the file in the tokens storage
        $data = array_merge($data, ['token' => $hash, 'timestamp' => time()]);
        $stored = file_put_contents($this->path($hash), json_encode($data));

        // Return the data or false in case of failure
        return ($stored)? $data : false;
    }
746280
protected function saveToCache(array $data)
    {
        $cacheDir = dirname($this->cacheFile);

        if (! is_dir($cacheDir) || ! is_writable($cacheDir)) {
            throw new \RuntimeException(sprintf(
                'Invalid cache directory "%s": directory does not exist or not writable.',
                $cacheDir
            ));
        }

        return file_put_contents(
            $this->cacheFile,
            '<?php return ' . var_export($data, true) . ';'
        );
    }
1325087
public function convertObjectInFolder(array $data = null)
    {
        if (empty($data)) {
            return null;
        }

        $objectInFolderData = new ObjectInFolderData();
        $object = $this->convertObject($data[JSONConstants::JSON_OBJECTINFOLDER_OBJECT] ?? []);

        if ($object !== null) {
            $objectInFolderData->setObject($object);
        }

        $objectInFolderData->setPathSegment((string) $data[JSONConstants::JSON_OBJECTINFOLDER_PATH_SEGMENT] ?? null);
        $objectInFolderData->setExtensions($this->convertExtension($data, JSONConstants::getObjectInFolderKeys()));

        return $objectInFolderData;
    }
705278
public function save($data)
    {
        $db = $this->getDb();
        $fields = [];

        foreach ($data as $field => $value) {
            $fields[] = '`' . $field . '` = ' . $db->quote($value);
        }

        $query = 'INSERT INTO `oepaypal_order` SET ';
        $query .= implode(', ', $fields);
        $query .= ' ON DUPLICATE KEY UPDATE ';
        $query .= ' `oepaypal_orderid`=LAST_INSERT_ID(`oepaypal_orderid`), ';
        $query .= implode(', ', $fields);

        $db->execute($query);

        $id = $data['oepaypal_orderid'];
        if (empty($id)) {
            $id = $db->getOne('SELECT LAST_INSERT_ID()');
        }

        return $id;
    }
211085
public function populateData(array $data)
    {
        //attempt to make the storage path if it doesn't already exist
        $path = $this->getStoragePath();

        if (!is_dir($path)) {
            mkdir($path);
        }

        //try to fetch the JSON file
        $file = $path.$this->getOption('name').'.json';

        if (file_exists($file)) {
            $json     = file_get_contents($file);
            $saveData = json_decode($json);

            //run through the saveData and update the associated fields that we populated from the edit fields
            foreach ($saveData as $field => $value) {
                if (array_key_exists($field, $data)) {
                    $data[$field] = $value;
                }
            }
        }

        return $data;
    }
69219
function save($args)
    {
        $args = parent::save($args);

        $this->_load_drivers();

        $data = $args['path'] ? file_get_contents($args['path']) : $args['data'];

        $args['data'] = null;

        $key  = $this->_key($args);
        $data = base64_encode($data);

        $status = $this->cache->write($key, $data);

        if (!$status && $this->mem_cache) {
            $status = $this->mem_cache->write($key, $data);
        }

        if ($status) {
            $args['id'] = $key;
            $args['status'] = true;
        }

        return $args;
    }
511817
public function createNewRecord($data) {

        $email = new $this->model;

        $email->email_type_id = $data['email_type_id'];
        $email->title         = $data['title'];
        $email->description   = $data['description'];
        $email->comments      = $data['comments'];
        $email->created_at    = $data['created_at'];
        $email->created_by    = $data['created_by'];
        $email->updated_at    = $data['updated_at'];
        $email->updated_by    = $data['updated_by'];
        $email->locked_at     = null;
        $email->locked_by     = null;

        if ($email->save()) {

            // Return the new ID
            return $email->id;
        }

        return false;
    }
682228
public function saveProduct($data)
    {
        Event::fire(new ProductBeforeSave($data));

        $this->update($data);
        $this->saveProductImages($data);
        $this->saveCategoryFilters($data);
        $this->saveProductCategories($data);
        $this->saveProductProperties($data);
        $this->saveProductAttributes($data);
        $this->saveProductDownloadable($data);

        Event::fire(new ProductAfterSave($this, $data));

        return $this;
    }