پیش ذخیره را انجام می‌دهد

@param boolean $create
حالت
ساخت یا به روز رسانی را تعیین می‌کند
343666
function preSave($create = false)
    {
        // File path
        $path = $this->getAbsloutPath();
        // file size
        if (file_exists($path)) {
            $this->file_size = filesize($path);
        } else {
            $this->file_size = 0;
        }
        // mime type (based on file name)
        $mime_type = $this->mime_type;
        if (! isset($mime_type) || $mime_type === 'application/octet-stream') {
            $fileInfo = Pluf_FileUtil::getMimeType($this->file_name);
            $this->mime_type = $fileInfo[0];
        }
    }
635841
public function applyEditSettings($create = false)
    {
        parent::applyEditSettings($create);

        $translator = $this->getTranslateAdapter();

        if ($this->hashSsn !== parent::SSN_HIDE) {
            self::setDutchSsn($this, $translator);
        }

        $this->setIfExists('grs_iso_lang', 'default', 'nl');
        $this->setIfExists('gr2o_treatment', 'description', $this->_('DBC\'s, etc...'));

        self::setDutchZipcode($this, $translator);

        return $this;
    }
1138822
public function setCreated($created)
    {
        $this->created = $created instanceof \DateTime ? $created->format('Y-m-d H:i:s') : $created;

        return $this;
    }
319523
public function create(bool $override): bool {
        if ($this->isFile() && !$override) return false;
        $handle = @fopen($this->path, 'w');
        if (false === $handle) return false;
        fclose($handle);
        return true;
    }
695612
protected function _createdb($check = false) {
		$this->out(__d('cake_installer', 'Creating database and initializing data'));
		$this->hr();

		$resultCheck = $this->InstallerCheck->checkDbTableExists();
		if ($resultCheck) {
			if ($check) {
				$this->out('<success>' . __d('cake_installer', 'This action has already been successfully completed. Skipped.') . '</success>');

				return true;
			} elseif ($this->useActionNotify) {
				if (!$this->_checkSure(__d('cake_installer', 'All schemas exists. Re-create?'))) {
					return true;
				}
			}
		}

		$this->out(__d('cake_installer', 'Create schema of application'));
		$this->hr();
		$yesArg = '';
		if (!empty($this->param('yes'))) {
			$yesArg = ' --yes';
		}
		$defaultSchemaArgs = 'schema create --quiet' . $yesArg;
		$this->dispatchShell($defaultSchemaArgs);
		$this->hr();
		$this->nl(1);
		$schemaList = $this->ConfigInstaller->getListSchemaCreation();
		if (empty($schemaList)) {
			return true;
		}

		$this->out(__d('cake_installer', 'Create additional schemes'));
		foreach ($schemaList as $schemaName) {
			if (empty($schemaName)) {
				continue;
			}

			$this->hr();
			$this->out(__d('cake_installer', 'Create additional scheme: \'%s\'', $schemaName));
			$this->hr();
			$this->nl(1);
			$additionalSchemaArgs = 'schema create ' . $schemaName . ' --quiet' . $yesArg;
			$this->dispatchShell($additionalSchemaArgs);
		}
		$this->hr();
		$this->out('<info>' . __d('cake_installer', 'Creating additional schemes completed.') . '</info>');

		return true;
	}
204904
public function writeable($create = true, $edit = true)
    {
        $this->actions[Action::CREATE] = $create;
        $this->actions[Action::EDIT] = $edit;

        return $this;
    }
9350
private function getIndex($create = true) {
    if (!$this->index || $create) {
      $indexPath = $this->getIndexPath();

      $analyzer = new LuceneUtf8Analyzer();

      // add stop words filter
      $stopWords = $this->getStopWords();
      $stopWordsFilter = new StopWords($stopWords);
      $analyzer->addFilter($stopWordsFilter);

      Analyzer::setDefault($analyzer);
      Wildcard::setMinPrefixLength(0);
      QueryParser::setDefaultEncoding('UTF-8');
      QueryParser::setDefaultOperator(QueryParser::B_AND);

      try {
        $this->index = Lucene::open($indexPath);
        //$this->index->setMaxMergeDocs(5);
        //$this->index->setMergeFactor(5);
      }
      catch (\Exception $ex) {
        $this->index = $this->resetIndex();
      }
    }
    return $this->index;
  }
1063941
function preSave($create = false)
    {
        if ($this->id == '') {
            $this->creation_dtime = gmdate('Y-m-d H:i:s');
            $this->remain_count = $this->count;
        }
    }
728842
public function beforeSave($insert)
    {
        if(parent::beforeSave($insert))
        {
            $this->updated_at = time();
            $this->translit();
            if($this->isNewRecord)
            {
                $this->created_at = $this->updated_at;
            }
            return true;
        }
        else
            return false;
    }
269045
public function createForm (bool $edit = false)
    {
        $users = HCUsers::get();

        $form = [
            'storageURL' => route ('admin.api.routes.users.groups'),
            'buttons'    => [
                [
                    "class" => "col-centered",
                    "label" => trans ('HCTranslations::core.buttons.submit'),
                    "type"  => "submit",
                ],
            ],
            'structure'  => [
                [
                    "type"            => "singleLine",
                    "fieldID"         => "label",
                    "label"           => trans ("HCACL::users_groups.label"),
                    "required"        => 1,
                    "requiredVisible" => 1,
                ],
                [
                    "type"            => "dropDownList",
                    "fieldID"         => "users",
                    "label"           => trans ("HCACL::users_groups.users"),
                    "required"        => 0,
                    "requiredVisible" => 0,
                    "options"         => $users,
                    "search"          => [
                        "showNodes" => ['email']
                    ]
                ],
            ],
        ];

        if ($this->multiLanguage)
            $form['availableLanguages'] = getHCContentLanguages ();

        if (!$edit)
            return $form;

        //Make changes to edit form if needed
        $form['structure'][] = [
            "type"            => "dropDownList",
            "fieldID"         => "creator_id",
            "label"           => trans ("HCACL::users_groups.creator_id"),
            "readonly"        => 1,
            "requiredVisible" => 1,
            "options"         => $users,
            "search"          => [
                "maximumSelectionLength" => 1,
                "minimumSelectionLength" => 1,
                "showNodes" => ['email']
            ]
        ];

        return $form;
    }
12933
public function form($instance = true)
	{
		if ($instance instanceof Form)
		{
			$this->form = $instance;
			return $instance;
		}

		if (empty($this->form) and $instance === true)
		{
			$this->form = \Form::forge($this);
		}

		return $this->form;
	}
934574
private function fileEntitySelect($create = false, $status = null)
    {
        if (!$this->file && $this->contactClient) {
            $file = null;
            // Discern the next file entity to use.
            if (!$status) {
                $status = File::STATUS_QUEUEING;
            }
            if (!$this->test) {
                $file = $this->getFileRepository()->findOneBy(
                    ['contactClient' => $this->contactClient, 'status' => $status, 'test' => $this->test],
                    ['dateAdded' => 'desc']
                );
            }
            if (!$file && ($create || $this->test)) {
                // There isn't currently a file being built, let's create one.
                $file = new File();
                $file->setContactClient($this->contactClient);
                $file->setIsPublished(true);
                $file->setTest($this->test);
                if (!$this->test) {
                    $this->em->persist($file);
                }
            }

            if ($file) {
                $this->file = $file;
                $this->setLogs($this->file->getId(), 'fileId');
                $this->setLogs($this->file->getStatus(), 'fileStatus');
            }
        }

        if (!$this->file) {
            throw new ContactClientException(
                'Nothing queued up for this client yet.',
                0,
                null,
                Stat::TYPE_INVALID,
                false
            );
        }

        return $this;
    }
491885
public function setName($name, $createHandle = false)
    {
        $this->_name = ($createHandle) ? Lang::createHandle($name) : $name;
    }
132897
private function _init_dir($create = false){
    if ( \defined('BBN_DATA_PATH') && $this->get_id() ){
      $this->path = BBN_DATA_PATH.'users/'.$this->get_id().'/';
      if ( !\defined('BBN_USER_PATH') ){
        define('BBN_USER_PATH', $this->path);
      }
      if ( $create ){
        file\dir::create_path(BBN_USER_PATH.'tmp');
        file\dir::delete(BBN_USER_PATH.'tmp', false);
      }
    }
    return $this;
  }
503464
public function disableCreatingCheck(bool $disable = true)
    {
        $this->builder()->getFooter()->disableCreatingCheck($disable);

        return $this;
    }
1096544
public function createForm (bool $edit = false)
    {
        $form = [
            'storageURL' => route ('admin.api.resources'),
            'buttons'    => [
                [
                    "class" => "col-centered",
                    "label" => trans ('HCTranslations::core.buttons.submit'),
                    "type"  => "submit",
                ],
            ],
            'structure'  => [[
                "type"            => "resource",
                "fieldID"         => "resource",
                "uploadURL"       => route("admin.api.resources"),
                "viewURL"         => route("resource.get", ['/']),
                "label"           => trans ("HCResources::resources.resource"),
                "required"        => 1,
                "requiredVisible" => 1,
            ]],
        ];

        if (!$edit)
            return $form;

        //Make changes to edit form if needed
        $form['structure'] = [[
            "type"            => "singleLine",
            "fieldID"         => "original_name",
            "label"           => trans ("HCResources::resources.original_name"),
            "readonly"        => 1,
        ], [
            "type"            => "singleLine",
            "fieldID"         => "id",
            "label"           => trans ("HCResources::resources.safe_name"),
            "readonly"        => 1,
        ], [
            "type"            => "singleLine",
            "fieldID"         => "size",
            "label"           => trans ("HCResources::resources.size"),
            "readonly"        => 1,
        ], [
            "type"            => "singleLine",
            "fieldID"         => "path",
            "label"           => trans ("HCResources::resources.path"),
            "readonly"        => 1,
        ]];

        return $form;
    }
1152693
public function delete($code, $check = true)
    {
        $result = null;
        $this->hook->attach('currency.delete.before', $code, $check, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        if ($check && !$this->canDelete($code)) {
            return false;
        }

        $currencies = $this->config->select('currencies', array());
        unset($currencies[$code]);

        $result = $this->config->set('currencies', $currencies);

        $this->hook->attach('currency.delete.after', $code, $check, $result, $this);
        return (bool) $result;
    }