Save this Source

@param boolean $validate

@return DataSift_Source

@throws DataSift_Exception_APIError
@throws DataSift_Exception_AccessDenied
766851
public function save($validate = true)
    {
        if ($this->getValidate() != $validate) {
            $this->setValidate($validate);
        }

        $endpoint = ($this->getId() ? 'source/update' : 'source/create');
        $this->fromArray($this->getUser()->post($endpoint, $this->toArray()));

        return $this;
    }
1168522
public function storeValues($validate = true)
    {
        $this->populateFormOnce();
        $container = $this->getController()->getSessionContainer();
        $id        = $this->form->getId();

        $container->storeValues($id, (array)$this->form->getValue());
        if ($validate) {
            $container->storeValidationStatus($id, $this->form->validate());
        }
        return $container->getValidationStatus($id);
    }
662486
public function saveRenderedData(bool $save = true)
    {
        $raw = $this->getAttributeFromArray('data');

        if ($raw === null) {
            return null;
        }

        if (($rendered = markdown($raw)) === $this->getAttributeFromArray('data_rendered')) {
            return null;
        }

        $this->setAttribute('data_rendered', $rendered);

        if ($save) {
            $this->save();
        }

        $this->renderedData = $rendered;

        return $this;
    }
135290
public static function path(&$path, bool $validate=true) {
		if (\is_array($path)) {
			foreach ($path as $k=>$v) {
				static::path($path[$k], $validate);
			}
		}
		else {
			cast::string($path, true);

			// This might be a URL rather than something local.
			// Only focus on the main ones.
			if (\preg_match('/^(https?|ftps?|sftp)/iu', $path)) {
				sanitize::url($path);
				return true;
			}

			// Strip leading file:// scheme.
			if (0 === \strpos($path, 'file://')) {
				$path = \substr($path, 7);
			}

			static::unixslash($path);

			$original = $path;
			try {
				$path = @\realpath($path);
			} catch (\Throwable $e) {
				$path = false;
			}

			if ($validate && (false === $path)) {
				$path = false;
				return false;
			}
			elseif (false === $path) {
				// Try just the directory.
				try {
					$path = $original;
					if (false !== $dir = @\realpath(\dirname($path))) {
						static::trailingslash($dir);
						$path = $dir . \basename($path);
					}
					else {
						$path = $original;
					}
				} catch (\Throwable $e) {
					$path = $original;
				}
			}

			$original = $path;
			try {
				if (@\is_dir($path)) {
					static::trailingslash($path);
				}
			} catch (\Throwable $e) {
				$path = $original;
			}
		}

		return true;
	}
347665
public function setValidate(\chilimatic\lib\route\validator\AbstractValidator $validate)
    {
        $this->validate = $validate;

        return $this;
    }
19708
public function setOutputFormat($outputFormat)
    {
        if (! $this->isValidOutputFormat($outputFormat)) {
            throw new InvalidFormat("Format {$outputFormat} is not supported");
        }

        $this->outputFormat = $outputFormat;

        return $this;
    }
381306
public function save($dest='./')
  {
    $new_name = false;
    if ( substr($dest,-1) === '/' ){
      if ( is_dir($dest) ){
        $new_name = 0;
      }
    }
    else if ( is_dir($dest) ){
      $dest .= '/';
      $new_name = 0;
    }
    else if ( is_dir(substr($dest,0,strrpos($dest,'/'))) ){
      $new_name = 1;
    }
    if ( $new_name !== false ){
      if ( $new_name === 0 ){
        $dest .= $this->name;
      }
      if ( null !== $_FILES ){
        move_uploaded_file($this->file,$dest);
        $this->file = $dest;
        $this->uploaded = 1;
      }
      else{
        copy($this->file, $dest);
      }
    }
    return $this;
  }
838214
public function getWorkflow($name, $validate = true)
    {
        $useCacheTxt = $this->getProperties()->getProperty(self::CACHE, 'false');
        $useCache = false;
        if ('true' === $useCacheTxt) {
            $useCache = true;
        }

        if ($useCache && array_key_exists($name, $this->cache)) {
            $descriptor = $this->cache[$name];
            return $descriptor;
        }

        try {
            $uri = $this->uriFactory($name);
            $descriptor = WorkflowLoader::load($uri);

            if ($useCache) {
                $this->cache[$name] = $descriptor;
            }
        } catch (\Exception $e) {
            $errMsg = sprintf('Ошибка при загрузке workflow: %s', $name);
            throw new FactoryException($errMsg, $e->getCode(), $e);
        }

        return $descriptor;
    }
1143572
public function consistentDataValdiateRule ($callback, $validate_rule = []) {
		return function () use ($callback, $validate_rule) {
			$consistent_validate_rule = [];

			foreach ($callback() as $id => $value) {
				$consistent_validate_rule[$id] = [
					'force_validate'	=> false,
					'force_value'		=> false,
					'value'	=> $value,
					['===', static::ReadSuidSession($id), 'raise_exception', 'message' => 'トランザクション中固定値がマッチしません。target:{:title} input:{:value}, session:{:operand:0}'],
				];
			}

			return $consistent_validate_rule + $validate_rule;
		};
	}
397057
public function detect($userAgent = null, $validate = false) {
		$this->report = $this->_report;
		
		if($userAgent === null) {
			$userAgent =  $_SERVER['HTTP_USER_AGENT'];
		}
		
		if (!is_string($userAgent)) {
			return false;	
		}
		$this->report['ua'] = $userAgent;
		preg_match_all($this->_patterns['parser'],$userAgent,$this->data);
		
		$this->data = (isset($this->data[0])) ? $this->data[0] : false;
		
		//$this->isValid == false;
		if ($this->data === false) {
			return false;
		}
		
		try {
			$this->checkProduct();
			$this->checkOs();
			
		} catch (Exception $e) {
			
		}
		
	
		return $this->report;
	}
692710
public function getWorkflow($name, $validate = true)
    {
        $name = (string)$name;
        if (!array_key_exists($name, $this->workflows)) {
            $errMsg = sprintf('Нет workflow с именем %s', $name);
            throw new FactoryException($errMsg);
        }
        $c = $this->workflows[$name];

        if (null !== $c->descriptor) {
            return  $c->descriptor;
        }

        $descriptor = call_user_func($c->callback);

        if (!$descriptor instanceof WorkflowDescriptor) {
            $errMsg = sprintf('Ошибка при создание WorkflowDescriptor, для workflow с именем: %s', $name);
            throw new FactoryException($errMsg);
        }

        $c->descriptor = $descriptor;
        $c->descriptor->setName($name);

        return $c->descriptor;
    }
841397
public function getUser($authenticate = true)
    {
        if ($this->user) {
            return $this->user;
        } elseif (! $authenticate) {
            return;
        }

        try {
            return $this->user = $this->authenticate();
        } catch (Exception $exception) {
            return;
        }
    }
530798
public function addResource(array $resources, $validate = false)
    {
        $response = $this->getUser()->post(
            'source/resource/add',
            array('id' => $this->getId(), 'resources' => $resources, 'validate' => $validate)
        );

        $this->resources = $response['resources'];
    }
558161
public function save($sendEmail = false)
    {
        // If the parent form saved and validated
        if (parent::save($sendEmail))
        {
            // Then bind the identity to this user permanently
	    $meta = UserMetadata::model()->generatePrototype('UserMetadata', array(
		'user_id' => $this->_user->id,
		'key' => $this->provider.'Provider',
	    ));

	    $meta->value = $this->adapter->identifier;

            // Save the associative object
            return $meta->save();
        }

        return false;
    }
12681
public function validate(...$validate)
    {
        if( $this->validate === [] )
        {
            $this->validate = $validate;
        }
        else
        {
            $this->validate = array_merge($this->validate, $validate);
        }

        return $this;
    }
1129452
private function update($validate = true)
	{
		$this->verifyNotReadonly('update');

		// Valid record?
		if ($validate && !$this->_validate()) {
			return false;
		}

		// Anything to update?
		if ($this->isDirty()) {

			// Check my primary key
			$pk = $this->valuesForPk();
			if (empty($pk)) {
				throw new ActiveRecordException("Cannot update, no primary key defined for: " . get_called_class());
			}

			// Check callback
			if (!$this->invokeCallback('beforeUpdate',false)) {
				return false;
			}

			// Do the update
			$dirty = $this->dirtyAttributes();
			static::table()->update($dirty, $pk);
			$this->invokeCallback('afterUpdate',false);
		}

		return true;
	}
110314
public function getVerifyCode(bool $regenerate = false): string
    {
        if ($this->fixedVerifyCode !== null) {
            return $this->fixedVerifyCode;
        }

        $session = $this->app->getSession();
        $session->open();
        $name = $this->getSessionKey();
        if ($regenerate || $session->get($name) === null) {
            $session->set($name, $this->driver->generateVerifyCode());
            $session->set($name . 'count', 1);
        }

        return $session->get($name);
    }