repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
romm/formz | Classes/ViewHelpers/FormViewHelper.php | FormViewHelper.getErrorText | protected function getErrorText(Result $result)
{
/** @var $view StandaloneView */
$view = Core::instantiate(StandaloneView::class);
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:' . ExtensionService::get()->getExtensionKey() . '/Resources/Private/Templates/Error/ConfigurationErrorBlock.html'));
$layoutRootPath = StringService::get()->getExtensionRelativePath('Resources/Private/Layouts');
$view->setLayoutRootPaths([$layoutRootPath]);
$view->assign('result', $result);
$templatePath = GeneralUtility::getFileAbsFileName('EXT:' . ExtensionService::get()->getExtensionKey() . '/Resources/Public/StyleSheets/Form.ErrorBlock.css');
$this->pageRenderer->addCssFile(StringService::get()->getResourceRelativePath($templatePath));
return $view->render();
} | php | protected function getErrorText(Result $result)
{
/** @var $view StandaloneView */
$view = Core::instantiate(StandaloneView::class);
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:' . ExtensionService::get()->getExtensionKey() . '/Resources/Private/Templates/Error/ConfigurationErrorBlock.html'));
$layoutRootPath = StringService::get()->getExtensionRelativePath('Resources/Private/Layouts');
$view->setLayoutRootPaths([$layoutRootPath]);
$view->assign('result', $result);
$templatePath = GeneralUtility::getFileAbsFileName('EXT:' . ExtensionService::get()->getExtensionKey() . '/Resources/Public/StyleSheets/Form.ErrorBlock.css');
$this->pageRenderer->addCssFile(StringService::get()->getResourceRelativePath($templatePath));
return $view->render();
} | [
"protected",
"function",
"getErrorText",
"(",
"Result",
"$",
"result",
")",
"{",
"/** @var $view StandaloneView */",
"$",
"view",
"=",
"Core",
"::",
"instantiate",
"(",
"StandaloneView",
"::",
"class",
")",
";",
"$",
"view",
"->",
"setTemplatePathAndFilename",
"("... | Will return an error text from a Fluid view.
@param Result $result
@return string | [
"Will",
"return",
"an",
"error",
"text",
"from",
"a",
"Fluid",
"view",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/FormViewHelper.php#L342-L355 | train |
romm/formz | Classes/ViewHelpers/FormViewHelper.php | FormViewHelper.getFormObjectArgument | protected function getFormObjectArgument()
{
$objectArgument = $this->arguments['object'];
if (null === $objectArgument) {
return null;
}
if (false === is_object($objectArgument)) {
throw InvalidOptionValueException::formViewHelperWrongFormValueType($objectArgument);
}
if (false === $objectArgument instanceof FormInterface) {
throw InvalidOptionValueException::formViewHelperWrongFormValueObjectType($objectArgument);
}
$formClassName = $this->getFormClassName();
if (false === $objectArgument instanceof $formClassName) {
throw InvalidOptionValueException::formViewHelperWrongFormValueClassName($formClassName, $objectArgument);
}
return $objectArgument;
} | php | protected function getFormObjectArgument()
{
$objectArgument = $this->arguments['object'];
if (null === $objectArgument) {
return null;
}
if (false === is_object($objectArgument)) {
throw InvalidOptionValueException::formViewHelperWrongFormValueType($objectArgument);
}
if (false === $objectArgument instanceof FormInterface) {
throw InvalidOptionValueException::formViewHelperWrongFormValueObjectType($objectArgument);
}
$formClassName = $this->getFormClassName();
if (false === $objectArgument instanceof $formClassName) {
throw InvalidOptionValueException::formViewHelperWrongFormValueClassName($formClassName, $objectArgument);
}
return $objectArgument;
} | [
"protected",
"function",
"getFormObjectArgument",
"(",
")",
"{",
"$",
"objectArgument",
"=",
"$",
"this",
"->",
"arguments",
"[",
"'object'",
"]",
";",
"if",
"(",
"null",
"===",
"$",
"objectArgument",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"fal... | Checks the type of the argument `object`, and returns it if everything is
ok.
@return FormInterface|null
@throws InvalidOptionValueException | [
"Checks",
"the",
"type",
"of",
"the",
"argument",
"object",
"and",
"returns",
"it",
"if",
"everything",
"is",
"ok",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/FormViewHelper.php#L364-L387 | train |
romm/formz | Classes/ViewHelpers/FormViewHelper.php | FormViewHelper.getFormClassNameFromControllerAction | protected function getFormClassNameFromControllerAction()
{
return $this->controllerService->getFormClassNameFromControllerAction(
$this->getControllerName(),
$this->getControllerActionName(),
$this->getFormObjectName()
);
} | php | protected function getFormClassNameFromControllerAction()
{
return $this->controllerService->getFormClassNameFromControllerAction(
$this->getControllerName(),
$this->getControllerActionName(),
$this->getFormObjectName()
);
} | [
"protected",
"function",
"getFormClassNameFromControllerAction",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"controllerService",
"->",
"getFormClassNameFromControllerAction",
"(",
"$",
"this",
"->",
"getControllerName",
"(",
")",
",",
"$",
"this",
"->",
"getControlle... | Will fetch the name of the controller action argument bound to this
request.
@return string
@throws EntryNotFoundException | [
"Will",
"fetch",
"the",
"name",
"of",
"the",
"controller",
"action",
"argument",
"bound",
"to",
"this",
"request",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/FormViewHelper.php#L425-L432 | train |
judev/php-htmltruncator | src/HtmlTruncator/Truncator.php | Truncator.truncate | public static function truncate($html, $length, $opts=array()) {
if (is_string($opts)) $opts = array('ellipsis' => $opts);
$opts = array_merge(static::$default_options, $opts);
// wrap the html in case it consists of adjacent nodes like <p>foo</p><p>bar</p>
$html = "<div>".static::utf8_for_xml($html)."</div>";
$root_node = null;
// Parse using HTML5Lib if it's available.
if (class_exists('HTML5Lib\\Parser')) {
try {
$doc = \HTML5Lib\Parser::parse($html);
$root_node = $doc->documentElement->lastChild->lastChild;
}
catch (\Exception $e) {
;
}
}
if ($root_node === null) {
// HTML5Lib not available so we'll have to use DOMDocument
// We'll only be able to parse HTML5 if it's valid XML
$doc = new DOMDocument;
$doc->formatOutput = false;
$doc->preserveWhitespace = true;
// loadHTML will fail with HTML5 tags (article, nav, etc)
// so we need to suppress errors and if it fails to parse we
// retry with the XML parser instead
$prev_use_errors = libxml_use_internal_errors(true);
if ($doc->loadHTML($html)) {
$root_node = $doc->documentElement->lastChild->lastChild;
}
else if ($doc->loadXML($html)) {
$root_node = $doc->documentElement;
}
else {
libxml_use_internal_errors($prev_use_errors);
throw new InvalidHtmlException;
}
libxml_use_internal_errors($prev_use_errors);
}
list($text, $_, $opts) = static::_truncate_node($doc, $root_node, $length, $opts);
$text = ht_substr(ht_substr($text, 0, -6), 5);
return $text;
} | php | public static function truncate($html, $length, $opts=array()) {
if (is_string($opts)) $opts = array('ellipsis' => $opts);
$opts = array_merge(static::$default_options, $opts);
// wrap the html in case it consists of adjacent nodes like <p>foo</p><p>bar</p>
$html = "<div>".static::utf8_for_xml($html)."</div>";
$root_node = null;
// Parse using HTML5Lib if it's available.
if (class_exists('HTML5Lib\\Parser')) {
try {
$doc = \HTML5Lib\Parser::parse($html);
$root_node = $doc->documentElement->lastChild->lastChild;
}
catch (\Exception $e) {
;
}
}
if ($root_node === null) {
// HTML5Lib not available so we'll have to use DOMDocument
// We'll only be able to parse HTML5 if it's valid XML
$doc = new DOMDocument;
$doc->formatOutput = false;
$doc->preserveWhitespace = true;
// loadHTML will fail with HTML5 tags (article, nav, etc)
// so we need to suppress errors and if it fails to parse we
// retry with the XML parser instead
$prev_use_errors = libxml_use_internal_errors(true);
if ($doc->loadHTML($html)) {
$root_node = $doc->documentElement->lastChild->lastChild;
}
else if ($doc->loadXML($html)) {
$root_node = $doc->documentElement;
}
else {
libxml_use_internal_errors($prev_use_errors);
throw new InvalidHtmlException;
}
libxml_use_internal_errors($prev_use_errors);
}
list($text, $_, $opts) = static::_truncate_node($doc, $root_node, $length, $opts);
$text = ht_substr(ht_substr($text, 0, -6), 5);
return $text;
} | [
"public",
"static",
"function",
"truncate",
"(",
"$",
"html",
",",
"$",
"length",
",",
"$",
"opts",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"opts",
")",
")",
"$",
"opts",
"=",
"array",
"(",
"'ellipsis'",
"=>",
"$",
"op... | Truncate given HTML string to specified length.
If length_in_chars is false it's trimmed by number
of words, otherwise by number of characters.
@param string $html
@param integer $length
@param string|array $opts
@return string | [
"Truncate",
"given",
"HTML",
"string",
"to",
"specified",
"length",
".",
"If",
"length_in_chars",
"is",
"false",
"it",
"s",
"trimmed",
"by",
"number",
"of",
"words",
"otherwise",
"by",
"number",
"of",
"characters",
"."
] | 2aeae94e5f42f6734c815d5e1d0753f51d2817cf | https://github.com/judev/php-htmltruncator/blob/2aeae94e5f42f6734c815d5e1d0753f51d2817cf/src/HtmlTruncator/Truncator.php#L63-L108 | train |
romm/formz | Classes/Service/ValidatorService.php | ValidatorService.getValidatorData | protected function getValidatorData($validatorClassName)
{
if (false === isset($this->validatorsData[$validatorClassName])) {
$this->validatorsData[$validatorClassName] = [];
if (in_array(AbstractValidator::class, class_parents($validatorClassName))) {
$validatorReflection = new \ReflectionClass($validatorClassName);
$validatorProperties = $validatorReflection->getDefaultProperties();
unset($validatorReflection);
$validatorData = [
'supportedOptions' => $validatorProperties['supportedOptions'],
'acceptsEmptyValues' => $validatorProperties['acceptsEmptyValues']
];
if (in_array(FormzAbstractValidator::class, class_parents($validatorClassName))) {
$validatorData['formzValidator'] = true;
$validatorData['supportedMessages'] = $validatorProperties['supportedMessages'];
$validatorData['supportsAllMessages'] = $validatorProperties['supportsAllMessages'];
}
$this->validatorsData[$validatorClassName] = $validatorData;
}
}
return $this->validatorsData[$validatorClassName];
} | php | protected function getValidatorData($validatorClassName)
{
if (false === isset($this->validatorsData[$validatorClassName])) {
$this->validatorsData[$validatorClassName] = [];
if (in_array(AbstractValidator::class, class_parents($validatorClassName))) {
$validatorReflection = new \ReflectionClass($validatorClassName);
$validatorProperties = $validatorReflection->getDefaultProperties();
unset($validatorReflection);
$validatorData = [
'supportedOptions' => $validatorProperties['supportedOptions'],
'acceptsEmptyValues' => $validatorProperties['acceptsEmptyValues']
];
if (in_array(FormzAbstractValidator::class, class_parents($validatorClassName))) {
$validatorData['formzValidator'] = true;
$validatorData['supportedMessages'] = $validatorProperties['supportedMessages'];
$validatorData['supportsAllMessages'] = $validatorProperties['supportsAllMessages'];
}
$this->validatorsData[$validatorClassName] = $validatorData;
}
}
return $this->validatorsData[$validatorClassName];
} | [
"protected",
"function",
"getValidatorData",
"(",
"$",
"validatorClassName",
")",
"{",
"if",
"(",
"false",
"===",
"isset",
"(",
"$",
"this",
"->",
"validatorsData",
"[",
"$",
"validatorClassName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"validatorsData",
"[",... | Will clone the data of the given validator class name. Please note that
it will use reflection to get the default value of the class properties.
@param $validatorClassName
@return array | [
"Will",
"clone",
"the",
"data",
"of",
"the",
"given",
"validator",
"class",
"name",
".",
"Please",
"note",
"that",
"it",
"will",
"use",
"reflection",
"to",
"get",
"the",
"default",
"value",
"of",
"the",
"class",
"properties",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Service/ValidatorService.php#L72-L98 | train |
compwright/codeigniter-installers | src/Composer/Installer/CodeigniterInstaller.php | CodeigniterInstaller.moveCoreFiles | protected function moveCoreFiles($downloadPath, $wildcard = '*.php')
{
$dir = realpath($downloadPath);
$dst = dirname($dir);
// Move the files up one level
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
shell_exec("move /Y $dir/$wildcard $dst/");
}
else
{
shell_exec("mv -f $dir/$wildcard $dst/");
}
// If there are no PHP files left in the package dir, remove the directory
if (count(glob("$dir/*.php")) === 0)
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
shell_exec("rd /S /Q $dir");
}
else
{
shell_exec("rm -Rf $dir");
}
}
} | php | protected function moveCoreFiles($downloadPath, $wildcard = '*.php')
{
$dir = realpath($downloadPath);
$dst = dirname($dir);
// Move the files up one level
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
shell_exec("move /Y $dir/$wildcard $dst/");
}
else
{
shell_exec("mv -f $dir/$wildcard $dst/");
}
// If there are no PHP files left in the package dir, remove the directory
if (count(glob("$dir/*.php")) === 0)
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
shell_exec("rd /S /Q $dir");
}
else
{
shell_exec("rm -Rf $dir");
}
}
} | [
"protected",
"function",
"moveCoreFiles",
"(",
"$",
"downloadPath",
",",
"$",
"wildcard",
"=",
"'*.php'",
")",
"{",
"$",
"dir",
"=",
"realpath",
"(",
"$",
"downloadPath",
")",
";",
"$",
"dst",
"=",
"dirname",
"(",
"$",
"dir",
")",
";",
"// Move the files... | Move files out of the package directory up one level
@var $downloadPath
@var $wildcard = '*.php' | [
"Move",
"files",
"out",
"of",
"the",
"package",
"directory",
"up",
"one",
"level"
] | adbbd5ae2cbf5a24a39931235b1ac7dab56abb4f | https://github.com/compwright/codeigniter-installers/blob/adbbd5ae2cbf5a24a39931235b1ac7dab56abb4f/src/Composer/Installer/CodeigniterInstaller.php#L189-L216 | train |
romm/formz | Classes/AssetHandler/Html/DataAttributesAssetHandler.php | DataAttributesAssetHandler.getFieldsValuesDataAttributes | public function getFieldsValuesDataAttributes(FormResult $formResult)
{
$result = [];
$formObject = $this->getFormObject();
$formInstance = $formObject->getForm();
foreach ($formObject->getConfiguration()->getFields() as $field) {
$fieldName = $field->getName();
if (false === $formResult->fieldIsDeactivated($field)) {
$value = ObjectAccess::getProperty($formInstance, $fieldName);
$value = (is_array($value))
? implode(' ', $value)
: $value;
if (false === empty($value)) {
$result[self::getFieldDataValueKey($fieldName)] = $value;
}
}
}
return $result;
} | php | public function getFieldsValuesDataAttributes(FormResult $formResult)
{
$result = [];
$formObject = $this->getFormObject();
$formInstance = $formObject->getForm();
foreach ($formObject->getConfiguration()->getFields() as $field) {
$fieldName = $field->getName();
if (false === $formResult->fieldIsDeactivated($field)) {
$value = ObjectAccess::getProperty($formInstance, $fieldName);
$value = (is_array($value))
? implode(' ', $value)
: $value;
if (false === empty($value)) {
$result[self::getFieldDataValueKey($fieldName)] = $value;
}
}
}
return $result;
} | [
"public",
"function",
"getFieldsValuesDataAttributes",
"(",
"FormResult",
"$",
"formResult",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"formObject",
"=",
"$",
"this",
"->",
"getFormObject",
"(",
")",
";",
"$",
"formInstance",
"=",
"$",
"formObject",
... | Handles the data attributes containing the values of the form fields.
Example: `fz-value-color="blue"`
@param FormResult $formResult
@return array | [
"Handles",
"the",
"data",
"attributes",
"containing",
"the",
"values",
"of",
"the",
"form",
"fields",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/AssetHandler/Html/DataAttributesAssetHandler.php#L49-L71 | train |
romm/formz | Classes/AssetHandler/Html/DataAttributesAssetHandler.php | DataAttributesAssetHandler.getFieldsMessagesDataAttributes | public function getFieldsMessagesDataAttributes()
{
$result = [];
$formConfiguration = $this->getFormObject()->getConfiguration();
$formResult = $this->getFormObject()->getFormResult();
foreach ($formResult->getSubResults() as $fieldName => $fieldResult) {
if (true === $formConfiguration->hasField($fieldName)
&& false === $formResult->fieldIsDeactivated($formConfiguration->getField($fieldName))
) {
$result += $this->getFieldErrorMessages($fieldName, $fieldResult);
$result += $this->getFieldWarningMessages($fieldName, $fieldResult);
$result += $this->getFieldNoticeMessages($fieldName, $fieldResult);
}
}
return $result;
} | php | public function getFieldsMessagesDataAttributes()
{
$result = [];
$formConfiguration = $this->getFormObject()->getConfiguration();
$formResult = $this->getFormObject()->getFormResult();
foreach ($formResult->getSubResults() as $fieldName => $fieldResult) {
if (true === $formConfiguration->hasField($fieldName)
&& false === $formResult->fieldIsDeactivated($formConfiguration->getField($fieldName))
) {
$result += $this->getFieldErrorMessages($fieldName, $fieldResult);
$result += $this->getFieldWarningMessages($fieldName, $fieldResult);
$result += $this->getFieldNoticeMessages($fieldName, $fieldResult);
}
}
return $result;
} | [
"public",
"function",
"getFieldsMessagesDataAttributes",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"formConfiguration",
"=",
"$",
"this",
"->",
"getFormObject",
"(",
")",
"->",
"getConfiguration",
"(",
")",
";",
"$",
"formResult",
"=",
"$",
"t... | Handles the data attributes for the fields which got errors, warnings and
notices.
Examples:
- `fz-error-email="1"`
- `fz-error-email-rule-default="1"`
@return array | [
"Handles",
"the",
"data",
"attributes",
"for",
"the",
"fields",
"which",
"got",
"errors",
"warnings",
"and",
"notices",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/AssetHandler/Html/DataAttributesAssetHandler.php#L83-L100 | train |
romm/formz | Classes/AssetHandler/Html/DataAttributesAssetHandler.php | DataAttributesAssetHandler.getFieldsValidDataAttributes | public function getFieldsValidDataAttributes()
{
$result = [];
$formConfiguration = $this->getFormObject()->getConfiguration();
$formResult = $this->getFormObject()->getFormResult();
foreach ($formConfiguration->getFields() as $field) {
$fieldName = $field->getName();
if (false === $formResult->fieldIsDeactivated($field)
&& false === $formResult->forProperty($fieldName)->hasErrors()
) {
$result[self::getFieldDataValidKey($fieldName)] = '1';
}
}
return $result;
} | php | public function getFieldsValidDataAttributes()
{
$result = [];
$formConfiguration = $this->getFormObject()->getConfiguration();
$formResult = $this->getFormObject()->getFormResult();
foreach ($formConfiguration->getFields() as $field) {
$fieldName = $field->getName();
if (false === $formResult->fieldIsDeactivated($field)
&& false === $formResult->forProperty($fieldName)->hasErrors()
) {
$result[self::getFieldDataValidKey($fieldName)] = '1';
}
}
return $result;
} | [
"public",
"function",
"getFieldsValidDataAttributes",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"formConfiguration",
"=",
"$",
"this",
"->",
"getFormObject",
"(",
")",
"->",
"getConfiguration",
"(",
")",
";",
"$",
"formResult",
"=",
"$",
"this... | Handles the data attributes for the fields which are valid.
Example: `fz-valid-email="1"`
@return array | [
"Handles",
"the",
"data",
"attributes",
"for",
"the",
"fields",
"which",
"are",
"valid",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/AssetHandler/Html/DataAttributesAssetHandler.php#L165-L182 | train |
romm/formz | Classes/AssetHandler/Html/DataAttributesAssetHandler.php | DataAttributesAssetHandler.getFieldDataValidationMessageKey | public static function getFieldDataValidationMessageKey($fieldName, $type, $validationName, $messageKey)
{
$stringService = StringService::get();
return vsprintf(
'fz-%s-%s-%s-%s',
[
$type,
$stringService->sanitizeString($fieldName),
$stringService->sanitizeString($validationName),
$stringService->sanitizeString($messageKey)
]
);
} | php | public static function getFieldDataValidationMessageKey($fieldName, $type, $validationName, $messageKey)
{
$stringService = StringService::get();
return vsprintf(
'fz-%s-%s-%s-%s',
[
$type,
$stringService->sanitizeString($fieldName),
$stringService->sanitizeString($validationName),
$stringService->sanitizeString($messageKey)
]
);
} | [
"public",
"static",
"function",
"getFieldDataValidationMessageKey",
"(",
"$",
"fieldName",
",",
"$",
"type",
",",
"$",
"validationName",
",",
"$",
"messageKey",
")",
"{",
"$",
"stringService",
"=",
"StringService",
"::",
"get",
"(",
")",
";",
"return",
"vsprin... | Formats the data message attribute key for a given failed validation for
the given field name.
@param string $fieldName
@param string $type Type of the message: `error`, `warning` or `notice`.
@param string $validationName
@param string $messageKey
@return string | [
"Formats",
"the",
"data",
"message",
"attribute",
"key",
"for",
"a",
"given",
"failed",
"validation",
"for",
"the",
"given",
"field",
"name",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/AssetHandler/Html/DataAttributesAssetHandler.php#L236-L249 | train |
QuickenLoans/mcp-panthor | src/HTTPProblem/HTTPProblem.php | HTTPProblem.title | public function title()
{
if (in_array($this->type(), [null, 'about:blank'], true)) {
return $this->determineStatusPhrase($this->status());
}
return $this->title;
} | php | public function title()
{
if (in_array($this->type(), [null, 'about:blank'], true)) {
return $this->determineStatusPhrase($this->status());
}
return $this->title;
} | [
"public",
"function",
"title",
"(",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"type",
"(",
")",
",",
"[",
"null",
",",
"'about:blank'",
"]",
",",
"true",
")",
")",
"{",
"return",
"$",
"this",
"->",
"determineStatusPhrase",
"(",
"$",
... | A short, human-readable summary of the problem type.
When type "about:blank" is used, title should be the HTTP status phrase for that code.
@return string|null | [
"A",
"short",
"human",
"-",
"readable",
"summary",
"of",
"the",
"problem",
"type",
"."
] | b73e22d83d21b8ed4296bee6aebc66c8b07f292c | https://github.com/QuickenLoans/mcp-panthor/blob/b73e22d83d21b8ed4296bee6aebc66c8b07f292c/src/HTTPProblem/HTTPProblem.php#L169-L176 | train |
alexandresalome/PHP-Selenium | src/Selenium/Specification/Loader/XmlLoader.php | XmlLoader.load | public function load($file)
{
if (!file_exists($file)) {
throw new \RuntimeException(sprintf('The file "%s" does not exists', $file));
}
$content = file_get_contents($file);
// HACK: DOMNode seems to bug when a node is named "param"
$content = str_replace('<param', '<parameter', $content);
$content = str_replace('</param', '</parameter', $content);
$crawler = new Crawler();
$crawler->addContent($content, 'xml');
foreach ($crawler->filterXPath('//function') as $node) {
$method = $this->getMethod($node);
$this->specification->addMethod($method);
}
} | php | public function load($file)
{
if (!file_exists($file)) {
throw new \RuntimeException(sprintf('The file "%s" does not exists', $file));
}
$content = file_get_contents($file);
// HACK: DOMNode seems to bug when a node is named "param"
$content = str_replace('<param', '<parameter', $content);
$content = str_replace('</param', '</parameter', $content);
$crawler = new Crawler();
$crawler->addContent($content, 'xml');
foreach ($crawler->filterXPath('//function') as $node) {
$method = $this->getMethod($node);
$this->specification->addMethod($method);
}
} | [
"public",
"function",
"load",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'The file \"%s\" does not exists'",
",",
"$",
"file",
")",
")",
";",... | Loads the specification from a XML file
@param string $file Path to the file to load | [
"Loads",
"the",
"specification",
"from",
"a",
"XML",
"file"
] | f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6 | https://github.com/alexandresalome/PHP-Selenium/blob/f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6/src/Selenium/Specification/Loader/XmlLoader.php#L39-L58 | train |
alexandresalome/PHP-Selenium | src/Selenium/Specification/Loader/XmlLoader.php | XmlLoader.getMethod | public function getMethod(\DOMNode $node)
{
$crawler = new Crawler($node);
$name = $crawler->attr('name');
// Initialize
$method = new Method($name);
// Type
$method->setType(
preg_match('/(^(get|is)|ToString$)/', $name) ?
Method::TYPE_ACCESSOR :
Method::TYPE_ACTION
);
// Description
$descriptions = $crawler->filterXPath('//comment');
if (count($descriptions) !== 1) {
throw new \Exception('Only one comment expected');
}
$descriptions->rewind();
$description = $this->getInner($descriptions->current());
$method->setDescription($description);
// Parameters
foreach ($crawler->filterXPath('//parameter') as $node) {
$method->addParameter($this->getParameter($node));
}
// Return
$returnNodes = $crawler->filterXPath('//return');
if (count($returnNodes) > 1) {
throw new \Exception("Should not be more than one return node");
} elseif (count($returnNodes) == 1) {
$returnNodes->rewind();
list($type, $description) = $this->getReturn($returnNodes->current());
$method->setReturnType($type);
$method->setReturnDescription($description);
}
return $method;
} | php | public function getMethod(\DOMNode $node)
{
$crawler = new Crawler($node);
$name = $crawler->attr('name');
// Initialize
$method = new Method($name);
// Type
$method->setType(
preg_match('/(^(get|is)|ToString$)/', $name) ?
Method::TYPE_ACCESSOR :
Method::TYPE_ACTION
);
// Description
$descriptions = $crawler->filterXPath('//comment');
if (count($descriptions) !== 1) {
throw new \Exception('Only one comment expected');
}
$descriptions->rewind();
$description = $this->getInner($descriptions->current());
$method->setDescription($description);
// Parameters
foreach ($crawler->filterXPath('//parameter') as $node) {
$method->addParameter($this->getParameter($node));
}
// Return
$returnNodes = $crawler->filterXPath('//return');
if (count($returnNodes) > 1) {
throw new \Exception("Should not be more than one return node");
} elseif (count($returnNodes) == 1) {
$returnNodes->rewind();
list($type, $description) = $this->getReturn($returnNodes->current());
$method->setReturnType($type);
$method->setReturnDescription($description);
}
return $method;
} | [
"public",
"function",
"getMethod",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"$",
"crawler",
"=",
"new",
"Crawler",
"(",
"$",
"node",
")",
";",
"$",
"name",
"=",
"$",
"crawler",
"->",
"attr",
"(",
"'name'",
")",
";",
"// Initialize",
"$",
"method"... | Returns a method in the current specification from a DOMNode
@param \DOMNode $node A DOMNode
@return Method | [
"Returns",
"a",
"method",
"in",
"the",
"current",
"specification",
"from",
"a",
"DOMNode"
] | f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6 | https://github.com/alexandresalome/PHP-Selenium/blob/f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6/src/Selenium/Specification/Loader/XmlLoader.php#L67-L110 | train |
alexandresalome/PHP-Selenium | src/Selenium/Specification/Loader/XmlLoader.php | XmlLoader.getParameter | protected function getParameter(\DOMNode $node)
{
$name = $node->getAttribute('name');
$parameter = new Parameter($name);
$parameter->setDescription($this->getInner($node));
return $parameter;
} | php | protected function getParameter(\DOMNode $node)
{
$name = $node->getAttribute('name');
$parameter = new Parameter($name);
$parameter->setDescription($this->getInner($node));
return $parameter;
} | [
"protected",
"function",
"getParameter",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"$",
"name",
"=",
"$",
"node",
"->",
"getAttribute",
"(",
"'name'",
")",
";",
"$",
"parameter",
"=",
"new",
"Parameter",
"(",
"$",
"name",
")",
";",
"$",
"parameter",... | Get a parameter model object from a DOMNode
@param \DOMNode $node A DOMNode to convert to specification parameter
@return Parameter The parameter model object | [
"Get",
"a",
"parameter",
"model",
"object",
"from",
"a",
"DOMNode"
] | f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6 | https://github.com/alexandresalome/PHP-Selenium/blob/f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6/src/Selenium/Specification/Loader/XmlLoader.php#L136-L144 | train |
alexandresalome/PHP-Selenium | src/Selenium/Specification/Loader/XmlLoader.php | XmlLoader.getInner | protected function getInner(\DOMNode $node)
{
$c14n = $node->C14N();
$begin = strpos($c14n, '>');
$end = strrpos($c14n, '<');
$content = substr($c14n, $begin + 1, $end - $begin - 1);
return $content;
} | php | protected function getInner(\DOMNode $node)
{
$c14n = $node->C14N();
$begin = strpos($c14n, '>');
$end = strrpos($c14n, '<');
$content = substr($c14n, $begin + 1, $end - $begin - 1);
return $content;
} | [
"protected",
"function",
"getInner",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"$",
"c14n",
"=",
"$",
"node",
"->",
"C14N",
"(",
")",
";",
"$",
"begin",
"=",
"strpos",
"(",
"$",
"c14n",
",",
"'>'",
")",
";",
"$",
"end",
"=",
"strrpos",
"(",
... | Get the inner content of a DOMNode.
@param \DOMNode $node A DOMNode instance
@return string The inner content | [
"Get",
"the",
"inner",
"content",
"of",
"a",
"DOMNode",
"."
] | f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6 | https://github.com/alexandresalome/PHP-Selenium/blob/f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6/src/Selenium/Specification/Loader/XmlLoader.php#L153-L162 | train |
QoboLtd/cakephp-utils | src/Model/Behavior/EncryptedFieldsBehavior.php | EncryptedFieldsBehavior.beforeSave | public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options): void
{
$entity = $this->encryptEntity($entity);
} | php | public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options): void
{
$entity = $this->encryptEntity($entity);
} | [
"public",
"function",
"beforeSave",
"(",
"Event",
"$",
"event",
",",
"EntityInterface",
"$",
"entity",
",",
"ArrayObject",
"$",
"options",
")",
":",
"void",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"encryptEntity",
"(",
"$",
"entity",
")",
";",
"}"
] | `Modele.beforeSave` callback which runs the entity encryption.
@param \Cake\Event\Event $event The beforeDelete event that was fired.
@param \Cake\Datasource\EntityInterface $entity The entity to be deleted.
@param \ArrayObject $options Options.
@return void | [
"Modele",
".",
"beforeSave",
"callback",
"which",
"runs",
"the",
"entity",
"encryption",
"."
] | 4b07a3e6f2e611e7c6909c913e6166d280f3c751 | https://github.com/QoboLtd/cakephp-utils/blob/4b07a3e6f2e611e7c6909c913e6166d280f3c751/src/Model/Behavior/EncryptedFieldsBehavior.php#L134-L137 | train |
QoboLtd/cakephp-utils | src/Model/Behavior/EncryptedFieldsBehavior.php | EncryptedFieldsBehavior.encryptEntity | public function encryptEntity(EntityInterface $entity): EntityInterface
{
if (!$this->isEncryptable($entity)) {
return $entity;
}
$fields = $this->getFields();
$encryptionKey = $this->getConfig('encryptionKey');
$base64 = $this->getConfig('base64');
$table = $this->getTable();
$patch = [];
foreach ($fields as $name => $field) {
if (!$table->hasField($name)) {
continue;
}
$value = $entity->get($name);
if ($value === null || is_resource($value)) {
continue;
}
$encrypted = Security::encrypt($value, $encryptionKey);
if ($base64 === true) {
$encrypted = base64_encode($encrypted);
}
$patch[$name] = $encrypted;
}
if (!empty($patch)) {
$accessible = array_fill_keys(array_keys($patch), true);
$entity = $table->patchEntity($entity, $patch, [
'accessibleFields' => $accessible,
]);
}
return $entity;
} | php | public function encryptEntity(EntityInterface $entity): EntityInterface
{
if (!$this->isEncryptable($entity)) {
return $entity;
}
$fields = $this->getFields();
$encryptionKey = $this->getConfig('encryptionKey');
$base64 = $this->getConfig('base64');
$table = $this->getTable();
$patch = [];
foreach ($fields as $name => $field) {
if (!$table->hasField($name)) {
continue;
}
$value = $entity->get($name);
if ($value === null || is_resource($value)) {
continue;
}
$encrypted = Security::encrypt($value, $encryptionKey);
if ($base64 === true) {
$encrypted = base64_encode($encrypted);
}
$patch[$name] = $encrypted;
}
if (!empty($patch)) {
$accessible = array_fill_keys(array_keys($patch), true);
$entity = $table->patchEntity($entity, $patch, [
'accessibleFields' => $accessible,
]);
}
return $entity;
} | [
"public",
"function",
"encryptEntity",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"EntityInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEncryptable",
"(",
"$",
"entity",
")",
")",
"{",
"return",
"$",
"entity",
";",
"}",
"$",
"fields",
"=",
... | Encrypts the fields.
If the value of the fields is null or a resource the encryption process
is skipped for this field.
@param \Cake\Datasource\EntityInterface $entity Entity object.
@return \Cake\Datasource\EntityInterface Entity object. | [
"Encrypts",
"the",
"fields",
"."
] | 4b07a3e6f2e611e7c6909c913e6166d280f3c751 | https://github.com/QoboLtd/cakephp-utils/blob/4b07a3e6f2e611e7c6909c913e6166d280f3c751/src/Model/Behavior/EncryptedFieldsBehavior.php#L148-L183 | train |
QoboLtd/cakephp-utils | src/Model/Behavior/EncryptedFieldsBehavior.php | EncryptedFieldsBehavior.isEncryptable | public function isEncryptable(EntityInterface $entity): bool
{
$enabled = $this->getConfig('enabled');
if (is_callable($enabled)) {
$enabled = $enabled($entity);
if (!is_bool($enabled)) {
throw new RuntimeException('Condition callable must return a boolean.');
}
}
return $enabled;
} | php | public function isEncryptable(EntityInterface $entity): bool
{
$enabled = $this->getConfig('enabled');
if (is_callable($enabled)) {
$enabled = $enabled($entity);
if (!is_bool($enabled)) {
throw new RuntimeException('Condition callable must return a boolean.');
}
}
return $enabled;
} | [
"public",
"function",
"isEncryptable",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"bool",
"{",
"$",
"enabled",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'enabled'",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"enabled",
")",
")",
"{",
"$",
"en... | Checks whether the given entity can be encrypted.
@param \Cake\Datasource\EntityInterface $entity Entity object.
@throws \RuntimeException When `condition` callable returns a non-boolean value.
@return bool True if encryption is allowed | [
"Checks",
"whether",
"the",
"given",
"entity",
"can",
"be",
"encrypted",
"."
] | 4b07a3e6f2e611e7c6909c913e6166d280f3c751 | https://github.com/QoboLtd/cakephp-utils/blob/4b07a3e6f2e611e7c6909c913e6166d280f3c751/src/Model/Behavior/EncryptedFieldsBehavior.php#L192-L203 | train |
QoboLtd/cakephp-utils | src/Model/Behavior/EncryptedFieldsBehavior.php | EncryptedFieldsBehavior.decryptEntity | public function decryptEntity(EntityInterface $entity, array $fields): EntityInterface
{
if (!$this->isEncryptable($entity)) {
return $entity;
}
foreach ($fields as $field) {
$value = $this->decryptEntityField($entity, $field);
if ($value !== null) {
$entity->set([$field => $value], ['guard' => false]);
$entity->setDirty($field, false);
}
}
return $entity;
} | php | public function decryptEntity(EntityInterface $entity, array $fields): EntityInterface
{
if (!$this->isEncryptable($entity)) {
return $entity;
}
foreach ($fields as $field) {
$value = $this->decryptEntityField($entity, $field);
if ($value !== null) {
$entity->set([$field => $value], ['guard' => false]);
$entity->setDirty($field, false);
}
}
return $entity;
} | [
"public",
"function",
"decryptEntity",
"(",
"EntityInterface",
"$",
"entity",
",",
"array",
"$",
"fields",
")",
":",
"EntityInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEncryptable",
"(",
"$",
"entity",
")",
")",
"{",
"return",
"$",
"entity",
"... | Decrypts entity fields and runs the conditions check to determine whether
the given entity can be decrypted.
@param \Cake\Datasource\EntityInterface $entity Entity object.
@param string[] $fields Fields to decrypt.
@return \Cake\Datasource\EntityInterface Entity object. | [
"Decrypts",
"entity",
"fields",
"and",
"runs",
"the",
"conditions",
"check",
"to",
"determine",
"whether",
"the",
"given",
"entity",
"can",
"be",
"decrypted",
"."
] | 4b07a3e6f2e611e7c6909c913e6166d280f3c751 | https://github.com/QoboLtd/cakephp-utils/blob/4b07a3e6f2e611e7c6909c913e6166d280f3c751/src/Model/Behavior/EncryptedFieldsBehavior.php#L213-L228 | train |
QoboLtd/cakephp-utils | src/Model/Behavior/EncryptedFieldsBehavior.php | EncryptedFieldsBehavior.decryptEntityField | public function decryptEntityField(EntityInterface $entity, string $field)
{
if (!$this->canDecryptField($entity, $field)) {
return null;
}
$encryptionKey = $this->getConfig('encryptionKey');
$base64 = $this->getConfig('base64');
$encoded = $entity->get($field);
if (empty($encoded) || $encoded === false) {
return null;
}
if ($base64 === true) {
$encoded = base64_decode($encoded, true);
if ($encoded === false) {
return null;
}
}
$decrypted = Security::decrypt($encoded, $encryptionKey);
if ($decrypted === false) {
throw new RuntimeException("Unable to decypher `{$field}`. Check your enryption key.");
}
return $decrypted;
} | php | public function decryptEntityField(EntityInterface $entity, string $field)
{
if (!$this->canDecryptField($entity, $field)) {
return null;
}
$encryptionKey = $this->getConfig('encryptionKey');
$base64 = $this->getConfig('base64');
$encoded = $entity->get($field);
if (empty($encoded) || $encoded === false) {
return null;
}
if ($base64 === true) {
$encoded = base64_decode($encoded, true);
if ($encoded === false) {
return null;
}
}
$decrypted = Security::decrypt($encoded, $encryptionKey);
if ($decrypted === false) {
throw new RuntimeException("Unable to decypher `{$field}`. Check your enryption key.");
}
return $decrypted;
} | [
"public",
"function",
"decryptEntityField",
"(",
"EntityInterface",
"$",
"entity",
",",
"string",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"canDecryptField",
"(",
"$",
"entity",
",",
"$",
"field",
")",
")",
"{",
"return",
"null",
";",
... | Returns the decrypted field value. Assumes that the field is actually encrypted.
@param \Cake\Datasource\EntityInterface $entity Entity.
@param string $field Field name.
@return mixed|null Credentials or null when empty. | [
"Returns",
"the",
"decrypted",
"field",
"value",
".",
"Assumes",
"that",
"the",
"field",
"is",
"actually",
"encrypted",
"."
] | 4b07a3e6f2e611e7c6909c913e6166d280f3c751 | https://github.com/QoboLtd/cakephp-utils/blob/4b07a3e6f2e611e7c6909c913e6166d280f3c751/src/Model/Behavior/EncryptedFieldsBehavior.php#L237-L262 | train |
QoboLtd/cakephp-utils | src/Model/Behavior/EncryptedFieldsBehavior.php | EncryptedFieldsBehavior.canDecryptField | protected function canDecryptField(EntityInterface $entity, string $field): bool
{
if (!$this->getTable()->hasField($field)) {
return false;
}
$decryptAll = $this->getConfig('decryptAll');
if ($decryptAll === true) {
return true;
}
$fields = $this->getFields();
if (!isset($fields[$field])) {
return false;
}
$decrypt = $fields[$field]['decrypt'];
if (is_callable($decrypt)) {
$decrypt = $decrypt($entity, $field);
}
return $decrypt;
} | php | protected function canDecryptField(EntityInterface $entity, string $field): bool
{
if (!$this->getTable()->hasField($field)) {
return false;
}
$decryptAll = $this->getConfig('decryptAll');
if ($decryptAll === true) {
return true;
}
$fields = $this->getFields();
if (!isset($fields[$field])) {
return false;
}
$decrypt = $fields[$field]['decrypt'];
if (is_callable($decrypt)) {
$decrypt = $decrypt($entity, $field);
}
return $decrypt;
} | [
"protected",
"function",
"canDecryptField",
"(",
"EntityInterface",
"$",
"entity",
",",
"string",
"$",
"field",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"hasField",
"(",
"$",
"field",
")",
")",
"{",
"return"... | Returns true when the field can be decrypted.
@param \Cake\Datasource\EntityInterface $entity Entity object.
@param string $field Field name.
@return bool True is decryption is allowed. | [
"Returns",
"true",
"when",
"the",
"field",
"can",
"be",
"decrypted",
"."
] | 4b07a3e6f2e611e7c6909c913e6166d280f3c751 | https://github.com/QoboLtd/cakephp-utils/blob/4b07a3e6f2e611e7c6909c913e6166d280f3c751/src/Model/Behavior/EncryptedFieldsBehavior.php#L271-L292 | train |
QoboLtd/cakephp-utils | src/Model/Behavior/EncryptedFieldsBehavior.php | EncryptedFieldsBehavior.getFields | protected function getFields(): array
{
$fields = $this->getConfig('fields');
$defaults = [
'decrypt' => false,
];
$result = [];
foreach ($fields as $field => $values) {
if (is_numeric($field)) {
$field = $values;
$values = [];
}
$values = array_merge($defaults, $values);
$result[$field] = $values;
}
return $result;
} | php | protected function getFields(): array
{
$fields = $this->getConfig('fields');
$defaults = [
'decrypt' => false,
];
$result = [];
foreach ($fields as $field => $values) {
if (is_numeric($field)) {
$field = $values;
$values = [];
}
$values = array_merge($defaults, $values);
$result[$field] = $values;
}
return $result;
} | [
"protected",
"function",
"getFields",
"(",
")",
":",
"array",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'fields'",
")",
";",
"$",
"defaults",
"=",
"[",
"'decrypt'",
"=>",
"false",
",",
"]",
";",
"$",
"result",
"=",
"[",
"]",
";... | Returns a processed list of fields with applied default values.
@return mixed[] Fields array. | [
"Returns",
"a",
"processed",
"list",
"of",
"fields",
"with",
"applied",
"default",
"values",
"."
] | 4b07a3e6f2e611e7c6909c913e6166d280f3c751 | https://github.com/QoboLtd/cakephp-utils/blob/4b07a3e6f2e611e7c6909c913e6166d280f3c751/src/Model/Behavior/EncryptedFieldsBehavior.php#L299-L316 | train |
romm/formz | Classes/Validation/Validator/Form/AbstractFormValidator.php | AbstractFormValidator.initializeValidator | private function initializeValidator($form)
{
if (false === $form instanceof FormInterface) {
throw InvalidArgumentTypeException::validatingWrongFormType(get_class($form));
}
$this->form = $form;
$this->result = new FormResult;
$this->formValidatorExecutor = $this->getFormValidatorExecutor($form);
} | php | private function initializeValidator($form)
{
if (false === $form instanceof FormInterface) {
throw InvalidArgumentTypeException::validatingWrongFormType(get_class($form));
}
$this->form = $form;
$this->result = new FormResult;
$this->formValidatorExecutor = $this->getFormValidatorExecutor($form);
} | [
"private",
"function",
"initializeValidator",
"(",
"$",
"form",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"form",
"instanceof",
"FormInterface",
")",
"{",
"throw",
"InvalidArgumentTypeException",
"::",
"validatingWrongFormType",
"(",
"get_class",
"(",
"$",
"form",... | Initializes all class variables.
@param FormInterface $form
@throws InvalidArgumentTypeException | [
"Initializes",
"all",
"class",
"variables",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Validation/Validator/Form/AbstractFormValidator.php#L100-L109 | train |
romm/formz | Classes/Validation/Validator/Form/AbstractFormValidator.php | AbstractFormValidator.validate | final public function validate($form)
{
$this->initializeValidator($form);
$formObject = $this->formValidatorExecutor->getFormObject();
$formObject->markFormAsSubmitted();
$formObject->setForm($form);
$this->validateGhost($form, false);
$formObject->setFormResult($this->result);
return $this->result;
} | php | final public function validate($form)
{
$this->initializeValidator($form);
$formObject = $this->formValidatorExecutor->getFormObject();
$formObject->markFormAsSubmitted();
$formObject->setForm($form);
$this->validateGhost($form, false);
$formObject->setFormResult($this->result);
return $this->result;
} | [
"final",
"public",
"function",
"validate",
"(",
"$",
"form",
")",
"{",
"$",
"this",
"->",
"initializeValidator",
"(",
"$",
"form",
")",
";",
"$",
"formObject",
"=",
"$",
"this",
"->",
"formValidatorExecutor",
"->",
"getFormObject",
"(",
")",
";",
"$",
"f... | Checks the given form instance, and launches the validation if it is a
correct form.
@param FormInterface $form The form instance to be validated.
@return FormResult | [
"Checks",
"the",
"given",
"form",
"instance",
"and",
"launches",
"the",
"validation",
"if",
"it",
"is",
"a",
"correct",
"form",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Validation/Validator/Form/AbstractFormValidator.php#L118-L131 | train |
romm/formz | Classes/Validation/Validator/Form/AbstractFormValidator.php | AbstractFormValidator.validateGhost | public function validateGhost($form, $initialize = true)
{
if ($initialize) {
$this->initializeValidator($form);
}
$this->isValid($form);
return $this->result;
} | php | public function validateGhost($form, $initialize = true)
{
if ($initialize) {
$this->initializeValidator($form);
}
$this->isValid($form);
return $this->result;
} | [
"public",
"function",
"validateGhost",
"(",
"$",
"form",
",",
"$",
"initialize",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"initialize",
")",
"{",
"$",
"this",
"->",
"initializeValidator",
"(",
"$",
"form",
")",
";",
"}",
"$",
"this",
"->",
"isValid",
"... | Validates the form, but won't save form data in the form object.
@param FormInterface $form
@param bool $initialize
@return FormResult
@internal | [
"Validates",
"the",
"form",
"but",
"won",
"t",
"save",
"form",
"data",
"in",
"the",
"form",
"object",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Validation/Validator/Form/AbstractFormValidator.php#L141-L150 | train |
romm/formz | Classes/Validation/Validator/Form/AbstractFormValidator.php | AbstractFormValidator.isValid | final public function isValid($form)
{
$this->formValidatorExecutor->applyBehaviours();
$this->formValidatorExecutor->checkFieldsActivation();
$this->beforeValidationProcess();
$this->formValidatorExecutor->validateFields(function (Field $field) {
$this->callAfterFieldValidationMethod($field);
});
$this->afterValidationProcess();
if ($this->result->hasErrors()) {
// Storing the form for possible third party further usage.
FormService::addFormWithErrors($form);
}
} | php | final public function isValid($form)
{
$this->formValidatorExecutor->applyBehaviours();
$this->formValidatorExecutor->checkFieldsActivation();
$this->beforeValidationProcess();
$this->formValidatorExecutor->validateFields(function (Field $field) {
$this->callAfterFieldValidationMethod($field);
});
$this->afterValidationProcess();
if ($this->result->hasErrors()) {
// Storing the form for possible third party further usage.
FormService::addFormWithErrors($form);
}
} | [
"final",
"public",
"function",
"isValid",
"(",
"$",
"form",
")",
"{",
"$",
"this",
"->",
"formValidatorExecutor",
"->",
"applyBehaviours",
"(",
")",
";",
"$",
"this",
"->",
"formValidatorExecutor",
"->",
"checkFieldsActivation",
"(",
")",
";",
"$",
"this",
"... | Runs the whole validation workflow.
@param FormInterface $form | [
"Runs",
"the",
"whole",
"validation",
"workflow",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Validation/Validator/Form/AbstractFormValidator.php#L157-L174 | train |
romm/formz | Classes/Validation/Validator/Form/AbstractFormValidator.php | AbstractFormValidator.callAfterFieldValidationMethod | private function callAfterFieldValidationMethod(Field $field)
{
$functionName = lcfirst($field->getName() . 'Validated');
if (method_exists($this, $functionName)) {
call_user_func([$this, $functionName]);
}
} | php | private function callAfterFieldValidationMethod(Field $field)
{
$functionName = lcfirst($field->getName() . 'Validated');
if (method_exists($this, $functionName)) {
call_user_func([$this, $functionName]);
}
} | [
"private",
"function",
"callAfterFieldValidationMethod",
"(",
"Field",
"$",
"field",
")",
"{",
"$",
"functionName",
"=",
"lcfirst",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
".",
"'Validated'",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",... | After each field has been validated, a matching method can be called if
it exists in the child class.
The syntax is `{lowerCamelCaseFieldName}Validated()`.
Example: for field `firstName` - `firstNameValidated()`.
@param Field $field | [
"After",
"each",
"field",
"has",
"been",
"validated",
"a",
"matching",
"method",
"can",
"be",
"called",
"if",
"it",
"exists",
"in",
"the",
"child",
"class",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Validation/Validator/Form/AbstractFormValidator.php#L202-L209 | train |
romm/formz | Classes/AssetHandler/JavaScript/FieldsValidationJavaScriptAssetHandler.php | FieldsValidationJavaScriptAssetHandler.getJavaScriptCode | public function getJavaScriptCode()
{
$fieldsJavaScriptCode = [];
$formConfiguration = $this->getFormObject()->getConfiguration();
foreach ($formConfiguration->getFields() as $field) {
$fieldsJavaScriptCode[] = $this->processField($field);
}
$formName = GeneralUtility::quoteJSvalue($this->getFormObject()->getName());
$fieldsJavaScriptCode = implode(CRLF, $fieldsJavaScriptCode);
return <<<JS
(function() {
Fz.Form.get(
$formName,
function(form) {
var field = null;
$fieldsJavaScriptCode
}
);
})();
JS;
} | php | public function getJavaScriptCode()
{
$fieldsJavaScriptCode = [];
$formConfiguration = $this->getFormObject()->getConfiguration();
foreach ($formConfiguration->getFields() as $field) {
$fieldsJavaScriptCode[] = $this->processField($field);
}
$formName = GeneralUtility::quoteJSvalue($this->getFormObject()->getName());
$fieldsJavaScriptCode = implode(CRLF, $fieldsJavaScriptCode);
return <<<JS
(function() {
Fz.Form.get(
$formName,
function(form) {
var field = null;
$fieldsJavaScriptCode
}
);
})();
JS;
} | [
"public",
"function",
"getJavaScriptCode",
"(",
")",
"{",
"$",
"fieldsJavaScriptCode",
"=",
"[",
"]",
";",
"$",
"formConfiguration",
"=",
"$",
"this",
"->",
"getFormObject",
"(",
")",
"->",
"getConfiguration",
"(",
")",
";",
"foreach",
"(",
"$",
"formConfigu... | Main function of this asset handler. See class description.
@return string | [
"Main",
"function",
"of",
"this",
"asset",
"handler",
".",
"See",
"class",
"description",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/AssetHandler/JavaScript/FieldsValidationJavaScriptAssetHandler.php#L44-L68 | train |
romm/formz | Classes/AssetHandler/JavaScript/FieldsValidationJavaScriptAssetHandler.php | FieldsValidationJavaScriptAssetHandler.processField | protected function processField($field)
{
$javaScriptCode = [];
$fieldName = $field->getName();
foreach ($field->getValidation() as $validationName => $validationConfiguration) {
$validatorClassName = $validationConfiguration->getClassName();
if (in_array(AbstractValidator::class, class_parents($validatorClassName))) {
$javaScriptCode[] = (string)$this->getInlineJavaScriptValidationCode($field, $validationName, $validationConfiguration);
}
}
$javaScriptCode = implode(CRLF, $javaScriptCode);
$javaScriptFieldName = GeneralUtility::quoteJSvalue($fieldName);
return <<<JS
/***************************
* Field: "$fieldName"
****************************/
field = form.getFieldByName($javaScriptFieldName);
if (null !== field) {
$javaScriptCode
}
JS;
} | php | protected function processField($field)
{
$javaScriptCode = [];
$fieldName = $field->getName();
foreach ($field->getValidation() as $validationName => $validationConfiguration) {
$validatorClassName = $validationConfiguration->getClassName();
if (in_array(AbstractValidator::class, class_parents($validatorClassName))) {
$javaScriptCode[] = (string)$this->getInlineJavaScriptValidationCode($field, $validationName, $validationConfiguration);
}
}
$javaScriptCode = implode(CRLF, $javaScriptCode);
$javaScriptFieldName = GeneralUtility::quoteJSvalue($fieldName);
return <<<JS
/***************************
* Field: "$fieldName"
****************************/
field = form.getFieldByName($javaScriptFieldName);
if (null !== field) {
$javaScriptCode
}
JS;
} | [
"protected",
"function",
"processField",
"(",
"$",
"field",
")",
"{",
"$",
"javaScriptCode",
"=",
"[",
"]",
";",
"$",
"fieldName",
"=",
"$",
"field",
"->",
"getName",
"(",
")",
";",
"foreach",
"(",
"$",
"field",
"->",
"getValidation",
"(",
")",
"as",
... | Will run the process for the given field.
@param Field $field
@return string | [
"Will",
"run",
"the",
"process",
"for",
"the",
"given",
"field",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/AssetHandler/JavaScript/FieldsValidationJavaScriptAssetHandler.php#L76-L103 | train |
romm/formz | Classes/AssetHandler/JavaScript/FieldsValidationJavaScriptAssetHandler.php | FieldsValidationJavaScriptAssetHandler.getInlineJavaScriptValidationCode | protected function getInlineJavaScriptValidationCode(Field $field, $validationName, Validation $validatorConfiguration)
{
$javaScriptValidationName = GeneralUtility::quoteJSvalue($validationName);
$validatorName = addslashes($validatorConfiguration->getClassName());
$validatorConfigurationFinal = $this->getValidationConfiguration($field, $validationName, $validatorConfiguration);
$validatorConfigurationFinal = $this->handleValidationConfiguration($validatorConfigurationFinal);
return <<<JS
/*
* Validation rule "$validationName"
*/
field.addValidation($javaScriptValidationName, '$validatorName', $validatorConfigurationFinal);
JS;
} | php | protected function getInlineJavaScriptValidationCode(Field $field, $validationName, Validation $validatorConfiguration)
{
$javaScriptValidationName = GeneralUtility::quoteJSvalue($validationName);
$validatorName = addslashes($validatorConfiguration->getClassName());
$validatorConfigurationFinal = $this->getValidationConfiguration($field, $validationName, $validatorConfiguration);
$validatorConfigurationFinal = $this->handleValidationConfiguration($validatorConfigurationFinal);
return <<<JS
/*
* Validation rule "$validationName"
*/
field.addValidation($javaScriptValidationName, '$validatorName', $validatorConfigurationFinal);
JS;
} | [
"protected",
"function",
"getInlineJavaScriptValidationCode",
"(",
"Field",
"$",
"field",
",",
"$",
"validationName",
",",
"Validation",
"$",
"validatorConfiguration",
")",
"{",
"$",
"javaScriptValidationName",
"=",
"GeneralUtility",
"::",
"quoteJSvalue",
"(",
"$",
"v... | Generates the JavaScript code to add a validation rule to a field.
@param Field $field
@param string $validationName The name of the validation rule.
@param Validation $validatorConfiguration Contains the current validator configuration.
@return string | [
"Generates",
"the",
"JavaScript",
"code",
"to",
"add",
"a",
"validation",
"rule",
"to",
"a",
"field",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/AssetHandler/JavaScript/FieldsValidationJavaScriptAssetHandler.php#L113-L127 | train |
romm/formz | Classes/AssetHandler/JavaScript/FieldsValidationJavaScriptAssetHandler.php | FieldsValidationJavaScriptAssetHandler.getValidationConfiguration | protected function getValidationConfiguration(Field $field, $validationName, Validation $validatorConfiguration)
{
$acceptsEmptyValues = ValidatorService::get()->validatorAcceptsEmptyValues($validatorConfiguration->getClassName());
/** @var FormzLocalizationJavaScriptAssetHandler $formzLocalizationJavaScriptAssetHandler */
$formzLocalizationJavaScriptAssetHandler = $this->assetHandlerFactory->getAssetHandler(FormzLocalizationJavaScriptAssetHandler::class);
$messages = $formzLocalizationJavaScriptAssetHandler->getTranslationKeysForFieldValidation($field, $validationName);
return ArrayService::get()->arrayToJavaScriptJson([
'options' => $validatorConfiguration->getOptions(),
'messages' => $messages,
'settings' => $validatorConfiguration->toArray(),
'acceptsEmptyValues' => $acceptsEmptyValues
]);
} | php | protected function getValidationConfiguration(Field $field, $validationName, Validation $validatorConfiguration)
{
$acceptsEmptyValues = ValidatorService::get()->validatorAcceptsEmptyValues($validatorConfiguration->getClassName());
/** @var FormzLocalizationJavaScriptAssetHandler $formzLocalizationJavaScriptAssetHandler */
$formzLocalizationJavaScriptAssetHandler = $this->assetHandlerFactory->getAssetHandler(FormzLocalizationJavaScriptAssetHandler::class);
$messages = $formzLocalizationJavaScriptAssetHandler->getTranslationKeysForFieldValidation($field, $validationName);
return ArrayService::get()->arrayToJavaScriptJson([
'options' => $validatorConfiguration->getOptions(),
'messages' => $messages,
'settings' => $validatorConfiguration->toArray(),
'acceptsEmptyValues' => $acceptsEmptyValues
]);
} | [
"protected",
"function",
"getValidationConfiguration",
"(",
"Field",
"$",
"field",
",",
"$",
"validationName",
",",
"Validation",
"$",
"validatorConfiguration",
")",
"{",
"$",
"acceptsEmptyValues",
"=",
"ValidatorService",
"::",
"get",
"(",
")",
"->",
"validatorAcce... | Returns a JSON array containing the validation configuration needed by
JavaScript.
@param Field $field
@param string $validationName
@param Validation $validatorConfiguration
@return string | [
"Returns",
"a",
"JSON",
"array",
"containing",
"the",
"validation",
"configuration",
"needed",
"by",
"JavaScript",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/AssetHandler/JavaScript/FieldsValidationJavaScriptAssetHandler.php#L149-L164 | train |
vegas-cmf/forms | src/FormFactory.php | FormFactory.callBuilderMethod | private function callBuilderMethod($item)
{
$settings = new InputSettingsForm;
if (!$settings->isValid($item)) {
throw new InvalidInputSettingsException;
}
$settings->bind($item, new \stdClass);
$className = $item[InputSettingsForm::TYPE_PARAM];
if(!class_exists($className)) {
throw new NotFoundException();
}
if(!in_array($className, $this->builders)) {
throw new NotDefinedException();
}
$method = new \ReflectionMethod($className, self::BUILDER_METHOD);
return $method->invokeArgs(new $className, array($settings));
} | php | private function callBuilderMethod($item)
{
$settings = new InputSettingsForm;
if (!$settings->isValid($item)) {
throw new InvalidInputSettingsException;
}
$settings->bind($item, new \stdClass);
$className = $item[InputSettingsForm::TYPE_PARAM];
if(!class_exists($className)) {
throw new NotFoundException();
}
if(!in_array($className, $this->builders)) {
throw new NotDefinedException();
}
$method = new \ReflectionMethod($className, self::BUILDER_METHOD);
return $method->invokeArgs(new $className, array($settings));
} | [
"private",
"function",
"callBuilderMethod",
"(",
"$",
"item",
")",
"{",
"$",
"settings",
"=",
"new",
"InputSettingsForm",
";",
"if",
"(",
"!",
"$",
"settings",
"->",
"isValid",
"(",
"$",
"item",
")",
")",
"{",
"throw",
"new",
"InvalidInputSettingsException",... | Proxies factory create call to specific responsible builder.
@param array $settings
@return \Phalcon\Forms\ElementInterface form element instance
@throws \Vegas\Forms\Builder\Exception\NotFoundException When a specific type is not found | [
"Proxies",
"factory",
"create",
"call",
"to",
"specific",
"responsible",
"builder",
"."
] | f2513b1367c3124f399955ed50ff0e3c13eb671b | https://github.com/vegas-cmf/forms/blob/f2513b1367c3124f399955ed50ff0e3c13eb671b/src/FormFactory.php#L135-L154 | train |
vegas-cmf/forms | src/FormFactory.php | FormFactory.callAdditionalOptionsMethod | private function callAdditionalOptionsMethod($item)
{
$settings = new InputSettingsForm;
if (!$settings->isValid($item)) {
throw new InvalidInputSettingsException;
}
$settings->bind($item, new \stdClass);
$className = $item[InputSettingsForm::TYPE_PARAM];
if(!class_exists($className)) {
throw new NotFoundException();
}
if(!in_array($className, $this->builders)) {
throw new NotDefinedException();
}
$builderObject = new $className;
$builderObject->setAdditionalOptions();
return $builderObject->getAdditionalOptions();
$setMethod = new \ReflectionMethod($className, self::INIT_ELEMENT_METHOD);
$getMethod = new \ReflectionMethod($className, self::ADDITIONAL_OPTIONS_METHOD);
$setMethod->invokeArgs($builderObject, array($settings));
return $getMethod->invokeArgs($builderObject, array($settings));
} | php | private function callAdditionalOptionsMethod($item)
{
$settings = new InputSettingsForm;
if (!$settings->isValid($item)) {
throw new InvalidInputSettingsException;
}
$settings->bind($item, new \stdClass);
$className = $item[InputSettingsForm::TYPE_PARAM];
if(!class_exists($className)) {
throw new NotFoundException();
}
if(!in_array($className, $this->builders)) {
throw new NotDefinedException();
}
$builderObject = new $className;
$builderObject->setAdditionalOptions();
return $builderObject->getAdditionalOptions();
$setMethod = new \ReflectionMethod($className, self::INIT_ELEMENT_METHOD);
$getMethod = new \ReflectionMethod($className, self::ADDITIONAL_OPTIONS_METHOD);
$setMethod->invokeArgs($builderObject, array($settings));
return $getMethod->invokeArgs($builderObject, array($settings));
} | [
"private",
"function",
"callAdditionalOptionsMethod",
"(",
"$",
"item",
")",
"{",
"$",
"settings",
"=",
"new",
"InputSettingsForm",
";",
"if",
"(",
"!",
"$",
"settings",
"->",
"isValid",
"(",
"$",
"item",
")",
")",
"{",
"throw",
"new",
"InvalidInputSettingsE... | Proxies factory create call for additional fields to specific responsible builder.
@param array $settings
@return \Phalcon\Forms\ElementInterface form element instance
@throws \Vegas\Forms\Builder\Exception\NotFoundException When a specific type is not found | [
"Proxies",
"factory",
"create",
"call",
"for",
"additional",
"fields",
"to",
"specific",
"responsible",
"builder",
"."
] | f2513b1367c3124f399955ed50ff0e3c13eb671b | https://github.com/vegas-cmf/forms/blob/f2513b1367c3124f399955ed50ff0e3c13eb671b/src/FormFactory.php#L162-L187 | train |
vegas-cmf/forms | src/FormFactory.php | FormFactory.render | public function render()
{
$elements = [];
foreach($this->builders as $builder) {
$object = new $builder;
$elements[] = [
'element' => $object->initElement(),
'options' => $object->getAdditionalOptions()
];
}
return $elements;
} | php | public function render()
{
$elements = [];
foreach($this->builders as $builder) {
$object = new $builder;
$elements[] = [
'element' => $object->initElement(),
'options' => $object->getAdditionalOptions()
];
}
return $elements;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"elements",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"builders",
"as",
"$",
"builder",
")",
"{",
"$",
"object",
"=",
"new",
"$",
"builder",
";",
"$",
"elements",
"[",
"]",
"=",
"["... | Method create object for render each element. Execute initElement method
@return array | [
"Method",
"create",
"object",
"for",
"render",
"each",
"element",
".",
"Execute",
"initElement",
"method"
] | f2513b1367c3124f399955ed50ff0e3c13eb671b | https://github.com/vegas-cmf/forms/blob/f2513b1367c3124f399955ed50ff0e3c13eb671b/src/FormFactory.php#L195-L207 | train |
vegas-cmf/forms | src/InputSettings.php | InputSettings.getDataFromProvider | public function getDataFromProvider()
{
$select = $this->get(self::DATA_PARAM);
if(is_null($select->getValue())) {
return array();
}
$classname = $select->getValue();
if (!class_exists($classname) || !array_key_exists($classname, $select->getOptions())) {
throw new NotFoundException;
}
return (new $classname)->getData();
} | php | public function getDataFromProvider()
{
$select = $this->get(self::DATA_PARAM);
if(is_null($select->getValue())) {
return array();
}
$classname = $select->getValue();
if (!class_exists($classname) || !array_key_exists($classname, $select->getOptions())) {
throw new NotFoundException;
}
return (new $classname)->getData();
} | [
"public",
"function",
"getDataFromProvider",
"(",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"get",
"(",
"self",
"::",
"DATA_PARAM",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"select",
"->",
"getValue",
"(",
")",
")",
")",
"{",
"return",
"array... | Proxy method to retrieve data to populate select lists.
@return array
@throws \Vegas\Forms\DataProvider\Exception\NotFoundException When DI is not configured properly or a wrong value is provided. | [
"Proxy",
"method",
"to",
"retrieve",
"data",
"to",
"populate",
"select",
"lists",
"."
] | f2513b1367c3124f399955ed50ff0e3c13eb671b | https://github.com/vegas-cmf/forms/blob/f2513b1367c3124f399955ed50ff0e3c13eb671b/src/InputSettings.php#L99-L111 | train |
vegas-cmf/forms | src/InputSettings.php | InputSettings.addDataProviderInput | public function addDataProviderInput()
{
$input = (new Select(self::DATA_PARAM))
->setOptions(array(null => '---'));
$dataProviderClasses = array();
foreach ($this->di->get('config')->formFactory->dataProviders as $classname) {
$provider = new $classname;
if ($provider instanceof DataProviderInterface) {
$dataProviderClasses[$classname] = $provider->getName();
}
}
$input
->addOptions($dataProviderClasses)
->setLabel('Data provider');
$this->add($input);
} | php | public function addDataProviderInput()
{
$input = (new Select(self::DATA_PARAM))
->setOptions(array(null => '---'));
$dataProviderClasses = array();
foreach ($this->di->get('config')->formFactory->dataProviders as $classname) {
$provider = new $classname;
if ($provider instanceof DataProviderInterface) {
$dataProviderClasses[$classname] = $provider->getName();
}
}
$input
->addOptions($dataProviderClasses)
->setLabel('Data provider');
$this->add($input);
} | [
"public",
"function",
"addDataProviderInput",
"(",
")",
"{",
"$",
"input",
"=",
"(",
"new",
"Select",
"(",
"self",
"::",
"DATA_PARAM",
")",
")",
"->",
"setOptions",
"(",
"array",
"(",
"null",
"=>",
"'---'",
")",
")",
";",
"$",
"dataProviderClasses",
"=",... | Adds selectable list of data providers.
Usable only for selectable input types. | [
"Adds",
"selectable",
"list",
"of",
"data",
"providers",
".",
"Usable",
"only",
"for",
"selectable",
"input",
"types",
"."
] | f2513b1367c3124f399955ed50ff0e3c13eb671b | https://github.com/vegas-cmf/forms/blob/f2513b1367c3124f399955ed50ff0e3c13eb671b/src/InputSettings.php#L117-L132 | train |
romm/formz | Classes/Service/CacheService.php | CacheService.getCacheInstance | public function getCacheInstance()
{
if (null === $this->cacheInstance) {
$this->cacheInstance = $this->cacheManager->getCache(self::CACHE_IDENTIFIER);
}
return $this->cacheInstance;
} | php | public function getCacheInstance()
{
if (null === $this->cacheInstance) {
$this->cacheInstance = $this->cacheManager->getCache(self::CACHE_IDENTIFIER);
}
return $this->cacheInstance;
} | [
"public",
"function",
"getCacheInstance",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"cacheInstance",
")",
"{",
"$",
"this",
"->",
"cacheInstance",
"=",
"$",
"this",
"->",
"cacheManager",
"->",
"getCache",
"(",
"self",
"::",
"CACHE_IDENTIF... | Returns the cache instance used by this extension.
@return FrontendInterface | [
"Returns",
"the",
"cache",
"instance",
"used",
"by",
"this",
"extension",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Service/CacheService.php#L76-L83 | train |
romm/formz | Classes/Service/CacheService.php | CacheService.getFormCacheIdentifier | public function getFormCacheIdentifier($formClassName, $formName)
{
$shortClassName = end(explode('\\', $formClassName));
return StringService::get()->sanitizeString($shortClassName . '-' . $formName);
} | php | public function getFormCacheIdentifier($formClassName, $formName)
{
$shortClassName = end(explode('\\', $formClassName));
return StringService::get()->sanitizeString($shortClassName . '-' . $formName);
} | [
"public",
"function",
"getFormCacheIdentifier",
"(",
"$",
"formClassName",
",",
"$",
"formName",
")",
"{",
"$",
"shortClassName",
"=",
"end",
"(",
"explode",
"(",
"'\\\\'",
",",
"$",
"formClassName",
")",
")",
";",
"return",
"StringService",
"::",
"get",
"("... | Generic cache identifier creation for usages in the extension.
@param string $formClassName
@param string $formName
@return string | [
"Generic",
"cache",
"identifier",
"creation",
"for",
"usages",
"in",
"the",
"extension",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Service/CacheService.php#L92-L97 | train |
romm/formz | Classes/Service/CacheService.php | CacheService.clearCacheCommand | public function clearCacheCommand($parameters)
{
if (in_array($parameters['cacheCmd'], ['all', 'system'])) {
$files = $this->getFilesInPath(self::GENERATED_FILES_PATH . '*');
foreach ($files as $file) {
$this->clearFile($file);
}
}
} | php | public function clearCacheCommand($parameters)
{
if (in_array($parameters['cacheCmd'], ['all', 'system'])) {
$files = $this->getFilesInPath(self::GENERATED_FILES_PATH . '*');
foreach ($files as $file) {
$this->clearFile($file);
}
}
} | [
"public",
"function",
"clearCacheCommand",
"(",
"$",
"parameters",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"parameters",
"[",
"'cacheCmd'",
"]",
",",
"[",
"'all'",
",",
"'system'",
"]",
")",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"getFilesI... | Function called when clearing TYPO3 caches. It will remove the temporary
asset files created by FormZ.
@param array $parameters | [
"Function",
"called",
"when",
"clearing",
"TYPO3",
"caches",
".",
"It",
"will",
"remove",
"the",
"temporary",
"asset",
"files",
"created",
"by",
"FormZ",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Service/CacheService.php#L105-L114 | train |
lotfio/ouch | src/Ouch/View.php | View.render | public static function render($file, $ex) : void
{
if (php_sapi_name() === 'cli') {
exit(json_encode($ex));
}
http_response_code(500);
require ouch_views($file);
exit(1); //stop execution on first error
} | php | public static function render($file, $ex) : void
{
if (php_sapi_name() === 'cli') {
exit(json_encode($ex));
}
http_response_code(500);
require ouch_views($file);
exit(1); //stop execution on first error
} | [
"public",
"static",
"function",
"render",
"(",
"$",
"file",
",",
"$",
"ex",
")",
":",
"void",
"{",
"if",
"(",
"php_sapi_name",
"(",
")",
"===",
"'cli'",
")",
"{",
"exit",
"(",
"json_encode",
"(",
"$",
"ex",
")",
")",
";",
"}",
"http_response_code",
... | render view method.
@param string $file view file name
@param object $ex exception
@return void | [
"render",
"view",
"method",
"."
] | 2d82d936a58f39cba005696107401d5a809c542d | https://github.com/lotfio/ouch/blob/2d82d936a58f39cba005696107401d5a809c542d/src/Ouch/View.php#L25-L34 | train |
DevFactoryCH/taxonomy | src/Controllers/TaxonomyController.php | TaxonomyController.deleteDestroy | public function deleteDestroy($id) {
$vocabulary = $this->vocabulary->find($id);
$terms = $vocabulary->terms->lists('id')->toArray();
TermRelation::whereIn('term_id',$terms)->delete();
Term::destroy($terms);
$this->vocabulary->destroy($id);
return response()->json(['OK']);
} | php | public function deleteDestroy($id) {
$vocabulary = $this->vocabulary->find($id);
$terms = $vocabulary->terms->lists('id')->toArray();
TermRelation::whereIn('term_id',$terms)->delete();
Term::destroy($terms);
$this->vocabulary->destroy($id);
return response()->json(['OK']);
} | [
"public",
"function",
"deleteDestroy",
"(",
"$",
"id",
")",
"{",
"$",
"vocabulary",
"=",
"$",
"this",
"->",
"vocabulary",
"->",
"find",
"(",
"$",
"id",
")",
";",
"$",
"terms",
"=",
"$",
"vocabulary",
"->",
"terms",
"->",
"lists",
"(",
"'id'",
")",
... | Destory a resource.
@return Response | [
"Destory",
"a",
"resource",
"."
] | ff49a2e450d749b82243e5514e8e847ae21371e8 | https://github.com/DevFactoryCH/taxonomy/blob/ff49a2e450d749b82243e5514e8e847ae21371e8/src/Controllers/TaxonomyController.php#L79-L89 | train |
DevFactoryCH/taxonomy | src/Controllers/TaxonomyController.php | TaxonomyController.putUpdate | public function putUpdate(Request $request, $id) {
$this->validate($request, isset($this->vocabulary->rules_create) ? $this->vocabulary->rules_create : $this->vocabulary->rules);
$vocabulary = $this->vocabulary->findOrFail($id);
$vocabulary->update(Input::only('name'));
return Redirect::to(action('\Devfactory\Taxonomy\Controllers\TaxonomyController@getIndex'))->with('success', 'Updated');
} | php | public function putUpdate(Request $request, $id) {
$this->validate($request, isset($this->vocabulary->rules_create) ? $this->vocabulary->rules_create : $this->vocabulary->rules);
$vocabulary = $this->vocabulary->findOrFail($id);
$vocabulary->update(Input::only('name'));
return Redirect::to(action('\Devfactory\Taxonomy\Controllers\TaxonomyController@getIndex'))->with('success', 'Updated');
} | [
"public",
"function",
"putUpdate",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"request",
",",
"isset",
"(",
"$",
"this",
"->",
"vocabulary",
"->",
"rules_create",
")",
"?",
"$",
"this",
"->",
"v... | Update a resource.
@return Response | [
"Update",
"a",
"resource",
"."
] | ff49a2e450d749b82243e5514e8e847ae21371e8 | https://github.com/DevFactoryCH/taxonomy/blob/ff49a2e450d749b82243e5514e8e847ae21371e8/src/Controllers/TaxonomyController.php#L96-L104 | train |
romm/formz | Classes/Form/FormObjectConfiguration.php | FormObjectConfiguration.getConfigurationObject | public function getConfigurationObject()
{
if (null === $this->configurationObject
|| $this->lastConfigurationHash !== $this->formObject->getHash()
) {
$this->lastConfigurationHash = $this->formObject->getHash();
$this->configurationObject = $this->getConfigurationObjectFromCache();
}
return $this->configurationObject;
} | php | public function getConfigurationObject()
{
if (null === $this->configurationObject
|| $this->lastConfigurationHash !== $this->formObject->getHash()
) {
$this->lastConfigurationHash = $this->formObject->getHash();
$this->configurationObject = $this->getConfigurationObjectFromCache();
}
return $this->configurationObject;
} | [
"public",
"function",
"getConfigurationObject",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"configurationObject",
"||",
"$",
"this",
"->",
"lastConfigurationHash",
"!==",
"$",
"this",
"->",
"formObject",
"->",
"getHash",
"(",
")",
")",
"{",
... | Returns an instance of configuration object. Checks if it was previously
stored in cache, otherwise it is created from scratch.
@return ConfigurationObjectInstance | [
"Returns",
"an",
"instance",
"of",
"configuration",
"object",
".",
"Checks",
"if",
"it",
"was",
"previously",
"stored",
"in",
"cache",
"otherwise",
"it",
"is",
"created",
"from",
"scratch",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Form/FormObjectConfiguration.php#L78-L88 | train |
romm/formz | Classes/Form/FormObjectConfiguration.php | FormObjectConfiguration.getConfigurationValidationResult | public function getConfigurationValidationResult()
{
if (null === $this->configurationValidationResult
|| $this->lastConfigurationHash !== $this->formObject->getHash()
) {
$configurationObject = $this->getConfigurationObject();
$this->configurationValidationResult = $this->refreshConfigurationValidationResult($configurationObject);
}
return $this->configurationValidationResult;
} | php | public function getConfigurationValidationResult()
{
if (null === $this->configurationValidationResult
|| $this->lastConfigurationHash !== $this->formObject->getHash()
) {
$configurationObject = $this->getConfigurationObject();
$this->configurationValidationResult = $this->refreshConfigurationValidationResult($configurationObject);
}
return $this->configurationValidationResult;
} | [
"public",
"function",
"getConfigurationValidationResult",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"configurationValidationResult",
"||",
"$",
"this",
"->",
"lastConfigurationHash",
"!==",
"$",
"this",
"->",
"formObject",
"->",
"getHash",
"(",
... | This function will merge and return the validation results of both the
global FormZ configuration object, and this form configuration object.
@return Result | [
"This",
"function",
"will",
"merge",
"and",
"return",
"the",
"validation",
"results",
"of",
"both",
"the",
"global",
"FormZ",
"configuration",
"object",
"and",
"this",
"form",
"configuration",
"object",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Form/FormObjectConfiguration.php#L96-L106 | train |
romm/formz | Classes/Form/FormObjectConfiguration.php | FormObjectConfiguration.refreshConfigurationValidationResult | protected function refreshConfigurationValidationResult(ConfigurationObjectInstance $configurationObject)
{
$result = new Result;
$formzConfigurationValidationResult = $this->configurationFactory
->getFormzConfiguration()
->getValidationResult();
$result->merge($formzConfigurationValidationResult);
$result->forProperty('forms.' . $this->formObject->getClassName())
->merge($configurationObject->getValidationResult());
return $result;
} | php | protected function refreshConfigurationValidationResult(ConfigurationObjectInstance $configurationObject)
{
$result = new Result;
$formzConfigurationValidationResult = $this->configurationFactory
->getFormzConfiguration()
->getValidationResult();
$result->merge($formzConfigurationValidationResult);
$result->forProperty('forms.' . $this->formObject->getClassName())
->merge($configurationObject->getValidationResult());
return $result;
} | [
"protected",
"function",
"refreshConfigurationValidationResult",
"(",
"ConfigurationObjectInstance",
"$",
"configurationObject",
")",
"{",
"$",
"result",
"=",
"new",
"Result",
";",
"$",
"formzConfigurationValidationResult",
"=",
"$",
"this",
"->",
"configurationFactory",
... | Resets the validation result and merges it with the global FormZ
configuration.
@param ConfigurationObjectInstance $configurationObject
@return Result | [
"Resets",
"the",
"validation",
"result",
"and",
"merges",
"it",
"with",
"the",
"global",
"FormZ",
"configuration",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Form/FormObjectConfiguration.php#L115-L128 | train |
romm/formz | Classes/Form/FormObjectConfiguration.php | FormObjectConfiguration.sanitizeConfiguration | protected function sanitizeConfiguration(array $configuration)
{
// Removing configuration of fields which do not exist for this form.
$sanitizedFieldsConfiguration = [];
$fieldsConfiguration = (isset($configuration['fields']))
? $configuration['fields']
: [];
foreach ($this->formObject->getProperties() as $property) {
$sanitizedFieldsConfiguration[$property] = (isset($fieldsConfiguration[$property]))
? $fieldsConfiguration[$property]
: [];
}
$configuration['fields'] = $sanitizedFieldsConfiguration;
return $configuration;
} | php | protected function sanitizeConfiguration(array $configuration)
{
// Removing configuration of fields which do not exist for this form.
$sanitizedFieldsConfiguration = [];
$fieldsConfiguration = (isset($configuration['fields']))
? $configuration['fields']
: [];
foreach ($this->formObject->getProperties() as $property) {
$sanitizedFieldsConfiguration[$property] = (isset($fieldsConfiguration[$property]))
? $fieldsConfiguration[$property]
: [];
}
$configuration['fields'] = $sanitizedFieldsConfiguration;
return $configuration;
} | [
"protected",
"function",
"sanitizeConfiguration",
"(",
"array",
"$",
"configuration",
")",
"{",
"// Removing configuration of fields which do not exist for this form.",
"$",
"sanitizedFieldsConfiguration",
"=",
"[",
"]",
";",
"$",
"fieldsConfiguration",
"=",
"(",
"isset",
"... | This function will clean the configuration array by removing useless data
and updating needed ones.
@param array $configuration
@return array | [
"This",
"function",
"will",
"clean",
"the",
"configuration",
"array",
"by",
"removing",
"useless",
"data",
"and",
"updating",
"needed",
"ones",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Form/FormObjectConfiguration.php#L166-L183 | train |
subscribepro/subscribepro-php | src/SubscribePro/Sdk.php | Sdk.getTool | public function getTool($name)
{
if (!isset($this->tools[$name])) {
$this->tools[$name] = $this->createTool($name);
}
return $this->tools[$name];
} | php | public function getTool($name)
{
if (!isset($this->tools[$name])) {
$this->tools[$name] = $this->createTool($name);
}
return $this->tools[$name];
} | [
"public",
"function",
"getTool",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"tools",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"tools",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"createTool"... | Get tool by name
@param string $name
@return \SubscribePro\Tools\AbstractTool
@throws \SubscribePro\Exception\InvalidArgumentException | [
"Get",
"tool",
"by",
"name"
] | e1909a4ac0cf7855466411a3fd1f017524218cc6 | https://github.com/subscribepro/subscribepro-php/blob/e1909a4ac0cf7855466411a3fd1f017524218cc6/src/SubscribePro/Sdk.php#L176-L182 | train |
romm/formz | Classes/Service/InstanceService.php | InstanceService.reset | public function reset()
{
foreach (array_keys($this->objectInstances) as $className) {
if ($className !== self::class) {
unset($this->objectInstances[$className]);
}
}
} | php | public function reset()
{
foreach (array_keys($this->objectInstances) as $className) {
if ($className !== self::class) {
unset($this->objectInstances[$className]);
}
}
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"objectInstances",
")",
"as",
"$",
"className",
")",
"{",
"if",
"(",
"$",
"className",
"!==",
"self",
"::",
"class",
")",
"{",
"unset",
"(",
"$",
"thi... | Used in unit tests. | [
"Used",
"in",
"unit",
"tests",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Service/InstanceService.php#L62-L69 | train |
romm/formz | Classes/ViewHelpers/ClassViewHelper.php | ClassViewHelper.initializeClassNames | protected function initializeClassNames()
{
list($this->classNameSpace, $this->className) = GeneralUtility::trimExplode('.', $this->arguments['name']);
if (false === in_array($this->classNameSpace, self::$acceptedClassesNameSpace)) {
throw InvalidEntryException::invalidCssClassNamespace($this->arguments['name'], self::$acceptedClassesNameSpace);
}
} | php | protected function initializeClassNames()
{
list($this->classNameSpace, $this->className) = GeneralUtility::trimExplode('.', $this->arguments['name']);
if (false === in_array($this->classNameSpace, self::$acceptedClassesNameSpace)) {
throw InvalidEntryException::invalidCssClassNamespace($this->arguments['name'], self::$acceptedClassesNameSpace);
}
} | [
"protected",
"function",
"initializeClassNames",
"(",
")",
"{",
"list",
"(",
"$",
"this",
"->",
"classNameSpace",
",",
"$",
"this",
"->",
"className",
")",
"=",
"GeneralUtility",
"::",
"trimExplode",
"(",
"'.'",
",",
"$",
"this",
"->",
"arguments",
"[",
"'... | Will initialize the namespace and name of the class which is given as
argument to this ViewHelper.
@throws InvalidEntryException | [
"Will",
"initialize",
"the",
"namespace",
"and",
"name",
"of",
"the",
"class",
"which",
"is",
"given",
"as",
"argument",
"to",
"this",
"ViewHelper",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/ClassViewHelper.php#L126-L133 | train |
romm/formz | Classes/ViewHelpers/ClassViewHelper.php | ClassViewHelper.initializeFieldName | protected function initializeFieldName()
{
$this->fieldName = $this->arguments['field'];
if (empty($this->fieldName)
&& $this->fieldService->fieldContextExists()
) {
$this->fieldName = $this->fieldService
->getCurrentField()
->getName();
}
if (null === $this->fieldName) {
throw EntryNotFoundException::classViewHelperFieldNotFound($this->arguments['name']);
}
} | php | protected function initializeFieldName()
{
$this->fieldName = $this->arguments['field'];
if (empty($this->fieldName)
&& $this->fieldService->fieldContextExists()
) {
$this->fieldName = $this->fieldService
->getCurrentField()
->getName();
}
if (null === $this->fieldName) {
throw EntryNotFoundException::classViewHelperFieldNotFound($this->arguments['name']);
}
} | [
"protected",
"function",
"initializeFieldName",
"(",
")",
"{",
"$",
"this",
"->",
"fieldName",
"=",
"$",
"this",
"->",
"arguments",
"[",
"'field'",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"fieldName",
")",
"&&",
"$",
"this",
"->",
"fieldS... | Fetches the name of the field which should refer to this class. It can
either be a given value, or be empty if the ViewHelper is used inside a
`FieldViewHelper`.
@throws EntryNotFoundException | [
"Fetches",
"the",
"name",
"of",
"the",
"field",
"which",
"should",
"refer",
"to",
"this",
"class",
".",
"It",
"can",
"either",
"be",
"a",
"given",
"value",
"or",
"be",
"empty",
"if",
"the",
"ViewHelper",
"is",
"used",
"inside",
"a",
"FieldViewHelper",
".... | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/ClassViewHelper.php#L142-L157 | train |
romm/formz | Classes/ViewHelpers/ClassViewHelper.php | ClassViewHelper.initializeClassValue | protected function initializeClassValue()
{
$classesConfiguration = $this->formService
->getFormObject()
->getConfiguration()
->getRootConfiguration()
->getView()
->getClasses();
/** @var ViewClass $class */
$class = ObjectAccess::getProperty($classesConfiguration, $this->classNameSpace);
if (false === $class->hasItem($this->className)) {
throw UnregisteredConfigurationException::cssClassNameNotFound($this->arguments['name'], $this->classNameSpace, $this->className);
}
$this->classValue = $class->getItem($this->className);
} | php | protected function initializeClassValue()
{
$classesConfiguration = $this->formService
->getFormObject()
->getConfiguration()
->getRootConfiguration()
->getView()
->getClasses();
/** @var ViewClass $class */
$class = ObjectAccess::getProperty($classesConfiguration, $this->classNameSpace);
if (false === $class->hasItem($this->className)) {
throw UnregisteredConfigurationException::cssClassNameNotFound($this->arguments['name'], $this->classNameSpace, $this->className);
}
$this->classValue = $class->getItem($this->className);
} | [
"protected",
"function",
"initializeClassValue",
"(",
")",
"{",
"$",
"classesConfiguration",
"=",
"$",
"this",
"->",
"formService",
"->",
"getFormObject",
"(",
")",
"->",
"getConfiguration",
"(",
")",
"->",
"getRootConfiguration",
"(",
")",
"->",
"getView",
"(",... | Fetches the corresponding value of this class, which was defined in
TypoScript.
@throws UnregisteredConfigurationException | [
"Fetches",
"the",
"corresponding",
"value",
"of",
"this",
"class",
"which",
"was",
"defined",
"in",
"TypoScript",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/ClassViewHelper.php#L165-L182 | train |
romm/formz | Classes/ViewHelpers/ClassViewHelper.php | ClassViewHelper.getFormResultClass | protected function getFormResultClass()
{
$result = '';
$formObject = $this->formService->getFormObject();
if ($formObject->formWasSubmitted()
&& $formObject->hasFormResult()
) {
$fieldResult = $formObject->getFormResult()->forProperty($this->fieldName);
$result = $this->getPropertyResultClass($fieldResult);
}
return $result;
} | php | protected function getFormResultClass()
{
$result = '';
$formObject = $this->formService->getFormObject();
if ($formObject->formWasSubmitted()
&& $formObject->hasFormResult()
) {
$fieldResult = $formObject->getFormResult()->forProperty($this->fieldName);
$result = $this->getPropertyResultClass($fieldResult);
}
return $result;
} | [
"protected",
"function",
"getFormResultClass",
"(",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"formObject",
"=",
"$",
"this",
"->",
"formService",
"->",
"getFormObject",
"(",
")",
";",
"if",
"(",
"$",
"formObject",
"->",
"formWasSubmitted",
"(",
")",
... | Checks if the form was submitted, then parses its result to handle
classes depending on TypoScript configuration.
@return string | [
"Checks",
"if",
"the",
"form",
"was",
"submitted",
"then",
"parses",
"its",
"result",
"to",
"handle",
"classes",
"depending",
"on",
"TypoScript",
"configuration",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/ClassViewHelper.php#L190-L203 | train |
romm/formz | Classes/Condition/Parser/ConditionParserFactory.php | ConditionParserFactory.parse | public function parse(ActivationInterface $activation)
{
$hash = 'condition-tree-' .
HashService::get()->getHash(serialize([
$activation->getExpression(),
$activation->getConditions()
]));
if (false === array_key_exists($hash, $this->trees)) {
$this->trees[$hash] = $this->getConditionTree($hash, $activation);
}
return $this->trees[$hash];
} | php | public function parse(ActivationInterface $activation)
{
$hash = 'condition-tree-' .
HashService::get()->getHash(serialize([
$activation->getExpression(),
$activation->getConditions()
]));
if (false === array_key_exists($hash, $this->trees)) {
$this->trees[$hash] = $this->getConditionTree($hash, $activation);
}
return $this->trees[$hash];
} | [
"public",
"function",
"parse",
"(",
"ActivationInterface",
"$",
"activation",
")",
"{",
"$",
"hash",
"=",
"'condition-tree-'",
".",
"HashService",
"::",
"get",
"(",
")",
"->",
"getHash",
"(",
"serialize",
"(",
"[",
"$",
"activation",
"->",
"getExpression",
"... | Will parse a condition expression, to build a tree containing one or
several nodes which represent the condition. See the class
`ConditionTree` for more information.
@param ActivationInterface $activation
@return ConditionTree | [
"Will",
"parse",
"a",
"condition",
"expression",
"to",
"build",
"a",
"tree",
"containing",
"one",
"or",
"several",
"nodes",
"which",
"represent",
"the",
"condition",
".",
"See",
"the",
"class",
"ConditionTree",
"for",
"more",
"information",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Condition/Parser/ConditionParserFactory.php#L43-L56 | train |
QuickenLoans/mcp-panthor | src/Bootstrap/RouteLoader.php | RouteLoader.loadRoutes | public function loadRoutes(App $slim, array $routes)
{
foreach ($routes as $name => $details) {
if ($children = $this->nullable('routes', $details)) {
$middlewares = $this->nullable('stack', $details) ?: [];
$prefix = $this->nullable('route', $details) ?: '';
$loader = [$this, 'loadRoutes'];
$groupLoader = function () use ($slim, $children, $loader) {
$loader($slim, $children);
};
$group = $slim->group($prefix, $groupLoader);
while ($mw = array_pop($middlewares)) {
$group->add($mw);
}
} else {
$this->loadRoute($slim, $name, $details);
}
}
} | php | public function loadRoutes(App $slim, array $routes)
{
foreach ($routes as $name => $details) {
if ($children = $this->nullable('routes', $details)) {
$middlewares = $this->nullable('stack', $details) ?: [];
$prefix = $this->nullable('route', $details) ?: '';
$loader = [$this, 'loadRoutes'];
$groupLoader = function () use ($slim, $children, $loader) {
$loader($slim, $children);
};
$group = $slim->group($prefix, $groupLoader);
while ($mw = array_pop($middlewares)) {
$group->add($mw);
}
} else {
$this->loadRoute($slim, $name, $details);
}
}
} | [
"public",
"function",
"loadRoutes",
"(",
"App",
"$",
"slim",
",",
"array",
"$",
"routes",
")",
"{",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"name",
"=>",
"$",
"details",
")",
"{",
"if",
"(",
"$",
"children",
"=",
"$",
"this",
"->",
"nullable",
"(... | Load routes into the application.
@param App $slim
@param array $routes
@return null | [
"Load",
"routes",
"into",
"the",
"application",
"."
] | b73e22d83d21b8ed4296bee6aebc66c8b07f292c | https://github.com/QuickenLoans/mcp-panthor/blob/b73e22d83d21b8ed4296bee6aebc66c8b07f292c/src/Bootstrap/RouteLoader.php#L79-L100 | train |
QuickenLoans/mcp-panthor | src/Bootstrap/RouteLoader.php | RouteLoader.loadRoute | private function loadRoute(App $slim, $name, array $details)
{
$methods = $this->methods($details);
$pattern = $this->nullable('route', $details);
$stack = $this->nullable('stack', $details) ?: [];
$controller = array_pop($stack);
$route = $slim->map($methods, $pattern, $controller);
$route->setName($name);
while ($middleware = array_pop($stack)) {
$route->add($middleware);
}
return $route;
} | php | private function loadRoute(App $slim, $name, array $details)
{
$methods = $this->methods($details);
$pattern = $this->nullable('route', $details);
$stack = $this->nullable('stack', $details) ?: [];
$controller = array_pop($stack);
$route = $slim->map($methods, $pattern, $controller);
$route->setName($name);
while ($middleware = array_pop($stack)) {
$route->add($middleware);
}
return $route;
} | [
"private",
"function",
"loadRoute",
"(",
"App",
"$",
"slim",
",",
"$",
"name",
",",
"array",
"$",
"details",
")",
"{",
"$",
"methods",
"=",
"$",
"this",
"->",
"methods",
"(",
"$",
"details",
")",
";",
"$",
"pattern",
"=",
"$",
"this",
"->",
"nullab... | Load a route into the application.
@param App $slim
@param string $name
@param array $details
@return RouteInterface | [
"Load",
"a",
"route",
"into",
"the",
"application",
"."
] | b73e22d83d21b8ed4296bee6aebc66c8b07f292c | https://github.com/QuickenLoans/mcp-panthor/blob/b73e22d83d21b8ed4296bee6aebc66c8b07f292c/src/Bootstrap/RouteLoader.php#L111-L127 | train |
QoboLtd/cakephp-utils | src/ErrorTrait.php | ErrorTrait.fail | protected function fail($message): void
{
if (is_string($message)) {
$message = new RuntimeException($message);
}
$this->errors[] = $message->getMessage();
throw $message;
} | php | protected function fail($message): void
{
if (is_string($message)) {
$message = new RuntimeException($message);
}
$this->errors[] = $message->getMessage();
throw $message;
} | [
"protected",
"function",
"fail",
"(",
"$",
"message",
")",
":",
"void",
"{",
"if",
"(",
"is_string",
"(",
"$",
"message",
")",
")",
"{",
"$",
"message",
"=",
"new",
"RuntimeException",
"(",
"$",
"message",
")",
";",
"}",
"$",
"this",
"->",
"errors",
... | Fail execution with a given error
* Adds error to the list of errors
* Throws an exception with the error message
@todo Switch to Throwable once the move to PHP 7 is complete
@throws \RuntimeException if error message given as a string
@param string|\Exception $message Error message or exception
@return void | [
"Fail",
"execution",
"with",
"a",
"given",
"error"
] | 4b07a3e6f2e611e7c6909c913e6166d280f3c751 | https://github.com/QoboLtd/cakephp-utils/blob/4b07a3e6f2e611e7c6909c913e6166d280f3c751/src/ErrorTrait.php#L47-L54 | train |
WouterSioen/sir-trevor-php | src/Sioen/JsonToHtml.php | JsonToHtml.toHtml | public function toHtml($json)
{
// convert the json to an associative array
$input = json_decode($json, true);
$html = '';
// loop trough the data blocks
foreach ($input['data'] as $block) {
$html .= $this->convert(new SirTrevorBlock($block['type'], $block['data']));
}
return $html;
} | php | public function toHtml($json)
{
// convert the json to an associative array
$input = json_decode($json, true);
$html = '';
// loop trough the data blocks
foreach ($input['data'] as $block) {
$html .= $this->convert(new SirTrevorBlock($block['type'], $block['data']));
}
return $html;
} | [
"public",
"function",
"toHtml",
"(",
"$",
"json",
")",
"{",
"// convert the json to an associative array",
"$",
"input",
"=",
"json_decode",
"(",
"$",
"json",
",",
"true",
")",
";",
"$",
"html",
"=",
"''",
";",
"// loop trough the data blocks",
"foreach",
"(",
... | Converts the outputted json from Sir Trevor to html
@param string $json
@return string | [
"Converts",
"the",
"outputted",
"json",
"from",
"Sir",
"Trevor",
"to",
"html"
] | f1dcae3454617366b685f80259016f9b87f7f9a9 | https://github.com/WouterSioen/sir-trevor-php/blob/f1dcae3454617366b685f80259016f9b87f7f9a9/src/Sioen/JsonToHtml.php#L32-L44 | train |
WouterSioen/sir-trevor-php | src/Sioen/JsonToHtml.php | JsonToHtml.convert | private function convert(SirTrevorBlock $block)
{
foreach ($this->converters as $converter) {
if ($converter->matches($block->getType())) {
return $converter->toHtml($block->getData());
}
}
} | php | private function convert(SirTrevorBlock $block)
{
foreach ($this->converters as $converter) {
if ($converter->matches($block->getType())) {
return $converter->toHtml($block->getData());
}
}
} | [
"private",
"function",
"convert",
"(",
"SirTrevorBlock",
"$",
"block",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"converters",
"as",
"$",
"converter",
")",
"{",
"if",
"(",
"$",
"converter",
"->",
"matches",
"(",
"$",
"block",
"->",
"getType",
"(",
"... | Converts on array to an html string
@param SirTrevorBlock $block
@return string | [
"Converts",
"on",
"array",
"to",
"an",
"html",
"string"
] | f1dcae3454617366b685f80259016f9b87f7f9a9 | https://github.com/WouterSioen/sir-trevor-php/blob/f1dcae3454617366b685f80259016f9b87f7f9a9/src/Sioen/JsonToHtml.php#L53-L60 | train |
lotfio/ouch | src/Ouch/Reporter.php | Reporter.on | public function on() : self
{
$this->handler->setErrorHandler();
$this->handler->setExceptionHandler();
$this->handler->setFatalHandler();
return $this;
} | php | public function on() : self
{
$this->handler->setErrorHandler();
$this->handler->setExceptionHandler();
$this->handler->setFatalHandler();
return $this;
} | [
"public",
"function",
"on",
"(",
")",
":",
"self",
"{",
"$",
"this",
"->",
"handler",
"->",
"setErrorHandler",
"(",
")",
";",
"$",
"this",
"->",
"handler",
"->",
"setExceptionHandler",
"(",
")",
";",
"$",
"this",
"->",
"handler",
"->",
"setFatalHandler",... | enable ouch error handler.
@return $this | [
"enable",
"ouch",
"error",
"handler",
"."
] | 2d82d936a58f39cba005696107401d5a809c542d | https://github.com/lotfio/ouch/blob/2d82d936a58f39cba005696107401d5a809c542d/src/Ouch/Reporter.php#L38-L45 | train |
alexandresalome/PHP-Selenium | src/Selenium/Driver.php | Driver.start | public function start($type = '*firefox', $startUrl = 'http://localhost')
{
if (null !== $this->sessionId) {
throw new Exception("Session already started");
}
$response = $this->doExecute('getNewBrowserSession', $type, $startUrl);
if (preg_match('/^OK,(.*)$/', $response, $vars)) {
$this->sessionId = $vars[1];
} else {
throw new Exception("Invalid response from server : $response");
}
} | php | public function start($type = '*firefox', $startUrl = 'http://localhost')
{
if (null !== $this->sessionId) {
throw new Exception("Session already started");
}
$response = $this->doExecute('getNewBrowserSession', $type, $startUrl);
if (preg_match('/^OK,(.*)$/', $response, $vars)) {
$this->sessionId = $vars[1];
} else {
throw new Exception("Invalid response from server : $response");
}
} | [
"public",
"function",
"start",
"(",
"$",
"type",
"=",
"'*firefox'",
",",
"$",
"startUrl",
"=",
"'http://localhost'",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"sessionId",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Session already started\""... | Starts a new session.
@param string $type Type of browser
@param string $startUrl Start URL for the browser | [
"Starts",
"a",
"new",
"session",
"."
] | f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6 | https://github.com/alexandresalome/PHP-Selenium/blob/f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6/src/Selenium/Driver.php#L58-L71 | train |
alexandresalome/PHP-Selenium | src/Selenium/Driver.php | Driver.getString | public function getString($command, $target = null, $value = null)
{
$result = $this->doExecute($command, $target, $value);
if (!preg_match('/^OK,/', $result)) {
throw new Exception("Unexpected response from Selenium server : ".$result);
}
return strlen($result) > 3 ? substr($result, 3) : '';
} | php | public function getString($command, $target = null, $value = null)
{
$result = $this->doExecute($command, $target, $value);
if (!preg_match('/^OK,/', $result)) {
throw new Exception("Unexpected response from Selenium server : ".$result);
}
return strlen($result) > 3 ? substr($result, 3) : '';
} | [
"public",
"function",
"getString",
"(",
"$",
"command",
",",
"$",
"target",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"doExecute",
"(",
"$",
"command",
",",
"$",
"target",
",",
"$",
"value",
")",
... | Executes a command on the server and returns a string.
@param string $command The command to execute
@param string $target First parameter
@param string $value Second parameter
@return string The result of the command as a string | [
"Executes",
"a",
"command",
"on",
"the",
"server",
"and",
"returns",
"a",
"string",
"."
] | f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6 | https://github.com/alexandresalome/PHP-Selenium/blob/f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6/src/Selenium/Driver.php#L101-L110 | train |
alexandresalome/PHP-Selenium | src/Selenium/Driver.php | Driver.getStringArray | public function getStringArray($command, $target = null, $value = null)
{
$string = $this->getString($command, $target, $value);
$results = preg_split('/(?<!\\\),/', $string);
foreach ($results as &$result) {
$result = str_replace('\,', ',', $result);
}
return $results;
} | php | public function getStringArray($command, $target = null, $value = null)
{
$string = $this->getString($command, $target, $value);
$results = preg_split('/(?<!\\\),/', $string);
foreach ($results as &$result) {
$result = str_replace('\,', ',', $result);
}
return $results;
} | [
"public",
"function",
"getStringArray",
"(",
"$",
"command",
",",
"$",
"target",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"getString",
"(",
"$",
"command",
",",
"$",
"target",
",",
"$",
"value",
... | Executes a command on the server and returns an array of string.
@param string $command Command to execute
@param string $target First parameter
@param string $value Second parameter
@return array The result of the command as an array of string | [
"Executes",
"a",
"command",
"on",
"the",
"server",
"and",
"returns",
"an",
"array",
"of",
"string",
"."
] | f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6 | https://github.com/alexandresalome/PHP-Selenium/blob/f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6/src/Selenium/Driver.php#L121-L131 | train |
alexandresalome/PHP-Selenium | src/Selenium/Driver.php | Driver.getNumber | public function getNumber($command, $target = null, $value = null)
{
$string = $this->getString($command, $target, $value);
return (int) $string;
} | php | public function getNumber($command, $target = null, $value = null)
{
$string = $this->getString($command, $target, $value);
return (int) $string;
} | [
"public",
"function",
"getNumber",
"(",
"$",
"command",
",",
"$",
"target",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"getString",
"(",
"$",
"command",
",",
"$",
"target",
",",
"$",
"value",
")",
... | Executes a command on the server and returns a number.
@param string $command The command to execute
@param string $target First parameter
@param string $value Second parameter
@return int The result of the command as a number | [
"Executes",
"a",
"command",
"on",
"the",
"server",
"and",
"returns",
"a",
"number",
"."
] | f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6 | https://github.com/alexandresalome/PHP-Selenium/blob/f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6/src/Selenium/Driver.php#L142-L147 | train |
alexandresalome/PHP-Selenium | src/Selenium/Driver.php | Driver.getBoolean | public function getBoolean($command, $target = null, $value = null)
{
$string = $this->getString($command, $target, $value);
return $string == 'true';
} | php | public function getBoolean($command, $target = null, $value = null)
{
$string = $this->getString($command, $target, $value);
return $string == 'true';
} | [
"public",
"function",
"getBoolean",
"(",
"$",
"command",
",",
"$",
"target",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"getString",
"(",
"$",
"command",
",",
"$",
"target",
",",
"$",
"value",
")",... | Executes a command on the server and returns a boolean.
@param string $command The command to execute
@param string $target First parameter
@param string $value Second parameter
@return boolean The result of the command as a boolean | [
"Executes",
"a",
"command",
"on",
"the",
"server",
"and",
"returns",
"a",
"boolean",
"."
] | f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6 | https://github.com/alexandresalome/PHP-Selenium/blob/f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6/src/Selenium/Driver.php#L158-L163 | train |
alexandresalome/PHP-Selenium | src/Selenium/Driver.php | Driver.stop | public function stop()
{
if (null === $this->sessionId) {
throw new Exception("Session not started");
}
$this->doExecute('testComplete');
$this->sessionId = null;
} | php | public function stop()
{
if (null === $this->sessionId) {
throw new Exception("Session not started");
}
$this->doExecute('testComplete');
$this->sessionId = null;
} | [
"public",
"function",
"stop",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"sessionId",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Session not started\"",
")",
";",
"}",
"$",
"this",
"->",
"doExecute",
"(",
"'testComplete'",
")",
";",
... | Stops the session.
@return void | [
"Stops",
"the",
"session",
"."
] | f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6 | https://github.com/alexandresalome/PHP-Selenium/blob/f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6/src/Selenium/Driver.php#L170-L178 | train |
alexandresalome/PHP-Selenium | src/Selenium/Driver.php | Driver.doExecute | protected function doExecute($command, $target = null, $value = null)
{
$postFields = array();
$query = array('cmd' => $command);
if ($target !== null) {
$postFields[1] = $target;
}
if ($value !== null) {
$postFields[2] = $value;
}
if (null !== $this->sessionId) {
$query['sessionId'] = $this->sessionId;
}
$query = http_build_query($query);
$url = $this->url.'?'.$query;
//open connection
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, count($postFields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$curlErrno = curl_errno($ch);
curl_close($ch);
if ($curlErrno > 0) {
throw new Exception("Unable to connect ! ");
}
if (false === $result) {
throw new Exception("Connection refused");
}
return $result;
} | php | protected function doExecute($command, $target = null, $value = null)
{
$postFields = array();
$query = array('cmd' => $command);
if ($target !== null) {
$postFields[1] = $target;
}
if ($value !== null) {
$postFields[2] = $value;
}
if (null !== $this->sessionId) {
$query['sessionId'] = $this->sessionId;
}
$query = http_build_query($query);
$url = $this->url.'?'.$query;
//open connection
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, count($postFields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$curlErrno = curl_errno($ch);
curl_close($ch);
if ($curlErrno > 0) {
throw new Exception("Unable to connect ! ");
}
if (false === $result) {
throw new Exception("Connection refused");
}
return $result;
} | [
"protected",
"function",
"doExecute",
"(",
"$",
"command",
",",
"$",
"target",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"postFields",
"=",
"array",
"(",
")",
";",
"$",
"query",
"=",
"array",
"(",
"'cmd'",
"=>",
"$",
"command",
")... | Executes a raw command on the server and integrate the current session
identifier if available.
@param string $command Command to execute
@param string $target First argument
@param string $value Second argument
@return string The raw result of the command | [
"Executes",
"a",
"raw",
"command",
"on",
"the",
"server",
"and",
"integrate",
"the",
"current",
"session",
"identifier",
"if",
"available",
"."
] | f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6 | https://github.com/alexandresalome/PHP-Selenium/blob/f737b6e396d9d6e2ee5092794bdc42a2ff5ef2c6/src/Selenium/Driver.php#L190-L230 | train |
QuickenLoans/mcp-panthor | src/ErrorHandling/StacktraceFormatterTrait.php | StacktraceFormatterTrait.unpackThrowables | private function unpackThrowables($throwable)
{
if (!$throwable instanceof Throwable) {
return [];
}
$throwables = [$throwable];
while ($throwable = $throwable->getPrevious()) {
$throwables[] = $throwable;
}
return $throwables;
} | php | private function unpackThrowables($throwable)
{
if (!$throwable instanceof Throwable) {
return [];
}
$throwables = [$throwable];
while ($throwable = $throwable->getPrevious()) {
$throwables[] = $throwable;
}
return $throwables;
} | [
"private",
"function",
"unpackThrowables",
"(",
"$",
"throwable",
")",
"{",
"if",
"(",
"!",
"$",
"throwable",
"instanceof",
"Throwable",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"throwables",
"=",
"[",
"$",
"throwable",
"]",
";",
"while",
"(",
"$",... | Unpack nested throwables into a flat array
@param Throwable$throwable
@return Throwable[] | [
"Unpack",
"nested",
"throwables",
"into",
"a",
"flat",
"array"
] | b73e22d83d21b8ed4296bee6aebc66c8b07f292c | https://github.com/QuickenLoans/mcp-panthor/blob/b73e22d83d21b8ed4296bee6aebc66c8b07f292c/src/ErrorHandling/StacktraceFormatterTrait.php#L42-L54 | train |
romm/formz | Classes/ViewHelpers/Slot/RenderViewHelper.php | RenderViewHelper.renderStatic | public static function renderStatic(array $arguments, Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
/** @var FieldViewHelperService $fieldService */
$fieldService = Core::instantiate(FieldViewHelperService::class);
if (false === $fieldService->fieldContextExists()) {
throw ContextNotFoundException::slotRenderViewHelperFieldContextNotFound();
}
/** @var SlotViewHelperService $slotService */
$slotService = Core::instantiate(SlotViewHelperService::class);
$slotName = $arguments['slot'];
$result = '';
if ($slotService->hasSlot($slotName)) {
$currentVariables = version_compare(VersionNumberUtility::getCurrentTypo3Version(), '8.0.0', '<')
? $renderingContext->getTemplateVariableContainer()->getAll()
: $renderingContext->getVariableProvider()->getAll();
ArrayUtility::mergeRecursiveWithOverrule($currentVariables, $arguments['arguments']);
$slotService->addTemplateVariables($slotName, $currentVariables);
$slotClosure = $slotService->getSlotClosure($slotName);
$result = $slotClosure();
$slotService->restoreTemplateVariables($slotName);
}
return $result;
} | php | public static function renderStatic(array $arguments, Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
/** @var FieldViewHelperService $fieldService */
$fieldService = Core::instantiate(FieldViewHelperService::class);
if (false === $fieldService->fieldContextExists()) {
throw ContextNotFoundException::slotRenderViewHelperFieldContextNotFound();
}
/** @var SlotViewHelperService $slotService */
$slotService = Core::instantiate(SlotViewHelperService::class);
$slotName = $arguments['slot'];
$result = '';
if ($slotService->hasSlot($slotName)) {
$currentVariables = version_compare(VersionNumberUtility::getCurrentTypo3Version(), '8.0.0', '<')
? $renderingContext->getTemplateVariableContainer()->getAll()
: $renderingContext->getVariableProvider()->getAll();
ArrayUtility::mergeRecursiveWithOverrule($currentVariables, $arguments['arguments']);
$slotService->addTemplateVariables($slotName, $currentVariables);
$slotClosure = $slotService->getSlotClosure($slotName);
$result = $slotClosure();
$slotService->restoreTemplateVariables($slotName);
}
return $result;
} | [
"public",
"static",
"function",
"renderStatic",
"(",
"array",
"$",
"arguments",
",",
"Closure",
"$",
"renderChildrenClosure",
",",
"RenderingContextInterface",
"$",
"renderingContext",
")",
"{",
"/** @var FieldViewHelperService $fieldService */",
"$",
"fieldService",
"=",
... | Will render the slot with the given name, only if the slot is found.
@inheritdoc | [
"Will",
"render",
"the",
"slot",
"with",
"the",
"given",
"name",
"only",
"if",
"the",
"slot",
"is",
"found",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/Slot/RenderViewHelper.php#L63-L93 | train |
QuickenLoans/mcp-panthor | src/ErrorHandling/ExceptionHandler.php | ExceptionHandler.handle | public function handle($throwable)
{
if ($throwable instanceof Exception) {
$response = $this->handler->handleException($this->defaultRequest, $this->defaultResponse, $throwable);
} elseif ($throwable instanceof Throwable) {
$response = $this->handler->handleThrowable($this->defaultRequest, $this->defaultResponse, $throwable);
} else {
return false;
}
if ($response instanceof ResponseInterface) {
$this->renderResponse($response);
return true;
} else {
return false;
}
} | php | public function handle($throwable)
{
if ($throwable instanceof Exception) {
$response = $this->handler->handleException($this->defaultRequest, $this->defaultResponse, $throwable);
} elseif ($throwable instanceof Throwable) {
$response = $this->handler->handleThrowable($this->defaultRequest, $this->defaultResponse, $throwable);
} else {
return false;
}
if ($response instanceof ResponseInterface) {
$this->renderResponse($response);
return true;
} else {
return false;
}
} | [
"public",
"function",
"handle",
"(",
"$",
"throwable",
")",
"{",
"if",
"(",
"$",
"throwable",
"instanceof",
"Exception",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"handler",
"->",
"handleException",
"(",
"$",
"this",
"->",
"defaultRequest",
",",
... | Handle a throwable, and return whether it was handled and the remaining stack should be aborted.
@param Exception|Throwable|mixed $throwable
@return bool | [
"Handle",
"a",
"throwable",
"and",
"return",
"whether",
"it",
"was",
"handled",
"and",
"the",
"remaining",
"stack",
"should",
"be",
"aborted",
"."
] | b73e22d83d21b8ed4296bee6aebc66c8b07f292c | https://github.com/QuickenLoans/mcp-panthor/blob/b73e22d83d21b8ed4296bee6aebc66c8b07f292c/src/ErrorHandling/ExceptionHandler.php#L54-L70 | train |
romm/formz | Classes/ViewHelpers/FieldViewHelper.php | FieldViewHelper.storeViewDataLegacy | protected function storeViewDataLegacy()
{
$originalArguments = [];
$variableProvider = $this->getVariableProvider();
foreach (self::$reservedVariablesNames as $key) {
if ($variableProvider->exists($key)) {
$originalArguments[$key] = $variableProvider->get($key);
}
}
$viewHelperVariableContainer = $this->renderingContext->getViewHelperVariableContainer();
$currentView = $viewHelperVariableContainer->getView();
return function (array $templateArguments) use ($originalArguments, $variableProvider, $viewHelperVariableContainer, $currentView) {
$viewHelperVariableContainer->setView($currentView);
/*
* Cleaning up the variables in the provider: the original
* values are restored to make the provider like it was before
* the field rendering started.
*/
foreach ($variableProvider->getAllIdentifiers() as $identifier) {
if (array_key_exists($identifier, $templateArguments)) {
$variableProvider->remove($identifier);
}
}
foreach ($originalArguments as $key => $value) {
if ($variableProvider->exists($key)) {
$variableProvider->remove($key);
}
$variableProvider->add($key, $value);
}
};
} | php | protected function storeViewDataLegacy()
{
$originalArguments = [];
$variableProvider = $this->getVariableProvider();
foreach (self::$reservedVariablesNames as $key) {
if ($variableProvider->exists($key)) {
$originalArguments[$key] = $variableProvider->get($key);
}
}
$viewHelperVariableContainer = $this->renderingContext->getViewHelperVariableContainer();
$currentView = $viewHelperVariableContainer->getView();
return function (array $templateArguments) use ($originalArguments, $variableProvider, $viewHelperVariableContainer, $currentView) {
$viewHelperVariableContainer->setView($currentView);
/*
* Cleaning up the variables in the provider: the original
* values are restored to make the provider like it was before
* the field rendering started.
*/
foreach ($variableProvider->getAllIdentifiers() as $identifier) {
if (array_key_exists($identifier, $templateArguments)) {
$variableProvider->remove($identifier);
}
}
foreach ($originalArguments as $key => $value) {
if ($variableProvider->exists($key)) {
$variableProvider->remove($key);
}
$variableProvider->add($key, $value);
}
};
} | [
"protected",
"function",
"storeViewDataLegacy",
"(",
")",
"{",
"$",
"originalArguments",
"=",
"[",
"]",
";",
"$",
"variableProvider",
"=",
"$",
"this",
"->",
"getVariableProvider",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"reservedVariablesNames",
"as... | Temporary solution for TYPO3 6.2 to 7.6 that will store the current view
variables, to be able to restore them later.
A callback function is returned; it will be called once the field layout
view was processed, and will restore all the view data.
@return \Closure
@deprecated Will be deleted when TYPO3 7.6 is not supported anymore. | [
"Temporary",
"solution",
"for",
"TYPO3",
"6",
".",
"2",
"to",
"7",
".",
"6",
"that",
"will",
"store",
"the",
"current",
"view",
"variables",
"to",
"be",
"able",
"to",
"restore",
"them",
"later",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/FieldViewHelper.php#L233-L270 | train |
romm/formz | Classes/ViewHelpers/FieldViewHelper.php | FieldViewHelper.injectFieldInService | protected function injectFieldInService($fieldName)
{
$formObject = $this->formService->getFormObject();
$formConfiguration = $formObject->getConfiguration();
if (false === is_string($fieldName)) {
throw InvalidArgumentTypeException::fieldViewHelperInvalidTypeNameArgument();
} elseif (false === $formConfiguration->hasField($fieldName)) {
throw PropertyNotAccessibleException::fieldViewHelperFieldNotAccessibleInForm($formObject, $fieldName);
}
$this->fieldService->setCurrentField($formConfiguration->getField($fieldName));
} | php | protected function injectFieldInService($fieldName)
{
$formObject = $this->formService->getFormObject();
$formConfiguration = $formObject->getConfiguration();
if (false === is_string($fieldName)) {
throw InvalidArgumentTypeException::fieldViewHelperInvalidTypeNameArgument();
} elseif (false === $formConfiguration->hasField($fieldName)) {
throw PropertyNotAccessibleException::fieldViewHelperFieldNotAccessibleInForm($formObject, $fieldName);
}
$this->fieldService->setCurrentField($formConfiguration->getField($fieldName));
} | [
"protected",
"function",
"injectFieldInService",
"(",
"$",
"fieldName",
")",
"{",
"$",
"formObject",
"=",
"$",
"this",
"->",
"formService",
"->",
"getFormObject",
"(",
")",
";",
"$",
"formConfiguration",
"=",
"$",
"formObject",
"->",
"getConfiguration",
"(",
"... | Will check that the given field exists in the current form definition and
inject it in the `FieldService` as `currentField`.
Throws an error if the field is not found or incorrect.
@param string $fieldName
@throws InvalidArgumentTypeException
@throws PropertyNotAccessibleException | [
"Will",
"check",
"that",
"the",
"given",
"field",
"exists",
"in",
"the",
"current",
"form",
"definition",
"and",
"inject",
"it",
"in",
"the",
"FieldService",
"as",
"currentField",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/FieldViewHelper.php#L282-L294 | train |
romm/formz | Classes/ViewHelpers/FieldViewHelper.php | FieldViewHelper.getLayout | protected function getLayout(View $viewConfiguration)
{
$layout = $this->arguments['layout'];
if (false === is_string($layout)) {
throw InvalidArgumentTypeException::invalidTypeNameArgumentFieldViewHelper($layout);
}
list($layoutName, $templateName) = GeneralUtility::trimExplode('.', $layout);
if (empty($templateName)) {
$templateName = 'default';
}
if (empty($layoutName)) {
throw InvalidArgumentValueException::fieldViewHelperEmptyLayout();
}
if (false === $viewConfiguration->hasLayout($layoutName)) {
throw EntryNotFoundException::fieldViewHelperLayoutNotFound($layout);
}
if (false === $viewConfiguration->getLayout($layoutName)->hasItem($templateName)) {
throw EntryNotFoundException::fieldViewHelperLayoutItemNotFound($layout, $templateName);
}
return $viewConfiguration->getLayout($layoutName)->getItem($templateName);
} | php | protected function getLayout(View $viewConfiguration)
{
$layout = $this->arguments['layout'];
if (false === is_string($layout)) {
throw InvalidArgumentTypeException::invalidTypeNameArgumentFieldViewHelper($layout);
}
list($layoutName, $templateName) = GeneralUtility::trimExplode('.', $layout);
if (empty($templateName)) {
$templateName = 'default';
}
if (empty($layoutName)) {
throw InvalidArgumentValueException::fieldViewHelperEmptyLayout();
}
if (false === $viewConfiguration->hasLayout($layoutName)) {
throw EntryNotFoundException::fieldViewHelperLayoutNotFound($layout);
}
if (false === $viewConfiguration->getLayout($layoutName)->hasItem($templateName)) {
throw EntryNotFoundException::fieldViewHelperLayoutItemNotFound($layout, $templateName);
}
return $viewConfiguration->getLayout($layoutName)->getItem($templateName);
} | [
"protected",
"function",
"getLayout",
"(",
"View",
"$",
"viewConfiguration",
")",
"{",
"$",
"layout",
"=",
"$",
"this",
"->",
"arguments",
"[",
"'layout'",
"]",
";",
"if",
"(",
"false",
"===",
"is_string",
"(",
"$",
"layout",
")",
")",
"{",
"throw",
"I... | Returns the layout instance used by this field.
@param View $viewConfiguration
@return Layout
@throws EntryNotFoundException
@throws InvalidArgumentTypeException
@throws InvalidArgumentValueException | [
"Returns",
"the",
"layout",
"instance",
"used",
"by",
"this",
"field",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/FieldViewHelper.php#L305-L332 | train |
romm/formz | Classes/ViewHelpers/FieldViewHelper.php | FieldViewHelper.getTemplateArguments | protected function getTemplateArguments()
{
$templateArguments = $this->arguments['arguments'] ?: [];
ArrayUtility::mergeRecursiveWithOverrule($templateArguments, $this->fieldService->getFieldOptions());
return $templateArguments;
} | php | protected function getTemplateArguments()
{
$templateArguments = $this->arguments['arguments'] ?: [];
ArrayUtility::mergeRecursiveWithOverrule($templateArguments, $this->fieldService->getFieldOptions());
return $templateArguments;
} | [
"protected",
"function",
"getTemplateArguments",
"(",
")",
"{",
"$",
"templateArguments",
"=",
"$",
"this",
"->",
"arguments",
"[",
"'arguments'",
"]",
"?",
":",
"[",
"]",
";",
"ArrayUtility",
"::",
"mergeRecursiveWithOverrule",
"(",
"$",
"templateArguments",
",... | Merging the arguments with the ones registered with the
`OptionViewHelper`.
@return array | [
"Merging",
"the",
"arguments",
"with",
"the",
"ones",
"registered",
"with",
"the",
"OptionViewHelper",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/ViewHelpers/FieldViewHelper.php#L340-L346 | train |
QoboLtd/cakephp-utils | src/Utility/Convert.php | Convert.valueToBytes | public static function valueToBytes($value): int
{
if (is_int($value)) {
return $value;
}
$value = trim($value);
// Native PHP check for digits in string
if (ctype_digit(ltrim($value, '-'))) {
return (int)$value;
}
$signed = (substr($value, 0, 1) === '-') ? -1 : 1;
// Kilobytes
if (preg_match('/(\d+)K$/i', $value, $matches)) {
return (int)($matches[1] * $signed * 1024);
}
// Megabytes
if (preg_match('/(\d+)M$/i', $value, $matches)) {
return (int)($matches[1] * $signed * 1024 * 1024);
}
// Gigabytes
if (preg_match('/(\d+)G$/i', $value, $matches)) {
return (int)($matches[1] * $signed * 1024 * 1024 * 1024);
}
throw new InvalidArgumentException("Failed to find K, M, or G in a non-integer value [$value]");
} | php | public static function valueToBytes($value): int
{
if (is_int($value)) {
return $value;
}
$value = trim($value);
// Native PHP check for digits in string
if (ctype_digit(ltrim($value, '-'))) {
return (int)$value;
}
$signed = (substr($value, 0, 1) === '-') ? -1 : 1;
// Kilobytes
if (preg_match('/(\d+)K$/i', $value, $matches)) {
return (int)($matches[1] * $signed * 1024);
}
// Megabytes
if (preg_match('/(\d+)M$/i', $value, $matches)) {
return (int)($matches[1] * $signed * 1024 * 1024);
}
// Gigabytes
if (preg_match('/(\d+)G$/i', $value, $matches)) {
return (int)($matches[1] * $signed * 1024 * 1024 * 1024);
}
throw new InvalidArgumentException("Failed to find K, M, or G in a non-integer value [$value]");
} | [
"public",
"static",
"function",
"valueToBytes",
"(",
"$",
"value",
")",
":",
"int",
"{",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"// Native PHP... | Convert value to bytes
Convert sizes from PHP settings like post_max_size
for example 8M to integer number of bytes.
If number is integer return as is.
NOTE: This is a modified copy from qobo/cakephp-utils/config/bootstrap.php
@throws \InvalidArgumentException when cannot convert
@param string|int $value Value to convert
@return int | [
"Convert",
"value",
"to",
"bytes"
] | 4b07a3e6f2e611e7c6909c913e6166d280f3c751 | https://github.com/QoboLtd/cakephp-utils/blob/4b07a3e6f2e611e7c6909c913e6166d280f3c751/src/Utility/Convert.php#L41-L72 | train |
QoboLtd/cakephp-utils | src/Utility/Convert.php | Convert.objectToArray | public static function objectToArray($source): array
{
$result = [];
if (is_array($source)) {
return $source;
}
if (!is_object($source)) {
return $result;
}
$json = json_encode($source);
if ($json === false) {
return $result;
}
$array = json_decode($json, true);
if ($array === null) {
return $result;
}
$result = $array;
return $result;
} | php | public static function objectToArray($source): array
{
$result = [];
if (is_array($source)) {
return $source;
}
if (!is_object($source)) {
return $result;
}
$json = json_encode($source);
if ($json === false) {
return $result;
}
$array = json_decode($json, true);
if ($array === null) {
return $result;
}
$result = $array;
return $result;
} | [
"public",
"static",
"function",
"objectToArray",
"(",
"$",
"source",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"source",
")",
")",
"{",
"return",
"$",
"source",
";",
"}",
"if",
"(",
"!",
"is_object"... | Convert an object to associative array
NOTE: in case of any issues during the conversion, this
method will return an empty array and NOT throw any
exceptions.
@param mixed $source Object to convert
@return mixed[] | [
"Convert",
"an",
"object",
"to",
"associative",
"array"
] | 4b07a3e6f2e611e7c6909c913e6166d280f3c751 | https://github.com/QoboLtd/cakephp-utils/blob/4b07a3e6f2e611e7c6909c913e6166d280f3c751/src/Utility/Convert.php#L84-L108 | train |
QoboLtd/cakephp-utils | src/Utility/Convert.php | Convert.dataToJson | public static function dataToJson(string $data, bool $lint = false): stdClass
{
if ($lint) {
$linter = new JsonParser();
$linter->parse($data);
}
$data = json_decode($data);
if ($data === null) {
throw new InvalidArgumentException("Failed to decode json");
}
return (object)$data;
} | php | public static function dataToJson(string $data, bool $lint = false): stdClass
{
if ($lint) {
$linter = new JsonParser();
$linter->parse($data);
}
$data = json_decode($data);
if ($data === null) {
throw new InvalidArgumentException("Failed to decode json");
}
return (object)$data;
} | [
"public",
"static",
"function",
"dataToJson",
"(",
"string",
"$",
"data",
",",
"bool",
"$",
"lint",
"=",
"false",
")",
":",
"stdClass",
"{",
"if",
"(",
"$",
"lint",
")",
"{",
"$",
"linter",
"=",
"new",
"JsonParser",
"(",
")",
";",
"$",
"linter",
"-... | Returns the json encoded data and applies linting if necessary.
@param string $data JSON string.
@param bool $lint True to apply json linting.
@throws \Seld\JsonLint\ParsingException When linting is enabled and it fails.
@throws \InvalidArgumentException When data is not a valid JSON object and linting is not enabled.
@return \stdClass JSON object. | [
"Returns",
"the",
"json",
"encoded",
"data",
"and",
"applies",
"linting",
"if",
"necessary",
"."
] | 4b07a3e6f2e611e7c6909c913e6166d280f3c751 | https://github.com/QoboLtd/cakephp-utils/blob/4b07a3e6f2e611e7c6909c913e6166d280f3c751/src/Utility/Convert.php#L147-L160 | train |
QuickenLoans/mcp-panthor | src/Utility/URI.php | URI.getQueryParam | public function getQueryParam(UriInterface $uri, $param)
{
if (!$query = $uri->getQuery()) {
return null;
}
parse_str($query, $params);
if (!array_key_exists($param, $params)) {
return null;
}
return $params[$param];
} | php | public function getQueryParam(UriInterface $uri, $param)
{
if (!$query = $uri->getQuery()) {
return null;
}
parse_str($query, $params);
if (!array_key_exists($param, $params)) {
return null;
}
return $params[$param];
} | [
"public",
"function",
"getQueryParam",
"(",
"UriInterface",
"$",
"uri",
",",
"$",
"param",
")",
"{",
"if",
"(",
"!",
"$",
"query",
"=",
"$",
"uri",
"->",
"getQuery",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"parse_str",
"(",
"$",
"query",
",... | Get a query parameter from a PSR-7 UriInterface
@param UriInterface $uri
@param string $param
@return string|array|null | [
"Get",
"a",
"query",
"parameter",
"from",
"a",
"PSR",
"-",
"7",
"UriInterface"
] | b73e22d83d21b8ed4296bee6aebc66c8b07f292c | https://github.com/QuickenLoans/mcp-panthor/blob/b73e22d83d21b8ed4296bee6aebc66c8b07f292c/src/Utility/URI.php#L36-L48 | train |
QuickenLoans/mcp-panthor | src/Utility/URI.php | URI.uriFor | public function uriFor($route, array $params = [], array $query = [])
{
if (!$route) {
return '';
}
return $this->router->relativePathFor($route, $params, $query);
} | php | public function uriFor($route, array $params = [], array $query = [])
{
if (!$route) {
return '';
}
return $this->router->relativePathFor($route, $params, $query);
} | [
"public",
"function",
"uriFor",
"(",
"$",
"route",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"route",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"this",
"->",
... | Get the relative URL for a given route name.
@param string $route
@param array $params
@param array $query
@return string | [
"Get",
"the",
"relative",
"URL",
"for",
"a",
"given",
"route",
"name",
"."
] | b73e22d83d21b8ed4296bee6aebc66c8b07f292c | https://github.com/QuickenLoans/mcp-panthor/blob/b73e22d83d21b8ed4296bee6aebc66c8b07f292c/src/Utility/URI.php#L59-L66 | train |
QuickenLoans/mcp-panthor | src/Utility/URI.php | URI.absoluteURIFor | public function absoluteURIFor(UriInterface $uri, $route, array $params = [], array $query = [])
{
$path = $this->uriFor($route, $params);
return (string) $uri
->withUserInfo('')
->withPath($path)
->withQuery(http_build_query($query))
->withFragment('');
} | php | public function absoluteURIFor(UriInterface $uri, $route, array $params = [], array $query = [])
{
$path = $this->uriFor($route, $params);
return (string) $uri
->withUserInfo('')
->withPath($path)
->withQuery(http_build_query($query))
->withFragment('');
} | [
"public",
"function",
"absoluteURIFor",
"(",
"UriInterface",
"$",
"uri",
",",
"$",
"route",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"uriFor",
"(",
"$",
... | Get the absolute URL for a given route name.
You must provide the current request Uri to retrieve the scheme and host.
@param UriInterface $uri
@param string $route
@param array $params
@param array $query
@return string | [
"Get",
"the",
"absolute",
"URL",
"for",
"a",
"given",
"route",
"name",
".",
"You",
"must",
"provide",
"the",
"current",
"request",
"Uri",
"to",
"retrieve",
"the",
"scheme",
"and",
"host",
"."
] | b73e22d83d21b8ed4296bee6aebc66c8b07f292c | https://github.com/QuickenLoans/mcp-panthor/blob/b73e22d83d21b8ed4296bee6aebc66c8b07f292c/src/Utility/URI.php#L79-L88 | train |
palmtreephp/form | src/FormBuilder.php | FormBuilder.getTypeObject | private function getTypeObject($type, $args)
{
/* @var AbstractType $object */
if ($type instanceof AbstractType) {
$object = $type;
} else {
$class = $this->getTypeClass($type);
if (!\class_exists($class)) {
$class = TextType::class;
}
$object = new $class($args, $this);
}
return $object;
} | php | private function getTypeObject($type, $args)
{
/* @var AbstractType $object */
if ($type instanceof AbstractType) {
$object = $type;
} else {
$class = $this->getTypeClass($type);
if (!\class_exists($class)) {
$class = TextType::class;
}
$object = new $class($args, $this);
}
return $object;
} | [
"private",
"function",
"getTypeObject",
"(",
"$",
"type",
",",
"$",
"args",
")",
"{",
"/* @var AbstractType $object */",
"if",
"(",
"$",
"type",
"instanceof",
"AbstractType",
")",
"{",
"$",
"object",
"=",
"$",
"type",
";",
"}",
"else",
"{",
"$",
"class",
... | Returns a new instance of the given form type.
@param string $type FQCN of the form type or short hand e.g 'text', 'email'.
@param array $args Arguments to pass to the type class constructor.
@return AbstractType | [
"Returns",
"a",
"new",
"instance",
"of",
"the",
"given",
"form",
"type",
"."
] | a5addc6fe82f7e687ad04e84565b78f748e22d12 | https://github.com/palmtreephp/form/blob/a5addc6fe82f7e687ad04e84565b78f748e22d12/src/FormBuilder.php#L137-L153 | train |
romm/formz | Classes/Behaviours/BehavioursManager.php | BehavioursManager.applyBehaviourOnFormInstance | public function applyBehaviourOnFormInstance(FormObject $formObject)
{
if ($formObject->hasForm()) {
$formInstance = $formObject->getForm();
foreach ($formObject->getConfiguration()->getFields() as $fieldName => $field) {
if (ObjectAccess::isPropertyGettable($formInstance, $fieldName)
&& ObjectAccess::isPropertySettable($formInstance, $fieldName)
) {
$propertyValue = ObjectAccess::getProperty($formInstance, $fieldName);
foreach ($field->getBehaviours() as $behaviour) {
/** @var AbstractBehaviour $behaviourInstance */
$behaviourInstance = GeneralUtility::makeInstance($behaviour->getClassName());
// Applying the behaviour on the field's value.
$propertyValue = $behaviourInstance->applyBehaviour($propertyValue);
}
ObjectAccess::setProperty($formInstance, $fieldName, $propertyValue);
}
}
}
} | php | public function applyBehaviourOnFormInstance(FormObject $formObject)
{
if ($formObject->hasForm()) {
$formInstance = $formObject->getForm();
foreach ($formObject->getConfiguration()->getFields() as $fieldName => $field) {
if (ObjectAccess::isPropertyGettable($formInstance, $fieldName)
&& ObjectAccess::isPropertySettable($formInstance, $fieldName)
) {
$propertyValue = ObjectAccess::getProperty($formInstance, $fieldName);
foreach ($field->getBehaviours() as $behaviour) {
/** @var AbstractBehaviour $behaviourInstance */
$behaviourInstance = GeneralUtility::makeInstance($behaviour->getClassName());
// Applying the behaviour on the field's value.
$propertyValue = $behaviourInstance->applyBehaviour($propertyValue);
}
ObjectAccess::setProperty($formInstance, $fieldName, $propertyValue);
}
}
}
} | [
"public",
"function",
"applyBehaviourOnFormInstance",
"(",
"FormObject",
"$",
"formObject",
")",
"{",
"if",
"(",
"$",
"formObject",
"->",
"hasForm",
"(",
")",
")",
"{",
"$",
"formInstance",
"=",
"$",
"formObject",
"->",
"getForm",
"(",
")",
";",
"foreach",
... | This is the same function as `applyBehaviourOnPropertiesArray`, but works
with an actual form object instance.
@param FormObject $formObject | [
"This",
"is",
"the",
"same",
"function",
"as",
"applyBehaviourOnPropertiesArray",
"but",
"works",
"with",
"an",
"actual",
"form",
"object",
"instance",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Behaviours/BehavioursManager.php#L65-L88 | train |
romm/formz | Classes/Condition/ConditionFactory.php | ConditionFactory.registerCondition | public function registerCondition($name, $className)
{
if (false === is_string($name)) {
throw InvalidArgumentTypeException::conditionNameNotString($name);
}
if (false === class_exists($className)) {
throw ClassNotFoundException::conditionClassNameNotFound($name, $className);
}
if (false === in_array(ConditionItemInterface::class, class_implements($className))) {
throw InvalidArgumentTypeException::conditionClassNameNotValid($className);
}
$this->conditions[$name] = $className;
return $this;
} | php | public function registerCondition($name, $className)
{
if (false === is_string($name)) {
throw InvalidArgumentTypeException::conditionNameNotString($name);
}
if (false === class_exists($className)) {
throw ClassNotFoundException::conditionClassNameNotFound($name, $className);
}
if (false === in_array(ConditionItemInterface::class, class_implements($className))) {
throw InvalidArgumentTypeException::conditionClassNameNotValid($className);
}
$this->conditions[$name] = $className;
return $this;
} | [
"public",
"function",
"registerCondition",
"(",
"$",
"name",
",",
"$",
"className",
")",
"{",
"if",
"(",
"false",
"===",
"is_string",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"InvalidArgumentTypeException",
"::",
"conditionNameNotString",
"(",
"$",
"name",
... | Use this function to register a new condition type which can then be used
in the TypoScript configuration. This function should be called from
`ext_localconf.php`.
The name of the condition must be a valid string, which will be then be
used as the identifier for the TypoScript conditions. By convention, you
should use the following syntax: `extension_name.condition_name`.
The condition class must implement the interface
`ConditionItemInterface`.
@param string $name The name of the condition, which will then be available for TypoScript conditions.
@param string $className Class which will process the condition.
@return $this
@throws ClassNotFoundException
@throws InvalidArgumentTypeException | [
"Use",
"this",
"function",
"to",
"register",
"a",
"new",
"condition",
"type",
"which",
"can",
"then",
"be",
"used",
"in",
"the",
"TypoScript",
"configuration",
".",
"This",
"function",
"should",
"be",
"called",
"from",
"ext_localconf",
".",
"php",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Condition/ConditionFactory.php#L74-L91 | train |
romm/formz | Classes/Condition/ConditionFactory.php | ConditionFactory.registerDefaultConditions | public function registerDefaultConditions()
{
if (false === $this->defaultConditionsWereRegistered) {
$this->defaultConditionsWereRegistered = true;
$this->registerCondition(
FieldHasValueCondition::CONDITION_NAME,
FieldHasValueCondition::class
)->registerCondition(
FieldHasErrorCondition::CONDITION_NAME,
FieldHasErrorCondition::class
)->registerCondition(
FieldIsValidCondition::CONDITION_NAME,
FieldIsValidCondition::class
)->registerCondition(
FieldIsEmptyCondition::CONDITION_NAME,
FieldIsEmptyCondition::class
)->registerCondition(
FieldIsFilledCondition::CONDITION_IDENTIFIER,
FieldIsFilledCondition::class
)->registerCondition(
FieldCountValuesCondition::CONDITION_IDENTIFIER,
FieldCountValuesCondition::class
);
}
} | php | public function registerDefaultConditions()
{
if (false === $this->defaultConditionsWereRegistered) {
$this->defaultConditionsWereRegistered = true;
$this->registerCondition(
FieldHasValueCondition::CONDITION_NAME,
FieldHasValueCondition::class
)->registerCondition(
FieldHasErrorCondition::CONDITION_NAME,
FieldHasErrorCondition::class
)->registerCondition(
FieldIsValidCondition::CONDITION_NAME,
FieldIsValidCondition::class
)->registerCondition(
FieldIsEmptyCondition::CONDITION_NAME,
FieldIsEmptyCondition::class
)->registerCondition(
FieldIsFilledCondition::CONDITION_IDENTIFIER,
FieldIsFilledCondition::class
)->registerCondition(
FieldCountValuesCondition::CONDITION_IDENTIFIER,
FieldCountValuesCondition::class
);
}
} | [
"public",
"function",
"registerDefaultConditions",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"defaultConditionsWereRegistered",
")",
"{",
"$",
"this",
"->",
"defaultConditionsWereRegistered",
"=",
"true",
";",
"$",
"this",
"->",
"registerConditi... | Registers all default conditions from FormZ core. | [
"Registers",
"all",
"default",
"conditions",
"from",
"FormZ",
"core",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Condition/ConditionFactory.php#L122-L147 | train |
romm/formz | Classes/Service/TypoScriptService.php | TypoScriptService.getFormConfiguration | public function getFormConfiguration($formClassName)
{
$formzConfiguration = $this->getExtensionConfiguration();
return (isset($formzConfiguration['forms'][$formClassName]))
? $formzConfiguration['forms'][$formClassName]
: [];
} | php | public function getFormConfiguration($formClassName)
{
$formzConfiguration = $this->getExtensionConfiguration();
return (isset($formzConfiguration['forms'][$formClassName]))
? $formzConfiguration['forms'][$formClassName]
: [];
} | [
"public",
"function",
"getFormConfiguration",
"(",
"$",
"formClassName",
")",
"{",
"$",
"formzConfiguration",
"=",
"$",
"this",
"->",
"getExtensionConfiguration",
"(",
")",
";",
"return",
"(",
"isset",
"(",
"$",
"formzConfiguration",
"[",
"'forms'",
"]",
"[",
... | Returns the TypoScript configuration for the given form class name.
@param string $formClassName
@return array | [
"Returns",
"the",
"TypoScript",
"configuration",
"for",
"the",
"given",
"form",
"class",
"name",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Service/TypoScriptService.php#L69-L76 | train |
romm/formz | Classes/Service/TypoScriptService.php | TypoScriptService.getExtensionConfiguration | protected function getExtensionConfiguration()
{
$cacheInstance = CacheService::get()->getCacheInstance();
$hash = $this->getContextHash();
if ($cacheInstance->has($hash)) {
$result = $cacheInstance->get($hash);
} else {
$result = $this->getFullConfiguration();
$result = (ArrayUtility::isValidPath($result, self::EXTENSION_CONFIGURATION_PATH, '.'))
? ArrayUtility::getValueByPath($result, self::EXTENSION_CONFIGURATION_PATH, '.')
: [];
if (ArrayUtility::isValidPath($result, 'settings.typoScriptIncluded', '.')) {
$cacheInstance->set($hash, $result);
}
}
return $result;
} | php | protected function getExtensionConfiguration()
{
$cacheInstance = CacheService::get()->getCacheInstance();
$hash = $this->getContextHash();
if ($cacheInstance->has($hash)) {
$result = $cacheInstance->get($hash);
} else {
$result = $this->getFullConfiguration();
$result = (ArrayUtility::isValidPath($result, self::EXTENSION_CONFIGURATION_PATH, '.'))
? ArrayUtility::getValueByPath($result, self::EXTENSION_CONFIGURATION_PATH, '.')
: [];
if (ArrayUtility::isValidPath($result, 'settings.typoScriptIncluded', '.')) {
$cacheInstance->set($hash, $result);
}
}
return $result;
} | [
"protected",
"function",
"getExtensionConfiguration",
"(",
")",
"{",
"$",
"cacheInstance",
"=",
"CacheService",
"::",
"get",
"(",
")",
"->",
"getCacheInstance",
"(",
")",
";",
"$",
"hash",
"=",
"$",
"this",
"->",
"getContextHash",
"(",
")",
";",
"if",
"(",... | This function will fetch the extension TypoScript configuration, and
store it in cache for further usage.
The configuration array is not stored in cache if the configuration
property `settings.typoScriptIncluded` is not found.
@return array | [
"This",
"function",
"will",
"fetch",
"the",
"extension",
"TypoScript",
"configuration",
"and",
"store",
"it",
"in",
"cache",
"for",
"further",
"usage",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Service/TypoScriptService.php#L101-L120 | train |
romm/formz | Classes/Service/TypoScriptService.php | TypoScriptService.getFullConfiguration | protected function getFullConfiguration()
{
$contextHash = $this->getContextHash();
if (false === array_key_exists($contextHash, $this->configuration)) {
$typoScriptArray = ($this->environmentService->isEnvironmentInFrontendMode())
? $this->getFrontendTypoScriptConfiguration()
: $this->getBackendTypoScriptConfiguration();
$this->configuration[$contextHash] = $this->typoScriptService->convertTypoScriptArrayToPlainArray($typoScriptArray);
}
return $this->configuration[$contextHash];
} | php | protected function getFullConfiguration()
{
$contextHash = $this->getContextHash();
if (false === array_key_exists($contextHash, $this->configuration)) {
$typoScriptArray = ($this->environmentService->isEnvironmentInFrontendMode())
? $this->getFrontendTypoScriptConfiguration()
: $this->getBackendTypoScriptConfiguration();
$this->configuration[$contextHash] = $this->typoScriptService->convertTypoScriptArrayToPlainArray($typoScriptArray);
}
return $this->configuration[$contextHash];
} | [
"protected",
"function",
"getFullConfiguration",
"(",
")",
"{",
"$",
"contextHash",
"=",
"$",
"this",
"->",
"getContextHash",
"(",
")",
";",
"if",
"(",
"false",
"===",
"array_key_exists",
"(",
"$",
"contextHash",
",",
"$",
"this",
"->",
"configuration",
")",... | Returns the full TypoScript configuration, based on the context of the
current request.
@return array | [
"Returns",
"the",
"full",
"TypoScript",
"configuration",
"based",
"on",
"the",
"context",
"of",
"the",
"current",
"request",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Service/TypoScriptService.php#L128-L141 | train |
lcobucci/di-builder | src/Generator.php | Generator.generate | public function generate(
ContainerConfiguration $config,
ConfigCache $dump
): ContainerInterface {
$this->compiler->compile($config, $dump, $this);
return $this->loadContainer($config, $dump);
} | php | public function generate(
ContainerConfiguration $config,
ConfigCache $dump
): ContainerInterface {
$this->compiler->compile($config, $dump, $this);
return $this->loadContainer($config, $dump);
} | [
"public",
"function",
"generate",
"(",
"ContainerConfiguration",
"$",
"config",
",",
"ConfigCache",
"$",
"dump",
")",
":",
"ContainerInterface",
"{",
"$",
"this",
"->",
"compiler",
"->",
"compile",
"(",
"$",
"config",
",",
"$",
"dump",
",",
"$",
"this",
")... | Loads the container | [
"Loads",
"the",
"container"
] | bfe59405150db1ef199190915066ed6b59a85b0a | https://github.com/lcobucci/di-builder/blob/bfe59405150db1ef199190915066ed6b59a85b0a/src/Generator.php#L27-L34 | train |
WouterSioen/sir-trevor-php | src/Sioen/HtmlToJson.php | HtmlToJson.toJson | public function toJson($html)
{
// Strip white space between tags to prevent creation of empty #text nodes
$html = preg_replace('~>\s+<~', '><', $html);
$document = new \DOMDocument();
// Load UTF-8 HTML hack (from http://bit.ly/pVDyCt)
$document->loadHTML('<?xml encoding="UTF-8">' . $html);
$document->encoding = 'UTF-8';
// fetch the body of the document. All html is stored in there
$body = $document->getElementsByTagName("body")->item(0);
$data = array();
// loop trough the child nodes and convert them
if ($body) {
foreach ($body->childNodes as $node) {
$data[] = $this->convert($node);
}
}
return json_encode(array('data' => $data));
} | php | public function toJson($html)
{
// Strip white space between tags to prevent creation of empty #text nodes
$html = preg_replace('~>\s+<~', '><', $html);
$document = new \DOMDocument();
// Load UTF-8 HTML hack (from http://bit.ly/pVDyCt)
$document->loadHTML('<?xml encoding="UTF-8">' . $html);
$document->encoding = 'UTF-8';
// fetch the body of the document. All html is stored in there
$body = $document->getElementsByTagName("body")->item(0);
$data = array();
// loop trough the child nodes and convert them
if ($body) {
foreach ($body->childNodes as $node) {
$data[] = $this->convert($node);
}
}
return json_encode(array('data' => $data));
} | [
"public",
"function",
"toJson",
"(",
"$",
"html",
")",
"{",
"// Strip white space between tags to prevent creation of empty #text nodes",
"$",
"html",
"=",
"preg_replace",
"(",
"'~>\\s+<~'",
",",
"'><'",
",",
"$",
"html",
")",
";",
"$",
"document",
"=",
"new",
"\\... | Converts html to the json Sir Trevor requires
@param string $html
@return string The json string | [
"Converts",
"html",
"to",
"the",
"json",
"Sir",
"Trevor",
"requires"
] | f1dcae3454617366b685f80259016f9b87f7f9a9 | https://github.com/WouterSioen/sir-trevor-php/blob/f1dcae3454617366b685f80259016f9b87f7f9a9/src/Sioen/HtmlToJson.php#L32-L55 | train |
WouterSioen/sir-trevor-php | src/Sioen/HtmlToJson.php | HtmlToJson.convert | private function convert(\DOMElement $node)
{
foreach ($this->converters as $converter) {
if ($converter->matches($node)) {
return $converter->toJson($node);
}
}
} | php | private function convert(\DOMElement $node)
{
foreach ($this->converters as $converter) {
if ($converter->matches($node)) {
return $converter->toJson($node);
}
}
} | [
"private",
"function",
"convert",
"(",
"\\",
"DOMElement",
"$",
"node",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"converters",
"as",
"$",
"converter",
")",
"{",
"if",
"(",
"$",
"converter",
"->",
"matches",
"(",
"$",
"node",
")",
")",
"{",
"retur... | Converts one node to json
@param \DOMElement $node
@return array | [
"Converts",
"one",
"node",
"to",
"json"
] | f1dcae3454617366b685f80259016f9b87f7f9a9 | https://github.com/WouterSioen/sir-trevor-php/blob/f1dcae3454617366b685f80259016f9b87f7f9a9/src/Sioen/HtmlToJson.php#L63-L70 | train |
romm/formz | Classes/Configuration/Form/Field/Activation/AbstractActivation.php | AbstractActivation.getConditions | public function getConditions()
{
$conditionList = $this->withFirstParent(
Form::class,
function (Form $formConfiguration) {
return $formConfiguration->getConditionList();
}
);
$conditionList = ($conditionList) ?: [];
ArrayUtility::mergeRecursiveWithOverrule($conditionList, $this->conditions);
return $conditionList;
} | php | public function getConditions()
{
$conditionList = $this->withFirstParent(
Form::class,
function (Form $formConfiguration) {
return $formConfiguration->getConditionList();
}
);
$conditionList = ($conditionList) ?: [];
ArrayUtility::mergeRecursiveWithOverrule($conditionList, $this->conditions);
return $conditionList;
} | [
"public",
"function",
"getConditions",
"(",
")",
"{",
"$",
"conditionList",
"=",
"$",
"this",
"->",
"withFirstParent",
"(",
"Form",
"::",
"class",
",",
"function",
"(",
"Form",
"$",
"formConfiguration",
")",
"{",
"return",
"$",
"formConfiguration",
"->",
"ge... | Will merge the conditions with the condition list of the parent form.
@return ConditionItemInterface[] | [
"Will",
"merge",
"the",
"conditions",
"with",
"the",
"condition",
"list",
"of",
"the",
"parent",
"form",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Configuration/Form/Field/Activation/AbstractActivation.php#L67-L80 | train |
romm/formz | Classes/Configuration/Form/Field/Activation/AbstractActivation.php | AbstractActivation.getCondition | public function getCondition($name)
{
if (false === $this->hasCondition($name)) {
throw EntryNotFoundException::activationConditionNotFound($name);
}
$items = $this->getConditions();
return $items[$name];
} | php | public function getCondition($name)
{
if (false === $this->hasCondition($name)) {
throw EntryNotFoundException::activationConditionNotFound($name);
}
$items = $this->getConditions();
return $items[$name];
} | [
"public",
"function",
"getCondition",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"hasCondition",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"EntryNotFoundException",
"::",
"activationConditionNotFound",
"(",
"$",
"name",
")",
... | Return the condition with the given name.
@param string $name Name of the item.
@return ConditionItemInterface
@throws EntryNotFoundException | [
"Return",
"the",
"condition",
"with",
"the",
"given",
"name",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Configuration/Form/Field/Activation/AbstractActivation.php#L100-L109 | train |
romm/formz | Classes/Service/FormService.php | FormService.getFormWithErrors | public static function getFormWithErrors($formClassName)
{
GeneralUtility::logDeprecatedFunction();
return (isset(self::$formWithErrors[$formClassName]))
? self::$formWithErrors[$formClassName]
: null;
} | php | public static function getFormWithErrors($formClassName)
{
GeneralUtility::logDeprecatedFunction();
return (isset(self::$formWithErrors[$formClassName]))
? self::$formWithErrors[$formClassName]
: null;
} | [
"public",
"static",
"function",
"getFormWithErrors",
"(",
"$",
"formClassName",
")",
"{",
"GeneralUtility",
"::",
"logDeprecatedFunction",
"(",
")",
";",
"return",
"(",
"isset",
"(",
"self",
"::",
"$",
"formWithErrors",
"[",
"$",
"formClassName",
"]",
")",
")"... | If a form has been submitted with errors, use this function to get it
back.
This is useful because an action is forwarded if the submitted argument
has errors.
@deprecated This method is deprecated, please try not to use it if you
can. It will be removed in FormZ v2, where you will have a
whole new way to get a validated form.
@param string $formClassName The class name of the form.
@return FormInterface|null | [
"If",
"a",
"form",
"has",
"been",
"submitted",
"with",
"errors",
"use",
"this",
"function",
"to",
"get",
"it",
"back",
".",
"This",
"is",
"useful",
"because",
"an",
"action",
"is",
"forwarded",
"if",
"the",
"submitted",
"argument",
"has",
"errors",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Service/FormService.php#L49-L56 | train |
romm/formz | Classes/Condition/Parser/ConditionParser.php | ConditionParser.getNodeRecursive | protected function getNodeRecursive()
{
while (false === empty($this->scope->getExpression())) {
$currentExpression = $this->scope->getExpression();
$this->processToken($currentExpression[0]);
$this->processLogicalAndNode();
}
$this->processLastLogicalOperatorNode();
$node = $this->scope->getNode();
unset($this->scope);
return $node;
} | php | protected function getNodeRecursive()
{
while (false === empty($this->scope->getExpression())) {
$currentExpression = $this->scope->getExpression();
$this->processToken($currentExpression[0]);
$this->processLogicalAndNode();
}
$this->processLastLogicalOperatorNode();
$node = $this->scope->getNode();
unset($this->scope);
return $node;
} | [
"protected",
"function",
"getNodeRecursive",
"(",
")",
"{",
"while",
"(",
"false",
"===",
"empty",
"(",
"$",
"this",
"->",
"scope",
"->",
"getExpression",
"(",
")",
")",
")",
"{",
"$",
"currentExpression",
"=",
"$",
"this",
"->",
"scope",
"->",
"getExpre... | Recursive function to convert an array of condition data to a nodes tree.
@return NodeInterface|null | [
"Recursive",
"function",
"to",
"convert",
"an",
"array",
"of",
"condition",
"data",
"to",
"a",
"nodes",
"tree",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Condition/Parser/ConditionParser.php#L122-L136 | train |
romm/formz | Classes/Condition/Parser/ConditionParser.php | ConditionParser.processToken | protected function processToken($token)
{
switch ($token) {
case ')':
$this->processTokenClosingParenthesis();
break;
case '(':
$this->processTokenOpeningParenthesis();
break;
case self::LOGICAL_OR:
case self::LOGICAL_AND:
$this->processTokenLogicalOperator($token);
break;
default:
$this->processTokenCondition($token);
break;
}
return $this;
} | php | protected function processToken($token)
{
switch ($token) {
case ')':
$this->processTokenClosingParenthesis();
break;
case '(':
$this->processTokenOpeningParenthesis();
break;
case self::LOGICAL_OR:
case self::LOGICAL_AND:
$this->processTokenLogicalOperator($token);
break;
default:
$this->processTokenCondition($token);
break;
}
return $this;
} | [
"protected",
"function",
"processToken",
"(",
"$",
"token",
")",
"{",
"switch",
"(",
"$",
"token",
")",
"{",
"case",
"')'",
":",
"$",
"this",
"->",
"processTokenClosingParenthesis",
"(",
")",
";",
"break",
";",
"case",
"'('",
":",
"$",
"this",
"->",
"p... | Will process a given token, which should be in the list of know tokens.
@param string $token
@return $this | [
"Will",
"process",
"a",
"given",
"token",
"which",
"should",
"be",
"in",
"the",
"list",
"of",
"know",
"tokens",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Condition/Parser/ConditionParser.php#L144-L163 | train |
romm/formz | Classes/Condition/Parser/ConditionParser.php | ConditionParser.processTokenOpeningParenthesis | protected function processTokenOpeningParenthesis()
{
$groupNode = $this->getGroupNode($this->scope->getExpression());
$scopeSave = $this->scope;
$expression = array_slice($scopeSave->getExpression(), count($groupNode) + 2);
$scopeSave->setExpression($expression);
$this->scope = $this->getNewScope();
$this->scope->setExpression($groupNode);
$node = $this->getNodeRecursive();
$this->scope = $scopeSave;
$this->scope->setNode($node);
} | php | protected function processTokenOpeningParenthesis()
{
$groupNode = $this->getGroupNode($this->scope->getExpression());
$scopeSave = $this->scope;
$expression = array_slice($scopeSave->getExpression(), count($groupNode) + 2);
$scopeSave->setExpression($expression);
$this->scope = $this->getNewScope();
$this->scope->setExpression($groupNode);
$node = $this->getNodeRecursive();
$this->scope = $scopeSave;
$this->scope->setNode($node);
} | [
"protected",
"function",
"processTokenOpeningParenthesis",
"(",
")",
"{",
"$",
"groupNode",
"=",
"$",
"this",
"->",
"getGroupNode",
"(",
"$",
"this",
"->",
"scope",
"->",
"getExpression",
"(",
")",
")",
";",
"$",
"scopeSave",
"=",
"$",
"this",
"->",
"scope... | Will process the opening parenthesis token `(`.
A new scope will be created, containing the whole tokens list, which are
located between the opening parenthesis and the closing one. The scope
will be processed in a new scope, then the result is stored and the
process can keep up. | [
"Will",
"process",
"the",
"opening",
"parenthesis",
"token",
"(",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Condition/Parser/ConditionParser.php#L173-L188 | train |
romm/formz | Classes/Condition/Parser/ConditionParser.php | ConditionParser.processTokenLogicalOperator | protected function processTokenLogicalOperator($operator)
{
if (null === $this->scope->getNode()) {
$this->addError('Logical operator must be preceded by a valid operation.', self::ERROR_CODE_LOGICAL_OPERATOR_PRECEDED);
} else {
if (self::LOGICAL_OR === $operator) {
if (null !== $this->scope->getLastOrNode()) {
/*
* If a `or` node was already registered, we create a new
* boolean node to join the two nodes.
*/
$node = new BooleanNode($this->scope->getLastOrNode(), $this->scope->getNode(), $operator);
$this->scope->setNode($node);
}
$this->scope->setLastOrNode($this->scope->getNode());
} else {
$this->scope
->setCurrentLeftNode($this->scope->getNode())
->deleteNode();
}
$this->scope
->setCurrentOperator($operator)
->shiftExpression();
}
} | php | protected function processTokenLogicalOperator($operator)
{
if (null === $this->scope->getNode()) {
$this->addError('Logical operator must be preceded by a valid operation.', self::ERROR_CODE_LOGICAL_OPERATOR_PRECEDED);
} else {
if (self::LOGICAL_OR === $operator) {
if (null !== $this->scope->getLastOrNode()) {
/*
* If a `or` node was already registered, we create a new
* boolean node to join the two nodes.
*/
$node = new BooleanNode($this->scope->getLastOrNode(), $this->scope->getNode(), $operator);
$this->scope->setNode($node);
}
$this->scope->setLastOrNode($this->scope->getNode());
} else {
$this->scope
->setCurrentLeftNode($this->scope->getNode())
->deleteNode();
}
$this->scope
->setCurrentOperator($operator)
->shiftExpression();
}
} | [
"protected",
"function",
"processTokenLogicalOperator",
"(",
"$",
"operator",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"scope",
"->",
"getNode",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'Logical operator must be preceded by a valid ... | Will process the logical operator tokens `&&` and `||`.
Depending on the type of the operator, the process will change.
@param string $operator | [
"Will",
"process",
"the",
"logical",
"operator",
"tokens",
"&&",
"and",
"||",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Condition/Parser/ConditionParser.php#L208-L234 | train |
romm/formz | Classes/Condition/Parser/ConditionParser.php | ConditionParser.processTokenCondition | protected function processTokenCondition($condition)
{
if (false === $this->condition->hasCondition($condition)) {
$this->addError('The condition "' . $condition . '" does not exist.', self::ERROR_CODE_CONDITION_NOT_FOUND);
} else {
$node = new ConditionNode($condition, $this->condition->getCondition($condition));
$this->scope
->setNode($node)
->shiftExpression();
}
} | php | protected function processTokenCondition($condition)
{
if (false === $this->condition->hasCondition($condition)) {
$this->addError('The condition "' . $condition . '" does not exist.', self::ERROR_CODE_CONDITION_NOT_FOUND);
} else {
$node = new ConditionNode($condition, $this->condition->getCondition($condition));
$this->scope
->setNode($node)
->shiftExpression();
}
} | [
"protected",
"function",
"processTokenCondition",
"(",
"$",
"condition",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"condition",
"->",
"hasCondition",
"(",
"$",
"condition",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'The condition \"'"... | Will process the condition token.
The condition must exist in the list of items of the condition.
@param string $condition | [
"Will",
"process",
"the",
"condition",
"token",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Condition/Parser/ConditionParser.php#L243-L253 | train |
romm/formz | Classes/Condition/Parser/ConditionParser.php | ConditionParser.processLogicalAndNode | protected function processLogicalAndNode()
{
if (null !== $this->scope->getCurrentLeftNode()
&& null !== $this->scope->getNode()
&& null !== $this->scope->getCurrentOperator()
) {
$node = new BooleanNode($this->scope->getCurrentLeftNode(), $this->scope->getNode(), $this->scope->getCurrentOperator());
$this->scope
->setNode($node)
->deleteCurrentLeftNode()
->deleteCurrentOperator();
}
return $this;
} | php | protected function processLogicalAndNode()
{
if (null !== $this->scope->getCurrentLeftNode()
&& null !== $this->scope->getNode()
&& null !== $this->scope->getCurrentOperator()
) {
$node = new BooleanNode($this->scope->getCurrentLeftNode(), $this->scope->getNode(), $this->scope->getCurrentOperator());
$this->scope
->setNode($node)
->deleteCurrentLeftNode()
->deleteCurrentOperator();
}
return $this;
} | [
"protected",
"function",
"processLogicalAndNode",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"scope",
"->",
"getCurrentLeftNode",
"(",
")",
"&&",
"null",
"!==",
"$",
"this",
"->",
"scope",
"->",
"getNode",
"(",
")",
"&&",
"null",
"!==",
... | Will check if a "logical and" node should be created, depending on which
tokens were processed before.
@return $this | [
"Will",
"check",
"if",
"a",
"logical",
"and",
"node",
"should",
"be",
"created",
"depending",
"on",
"which",
"tokens",
"were",
"processed",
"before",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Condition/Parser/ConditionParser.php#L261-L275 | train |
romm/formz | Classes/Condition/Parser/ConditionParser.php | ConditionParser.processLastLogicalOperatorNode | protected function processLastLogicalOperatorNode()
{
if (null !== $this->scope->getCurrentLeftNode()) {
$this->addError('Logical operator must be followed by a valid operation.', self::ERROR_CODE_LOGICAL_OPERATOR_FOLLOWED);
} elseif (null !== $this->scope->getLastOrNode()) {
$node = new BooleanNode($this->scope->getLastOrNode(), $this->scope->getNode(), self::LOGICAL_OR);
$this->scope->setNode($node);
}
return $this;
} | php | protected function processLastLogicalOperatorNode()
{
if (null !== $this->scope->getCurrentLeftNode()) {
$this->addError('Logical operator must be followed by a valid operation.', self::ERROR_CODE_LOGICAL_OPERATOR_FOLLOWED);
} elseif (null !== $this->scope->getLastOrNode()) {
$node = new BooleanNode($this->scope->getLastOrNode(), $this->scope->getNode(), self::LOGICAL_OR);
$this->scope->setNode($node);
}
return $this;
} | [
"protected",
"function",
"processLastLogicalOperatorNode",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"scope",
"->",
"getCurrentLeftNode",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'Logical operator must be followed by a valid operati... | Will check if a last logical operator node is remaining.
@return $this | [
"Will",
"check",
"if",
"a",
"last",
"logical",
"operator",
"node",
"is",
"remaining",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Condition/Parser/ConditionParser.php#L282-L292 | train |
romm/formz | Classes/Condition/Parser/ConditionParser.php | ConditionParser.getGroupNodeClosingIndex | protected function getGroupNodeClosingIndex(array $expression)
{
$parenthesis = 1;
$index = 0;
while ($parenthesis > 0) {
$index++;
if ($index > count($expression)) {
$this->addError('Parenthesis not correctly closed.', self::ERROR_CODE_CLOSING_PARENTHESIS_NOT_FOUND);
}
if ('(' === $expression[$index]) {
$parenthesis++;
} elseif (')' === $expression[$index]) {
$parenthesis--;
}
}
return $index;
} | php | protected function getGroupNodeClosingIndex(array $expression)
{
$parenthesis = 1;
$index = 0;
while ($parenthesis > 0) {
$index++;
if ($index > count($expression)) {
$this->addError('Parenthesis not correctly closed.', self::ERROR_CODE_CLOSING_PARENTHESIS_NOT_FOUND);
}
if ('(' === $expression[$index]) {
$parenthesis++;
} elseif (')' === $expression[$index]) {
$parenthesis--;
}
}
return $index;
} | [
"protected",
"function",
"getGroupNodeClosingIndex",
"(",
"array",
"$",
"expression",
")",
"{",
"$",
"parenthesis",
"=",
"1",
";",
"$",
"index",
"=",
"0",
";",
"while",
"(",
"$",
"parenthesis",
">",
"0",
")",
"{",
"$",
"index",
"++",
";",
"if",
"(",
... | Returns the index of the closing parenthesis that matches the opening
parenthesis at index 0 of the given expression.
@param array $expression
@return int | [
"Returns",
"the",
"index",
"of",
"the",
"closing",
"parenthesis",
"that",
"matches",
"the",
"opening",
"parenthesis",
"at",
"index",
"0",
"of",
"the",
"given",
"expression",
"."
] | b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f | https://github.com/romm/formz/blob/b0bc266a1c86377ab43ef8d1c07a4b5f54d5fc3f/Classes/Condition/Parser/ConditionParser.php#L324-L343 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.