code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
protected function applyLengthValidators(ValidatorManagerInterface $manager) { $minimum = $this->getMinimumRequirement(); $maximum = $this->getMaximumRequirement(); $this->applyMinMaxStrings($minimum, $maximum); // Set validators if ($maximum) { $manager->setValidator('maximum_length', $maximum); } if ($minimum) { $manager->setValidator('minimum_length', $minimum); } }
Apply configured password length validators @param $manager
applyLengthValidators
php
concretecms/concretecms
concrete/src/Validator/PasswordValidatorServiceProvider.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/PasswordValidatorServiceProvider.php
MIT
protected function getMaximumRequirement() { $maximumLength = $this->config->get('concrete.user.password.maximum'); return $maximumLength ? $this->app->make(MaximumLengthValidator::class, ['maximum_length' => $maximumLength]) : null; }
Get maximum length validator @return \Concrete\Core\Validator\String\MaximumLengthValidator|null
getMaximumRequirement
php
concretecms/concretecms
concrete/src/Validator/PasswordValidatorServiceProvider.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/PasswordValidatorServiceProvider.php
MIT
protected function getMinimumRequirement() { $minimumLength = $this->config->get('concrete.user.password.minimum', 8); return $minimumLength ? $this->app->make(MinimumLengthValidator::class, ['minimum_length' => $minimumLength]) : null; }
Get minimum length validator @return \Concrete\Core\Validator\String\MinimumLengthValidator|null
getMinimumRequirement
php
concretecms/concretecms
concrete/src/Validator/PasswordValidatorServiceProvider.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/PasswordValidatorServiceProvider.php
MIT
protected function applyMinMaxStrings($minimum, $maximum) { if ($minimum && $maximum) { $errorString = t('A password must be between %s and %s characters long.', $minimum->getMinimumLength(), $maximum->getMaximumLength()); $requirement = t('Must be between %s and %s characters long.', $minimum->getMinimumLength(), $maximum->getMaximumLength()); } elseif ($minimum) { $errorString = t('Must be at least %s characters long.', $minimum->getMinimumLength()); $requirement = t('A password must be at least %s characters long.', $minimum->getMinimumLength()); } elseif ($maximum) { $errorString = t('A password must be at most %s characters long.', $maximum->getMaximumLength()); $requirement = t('Must be at most %s characters long.', $maximum->getMaximumLength()); } else { $errorString = t('Invalid Password.'); $requirement = ''; } $errorHandler = function ($validator, $code, $password) use ($errorString) { return $errorString; }; $requirementHandler = function ($validator, $code) use (&$requirement) { return $requirement; }; $minimum->setRequirementString($minimum::E_TOO_SHORT, $requirementHandler); $minimum->setErrorString($minimum::E_TOO_SHORT, $errorHandler); if (is_object($maximum)) { $maximum->setRequirementString($maximum::E_TOO_LONG, $requirementHandler); $maximum->setErrorString($maximum::E_TOO_LONG, $errorHandler); } }
Apply translatable strings to minimum and maximum requirements @param $minimum @param $maximum
applyMinMaxStrings
php
concretecms/concretecms
concrete/src/Validator/PasswordValidatorServiceProvider.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/PasswordValidatorServiceProvider.php
MIT
protected function applyStringRequirementValidators(ValidatorManagerInterface $manager) { $specialCharacters = (int) $this->config->get('concrete.user.password.required_special_characters', 0); $lowerCase = (int) $this->config->get('concrete.user.password.required_lower_case', 0); $upperCase = (int) $this->config->get('concrete.user.password.required_upper_case', 0); if ($specialCharacters) { $regex = "/([^a-zA-Z0-9].*){{$specialCharacters},}/"; $requirement = t2('Must contain at least %d special character.', 'Must contain at least %d special characters.', $specialCharacters); $manager->setValidator('required_special_characters', $this->regexValidator($regex, $requirement)); } if ($lowerCase) { $regex = "/([a-z].*){{$lowerCase},}/"; $requirement = t2('Must contain at least %d lowercase character.', 'Must contain at least %d lowercase characters.', $lowerCase); $manager->setValidator('required_lower_case', $this->regexValidator($regex, $requirement)); } if ($upperCase) { $regex = "/([A-Z].*){{$upperCase},}/"; $requirement = t2('Must contain at least %d uppercase character.', 'Must contain at least %d uppercase characters.', $upperCase); $manager->setValidator('required_upper_case', $this->regexValidator($regex, $requirement)); } }
Apply validators that require specific substrings @param \Concrete\Core\Validator\ValidatorManagerInterface $manager
applyStringRequirementValidators
php
concretecms/concretecms
concrete/src/Validator/PasswordValidatorServiceProvider.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/PasswordValidatorServiceProvider.php
MIT
protected function regexValidator($regex, $requirement) { $validator = $this->app->make(RegexValidator::class, ['pattern' => $regex]); $validator->setRequirementString(RegexValidator::E_DOES_NOT_MATCH, $requirement); $validator->setErrorString(RegexValidator::E_DOES_NOT_MATCH, $requirement); return $validator; }
Create a regex validator @param string $regex @param string $requirement @return RegexValidator
regexValidator
php
concretecms/concretecms
concrete/src/Validator/PasswordValidatorServiceProvider.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/PasswordValidatorServiceProvider.php
MIT
protected function wrappedRegexValidator($regex, $requirementString) { $regexValidator = $this->regexValidator($regex, $requirementString); $validator = $this->app->make(ClosureValidator::class, [ 'validator_closure' => function (ClosureValidator $validator, $string, ?ArrayAccess $error = null) use ($regexValidator) { try { $regexValidator->isValid($string, $error); } catch (\RuntimeException $e) { if ($error) { $error[] = $regexValidator::E_DOES_NOT_MATCH; } return false; } }, 'requirements_closure' => function () use ($regexValidator, $requirementString) { return [ $regexValidator::E_DOES_NOT_MATCH => $requirementString ]; } ] ); return $validator; }
Create a closure validator that wraps a regex validator and handles all errors If the given regex is invalid, we will deny all passwords! @param $regex @param $requirementString @return \Concrete\Core\Validator\ClosureValidator|mixed
wrappedRegexValidator
php
concretecms/concretecms
concrete/src/Validator/PasswordValidatorServiceProvider.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/PasswordValidatorServiceProvider.php
MIT
public function register() { $this->app->singleton('validator/user/email', function (Application $app) { $config = $app->make('config'); $manager = $app->make(ValidatorForSubjectInterface::class); $manager->setValidator( 'unique_user_email', $app->make( UniqueUserEmailValidator::class, [ 'testMXRecord' => $config->get('concrete.user.email.test_mx_record', false), 'strict' => $config->get('concrete.user.email.strict', false), ] ) ); return $manager; }); }
{@inheritdoc} @see \Concrete\Core\Foundation\Service\Provider::register()
register
php
concretecms/concretecms
concrete/src/Validator/UserEmailValidatorServiceProvider.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/UserEmailValidatorServiceProvider.php
MIT
public function register() { $this->app->singleton('validator/user/name', function (Application $app) { $config = $app->make('config'); $manager = $app->make(ValidatorForSubjectInterface::class); $minimumLengthValidator = null; $maximumLengthValidator = null; $lengthError = function ($validator, $code, $username) use (&$minimumLengthValidator, &$maximumLengthValidator) { if ($minimumLengthValidator && $maximumLengthValidator) { return t('A username must be between %s and %s characters long.', $minimumLengthValidator->getMinimumLength(), $maximumLengthValidator->getMaximumLength()); } elseif ($minimumLengthValidator) { return t('A username must be at least %s characters long.', $minimumLengthValidator->getMinimumLength()); } elseif ($maximumLengthValidator) { return t('A username can be at most %s characters long.', $maximumLengthValidator->getMaximumLength()); } return t('Invalid username.'); }; $lengthRequirements = function ($validator, $code) use (&$minimumLengthValidator, &$maximumLengthValidator) { if ($minimumLengthValidator && $maximumLengthValidator) { return t('Must be between %s and %s characters long.', $minimumLengthValidator->getMinimumLength(), $maximumLengthValidator->getMaximumLength()); } elseif ($minimumLengthValidator) { return t('Must be at least %s characters long.', $minimumLengthValidator->getMinimumLength()); } elseif ($maximumLengthValidator) { return t('Must be at most %s characters long.', $maximumLengthValidator->getMaximumLength()); } }; $minimumLength = $config->get('concrete.user.username.minimum', 1); if ($minimumLength) { $minimumLengthValidator = $app->make(MinimumLengthValidator::class, ['minimum_length' => $minimumLength]); $minimumLengthValidator->setRequirementString($minimumLengthValidator::E_TOO_SHORT, $lengthRequirements); $minimumLengthValidator->setErrorString($minimumLengthValidator::E_TOO_SHORT, $lengthError); $manager->setValidator('minimum_length', $minimumLengthValidator); } $maximumLength = $config->get('concrete.user.username.maximum'); if ($maximumLength) { $maximumLengthValidator = $app->make(MaximumLengthValidator::class, ['maximum_length' => $maximumLength]); $maximumLengthValidator->setRequirementString($maximumLengthValidator::E_TOO_LONG, $lengthRequirements); $maximumLengthValidator->setErrorString($maximumLengthValidator::E_TOO_LONG, $lengthError); $manager->setValidator('maximum_length', $maximumLengthValidator); } $rxBoundary = '[' . $config->get('concrete.user.username.allowed_characters.boundary') . ']'; $rxMiddle = '[' . $config->get('concrete.user.username.allowed_characters.middle') . ']'; $rx = "/^({$rxBoundary}({$rxMiddle}*{$rxBoundary})?)?$/"; $rxValidator = $app->make(RegexValidator::class, ['pattern' => $rx]); $rxValidator->setRequirementString($rxValidator::E_DOES_NOT_MATCH, function($validator, $code) use ($config) { return t($config->get('concrete.user.username.allowed_characters.requirement_string')); }); $rxValidator->setErrorString($rxValidator::E_DOES_NOT_MATCH, function($validator, $code) use ($config) { return t($config->get('concrete.user.username.allowed_characters.error_string')); }); $manager->setValidator('valid_pattern', $rxValidator); $manager->setValidator('unique_username', $app->make(UniqueUserNameValidator::class)); return $manager; }); }
{@inheritdoc} @see \Concrete\Core\Foundation\Service\Provider::register()
register
php
concretecms/concretecms
concrete/src/Validator/UserNameValidatorServiceProvider.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/UserNameValidatorServiceProvider.php
MIT
public function isValid($mixed, ?ArrayAccess $error = null) { return $this->isValidFor($mixed, null, $error); }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorInterface::isValid()
isValid
php
concretecms/concretecms
concrete/src/Validator/ValidatorForSubjectManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/ValidatorForSubjectManager.php
MIT
public function isValidFor($mixed, $subject = null, ?ArrayAccess $error = null) { $valid = true; foreach ($this->getValidators() as $validator) { if ($validator instanceof ValidatorForSubjectInterface) { if (!$validator->isValidFor($mixed, $subject, $error)) { $valid = false; } } elseif (!$validator->isValid($mixed, $error)) { $valid = false; } } return $valid; }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorForSubjectInterface::isValidFor()
isValidFor
php
concretecms/concretecms
concrete/src/Validator/ValidatorForSubjectManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/ValidatorForSubjectManager.php
MIT
public function isValid($mixed, ?ArrayAccess $error = null) { return $this->isValidFor($mixed, null, $error); }
@see \Concrete\Core\Validator\ValidatorInterface::isValid()
isValid
php
concretecms/concretecms
concrete/src/Validator/ValidatorForSubjectTrait.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/ValidatorForSubjectTrait.php
MIT
public function getRequirementStrings() { $strings = []; foreach ($this->getValidators() as $validator) { $validator_strings = $validator->getRequirementStrings(); $strings = array_merge($strings, $validator_strings); } return $strings; }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorInterface::getRequirementStrings()
getRequirementStrings
php
concretecms/concretecms
concrete/src/Validator/ValidatorManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/ValidatorManager.php
MIT
public function getValidators() { return $this->validators; }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorManagerInterface::getValidators()
getValidators
php
concretecms/concretecms
concrete/src/Validator/ValidatorManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/ValidatorManager.php
MIT
public function hasValidator($handle) { return isset($this->validators[$handle]); }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorManagerInterface::hasValidator()
hasValidator
php
concretecms/concretecms
concrete/src/Validator/ValidatorManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/ValidatorManager.php
MIT
public function setValidator($handle, ?ValidatorInterface $validator = null) { $this->validators[$handle] = $validator; }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorManagerInterface::setValidator()
setValidator
php
concretecms/concretecms
concrete/src/Validator/ValidatorManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/ValidatorManager.php
MIT
public function isValid($mixed, ?ArrayAccess $error = null) { $valid = true; foreach ($this->getValidators() as $validator) { if (!$validator->isValid($mixed, $error)) { $valid = false; } } return $valid; }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorInterface::isValid()
isValid
php
concretecms/concretecms
concrete/src/Validator/ValidatorManager.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/ValidatorManager.php
MIT
public function register() { // Bind the manager interface to the default implementation $this->app->bind(ValidatorManagerInterface::class, ValidatorManager::class); $this->app->bind(ValidatorForSubjectInterface::class, ValidatorForSubjectManager::class); }
{@inheritdoc} @see \Concrete\Core\Foundation\Service\Provider::register()
register
php
concretecms/concretecms
concrete/src/Validator/ValidatorServiceProvider.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/ValidatorServiceProvider.php
MIT
public function __construct($testMXRecord = false, $strict = false) { $this ->setTestMXRecord($testMXRecord) ->setStrict($strict) ; $this->setRequirementString( self::E_INVALID_ADDRESS, function (EmailValidator $validator, $code) { return t('The email address must be valid.'); } ); $this->setErrorString( self::E_INVALID_ADDRESS, function (EmailValidator $validator, $code, $mixed) { return t('Invalid email address.'); } ); }
EmailValidator constructor. @param bool $testMXRecord Should we test the MX record to see if the domain is valid? @param bool $strict Should email address warnings be considered as errors?
__construct
php
concretecms/concretecms
concrete/src/Validator/String/EmailValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/EmailValidator.php
MIT
public function isTestMXRecord() { return $this->testMXRecord; }
Should we test the MX record to see if the domain is valid? @return bool
isTestMXRecord
php
concretecms/concretecms
concrete/src/Validator/String/EmailValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/EmailValidator.php
MIT
public function setTestMXRecord($testMXRecord) { $this->testMXRecord = (bool) $testMXRecord; return $this; }
Should we test the MX record to see if the domain is valid? @param bool $testMXRecord @return $this
setTestMXRecord
php
concretecms/concretecms
concrete/src/Validator/String/EmailValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/EmailValidator.php
MIT
public function isStrict() { return $this->strict; }
Should email address warnings be considered as errors? @return bool
isStrict
php
concretecms/concretecms
concrete/src/Validator/String/EmailValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/EmailValidator.php
MIT
public function setStrict($strict) { $this->strict = (bool) $strict; return $this; }
Should email address warnings be considered as errors? @param bool $strict @return $this
setStrict
php
concretecms/concretecms
concrete/src/Validator/String/EmailValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/EmailValidator.php
MIT
public function isValid($mixed, ?ArrayAccess $error = null) { if ($mixed !== null && !is_string($mixed)) { throw new InvalidArgumentException(t('Invalid type supplied to validator.')); } if (!filter_var($mixed, FILTER_VALIDATE_EMAIL) || $this->checkEmail($mixed) === false) { if ($error && $message = $this->getErrorString(self::E_INVALID_ADDRESS, $mixed)) { $error[] = $message; } return false; } return true; }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorInterface::isValid()
isValid
php
concretecms/concretecms
concrete/src/Validator/String/EmailValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/EmailValidator.php
MIT
protected function checkEmail($mixed) { $result = false; if (is_string($mixed) && $mixed !== '') { $eev = $this->getEguliasEmailValidator(); $testMX = $this->isTestMXRecord(); if ($eev->isValid($mixed, $testMX, $this->isStrict())) { if ($testMX) { $result = !in_array(EguliasEmailValidator::DNSWARN_NO_RECORD, $eev->getWarnings(), true); } else { $result = true; } } } return $result; }
Actually check if an email address is valid. @param string|mixed $mixed @return bool
checkEmail
php
concretecms/concretecms
concrete/src/Validator/String/EmailValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/EmailValidator.php
MIT
private function getEguliasEmailValidator() { if ($this->eguliasEmailValidator === null) { $this->eguliasEmailValidator = new EguliasEmailValidator(); } return $this->eguliasEmailValidator; }
Get the instance of Egulias\EmailValidator to be used. This is private because in future we may switch to another library. @return \Egulias\EmailValidator\EmailValidator
getEguliasEmailValidator
php
concretecms/concretecms
concrete/src/Validator/String/EmailValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/EmailValidator.php
MIT
public function getMaximumLength() { return $this->maximum_length; }
Get the maximum length allowed. @return int
getMaximumLength
php
concretecms/concretecms
concrete/src/Validator/String/MaximumLengthValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/MaximumLengthValidator.php
MIT
public function setMaximumLength($maximum_length) { $this->maximum_length = $maximum_length; }
Set the maximum length allowed. @param int $maximum_length
setMaximumLength
php
concretecms/concretecms
concrete/src/Validator/String/MaximumLengthValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/MaximumLengthValidator.php
MIT
public function isValid($mixed, ?ArrayAccess $error = null) { if ($mixed !== null && !is_string($mixed)) { throw new InvalidArgumentException(t('Invalid type supplied to validator.')); } if ($this->getMaximumLength() < strlen($mixed)) { if ($error && $message = $this->getErrorString(self::E_TOO_LONG, $mixed)) { $error[] = $message; } return false; } return true; }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorInterface::isValid()
isValid
php
concretecms/concretecms
concrete/src/Validator/String/MaximumLengthValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/MaximumLengthValidator.php
MIT
public function getMinimumLength() { return $this->minimum_length; }
Get the minimum length allowed. @return int
getMinimumLength
php
concretecms/concretecms
concrete/src/Validator/String/MinimumLengthValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/MinimumLengthValidator.php
MIT
public function setMinimumLength($minimum_length) { $this->minimum_length = $minimum_length; }
Set the minimum length allowed. @param int $minimum_length
setMinimumLength
php
concretecms/concretecms
concrete/src/Validator/String/MinimumLengthValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/MinimumLengthValidator.php
MIT
public function isValid($mixed, ?ArrayAccess $error = null) { if ($mixed !== null && !is_string($mixed)) { throw new InvalidArgumentException(t('Invalid type supplied to validator.')); } if ($this->getMinimumLength() > strlen($mixed)) { if ($error && $message = $this->getErrorString(self::E_TOO_SHORT, $mixed)) { $error[] = $message; } return false; } return true; }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorInterface::isValid()
isValid
php
concretecms/concretecms
concrete/src/Validator/String/MinimumLengthValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/MinimumLengthValidator.php
MIT
public function getPattern() { return $this->pattern; }
Get the regex pattern. @return string
getPattern
php
concretecms/concretecms
concrete/src/Validator/String/RegexValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/RegexValidator.php
MIT
public function setPattern($pattern) { $this->pattern = $pattern; }
Set the regex pattern. @param string $pattern
setPattern
php
concretecms/concretecms
concrete/src/Validator/String/RegexValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/RegexValidator.php
MIT
public function isValid($mixed, ?ArrayAccess $error = null) { if (!is_string($mixed)) { throw new InvalidArgumentException(t(/*i18n: %s is the name of a PHP class*/'%s only validates string length', __CLASS__)); } $result = @preg_match($this->getPattern(), $mixed); if ($result === false) { throw new RuntimeException(sprintf('Regex Error: %d', preg_last_error())); } if (!$result) { if ($error && $message = $this->getErrorString(self::E_DOES_NOT_MATCH, $mixed)) { $error[] = $message; } return false; } return true; }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorInterface::isValid() @throws \RuntimeException invalid regex pattern
isValid
php
concretecms/concretecms
concrete/src/Validator/String/RegexValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/RegexValidator.php
MIT
public function isValidFor($mixed, $subject = null, ?ArrayAccess $error = null) { $id = $this->resolveUserID($subject); // If no subject is provided then we have no data to check against if (!$id) { return true; } // Validate the provided mixed type if (!is_string($mixed)) { throw new \InvalidArgumentException(t('Invalid mixed value provided. Must be a string.')); } // If the password hasn't been used it's valid if (!$this->hasBeenUsed($mixed, $id)) { return true; } // If the password has recently been used, it's invalid if ($error) { $error->add($this->getErrorString(self::E_PASSWORD_RECENTLY_USED, $mixed)); } return false; }
Is this mixed value valid for the specified (optional) subject? @param mixed $mixed Can be any value, should be a string to be valid @param mixed|int $subject The user ID the mixed value needs to be valid for @param \ArrayAccess|null $error @throws \InvalidArgumentException throws a InvalidArgumentException when $mixed or $subject are not valid @return bool
isValidFor
php
concretecms/concretecms
concrete/src/Validator/String/ReuseValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/ReuseValidator.php
MIT
private function hasBeenUsed($string, $id) { $repository = $this->entityManager->getRepository(UsedString::class); $allUses = $repository->findBy(['subject' => $id], ['id' => 'desc'], $this->maxReuse); foreach ($allUses as $use) { if ($this->matches($string, $use)) { return true; } } return false; }
Check whether a string has been used against an id @param string $string @param int$id @return bool
hasBeenUsed
php
concretecms/concretecms
concrete/src/Validator/String/ReuseValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/ReuseValidator.php
MIT
private function matches($string, UsedString $usedString) { return password_verify($string, $usedString->getUsedString()); }
Verify whether an obfuscated password matches a tracked used password @param string $string @param UsedString $usedString @return bool
matches
php
concretecms/concretecms
concrete/src/Validator/String/ReuseValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/ReuseValidator.php
MIT
protected function getEntityManager() { return $this->entityManager; }
Protected accessor method for subclasses @return \Doctrine\ORM\EntityManagerInterface
getEntityManager
php
concretecms/concretecms
concrete/src/Validator/String/ReuseValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/ReuseValidator.php
MIT
protected function getMaxReuseCount() { return $this->maxReuse; }
Protected accessor method for subclasses @return int
getMaxReuseCount
php
concretecms/concretecms
concrete/src/Validator/String/ReuseValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/ReuseValidator.php
MIT
private function resolveUserID($subject) { // Handle `null`, `0`, and any other falsy subject if (!$subject) { return 0; } // If an integer is just passed in if (is_numeric($subject)) { return (int) $subject; } // If we get an actual user instance if ($subject instanceof User || $subject instanceof UserInfo || $subject instanceof EntityUser) { return $subject->getUserID(); } // Non-falsy subject that is unsupported throw new \InvalidArgumentException(t('Unsupported subject provided. Subject must be a User, UserInfo, or User Entity object.')); }
@param $subject @return int @throws \InvalidArgumentException
resolveUserID
php
concretecms/concretecms
concrete/src/Validator/String/ReuseValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/ReuseValidator.php
MIT
public function __construct(Connection $connection, $testMXRecord = false, $strict = false) { parent::__construct($testMXRecord, $strict); $this->connection = $connection; $this->setRequirementString( self::E_EMAIL_IN_USE, function (UniqueUserEmailValidator $validator, $code) { return t('An email address must be unique.'); } ); $this->setRequirementString( self::E_EMAIL_USED_BY_ANOTHER_USER, function (UniqueUserEmailValidator $validator, $code) { return t('An email address must be unique.'); } ); $this->setErrorString( self::E_EMAIL_IN_USE, function (UniqueUserEmailValidator $validator, $code, $mixed) { return t('The email address "%s" is already in use.', $mixed); } ); $this->setErrorString( self::E_EMAIL_USED_BY_ANOTHER_USER, function (UniqueUserEmailValidator $validator, $code, $mixed) { return t('The email address "%s" is already in use.', $mixed); } ); }
UniqueUserEmailValidator constructor. @param \Concrete\Core\Database\Connection\Connection $connection @param bool $testMXRecord Should we test the MX record to see if the domain is valid? @param bool $strict Should email address warnings be considered as errors?
__construct
php
concretecms/concretecms
concrete/src/Validator/String/UniqueUserEmailValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/UniqueUserEmailValidator.php
MIT
public function isValid($mixed, ?ArrayAccess $error = null) { return $this->isValidFor($mixed, null, $error); }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorInterface::isValid()
isValid
php
concretecms/concretecms
concrete/src/Validator/String/UniqueUserEmailValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/UniqueUserEmailValidator.php
MIT
public function isValidFor($mixed, $subject = null, ?ArrayAccess $error = null) { $result = parent::isValid($mixed, $error); if ($result === true) { $uID = 0; if ($subject) { if (is_object($subject)) { if (!method_exists($subject, 'getUserID')) { throw new InvalidArgumentException(t('Invalid subject type supplied to validator.')); } $uID = (int) $subject->getUserID(); } else { $uID = (int) $subject; } } else { $uID = 0; } $qb = $this->connection->createQueryBuilder(); $qb ->select('u.uID') ->from('Users', 'u') ->where($qb->expr()->eq('u.uEmail', $qb->createNamedParameter($mixed))) ; if ($uID !== 0) { $qb->andWhere($qb->expr()->neq('u.uID', $qb->createNamedParameter($uID))); } if ($qb->execute()->fetchColumn() !== false) { $result = false; if ($error) { $message = $this->getErrorString($uID === 0 ? self::E_EMAIL_IN_USE : self::E_EMAIL_USED_BY_ANOTHER_USER, $mixed); if ($message) { $error[] = $message; } } } } return $result; }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorForSubjectInterface::isValidFor()
isValidFor
php
concretecms/concretecms
concrete/src/Validator/String/UniqueUserEmailValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/UniqueUserEmailValidator.php
MIT
public function __construct(Connection $connection) { $this->connection = $connection; $this->setRequirementString( self::E_USERNAME_IN_USE, function (UniqueUserNameValidator $validator, $code) { return t('A username must be unique.'); } ); $this->setRequirementString( self::E_USERNAME_USED_BY_ANOTHER_USER, function (UniqueUserNameValidator $validator, $code) { return t('A username must be unique.'); } ); $this->setErrorString( self::E_USERNAME_IN_USE, function (UniqueUserNameValidator $validator, $code, $mixed) { return t('The username "%s" is already taken.', $mixed); } ); $this->setErrorString( self::E_USERNAME_USED_BY_ANOTHER_USER, function (UniqueUserNameValidator $validator, $code, $mixed) { return t('The username "%s" is already used by another user.', $mixed); } ); }
UniqueUserNameValidator constructor. @param \Concrete\Core\Database\Connection\Connection $connection
__construct
php
concretecms/concretecms
concrete/src/Validator/String/UniqueUserNameValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/UniqueUserNameValidator.php
MIT
public function isValid($mixed, ?ArrayAccess $error = null) { return $this->isValidFor($mixed, null, $error); }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorInterface::isValid()
isValid
php
concretecms/concretecms
concrete/src/Validator/String/UniqueUserNameValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/UniqueUserNameValidator.php
MIT
public function isValidFor($mixed, $subject = null, ?ArrayAccess $error = null) { if (!is_string($mixed)) { throw new InvalidArgumentException(t('Invalid type supplied to validator.')); } $uID = 0; if ($subject) { if (is_object($subject)) { if (!method_exists($subject, 'getUserID')) { throw new InvalidArgumentException(t('Invalid subject type supplied to validator.')); } $uID = (int) $subject->getUserID(); } else { $uID = (int) $subject; } } else { $uID = 0; } $qb = $this->connection->createQueryBuilder(); $qb ->select('u.uID') ->from('Users', 'u') ->where($qb->expr()->eq('u.uName', $qb->createNamedParameter($mixed))) ; if ($uID !== 0) { $qb->andWhere($qb->expr()->neq('u.uID', $qb->createNamedParameter($uID))); } if ($qb->execute()->fetchOne() !== false) { if ($error) { $message = $this->getErrorString($uID === 0 ? self::E_USERNAME_IN_USE : self::E_USERNAME_USED_BY_ANOTHER_USER, $mixed); if ($message) { $error[] = $message; } } return false; } return true; }
{@inheritdoc} @see \Concrete\Core\Validator\ValidatorForSubjectInterface::isValidFor() @param int|\Concrete\Core\User\User|\Concrete\Core\Entity\User\User|\Concrete\Core\User\UserInfo|null $subject
isValidFor
php
concretecms/concretecms
concrete/src/Validator/String/UniqueUserNameValidator.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Validator/String/UniqueUserNameValidator.php
MIT
public function __construct($mixed = false) { $this->constructView($mixed); }
@param mixed $mixed object to view
__construct
php
concretecms/concretecms
concrete/src/View/AbstractView.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/AbstractView.php
MIT
public function post($key, $defaultValue = null) { $r = Request::getInstance(); return $r->post($key, $defaultValue); }
Returns the value of the item in the POST array. @param $key
post
php
concretecms/concretecms
concrete/src/View/AbstractView.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/AbstractView.php
MIT
public static function url($action, $task = null) { $args = func_get_args(); return (string) call_user_func_array(array('URL', 'to'), $args); }
URL is a utility function that is used inside a view to setup urls w/tasks and parameters. @param string $action @param string $task @return string $url
url
php
concretecms/concretecms
concrete/src/View/AbstractView.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/AbstractView.php
MIT
public static function getInstance() { return View::getRequestInstance(); }
Get an instance of the View. Note: In versions before 8.5.0a3, this method may return 'false' if it's called after the page is rendered (for example in middleware). @return View
getInstance
php
concretecms/concretecms
concrete/src/View/AbstractView.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/AbstractView.php
MIT
public function getThemePath() { return $this->themeRelativePath; }
gets the relative theme path for use in templates. @return string $themePath
getThemePath
php
concretecms/concretecms
concrete/src/View/View.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/View.php
MIT
public function action($action) { $a = func_get_args(); $controllerPath = $this->controller->getControllerActionPath(); array_unshift($a, $controllerPath); $ret = call_user_func_array([$this, 'url'], $a); return $ret; }
A shortcut to posting back to the current page with a task and optional parameters. Only works in the context of. @param string $action @param string $task @return string $url
action
php
concretecms/concretecms
concrete/src/View/View.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/View.php
MIT
public function isEditingDisabled(): bool { return false; }
Fix https://github.com/concretecms/concretecms/issues/11283 @return bool
isEditingDisabled
php
concretecms/concretecms
concrete/src/View/View.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/View.php
MIT
protected function loadViewThemeObject() { $env = Environment::get(); $app = Facade::getFacadeApplication(); // Note: Making this ALWAYS override the $controller->setTheme() was making this really inflexible. // We need to be able to set site themes from dashboard pages for complex board rendering. So I'm only going // to go to the theme route collection if the theme isn't set explicitly in the controller. if (!$this->getThemeHandle()) { $tmpTheme = $app->make(ThemeRouteCollection::class) ->getThemeByRoute($this->getViewPath()); if (isset($tmpTheme[0])) { $this->themeHandle = $tmpTheme[0]; } } if ($this->themeHandle) { switch ($this->themeHandle) { case VIEW_CORE_THEME: $this->themeObject = new \Concrete\Theme\Concrete\PageTheme(); $this->themePkgHandle = false; break; case 'dashboard': $this->themeObject = new \Concrete\Theme\Dashboard\PageTheme(); $this->themePkgHandle = false; break; default: if (!isset($this->themeObject)) { $this->themeObject = PageTheme::getByHandle($this->themeHandle); $this->themePkgHandle = $this->themeObject->getPackageHandle(); } } $this->themeAbsolutePath = $env->getPath(DIRNAME_THEMES.'/'.$this->themeHandle, $this->themePkgHandle); $this->themeRelativePath = $env->getURL(DIRNAME_THEMES.'/'.$this->themeHandle, $this->themePkgHandle); if ($this->themeObject) { $this->handleRequiredFeatures($this->controller, $this->themeObject); } } }
Load all the theme-related variables for which theme to use for this request. May update the themeHandle property on the view based on themeByRoute settings.
loadViewThemeObject
php
concretecms/concretecms
concrete/src/View/View.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/View.php
MIT
protected function renderInnerContents($scopeItems) { // Extract the items into the current scope extract($scopeItems); ob_start(); include $this->innerContentFile; $innerContent = ob_get_contents(); ob_end_clean(); return $innerContent; }
Render the file set to $this->innerContentFile @param $scopeItems @return string
renderInnerContents
php
concretecms/concretecms
concrete/src/View/View.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/View.php
MIT
protected function renderTemplate($scopeItems, $innerContent) { // Extract the items into the current scope extract($scopeItems); ob_start(); // Fire a `before` event $this->onBeforeGetContents(); include $this->template; // Fire an `after` event $this->onAfterGetContents(); $contents = ob_get_contents(); ob_end_clean(); return $contents; }
Render the file set to $this->template @param $scopeItems @return string
renderTemplate
php
concretecms/concretecms
concrete/src/View/View.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/View.php
MIT
public function markHeaderAssetPosition() { echo '<!--ccm:assets:'.Asset::ASSET_POSITION_HEADER.'//-->'; }
Function responsible for outputting header items.
markHeaderAssetPosition
php
concretecms/concretecms
concrete/src/View/View.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/View.php
MIT
public function markFooterAssetPosition() { echo '<!--ccm:assets:'.Asset::ASSET_POSITION_FOOTER.'//-->'; }
Function responsible for outputting footer items.
markFooterAssetPosition
php
concretecms/concretecms
concrete/src/View/View.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/View/View.php
MIT
public function canApproveWorkflow() { $pk = Key::getByHandle('approve_basic_workflow_action'); $pk->setPermissionObject($this); return $pk->validate(); }
Returns true if the logged-in user can approve the current workflow.
canApproveWorkflow
php
concretecms/concretecms
concrete/src/Workflow/BasicWorkflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/BasicWorkflow.php
MIT
public function getWorkflowTypeID() { return $this->wftID; }
Get the ID of this workflow type. @return int
getWorkflowTypeID
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public function getWorkflowTypeHandle() { return $this->wftHandle; }
Get the handle of this workflow type. @return string
getWorkflowTypeHandle
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public function getWorkflowTypeName() { return $this->wftName; }
Get the name of this workflow type. @return string
getWorkflowTypeName
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public function getPackageID() { return $this->pkgID; }
Get the ID of the package that created this workflow type. @return int zero if no package defined this workflow type, the package ID otherwise
getPackageID
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public function getPackageHandle() { $pkgID = $this->getPackageID(); return $pkgID ? PackageList::getHandle($pkgID) : false; }
Get the handle of the package that created this workflow type. @return string|bool false if no package defined this workflow type, the package handle otherwise
getPackageHandle
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public function getWorkflows() { $workflows = []; $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $qb = $db->createQueryBuilder(); $qb ->select('wfID') ->from('Workflows') ->where($qb->expr()->eq('wftID', $this->getWorkflowTypeID())); $rows = $qb->execute()->fetchAll(); foreach ($rows as $row) { $workflow = Workflow::getByID($row['wfID']); if ($workflow !== null) { $workflows[] = $workflow; } } $cmp = new Comparer(); usort($workflows, function (Workflow $a, Workflow $b) use ($cmp) { return $cmp->compare($a->getWorkflowDisplayName('text'), $b->getWorkflowDisplayName('text')); }); return $workflows; }
Gets all workflows belonging to this type, sorted by their display name. @return \Concrete\Core\Workflow\Workflow[]
getWorkflows
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public function delete() { $workflows = $this->getWorkflows(); foreach ($workflows as $workflow) { $workflow->delete(); } $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $db->delete('WorkflowTypes', ['wftID' => $this->getWorkflowTypeID()]); }
Delete this workflow type and all workflows belonging to this type. @throws \Doctrine\DBAL\Exception\InvalidArgumentException
delete
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public static function add($wftHandle, $wftName, $pkg = false) { $pkgID = is_object($pkg) ? (int) $pkg->getPackageID() : 0; $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $db->insert( 'WorkflowTypes', [ 'wftHandle' => $wftHandle, 'wftName' => $wftName, 'pkgID' => $pkgID, ], [ PDO::PARAM_STR, PDO::PARAM_STR, PDO::PARAM_INT, ] ); $id = $db->lastInsertId(); return static::getByID($id); }
Add a new workflow type. @param string $wftHandle The handle of the new workflow type @param string $wftName The name of the new workflow type @param \Concrete\Core\Package\Package|\Concrete\Core\Entity\Package|null|bool $pkg the package that's creating the new workflow type @return \Concrete\Core\Workflow\Type
add
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public static function getByID($wftID) { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $qb = $db->createQueryBuilder(); $qb ->select('wftID, pkgID, wftHandle, wftName') ->from('WorkflowTypes') ->where($qb->expr()->eq('wftID', (int) $wftID)) ->setMaxResults(1) ; $row = $qb->execute()->fetch(); if (!$row) { return null; } $wt = new static(); $row['wftID'] = (int) $row['wftID']; $row['pkgID'] = (int) $row['pkgID']; $wt->setPropertiesFromArray($row); return $wt; }
Get a workflow type given its ID. @param int $wftID @return \Concrete\Core\Workflow\Type|null
getByID
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public static function getByHandle($wftHandle) { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $qb = $db->createQueryBuilder(); $qb ->select('wftID') ->from('WorkflowTypes') ->where($qb->expr()->eq('wftHandle', $qb->createNamedParameter((string) $wftHandle))) ->setMaxResults(1); $wftID = $qb->execute()->fetchColumn(); return $wftID ? self::getByID($wftID) : null; }
Gets a Workflow Type by handle. @param $wftHandle @return Type|null
getByHandle
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public static function getList() { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $qb = $db->createQueryBuilder(); $qb ->select('wftID') ->from('WorkflowTypes') ->orderBy('wftID', 'asc') ; $list = []; foreach ($qb->execute()->fetchAll() as $row) { $list[] = static::getByID($row['wftID']); } $cmp = new Comparer(); usort($list, function (Type $a, Type $b) use ($cmp) { return $cmp->compare($a->getWorkflowTypeName(), $b->getWorkflowTypeName()); }); return $list; }
Get the list of the currently installed workflow types, sorted by their name. @return \Concrete\Core\Workflow\Type[]
getList
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public static function getListByPackage($pkg) { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $qb = $db->createQueryBuilder(); $qb ->select('wftID') ->from('WorkflowTypes') ->where($qb->expr()->eq('pkgID', $pkg->getPackageID())) ; $list = []; foreach ($qb->execute()->fetchAll() as $row) { $list[] = static::getByID($row['wftID']); } $cmp = new Comparer(); usort($list, function (Type $a, Type $b) use ($cmp) { return $cmp->compare($a->getWorkflowTypeName(), $b->getWorkflowTypeName()); }); return $list; }
Get the list of the currently installed workflow types that were created by a package, sorted by their name. @param \Concrete\Core\Package\Package|\Concrete\Core\Entity\Package $pkg @return \Concrete\Core\Workflow\Type[]
getListByPackage
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public static function exportList($xml) { $wtypes = static::getList(); if (empty($wtypes)) { return; } $axml = $xml->addChild('workflowtypes'); foreach ($wtypes as $wt) { $wtype = $axml->addChild('workflowtype'); $wtype->addAttribute('handle', $wt->getWorkflowTypeHandle()); $wtype->addAttribute('name', $wt->getWorkflowTypeName()); $wtype->addAttribute('package', $wt->getPackageHandle() ?: ''); } }
Export the currently installed workflow types to XML. @param \SimpleXMLElement $xml
exportList
php
concretecms/concretecms
concrete/src/Workflow/Type.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Type.php
MIT
public function getWorkflowID() { return $this->wfID; }
Get the workflow ID. @return int
getWorkflowID
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function getWorkflowName() { return $this->wfName; }
Get the workflow (English) name. @return string
getWorkflowName
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function getWorkflowDisplayName($format = 'html') { $value = tc('WorkflowName', $this->getWorkflowName()); switch ($format) { case 'html': return h($value); case 'text': default: return $value; } }
Get the display name for this workflow (localized and escaped accordingly to $format). @param string $format = 'html' Escape the result in html format (if $format is 'html'). If $format is 'text' or any other value, the display name won't be escaped. @return string
getWorkflowDisplayName
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function getAllowedTasks() { return $this->allowedTasks; }
Get the list of allowed tasks. @return string[]
getAllowedTasks
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function getWorkflowTypeObject() { return empty($this->wftID) ? null : Type::getByID($this->wftID); }
Get the workflow type associated to this workflow. @return \Concrete\Core\Workflow\Type|null
getWorkflowTypeObject
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function getRestrictedToPermissionKeyHandles() { return $this->restrictedToPermissionKeyHandles; }
Get the list of permission key handles that this workflow can be attached to. @var string[]
getRestrictedToPermissionKeyHandles
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function getPermissionResponseClassName() { return '\\Concrete\\Core\\Permission\\Response\\Workflow'; }
{@inheritdoc} @see \Concrete\Core\Permission\ObjectInterface::getPermissionResponseClassName()
getPermissionResponseClassName
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function getPermissionAssignmentClassName() { return '\\Concrete\\Core\\Permission\\Assignment\\WorkflowAssignment'; }
{@inheritdoc} @see \Concrete\Core\Permission\ObjectInterface::getPermissionAssignmentClassName()
getPermissionAssignmentClassName
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function getPermissionObjectKeyCategoryHandle() { return 'basic_workflow'; }
{@inheritdoc} @see \Concrete\Core\Permission\ObjectInterface::getPermissionObjectKeyCategoryHandle()
getPermissionObjectKeyCategoryHandle
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function getPermissionObjectIdentifier() { return $this->getWorkflowID(); }
{@inheritdoc} @see \Concrete\Core\Permission\ObjectInterface::getPermissionObjectIdentifier()
getPermissionObjectIdentifier
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function delete() { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $rows = $db->fetchAll('select wpID from WorkflowProgress where wfID = ?', [$this->getWorkflowID()]); foreach ($rows as $row) { $wfp = WorkflowProgress::getByID($row['wpID']); if ($wfp) { $wfp->delete(); } } $db->delete('Workflows', ['wfID' => $this->getWorkflowID()]); }
Delete this workflow and all its associated progresses.
delete
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function getWorkflowProgressCurrentStatusNum(WorkflowProgress $wp) { $req = $wp->getWorkflowRequestObject(); if (is_object($req)) { return $req->getWorkflowRequestStatusNum(); } }
By default the basic workflow just passes the status num from the request we do this so that we can order things by most important, etc... @param \Concrete\Core\Workflow\Progress\Progress $wp @return int|null
getWorkflowProgressCurrentStatusNum
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public static function getList() { $workflows = []; $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $rows = $db->fetchAll('select wfID from Workflows'); foreach ($rows as $row) { $wf = static::getByID($row['wfID']); if ($wf) { $workflows[] = $wf; } } $cmp = new Comparer(); usort($workflows, function (Workflow $a, Workflow $b) use ($cmp) { return $cmp->compare($a->getWorkflowDisplayName('text'), $b->getWorkflowDisplayName('text')); }); return $workflows; }
Get the list of installed workflows, sorted by the workflow display name. @return \Concrete\Core\Workflow\Workflow[]
getList
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public static function getListByPackage(Package $pkg) { $workflows = []; $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $rows = $db->fetchAll('select wfID from Workflows where pkgID = ?', [$pkg->getPackageID()]); foreach ($rows as $row) { $wf = static::getByID($row['wfID']); if ($wf) { $workflows[] = $wf; } } $cmp = new Comparer(); usort($workflows, function (Workflow $a, Workflow $b) use ($cmp) { return $cmp->compare($a->getWorkflowDisplayName('text'), $b->getWorkflowDisplayName('text')); }); return $workflows; }
Get the list of workflows installed by a package, sorted by the workflow display name. @param \Concrete\Core\Entity\Package $pkg @return \Concrete\Core\Workflow\Workflow[]
getListByPackage
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public static function add(Type $wt, $name, ?Package $pkg = null) { $wf = static::getByName($name); if ($wf !== null) { return $wf; } $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $db->insert( 'Workflows', [ 'wftID' => $wt->getWorkflowTypeID(), 'wfName' => (string) $name, 'pkgID' => $pkg === null ? $wt->getPackageID() : $pkg->getPackageID(), ] ); $wfID = $db->lastInsertId(); return self::getByID($wfID); }
Create a new workflow. @param \Concrete\Core\Workflow\Type $wt The workflow type @param string $name the (English) name of the workflow @param \Concrete\Core\Entity\Package|null $pkg the package that's creating the new workflow @return \Concrete\Core\Workflow\Workflow
add
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public static function getByID($wfID) { $wfID = (int) $wfID; if ($wfID === 0) { return null; } $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $r = $db->fetchAssoc(<<<'EOT' select WorkflowTypes.wftHandle, WorkflowTypes.pkgID from Workflows inner join WorkflowTypes on Workflows.wftID = WorkflowTypes.wftID where Workflows.wfID = ? EOT , [$wfID] ); if (!$r) { return null; } $class = '\\Core\\Workflow\\' . camelcase($r['wftHandle']) . 'Workflow'; if ($r['pkgID']) { $pkg = $app->make(PackageService::class)->getByID($r['pkgID']); $prefix = $pkg->getPackageHandle(); } else { $prefix = null; } $class = core_class($class, $prefix); $obj = $app->make($class); /** @var \Concrete\Core\Workflow\Workflow $obj */ $obj->load($wfID); if (!$obj->getWorkflowID()) { return null; } $obj->loadDetails(); return $obj; }
Get a workflow given its ID. @param int $wfID the ID of the workflow @return \Concrete\Core\Workflow\Workflow|null
getByID
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public static function getByName($wfName) { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $wfID = $db->fetchColumn('SELECT wfID FROM Workflows WHERE wfName = ?', [(string) $wfName]); return $wfID ? static::getByID($wfID) : null; }
Get a workflow given its (English) name. @param string $wfName @return \Concrete\Core\Workflow\Workflow|null
getByName
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function updateName($wfName) { $wfName = (string) $wfName; $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $db->update( 'Workflows', [ 'wfName' => $wfName, ], [ 'wfID' => $this->getWorkflowID(), ] ); $this->wfName = $wfName; }
Change the (English) name of this workflow. @param string $wfName
updateName
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function validateTrigger(WorkflowRequest $req) { // Check if the current workflow request is not already deleted $wr = $req::getByID($req->getWorkflowRequestID()); return is_object($wr); }
Check if a workflow request is valid. @param \Concrete\Core\Workflow\Request\Request $req @return bool
validateTrigger
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
protected function load($wfID) { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $r = $db->fetchAssoc('select * from Workflows where wfID = ?', [(int) $wfID]); $r['wfID'] = (int) $r['wfID']; $r['wftID'] = (int) $r['wftID']; $r['pkgID'] = (int) $r['pkgID']; $this->setPropertiesFromArray($r); }
Load the workflow data from the database row. @param int $wfID
load
php
concretecms/concretecms
concrete/src/Workflow/Workflow.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Workflow.php
MIT
public function getWorkflowObject() { if ($this->wfID > 0) { $wf = Workflow::getByID($this->wfID); } else { $wf = new EmptyWorkflow(); } return $wf; }
Gets the Workflow object attached to this WorkflowProgress object. @return Workflow
getWorkflowObject
php
concretecms/concretecms
concrete/src/Workflow/Progress/Progress.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Progress/Progress.php
MIT
public function getWorkflowProgressResponseObject() { return $this->response; }
Gets an optional WorkflowResponse object. This is set in some cases.
getWorkflowProgressResponseObject
php
concretecms/concretecms
concrete/src/Workflow/Progress/Progress.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Progress/Progress.php
MIT
public function getWorkflowProgressDateLastAction() { return $this->wpDateLastAction; }
Gets the date of the last action.
getWorkflowProgressDateLastAction
php
concretecms/concretecms
concrete/src/Workflow/Progress/Progress.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Progress/Progress.php
MIT
public function getWorkflowProgressID() { return $this->wpID; }
Gets the ID of the progress object.
getWorkflowProgressID
php
concretecms/concretecms
concrete/src/Workflow/Progress/Progress.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Progress/Progress.php
MIT
public function getWorkflowProgressCategoryHandle() { return $this->wpCategoryHandle; }
Gets the ID of the progress object.
getWorkflowProgressCategoryHandle
php
concretecms/concretecms
concrete/src/Workflow/Progress/Progress.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Progress/Progress.php
MIT
public function getWorkflowProgressDateAdded() { return $this->wpDateAdded; }
Gets the date the WorkflowProgress object was added. @return datetime
getWorkflowProgressDateAdded
php
concretecms/concretecms
concrete/src/Workflow/Progress/Progress.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Progress/Progress.php
MIT
public function getWorkflowRequestObject() { if ($this->wrID > 0) { $cat = WorkflowProgressCategory::getByID($this->wpCategoryID); $handle = $cat->getWorkflowProgressCategoryHandle(); $class = '\\Core\\Workflow\\Request\\' . Core::make('helper/text')->camelcase($handle) . 'Request'; $pkHandle = $cat->getPackageHandle(); $class = core_class($class, $pkHandle); $wr = $class::getByID($this->wrID); if (is_object($wr)) { $wr->setCurrentWorkflowProgressObject($this); return $wr; } } }
Get the WorkflowRequest object for the current WorkflowProgress object. @return WorkflowRequest
getWorkflowRequestObject
php
concretecms/concretecms
concrete/src/Workflow/Progress/Progress.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Workflow/Progress/Progress.php
MIT