repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
silverstripe/silverstripe-userforms | code/Model/EditableFormField/EditableDateField.php | EditableDateField.getFormField | public function getFormField()
{
$defaultValue = $this->DefaultToToday
? DBDatetime::now()->Format('yyyy-MM-dd')
: $this->Default;
$field = FormField::create($this->Name, $this->Title ?: false, $defaultValue)
->setFieldHolderTemplate(EditableFormField::class . '_... | php | public function getFormField()
{
$defaultValue = $this->DefaultToToday
? DBDatetime::now()->Format('yyyy-MM-dd')
: $this->Default;
$field = FormField::create($this->Name, $this->Title ?: false, $defaultValue)
->setFieldHolderTemplate(EditableFormField::class . '_... | [
"public",
"function",
"getFormField",
"(",
")",
"{",
"$",
"defaultValue",
"=",
"$",
"this",
"->",
"DefaultToToday",
"?",
"DBDatetime",
"::",
"now",
"(",
")",
"->",
"Format",
"(",
"'yyyy-MM-dd'",
")",
":",
"$",
"this",
"->",
"Default",
";",
"$",
"field",
... | Return the form field | [
"Return",
"the",
"form",
"field"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/EditableFormField/EditableDateField.php#L55-L68 |
silverstripe/silverstripe-userforms | code/FormField/UserFormsCheckboxSetField.php | UserFormsCheckboxSetField.getOptions | public function getOptions()
{
$options = parent::getOptions();
foreach ($options as $option) {
$option->Name = "{$this->name}[]";
}
return $options;
} | php | public function getOptions()
{
$options = parent::getOptions();
foreach ($options as $option) {
$option->Name = "{$this->name}[]";
}
return $options;
} | [
"public",
"function",
"getOptions",
"(",
")",
"{",
"$",
"options",
"=",
"parent",
"::",
"getOptions",
"(",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
")",
"{",
"$",
"option",
"->",
"Name",
"=",
"\"{$this->name}[]\"",
";",
"}",
"retu... | jQuery validate requires that the value of the option does not contain
the actual value of the input.
@return ArrayList | [
"jQuery",
"validate",
"requires",
"that",
"the",
"value",
"of",
"the",
"option",
"does",
"not",
"contain",
"the",
"actual",
"value",
"of",
"the",
"input",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/FormField/UserFormsCheckboxSetField.php#L19-L28 |
silverstripe/silverstripe-userforms | code/FormField/UserFormsCheckboxSetField.php | UserFormsCheckboxSetField.validate | public function validate($validator)
{
// get the previous values (could contain comma-delimited list)
$previous = $value = $this->Value();
if (is_string($value) && strstr($value, ",")) {
$value = explode(",", $value);
}
// set the value as an array for parent ... | php | public function validate($validator)
{
// get the previous values (could contain comma-delimited list)
$previous = $value = $this->Value();
if (is_string($value) && strstr($value, ",")) {
$value = explode(",", $value);
}
// set the value as an array for parent ... | [
"public",
"function",
"validate",
"(",
"$",
"validator",
")",
"{",
"// get the previous values (could contain comma-delimited list)",
"$",
"previous",
"=",
"$",
"value",
"=",
"$",
"this",
"->",
"Value",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"value",
... | @inheritdoc
@param Validator $validator
@return bool | [
"@inheritdoc"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/FormField/UserFormsCheckboxSetField.php#L37-L58 |
silverstripe/silverstripe-userforms | code/Form/GridFieldAddClassesButton.php | GridFieldAddClassesButton.getClassesCreate | public function getClassesCreate($grid)
{
// Get explicit or fallback class list
$classes = $this->getClasses();
if (empty($classes) && $grid) {
$classes = array($grid->getModelClass());
}
// Filter out classes without permission
return array_filter($clas... | php | public function getClassesCreate($grid)
{
// Get explicit or fallback class list
$classes = $this->getClasses();
if (empty($classes) && $grid) {
$classes = array($grid->getModelClass());
}
// Filter out classes without permission
return array_filter($clas... | [
"public",
"function",
"getClassesCreate",
"(",
"$",
"grid",
")",
"{",
"// Get explicit or fallback class list",
"$",
"classes",
"=",
"$",
"this",
"->",
"getClasses",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"classes",
")",
"&&",
"$",
"grid",
")",
"{",
... | Gets the list of classes which can be created, with checks for permissions.
Will fallback to the default model class for the given DataGrid
@param DataGrid $grid
@return array | [
"Gets",
"the",
"list",
"of",
"classes",
"which",
"can",
"be",
"created",
"with",
"checks",
"for",
"permissions",
".",
"Will",
"fallback",
"to",
"the",
"default",
"model",
"class",
"for",
"the",
"given",
"DataGrid"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Form/GridFieldAddClassesButton.php#L139-L151 |
silverstripe/silverstripe-userforms | code/Form/GridFieldAddClassesButton.php | GridFieldAddClassesButton.setClasses | public function setClasses($classes)
{
if (!is_array($classes)) {
$classes = $classes ? array($classes) : array();
}
$this->modelClasses = $classes;
} | php | public function setClasses($classes)
{
if (!is_array($classes)) {
$classes = $classes ? array($classes) : array();
}
$this->modelClasses = $classes;
} | [
"public",
"function",
"setClasses",
"(",
"$",
"classes",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"classes",
")",
")",
"{",
"$",
"classes",
"=",
"$",
"classes",
"?",
"array",
"(",
"$",
"classes",
")",
":",
"array",
"(",
")",
";",
"}",
"$",... | Specify the classes to create
@param array $classes | [
"Specify",
"the",
"classes",
"to",
"create"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Form/GridFieldAddClassesButton.php#L158-L164 |
silverstripe/silverstripe-userforms | code/Form/GridFieldAddClassesButton.php | GridFieldAddClassesButton.handleAdd | public function handleAdd($grid)
{
$classes = $this->getClassesCreate($grid);
if (empty($classes)) {
throw new HTTPResponse_Exception(400);
}
// Add item to gridfield
$list = $grid->getList();
foreach ($classes as $class) {
$item = $class::cre... | php | public function handleAdd($grid)
{
$classes = $this->getClassesCreate($grid);
if (empty($classes)) {
throw new HTTPResponse_Exception(400);
}
// Add item to gridfield
$list = $grid->getList();
foreach ($classes as $class) {
$item = $class::cre... | [
"public",
"function",
"handleAdd",
"(",
"$",
"grid",
")",
"{",
"$",
"classes",
"=",
"$",
"this",
"->",
"getClassesCreate",
"(",
"$",
"grid",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"classes",
")",
")",
"{",
"throw",
"new",
"HTTPResponse_Exception",
"("... | Handles adding a new instance of a selected class.
@param GridField $grid
@return null | [
"Handles",
"adding",
"a",
"new",
"instance",
"of",
"a",
"selected",
"class",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Form/GridFieldAddClassesButton.php#L236-L253 |
silverstripe/silverstripe-userforms | code/Task/UserFormsColumnCleanTask.php | UserFormsColumnCleanTask.run | public function run($request)
{
/** @var \SilverStripe\ORM\DataObjectSchema $schema */
$schema = DataObject::getSchema();
foreach ($this->tables as $db) {
$columns = $schema->databaseFields($db);
$query = "SHOW COLUMNS FROM $db";
$liveColumns = DB::query(... | php | public function run($request)
{
/** @var \SilverStripe\ORM\DataObjectSchema $schema */
$schema = DataObject::getSchema();
foreach ($this->tables as $db) {
$columns = $schema->databaseFields($db);
$query = "SHOW COLUMNS FROM $db";
$liveColumns = DB::query(... | [
"public",
"function",
"run",
"(",
"$",
"request",
")",
"{",
"/** @var \\SilverStripe\\ORM\\DataObjectSchema $schema */",
"$",
"schema",
"=",
"DataObject",
"::",
"getSchema",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"tables",
"as",
"$",
"db",
")",
"{",... | Publish the existing forms. | [
"Publish",
"the",
"existing",
"forms",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Task/UserFormsColumnCleanTask.php#L31-L67 |
silverstripe/silverstripe-userforms | code/Model/Submission/SubmittedForm.php | SubmittedForm.relField | public function relField($fieldName)
{
// default case
if ($value = parent::relField($fieldName)) {
return $value;
}
// check values for a form field with the matching name.
$formField = SubmittedFormField::get()->filter(array(
'ParentID' => $this->ID... | php | public function relField($fieldName)
{
// default case
if ($value = parent::relField($fieldName)) {
return $value;
}
// check values for a form field with the matching name.
$formField = SubmittedFormField::get()->filter(array(
'ParentID' => $this->ID... | [
"public",
"function",
"relField",
"(",
"$",
"fieldName",
")",
"{",
"// default case",
"if",
"(",
"$",
"value",
"=",
"parent",
"::",
"relField",
"(",
"$",
"fieldName",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"// check values for a form field with the m... | Returns the value of a relation or, in the case of this form, the value
of a given child {@link SubmittedFormField}
@param string
@return mixed | [
"Returns",
"the",
"value",
"of",
"a",
"relation",
"or",
"in",
"the",
"case",
"of",
"this",
"form",
"the",
"value",
"of",
"a",
"given",
"child",
"{",
"@link",
"SubmittedFormField",
"}"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/Submission/SubmittedForm.php#L56-L72 |
silverstripe/silverstripe-userforms | code/Model/Submission/SubmittedForm.php | SubmittedForm.canCreate | public function canCreate($member = null, $context = [])
{
$extended = $this->extendedCan(__FUNCTION__, $member);
if ($extended !== null) {
return $extended;
}
return $this->Parent()->canCreate();
} | php | public function canCreate($member = null, $context = [])
{
$extended = $this->extendedCan(__FUNCTION__, $member);
if ($extended !== null) {
return $extended;
}
return $this->Parent()->canCreate();
} | [
"public",
"function",
"canCreate",
"(",
"$",
"member",
"=",
"null",
",",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"$",
"extended",
"=",
"$",
"this",
"->",
"extendedCan",
"(",
"__FUNCTION__",
",",
"$",
"member",
")",
";",
"if",
"(",
"$",
"extended",
... | @param Member
@return boolean | [
"@param",
"Member"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/Submission/SubmittedForm.php#L127-L134 |
silverstripe/silverstripe-userforms | code/Model/Submission/SubmittedForm.php | SubmittedForm.canView | public function canView($member = null)
{
$extended = $this->extendedCan(__FUNCTION__, $member);
if ($extended !== null) {
return $extended;
}
if ($this->Parent()) {
return $this->Parent()->canView($member);
}
return parent::canView($member)... | php | public function canView($member = null)
{
$extended = $this->extendedCan(__FUNCTION__, $member);
if ($extended !== null) {
return $extended;
}
if ($this->Parent()) {
return $this->Parent()->canView($member);
}
return parent::canView($member)... | [
"public",
"function",
"canView",
"(",
"$",
"member",
"=",
"null",
")",
"{",
"$",
"extended",
"=",
"$",
"this",
"->",
"extendedCan",
"(",
"__FUNCTION__",
",",
"$",
"member",
")",
";",
"if",
"(",
"$",
"extended",
"!==",
"null",
")",
"{",
"return",
"$",... | @param Member
@return boolean | [
"@param",
"Member"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/Submission/SubmittedForm.php#L141-L154 |
silverstripe/silverstripe-userforms | code/Model/Submission/SubmittedForm.php | SubmittedForm.onBeforeDelete | protected function onBeforeDelete()
{
if ($this->Values()) {
foreach ($this->Values() as $value) {
$value->delete();
}
}
parent::onBeforeDelete();
} | php | protected function onBeforeDelete()
{
if ($this->Values()) {
foreach ($this->Values() as $value) {
$value->delete();
}
}
parent::onBeforeDelete();
} | [
"protected",
"function",
"onBeforeDelete",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"Values",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"Values",
"(",
")",
"as",
"$",
"value",
")",
"{",
"$",
"value",
"->",
"delete",
"(",
")",
";"... | Before we delete this form make sure we delete all the field values so
that we don't leave old data round.
@return void | [
"Before",
"we",
"delete",
"this",
"form",
"make",
"sure",
"we",
"delete",
"all",
"the",
"field",
"values",
"so",
"that",
"we",
"don",
"t",
"leave",
"old",
"data",
"round",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/Submission/SubmittedForm.php#L202-L211 |
silverstripe/silverstripe-userforms | code/UserForm.php | UserForm.FilteredEmailRecipients | public function FilteredEmailRecipients($data = null, $form = null)
{
$recipients = ArrayList::create($this->EmailRecipients()->toArray());
// Filter by rules
$recipients = $recipients->filterByCallback(function ($recipient) use ($data, $form) {
/** @var EmailRecipient $recipien... | php | public function FilteredEmailRecipients($data = null, $form = null)
{
$recipients = ArrayList::create($this->EmailRecipients()->toArray());
// Filter by rules
$recipients = $recipients->filterByCallback(function ($recipient) use ($data, $form) {
/** @var EmailRecipient $recipien... | [
"public",
"function",
"FilteredEmailRecipients",
"(",
"$",
"data",
"=",
"null",
",",
"$",
"form",
"=",
"null",
")",
"{",
"$",
"recipients",
"=",
"ArrayList",
"::",
"create",
"(",
"$",
"this",
"->",
"EmailRecipients",
"(",
")",
"->",
"toArray",
"(",
")",
... | Allow overriding the EmailRecipients on a {@link DataExtension}
so you can customise who receives an email.
Converts the RelationList to an ArrayList so that manipulation
of the original source data isn't possible.
@return ArrayList | [
"Allow",
"overriding",
"the",
"EmailRecipients",
"on",
"a",
"{",
"@link",
"DataExtension",
"}",
"so",
"you",
"can",
"customise",
"who",
"receives",
"an",
"email",
".",
"Converts",
"the",
"RelationList",
"to",
"an",
"ArrayList",
"so",
"that",
"manipulation",
"o... | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/UserForm.php#L346-L359 |
silverstripe/silverstripe-userforms | code/UserForm.php | UserForm.getFormOptions | public function getFormOptions()
{
$submit = ($this->SubmitButtonText) ? $this->SubmitButtonText : _t(__CLASS__.'.SUBMITBUTTON', 'Submit');
$clear = ($this->ClearButtonText) ? $this->ClearButtonText : _t(__CLASS__.'.CLEARBUTTON', 'Clear');
$options = FieldList::create(
TextField... | php | public function getFormOptions()
{
$submit = ($this->SubmitButtonText) ? $this->SubmitButtonText : _t(__CLASS__.'.SUBMITBUTTON', 'Submit');
$clear = ($this->ClearButtonText) ? $this->ClearButtonText : _t(__CLASS__.'.CLEARBUTTON', 'Clear');
$options = FieldList::create(
TextField... | [
"public",
"function",
"getFormOptions",
"(",
")",
"{",
"$",
"submit",
"=",
"(",
"$",
"this",
"->",
"SubmitButtonText",
")",
"?",
"$",
"this",
"->",
"SubmitButtonText",
":",
"_t",
"(",
"__CLASS__",
".",
"'.SUBMITBUTTON'",
",",
"'Submit'",
")",
";",
"$",
"... | Custom options for the form. You can extend the built in options by
using {@link updateFormOptions()}
@return FieldList | [
"Custom",
"options",
"for",
"the",
"form",
".",
"You",
"can",
"extend",
"the",
"built",
"in",
"options",
"by",
"using",
"{",
"@link",
"updateFormOptions",
"()",
"}"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/UserForm.php#L367-L385 |
silverstripe/silverstripe-userforms | code/Model/EditableFormField/EditableOption.php | EditableOption.getValue | public function getValue()
{
$value = $this->getField('Value');
if (empty($value) && !self::allow_empty_values()) {
return $this->Title;
}
return $value;
} | php | public function getValue()
{
$value = $this->getField('Value');
if (empty($value) && !self::allow_empty_values()) {
return $this->Title;
}
return $value;
} | [
"public",
"function",
"getValue",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getField",
"(",
"'Value'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
"&&",
"!",
"self",
"::",
"allow_empty_values",
"(",
")",
")",
"{",
"return",
"$... | Fetches a value for $this->Value. If empty values are not allowed,
then this will return the title in the case of an empty value.
@return string | [
"Fetches",
"a",
"value",
"for",
"$this",
"-",
">",
"Value",
".",
"If",
"empty",
"values",
"are",
"not",
"allowed",
"then",
"this",
"will",
"return",
"the",
"title",
"in",
"the",
"case",
"of",
"an",
"empty",
"value",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/EditableFormField/EditableOption.php#L81-L88 |
silverstripe/silverstripe-userforms | code/Model/EditableFormField/EditableOption.php | EditableOption.canCreate | public function canCreate($member = null, $context = [])
{
// Check parent object
$parent = $this->Parent();
if ($parent) {
return $parent->canCreate($member);
}
// Fall back to secure admin permissions
return parent::canCreate($member);
} | php | public function canCreate($member = null, $context = [])
{
// Check parent object
$parent = $this->Parent();
if ($parent) {
return $parent->canCreate($member);
}
// Fall back to secure admin permissions
return parent::canCreate($member);
} | [
"public",
"function",
"canCreate",
"(",
"$",
"member",
"=",
"null",
",",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"// Check parent object",
"$",
"parent",
"=",
"$",
"this",
"->",
"Parent",
"(",
")",
";",
"if",
"(",
"$",
"parent",
")",
"{",
"return",
... | Return whether a user can create an object of this type
@param Member $member
@param array $context Virtual parameter to allow context to be passed in to check
@return bool | [
"Return",
"whether",
"a",
"user",
"can",
"create",
"an",
"object",
"of",
"this",
"type"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/EditableFormField/EditableOption.php#L134-L144 |
silverstripe/silverstripe-userforms | code/Extension/UserFormFieldEditorExtension.php | UserFormFieldEditorExtension.updateCMSFields | public function updateCMSFields(FieldList $fields)
{
$fieldEditor = $this->getFieldEditorGrid();
$fields->insertAfter(new Tab('FormFields', _t(__CLASS__.'.FORMFIELDS', 'Form Fields')), 'Main');
$fields->addFieldToTab('Root.FormFields', $fieldEditor);
return $fields;
} | php | public function updateCMSFields(FieldList $fields)
{
$fieldEditor = $this->getFieldEditorGrid();
$fields->insertAfter(new Tab('FormFields', _t(__CLASS__.'.FORMFIELDS', 'Form Fields')), 'Main');
$fields->addFieldToTab('Root.FormFields', $fieldEditor);
return $fields;
} | [
"public",
"function",
"updateCMSFields",
"(",
"FieldList",
"$",
"fields",
")",
"{",
"$",
"fieldEditor",
"=",
"$",
"this",
"->",
"getFieldEditorGrid",
"(",
")",
";",
"$",
"fields",
"->",
"insertAfter",
"(",
"new",
"Tab",
"(",
"'FormFields'",
",",
"_t",
"(",... | Adds the field editor to the page.
@return FieldList | [
"Adds",
"the",
"field",
"editor",
"to",
"the",
"page",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Extension/UserFormFieldEditorExtension.php#L51-L59 |
silverstripe/silverstripe-userforms | code/Extension/UserFormFieldEditorExtension.php | UserFormFieldEditorExtension.getFieldEditorGrid | public function getFieldEditorGrid()
{
Requirements::javascript('silverstripe/userforms:client/dist/js/userforms-cms.js');
$fields = $this->owner->Fields();
$this->createInitialFormStep(true);
$editableColumns = new GridFieldEditableColumns();
$fieldClasses = singleton(Edi... | php | public function getFieldEditorGrid()
{
Requirements::javascript('silverstripe/userforms:client/dist/js/userforms-cms.js');
$fields = $this->owner->Fields();
$this->createInitialFormStep(true);
$editableColumns = new GridFieldEditableColumns();
$fieldClasses = singleton(Edi... | [
"public",
"function",
"getFieldEditorGrid",
"(",
")",
"{",
"Requirements",
"::",
"javascript",
"(",
"'silverstripe/userforms:client/dist/js/userforms-cms.js'",
")",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"owner",
"->",
"Fields",
"(",
")",
";",
"$",
"this",
... | Gets the field editor, for adding and removing EditableFormFields.
@return GridField | [
"Gets",
"the",
"field",
"editor",
"for",
"adding",
"and",
"removing",
"EditableFormFields",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Extension/UserFormFieldEditorExtension.php#L66-L119 |
silverstripe/silverstripe-userforms | code/Extension/UserFormFieldEditorExtension.php | UserFormFieldEditorExtension.createInitialFormStep | public function createInitialFormStep($force = false)
{
// Only invoke once saved
if (!$this->owner->exists()) {
return;
}
// Check if first field is a step
$fields = $this->owner->Fields();
$firstField = $fields->first();
if ($firstField instance... | php | public function createInitialFormStep($force = false)
{
// Only invoke once saved
if (!$this->owner->exists()) {
return;
}
// Check if first field is a step
$fields = $this->owner->Fields();
$firstField = $fields->first();
if ($firstField instance... | [
"public",
"function",
"createInitialFormStep",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"// Only invoke once saved",
"if",
"(",
"!",
"$",
"this",
"->",
"owner",
"->",
"exists",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Check if first field is a step",
"$",... | A UserForm must have at least one step.
If no steps exist, create an initial step, and put all fields inside it.
@param bool $force
@return void | [
"A",
"UserForm",
"must",
"have",
"at",
"least",
"one",
"step",
".",
"If",
"no",
"steps",
"exist",
"create",
"an",
"initial",
"step",
"and",
"put",
"all",
"fields",
"inside",
"it",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Extension/UserFormFieldEditorExtension.php#L128-L161 |
silverstripe/silverstripe-userforms | code/Extension/UserFormFieldEditorExtension.php | UserFormFieldEditorExtension.onAfterPublish | public function onAfterPublish()
{
// store IDs of fields we've published
$seenIDs = [];
foreach ($this->owner->Fields() as $field) {
// store any IDs of fields we publish so we don't unpublish them
$seenIDs[] = $field->ID;
$field->doPublish(Versioned::DRA... | php | public function onAfterPublish()
{
// store IDs of fields we've published
$seenIDs = [];
foreach ($this->owner->Fields() as $field) {
// store any IDs of fields we publish so we don't unpublish them
$seenIDs[] = $field->ID;
$field->doPublish(Versioned::DRA... | [
"public",
"function",
"onAfterPublish",
"(",
")",
"{",
"// store IDs of fields we've published",
"$",
"seenIDs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"owner",
"->",
"Fields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"// store any IDs of fields... | Remove any orphaned child records on publish | [
"Remove",
"any",
"orphaned",
"child",
"records",
"on",
"publish"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Extension/UserFormFieldEditorExtension.php#L174-L202 |
silverstripe/silverstripe-userforms | code/Extension/UserFormFieldEditorExtension.php | UserFormFieldEditorExtension.onAfterUnpublish | public function onAfterUnpublish()
{
foreach ($this->owner->Fields() as $field) {
$field->deleteFromStage(Versioned::LIVE);
}
} | php | public function onAfterUnpublish()
{
foreach ($this->owner->Fields() as $field) {
$field->deleteFromStage(Versioned::LIVE);
}
} | [
"public",
"function",
"onAfterUnpublish",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"owner",
"->",
"Fields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"field",
"->",
"deleteFromStage",
"(",
"Versioned",
"::",
"LIVE",
")",
";",
"}",
"}"
] | Remove all fields from the live stage when unpublishing the page | [
"Remove",
"all",
"fields",
"from",
"the",
"live",
"stage",
"when",
"unpublishing",
"the",
"page"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Extension/UserFormFieldEditorExtension.php#L207-L212 |
silverstripe/silverstripe-userforms | code/Extension/UserFormFieldEditorExtension.php | UserFormFieldEditorExtension.onAfterDuplicate | public function onAfterDuplicate($oldPage, $doWrite, $manyMany)
{
// List of EditableFieldGroups, where the key of the array is the ID of the old end group
$fieldGroups = [];
foreach ($oldPage->Fields() as $field) {
/** @var EditableFormField $newField */
$newField = ... | php | public function onAfterDuplicate($oldPage, $doWrite, $manyMany)
{
// List of EditableFieldGroups, where the key of the array is the ID of the old end group
$fieldGroups = [];
foreach ($oldPage->Fields() as $field) {
/** @var EditableFormField $newField */
$newField = ... | [
"public",
"function",
"onAfterDuplicate",
"(",
"$",
"oldPage",
",",
"$",
"doWrite",
",",
"$",
"manyMany",
")",
"{",
"// List of EditableFieldGroups, where the key of the array is the ID of the old end group",
"$",
"fieldGroups",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
... | When duplicating a UserDefinedForm, duplicate all of its fields and display rules
@see \SilverStripe\ORM\DataObject::duplicate
@param \SilverStripe\ORM\DataObject $oldPage
@param bool $doWrite
@param string $manyMany
@return \SilverStripe\ORM\DataObject | [
"When",
"duplicating",
"a",
"UserDefinedForm",
"duplicate",
"all",
"of",
"its",
"fields",
"and",
"display",
"rules"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Extension/UserFormFieldEditorExtension.php#L223-L254 |
silverstripe/silverstripe-userforms | code/Control/UserDefinedFormController.php | UserDefinedFormController.addUserFormsValidatei18n | protected function addUserFormsValidatei18n()
{
$module = ModuleLoader::getModule('silverstripe/userforms');
$candidates = [
i18n::getData()->langFromLocale(i18n::config()->get('default_locale')),
i18n::config()->get('default_locale'),
i18n::getData()->langFromLo... | php | protected function addUserFormsValidatei18n()
{
$module = ModuleLoader::getModule('silverstripe/userforms');
$candidates = [
i18n::getData()->langFromLocale(i18n::config()->get('default_locale')),
i18n::config()->get('default_locale'),
i18n::getData()->langFromLo... | [
"protected",
"function",
"addUserFormsValidatei18n",
"(",
")",
"{",
"$",
"module",
"=",
"ModuleLoader",
"::",
"getModule",
"(",
"'silverstripe/userforms'",
")",
";",
"$",
"candidates",
"=",
"[",
"i18n",
"::",
"getData",
"(",
")",
"->",
"langFromLocale",
"(",
"... | Add the necessary jQuery validate i18n translation files, either by locale or by langauge,
e.g. 'en_NZ' or 'en'. This adds "methods_abc.min.js" as well as "messages_abc.min.js" from the
jQuery validate thirdparty library. | [
"Add",
"the",
"necessary",
"jQuery",
"validate",
"i18n",
"translation",
"files",
"either",
"by",
"locale",
"or",
"by",
"langauge",
"e",
".",
"g",
".",
"en_NZ",
"or",
"en",
".",
"This",
"adds",
"methods_abc",
".",
"min",
".",
"js",
"as",
"well",
"as",
"... | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Control/UserDefinedFormController.php#L80-L101 |
silverstripe/silverstripe-userforms | code/Control/UserDefinedFormController.php | UserDefinedFormController.index | public function index(HTTPRequest $request = null)
{
$form = $this->Form();
if ($this->Content && $form && !$this->config()->disable_form_content_shortcode) {
$hasLocation = stristr($this->Content, '$UserDefinedForm');
if ($hasLocation) {
/** @see Requirements... | php | public function index(HTTPRequest $request = null)
{
$form = $this->Form();
if ($this->Content && $form && !$this->config()->disable_form_content_shortcode) {
$hasLocation = stristr($this->Content, '$UserDefinedForm');
if ($hasLocation) {
/** @see Requirements... | [
"public",
"function",
"index",
"(",
"HTTPRequest",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"Form",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Content",
"&&",
"$",
"form",
"&&",
"!",
"$",
"this",
"->",
"confi... | Using $UserDefinedForm in the Content area of the page shows
where the form should be rendered into. If it does not exist
then default back to $Form.
@return array | [
"Using",
"$UserDefinedForm",
"in",
"the",
"Content",
"area",
"of",
"the",
"page",
"shows",
"where",
"the",
"form",
"should",
"be",
"rendered",
"into",
".",
"If",
"it",
"does",
"not",
"exist",
"then",
"default",
"back",
"to",
"$Form",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Control/UserDefinedFormController.php#L110-L134 |
silverstripe/silverstripe-userforms | code/Control/UserDefinedFormController.php | UserDefinedFormController.Form | public function Form()
{
$form = UserForm::create($this, 'Form_' . $this->ID);
/** @skipUpgrade */
$form->setFormAction(Controller::join_links($this->Link(), 'Form'));
$this->generateConditionalJavascript();
return $form;
} | php | public function Form()
{
$form = UserForm::create($this, 'Form_' . $this->ID);
/** @skipUpgrade */
$form->setFormAction(Controller::join_links($this->Link(), 'Form'));
$this->generateConditionalJavascript();
return $form;
} | [
"public",
"function",
"Form",
"(",
")",
"{",
"$",
"form",
"=",
"UserForm",
"::",
"create",
"(",
"$",
"this",
",",
"'Form_'",
".",
"$",
"this",
"->",
"ID",
")",
";",
"/** @skipUpgrade */",
"$",
"form",
"->",
"setFormAction",
"(",
"Controller",
"::",
"jo... | Get the form for the page. Form can be modified by calling {@link updateForm()}
on a UserDefinedForm extension.
@return Form | [
"Get",
"the",
"form",
"for",
"the",
"page",
".",
"Form",
"can",
"be",
"modified",
"by",
"calling",
"{",
"@link",
"updateForm",
"()",
"}",
"on",
"a",
"UserDefinedForm",
"extension",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Control/UserDefinedFormController.php#L152-L159 |
silverstripe/silverstripe-userforms | code/Control/UserDefinedFormController.php | UserDefinedFormController.generateConditionalJavascript | public function generateConditionalJavascript()
{
$rules = '';
$form = $this->data();
if (!$form) {
return;
}
$formFields = $form->Fields();
$watch = [];
if ($formFields) {
/** @var EditableFormField $field */
foreach ($fo... | php | public function generateConditionalJavascript()
{
$rules = '';
$form = $this->data();
if (!$form) {
return;
}
$formFields = $form->Fields();
$watch = [];
if ($formFields) {
/** @var EditableFormField $field */
foreach ($fo... | [
"public",
"function",
"generateConditionalJavascript",
"(",
")",
"{",
"$",
"rules",
"=",
"''",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"data",
"(",
")",
";",
"if",
"(",
"!",
"$",
"form",
")",
"{",
"return",
";",
"}",
"$",
"formFields",
"=",
"$",
... | Generate the javascript for the conditional field show / hiding logic.
@return void | [
"Generate",
"the",
"javascript",
"for",
"the",
"conditional",
"field",
"show",
"/",
"hiding",
"logic",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Control/UserDefinedFormController.php#L166-L200 |
silverstripe/silverstripe-userforms | code/Control/UserDefinedFormController.php | UserDefinedFormController.process | public function process($data, $form)
{
$submittedForm = SubmittedForm::create();
$submittedForm->SubmittedByID = Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0;
$submittedForm->ParentClass = get_class($this->data());
$submittedForm->ParentID = $this->ID;
//... | php | public function process($data, $form)
{
$submittedForm = SubmittedForm::create();
$submittedForm->SubmittedByID = Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0;
$submittedForm->ParentClass = get_class($this->data());
$submittedForm->ParentID = $this->ID;
//... | [
"public",
"function",
"process",
"(",
"$",
"data",
",",
"$",
"form",
")",
"{",
"$",
"submittedForm",
"=",
"SubmittedForm",
"::",
"create",
"(",
")",
";",
"$",
"submittedForm",
"->",
"SubmittedByID",
"=",
"Security",
"::",
"getCurrentUser",
"(",
")",
"?",
... | Process the form that is submitted through the site
{@see UserForm::validate()} for validation step prior to processing
@param array $data
@param Form $form
@return HTTPResponse | [
"Process",
"the",
"form",
"that",
"is",
"submitted",
"through",
"the",
"site"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Control/UserDefinedFormController.php#L212-L427 |
silverstripe/silverstripe-userforms | code/Control/UserDefinedFormController.php | UserDefinedFormController.getMergeFieldsMap | protected function getMergeFieldsMap($fields = [])
{
$data = ArrayData::create([]);
foreach ($fields as $field) {
$data->setField($field->Name, DBField::create_field('Text', $field->Value));
}
return $data;
} | php | protected function getMergeFieldsMap($fields = [])
{
$data = ArrayData::create([]);
foreach ($fields as $field) {
$data->setField($field->Name, DBField::create_field('Text', $field->Value));
}
return $data;
} | [
"protected",
"function",
"getMergeFieldsMap",
"(",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"ArrayData",
"::",
"create",
"(",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"data",
"->",
"setF... | Allows the use of field values in email body.
@param ArrayList $fields
@return ArrayData | [
"Allows",
"the",
"use",
"of",
"field",
"values",
"in",
"email",
"body",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Control/UserDefinedFormController.php#L435-L444 |
silverstripe/silverstripe-userforms | code/Control/UserDefinedFormController.php | UserDefinedFormController.finished | public function finished()
{
$submission = $this->getRequest()->getSession()->get('userformssubmission'. $this->ID);
if ($submission) {
$submission = SubmittedForm::get()->byId($submission);
}
$referrer = isset($_GET['referrer']) ? urldecode($_GET['referrer']) : null;
... | php | public function finished()
{
$submission = $this->getRequest()->getSession()->get('userformssubmission'. $this->ID);
if ($submission) {
$submission = SubmittedForm::get()->byId($submission);
}
$referrer = isset($_GET['referrer']) ? urldecode($_GET['referrer']) : null;
... | [
"public",
"function",
"finished",
"(",
")",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getSession",
"(",
")",
"->",
"get",
"(",
"'userformssubmission'",
".",
"$",
"this",
"->",
"ID",
")",
";",
"if",
"(",
"$",
"subm... | This action handles rendering the "finished" message, which is
customizable by editing the ReceivedFormSubmission template.
@return ViewableData | [
"This",
"action",
"handles",
"rendering",
"the",
"finished",
"message",
"which",
"is",
"customizable",
"by",
"editing",
"the",
"ReceivedFormSubmission",
"template",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Control/UserDefinedFormController.php#L452-L493 |
silverstripe/silverstripe-userforms | code/Control/UserDefinedFormController.php | UserDefinedFormController.buildWatchJS | protected function buildWatchJS($watch)
{
$result = '';
foreach ($watch as $key => $rule) {
$events = implode(' ', $rule['events']);
$selectors = implode(', ', $rule['selectors']);
$conjunction = $rule['conjunction'];
$operations = implode(" {$conjunct... | php | protected function buildWatchJS($watch)
{
$result = '';
foreach ($watch as $key => $rule) {
$events = implode(' ', $rule['events']);
$selectors = implode(', ', $rule['selectors']);
$conjunction = $rule['conjunction'];
$operations = implode(" {$conjunct... | [
"protected",
"function",
"buildWatchJS",
"(",
"$",
"watch",
")",
"{",
"$",
"result",
"=",
"''",
";",
"foreach",
"(",
"$",
"watch",
"as",
"$",
"key",
"=>",
"$",
"rule",
")",
"{",
"$",
"events",
"=",
"implode",
"(",
"' '",
",",
"$",
"rule",
"[",
"'... | Outputs the required JS from the $watch input
@param array $watch
@return string | [
"Outputs",
"the",
"required",
"JS",
"from",
"the",
"$watch",
"input"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Control/UserDefinedFormController.php#L502-L531 |
silverstripe/silverstripe-userforms | code/Model/Recipient/UserFormRecipientItemRequest.php | UserFormRecipientItemRequest.preview | public function preview()
{
// Enable theme for preview (may be needed for Shortcodes)
Config::nest();
Config::modify()->set(SSViewer::class, 'theme_enabled', true);
$content = $this->customise([
'Body' => $this->record->getEmailBodyContent(),
'HideFormData' ... | php | public function preview()
{
// Enable theme for preview (may be needed for Shortcodes)
Config::nest();
Config::modify()->set(SSViewer::class, 'theme_enabled', true);
$content = $this->customise([
'Body' => $this->record->getEmailBodyContent(),
'HideFormData' ... | [
"public",
"function",
"preview",
"(",
")",
"{",
"// Enable theme for preview (may be needed for Shortcodes)",
"Config",
"::",
"nest",
"(",
")",
";",
"Config",
"::",
"modify",
"(",
")",
"->",
"set",
"(",
"SSViewer",
"::",
"class",
",",
"'theme_enabled'",
",",
"tr... | Renders a preview of the recipient email. | [
"Renders",
"a",
"preview",
"of",
"the",
"recipient",
"email",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/Recipient/UserFormRecipientItemRequest.php#L31-L46 |
silverstripe/silverstripe-userforms | code/Model/Recipient/UserFormRecipientItemRequest.php | UserFormRecipientItemRequest.getPreviewFieldData | protected function getPreviewFieldData()
{
$data = ArrayList::create();
$fields = $this->record->Form()->Fields()->filter(
'ClassName:not',
[
EditableLiteralField::class,
EditableFormHeading::class,
]
);
foreach ($... | php | protected function getPreviewFieldData()
{
$data = ArrayList::create();
$fields = $this->record->Form()->Fields()->filter(
'ClassName:not',
[
EditableLiteralField::class,
EditableFormHeading::class,
]
);
foreach ($... | [
"protected",
"function",
"getPreviewFieldData",
"(",
")",
"{",
"$",
"data",
"=",
"ArrayList",
"::",
"create",
"(",
")",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"record",
"->",
"Form",
"(",
")",
"->",
"Fields",
"(",
")",
"->",
"filter",
"(",
"'Cla... | Get some placeholder field values to display in the preview
@return ArrayList | [
"Get",
"some",
"placeholder",
"field",
"values",
"to",
"display",
"in",
"the",
"preview"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/Recipient/UserFormRecipientItemRequest.php#L53-L75 |
silverstripe/silverstripe-userforms | code/Model/EditableCustomRule.php | EditableCustomRule.buildExpression | public function buildExpression()
{
/** @var EditableFormField $formFieldWatch */
$formFieldWatch = $this->ConditionField();
//Encapsulated the action to the object
$action = $formFieldWatch->getJsEventHandler();
// is this field a special option field
$checkboxField... | php | public function buildExpression()
{
/** @var EditableFormField $formFieldWatch */
$formFieldWatch = $this->ConditionField();
//Encapsulated the action to the object
$action = $formFieldWatch->getJsEventHandler();
// is this field a special option field
$checkboxField... | [
"public",
"function",
"buildExpression",
"(",
")",
"{",
"/** @var EditableFormField $formFieldWatch */",
"$",
"formFieldWatch",
"=",
"$",
"this",
"->",
"ConditionField",
"(",
")",
";",
"//Encapsulated the action to the object",
"$",
"action",
"=",
"$",
"formFieldWatch",
... | Substitutes configured rule logic with it's JS equivalents and returns them as array elements
@return array
@throws LogicException If the provided condition option was not able to be handled | [
"Substitutes",
"configured",
"rule",
"logic",
"with",
"it",
"s",
"JS",
"equivalents",
"and",
"returns",
"them",
"as",
"array",
"elements"
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/EditableCustomRule.php#L151-L231 |
silverstripe/silverstripe-userforms | code/Model/EditableCustomRule.php | EditableCustomRule.toggleDisplayText | public function toggleDisplayText($initialState, $invert = false)
{
$action = strtolower($initialState) === 'hide' ? 'removeClass' : 'addClass';
if ($invert) {
$action = $action === 'removeClass' ? 'addClass' : 'removeClass';
}
return sprintf('%s("hide")', $action);
} | php | public function toggleDisplayText($initialState, $invert = false)
{
$action = strtolower($initialState) === 'hide' ? 'removeClass' : 'addClass';
if ($invert) {
$action = $action === 'removeClass' ? 'addClass' : 'removeClass';
}
return sprintf('%s("hide")', $action);
} | [
"public",
"function",
"toggleDisplayText",
"(",
"$",
"initialState",
",",
"$",
"invert",
"=",
"false",
")",
"{",
"$",
"action",
"=",
"strtolower",
"(",
"$",
"initialState",
")",
"===",
"'hide'",
"?",
"'removeClass'",
":",
"'addClass'",
";",
"if",
"(",
"$",... | Returns the opposite visibility function for the value of the initial visibility field, e.g. show/hide. This
will toggle the "hide" class either way, which is handled by CSS.
@param string $initialState
@param boolean $invert
@return string | [
"Returns",
"the",
"opposite",
"visibility",
"function",
"for",
"the",
"value",
"of",
"the",
"initial",
"visibility",
"field",
"e",
".",
"g",
".",
"show",
"/",
"hide",
".",
"This",
"will",
"toggle",
"the",
"hide",
"class",
"either",
"way",
"which",
"is",
... | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/EditableCustomRule.php#L241-L248 |
silverstripe/silverstripe-userforms | code/Model/EditableCustomRule.php | EditableCustomRule.toggleDisplayEvent | public function toggleDisplayEvent($initialState, $invert = false)
{
$action = strtolower($initialState) === 'hide' ? 'show' : 'hide';
if ($invert) {
$action = $action === 'hide' ? 'show' : 'hide';
}
return sprintf('userform.field.%s', $action);
} | php | public function toggleDisplayEvent($initialState, $invert = false)
{
$action = strtolower($initialState) === 'hide' ? 'show' : 'hide';
if ($invert) {
$action = $action === 'hide' ? 'show' : 'hide';
}
return sprintf('userform.field.%s', $action);
} | [
"public",
"function",
"toggleDisplayEvent",
"(",
"$",
"initialState",
",",
"$",
"invert",
"=",
"false",
")",
"{",
"$",
"action",
"=",
"strtolower",
"(",
"$",
"initialState",
")",
"===",
"'hide'",
"?",
"'show'",
":",
"'hide'",
";",
"if",
"(",
"$",
"invert... | Returns an event name to be dispatched when the field is changed. Matches up with the visibility classes
added or removed in `toggleDisplayText()`.
@param string $initialState
@param bool $invert
@return string | [
"Returns",
"an",
"event",
"name",
"to",
"be",
"dispatched",
"when",
"the",
"field",
"is",
"changed",
".",
"Matches",
"up",
"with",
"the",
"visibility",
"classes",
"added",
"or",
"removed",
"in",
"toggleDisplayText",
"()",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/EditableCustomRule.php#L258-L265 |
silverstripe/silverstripe-userforms | code/Model/Submission/SubmittedFileField.php | SubmittedFileField.getFormattedValue | public function getFormattedValue()
{
$name = $this->getFileName();
$link = $this->getLink();
$title = _t(__CLASS__.'.DOWNLOADFILE', 'Download File');
if ($link) {
return DBField::create_field('HTMLText', sprintf(
'%s - <a href="%s" target="_blank">%s</a>... | php | public function getFormattedValue()
{
$name = $this->getFileName();
$link = $this->getLink();
$title = _t(__CLASS__.'.DOWNLOADFILE', 'Download File');
if ($link) {
return DBField::create_field('HTMLText', sprintf(
'%s - <a href="%s" target="_blank">%s</a>... | [
"public",
"function",
"getFormattedValue",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getFileName",
"(",
")",
";",
"$",
"link",
"=",
"$",
"this",
"->",
"getLink",
"(",
")",
";",
"$",
"title",
"=",
"_t",
"(",
"__CLASS__",
".",
"'.DOWNLOADFIL... | Return the value of this field for inclusion into things such as
reports.
@return string | [
"Return",
"the",
"value",
"of",
"this",
"field",
"for",
"inclusion",
"into",
"things",
"such",
"as",
"reports",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/Submission/SubmittedFileField.php#L29-L45 |
silverstripe/silverstripe-userforms | code/Model/Submission/SubmittedFileField.php | SubmittedFileField.getLink | public function getLink()
{
if ($file = $this->UploadedFile()) {
if (trim($file->getFilename(), '/') != trim(ASSETS_DIR, '/')) {
return $this->UploadedFile()->AbsoluteLink();
}
}
} | php | public function getLink()
{
if ($file = $this->UploadedFile()) {
if (trim($file->getFilename(), '/') != trim(ASSETS_DIR, '/')) {
return $this->UploadedFile()->AbsoluteLink();
}
}
} | [
"public",
"function",
"getLink",
"(",
")",
"{",
"if",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"UploadedFile",
"(",
")",
")",
"{",
"if",
"(",
"trim",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
",",
"'/'",
")",
"!=",
"trim",
"(",
"ASSETS_DI... | Return the link for the file attached to this submitted form field.
@return string | [
"Return",
"the",
"link",
"for",
"the",
"file",
"attached",
"to",
"this",
"submitted",
"form",
"field",
"."
] | train | https://github.com/silverstripe/silverstripe-userforms/blob/6eb661fedf5f1cb70a814a1c2354e627b28273e3/code/Model/Submission/SubmittedFileField.php#L62-L69 |
core23/DompdfBundle | src/Wrapper/DompdfWrapper.php | DompdfWrapper.streamHtml | public function streamHtml(string $html, string $filename, array $options = []): void
{
$pdf = $this->dompdfFactory->create($options);
$pdf->loadHtml($html);
$pdf->render();
if ($this->eventDispatcher instanceof EventDispatcherInterface) {
$event = new StreamEvent($pdf, ... | php | public function streamHtml(string $html, string $filename, array $options = []): void
{
$pdf = $this->dompdfFactory->create($options);
$pdf->loadHtml($html);
$pdf->render();
if ($this->eventDispatcher instanceof EventDispatcherInterface) {
$event = new StreamEvent($pdf, ... | [
"public",
"function",
"streamHtml",
"(",
"string",
"$",
"html",
",",
"string",
"$",
"filename",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"void",
"{",
"$",
"pdf",
"=",
"$",
"this",
"->",
"dompdfFactory",
"->",
"create",
"(",
"$",
"option... | {@inheritdoc} | [
"{"
] | train | https://github.com/core23/DompdfBundle/blob/d24afba1351c807ddff35df53500ec81c9cae5cf/src/Wrapper/DompdfWrapper.php#L47-L59 |
core23/DompdfBundle | src/Wrapper/DompdfWrapper.php | DompdfWrapper.getStreamResponse | public function getStreamResponse(string $html, string $filename, array $options = []): StreamedResponse
{
$response = new StreamedResponse();
$response->setCallback(function () use ($html, $filename, $options): void {
$this->streamHtml($html, $filename, $options);
});
r... | php | public function getStreamResponse(string $html, string $filename, array $options = []): StreamedResponse
{
$response = new StreamedResponse();
$response->setCallback(function () use ($html, $filename, $options): void {
$this->streamHtml($html, $filename, $options);
});
r... | [
"public",
"function",
"getStreamResponse",
"(",
"string",
"$",
"html",
",",
"string",
"$",
"filename",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"StreamedResponse",
"{",
"$",
"response",
"=",
"new",
"StreamedResponse",
"(",
")",
";",
"$",
"r... | @param string $html
@param string $filename
@param array $options
@return StreamedResponse | [
"@param",
"string",
"$html",
"@param",
"string",
"$filename",
"@param",
"array",
"$options"
] | train | https://github.com/core23/DompdfBundle/blob/d24afba1351c807ddff35df53500ec81c9cae5cf/src/Wrapper/DompdfWrapper.php#L68-L76 |
core23/DompdfBundle | src/Wrapper/DompdfWrapper.php | DompdfWrapper.getPdf | public function getPdf(string $html, array $options = []): string
{
$pdf = $this->dompdfFactory->create($options);
$pdf->loadHtml($html);
$pdf->render();
if ($this->eventDispatcher instanceof EventDispatcherInterface) {
$event = new OutputEvent($pdf, $html);
... | php | public function getPdf(string $html, array $options = []): string
{
$pdf = $this->dompdfFactory->create($options);
$pdf->loadHtml($html);
$pdf->render();
if ($this->eventDispatcher instanceof EventDispatcherInterface) {
$event = new OutputEvent($pdf, $html);
... | [
"public",
"function",
"getPdf",
"(",
"string",
"$",
"html",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"pdf",
"=",
"$",
"this",
"->",
"dompdfFactory",
"->",
"create",
"(",
"$",
"options",
")",
";",
"$",
"pdf",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/core23/DompdfBundle/blob/d24afba1351c807ddff35df53500ec81c9cae5cf/src/Wrapper/DompdfWrapper.php#L81-L99 |
core23/DompdfBundle | src/DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('core23_dompdf');
// Keep compatibility with symfony/config < 4.2
if (!method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->root('core23_dompdf');
} else {
$rootNode = ... | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('core23_dompdf');
// Keep compatibility with symfony/config < 4.2
if (!method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->root('core23_dompdf');
} else {
$rootNode = ... | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
"'core23_dompdf'",
")",
";",
"// Keep compatibility with symfony/config < 4.2",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"treeBuilder",
",",
"'getRootNod... | {@inheritdoc} | [
"{"
] | train | https://github.com/core23/DompdfBundle/blob/d24afba1351c807ddff35df53500ec81c9cae5cf/src/DependencyInjection/Configuration.php#L23-L48 |
evias/nem-php | src/Models/Transaction/MosaicSupplyChange.php | MosaicSupplyChange.extend | public function extend()
{
// supply type validation
$type = $this->getAttribute("supplyType");
$validTypes = [self::TYPE_INCREASE, self::TYPE_DECREASE];
if (! $type || ! in_array($type, $validTypes)) {
$type = self::TYPE_INCREASE;
$this->setAttribute("supply... | php | public function extend()
{
// supply type validation
$type = $this->getAttribute("supplyType");
$validTypes = [self::TYPE_INCREASE, self::TYPE_DECREASE];
if (! $type || ! in_array($type, $validTypes)) {
$type = self::TYPE_INCREASE;
$this->setAttribute("supply... | [
"public",
"function",
"extend",
"(",
")",
"{",
"// supply type validation",
"$",
"type",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"supplyType\"",
")",
";",
"$",
"validTypes",
"=",
"[",
"self",
"::",
"TYPE_INCREASE",
",",
"self",
"::",
"TYPE_DECREASE",
... | The Signature transaction type does not need to add an offset to
the transaction base DTO.
@return array | [
"The",
"Signature",
"transaction",
"type",
"does",
"not",
"need",
"to",
"add",
"an",
"offset",
"to",
"the",
"transaction",
"base",
"DTO",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/MosaicSupplyChange.php#L64-L84 |
evias/nem-php | src/Models/Transaction/MosaicSupplyChange.php | MosaicSupplyChange.serialize | public function serialize($parameters = null)
{
$baseTx = parent::serialize($parameters);
$nisData = $this->extend();
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_mosaic = $this->mosaicId()->ser... | php | public function serialize($parameters = null)
{
$baseTx = parent::serialize($parameters);
$nisData = $this->extend();
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_mosaic = $this->mosaicId()->ser... | [
"public",
"function",
"serialize",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"baseTx",
"=",
"parent",
"::",
"serialize",
"(",
"$",
"parameters",
")",
";",
"$",
"nisData",
"=",
"$",
"this",
"->",
"extend",
"(",
")",
";",
"// shortcuts",
"$",
... | Overload of the \NEM\Core\Model::serialize() method to provide
with a specialization for *MosaicSupplyChange* serialization.
@see \NEM\Contracts\Serializable
@param null|string $parameters non-null will return only the named sub-dtos.
@return array Returns a byte-array with values in UInt8 representation. | [
"Overload",
"of",
"the",
"\\",
"NEM",
"\\",
"Core",
"\\",
"Model",
"::",
"serialize",
"()",
"method",
"to",
"provide",
"with",
"a",
"specialization",
"for",
"*",
"MosaicSupplyChange",
"*",
"serialization",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/MosaicSupplyChange.php#L105-L127 |
evias/nem-php | src/Models/Mutators/CollectionMutator.php | CollectionMutator.mutate | public function mutate($name, $items)
{
// snake_case to camelCase
$modelClass = "\\NEM\\Models\\" . Str::studly($name);
if (!class_exists($modelClass)) {
throw new BadMethodCallException("Model class '" . $modelClass . "' could not be found in \\NEM\\Model namespace.");
... | php | public function mutate($name, $items)
{
// snake_case to camelCase
$modelClass = "\\NEM\\Models\\" . Str::studly($name);
if (!class_exists($modelClass)) {
throw new BadMethodCallException("Model class '" . $modelClass . "' could not be found in \\NEM\\Model namespace.");
... | [
"public",
"function",
"mutate",
"(",
"$",
"name",
",",
"$",
"items",
")",
"{",
"// snake_case to camelCase",
"$",
"modelClass",
"=",
"\"\\\\NEM\\\\Models\\\\\"",
".",
"Str",
"::",
"studly",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"... | Collect several items into a Collection of Models.
The \NEM\Models\ModelMutator will be used internally to craft singular
model objects for each item you pass to this method.
@internal
@param string $name The model name you would like to store in the collection.
@param array $items The colle... | [
"Collect",
"several",
"items",
"into",
"a",
"Collection",
"of",
"Models",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Mutators/CollectionMutator.php#L50-L88 |
evias/nem-php | src/Models/Transaction/NamespaceProvision.php | NamespaceProvision.extend | public function extend()
{
return [
"rentalFeeSink" => $this->rentalFeeSink()->address()->toClean(),
"rentalFee" => empty($this->parent) ? Fee::ROOT_PROVISION_NAMESPACE : Fee::SUB_PROVISION_NAMESPACE,
"parent" => $this->parent,
"newPart" => $this->newPart,
... | php | public function extend()
{
return [
"rentalFeeSink" => $this->rentalFeeSink()->address()->toClean(),
"rentalFee" => empty($this->parent) ? Fee::ROOT_PROVISION_NAMESPACE : Fee::SUB_PROVISION_NAMESPACE,
"parent" => $this->parent,
"newPart" => $this->newPart,
... | [
"public",
"function",
"extend",
"(",
")",
"{",
"return",
"[",
"\"rentalFeeSink\"",
"=>",
"$",
"this",
"->",
"rentalFeeSink",
"(",
")",
"->",
"address",
"(",
")",
"->",
"toClean",
"(",
")",
",",
"\"rentalFee\"",
"=>",
"empty",
"(",
"$",
"this",
"->",
"p... | Return specialized fields array for Namespace Provision Transactions.
@return array | [
"Return",
"specialized",
"fields",
"array",
"for",
"Namespace",
"Provision",
"Transactions",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/NamespaceProvision.php#L56-L66 |
evias/nem-php | src/Models/Transaction/NamespaceProvision.php | NamespaceProvision.serialize | public function serialize($parameters = null)
{
$baseTx = parent::serialize($parameters);
$nisData = $this->extend();
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_sink = $serializer->serializeSt... | php | public function serialize($parameters = null)
{
$baseTx = parent::serialize($parameters);
$nisData = $this->extend();
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_sink = $serializer->serializeSt... | [
"public",
"function",
"serialize",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"baseTx",
"=",
"parent",
"::",
"serialize",
"(",
"$",
"parameters",
")",
";",
"$",
"nisData",
"=",
"$",
"this",
"->",
"extend",
"(",
")",
";",
"// shortcuts",
"$",
... | Overload of the \NEM\Core\Model::serialize() method to provide
with a specialization for *NamespaceProvision* serialization.
@see \NEM\Contracts\Serializable
@param null|string $parameters non-null will return only the named sub-dtos.
@return array Returns a byte-array with values in UInt8 representation. | [
"Overload",
"of",
"the",
"\\",
"NEM",
"\\",
"Core",
"\\",
"Model",
"::",
"serialize",
"()",
"method",
"to",
"provide",
"with",
"a",
"specialization",
"for",
"*",
"NamespaceProvision",
"*",
"serialization",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/NamespaceProvision.php#L87-L116 |
evias/nem-php | src/Handlers/AbstractRequestHandler.php | AbstractRequestHandler.normalizeHeaders | protected function normalizeHeaders(array $headers)
{
if (empty($headers["User-Agent"]))
$headers["User-Agent"] = "evias NEM Blockchain Wrapper";
if (empty($headers["Accept"]))
$headers["Accept"] = "application/json";
if (empty($headers["Content-Type"]))
... | php | protected function normalizeHeaders(array $headers)
{
if (empty($headers["User-Agent"]))
$headers["User-Agent"] = "evias NEM Blockchain Wrapper";
if (empty($headers["Accept"]))
$headers["Accept"] = "application/json";
if (empty($headers["Content-Type"]))
... | [
"protected",
"function",
"normalizeHeaders",
"(",
"array",
"$",
"headers",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"headers",
"[",
"\"User-Agent\"",
"]",
")",
")",
"$",
"headers",
"[",
"\"User-Agent\"",
"]",
"=",
"\"evias NEM Blockchain Wrapper\"",
";",
"if",
... | This method makes sure mandatory headers are
added in case they are not present.
@param array $headers [description]
@return [type] [description] | [
"This",
"method",
"makes",
"sure",
"mandatory",
"headers",
"are",
"added",
"in",
"case",
"they",
"are",
"not",
"present",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Handlers/AbstractRequestHandler.php#L45-L57 |
evias/nem-php | src/Models/Mosaic.php | Mosaic.create | static public function create(string $namespace, string $mosaic = null)
{
if (empty($mosaic)) {
// `namespace` should contain `FQN`
$fullyQualifiedName = $namespace;
$splitRegexp = "/([^:]+):([^:]+)/";
// split with format: `namespace:mosaic`
$nam... | php | static public function create(string $namespace, string $mosaic = null)
{
if (empty($mosaic)) {
// `namespace` should contain `FQN`
$fullyQualifiedName = $namespace;
$splitRegexp = "/([^:]+):([^:]+)/";
// split with format: `namespace:mosaic`
$nam... | [
"static",
"public",
"function",
"create",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"mosaic",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"mosaic",
")",
")",
"{",
"// `namespace` should contain `FQN`",
"$",
"fullyQualifiedName",
"=",
"$",... | Class method to create a new `Mosaic` object from `namespace`
name and `mosaic` mosaic name.
@param string $namespace
@param string $mosaic
@return \NEM\Models\Mosaic | [
"Class",
"method",
"to",
"create",
"a",
"new",
"Mosaic",
"object",
"from",
"namespace",
"name",
"and",
"mosaic",
"mosaic",
"name",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Mosaic.php#L52-L72 |
evias/nem-php | src/Models/Mosaic.php | Mosaic.serialize | public function serialize($parameters = null)
{
$nisData = $this->toDTO();
// shortcuts
$serializer = $this->getSerializer();
$namespace = $nisData["namespaceId"];
$mosaicName = $nisData["name"];
$serializedNS = $serializer->serializeString($namespace);
$se... | php | public function serialize($parameters = null)
{
$nisData = $this->toDTO();
// shortcuts
$serializer = $this->getSerializer();
$namespace = $nisData["namespaceId"];
$mosaicName = $nisData["name"];
$serializedNS = $serializer->serializeString($namespace);
$se... | [
"public",
"function",
"serialize",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"nisData",
"=",
"$",
"this",
"->",
"toDTO",
"(",
")",
";",
"// shortcuts",
"$",
"serializer",
"=",
"$",
"this",
"->",
"getSerializer",
"(",
")",
";",
"$",
"namespace... | Overload of the \NEM\Core\Model::serialize() method to provide
with a specialization for *mosaicId* serialization.
@see \NEM\Contracts\Serializable
@param null|string $parameters non-null will return only the named sub-dtos.
@return array Returns a byte-array with values in UInt8 representation. | [
"Overload",
"of",
"the",
"\\",
"NEM",
"\\",
"Core",
"\\",
"Model",
"::",
"serialize",
"()",
"method",
"to",
"provide",
"with",
"a",
"specialization",
"for",
"*",
"mosaicId",
"*",
"serialization",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Mosaic.php#L96-L109 |
evias/nem-php | src/Models/Mosaic.php | Mosaic.getFQN | public function getFQN()
{
if (empty($this->namespaceId) || empty($this->name))
return "";
return sprintf("%s:%s", $this->namespaceId, $this->name);
} | php | public function getFQN()
{
if (empty($this->namespaceId) || empty($this->name))
return "";
return sprintf("%s:%s", $this->namespaceId, $this->name);
} | [
"public",
"function",
"getFQN",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"namespaceId",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"name",
")",
")",
"return",
"\"\"",
";",
"return",
"sprintf",
"(",
"\"%s:%s\"",
",",
"$",
"this",
... | Getter for the *fully qualified name* of the Mosaic.
@return string | [
"Getter",
"for",
"the",
"*",
"fully",
"qualified",
"name",
"*",
"of",
"the",
"Mosaic",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Mosaic.php#L116-L122 |
evias/nem-php | src/Mosaics/Pacnem/Cheese.php | Cheese.levy | public function levy(array $levy = null)
{
$xem = new Mosaic(["namespaceId" => "nem", "name" => "xem"]);
$data = $levy ?: [
"type" => MosaicLevy::TYPE_PERCENTILE,
"fee" => 100,
"recipient" => "NDHGYUVXKUWYFNO6THLUKAF6ZH2WIDCC6XD5UPC4",
"mosaicId" => $x... | php | public function levy(array $levy = null)
{
$xem = new Mosaic(["namespaceId" => "nem", "name" => "xem"]);
$data = $levy ?: [
"type" => MosaicLevy::TYPE_PERCENTILE,
"fee" => 100,
"recipient" => "NDHGYUVXKUWYFNO6THLUKAF6ZH2WIDCC6XD5UPC4",
"mosaicId" => $x... | [
"public",
"function",
"levy",
"(",
"array",
"$",
"levy",
"=",
"null",
")",
"{",
"$",
"xem",
"=",
"new",
"Mosaic",
"(",
"[",
"\"namespaceId\"",
"=>",
"\"nem\"",
",",
"\"name\"",
"=>",
"\"xem\"",
"]",
")",
";",
"$",
"data",
"=",
"$",
"levy",
"?",
":"... | Mutator for `levy` relation.
This will return a NIS compliant [MosaicLevy](https://bob.nem.ninja/docs/#mosaicLevy) object.
@param array $mosaidId Array should contain offsets `type`, `recipient`, `mosaicId` and `fee`.
@return \NEM\Models\MosaicLevy | [
"Mutator",
"for",
"levy",
"relation",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Mosaics/Pacnem/Cheese.php#L80-L91 |
evias/nem-php | src/Models/Address.php | Address.fromPublicKey | static public function fromPublicKey($publicKey, $networkId = 104) // 104=mainnet
{
// discover public key content
if ($publicKey instanceof Buffer) {
$pubKeyBuf = $publicKey; // Buffer to public key
}
elseif ($publicKey instanceof KeyPair) {
$pubKeyBuf = $pub... | php | static public function fromPublicKey($publicKey, $networkId = 104) // 104=mainnet
{
// discover public key content
if ($publicKey instanceof Buffer) {
$pubKeyBuf = $publicKey; // Buffer to public key
}
elseif ($publicKey instanceof KeyPair) {
$pubKeyBuf = $pub... | [
"static",
"public",
"function",
"fromPublicKey",
"(",
"$",
"publicKey",
",",
"$",
"networkId",
"=",
"104",
")",
"// 104=mainnet",
"{",
"// discover public key content",
"if",
"(",
"$",
"publicKey",
"instanceof",
"Buffer",
")",
"{",
"$",
"pubKeyBuf",
"=",
"$",
... | Generate an address corresponding to a `publicKey`
public key.
The `publicKey` parameter can be either a hexadecimal
public key representation, a byte level representation
of the public key, a Buffer object or a KeyPair object.
@param mixed $publicKey
@param string|integer $networkId A network I... | [
"Generate",
"an",
"address",
"corresponding",
"to",
"a",
"publicKey",
"public",
"key",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Address.php#L78-L136 |
evias/nem-php | src/Models/Address.php | Address.getAttribute | public function getAttribute($alias, $doCast = true)
{
if ($alias === 'address')
return $this->toClean();
return parent::getAttribute($alias, $doCast);
} | php | public function getAttribute($alias, $doCast = true)
{
if ($alias === 'address')
return $this->toClean();
return parent::getAttribute($alias, $doCast);
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"alias",
",",
"$",
"doCast",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"alias",
"===",
"'address'",
")",
"return",
"$",
"this",
"->",
"toClean",
"(",
")",
";",
"return",
"parent",
"::",
"getAttribute",
"(",
... | Getter for singular attribute values by name.
Overloaded to provide with specific CLEAN FORMATTING
always when trying to read address attributes.
@param string $alias The attribute field alias.
@return mixed | [
"Getter",
"for",
"singular",
"attribute",
"values",
"by",
"name",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Address.php#L147-L153 |
evias/nem-php | src/Models/Address.php | Address.toDTO | public function toDTO($filterByKey = null)
{
$toDTO = ["address" => $this->toClean()];
// KeyPair's public key/private key not always set
// because \NEM\Models\Address is used for simple Address formatting
if (!empty($this->publicKey))
$toDTO["publicKey"] = $this->publi... | php | public function toDTO($filterByKey = null)
{
$toDTO = ["address" => $this->toClean()];
// KeyPair's public key/private key not always set
// because \NEM\Models\Address is used for simple Address formatting
if (!empty($this->publicKey))
$toDTO["publicKey"] = $this->publi... | [
"public",
"function",
"toDTO",
"(",
"$",
"filterByKey",
"=",
"null",
")",
"{",
"$",
"toDTO",
"=",
"[",
"\"address\"",
"=>",
"$",
"this",
"->",
"toClean",
"(",
")",
"]",
";",
"// KeyPair's public key/private key not always set",
"// because \\NEM\\Models\\Address is ... | Address DTO automatically cleans address representation.
@see [KeyPairViewModel](https://nemproject.github.io/#keyPairViewModel)
@return array Associative array with key `address` containing a NIS *compliable* address representation. | [
"Address",
"DTO",
"automatically",
"cleans",
"address",
"representation",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Address.php#L161-L177 |
evias/nem-php | src/Models/Address.php | Address.toClean | public function toClean($string = null)
{
$attrib = $string;
if (! $attrib && isset($this->attributes["address"]))
$attrib = $this->attributes["address"];
return strtoupper(preg_replace("/[^a-zA-Z0-9]+/", "", $attrib));
} | php | public function toClean($string = null)
{
$attrib = $string;
if (! $attrib && isset($this->attributes["address"]))
$attrib = $this->attributes["address"];
return strtoupper(preg_replace("/[^a-zA-Z0-9]+/", "", $attrib));
} | [
"public",
"function",
"toClean",
"(",
"$",
"string",
"=",
"null",
")",
"{",
"$",
"attrib",
"=",
"$",
"string",
";",
"if",
"(",
"!",
"$",
"attrib",
"&&",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"\"address\"",
"]",
")",
")",
"$",
"attrib"... | Helper to clean an address of any non alpha-numeric characters
back to the actual Base32 representation of the address.
@return string | [
"Helper",
"to",
"clean",
"an",
"address",
"of",
"any",
"non",
"alpha",
"-",
"numeric",
"characters",
"back",
"to",
"the",
"actual",
"Base32",
"representation",
"of",
"the",
"address",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Address.php#L185-L192 |
evias/nem-php | src/Models/Transaction/Multisig.php | Multisig.serialize | public function serialize($parameters = null)
{
$baseTx = parent::serialize($parameters);
$nisData = $this->extend();
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_tx = $this->otherTrans()->seria... | php | public function serialize($parameters = null)
{
$baseTx = parent::serialize($parameters);
$nisData = $this->extend();
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_tx = $this->otherTrans()->seria... | [
"public",
"function",
"serialize",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"baseTx",
"=",
"parent",
"::",
"serialize",
"(",
"$",
"parameters",
")",
";",
"$",
"nisData",
"=",
"$",
"this",
"->",
"extend",
"(",
")",
";",
"// shortcuts",
"$",
... | Overload of the \NEM\Core\Model::serialize() method to provide
with a specialization for *Multisig transaction* serialization.
@see \NEM\Contracts\Serializable
@param null|string $parameters non-null will return only the named sub-dtos.
@return array Returns a byte-array with values in UInt8 representation. | [
"Overload",
"of",
"the",
"\\",
"NEM",
"\\",
"Core",
"\\",
"Model",
"::",
"serialize",
"()",
"method",
"to",
"provide",
"with",
"a",
"specialization",
"for",
"*",
"Multisig",
"transaction",
"*",
"serialization",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/Multisig.php#L68-L86 |
evias/nem-php | src/Models/Transaction/Multisig.php | Multisig.extend | public function extend()
{
// The Multisig Wrapper transaction should have VERSION_1
$version = $this->getAttribute("version");
$oneByOld = [
Transaction::VERSION_2 => Transaction::VERSION_1,
Transaction::VERSION_2_TEST => Transaction::VERSION_1_TEST,
... | php | public function extend()
{
// The Multisig Wrapper transaction should have VERSION_1
$version = $this->getAttribute("version");
$oneByOld = [
Transaction::VERSION_2 => Transaction::VERSION_1,
Transaction::VERSION_2_TEST => Transaction::VERSION_1_TEST,
... | [
"public",
"function",
"extend",
"(",
")",
"{",
"// The Multisig Wrapper transaction should have VERSION_1",
"$",
"version",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"version\"",
")",
";",
"$",
"oneByOld",
"=",
"[",
"Transaction",
"::",
"VERSION_2",
"=>",
"Tr... | The Multisig transaction type adds offsets `otherTrans` and
`signatures`.
The `otherTrans` in the DTO is used to store transaction details.
The Multisig Transaction Type only acts as a wrapper! It will contain
a subordinate Transaction object in the `otherTrans` attribute and a
collection of subordinate Transaction\S... | [
"The",
"Multisig",
"transaction",
"type",
"adds",
"offsets",
"otherTrans",
"and",
"signatures",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/Multisig.php#L101-L131 |
evias/nem-php | src/Models/Transaction/Multisig.php | Multisig.setOtherTrans | public function setOtherTrans(Transaction $otherTrans)
{
$this->setAttribute("otherTrans", $otherTrans->toDTO("transaction"));
return $this->otherTrans($otherTrans->toDTO("transaction"));
} | php | public function setOtherTrans(Transaction $otherTrans)
{
$this->setAttribute("otherTrans", $otherTrans->toDTO("transaction"));
return $this->otherTrans($otherTrans->toDTO("transaction"));
} | [
"public",
"function",
"setOtherTrans",
"(",
"Transaction",
"$",
"otherTrans",
")",
"{",
"$",
"this",
"->",
"setAttribute",
"(",
"\"otherTrans\"",
",",
"$",
"otherTrans",
"->",
"toDTO",
"(",
"\"transaction\"",
")",
")",
";",
"return",
"$",
"this",
"->",
"othe... | Setter for the `otherTrans` DTO property.
This is used to include non-multisig transaction data in
the multisig transaction package.
@param \NEM\Models\Transaction $otherTrans Transaction to include in the multisig DTO's `otherTrans` attribute.
@return \NEM\Models\Transaction\Multisig | [
"Setter",
"for",
"the",
"otherTrans",
"DTO",
"property",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/Multisig.php#L172-L176 |
evias/nem-php | src/Models/Transaction/Multisig.php | Multisig.otherTrans | public function otherTrans(array $transaction = null)
{
// morph Transaction extension - will read the type of transaction
// and instantiate the correct class extending Transaction.
$morphed = Transaction::create($transaction ?: $this->getAttribute("otherTrans"));
if ($morphed->typ... | php | public function otherTrans(array $transaction = null)
{
// morph Transaction extension - will read the type of transaction
// and instantiate the correct class extending Transaction.
$morphed = Transaction::create($transaction ?: $this->getAttribute("otherTrans"));
if ($morphed->typ... | [
"public",
"function",
"otherTrans",
"(",
"array",
"$",
"transaction",
"=",
"null",
")",
"{",
"// morph Transaction extension - will read the type of transaction",
"// and instantiate the correct class extending Transaction.",
"$",
"morphed",
"=",
"Transaction",
"::",
"create",
... | Mutator for the `otherTrans` sub DTO.
@param array $transaction
@return \NEM\Models\Transaction | [
"Mutator",
"for",
"the",
"otherTrans",
"sub",
"DTO",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/Multisig.php#L184-L200 |
evias/nem-php | src/Core/KeyGenerator.php | KeyGenerator.derivePublicKey | public function derivePublicKey(KeyPair $keyPair)
{
$buffer = new Buffer;
// hash the secret key with Keccak SHA3 variation with 512-bit output (64 bytes)
$hashedSecret = Encryption::hash("keccak-512", $keyPair->getSecretKey()->getBinary(), true); // raw=true
// clamp bits of the s... | php | public function derivePublicKey(KeyPair $keyPair)
{
$buffer = new Buffer;
// hash the secret key with Keccak SHA3 variation with 512-bit output (64 bytes)
$hashedSecret = Encryption::hash("keccak-512", $keyPair->getSecretKey()->getBinary(), true); // raw=true
// clamp bits of the s... | [
"public",
"function",
"derivePublicKey",
"(",
"KeyPair",
"$",
"keyPair",
")",
"{",
"$",
"buffer",
"=",
"new",
"Buffer",
";",
"// hash the secret key with Keccak SHA3 variation with 512-bit output (64 bytes)",
"$",
"hashedSecret",
"=",
"Encryption",
"::",
"hash",
"(",
"\... | Derive the public key from the KeyPair's secret.
This method uses Keccak 64 bytes (512 bits) hashing on
the provided `keyPair`'s secret key.
@param \NEM\Core\KeyPair $keyPair The initialized key pair from which to derive the public key.
@return \NEM\Core\Buffer | [
"Derive",
"the",
"public",
"key",
"from",
"the",
"KeyPair",
"s",
"secret",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Core/KeyGenerator.php#L49-L67 |
evias/nem-php | src/Models/Amount.php | Amount.fromMicro | static public function fromMicro($amount, $divisibility = 6)
{
$amt = new Amount(["amount" => $amount]);
$amt->setDivisibility($divisibility);
return $amt;
} | php | static public function fromMicro($amount, $divisibility = 6)
{
$amt = new Amount(["amount" => $amount]);
$amt->setDivisibility($divisibility);
return $amt;
} | [
"static",
"public",
"function",
"fromMicro",
"(",
"$",
"amount",
",",
"$",
"divisibility",
"=",
"6",
")",
"{",
"$",
"amt",
"=",
"new",
"Amount",
"(",
"[",
"\"amount\"",
"=>",
"$",
"amount",
"]",
")",
";",
"$",
"amt",
"->",
"setDivisibility",
"(",
"$"... | Factory for Amount models with MICRO amounts and provided
`divisibility`.
@param integer $amount
@param integer $divisibility
@return \NEM\Models\Amount | [
"Factory",
"for",
"Amount",
"models",
"with",
"MICRO",
"amounts",
"and",
"provided",
"divisibility",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Amount.php#L93-L99 |
evias/nem-php | src/Models/Amount.php | Amount.setAttribute | public function setAttribute($name, $data)
{
if ($name === 'amount') {
$this->attributes["amount"] = $data;
// parse provided data and check for overflow
$micro = $this->toMicro();
if ($micro >= Amount::MAX_AMOUNT)
throw new NISAmountOverflowE... | php | public function setAttribute($name, $data)
{
if ($name === 'amount') {
$this->attributes["amount"] = $data;
// parse provided data and check for overflow
$micro = $this->toMicro();
if ($micro >= Amount::MAX_AMOUNT)
throw new NISAmountOverflowE... | [
"public",
"function",
"setAttribute",
"(",
"$",
"name",
",",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'amount'",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"\"amount\"",
"]",
"=",
"$",
"data",
";",
"// parse provided data and check for o... | Setter for singular attribute values by name.
Overload takes care of TOO BIG amounts.
@param string $name The attribute name.
@param mixed $data The attribute data.
@return mixed
@throws \NEM\Errors\NISAmountOverflowException | [
"Setter",
"for",
"singular",
"attribute",
"values",
"by",
"name",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Amount.php#L111-L123 |
evias/nem-php | src/Models/Amount.php | Amount.toDTO | public function toDTO($filterByKey = null)
{
$toDTO = ["amount" => $this->toMicro()];
if ($filterByKey && isset($toDTO[$filterByKey]))
return $toDTO[$filterByKey];
return $toDTO;
} | php | public function toDTO($filterByKey = null)
{
$toDTO = ["amount" => $this->toMicro()];
if ($filterByKey && isset($toDTO[$filterByKey]))
return $toDTO[$filterByKey];
return $toDTO;
} | [
"public",
"function",
"toDTO",
"(",
"$",
"filterByKey",
"=",
"null",
")",
"{",
"$",
"toDTO",
"=",
"[",
"\"amount\"",
"=>",
"$",
"this",
"->",
"toMicro",
"(",
")",
"]",
";",
"if",
"(",
"$",
"filterByKey",
"&&",
"isset",
"(",
"$",
"toDTO",
"[",
"$",
... | Amount DTO automatically returns MICRO amount.
@return array Associative array with key `address` containing a NIS *compliable* address representation. | [
"Amount",
"DTO",
"automatically",
"returns",
"MICRO",
"amount",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Amount.php#L130-L138 |
evias/nem-php | src/Models/Amount.php | Amount.toMicro | public function toMicro()
{
$inner = $this->getAttribute("amount", false); //cast=false
$decimals = $this->getDivisibility();
if (is_integer($inner)) {
$attrib = $inner;
}
elseif (is_float($inner)) {
// we want only integer!
$attrib = $inn... | php | public function toMicro()
{
$inner = $this->getAttribute("amount", false); //cast=false
$decimals = $this->getDivisibility();
if (is_integer($inner)) {
$attrib = $inner;
}
elseif (is_float($inner)) {
// we want only integer!
$attrib = $inn... | [
"public",
"function",
"toMicro",
"(",
")",
"{",
"$",
"inner",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"amount\"",
",",
"false",
")",
";",
"//cast=false",
"$",
"decimals",
"=",
"$",
"this",
"->",
"getDivisibility",
"(",
")",
";",
"if",
"(",
"is_i... | Helper to return a MICRO amount. This means to get the smallest unit
of an Amount on the NEM Blockchain. Maximum Divisibility is up to 6
decimal places.
@return integer | [
"Helper",
"to",
"return",
"a",
"MICRO",
"amount",
".",
"This",
"means",
"to",
"get",
"the",
"smallest",
"unit",
"of",
"an",
"Amount",
"on",
"the",
"NEM",
"Blockchain",
".",
"Maximum",
"Divisibility",
"is",
"up",
"to",
"6",
"decimal",
"places",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Amount.php#L147-L180 |
evias/nem-php | src/Models/Amount.php | Amount.toUnit | public function toUnit()
{
if ($this->divisibility <= 0)
return $this->toMicro();
$div = pow(10, $this->getDivisibility());
return ($this->toMicro() / $div);
} | php | public function toUnit()
{
if ($this->divisibility <= 0)
return $this->toMicro();
$div = pow(10, $this->getDivisibility());
return ($this->toMicro() / $div);
} | [
"public",
"function",
"toUnit",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"divisibility",
"<=",
"0",
")",
"return",
"$",
"this",
"->",
"toMicro",
"(",
")",
";",
"$",
"div",
"=",
"pow",
"(",
"10",
",",
"$",
"this",
"->",
"getDivisibility",
"(",
... | Helper to return UNITs amounts. This method will return floating
point numbers. The divisibility can be set using `setDivisibility`
in case of different mosaics.
@return float | [
"Helper",
"to",
"return",
"UNITs",
"amounts",
".",
"This",
"method",
"will",
"return",
"floating",
"point",
"numbers",
".",
"The",
"divisibility",
"can",
"be",
"set",
"using",
"setDivisibility",
"in",
"case",
"of",
"different",
"mosaics",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Amount.php#L189-L196 |
evias/nem-php | src/Models/Amount.php | Amount.setDivisibility | public function setDivisibility($divisibility)
{
if (!is_integer($divisibility) || $divisibility < 0)
$divisibility = 6; // default 6
$this->divisibility = $divisibility;
return $this;
} | php | public function setDivisibility($divisibility)
{
if (!is_integer($divisibility) || $divisibility < 0)
$divisibility = 6; // default 6
$this->divisibility = $divisibility;
return $this;
} | [
"public",
"function",
"setDivisibility",
"(",
"$",
"divisibility",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"divisibility",
")",
"||",
"$",
"divisibility",
"<",
"0",
")",
"$",
"divisibility",
"=",
"6",
";",
"// default 6",
"$",
"this",
"->",
"di... | Setter for the `divisibility` property.
@param integer $divisibility
@return \NEM\Models\Amount | [
"Setter",
"for",
"the",
"divisibility",
"property",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Amount.php#L204-L211 |
evias/nem-php | src/Models/Amount.php | Amount.mosaicQuantityToXEM | static public function mosaicQuantityToXEM($divisibility, $supply, $quantity, $multiplier = Amount::XEM)
{
if ((int) $supply <= 0) return 0;
if ((int) $divisibility <= 0) $divisibility = 0;
return self::XEM_SUPPLY * $quantity * $multiplier / $supply / pow(10, $divisibility + 6);
} | php | static public function mosaicQuantityToXEM($divisibility, $supply, $quantity, $multiplier = Amount::XEM)
{
if ((int) $supply <= 0) return 0;
if ((int) $divisibility <= 0) $divisibility = 0;
return self::XEM_SUPPLY * $quantity * $multiplier / $supply / pow(10, $divisibility + 6);
} | [
"static",
"public",
"function",
"mosaicQuantityToXEM",
"(",
"$",
"divisibility",
",",
"$",
"supply",
",",
"$",
"quantity",
",",
"$",
"multiplier",
"=",
"Amount",
"::",
"XEM",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"supply",
"<=",
"0",
")",
"return"... | Helper to get the XEM equivalent for a given mosaic definition
`definition` and attachment quantity `quantity`.
This method is used internally to calculate the equivalent XEM
amounts of a given mosaic quantity for *fees calculation*.
@internal
@param \NEM\Models\MosaicDefinition $definition
@param integer ... | [
"Helper",
"to",
"get",
"the",
"XEM",
"equivalent",
"for",
"a",
"given",
"mosaic",
"definition",
"definition",
"and",
"attachment",
"quantity",
"quantity",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Amount.php#L235-L241 |
evias/nem-php | src/Traits/Serializable.php | Serializable.getSerializer | public function getSerializer()
{
if (! $this->serializer || ! ($this->serializer instanceof Serializer)) {
$this->serializer = Serializer::getInstance();
}
return $this->serializer;
} | php | public function getSerializer()
{
if (! $this->serializer || ! ($this->serializer instanceof Serializer)) {
$this->serializer = Serializer::getInstance();
}
return $this->serializer;
} | [
"public",
"function",
"getSerializer",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"serializer",
"||",
"!",
"(",
"$",
"this",
"->",
"serializer",
"instanceof",
"Serializer",
")",
")",
"{",
"$",
"this",
"->",
"serializer",
"=",
"Serializer",
"::",
... | Getter for the `serializer` property.
@return \NEM\Core\Serializer | [
"Getter",
"for",
"the",
"serializer",
"property",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Traits/Serializable.php#L44-L51 |
evias/nem-php | src/Mosaics/Nemether/Nemether.php | Nemether.levy | public function levy(array $levy = null)
{
$xem = new Mosaic(["namespaceId" => "nem", "name" => "xem"]);
$data = $levy ?: [
"type" => MosaicLevy::TYPE_ABSOLUTE,
"fee" => 10,
"recipient" => "NC56RYVRUPG3WRNGMVNRKODJZJNZKZYS76UAPO7K",
"mosaicId" => $xem-... | php | public function levy(array $levy = null)
{
$xem = new Mosaic(["namespaceId" => "nem", "name" => "xem"]);
$data = $levy ?: [
"type" => MosaicLevy::TYPE_ABSOLUTE,
"fee" => 10,
"recipient" => "NC56RYVRUPG3WRNGMVNRKODJZJNZKZYS76UAPO7K",
"mosaicId" => $xem-... | [
"public",
"function",
"levy",
"(",
"array",
"$",
"levy",
"=",
"null",
")",
"{",
"$",
"xem",
"=",
"new",
"Mosaic",
"(",
"[",
"\"namespaceId\"",
"=>",
"\"nem\"",
",",
"\"name\"",
"=>",
"\"xem\"",
"]",
")",
";",
"$",
"data",
"=",
"$",
"levy",
"?",
":"... | Mutator for `levy` relation.
This will return a NIS compliant [MosaicLevy](https://bob.nem.ninja/docs/#mosaicLevy) object.
@param array $mosaidId Array should contain offsets `type`, `recipient`, `mosaicId` and `fee`.
@return \NEM\Models\MosaicLevy | [
"Mutator",
"for",
"levy",
"relation",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Mosaics/Nemether/Nemether.php#L73-L84 |
evias/nem-php | src/Mosaics/Nemether/Nemether.php | Nemether.properties | public function properties(array $properties = null)
{
$data = [
new MosaicProperty(["name" => "divisibility", "value" => 6]),
new MosaicProperty(["name" => "initialSupply", "value" => 95100000]),
new MosaicProperty(["name" => "supplyMutable", "value" => true]),
... | php | public function properties(array $properties = null)
{
$data = [
new MosaicProperty(["name" => "divisibility", "value" => 6]),
new MosaicProperty(["name" => "initialSupply", "value" => 95100000]),
new MosaicProperty(["name" => "supplyMutable", "value" => true]),
... | [
"public",
"function",
"properties",
"(",
"array",
"$",
"properties",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"[",
"new",
"MosaicProperty",
"(",
"[",
"\"name\"",
"=>",
"\"divisibility\"",
",",
"\"value\"",
"=>",
"6",
"]",
")",
",",
"new",
"MosaicProperty",... | Mutator for `properties` relation.
This will return a NIS compliant collection of [MosaicProperties](https://bob.nem.ninja/docs/#mosaicProperties) object.
@param array $properties Array of MosaicProperty instances
@return \NEM\Models\MosaicProperties | [
"Mutator",
"for",
"properties",
"relation",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Mosaics/Nemether/Nemether.php#L94-L104 |
evias/nem-php | src/Models/Fee.php | Fee.calculateForTransaction | static public function calculateForTransaction(Transaction $transaction)
{
// generate each content fee accordingly
$msgFee = self::calculateForMessage($transaction->message());
// default content fee is XEM amount transfer fee
$contentFee = Fee::FEE_FACTOR * self::calculateForXEM($... | php | static public function calculateForTransaction(Transaction $transaction)
{
// generate each content fee accordingly
$msgFee = self::calculateForMessage($transaction->message());
// default content fee is XEM amount transfer fee
$contentFee = Fee::FEE_FACTOR * self::calculateForXEM($... | [
"static",
"public",
"function",
"calculateForTransaction",
"(",
"Transaction",
"$",
"transaction",
")",
"{",
"// generate each content fee accordingly",
"$",
"msgFee",
"=",
"self",
"::",
"calculateForMessage",
"(",
"$",
"transaction",
"->",
"message",
"(",
")",
")",
... | Calculate the needed fee for a provided `$transaction` NEM transaction
object.
This method can be used to calculate all needed fees for a given
`transaction` object.
@param \NEM\Models\Transaction $transaction
@return \NEM\Models\Fee | [
"Calculate",
"the",
"needed",
"fee",
"for",
"a",
"provided",
"$transaction",
"NEM",
"transaction",
"object",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Fee.php#L147-L163 |
evias/nem-php | src/Models/Fee.php | Fee.calculateForMessage | static public function calculateForMessage(Message $message)
{
$dto = $message->toDTO();
if (empty($dto["payload"]))
return 0;
// message fee is 0.05 (current fee factor) multiplied
// by the count of *started* 31 characters chunks.
$chunks = floor((strlen($dto[... | php | static public function calculateForMessage(Message $message)
{
$dto = $message->toDTO();
if (empty($dto["payload"]))
return 0;
// message fee is 0.05 (current fee factor) multiplied
// by the count of *started* 31 characters chunks.
$chunks = floor((strlen($dto[... | [
"static",
"public",
"function",
"calculateForMessage",
"(",
"Message",
"$",
"message",
")",
"{",
"$",
"dto",
"=",
"$",
"message",
"->",
"toDTO",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"dto",
"[",
"\"payload\"",
"]",
")",
")",
"return",
"0",
";"... | Calculate the needed fee for a provided `$message` message.
Messages are more expensive when they are encrypted.
This method is used internally to calculate a transactions's
message fees.
@internal
@param Message $message
@return \NEM\Models\Fee | [
"Calculate",
"the",
"needed",
"fee",
"for",
"a",
"provided",
"$message",
"message",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Fee.php#L177-L188 |
evias/nem-php | src/Models/Fee.php | Fee.calculateForMosaics | static public function calculateForMosaics(MosaicDefinitions $definitions,
MosaicAttachments $attachments,
$multiplier = Amount::XEM)
{
if ($attachments->isEmpty())
return 0;
$totalFee = 0;
... | php | static public function calculateForMosaics(MosaicDefinitions $definitions,
MosaicAttachments $attachments,
$multiplier = Amount::XEM)
{
if ($attachments->isEmpty())
return 0;
$totalFee = 0;
... | [
"static",
"public",
"function",
"calculateForMosaics",
"(",
"MosaicDefinitions",
"$",
"definitions",
",",
"MosaicAttachments",
"$",
"attachments",
",",
"$",
"multiplier",
"=",
"Amount",
"::",
"XEM",
")",
"{",
"if",
"(",
"$",
"attachments",
"->",
"isEmpty",
"(",
... | Calculate the needed fee for a provided `$mosaics` mosaics
attachments array.
This method is used internally to calculate a mosaic transfer
transaction's needed fees.
The `definitions` argument should contain definitions of attached
mosaics.
@internal
@param \NEM\Models\MosaicDefinitions $definitions Collecti... | [
"Calculate",
"the",
"needed",
"fee",
"for",
"a",
"provided",
"$mosaics",
"mosaics",
"attachments",
"array",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Fee.php#L207-L262 |
evias/nem-php | src/Models/Fee.php | Fee.calculateForXEM | static public function calculateForXEM($amountXEM = 1)
{
$fee = floor(max([1, $amountXEM / 10000]));
return $fee > self::MAX_AMOUNT_FEE ? self::MAX_AMOUNT_FEE : $fee;
} | php | static public function calculateForXEM($amountXEM = 1)
{
$fee = floor(max([1, $amountXEM / 10000]));
return $fee > self::MAX_AMOUNT_FEE ? self::MAX_AMOUNT_FEE : $fee;
} | [
"static",
"public",
"function",
"calculateForXEM",
"(",
"$",
"amountXEM",
"=",
"1",
")",
"{",
"$",
"fee",
"=",
"floor",
"(",
"max",
"(",
"[",
"1",
",",
"$",
"amountXEM",
"/",
"10000",
"]",
")",
")",
";",
"return",
"$",
"fee",
">",
"self",
"::",
"... | Calculate the minimum needed fee for a provided `$amountXEM` amount
of XEM to transfer.
This method is used internally to calculate a transaction's base fee.
@internal
@param string $message
@return \NEM\Models\Fee | [
"Calculate",
"the",
"minimum",
"needed",
"fee",
"for",
"a",
"provided",
"$amountXEM",
"amount",
"of",
"XEM",
"to",
"transfer",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Fee.php#L274-L278 |
evias/nem-php | src/Models/Transaction/Transfer.php | Transfer.extend | public function extend()
{
return [
"amount" => $this->amount()->toMicro(),
"recipient" => $this->recipient()->address()->toClean(),
"message" => $this->message()->toDTO(),
// transaction type specialization
"type" => TransactionType::TR... | php | public function extend()
{
return [
"amount" => $this->amount()->toMicro(),
"recipient" => $this->recipient()->address()->toClean(),
"message" => $this->message()->toDTO(),
// transaction type specialization
"type" => TransactionType::TR... | [
"public",
"function",
"extend",
"(",
")",
"{",
"return",
"[",
"\"amount\"",
"=>",
"$",
"this",
"->",
"amount",
"(",
")",
"->",
"toMicro",
"(",
")",
",",
"\"recipient\"",
"=>",
"$",
"this",
"->",
"recipient",
"(",
")",
"->",
"address",
"(",
")",
"->",... | The extend() method must be overloaded by any Transaction Type
which needs to extend the base DTO structure.
@return array | [
"The",
"extend",
"()",
"method",
"must",
"be",
"overloaded",
"by",
"any",
"Transaction",
"Type",
"which",
"needs",
"to",
"extend",
"the",
"base",
"DTO",
"structure",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/Transfer.php#L44-L53 |
evias/nem-php | src/Models/Transaction/Transfer.php | Transfer.serialize | public function serialize($parameters = null)
{
$baseTx = parent::serialize($parameters);
$nisData = $this->toDTO("transaction");
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_acct = $serializer-... | php | public function serialize($parameters = null)
{
$baseTx = parent::serialize($parameters);
$nisData = $this->toDTO("transaction");
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_acct = $serializer-... | [
"public",
"function",
"serialize",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"baseTx",
"=",
"parent",
"::",
"serialize",
"(",
"$",
"parameters",
")",
";",
"$",
"nisData",
"=",
"$",
"this",
"->",
"toDTO",
"(",
"\"transaction\"",
")",
";",
"// ... | Overload of the \NEM\Core\Model::serialize() method to provide
with a specialization for *Transfer* serialization.
@see \NEM\Contracts\Serializable
@param null|string $parameters non-null will return only the named sub-dtos.
@return array Returns a byte-array with values in UInt8 representation. | [
"Overload",
"of",
"the",
"\\",
"NEM",
"\\",
"Core",
"\\",
"Model",
"::",
"serialize",
"()",
"method",
"to",
"provide",
"with",
"a",
"specialization",
"for",
"*",
"Transfer",
"*",
"serialization",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/Transfer.php#L89-L126 |
evias/nem-php | src/Models/MosaicAttachments.php | MosaicAttachments.serialize | public function serialize($parameters = null)
{
// shortcuts
$serializer = $this->getSerializer();
$mapped = $this->map(function(&$attach) {
return new MosaicAttachment($attach);
});
// sort attachments lexicographically
$sorted = $mapped->sort(function(... | php | public function serialize($parameters = null)
{
// shortcuts
$serializer = $this->getSerializer();
$mapped = $this->map(function(&$attach) {
return new MosaicAttachment($attach);
});
// sort attachments lexicographically
$sorted = $mapped->sort(function(... | [
"public",
"function",
"serialize",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"// shortcuts",
"$",
"serializer",
"=",
"$",
"this",
"->",
"getSerializer",
"(",
")",
";",
"$",
"mapped",
"=",
"$",
"this",
"->",
"map",
"(",
"function",
"(",
"&",
"$",
... | Overload of the \NEM\Core\ModelCollection::serialize() method to provide
with a specialization for *MosaicAttachments Arrays* serialization.
@see \NEM\Contracts\Serializable
@param null|string $parameters non-null will return only the named sub-dtos.
@return array Returns a byte-array with values in UInt8 repr... | [
"Overload",
"of",
"the",
"\\",
"NEM",
"\\",
"Core",
"\\",
"ModelCollection",
"::",
"serialize",
"()",
"method",
"to",
"provide",
"with",
"a",
"specialization",
"for",
"*",
"MosaicAttachments",
"Arrays",
"*",
"serialization",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/MosaicAttachments.php#L44-L82 |
evias/nem-php | src/Models/Mutators/ModelMutator.php | ModelMutator.mutate | public function mutate($name, $attributes)
{
// snake_case to camelCase
$modelClass = "\\NEM\\Models\\" . Str::studly($name);
if (!class_exists($modelClass)) {
throw new BadMethodCallException("Model class '" . $modelClass . "' could not be found in \\NEM\\Model namespace.");
... | php | public function mutate($name, $attributes)
{
// snake_case to camelCase
$modelClass = "\\NEM\\Models\\" . Str::studly($name);
if (!class_exists($modelClass)) {
throw new BadMethodCallException("Model class '" . $modelClass . "' could not be found in \\NEM\\Model namespace.");
... | [
"public",
"function",
"mutate",
"(",
"$",
"name",
",",
"$",
"attributes",
")",
"{",
"// snake_case to camelCase",
"$",
"modelClass",
"=",
"\"\\\\NEM\\\\Models\\\\\"",
".",
"Str",
"::",
"studly",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"class_exists",
"("... | Mutate a Model object.
This method takes a *snake_case* model name and converts it
to a class name in the namespace \NEM\Models.
@internal
@param string $name The model name you would like to create.
@param array $attributes The model's attribute values.
@return \NEM\Models\ModelInterface | [
"Mutate",
"a",
"Model",
"object",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Mutators/ModelMutator.php#L46-L58 |
evias/nem-php | src/Models/Model.php | Model.toDTO | public function toDTO($filterByKey = null)
{
$dtos = [];
foreach ($this->getAttributes() as $attrib => $data) {
$attribDTO = $data; // default (unparsed or scalar)
// we may need to parse the attribute relation or use
// the model to get the subordinated Data Tr... | php | public function toDTO($filterByKey = null)
{
$dtos = [];
foreach ($this->getAttributes() as $attrib => $data) {
$attribDTO = $data; // default (unparsed or scalar)
// we may need to parse the attribute relation or use
// the model to get the subordinated Data Tr... | [
"public",
"function",
"toDTO",
"(",
"$",
"filterByKey",
"=",
"null",
")",
"{",
"$",
"dtos",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"attrib",
"=>",
"$",
"data",
")",
"{",
"$",
"attribDTO",
"=",
... | Generic helper to convert a Model instance to a Data Transfer Object.
This will make it easy to bridge implemented models to NEM *NIS compliant*
objects.
More complicated objects may overload this method to provide with finer
grained data transfer objects.
@see http://bob.nem.ninja/docs/ NIS API Documentation
@para... | [
"Generic",
"helper",
"to",
"convert",
"a",
"Model",
"instance",
"to",
"a",
"Data",
"Transfer",
"Object",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Model.php#L222-L249 |
evias/nem-php | src/Models/Model.php | Model.getFields | public function getFields()
{
$fields = array_keys($this->fillable);
if (!empty($fields) && is_integer($fields[0]))
// only alias provided
$fields = array_values($this->fillable);
return array_merge($fields, $this->appends, array_keys($this->attributes));
} | php | public function getFields()
{
$fields = array_keys($this->fillable);
if (!empty($fields) && is_integer($fields[0]))
// only alias provided
$fields = array_values($this->fillable);
return array_merge($fields, $this->appends, array_keys($this->attributes));
} | [
"public",
"function",
"getFields",
"(",
")",
"{",
"$",
"fields",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"fillable",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"fields",
")",
"&&",
"is_integer",
"(",
"$",
"fields",
"[",
"0",
"]",
")",
")",
"... | Getter for the model's field names.
This method will merge the `fillable` property and the `appends`
properties into one array of field names.
@param array $fieldNames An array of field names
@return \NEM\Models\ModelInterface | [
"Getter",
"for",
"the",
"model",
"s",
"field",
"names",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Model.php#L295-L303 |
evias/nem-php | src/Models/Model.php | Model.setAttributes | public function setAttributes(array $attributes)
{
$flattened = array_dot($attributes);
$fields = $this->getFields();
if (empty($fields))
$fields = array_keys($attributes);
foreach ($fields as $field) :
// make sure we have an aliased fields list
... | php | public function setAttributes(array $attributes)
{
$flattened = array_dot($attributes);
$fields = $this->getFields();
if (empty($fields))
$fields = array_keys($attributes);
foreach ($fields as $field) :
// make sure we have an aliased fields list
... | [
"public",
"function",
"setAttributes",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"flattened",
"=",
"array_dot",
"(",
"$",
"attributes",
")",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"getFields",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"... | Setter for the `attributes` property.
This method uses a *dot notation* for attributes and resolves
relationships automatically when needed.
@internal
@return \NEM\Contracts\DataTransferObject | [
"Setter",
"for",
"the",
"attributes",
"property",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Model.php#L314-L358 |
evias/nem-php | src/Models/Model.php | Model.getAttributes | public function getAttributes()
{
// prevent order of fields from changing
$sortedAttribs = [];
foreach ($this->sortedFields as $ix => $attribute) {
$sortedAttribs[$attribute] = $this->attributes[$attribute];
}
return $sortedAttribs;
} | php | public function getAttributes()
{
// prevent order of fields from changing
$sortedAttribs = [];
foreach ($this->sortedFields as $ix => $attribute) {
$sortedAttribs[$attribute] = $this->attributes[$attribute];
}
return $sortedAttribs;
} | [
"public",
"function",
"getAttributes",
"(",
")",
"{",
"// prevent order of fields from changing",
"$",
"sortedAttribs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"sortedFields",
"as",
"$",
"ix",
"=>",
"$",
"attribute",
")",
"{",
"$",
"sortedAttrib... | Getter for the `attributes` property.
The `attributes` property holds an array with key values representing
the Data of this Model instance.
@return array | [
"Getter",
"for",
"the",
"attributes",
"property",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Model.php#L368-L377 |
evias/nem-php | src/Models/Model.php | Model.getAttribute | public function getAttribute($alias, $doCast = true)
{
if (property_exists($this, $alias))
return $this->$alias;
if (array_key_exists($alias, $this->attributes))
// value available
return $this->castValue($alias, $this->attributes[$alias], $doCast);
// c... | php | public function getAttribute($alias, $doCast = true)
{
if (property_exists($this, $alias))
return $this->$alias;
if (array_key_exists($alias, $this->attributes))
// value available
return $this->castValue($alias, $this->attributes[$alias], $doCast);
// c... | [
"public",
"function",
"getAttribute",
"(",
"$",
"alias",
",",
"$",
"doCast",
"=",
"true",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"alias",
")",
")",
"return",
"$",
"this",
"->",
"$",
"alias",
";",
"if",
"(",
"array_key_exi... | Getter for singular attribute values by name.
@param string $alias The attribute field alias.
@return mixed | [
"Getter",
"for",
"singular",
"attribute",
"values",
"by",
"name",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Model.php#L385-L419 |
evias/nem-php | src/Models/Model.php | Model.setAttribute | public function setAttribute($name, $data)
{
// new fields are detected to *prevent the order of fields*
// from changing during data processes.
$attributes = array_keys($this->attributes);
$cntAttribs = count($attributes);
if (! in_array($name, $attributes)) {
/... | php | public function setAttribute($name, $data)
{
// new fields are detected to *prevent the order of fields*
// from changing during data processes.
$attributes = array_keys($this->attributes);
$cntAttribs = count($attributes);
if (! in_array($name, $attributes)) {
/... | [
"public",
"function",
"setAttribute",
"(",
"$",
"name",
",",
"$",
"data",
")",
"{",
"// new fields are detected to *prevent the order of fields*",
"// from changing during data processes.",
"$",
"attributes",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"attributes",
")",
... | Setter for singular attribute values by name.
@param string $name The attribute name.
@param mixed $data The attribute data.
@return mixed | [
"Setter",
"for",
"singular",
"attribute",
"values",
"by",
"name",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Model.php#L428-L456 |
evias/nem-php | src/Models/Model.php | Model.castValue | public function castValue($field, $value, $cast = true)
{
if (! array_key_exists($field, $this->casts) || ! $cast)
// no cast configured for said field. Nothing done.
return $value;
$types = [
"boolean", "bool", "integer", "int", "float", "double",
"s... | php | public function castValue($field, $value, $cast = true)
{
if (! array_key_exists($field, $this->casts) || ! $cast)
// no cast configured for said field. Nothing done.
return $value;
$types = [
"boolean", "bool", "integer", "int", "float", "double",
"s... | [
"public",
"function",
"castValue",
"(",
"$",
"field",
",",
"$",
"value",
",",
"$",
"cast",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"casts",
")",
"||",
"!",
"$",
"cast",
")",
"// no cast ... | This method will read the `casts` instance property and
automatically cast the `value` provided in the set cast
type.
@see http://php.net/manual/en/function.settype.php
@param string $field
@param mixed $value
@return mixed | [
"This",
"method",
"will",
"read",
"the",
"casts",
"instance",
"property",
"and",
"automatically",
"cast",
"the",
"value",
"provided",
"in",
"the",
"set",
"cast",
"type",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Model.php#L606-L630 |
evias/nem-php | src/Models/Model.php | Model.resolveRelationship | public function resolveRelationship($alias, $data)
{
if (! in_array($alias, $this->relations) && ! method_exists($this, $alias)) {
throw new BadMethodCallException("Relationship for field '" . $alias . "' not configured in " . get_class($this));
}
if (method_exists($this, $alias... | php | public function resolveRelationship($alias, $data)
{
if (! in_array($alias, $this->relations) && ! method_exists($this, $alias)) {
throw new BadMethodCallException("Relationship for field '" . $alias . "' not configured in " . get_class($this));
}
if (method_exists($this, $alias... | [
"public",
"function",
"resolveRelationship",
"(",
"$",
"alias",
",",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"alias",
",",
"$",
"this",
"->",
"relations",
")",
"&&",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"alias",
")",... | Build a Model Relationship between \NEM\Contracts\DataTransferObject objects.
Relation can be defined with the `$relations` property on extending classes.
Relationships for which there is no method implementation, will automatically
try to instantiate using the uppercased CamelCase representation of the relation
alia... | [
"Build",
"a",
"Model",
"Relationship",
"between",
"\\",
"NEM",
"\\",
"Contracts",
"\\",
"DataTransferObject",
"objects",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Model.php#L645-L666 |
evias/nem-php | src/Models/MosaicDefinition.php | MosaicDefinition.toDTO | public function toDTO($filterByKey = null)
{
$isHexDescription = $filterByKey === true ? true : false;
return [
"creator" => $this->creator()->publicKey,
"id" => $this->id()->toDTO(),
"description" => $isHexDescription ? $this->description()->toHex()
... | php | public function toDTO($filterByKey = null)
{
$isHexDescription = $filterByKey === true ? true : false;
return [
"creator" => $this->creator()->publicKey,
"id" => $this->id()->toDTO(),
"description" => $isHexDescription ? $this->description()->toHex()
... | [
"public",
"function",
"toDTO",
"(",
"$",
"filterByKey",
"=",
"null",
")",
"{",
"$",
"isHexDescription",
"=",
"$",
"filterByKey",
"===",
"true",
"?",
"true",
":",
"false",
";",
"return",
"[",
"\"creator\"",
"=>",
"$",
"this",
"->",
"creator",
"(",
")",
... | Address DTO automatically cleans address representation.
@param boolean $filterByKey When set to `true`, the method will return the description field in hexadecimal format.
@return array Associative array with key `address` containing a NIS *compliable* address representation. | [
"Address",
"DTO",
"automatically",
"cleans",
"address",
"representation",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/MosaicDefinition.php#L66-L77 |
evias/nem-php | src/Models/MosaicDefinition.php | MosaicDefinition.serialize | public function serialize($parameters = null)
{
$nisData = $this->toDTO(true); // true=hexadecimal description
// shortcuts
$serializer = $this->getSerializer();
$publicKey = hex2bin($nisData["creator"]);
// bundle with length of pub key and public key in UInt8
$pu... | php | public function serialize($parameters = null)
{
$nisData = $this->toDTO(true); // true=hexadecimal description
// shortcuts
$serializer = $this->getSerializer();
$publicKey = hex2bin($nisData["creator"]);
// bundle with length of pub key and public key in UInt8
$pu... | [
"public",
"function",
"serialize",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"nisData",
"=",
"$",
"this",
"->",
"toDTO",
"(",
"true",
")",
";",
"// true=hexadecimal description",
"// shortcuts",
"$",
"serializer",
"=",
"$",
"this",
"->",
"getSerial... | Overload of the \NEM\Core\Model::serialize() method to provide
with a specialization for *Mosaic Definition* serialization.
@see \NEM\Contracts\Serializable
@param null|string $parameters non-null will return only the named sub-dtos.
@return array Returns a byte-array with values in UInt8 representation. | [
"Overload",
"of",
"the",
"\\",
"NEM",
"\\",
"Core",
"\\",
"Model",
"::",
"serialize",
"()",
"method",
"to",
"provide",
"with",
"a",
"specialization",
"for",
"*",
"Mosaic",
"Definition",
"*",
"serialization",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/MosaicDefinition.php#L87-L110 |
evias/nem-php | src/Models/MultisigModification.php | MultisigModification.toDTO | public function toDTO($filterByKey = null)
{
if (! in_array($this->modificationType, [self::TYPE_ADD, self::TYPE_REMOVE]))
$this->modificationType = self::TYPE_ADD;
return [
"modificationType" => (int) $this->modificationType,
"cosignatoryAccount" => $this->cosig... | php | public function toDTO($filterByKey = null)
{
if (! in_array($this->modificationType, [self::TYPE_ADD, self::TYPE_REMOVE]))
$this->modificationType = self::TYPE_ADD;
return [
"modificationType" => (int) $this->modificationType,
"cosignatoryAccount" => $this->cosig... | [
"public",
"function",
"toDTO",
"(",
"$",
"filterByKey",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"modificationType",
",",
"[",
"self",
"::",
"TYPE_ADD",
",",
"self",
"::",
"TYPE_REMOVE",
"]",
")",
")",
"$",
"this",
"... | MultisigModification DTO automatically builds a *NIS compliant*
[MultisigCosignatoryModification](https://bob.nem.ninja/docs/#multisigCosignatoryModification)
@return array Associative array with key `modificationType` integer and `cosignatoryAccount` public key. | [
"MultisigModification",
"DTO",
"automatically",
"builds",
"a",
"*",
"NIS",
"compliant",
"*",
"[",
"MultisigCosignatoryModification",
"]",
"(",
"https",
":",
"//",
"bob",
".",
"nem",
".",
"ninja",
"/",
"docs",
"/",
"#multisigCosignatoryModification",
")"
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/MultisigModification.php#L78-L87 |
evias/nem-php | src/Models/MultisigModification.php | MultisigModification.serialize | public function serialize($parameters = null)
{
$nisData = $this->toDTO();
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_struct = $serializer->serializeInt(40); // length of structure
$uint8_type ... | php | public function serialize($parameters = null)
{
$nisData = $this->toDTO();
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_struct = $serializer->serializeInt(40); // length of structure
$uint8_type ... | [
"public",
"function",
"serialize",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"nisData",
"=",
"$",
"this",
"->",
"toDTO",
"(",
")",
";",
"// shortcuts",
"$",
"serializer",
"=",
"$",
"this",
"->",
"getSerializer",
"(",
")",
";",
"$",
"output",
... | Overload of the \NEM\Core\Model::serialize() method to provide
with a specialization for *mosaicId* serialization.
@see \NEM\Contracts\Serializable
@param null|string $parameters non-null will return only the named sub-dtos.
@return array Returns a byte-array with values in UInt8 representation. | [
"Overload",
"of",
"the",
"\\",
"NEM",
"\\",
"Core",
"\\",
"Model",
"::",
"serialize",
"()",
"method",
"to",
"provide",
"with",
"a",
"specialization",
"for",
"*",
"mosaicId",
"*",
"serialization",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/MultisigModification.php#L97-L113 |
evias/nem-php | src/Models/MosaicAttachment.php | MosaicAttachment.serialize | public function serialize($parameters = null)
{
$nisData = $this->toDTO();
// shortcuts
$mosaicS = $this->mosaicId()->serialize();
$quantity = $this->getSerializer()->serializeLong($nisData["quantity"]);
return $this->getSerializer()->aggregate($mosaicS, $quantity);
} | php | public function serialize($parameters = null)
{
$nisData = $this->toDTO();
// shortcuts
$mosaicS = $this->mosaicId()->serialize();
$quantity = $this->getSerializer()->serializeLong($nisData["quantity"]);
return $this->getSerializer()->aggregate($mosaicS, $quantity);
} | [
"public",
"function",
"serialize",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"nisData",
"=",
"$",
"this",
"->",
"toDTO",
"(",
")",
";",
"// shortcuts",
"$",
"mosaicS",
"=",
"$",
"this",
"->",
"mosaicId",
"(",
")",
"->",
"serialize",
"(",
")... | Overload of the \NEM\Core\Model::serialize() method to provide
with a specialization for *mosaicId and Quantity* serialization.
@see \NEM\Contracts\Serializable
@param null|string $parameters non-null will return only the named sub-dtos.
@return array Returns a byte-array with values in UInt8 representation. | [
"Overload",
"of",
"the",
"\\",
"NEM",
"\\",
"Core",
"\\",
"Model",
"::",
"serialize",
"()",
"method",
"to",
"provide",
"with",
"a",
"specialization",
"for",
"*",
"mosaicId",
"and",
"Quantity",
"*",
"serialization",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/MosaicAttachment.php#L83-L92 |
evias/nem-php | src/Models/Transaction.php | Transaction.create | static public function create(array $data = null)
{
if (empty($data["type"]) && isset($data["transaction"])) {
$type = $data["transaction"]["type"];
}
elseif (! $data || empty($data["type"])) {
return new static($data);
}
else {
$type = $da... | php | static public function create(array $data = null)
{
if (empty($data["type"]) && isset($data["transaction"])) {
$type = $data["transaction"]["type"];
}
elseif (! $data || empty($data["type"])) {
return new static($data);
}
else {
$type = $da... | [
"static",
"public",
"function",
"create",
"(",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"\"type\"",
"]",
")",
"&&",
"isset",
"(",
"$",
"data",
"[",
"\"transaction\"",
"]",
")",
")",
"{",
"$",
"type",
... | Class method to create a Transaction object out of
a DTO data set.
The `type` field is used to determine which class
must be loaded, see the static `typeClassMap` property
for details. | [
"Class",
"method",
"to",
"create",
"a",
"Transaction",
"object",
"out",
"of",
"a",
"DTO",
"data",
"set",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction.php#L162-L190 |
evias/nem-php | src/Models/Transaction.php | Transaction.meta | public function meta()
{
$meta = [];
// look for basic parameters of transactions, only unconfirmed
// transactions will have those fields empty.
if (isset($this->attributes["id"]))
$meta["id"] = (int) $this->attributes["id"];
if (isset($this->attributes["heigh... | php | public function meta()
{
$meta = [];
// look for basic parameters of transactions, only unconfirmed
// transactions will have those fields empty.
if (isset($this->attributes["id"]))
$meta["id"] = (int) $this->attributes["id"];
if (isset($this->attributes["heigh... | [
"public",
"function",
"meta",
"(",
")",
"{",
"$",
"meta",
"=",
"[",
"]",
";",
"// look for basic parameters of transactions, only unconfirmed",
"// transactions will have those fields empty.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"\"id\"",
"]... | The meta() method must be overloaded by any Transaction Type
which needs to extend the base META structure.
@return array | [
"The",
"meta",
"()",
"method",
"must",
"be",
"overloaded",
"by",
"any",
"Transaction",
"Type",
"which",
"needs",
"to",
"extend",
"the",
"base",
"META",
"structure",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction.php#L251-L268 |
evias/nem-php | src/Models/Transaction.php | Transaction.toDTO | public function toDTO($filterByKey = null)
{
$baseMeta = $this->meta();
$baseEntity = [
"timeStamp" => $this->timeStamp()->toDTO(),
"fee" => $this->fee()->toMicro(),
];
// extend entity data in sub class
// @see \NEM\Models\Transaction\MosaicTr... | php | public function toDTO($filterByKey = null)
{
$baseMeta = $this->meta();
$baseEntity = [
"timeStamp" => $this->timeStamp()->toDTO(),
"fee" => $this->fee()->toMicro(),
];
// extend entity data in sub class
// @see \NEM\Models\Transaction\MosaicTr... | [
"public",
"function",
"toDTO",
"(",
"$",
"filterByKey",
"=",
"null",
")",
"{",
"$",
"baseMeta",
"=",
"$",
"this",
"->",
"meta",
"(",
")",
";",
"$",
"baseEntity",
"=",
"[",
"\"timeStamp\"",
"=>",
"$",
"this",
"->",
"timeStamp",
"(",
")",
"->",
"toDTO"... | Account DTO represents NIS API's [AccountMetaDataPair](https://bob.nem.ninja/docs/#accountMetaDataPair).
@see [AccountMetaDataPair](https://bob.nem.ninja/docs/#accountMetaDataPair)
@return array Associative array containing a NIS *compliable* account representation. | [
"Account",
"DTO",
"represents",
"NIS",
"API",
"s",
"[",
"AccountMetaDataPair",
"]",
"(",
"https",
":",
"//",
"bob",
".",
"nem",
".",
"ninja",
"/",
"docs",
"/",
"#accountMetaDataPair",
")",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction.php#L276-L344 |
evias/nem-php | src/Models/Transaction.php | Transaction.serialize | public function serialize($parameters = null)
{
$nisData = $this->toDTO("transaction");
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize all the base data
$uint8_type = $serializer->serializeInt($nisData["type"]);
$uint8_version ... | php | public function serialize($parameters = null)
{
$nisData = $this->toDTO("transaction");
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize all the base data
$uint8_type = $serializer->serializeInt($nisData["type"]);
$uint8_version ... | [
"public",
"function",
"serialize",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"nisData",
"=",
"$",
"this",
"->",
"toDTO",
"(",
"\"transaction\"",
")",
";",
"// shortcuts",
"$",
"serializer",
"=",
"$",
"this",
"->",
"getSerializer",
"(",
")",
";"... | Overload of the \NEM\Core\Model::serialize() method to provide
with a specialization for *Transaction* serialization.
@see \NEM\Contracts\Serializable
@param null|string $parameters non-null will return only the named sub-dtos.
@return array Returns a byte-array with values in UInt8 representation. | [
"Overload",
"of",
"the",
"\\",
"NEM",
"\\",
"Core",
"\\",
"Model",
"::",
"serialize",
"()",
"method",
"to",
"provide",
"with",
"a",
"specialization",
"for",
"*",
"Transaction",
"*",
"serialization",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction.php#L354-L384 |
evias/nem-php | src/Models/Transaction.php | Transaction.timeStamp | public function timeStamp($timestamp = null)
{
$ts = $timestamp ?: $this->getAttribute("timeStamp");
if (is_integer($ts) || $ts instanceof TimeWindow) {
return new TimeWindow(["timeStamp" => $ts]);
}
return new TimeWindow();
} | php | public function timeStamp($timestamp = null)
{
$ts = $timestamp ?: $this->getAttribute("timeStamp");
if (is_integer($ts) || $ts instanceof TimeWindow) {
return new TimeWindow(["timeStamp" => $ts]);
}
return new TimeWindow();
} | [
"public",
"function",
"timeStamp",
"(",
"$",
"timestamp",
"=",
"null",
")",
"{",
"$",
"ts",
"=",
"$",
"timestamp",
"?",
":",
"$",
"this",
"->",
"getAttribute",
"(",
"\"timeStamp\"",
")",
";",
"if",
"(",
"is_integer",
"(",
"$",
"ts",
")",
"||",
"$",
... | Returns timestamp of the transaction.
@return int | [
"Returns",
"timestamp",
"of",
"the",
"transaction",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction.php#L391-L399 |
evias/nem-php | src/Models/Transaction.php | Transaction.deadline | public function deadline($deadline = null)
{
$ts = $deadline ?: $this->getAttribute("deadline");
if (is_integer($ts) || $ts instanceof TimeWindow) {
return new TimeWindow(["timeStamp" => $ts]);
}
return new TimeWindow();
} | php | public function deadline($deadline = null)
{
$ts = $deadline ?: $this->getAttribute("deadline");
if (is_integer($ts) || $ts instanceof TimeWindow) {
return new TimeWindow(["timeStamp" => $ts]);
}
return new TimeWindow();
} | [
"public",
"function",
"deadline",
"(",
"$",
"deadline",
"=",
"null",
")",
"{",
"$",
"ts",
"=",
"$",
"deadline",
"?",
":",
"$",
"this",
"->",
"getAttribute",
"(",
"\"deadline\"",
")",
";",
"if",
"(",
"is_integer",
"(",
"$",
"ts",
")",
"||",
"$",
"ts... | Returns deadline associated with the transaction
@return int | [
"Returns",
"deadline",
"associated",
"with",
"the",
"transaction"
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction.php#L406-L414 |
evias/nem-php | src/Models/Transaction.php | Transaction.fee | public function fee($fee = null)
{
$amount = $fee ?: $this->getAttribute("fee");
if (!$amount)
$amount = (int) Fee::calculateForTransaction($this);
return new Fee(["amount" => $amount]);
} | php | public function fee($fee = null)
{
$amount = $fee ?: $this->getAttribute("fee");
if (!$amount)
$amount = (int) Fee::calculateForTransaction($this);
return new Fee(["amount" => $amount]);
} | [
"public",
"function",
"fee",
"(",
"$",
"fee",
"=",
"null",
")",
"{",
"$",
"amount",
"=",
"$",
"fee",
"?",
":",
"$",
"this",
"->",
"getAttribute",
"(",
"\"fee\"",
")",
";",
"if",
"(",
"!",
"$",
"amount",
")",
"$",
"amount",
"=",
"(",
"int",
")",... | Mutator for the fee amount object.
@return \NEM\Models\Fee | [
"Mutator",
"for",
"the",
"fee",
"amount",
"object",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction.php#L441-L448 |
evias/nem-php | src/Models/Transaction/MosaicDefinition.php | MosaicDefinition.extend | public function extend()
{
return [
"creationFeeSink" => $this->creationFeeSink()->address()->toClean(),
"creationFee" => Fee::MOSAIC_DEFINITION,
"mosaicDefinition" => $this->mosaicDefinition()->toDTO(),
// transaction type specialization
"type" ... | php | public function extend()
{
return [
"creationFeeSink" => $this->creationFeeSink()->address()->toClean(),
"creationFee" => Fee::MOSAIC_DEFINITION,
"mosaicDefinition" => $this->mosaicDefinition()->toDTO(),
// transaction type specialization
"type" ... | [
"public",
"function",
"extend",
"(",
")",
"{",
"return",
"[",
"\"creationFeeSink\"",
"=>",
"$",
"this",
"->",
"creationFeeSink",
"(",
")",
"->",
"address",
"(",
")",
"->",
"toClean",
"(",
")",
",",
"\"creationFee\"",
"=>",
"Fee",
"::",
"MOSAIC_DEFINITION",
... | The extend() method must be overloaded by any Transaction Type
which needs to extend the base DTO structure.
@return array | [
"The",
"extend",
"()",
"method",
"must",
"be",
"overloaded",
"by",
"any",
"Transaction",
"Type",
"which",
"needs",
"to",
"extend",
"the",
"base",
"DTO",
"structure",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/MosaicDefinition.php#L67-L76 |
evias/nem-php | src/Models/Transaction/MosaicDefinition.php | MosaicDefinition.serialize | public function serialize($parameters = null)
{
$baseTx = parent::serialize($parameters);
$nisData = $this->extend();
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_def = $this->mosaicDefinition... | php | public function serialize($parameters = null)
{
$baseTx = parent::serialize($parameters);
$nisData = $this->extend();
// shortcuts
$serializer = $this->getSerializer();
$output = [];
// serialize specialized fields
$uint8_def = $this->mosaicDefinition... | [
"public",
"function",
"serialize",
"(",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"baseTx",
"=",
"parent",
"::",
"serialize",
"(",
"$",
"parameters",
")",
";",
"$",
"nisData",
"=",
"$",
"this",
"->",
"extend",
"(",
")",
";",
"// shortcuts",
"$",
... | Overload of the \NEM\Core\Model::serialize() method to provide
with a specialization for *MosaicDefinition transaction* serialization.
@see \NEM\Contracts\Serializable
@param null|string $parameters non-null will return only the named sub-dtos.
@return array Returns a byte-array with values in UInt8 representa... | [
"Overload",
"of",
"the",
"\\",
"NEM",
"\\",
"Core",
"\\",
"Model",
"::",
"serialize",
"()",
"method",
"to",
"provide",
"with",
"a",
"specialization",
"for",
"*",
"MosaicDefinition",
"transaction",
"*",
"serialization",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/Transaction/MosaicDefinition.php#L99-L123 |
evias/nem-php | src/Models/MosaicLevy.php | MosaicLevy.toDTO | public function toDTO($filterByKey = null)
{
if (! $this->getAttribute("recipient") || ! $this->getAttribute("mosaicId"))
return [];
return [
"type" => $this->type,
"recipient" => $this->recipient()->address()->toClean(),
"mosaicId" => $this->mosaicId... | php | public function toDTO($filterByKey = null)
{
if (! $this->getAttribute("recipient") || ! $this->getAttribute("mosaicId"))
return [];
return [
"type" => $this->type,
"recipient" => $this->recipient()->address()->toClean(),
"mosaicId" => $this->mosaicId... | [
"public",
"function",
"toDTO",
"(",
"$",
"filterByKey",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getAttribute",
"(",
"\"recipient\"",
")",
"||",
"!",
"$",
"this",
"->",
"getAttribute",
"(",
"\"mosaicId\"",
")",
")",
"return",
"[",
"]"... | Mosaic Levy DTO builds a package with offsets `type`,
`recipient`, `mosaicId` and `fee`.
Those fields are required by NIS for the mosaic levy identification.
@return array Associative array with fields present in `$fillable` property. | [
"Mosaic",
"Levy",
"DTO",
"builds",
"a",
"package",
"with",
"offsets",
"type",
"recipient",
"mosaicId",
"and",
"fee",
"."
] | train | https://github.com/evias/nem-php/blob/88cf1674077ed1146b85521db25c09e60c3634bb/src/Models/MosaicLevy.php#L77-L88 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.