id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
43,100
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.doArchive
public function doArchive() { $owner = $this->owner; $owner->invokeWithExtensions('onBeforeArchive', $this); $owner->deleteFromChangeSets(); // Unpublish without creating deleted version $this->suppressDeletedVersion(function () use ($owner) { $owner->doUnpublish(); $owner->deleteFromStage(static::DRAFT); }); // Create deleted version in both stages $this->createDeletedVersion([ static::LIVE, static::DRAFT, ]); $owner->invokeWithExtensions('onAfterArchive', $this); return true; }
php
public function doArchive() { $owner = $this->owner; $owner->invokeWithExtensions('onBeforeArchive', $this); $owner->deleteFromChangeSets(); // Unpublish without creating deleted version $this->suppressDeletedVersion(function () use ($owner) { $owner->doUnpublish(); $owner->deleteFromStage(static::DRAFT); }); // Create deleted version in both stages $this->createDeletedVersion([ static::LIVE, static::DRAFT, ]); $owner->invokeWithExtensions('onAfterArchive', $this); return true; }
[ "public", "function", "doArchive", "(", ")", "{", "$", "owner", "=", "$", "this", "->", "owner", ";", "$", "owner", "->", "invokeWithExtensions", "(", "'onBeforeArchive'", ",", "$", "this", ")", ";", "$", "owner", "->", "deleteFromChangeSets", "(", ")", ...
Removes the record from both live and stage User code should call {@see canArchive()} prior to invoking this method. @return bool Success
[ "Removes", "the", "record", "from", "both", "live", "and", "stage" ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L1730-L1747
43,101
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.doUnpublish
public function doUnpublish() { $owner = $this->owner; // Skip if this record isn't saved if (!$owner->isInDB()) { return false; } // Skip if this record isn't on live if (!$owner->isPublished()) { return false; } $owner->invokeWithExtensions('onBeforeUnpublish'); // Modify in isolated mode static::withVersionedMode(function () use ($owner) { static::set_stage(static::LIVE); // This way our ID won't be unset $clone = clone $owner; $clone->delete(); }); $owner->invokeWithExtensions('onAfterUnpublish'); return true; }
php
public function doUnpublish() { $owner = $this->owner; // Skip if this record isn't saved if (!$owner->isInDB()) { return false; } // Skip if this record isn't on live if (!$owner->isPublished()) { return false; } $owner->invokeWithExtensions('onBeforeUnpublish'); // Modify in isolated mode static::withVersionedMode(function () use ($owner) { static::set_stage(static::LIVE); // This way our ID won't be unset $clone = clone $owner; $clone->delete(); }); $owner->invokeWithExtensions('onAfterUnpublish'); return true; }
[ "public", "function", "doUnpublish", "(", ")", "{", "$", "owner", "=", "$", "this", "->", "owner", ";", "// Skip if this record isn't saved", "if", "(", "!", "$", "owner", "->", "isInDB", "(", ")", ")", "{", "return", "false", ";", "}", "// Skip if this re...
Removes this record from the live site User code should call {@see canUnpublish()} prior to invoking this method. @return bool Flag whether the unpublish was successful
[ "Removes", "this", "record", "from", "the", "live", "site" ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L1756-L1782
43,102
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.hasPublishedOwners
public function hasPublishedOwners() { if (!$this->isPublished()) { return false; } // Count live owners /** @var Versioned|RecursivePublishable|DataObject $liveRecord */ $liveRecord = static::get_by_stage(get_class($this->owner), Versioned::LIVE)->byID($this->owner->ID); return $liveRecord->findOwners(false)->count() > 0; }
php
public function hasPublishedOwners() { if (!$this->isPublished()) { return false; } // Count live owners /** @var Versioned|RecursivePublishable|DataObject $liveRecord */ $liveRecord = static::get_by_stage(get_class($this->owner), Versioned::LIVE)->byID($this->owner->ID); return $liveRecord->findOwners(false)->count() > 0; }
[ "public", "function", "hasPublishedOwners", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isPublished", "(", ")", ")", "{", "return", "false", ";", "}", "// Count live owners", "/** @var Versioned|RecursivePublishable|DataObject $liveRecord */", "$", "liveRecord"...
Determine if this object is published, and has any published owners. If this is true, a warning should be shown before this is published. Note: This method returns false if the object itself is unpublished, since owners are only considered on the same stage as the record itself. @return bool
[ "Determine", "if", "this", "object", "is", "published", "and", "has", "any", "published", "owners", ".", "If", "this", "is", "true", "a", "warning", "should", "be", "shown", "before", "this", "is", "published", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L1799-L1808
43,103
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.copyVersionToStage
public function copyVersionToStage($fromStage, $toStage, $createNewVersion = true) { // Disallow $createNewVersion = false if (!$createNewVersion) { Deprecation::notice('5.0', 'copyVersionToStage no longer allows $createNewVersion to be false'); $createNewVersion = true; } $owner = $this->owner; $owner->invokeWithExtensions('onBeforeVersionedPublish', $fromStage, $toStage, $createNewVersion); // Get at specific version $from = $this->getAtVersion($fromStage); if (!$from) { $baseClass = $owner->baseClass(); throw new InvalidArgumentException("Can't find {$baseClass}#{$owner->ID} in stage {$fromStage}"); } $from->writeToStage($toStage); $owner->invokeWithExtensions('onAfterVersionedPublish', $fromStage, $toStage, $createNewVersion); }
php
public function copyVersionToStage($fromStage, $toStage, $createNewVersion = true) { // Disallow $createNewVersion = false if (!$createNewVersion) { Deprecation::notice('5.0', 'copyVersionToStage no longer allows $createNewVersion to be false'); $createNewVersion = true; } $owner = $this->owner; $owner->invokeWithExtensions('onBeforeVersionedPublish', $fromStage, $toStage, $createNewVersion); // Get at specific version $from = $this->getAtVersion($fromStage); if (!$from) { $baseClass = $owner->baseClass(); throw new InvalidArgumentException("Can't find {$baseClass}#{$owner->ID} in stage {$fromStage}"); } $from->writeToStage($toStage); $owner->invokeWithExtensions('onAfterVersionedPublish', $fromStage, $toStage, $createNewVersion); }
[ "public", "function", "copyVersionToStage", "(", "$", "fromStage", ",", "$", "toStage", ",", "$", "createNewVersion", "=", "true", ")", "{", "// Disallow $createNewVersion = false", "if", "(", "!", "$", "createNewVersion", ")", "{", "Deprecation", "::", "notice", ...
Move a database record from one stage to the other. @param int|string|null $fromStage Place to copy from. Can be either a stage name or a version number. Null copies current object to stage @param string $toStage Place to copy to. Must be a stage name. @param bool $createNewVersion [DEPRECATED] This parameter is ignored, as copying to stage should always create a new version.
[ "Move", "a", "database", "record", "from", "one", "stage", "to", "the", "other", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L1851-L1870
43,104
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.stagesDiffer
public function stagesDiffer() { if (func_num_args() > 0) { Deprecation::notice('5.0', 'Versioned only has two stages and stagesDiffer no longer requires parameters'); } $id = $this->owner->ID ?: $this->owner->OldID; if (!$id || !$this->hasStages()) { return false; } $draftVersion = static::get_versionnumber_by_stage($this->owner, Versioned::DRAFT, $id); $liveVersion = static::get_versionnumber_by_stage($this->owner, Versioned::LIVE, $id); return $draftVersion !== $liveVersion; }
php
public function stagesDiffer() { if (func_num_args() > 0) { Deprecation::notice('5.0', 'Versioned only has two stages and stagesDiffer no longer requires parameters'); } $id = $this->owner->ID ?: $this->owner->OldID; if (!$id || !$this->hasStages()) { return false; } $draftVersion = static::get_versionnumber_by_stage($this->owner, Versioned::DRAFT, $id); $liveVersion = static::get_versionnumber_by_stage($this->owner, Versioned::LIVE, $id); return $draftVersion !== $liveVersion; }
[ "public", "function", "stagesDiffer", "(", ")", "{", "if", "(", "func_num_args", "(", ")", ">", "0", ")", "{", "Deprecation", "::", "notice", "(", "'5.0'", ",", "'Versioned only has two stages and stagesDiffer no longer requires parameters'", ")", ";", "}", "$", "...
Compare two stages to see if they're different. Only checks the version numbers, not the actual content. @return bool
[ "Compare", "two", "stages", "to", "see", "if", "they", "re", "different", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L1910-L1923
43,105
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.allVersions
public function allVersions($filter = "", $sort = "", $limit = "", $join = "", $having = "") { // Make sure the table names are not postfixed (e.g. _Live) $oldMode = static::get_reading_mode(); static::set_stage(static::DRAFT); $owner = $this->owner; $list = DataObject::get(DataObject::getSchema()->baseDataClass($owner), $filter, $sort, $join, $limit); if ($having) { // @todo - This method doesn't exist on DataList $list->having($having); } $query = $list->dataQuery()->query(); $baseTable = null; foreach ($query->getFrom() as $table => $tableJoin) { if (is_string($tableJoin) && $tableJoin[0] == '"') { $baseTable = str_replace('"', '', $tableJoin); } elseif (is_string($tableJoin) && substr($tableJoin, 0, 5) != 'INNER') { $query->setFrom([ $table => "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\"=\"{$baseTable}_Versions\".\"RecordID\"" . " AND \"$table\".\"Version\" = \"{$baseTable}_Versions\".\"Version\"" ]); } $query->renameTable($table, $table . '_Versions'); } // Add all <basetable>_Versions columns foreach (Config::inst()->get(static::class, 'db_for_versions_table') as $name => $type) { $query->selectField(sprintf('"%s_Versions"."%s"', $baseTable, $name), $name); } $query->addWhere([ "\"{$baseTable}_Versions\".\"RecordID\" = ?" => $owner->ID ]); $query->setOrderBy(($sort) ? $sort : "\"{$baseTable}_Versions\".\"LastEdited\" DESC, \"{$baseTable}_Versions\".\"Version\" DESC"); $records = $query->execute(); $versions = new ArrayList(); foreach ($records as $record) { $versions->push(new Versioned_Version($record)); } Versioned::set_reading_mode($oldMode); return $versions; }
php
public function allVersions($filter = "", $sort = "", $limit = "", $join = "", $having = "") { // Make sure the table names are not postfixed (e.g. _Live) $oldMode = static::get_reading_mode(); static::set_stage(static::DRAFT); $owner = $this->owner; $list = DataObject::get(DataObject::getSchema()->baseDataClass($owner), $filter, $sort, $join, $limit); if ($having) { // @todo - This method doesn't exist on DataList $list->having($having); } $query = $list->dataQuery()->query(); $baseTable = null; foreach ($query->getFrom() as $table => $tableJoin) { if (is_string($tableJoin) && $tableJoin[0] == '"') { $baseTable = str_replace('"', '', $tableJoin); } elseif (is_string($tableJoin) && substr($tableJoin, 0, 5) != 'INNER') { $query->setFrom([ $table => "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\"=\"{$baseTable}_Versions\".\"RecordID\"" . " AND \"$table\".\"Version\" = \"{$baseTable}_Versions\".\"Version\"" ]); } $query->renameTable($table, $table . '_Versions'); } // Add all <basetable>_Versions columns foreach (Config::inst()->get(static::class, 'db_for_versions_table') as $name => $type) { $query->selectField(sprintf('"%s_Versions"."%s"', $baseTable, $name), $name); } $query->addWhere([ "\"{$baseTable}_Versions\".\"RecordID\" = ?" => $owner->ID ]); $query->setOrderBy(($sort) ? $sort : "\"{$baseTable}_Versions\".\"LastEdited\" DESC, \"{$baseTable}_Versions\".\"Version\" DESC"); $records = $query->execute(); $versions = new ArrayList(); foreach ($records as $record) { $versions->push(new Versioned_Version($record)); } Versioned::set_reading_mode($oldMode); return $versions; }
[ "public", "function", "allVersions", "(", "$", "filter", "=", "\"\"", ",", "$", "sort", "=", "\"\"", ",", "$", "limit", "=", "\"\"", ",", "$", "join", "=", "\"\"", ",", "$", "having", "=", "\"\"", ")", "{", "// Make sure the table names are not postfixed (...
Return a list of all the versions available. @param string $filter @param string $sort @param string $limit @param string $join @deprecated use leftJoin($table, $joinClause) instead @param string $having @deprecated @return ArrayList
[ "Return", "a", "list", "of", "all", "the", "versions", "available", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L1961-L2009
43,106
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.compareVersions
public function compareVersions($from, $to) { $owner = $this->owner; $fromRecord = Versioned::get_version(get_class($owner), $owner->ID, $from); $toRecord = Versioned::get_version(get_class($owner), $owner->ID, $to); $diff = new DataDifferencer($fromRecord, $toRecord); return $diff->diffedData(); }
php
public function compareVersions($from, $to) { $owner = $this->owner; $fromRecord = Versioned::get_version(get_class($owner), $owner->ID, $from); $toRecord = Versioned::get_version(get_class($owner), $owner->ID, $to); $diff = new DataDifferencer($fromRecord, $toRecord); return $diff->diffedData(); }
[ "public", "function", "compareVersions", "(", "$", "from", ",", "$", "to", ")", "{", "$", "owner", "=", "$", "this", "->", "owner", ";", "$", "fromRecord", "=", "Versioned", "::", "get_version", "(", "get_class", "(", "$", "owner", ")", ",", "$", "ow...
Compare two version, and return the diff between them. @param string $from The version to compare from. @param string $to The version to compare to. @return DataObject
[ "Compare", "two", "version", "and", "return", "the", "diff", "between", "them", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2019-L2028
43,107
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.baseTable
protected function baseTable($stage = null) { $baseTable = $this->owner->baseTable(); return $this->stageTable($baseTable, $stage); }
php
protected function baseTable($stage = null) { $baseTable = $this->owner->baseTable(); return $this->stageTable($baseTable, $stage); }
[ "protected", "function", "baseTable", "(", "$", "stage", "=", "null", ")", "{", "$", "baseTable", "=", "$", "this", "->", "owner", "->", "baseTable", "(", ")", ";", "return", "$", "this", "->", "stageTable", "(", "$", "baseTable", ",", "$", "stage", ...
Return the base table - the class that directly extends DataObject. Protected so it doesn't conflict with DataObject::baseTable() @param string $stage @return string
[ "Return", "the", "base", "table", "-", "the", "class", "that", "directly", "extends", "DataObject", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2038-L2042
43,108
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.choose_site_stage
public static function choose_site_stage(HTTPRequest $request) { $mode = static::get_default_reading_mode(); // Check any pre-existing session mode $useSession = Config::inst()->get(static::class, 'use_session'); $updateSession = false; if ($useSession) { // Boot reading mode from session $mode = $request->getSession()->get('readingMode') ?: $mode; // Set draft site security if disabled for this session if ($request->getSession()->get('unsecuredDraftSite')) { static::set_draft_site_secured(false); } } // Verify if querystring contains valid reading mode $queryMode = ReadingMode::fromQueryString($request->getVars()); if ($queryMode) { $mode = $queryMode; $updateSession = true; } // Save reading mode Versioned::set_reading_mode($mode); // Set mode if session enabled if ($useSession && $updateSession) { $request->getSession()->set('readingMode', $mode); } if (!headers_sent() && !Director::is_cli()) { if (Versioned::get_stage() === static::LIVE) { // clear the cookie if it's set if (Cookie::get('bypassStaticCache')) { Cookie::force_expiry('bypassStaticCache', null, null, false, true /* httponly */); } } else { // set the cookie if it's cleared if (!Cookie::get('bypassStaticCache')) { Cookie::set('bypassStaticCache', '1', 0, null, null, false, true /* httponly */); } } } }
php
public static function choose_site_stage(HTTPRequest $request) { $mode = static::get_default_reading_mode(); // Check any pre-existing session mode $useSession = Config::inst()->get(static::class, 'use_session'); $updateSession = false; if ($useSession) { // Boot reading mode from session $mode = $request->getSession()->get('readingMode') ?: $mode; // Set draft site security if disabled for this session if ($request->getSession()->get('unsecuredDraftSite')) { static::set_draft_site_secured(false); } } // Verify if querystring contains valid reading mode $queryMode = ReadingMode::fromQueryString($request->getVars()); if ($queryMode) { $mode = $queryMode; $updateSession = true; } // Save reading mode Versioned::set_reading_mode($mode); // Set mode if session enabled if ($useSession && $updateSession) { $request->getSession()->set('readingMode', $mode); } if (!headers_sent() && !Director::is_cli()) { if (Versioned::get_stage() === static::LIVE) { // clear the cookie if it's set if (Cookie::get('bypassStaticCache')) { Cookie::force_expiry('bypassStaticCache', null, null, false, true /* httponly */); } } else { // set the cookie if it's cleared if (!Cookie::get('bypassStaticCache')) { Cookie::set('bypassStaticCache', '1', 0, null, null, false, true /* httponly */); } } } }
[ "public", "static", "function", "choose_site_stage", "(", "HTTPRequest", "$", "request", ")", "{", "$", "mode", "=", "static", "::", "get_default_reading_mode", "(", ")", ";", "// Check any pre-existing session mode", "$", "useSession", "=", "Config", "::", "inst", ...
Choose the stage the site is currently on. If $_GET['stage'] is set, then it will use that stage, and store it in the session. if $_GET['archiveDate'] is set, it will use that date, and store it in the session. If neither of these are set, it checks the session, otherwise the stage is set to 'Live'. @param HTTPRequest $request
[ "Choose", "the", "stage", "the", "site", "is", "currently", "on", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2108-L2153
43,109
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.current_archived_stage
public static function current_archived_stage() { $parts = explode('.', Versioned::get_reading_mode()); if (sizeof($parts) === 3 && $parts[0] == 'Archive') { return $parts[2]; } return static::DRAFT; }
php
public static function current_archived_stage() { $parts = explode('.', Versioned::get_reading_mode()); if (sizeof($parts) === 3 && $parts[0] == 'Archive') { return $parts[2]; } return static::DRAFT; }
[ "public", "static", "function", "current_archived_stage", "(", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "Versioned", "::", "get_reading_mode", "(", ")", ")", ";", "if", "(", "sizeof", "(", "$", "parts", ")", "===", "3", "&&", "$", "part...
Get the current archive stage. @return string
[ "Get", "the", "current", "archive", "stage", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2209-L2216
43,110
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.get_draft_site_secured
public static function get_draft_site_secured() { if (isset(static::$is_draft_site_secured)) { return (bool)static::$is_draft_site_secured; } // Config default return (bool)Config::inst()->get(self::class, 'draft_site_secured'); }
php
public static function get_draft_site_secured() { if (isset(static::$is_draft_site_secured)) { return (bool)static::$is_draft_site_secured; } // Config default return (bool)Config::inst()->get(self::class, 'draft_site_secured'); }
[ "public", "static", "function", "get_draft_site_secured", "(", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "is_draft_site_secured", ")", ")", "{", "return", "(", "bool", ")", "static", "::", "$", "is_draft_site_secured", ";", "}", "// Config defaul...
Check if draft site should be secured. Can be turned off if draft site unauthenticated @return bool
[ "Check", "if", "draft", "site", "should", "be", "secured", ".", "Can", "be", "turned", "off", "if", "draft", "site", "unauthenticated" ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2257-L2264
43,111
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.reading_archived_date
public static function reading_archived_date($date, $stage = self::DRAFT) { ReadingMode::validateStage($stage); Versioned::set_reading_mode('Archive.' . $date . '.' . $stage); }
php
public static function reading_archived_date($date, $stage = self::DRAFT) { ReadingMode::validateStage($stage); Versioned::set_reading_mode('Archive.' . $date . '.' . $stage); }
[ "public", "static", "function", "reading_archived_date", "(", "$", "date", ",", "$", "stage", "=", "self", "::", "DRAFT", ")", "{", "ReadingMode", "::", "validateStage", "(", "$", "stage", ")", ";", "Versioned", "::", "set_reading_mode", "(", "'Archive.'", "...
Set the reading archive date. @param string $date New reading archived date. @param string $stage Set stage
[ "Set", "the", "reading", "archive", "date", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2282-L2286
43,112
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.get_one_by_stage
public static function get_one_by_stage($class, $stage, $filter = '', $cache = true, $sort = '') { return static::withVersionedMode(function () use ($class, $stage, $filter, $cache, $sort) { Versioned::set_stage($stage); return DataObject::get_one($class, $filter, $cache, $sort); }); }
php
public static function get_one_by_stage($class, $stage, $filter = '', $cache = true, $sort = '') { return static::withVersionedMode(function () use ($class, $stage, $filter, $cache, $sort) { Versioned::set_stage($stage); return DataObject::get_one($class, $filter, $cache, $sort); }); }
[ "public", "static", "function", "get_one_by_stage", "(", "$", "class", ",", "$", "stage", ",", "$", "filter", "=", "''", ",", "$", "cache", "=", "true", ",", "$", "sort", "=", "''", ")", "{", "return", "static", "::", "withVersionedMode", "(", "functio...
Get a singleton instance of a class in the given stage. @param string $class The name of the class. @param string $stage The name of the stage. @param string $filter A filter to be inserted into the WHERE clause. @param boolean $cache Use caching. @param string $sort A sort expression to be inserted into the ORDER BY clause. @return DataObject
[ "Get", "a", "singleton", "instance", "of", "a", "class", "in", "the", "given", "stage", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2299-L2305
43,113
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.get_versionnumber_by_stage
public static function get_versionnumber_by_stage($class, $stage, $id, $cache = true) { ReadingMode::validateStage($stage); $baseClass = DataObject::getSchema()->baseDataClass($class); $stageTable = DataObject::getSchema()->tableName($baseClass); if ($stage === static::LIVE) { $stageTable .= "_{$stage}"; } // cached call if ($cache) { if (isset(self::$cache_versionnumber[$baseClass][$stage][$id])) { return self::$cache_versionnumber[$baseClass][$stage][$id] ?: null; } elseif (isset(self::$cache_versionnumber[$baseClass][$stage]['_complete'])) { // if the cache was marked as "complete" then we know the record is missing, just return null // this is used for treeview optimisation to avoid unnecessary re-requests for draft pages return null; } } // get version as performance-optimized SQL query (gets called for each record in the sitetree) $version = DB::prepared_query( "SELECT \"Version\" FROM \"$stageTable\" WHERE \"ID\" = ?", [$id] )->value(); // cache value (if required) if ($cache) { if (!isset(self::$cache_versionnumber[$baseClass])) { self::$cache_versionnumber[$baseClass] = []; } if (!isset(self::$cache_versionnumber[$baseClass][$stage])) { self::$cache_versionnumber[$baseClass][$stage] = []; } // Internally store nulls as 0 self::$cache_versionnumber[$baseClass][$stage][$id] = $version ?: 0; } return $version ?: null; }
php
public static function get_versionnumber_by_stage($class, $stage, $id, $cache = true) { ReadingMode::validateStage($stage); $baseClass = DataObject::getSchema()->baseDataClass($class); $stageTable = DataObject::getSchema()->tableName($baseClass); if ($stage === static::LIVE) { $stageTable .= "_{$stage}"; } // cached call if ($cache) { if (isset(self::$cache_versionnumber[$baseClass][$stage][$id])) { return self::$cache_versionnumber[$baseClass][$stage][$id] ?: null; } elseif (isset(self::$cache_versionnumber[$baseClass][$stage]['_complete'])) { // if the cache was marked as "complete" then we know the record is missing, just return null // this is used for treeview optimisation to avoid unnecessary re-requests for draft pages return null; } } // get version as performance-optimized SQL query (gets called for each record in the sitetree) $version = DB::prepared_query( "SELECT \"Version\" FROM \"$stageTable\" WHERE \"ID\" = ?", [$id] )->value(); // cache value (if required) if ($cache) { if (!isset(self::$cache_versionnumber[$baseClass])) { self::$cache_versionnumber[$baseClass] = []; } if (!isset(self::$cache_versionnumber[$baseClass][$stage])) { self::$cache_versionnumber[$baseClass][$stage] = []; } // Internally store nulls as 0 self::$cache_versionnumber[$baseClass][$stage][$id] = $version ?: 0; } return $version ?: null; }
[ "public", "static", "function", "get_versionnumber_by_stage", "(", "$", "class", ",", "$", "stage", ",", "$", "id", ",", "$", "cache", "=", "true", ")", "{", "ReadingMode", "::", "validateStage", "(", "$", "stage", ")", ";", "$", "baseClass", "=", "DataO...
Gets the current version number of a specific record. @param string $class Class to search @param string $stage Stage name @param int $id ID of the record @param bool $cache Set to true to turn on cache @return int|null Return the version number, or null if not on this stage
[ "Gets", "the", "current", "version", "number", "of", "a", "specific", "record", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2316-L2357
43,114
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.get_by_stage
public static function get_by_stage( $class, $stage, $filter = '', $sort = '', $join = '', $limit = null, $containerClass = DataList::class ) { ReadingMode::validateStage($stage); $result = DataObject::get($class, $filter, $sort, $join, $limit, $containerClass); return $result->setDataQueryParam([ 'Versioned.mode' => 'stage', 'Versioned.stage' => $stage ]); }
php
public static function get_by_stage( $class, $stage, $filter = '', $sort = '', $join = '', $limit = null, $containerClass = DataList::class ) { ReadingMode::validateStage($stage); $result = DataObject::get($class, $filter, $sort, $join, $limit, $containerClass); return $result->setDataQueryParam([ 'Versioned.mode' => 'stage', 'Versioned.stage' => $stage ]); }
[ "public", "static", "function", "get_by_stage", "(", "$", "class", ",", "$", "stage", ",", "$", "filter", "=", "''", ",", "$", "sort", "=", "''", ",", "$", "join", "=", "''", ",", "$", "limit", "=", "null", ",", "$", "containerClass", "=", "DataLis...
Get a set of class instances by the given stage. @param string $class The name of the class. @param string $stage The name of the stage. @param string $filter A filter to be inserted into the WHERE clause. @param string $sort A sort expression to be inserted into the ORDER BY clause. @param string $join Deprecated, use leftJoin($table, $joinClause) instead @param int $limit A limit on the number of records returned from the database. @param string $containerClass The container class for the result set (default is DataList) @return DataList A modified DataList designated to the specified stage
[ "Get", "a", "set", "of", "class", "instances", "by", "the", "given", "stage", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2437-L2452
43,115
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.deleteFromStage
public function deleteFromStage($stage) { ReadingMode::validateStage($stage); $owner = $this->owner; static::withVersionedMode(function () use ($stage, $owner) { Versioned::set_stage($stage); $clone = clone $owner; $clone->delete(); }); // Fix the version number cache (in case you go delete from stage and then check ExistsOnLive) $baseClass = $owner->baseClass(); self::$cache_versionnumber[$baseClass][$stage][$owner->ID] = null; }
php
public function deleteFromStage($stage) { ReadingMode::validateStage($stage); $owner = $this->owner; static::withVersionedMode(function () use ($stage, $owner) { Versioned::set_stage($stage); $clone = clone $owner; $clone->delete(); }); // Fix the version number cache (in case you go delete from stage and then check ExistsOnLive) $baseClass = $owner->baseClass(); self::$cache_versionnumber[$baseClass][$stage][$owner->ID] = null; }
[ "public", "function", "deleteFromStage", "(", "$", "stage", ")", "{", "ReadingMode", "::", "validateStage", "(", "$", "stage", ")", ";", "$", "owner", "=", "$", "this", "->", "owner", ";", "static", "::", "withVersionedMode", "(", "function", "(", ")", "...
Delete this record from the given stage @param string $stage
[ "Delete", "this", "record", "from", "the", "given", "stage" ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2459-L2472
43,116
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.rollbackSingle
public function rollbackSingle($version) { // Validate $version and safely cast if (isset($version) && !is_numeric($version) && $version !== self::LIVE) { throw new InvalidArgumentException("Invalid rollback source version $version"); } if (isset($version) && is_numeric($version)) { $version = (int)$version; } // Copy version between stage $owner = $this->owner; $owner->invokeWithExtensions('onBeforeRollbackSingle', $version); $owner->copyVersionToStage($version, self::DRAFT); $owner->invokeWithExtensions('onAfterRollbackSingle', $version); }
php
public function rollbackSingle($version) { // Validate $version and safely cast if (isset($version) && !is_numeric($version) && $version !== self::LIVE) { throw new InvalidArgumentException("Invalid rollback source version $version"); } if (isset($version) && is_numeric($version)) { $version = (int)$version; } // Copy version between stage $owner = $this->owner; $owner->invokeWithExtensions('onBeforeRollbackSingle', $version); $owner->copyVersionToStage($version, self::DRAFT); $owner->invokeWithExtensions('onAfterRollbackSingle', $version); }
[ "public", "function", "rollbackSingle", "(", "$", "version", ")", "{", "// Validate $version and safely cast", "if", "(", "isset", "(", "$", "version", ")", "&&", "!", "is_numeric", "(", "$", "version", ")", "&&", "$", "version", "!==", "self", "::", "LIVE",...
Rollback draft to a given version @param int|string|null $version Version ID or Versioned::LIVE to rollback from live. Null to rollback current owner object.
[ "Rollback", "draft", "to", "a", "given", "version" ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2571-L2585
43,117
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.isPublished
public function isPublished() { $id = $this->owner->ID ?: $this->owner->OldID; if (!$id) { return false; } // Non-staged objects are considered "published" if saved if (!$this->hasStages()) { return true; } $liveVersion = static::get_versionnumber_by_stage($this->owner, Versioned::LIVE, $id); return (bool)$liveVersion; }
php
public function isPublished() { $id = $this->owner->ID ?: $this->owner->OldID; if (!$id) { return false; } // Non-staged objects are considered "published" if saved if (!$this->hasStages()) { return true; } $liveVersion = static::get_versionnumber_by_stage($this->owner, Versioned::LIVE, $id); return (bool)$liveVersion; }
[ "public", "function", "isPublished", "(", ")", "{", "$", "id", "=", "$", "this", "->", "owner", "->", "ID", "?", ":", "$", "this", "->", "owner", "->", "OldID", ";", "if", "(", "!", "$", "id", ")", "{", "return", "false", ";", "}", "// Non-staged...
Check if this record exists on live @return bool
[ "Check", "if", "this", "record", "exists", "on", "live" ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2664-L2678
43,118
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.isArchived
public function isArchived() { $id = $this->owner->ID ?: $this->owner->OldID; return $id && !$this->isOnDraft() && !$this->isPublished(); }
php
public function isArchived() { $id = $this->owner->ID ?: $this->owner->OldID; return $id && !$this->isOnDraft() && !$this->isPublished(); }
[ "public", "function", "isArchived", "(", ")", "{", "$", "id", "=", "$", "this", "->", "owner", "->", "ID", "?", ":", "$", "this", "->", "owner", "->", "OldID", ";", "return", "$", "id", "&&", "!", "$", "this", "->", "isOnDraft", "(", ")", "&&", ...
Check if page doesn't exist on any stage, but used to be @return bool
[ "Check", "if", "page", "doesn", "t", "exist", "on", "any", "stage", "but", "used", "to", "be" ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2685-L2689
43,119
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.isOnDraft
public function isOnDraft() { $id = $this->owner->ID ?: $this->owner->OldID; if (!$id) { return false; } if (!$this->hasStages()) { return true; } $draftVersion = static::get_versionnumber_by_stage($this->owner, Versioned::DRAFT, $id); return (bool)$draftVersion; }
php
public function isOnDraft() { $id = $this->owner->ID ?: $this->owner->OldID; if (!$id) { return false; } if (!$this->hasStages()) { return true; } $draftVersion = static::get_versionnumber_by_stage($this->owner, Versioned::DRAFT, $id); return (bool)$draftVersion; }
[ "public", "function", "isOnDraft", "(", ")", "{", "$", "id", "=", "$", "this", "->", "owner", "->", "ID", "?", ":", "$", "this", "->", "owner", "->", "OldID", ";", "if", "(", "!", "$", "id", ")", "{", "return", "false", ";", "}", "if", "(", "...
Check if this record exists on the draft stage @return bool
[ "Check", "if", "this", "record", "exists", "on", "the", "draft", "stage" ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2696-L2708
43,120
silverstripe/silverstripe-versioned
src/Versioned.php
Versioned.get_version
public static function get_version($class, $id, $version) { $baseClass = DataObject::getSchema()->baseDataClass($class); $list = DataList::create($baseClass) ->setDataQueryParam([ "Versioned.mode" => 'version', "Versioned.version" => $version ]); return $list->byID($id); }
php
public static function get_version($class, $id, $version) { $baseClass = DataObject::getSchema()->baseDataClass($class); $list = DataList::create($baseClass) ->setDataQueryParam([ "Versioned.mode" => 'version', "Versioned.version" => $version ]); return $list->byID($id); }
[ "public", "static", "function", "get_version", "(", "$", "class", ",", "$", "id", ",", "$", "version", ")", "{", "$", "baseClass", "=", "DataObject", "::", "getSchema", "(", ")", "->", "baseDataClass", "(", "$", "class", ")", ";", "$", "list", "=", "...
Return the specific version of the given id. Caution: The record is retrieved as a DataObject, but saving back modifications via write() will create a new version, rather than modifying the existing one. @param string $class @param int $id @param int $version @return DataObject
[ "Return", "the", "specific", "version", "of", "the", "given", "id", "." ]
bddf25fd3a713e7ed7a861d6c6992febc3c7998b
https://github.com/silverstripe/silverstripe-versioned/blob/bddf25fd3a713e7ed7a861d6c6992febc3c7998b/src/Versioned.php#L2777-L2787
43,121
UndefinedOffset/SortableGridField
src/Forms/GridFieldSortableRows.php
GridFieldSortableRows.getManipulatedData
public function getManipulatedData(GridField $gridField, SS_List $dataList) { //Detect and correct items with a sort column value of 0 (push to bottom) $this->fixSortColumn($gridField, $dataList); $headerState = $gridField->State->GridFieldSortableHeader; $state = $gridField->State->GridFieldSortableRows; if ((!is_bool($state->sortableToggle) || $state->sortableToggle === false) && $headerState && is_string($headerState->SortColumn) && is_string($headerState->SortDirection)) { return $dataList->sort($headerState->SortColumn, $headerState->SortDirection); } if ($state->sortableToggle === true) { $gridField->getConfig()->removeComponentsByType(GridFieldFilterHeader::class); $gridField->getConfig()->removeComponentsByType(GridFieldSortableHeader::class); } return $dataList->sort($this->sortColumn); }
php
public function getManipulatedData(GridField $gridField, SS_List $dataList) { //Detect and correct items with a sort column value of 0 (push to bottom) $this->fixSortColumn($gridField, $dataList); $headerState = $gridField->State->GridFieldSortableHeader; $state = $gridField->State->GridFieldSortableRows; if ((!is_bool($state->sortableToggle) || $state->sortableToggle === false) && $headerState && is_string($headerState->SortColumn) && is_string($headerState->SortDirection)) { return $dataList->sort($headerState->SortColumn, $headerState->SortDirection); } if ($state->sortableToggle === true) { $gridField->getConfig()->removeComponentsByType(GridFieldFilterHeader::class); $gridField->getConfig()->removeComponentsByType(GridFieldSortableHeader::class); } return $dataList->sort($this->sortColumn); }
[ "public", "function", "getManipulatedData", "(", "GridField", "$", "gridField", ",", "SS_List", "$", "dataList", ")", "{", "//Detect and correct items with a sort column value of 0 (push to bottom)", "$", "this", "->", "fixSortColumn", "(", "$", "gridField", ",", "$", "...
Manipulate the datalist as needed by this grid modifier. @param GridField $gridField Grid Field Reference @param SS_List|DataList $dataList Data List to adjust @return DataList Modified Data List
[ "Manipulate", "the", "datalist", "as", "needed", "by", "this", "grid", "modifier", "." ]
af492d02675f1222197f6d1dd1d32122fb4cc1cb
https://github.com/UndefinedOffset/SortableGridField/blob/af492d02675f1222197f6d1dd1d32122fb4cc1cb/src/Forms/GridFieldSortableRows.php#L151-L169
43,122
UndefinedOffset/SortableGridField
src/Forms/GridFieldSortableRows.php
GridFieldSortableRows.handleAction
public function handleAction(GridField $gridField, $actionName, $arguments, $data) { $state = $gridField->State->GridFieldSortableRows; if (!is_bool($state->sortableToggle)) { $state->sortableToggle = false; } else if ($state->sortableToggle == true) { $gridField->getConfig()->removeComponentsByType(GridFieldFilterHeader::class); $gridField->getConfig()->removeComponentsByType(GridFieldSortableHeader::class); } if ($actionName == 'savegridrowsort') { return $this->saveGridRowSort($gridField, $data); } else if ($actionName == 'sorttopage') { return $this->sortToPage($gridField, $data); } }
php
public function handleAction(GridField $gridField, $actionName, $arguments, $data) { $state = $gridField->State->GridFieldSortableRows; if (!is_bool($state->sortableToggle)) { $state->sortableToggle = false; } else if ($state->sortableToggle == true) { $gridField->getConfig()->removeComponentsByType(GridFieldFilterHeader::class); $gridField->getConfig()->removeComponentsByType(GridFieldSortableHeader::class); } if ($actionName == 'savegridrowsort') { return $this->saveGridRowSort($gridField, $data); } else if ($actionName == 'sorttopage') { return $this->sortToPage($gridField, $data); } }
[ "public", "function", "handleAction", "(", "GridField", "$", "gridField", ",", "$", "actionName", ",", "$", "arguments", ",", "$", "data", ")", "{", "$", "state", "=", "$", "gridField", "->", "State", "->", "GridFieldSortableRows", ";", "if", "(", "!", "...
Handle an action on the given grid field. @param GridField $gridField Grid Field Reference @param String $actionName Action identifier, see {@link getActions()}. @param array $arguments Arguments relevant for this @param array $data All form data
[ "Handle", "an", "action", "on", "the", "given", "grid", "field", "." ]
af492d02675f1222197f6d1dd1d32122fb4cc1cb
https://github.com/UndefinedOffset/SortableGridField/blob/af492d02675f1222197f6d1dd1d32122fb4cc1cb/src/Forms/GridFieldSortableRows.php#L429-L445
43,123
pusher/chatkit-server-php
src/Chatkit.php
Chatkit.log
protected function log($msg) { if (is_null($this->logger) === false) { $this->logger->log('Chatkit: '.$msg); } }
php
protected function log($msg) { if (is_null($this->logger) === false) { $this->logger->log('Chatkit: '.$msg); } }
[ "protected", "function", "log", "(", "$", "msg", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "logger", ")", "===", "false", ")", "{", "$", "this", "->", "logger", "->", "log", "(", "'Chatkit: '", ".", "$", "msg", ")", ";", "}", "}" ]
Log a string. @param string $msg The message to log @return void
[ "Log", "a", "string", "." ]
13975a4d89a109c1fe3e16e4e0441bab82ec5ad1
https://github.com/pusher/chatkit-server-php/blob/13975a4d89a109c1fe3e16e4e0441bab82ec5ad1/src/Chatkit.php#L157-L162
43,124
pusher/chatkit-server-php
src/Chatkit.php
Chatkit.createRoom
public function createRoom($options) { if (!isset($options['creator_id'])) { throw new MissingArgumentException('You must provide the ID of the user creating the room'); } if (!isset($options['name'])) { throw new MissingArgumentException('You must provide a name for the room'); } $body = [ 'name' => $options['name'], 'private' => false ]; if (isset($options['private'])) { $body['private'] = $options['private']; } if (isset($options['user_ids'])) { $body['user_ids'] = $options['user_ids']; } if (isset($options['custom_data'])) { $body['custom_data'] = $options['custom_data']; } $token = $this->getServerToken([ 'user_id' => $options['creator_id'] ])['token']; return $this->apiRequest([ 'method' => 'POST', 'path' => '/rooms', 'jwt' => $token, 'body' => $body ]); }
php
public function createRoom($options) { if (!isset($options['creator_id'])) { throw new MissingArgumentException('You must provide the ID of the user creating the room'); } if (!isset($options['name'])) { throw new MissingArgumentException('You must provide a name for the room'); } $body = [ 'name' => $options['name'], 'private' => false ]; if (isset($options['private'])) { $body['private'] = $options['private']; } if (isset($options['user_ids'])) { $body['user_ids'] = $options['user_ids']; } if (isset($options['custom_data'])) { $body['custom_data'] = $options['custom_data']; } $token = $this->getServerToken([ 'user_id' => $options['creator_id'] ])['token']; return $this->apiRequest([ 'method' => 'POST', 'path' => '/rooms', 'jwt' => $token, 'body' => $body ]); }
[ "public", "function", "createRoom", "(", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'creator_id'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'You must provide the ID of the user creating the room'", ")...
Creates a new room. @param array $options The room options [Available Options] • creator_id (string|required): Represents the ID of the user that you want to create the room. • name (string|optional): Represents the name with which the room is identified. A room name must not be longer than 40 characters and can only contain lowercase letters, numbers, underscores and hyphens. • private (boolean|optional): Indicates if a room should be private or public. Private by default. • user_ids (array|optional): If you wish to add users to the room at the point of creation, you may provide their user IDs. . custom_data (assoc array|optional): If you wish to attach some custom data to a room, you may provide a list of key value pairs. @return array
[ "Creates", "a", "new", "room", "." ]
13975a4d89a109c1fe3e16e4e0441bab82ec5ad1
https://github.com/pusher/chatkit-server-php/blob/13975a4d89a109c1fe3e16e4e0441bab82ec5ad1/src/Chatkit.php#L355-L386
43,125
pusher/chatkit-server-php
src/Chatkit.php
Chatkit.deleteRoom
public function deleteRoom($options) { if (!isset($options['id'])) { throw new MissingArgumentException('You must provide the ID of the room to delete'); } $room_id = rawurlencode($options['id']); return $this->apiRequest([ 'method' => 'DELETE', 'path' => "/rooms/$room_id", 'jwt' => $this->getServerToken()['token'] ]); }
php
public function deleteRoom($options) { if (!isset($options['id'])) { throw new MissingArgumentException('You must provide the ID of the room to delete'); } $room_id = rawurlencode($options['id']); return $this->apiRequest([ 'method' => 'DELETE', 'path' => "/rooms/$room_id", 'jwt' => $this->getServerToken()['token'] ]); }
[ "public", "function", "deleteRoom", "(", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'id'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'You must provide the ID of the room to delete'", ")", ";", "}",...
Deletes a room
[ "Deletes", "a", "room" ]
13975a4d89a109c1fe3e16e4e0441bab82ec5ad1
https://github.com/pusher/chatkit-server-php/blob/13975a4d89a109c1fe3e16e4e0441bab82ec5ad1/src/Chatkit.php#L418-L431
43,126
pusher/chatkit-server-php
src/Chatkit.php
Chatkit.getRoomMessages
public function getRoomMessages($options) { if (!isset($options['room_id'])) { throw new MissingArgumentException('You must provide the ID of the room to fetch messages from'); } $query_params = []; if (!empty($options['initial_id'])) { $query_params['initial_id'] = $options['initial_id']; } if (!empty($options['limit'])) { $query_params['limit'] = $options['limit']; } if (!empty($options['direction'])) { $query_params['direction'] = $options['direction']; } $room_id = rawurlencode($options['room_id']); return $this->apiRequestV2([ 'method' => 'GET', 'path' => "/rooms/$room_id/messages", 'jwt' => $this->getServerToken()['token'], 'query' => $query_params ]); }
php
public function getRoomMessages($options) { if (!isset($options['room_id'])) { throw new MissingArgumentException('You must provide the ID of the room to fetch messages from'); } $query_params = []; if (!empty($options['initial_id'])) { $query_params['initial_id'] = $options['initial_id']; } if (!empty($options['limit'])) { $query_params['limit'] = $options['limit']; } if (!empty($options['direction'])) { $query_params['direction'] = $options['direction']; } $room_id = rawurlencode($options['room_id']); return $this->apiRequestV2([ 'method' => 'GET', 'path' => "/rooms/$room_id/messages", 'jwt' => $this->getServerToken()['token'], 'query' => $query_params ]); }
[ "public", "function", "getRoomMessages", "(", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'room_id'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'You must provide the ID of the room to fetch messages from'...
Get messages in a room @param array $options [Available Options] • room_id (string|required): Represents the ID of the room that you want to get the messages for. • initial_id (integer|optional): Starting ID of the range of messages. • limit (integer|optional): Number of messages to return • direction (string|optional): Order of messages - one of newer or older @return array @throws ChatkitException or MissingArgumentException
[ "Get", "messages", "in", "a", "room" ]
13975a4d89a109c1fe3e16e4e0441bab82ec5ad1
https://github.com/pusher/chatkit-server-php/blob/13975a4d89a109c1fe3e16e4e0441bab82ec5ad1/src/Chatkit.php#L537-L562
43,127
pusher/chatkit-server-php
src/Chatkit.php
Chatkit.getReadCursorsForUser
public function getReadCursorsForUser($options) { if (!isset($options['user_id'])) { throw new MissingArgumentException('You must provide the ID of the user that you want the read cursors for'); } $user_id = rawurlencode($options['user_id']); return $this->cursorsRequest([ 'method' => 'GET', 'path' => "/cursors/0/users/$user_id", 'jwt' => $this->getServerToken()['token'] ]); }
php
public function getReadCursorsForUser($options) { if (!isset($options['user_id'])) { throw new MissingArgumentException('You must provide the ID of the user that you want the read cursors for'); } $user_id = rawurlencode($options['user_id']); return $this->cursorsRequest([ 'method' => 'GET', 'path' => "/cursors/0/users/$user_id", 'jwt' => $this->getServerToken()['token'] ]); }
[ "public", "function", "getReadCursorsForUser", "(", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'user_id'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'You must provide the ID of the user that you want the...
Get all read cursors for a user @param array $options [Available Options] • user_id (string|required): Represents the ID of the user that you want to get the read cursors for. @return array @throws ChatkitException or MissingArgumentException
[ "Get", "all", "read", "cursors", "for", "a", "user" ]
13975a4d89a109c1fe3e16e4e0441bab82ec5ad1
https://github.com/pusher/chatkit-server-php/blob/13975a4d89a109c1fe3e16e4e0441bab82ec5ad1/src/Chatkit.php#L867-L880
43,128
pusher/chatkit-server-php
src/Chatkit.php
Chatkit.getReadCursorsForRoom
public function getReadCursorsForRoom($options) { if (!isset($options['room_id'])) { throw new MissingArgumentException('You must provide the ID of the room that you want the read cursors for'); } $room_id = rawurlencode($options['room_id']); return $this->cursorsRequest([ 'method' => 'GET', 'path' => "/cursors/0/rooms/$room_id", 'jwt' => $this->getServerToken()['token'] ]); }
php
public function getReadCursorsForRoom($options) { if (!isset($options['room_id'])) { throw new MissingArgumentException('You must provide the ID of the room that you want the read cursors for'); } $room_id = rawurlencode($options['room_id']); return $this->cursorsRequest([ 'method' => 'GET', 'path' => "/cursors/0/rooms/$room_id", 'jwt' => $this->getServerToken()['token'] ]); }
[ "public", "function", "getReadCursorsForRoom", "(", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'room_id'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'You must provide the ID of the room that you want the...
Get all read cursors for a room @param array $options [Available Options] • room_id (string|required): Represents the ID of the room that you want to get the read cursors for. @return array @throws ChatkitException or MissingArgumentException
[ "Get", "all", "read", "cursors", "for", "a", "room" ]
13975a4d89a109c1fe3e16e4e0441bab82ec5ad1
https://github.com/pusher/chatkit-server-php/blob/13975a4d89a109c1fe3e16e4e0441bab82ec5ad1/src/Chatkit.php#L891-L904
43,129
pusher/chatkit-server-php
src/Chatkit.php
Chatkit.createCurl
protected function createCurl($service_settings, $path, $jwt, $request_method, $body = null, $query_params = array()) { $split_instance_locator = explode(':', $this->settings['instance_locator']); $scheme = 'https'; $host = $split_instance_locator[1].'.pusherplatform.io'; $service_path_fragment = $service_settings['service_name'].'/'.$service_settings['service_version']; $instance_id = $split_instance_locator[2]; $full_url = $scheme.'://'.$host.'/services/'.$service_path_fragment.'/'.$instance_id.$path; $query = http_build_query($query_params); // Passing foo = [1, 2, 3] to query params will encode it as foo[0]=1&foo[1]=2 // however, we want foo=1&foo=2 (to treat them as an array) $query_string = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $query); $final_url = $full_url.'?'.$query_string; $this->log('INFO: createCurl( '.$final_url.' )'); return $this->createRawCurl($request_method, $final_url, $body, null, $jwt, true); }
php
protected function createCurl($service_settings, $path, $jwt, $request_method, $body = null, $query_params = array()) { $split_instance_locator = explode(':', $this->settings['instance_locator']); $scheme = 'https'; $host = $split_instance_locator[1].'.pusherplatform.io'; $service_path_fragment = $service_settings['service_name'].'/'.$service_settings['service_version']; $instance_id = $split_instance_locator[2]; $full_url = $scheme.'://'.$host.'/services/'.$service_path_fragment.'/'.$instance_id.$path; $query = http_build_query($query_params); // Passing foo = [1, 2, 3] to query params will encode it as foo[0]=1&foo[1]=2 // however, we want foo=1&foo=2 (to treat them as an array) $query_string = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $query); $final_url = $full_url.'?'.$query_string; $this->log('INFO: createCurl( '.$final_url.' )'); return $this->createRawCurl($request_method, $final_url, $body, null, $jwt, true); }
[ "protected", "function", "createCurl", "(", "$", "service_settings", ",", "$", "path", ",", "$", "jwt", ",", "$", "request_method", ",", "$", "body", "=", "null", ",", "$", "query_params", "=", "array", "(", ")", ")", "{", "$", "split_instance_locator", ...
Utility function used to create the curl object setup to interact with the Pusher API
[ "Utility", "function", "used", "to", "create", "the", "curl", "object", "setup", "to", "interact", "with", "the", "Pusher", "API" ]
13975a4d89a109c1fe3e16e4e0441bab82ec5ad1
https://github.com/pusher/chatkit-server-php/blob/13975a4d89a109c1fe3e16e4e0441bab82ec5ad1/src/Chatkit.php#L1148-L1167
43,130
pusher/chatkit-server-php
src/Chatkit.php
Chatkit.createRawCurl
protected function createRawCurl($request_method, $url, $body = null, $content_type = null, $jwt = null, $encode_json = false) { // Create or reuse existing curl handle if (null === $this->ch) { $this->ch = curl_init(); } if ($this->ch === false) { throw new ConfigurationException('Could not initialise cURL!'); } $ch = $this->ch; // curl handle is not reusable unless reset if (function_exists('curl_reset')) { curl_reset($ch); } $headers = array(); if(!is_null($jwt)) { array_push($headers, 'Authorization: Bearer '.$jwt); } if(!is_null($content_type)) { array_push($headers, 'Content-Type: '.$content_type); } // Set cURL opts and execute request curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $this->settings['timeout']); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request_method); if (!is_null($body)) { if ($encode_json) { $body = json_encode($body, JSON_ERROR_UTF8); array_push($headers, 'Content-Type: application/json'); } curl_setopt($ch, CURLOPT_POSTFIELDS, $body); array_push($headers, 'Content-Length: '.strlen($body)); } curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Set custom curl options if (!empty($this->settings['curl_options'])) { foreach ($this->settings['curl_options'] as $option => $value) { curl_setopt($ch, $option, $value); } } return $ch; }
php
protected function createRawCurl($request_method, $url, $body = null, $content_type = null, $jwt = null, $encode_json = false) { // Create or reuse existing curl handle if (null === $this->ch) { $this->ch = curl_init(); } if ($this->ch === false) { throw new ConfigurationException('Could not initialise cURL!'); } $ch = $this->ch; // curl handle is not reusable unless reset if (function_exists('curl_reset')) { curl_reset($ch); } $headers = array(); if(!is_null($jwt)) { array_push($headers, 'Authorization: Bearer '.$jwt); } if(!is_null($content_type)) { array_push($headers, 'Content-Type: '.$content_type); } // Set cURL opts and execute request curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $this->settings['timeout']); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request_method); if (!is_null($body)) { if ($encode_json) { $body = json_encode($body, JSON_ERROR_UTF8); array_push($headers, 'Content-Type: application/json'); } curl_setopt($ch, CURLOPT_POSTFIELDS, $body); array_push($headers, 'Content-Length: '.strlen($body)); } curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Set custom curl options if (!empty($this->settings['curl_options'])) { foreach ($this->settings['curl_options'] as $option => $value) { curl_setopt($ch, $option, $value); } } return $ch; }
[ "protected", "function", "createRawCurl", "(", "$", "request_method", ",", "$", "url", ",", "$", "body", "=", "null", ",", "$", "content_type", "=", "null", ",", "$", "jwt", "=", "null", ",", "$", "encode_json", "=", "false", ")", "{", "// Create or reus...
Utility function used to create the curl object with common settings.
[ "Utility", "function", "used", "to", "create", "the", "curl", "object", "with", "common", "settings", "." ]
13975a4d89a109c1fe3e16e4e0441bab82ec5ad1
https://github.com/pusher/chatkit-server-php/blob/13975a4d89a109c1fe3e16e4e0441bab82ec5ad1/src/Chatkit.php#L1172-L1222
43,131
pusher/chatkit-server-php
src/Chatkit.php
Chatkit.execCurl
protected function execCurl($ch) { $headers = []; $response = []; curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$headers) { $len = strlen($header); $header = explode(':', $header, 2); if (count($header) < 2) { return $len; } $name = strtolower(trim($header[0])); if (!array_key_exists($name, $headers)) { $headers[$name] = [trim($header[1])]; } else { $headers[$name][] = trim($header[1]); } return $len; } ); $data = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); $body = empty($data) ? null : json_decode($data, true); $response = [ 'status' => $status, 'headers' => $headers, 'body' => $body ]; // inform the user of a connection failure if ($status == 0 || $response['body'] === false) { throw new ConnectionException(curl_error($ch)); } // or an error response from Chatkit if ($status >= 400) { $this->log('ERROR: execCurl error: '.print_r($response, true)); throw (new ChatkitException($response['body']['error_description'], $status))->setBody($response['body']); } $this->log('INFO: execCurl response: '.print_r($response, true)); return $response; }
php
protected function execCurl($ch) { $headers = []; $response = []; curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$headers) { $len = strlen($header); $header = explode(':', $header, 2); if (count($header) < 2) { return $len; } $name = strtolower(trim($header[0])); if (!array_key_exists($name, $headers)) { $headers[$name] = [trim($header[1])]; } else { $headers[$name][] = trim($header[1]); } return $len; } ); $data = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); $body = empty($data) ? null : json_decode($data, true); $response = [ 'status' => $status, 'headers' => $headers, 'body' => $body ]; // inform the user of a connection failure if ($status == 0 || $response['body'] === false) { throw new ConnectionException(curl_error($ch)); } // or an error response from Chatkit if ($status >= 400) { $this->log('ERROR: execCurl error: '.print_r($response, true)); throw (new ChatkitException($response['body']['error_description'], $status))->setBody($response['body']); } $this->log('INFO: execCurl response: '.print_r($response, true)); return $response; }
[ "protected", "function", "execCurl", "(", "$", "ch", ")", "{", "$", "headers", "=", "[", "]", ";", "$", "response", "=", "[", "]", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HEADERFUNCTION", ",", "function", "(", "$", "curl", ",", "$", "header...
Utility function to execute curl and create capture response information.
[ "Utility", "function", "to", "execute", "curl", "and", "create", "capture", "response", "information", "." ]
13975a4d89a109c1fe3e16e4e0441bab82ec5ad1
https://github.com/pusher/chatkit-server-php/blob/13975a4d89a109c1fe3e16e4e0441bab82ec5ad1/src/Chatkit.php#L1236-L1284
43,132
guzzle/command
src/ServiceClient.php
ServiceClient.createCommandHandler
private function createCommandHandler() { return function (CommandInterface $command) { return Promise\coroutine(function () use ($command) { // Prepare the HTTP options. $opts = $command['@http'] ?: []; unset($command['@http']); try { // Prepare the request from the command and send it. $request = $this->transformCommandToRequest($command); $promise = $this->httpClient->sendAsync($request, $opts); // Create a result from the response. $response = (yield $promise); yield $this->transformResponseToResult($response, $request, $command); } catch (\Exception $e) { throw CommandException::fromPrevious($command, $e); } }); }; }
php
private function createCommandHandler() { return function (CommandInterface $command) { return Promise\coroutine(function () use ($command) { // Prepare the HTTP options. $opts = $command['@http'] ?: []; unset($command['@http']); try { // Prepare the request from the command and send it. $request = $this->transformCommandToRequest($command); $promise = $this->httpClient->sendAsync($request, $opts); // Create a result from the response. $response = (yield $promise); yield $this->transformResponseToResult($response, $request, $command); } catch (\Exception $e) { throw CommandException::fromPrevious($command, $e); } }); }; }
[ "private", "function", "createCommandHandler", "(", ")", "{", "return", "function", "(", "CommandInterface", "$", "command", ")", "{", "return", "Promise", "\\", "coroutine", "(", "function", "(", ")", "use", "(", "$", "command", ")", "{", "// Prepare the HTTP...
Defines the main handler for commands that uses the HTTP client. @return callable
[ "Defines", "the", "main", "handler", "for", "commands", "that", "uses", "the", "HTTP", "client", "." ]
03f4ad0724fc8d15b48459c1388c8c68ed338c3f
https://github.com/guzzle/command/blob/03f4ad0724fc8d15b48459c1388c8c68ed338c3f/src/ServiceClient.php#L162-L183
43,133
guzzle/command
src/ServiceClient.php
ServiceClient.transformResponseToResult
private function transformResponseToResult( ResponseInterface $response, RequestInterface $request, CommandInterface $command ) { $transform = $this->responseToResultTransformer; return $transform($response, $request, $command); }
php
private function transformResponseToResult( ResponseInterface $response, RequestInterface $request, CommandInterface $command ) { $transform = $this->responseToResultTransformer; return $transform($response, $request, $command); }
[ "private", "function", "transformResponseToResult", "(", "ResponseInterface", "$", "response", ",", "RequestInterface", "$", "request", ",", "CommandInterface", "$", "command", ")", "{", "$", "transform", "=", "$", "this", "->", "responseToResultTransformer", ";", "...
Transforms a Response object, also using data from the Request object, into a Result object. @param ResponseInterface $response @param RequestInterface $request @param CommandInterface $command @return ResultInterface
[ "Transforms", "a", "Response", "object", "also", "using", "data", "from", "the", "Request", "object", "into", "a", "Result", "object", "." ]
03f4ad0724fc8d15b48459c1388c8c68ed338c3f
https://github.com/guzzle/command/blob/03f4ad0724fc8d15b48459c1388c8c68ed338c3f/src/ServiceClient.php#L208-L216
43,134
wp-cli/checksum-command
src/Checksum_Base_Command.php
Checksum_Base_Command._read
protected static function _read( $url ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore -- Could be used in classes extending this class. $headers = array( 'Accept' => 'application/json' ); $response = Utils\http_request( 'GET', $url, null, $headers, array( 'timeout' => 30 ) ); if ( 200 === $response->status_code ) { return $response->body; } WP_CLI::error( "Couldn't fetch response from {$url} (HTTP code {$response->status_code})." ); }
php
protected static function _read( $url ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore -- Could be used in classes extending this class. $headers = array( 'Accept' => 'application/json' ); $response = Utils\http_request( 'GET', $url, null, $headers, array( 'timeout' => 30 ) ); if ( 200 === $response->status_code ) { return $response->body; } WP_CLI::error( "Couldn't fetch response from {$url} (HTTP code {$response->status_code})." ); }
[ "protected", "static", "function", "_read", "(", "$", "url", ")", "{", "// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore -- Could be used in classes extending this class.", "$", "headers", "=", "array", "(", "'Accept'", "=>", "'application/json'", ")", ";", "$", "r...
Read a remote file and return its contents. @param string $url URL of the remote file to read. @return mixed
[ "Read", "a", "remote", "file", "and", "return", "its", "contents", "." ]
7db66668ec116c5ccef7bc27b4354fa81b85018a
https://github.com/wp-cli/checksum-command/blob/7db66668ec116c5ccef7bc27b4354fa81b85018a/src/Checksum_Base_Command.php#L30-L43
43,135
wp-cli/checksum-command
src/Checksum_Base_Command.php
Checksum_Base_Command.get_files
protected function get_files( $path ) { $filtered_files = array(); try { $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $path, RecursiveDirectoryIterator::SKIP_DOTS ), RecursiveIteratorIterator::CHILD_FIRST ); foreach ( $files as $file_info ) { $pathname = self::normalize_directory_separators( substr( $file_info->getPathname(), strlen( $path ) ) ); if ( $file_info->isFile() && $this->filter_file( $pathname ) ) { $filtered_files[] = $pathname; } } } catch ( Exception $e ) { WP_CLI::error( $e->getMessage() ); } return $filtered_files; }
php
protected function get_files( $path ) { $filtered_files = array(); try { $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $path, RecursiveDirectoryIterator::SKIP_DOTS ), RecursiveIteratorIterator::CHILD_FIRST ); foreach ( $files as $file_info ) { $pathname = self::normalize_directory_separators( substr( $file_info->getPathname(), strlen( $path ) ) ); if ( $file_info->isFile() && $this->filter_file( $pathname ) ) { $filtered_files[] = $pathname; } } } catch ( Exception $e ) { WP_CLI::error( $e->getMessage() ); } return $filtered_files; }
[ "protected", "function", "get_files", "(", "$", "path", ")", "{", "$", "filtered_files", "=", "array", "(", ")", ";", "try", "{", "$", "files", "=", "new", "RecursiveIteratorIterator", "(", "new", "RecursiveDirectoryIterator", "(", "$", "path", ",", "Recursi...
Recursively get the list of files for a given path. @param string $path Root path to start the recursive traversal in. @return array<string>
[ "Recursively", "get", "the", "list", "of", "files", "for", "a", "given", "path", "." ]
7db66668ec116c5ccef7bc27b4354fa81b85018a
https://github.com/wp-cli/checksum-command/blob/7db66668ec116c5ccef7bc27b4354fa81b85018a/src/Checksum_Base_Command.php#L52-L73
43,136
wp-cli/checksum-command
src/Checksum_Plugin_Command.php
Checksum_Plugin_Command.add_error
private function add_error( $plugin_name, $file, $message ) { $error['plugin_name'] = $plugin_name; $error['file'] = $file; $error['message'] = $message; $this->errors[] = $error; }
php
private function add_error( $plugin_name, $file, $message ) { $error['plugin_name'] = $plugin_name; $error['file'] = $file; $error['message'] = $message; $this->errors[] = $error; }
[ "private", "function", "add_error", "(", "$", "plugin_name", ",", "$", "file", ",", "$", "message", ")", "{", "$", "error", "[", "'plugin_name'", "]", "=", "$", "plugin_name", ";", "$", "error", "[", "'file'", "]", "=", "$", "file", ";", "$", "error"...
Adds a new error to the array of detected errors. @param string $plugin_name Name of the plugin that had the error. @param string $file Relative path to the file that had the error. @param string $message Message explaining the error.
[ "Adds", "a", "new", "error", "to", "the", "array", "of", "detected", "errors", "." ]
7db66668ec116c5ccef7bc27b4354fa81b85018a
https://github.com/wp-cli/checksum-command/blob/7db66668ec116c5ccef7bc27b4354fa81b85018a/src/Checksum_Plugin_Command.php#L156-L161
43,137
wp-cli/checksum-command
src/Checksum_Plugin_Command.php
Checksum_Plugin_Command.get_plugin_version
private function get_plugin_version( $path ) { if ( ! isset( $this->plugins_data ) ) { $this->plugins_data = get_plugins(); } if ( ! array_key_exists( $path, $this->plugins_data ) ) { return false; } return $this->plugins_data[ $path ]['Version']; }
php
private function get_plugin_version( $path ) { if ( ! isset( $this->plugins_data ) ) { $this->plugins_data = get_plugins(); } if ( ! array_key_exists( $path, $this->plugins_data ) ) { return false; } return $this->plugins_data[ $path ]['Version']; }
[ "private", "function", "get_plugin_version", "(", "$", "path", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "plugins_data", ")", ")", "{", "$", "this", "->", "plugins_data", "=", "get_plugins", "(", ")", ";", "}", "if", "(", "!", "array...
Gets the currently installed version for a given plugin. @param string $path Relative path to plugin file to get the version for. @return string|false Installed version of the plugin, or false if not found.
[ "Gets", "the", "currently", "installed", "version", "for", "a", "given", "plugin", "." ]
7db66668ec116c5ccef7bc27b4354fa81b85018a
https://github.com/wp-cli/checksum-command/blob/7db66668ec116c5ccef7bc27b4354fa81b85018a/src/Checksum_Plugin_Command.php#L171-L181
43,138
wp-cli/checksum-command
src/Checksum_Plugin_Command.php
Checksum_Plugin_Command.get_plugin_checksums
private function get_plugin_checksums( $plugin, $version ) { $url = str_replace( array( '{slug}', '{version}', ), array( $plugin, $version, ), $this->url_template ); $options = array( 'timeout' => 30, ); $headers = array( 'Accept' => 'application/json', ); $response = Utils\http_request( 'GET', $url, null, $headers, $options ); if ( ! $response->success || 200 !== $response->status_code ) { return false; } $body = trim( $response->body ); $body = json_decode( $body, true ); if ( ! is_array( $body ) || ! isset( $body['files'] ) || ! is_array( $body['files'] ) ) { return false; } return $body['files']; }
php
private function get_plugin_checksums( $plugin, $version ) { $url = str_replace( array( '{slug}', '{version}', ), array( $plugin, $version, ), $this->url_template ); $options = array( 'timeout' => 30, ); $headers = array( 'Accept' => 'application/json', ); $response = Utils\http_request( 'GET', $url, null, $headers, $options ); if ( ! $response->success || 200 !== $response->status_code ) { return false; } $body = trim( $response->body ); $body = json_decode( $body, true ); if ( ! is_array( $body ) || ! isset( $body['files'] ) || ! is_array( $body['files'] ) ) { return false; } return $body['files']; }
[ "private", "function", "get_plugin_checksums", "(", "$", "plugin", ",", "$", "version", ")", "{", "$", "url", "=", "str_replace", "(", "array", "(", "'{slug}'", ",", "'{version}'", ",", ")", ",", "array", "(", "$", "plugin", ",", "$", "version", ",", "...
Gets the checksums for the given version of plugin. @param string $version Version string to query. @param string $plugin plugin string to query. @return bool|array False on failure. An array of checksums on success.
[ "Gets", "the", "checksums", "for", "the", "given", "version", "of", "plugin", "." ]
7db66668ec116c5ccef7bc27b4354fa81b85018a
https://github.com/wp-cli/checksum-command/blob/7db66668ec116c5ccef7bc27b4354fa81b85018a/src/Checksum_Plugin_Command.php#L191-L225
43,139
wp-cli/checksum-command
src/Checksum_Plugin_Command.php
Checksum_Plugin_Command.get_all_plugin_names
private function get_all_plugin_names() { $names = array(); foreach ( get_plugins() as $file => $details ) { $names[] = Utils\get_plugin_name( $file ); } return $names; }
php
private function get_all_plugin_names() { $names = array(); foreach ( get_plugins() as $file => $details ) { $names[] = Utils\get_plugin_name( $file ); } return $names; }
[ "private", "function", "get_all_plugin_names", "(", ")", "{", "$", "names", "=", "array", "(", ")", ";", "foreach", "(", "get_plugins", "(", ")", "as", "$", "file", "=>", "$", "details", ")", "{", "$", "names", "[", "]", "=", "Utils", "\\", "get_plug...
Gets the names of all installed plugins. @return array<string> Names of all installed plugins.
[ "Gets", "the", "names", "of", "all", "installed", "plugins", "." ]
7db66668ec116c5ccef7bc27b4354fa81b85018a
https://github.com/wp-cli/checksum-command/blob/7db66668ec116c5ccef7bc27b4354fa81b85018a/src/Checksum_Plugin_Command.php#L232-L239
43,140
wp-cli/checksum-command
src/Checksum_Plugin_Command.php
Checksum_Plugin_Command.get_plugin_files
private function get_plugin_files( $path ) { $folder = dirname( $this->get_absolute_path( $path ) ); // Return single file plugins immediately, to avoid iterating over the // entire plugins folder. if ( WP_PLUGIN_DIR === $folder ) { return (array) $path; } return $this->get_files( trailingslashit( $folder ) ); }
php
private function get_plugin_files( $path ) { $folder = dirname( $this->get_absolute_path( $path ) ); // Return single file plugins immediately, to avoid iterating over the // entire plugins folder. if ( WP_PLUGIN_DIR === $folder ) { return (array) $path; } return $this->get_files( trailingslashit( $folder ) ); }
[ "private", "function", "get_plugin_files", "(", "$", "path", ")", "{", "$", "folder", "=", "dirname", "(", "$", "this", "->", "get_absolute_path", "(", "$", "path", ")", ")", ";", "// Return single file plugins immediately, to avoid iterating over the", "// entire plu...
Gets the list of files that are part of the given plugin. @param string $path Relative path to the main plugin file. @return array<string> Array of files with their relative paths.
[ "Gets", "the", "list", "of", "files", "that", "are", "part", "of", "the", "given", "plugin", "." ]
7db66668ec116c5ccef7bc27b4354fa81b85018a
https://github.com/wp-cli/checksum-command/blob/7db66668ec116c5ccef7bc27b4354fa81b85018a/src/Checksum_Plugin_Command.php#L248-L258
43,141
wp-cli/checksum-command
src/Checksum_Plugin_Command.php
Checksum_Plugin_Command.check_file_checksum
private function check_file_checksum( $path, $checksums ) { if ( $this->supports_sha256() && array_key_exists( 'sha256', $checksums ) ) { $sha256 = $this->get_sha256( $this->get_absolute_path( $path ) ); return in_array( $sha256, (array) $checksums['sha256'], true ); } if ( ! array_key_exists( 'md5', $checksums ) ) { return 'No matching checksum algorithm found'; } $md5 = $this->get_md5( $this->get_absolute_path( $path ) ); return in_array( $md5, (array) $checksums['md5'], true ); }
php
private function check_file_checksum( $path, $checksums ) { if ( $this->supports_sha256() && array_key_exists( 'sha256', $checksums ) ) { $sha256 = $this->get_sha256( $this->get_absolute_path( $path ) ); return in_array( $sha256, (array) $checksums['sha256'], true ); } if ( ! array_key_exists( 'md5', $checksums ) ) { return 'No matching checksum algorithm found'; } $md5 = $this->get_md5( $this->get_absolute_path( $path ) ); return in_array( $md5, (array) $checksums['md5'], true ); }
[ "private", "function", "check_file_checksum", "(", "$", "path", ",", "$", "checksums", ")", "{", "if", "(", "$", "this", "->", "supports_sha256", "(", ")", "&&", "array_key_exists", "(", "'sha256'", ",", "$", "checksums", ")", ")", "{", "$", "sha256", "=...
Checks the integrity of a single plugin file by comparing it to the officially provided checksum. @param string $path Relative path to the plugin file to check the integrity of. @param array $checksums Array of provided checksums to compare against. @return true|string
[ "Checks", "the", "integrity", "of", "a", "single", "plugin", "file", "by", "comparing", "it", "to", "the", "officially", "provided", "checksum", "." ]
7db66668ec116c5ccef7bc27b4354fa81b85018a
https://github.com/wp-cli/checksum-command/blob/7db66668ec116c5ccef7bc27b4354fa81b85018a/src/Checksum_Plugin_Command.php#L270-L286
43,142
checkout/checkout-magento2-plugin
Model/Validator/Rule.php
Rule.getErrorMessage
public function getErrorMessage() { if($this->errorMessage) { return $this->errorMessage; } return sprintf(self::$defaultErrorMessagePattern, $this->getName()); }
php
public function getErrorMessage() { if($this->errorMessage) { return $this->errorMessage; } return sprintf(self::$defaultErrorMessagePattern, $this->getName()); }
[ "public", "function", "getErrorMessage", "(", ")", "{", "if", "(", "$", "this", "->", "errorMessage", ")", "{", "return", "$", "this", "->", "errorMessage", ";", "}", "return", "sprintf", "(", "self", "::", "$", "defaultErrorMessagePattern", ",", "$", "thi...
Returns error message. If the error message has not been defined in the object constructor the default message will be returned. @return string
[ "Returns", "error", "message", ".", "If", "the", "error", "message", "has", "not", "been", "defined", "in", "the", "object", "constructor", "the", "default", "message", "will", "be", "returned", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Validator/Rule.php#L70-L76
43,143
checkout/checkout-magento2-plugin
Observer/DataAssignObserver.php
DataAssignObserver.execute
public function execute(Observer $observer) { $data = $this->readDataArgument($observer); $additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA); if (!is_array($additionalData)) { return; } $paymentInfo = $this->readPaymentModelArgument($observer); foreach (self::$additionalInformationList as $additionalInformationKey) { if( array_key_exists($additionalInformationKey, $additionalData) ) { $paymentInfo->setAdditionalInformation($additionalInformationKey, $additionalData[$additionalInformationKey]); } } }
php
public function execute(Observer $observer) { $data = $this->readDataArgument($observer); $additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA); if (!is_array($additionalData)) { return; } $paymentInfo = $this->readPaymentModelArgument($observer); foreach (self::$additionalInformationList as $additionalInformationKey) { if( array_key_exists($additionalInformationKey, $additionalData) ) { $paymentInfo->setAdditionalInformation($additionalInformationKey, $additionalData[$additionalInformationKey]); } } }
[ "public", "function", "execute", "(", "Observer", "$", "observer", ")", "{", "$", "data", "=", "$", "this", "->", "readDataArgument", "(", "$", "observer", ")", ";", "$", "additionalData", "=", "$", "data", "->", "getData", "(", "PaymentInterface", "::", ...
Handles the observer for payment. @param Observer $observer @return void
[ "Handles", "the", "observer", "for", "payment", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Observer/DataAssignObserver.php#L34-L49
43,144
checkout/checkout-magento2-plugin
Block/Adminhtml/System/Config/Fieldset/Logo.php
Logo.render
public function render(AbstractElement $element) { $pattern = '<div id="checkout_com_adminhtml_logo"><a href="%s" target="_blank"><img src="%s" alt="Checkout.com Logo"></a></div>'; $url = 'https://checkout.com'; $src = 'https://cdn.checkout.com/img/checkout-logo-online-payments.jpg'; return sprintf($pattern, $url, $src); }
php
public function render(AbstractElement $element) { $pattern = '<div id="checkout_com_adminhtml_logo"><a href="%s" target="_blank"><img src="%s" alt="Checkout.com Logo"></a></div>'; $url = 'https://checkout.com'; $src = 'https://cdn.checkout.com/img/checkout-logo-online-payments.jpg'; return sprintf($pattern, $url, $src); }
[ "public", "function", "render", "(", "AbstractElement", "$", "element", ")", "{", "$", "pattern", "=", "'<div id=\"checkout_com_adminhtml_logo\"><a href=\"%s\" target=\"_blank\"><img src=\"%s\" alt=\"Checkout.com Logo\"></a></div>'", ";", "$", "url", "=", "'https://checkout.com'", ...
Renders form element as HTML @param AbstractElement $element @return string
[ "Renders", "form", "element", "as", "HTML" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Adminhtml/System/Config/Fieldset/Logo.php#L25-L31
43,145
checkout/checkout-magento2-plugin
Block/Adminhtml/System/Config/Field/AbstractCallbackUrl.php
AbstractCallbackUrl._getElementHtml
protected function _getElementHtml(AbstractElement $element) { $callbackUrl= $this->getBaseUrl() . 'checkout_com/' . $this->getControllerUrl(); $element->setData('value', $callbackUrl); $element->setReadonly('readonly'); return $element->getElementHtml(); }
php
protected function _getElementHtml(AbstractElement $element) { $callbackUrl= $this->getBaseUrl() . 'checkout_com/' . $this->getControllerUrl(); $element->setData('value', $callbackUrl); $element->setReadonly('readonly'); return $element->getElementHtml(); }
[ "protected", "function", "_getElementHtml", "(", "AbstractElement", "$", "element", ")", "{", "$", "callbackUrl", "=", "$", "this", "->", "getBaseUrl", "(", ")", ".", "'checkout_com/'", ".", "$", "this", "->", "getControllerUrl", "(", ")", ";", "$", "element...
Overridden method for rendering a field. In this case the field must be only for read. @param AbstractElement $element @return string
[ "Overridden", "method", "for", "rendering", "a", "field", ".", "In", "this", "case", "the", "field", "must", "be", "only", "for", "read", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Adminhtml/System/Config/Field/AbstractCallbackUrl.php#L24-L31
43,146
checkout/checkout-magento2-plugin
Gateway/Response/VaultDetailsHandler.php
VaultDetailsHandler.getExtensionAttributes
private function getExtensionAttributes(InfoInterface $payment) { $extensionAttributes = $payment->getExtensionAttributes(); if (null === $extensionAttributes) { $extensionAttributes = $this->paymentExtensionFactory->create(); $payment->setExtensionAttributes($extensionAttributes); } return $extensionAttributes; }
php
private function getExtensionAttributes(InfoInterface $payment) { $extensionAttributes = $payment->getExtensionAttributes(); if (null === $extensionAttributes) { $extensionAttributes = $this->paymentExtensionFactory->create(); $payment->setExtensionAttributes($extensionAttributes); } return $extensionAttributes; }
[ "private", "function", "getExtensionAttributes", "(", "InfoInterface", "$", "payment", ")", "{", "$", "extensionAttributes", "=", "$", "payment", "->", "getExtensionAttributes", "(", ")", ";", "if", "(", "null", "===", "$", "extensionAttributes", ")", "{", "$", ...
Get payment extension attributes @param InfoInterface $payment @return OrderPaymentExtensionInterface
[ "Get", "payment", "extension", "attributes" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Response/VaultDetailsHandler.php#L88-L97
43,147
checkout/checkout-magento2-plugin
Block/Adminhtml/Plan/Edit/Form.php
Form._getSaveSplitButtonOptions
protected function _getSaveSplitButtonOptions() { $options = []; $options[] = [ 'id' => 'edit-button', 'label' => __('Save & Edit'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndContinueEdit', 'target' => '[data-form=edit-product]'], ], ], 'default' => true, //'onclick'=>'setLocation("ACTION CONTROLLER")', ]; $options[] = [ 'id' => 'new-button', 'label' => __('Save & New'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndNew', 'target' => '[data-form=edit-product]'], ], ], ]; $options[] = [ 'id' => 'duplicate-button', 'label' => __('Save & Duplicate'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndDuplicate', 'target' => '[data-form=edit-product]'], ], ], ]; $options[] = [ 'id' => 'close-button', 'label' => __('Save & Close'), 'data_attribute' => [ 'mage-init' => ['button' => ['event' => 'save', 'target' => '[data-form=edit-product]']], ], ]; return $options; }
php
protected function _getSaveSplitButtonOptions() { $options = []; $options[] = [ 'id' => 'edit-button', 'label' => __('Save & Edit'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndContinueEdit', 'target' => '[data-form=edit-product]'], ], ], 'default' => true, //'onclick'=>'setLocation("ACTION CONTROLLER")', ]; $options[] = [ 'id' => 'new-button', 'label' => __('Save & New'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndNew', 'target' => '[data-form=edit-product]'], ], ], ]; $options[] = [ 'id' => 'duplicate-button', 'label' => __('Save & Duplicate'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndDuplicate', 'target' => '[data-form=edit-product]'], ], ], ]; $options[] = [ 'id' => 'close-button', 'label' => __('Save & Close'), 'data_attribute' => [ 'mage-init' => ['button' => ['event' => 'save', 'target' => '[data-form=edit-product]']], ], ]; return $options; }
[ "protected", "function", "_getSaveSplitButtonOptions", "(", ")", "{", "$", "options", "=", "[", "]", ";", "$", "options", "[", "]", "=", "[", "'id'", "=>", "'edit-button'", ",", "'label'", "=>", "__", "(", "'Save & Edit'", ")", ",", "'data_attribute'", "=>...
Get dropdown options for save split button @return array
[ "Get", "dropdown", "options", "for", "save", "split", "button" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Adminhtml/Plan/Edit/Form.php#L307-L351
43,148
checkout/checkout-magento2-plugin
Model/Adminhtml/Source/ApplePayButton.php
ApplePayButton.toOptionArray
public function toOptionArray() { return [ [ 'value' => self::BUTTON_BLACK, 'label' => __('Black') ], [ 'value' => self::BUTTON_WHITE, 'label' => __('White') ], [ 'value' => self::BUTTON_WHITE_LINE, 'label' => __('White with line') ], ]; }
php
public function toOptionArray() { return [ [ 'value' => self::BUTTON_BLACK, 'label' => __('Black') ], [ 'value' => self::BUTTON_WHITE, 'label' => __('White') ], [ 'value' => self::BUTTON_WHITE_LINE, 'label' => __('White with line') ], ]; }
[ "public", "function", "toOptionArray", "(", ")", "{", "return", "[", "[", "'value'", "=>", "self", "::", "BUTTON_BLACK", ",", "'label'", "=>", "__", "(", "'Black'", ")", "]", ",", "[", "'value'", "=>", "self", "::", "BUTTON_WHITE", ",", "'label'", "=>", ...
Possible Apple Pay button styles @return array
[ "Possible", "Apple", "Pay", "button", "styles" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adminhtml/Source/ApplePayButton.php#L26-L41
43,149
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getIntegrationLanguage
public function getIntegrationLanguage() { // Get and format the user language $userLanguage = $this->localeResolver->getLocale(); $userLanguage = strtoupper(str_replace('_', '-', $userLanguage)); // Get and format the supported languages $supportedLanguages = []; foreach (self::getSupportedLanguages() as $arr) { $supportedLanguages[] = $arr['value']; } // Get the fallback language $fallbackLanguage = $this->getValue( self::KEY_FALLBACK_LANGUAGE, $this->storeManager->getStore() ); // Compare user language with supported if (in_array($userLanguage, $supportedLanguages)) { return $userLanguage; } else { return ($fallbackLanguage) ? $fallbackLanguage : 'EN-EN'; } }
php
public function getIntegrationLanguage() { // Get and format the user language $userLanguage = $this->localeResolver->getLocale(); $userLanguage = strtoupper(str_replace('_', '-', $userLanguage)); // Get and format the supported languages $supportedLanguages = []; foreach (self::getSupportedLanguages() as $arr) { $supportedLanguages[] = $arr['value']; } // Get the fallback language $fallbackLanguage = $this->getValue( self::KEY_FALLBACK_LANGUAGE, $this->storeManager->getStore() ); // Compare user language with supported if (in_array($userLanguage, $supportedLanguages)) { return $userLanguage; } else { return ($fallbackLanguage) ? $fallbackLanguage : 'EN-EN'; } }
[ "public", "function", "getIntegrationLanguage", "(", ")", "{", "// Get and format the user language", "$", "userLanguage", "=", "$", "this", "->", "localeResolver", "->", "getLocale", "(", ")", ";", "$", "userLanguage", "=", "strtoupper", "(", "str_replace", "(", ...
Returns the integration language. @return string
[ "Returns", "the", "integration", "language", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L174-L198
43,150
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getDesignSettings
public function getDesignSettings() { return (array) array ( 'hosted' => array ( 'theme_color' => $this->getValue( self::KEY_THEME_COLOR, $this->storeManager->getStore() ), 'button_label' => $this->getValue( self::KEY_BUTTON_LABEL, $this->storeManager->getStore() ), 'box_title' => $this->getValue( self::KEY_BOX_TITLE, $this->storeManager->getStore() ), 'box_subtitle' => $this->getValue( self::KEY_BOX_SUBTITLE, $this->storeManager->getStore() ), 'logo_url' => $this->getLogoUrl() ) ); }
php
public function getDesignSettings() { return (array) array ( 'hosted' => array ( 'theme_color' => $this->getValue( self::KEY_THEME_COLOR, $this->storeManager->getStore() ), 'button_label' => $this->getValue( self::KEY_BUTTON_LABEL, $this->storeManager->getStore() ), 'box_title' => $this->getValue( self::KEY_BOX_TITLE, $this->storeManager->getStore() ), 'box_subtitle' => $this->getValue( self::KEY_BOX_SUBTITLE, $this->storeManager->getStore() ), 'logo_url' => $this->getLogoUrl() ) ); }
[ "public", "function", "getDesignSettings", "(", ")", "{", "return", "(", "array", ")", "array", "(", "'hosted'", "=>", "array", "(", "'theme_color'", "=>", "$", "this", "->", "getValue", "(", "self", "::", "KEY_THEME_COLOR", ",", "$", "this", "->", "storeM...
Returns the design settings. @return array
[ "Returns", "the", "design", "settings", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L325-L347
43,151
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getLogoUrl
public function getLogoUrl() { $logoUrl = $this->getValue( self::KEY_LOGO_URL, $this->storeManager->getStore() ); return (string) (isset($logoUrl) && !empty($logoUrl)) ? $logoUrl : 'none'; }
php
public function getLogoUrl() { $logoUrl = $this->getValue( self::KEY_LOGO_URL, $this->storeManager->getStore() ); return (string) (isset($logoUrl) && !empty($logoUrl)) ? $logoUrl : 'none'; }
[ "public", "function", "getLogoUrl", "(", ")", "{", "$", "logoUrl", "=", "$", "this", "->", "getValue", "(", "self", "::", "KEY_LOGO_URL", ",", "$", "this", "->", "storeManager", "->", "getStore", "(", ")", ")", ";", "return", "(", "string", ")", "(", ...
Returns the hosted logo URL. @return string
[ "Returns", "the", "hosted", "logo", "URL", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L354-L361
43,152
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.isActive
public function isActive() { if (!$this->getValue( self::KEY_ACTIVE, $this->storeManager->getStore() )) { return false; } $quote = $this->checkoutSession->getQuote(); return (bool) in_array($quote->getQuoteCurrencyCode(), $this->getAcceptedCurrencies()); }
php
public function isActive() { if (!$this->getValue( self::KEY_ACTIVE, $this->storeManager->getStore() )) { return false; } $quote = $this->checkoutSession->getQuote(); return (bool) in_array($quote->getQuoteCurrencyCode(), $this->getAcceptedCurrencies()); }
[ "public", "function", "isActive", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getValue", "(", "self", "::", "KEY_ACTIVE", ",", "$", "this", "->", "storeManager", "->", "getStore", "(", ")", ")", ")", "{", "return", "false", ";", "}", "$", "q...
Determines if the gateway is active. @return bool
[ "Determines", "if", "the", "gateway", "is", "active", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L407-L418
43,153
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getStoreName
public function getStoreName() { $storeName = $this->scopeConfig->getValue( 'general/store_information/name', ScopeInterface::SCOPE_STORE ); trim($storeName); if (empty($storeName)) { $storeName = parse_url($this->storeManager->getStore()->getBaseUrl())['host'] ; } return (string) $storeName; }
php
public function getStoreName() { $storeName = $this->scopeConfig->getValue( 'general/store_information/name', ScopeInterface::SCOPE_STORE ); trim($storeName); if (empty($storeName)) { $storeName = parse_url($this->storeManager->getStore()->getBaseUrl())['host'] ; } return (string) $storeName; }
[ "public", "function", "getStoreName", "(", ")", "{", "$", "storeName", "=", "$", "this", "->", "scopeConfig", "->", "getValue", "(", "'general/store_information/name'", ",", "ScopeInterface", "::", "SCOPE_STORE", ")", ";", "trim", "(", "$", "storeName", ")", "...
Returns the store name. @return string
[ "Returns", "the", "store", "name", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L425-L438
43,154
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getGooglePayAllowedNetworks
public function getGooglePayAllowedNetworks() { $allowedNetworks = $this->scopeConfig->getValue( 'payment/checkout_com_googlepay/allowed_card_networks', ScopeInterface::SCOPE_STORE ); return (string) !empty($allowedNetworks) ? $allowedNetworks : 'VISA'; }
php
public function getGooglePayAllowedNetworks() { $allowedNetworks = $this->scopeConfig->getValue( 'payment/checkout_com_googlepay/allowed_card_networks', ScopeInterface::SCOPE_STORE ); return (string) !empty($allowedNetworks) ? $allowedNetworks : 'VISA'; }
[ "public", "function", "getGooglePayAllowedNetworks", "(", ")", "{", "$", "allowedNetworks", "=", "$", "this", "->", "scopeConfig", "->", "getValue", "(", "'payment/checkout_com_googlepay/allowed_card_networks'", ",", "ScopeInterface", "::", "SCOPE_STORE", ")", ";", "ret...
Gets the Google Pay allowed networks. @return string
[ "Gets", "the", "Google", "Pay", "allowed", "networks", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L485-L492
43,155
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getApplePayTokenRequestUrl
public function getApplePayTokenRequestUrl() { $path = ($this->isLive()) ? self::KEY_LIVE_APPLEPAY_TOKEN_REQUEST_URL : self::KEY_SANDBOX_APPLEPAY_TOKEN_REQUEST_URL; return (string) $this->getValue( $path, $this->storeManager->getStore() ); }
php
public function getApplePayTokenRequestUrl() { $path = ($this->isLive()) ? self::KEY_LIVE_APPLEPAY_TOKEN_REQUEST_URL : self::KEY_SANDBOX_APPLEPAY_TOKEN_REQUEST_URL; return (string) $this->getValue( $path, $this->storeManager->getStore() ); }
[ "public", "function", "getApplePayTokenRequestUrl", "(", ")", "{", "$", "path", "=", "(", "$", "this", "->", "isLive", "(", ")", ")", "?", "self", "::", "KEY_LIVE_APPLEPAY_TOKEN_REQUEST_URL", ":", "self", "::", "KEY_SANDBOX_APPLEPAY_TOKEN_REQUEST_URL", ";", "retur...
Returns the Apple Pay token request URL. @return string
[ "Returns", "the", "Apple", "Pay", "token", "request", "URL", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L551-L560
43,156
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getGooglePayTokenRequestUrl
public function getGooglePayTokenRequestUrl() { $path = ($this->isLive()) ? self::KEY_LIVE_GOOGLEPAY_TOKEN_REQUEST_URL : self::KEY_SANDBOX_GOOGLEPAY_TOKEN_REQUEST_URL; return (string) $this->getValue( $path, $this->storeManager->getStore() ); }
php
public function getGooglePayTokenRequestUrl() { $path = ($this->isLive()) ? self::KEY_LIVE_GOOGLEPAY_TOKEN_REQUEST_URL : self::KEY_SANDBOX_GOOGLEPAY_TOKEN_REQUEST_URL; return (string) $this->getValue( $path, $this->storeManager->getStore() ); }
[ "public", "function", "getGooglePayTokenRequestUrl", "(", ")", "{", "$", "path", "=", "(", "$", "this", "->", "isLive", "(", ")", ")", "?", "self", "::", "KEY_LIVE_GOOGLEPAY_TOKEN_REQUEST_URL", ":", "self", "::", "KEY_SANDBOX_GOOGLEPAY_TOKEN_REQUEST_URL", ";", "re...
Returns the Google Pay token request URL. @return string
[ "Returns", "the", "Google", "Pay", "token", "request", "URL", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L567-L576
43,157
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getApplePaySupportedCountries
public function getApplePaySupportedCountries() { $supportedCountries = $this->scopeConfig->getValue( 'payment/checkout_com_applepay/supported_countries', ScopeInterface::SCOPE_STORE ); return !empty($supportedCountries) ? $supportedCountries : 'US,GB'; }
php
public function getApplePaySupportedCountries() { $supportedCountries = $this->scopeConfig->getValue( 'payment/checkout_com_applepay/supported_countries', ScopeInterface::SCOPE_STORE ); return !empty($supportedCountries) ? $supportedCountries : 'US,GB'; }
[ "public", "function", "getApplePaySupportedCountries", "(", ")", "{", "$", "supportedCountries", "=", "$", "this", "->", "scopeConfig", "->", "getValue", "(", "'payment/checkout_com_applepay/supported_countries'", ",", "ScopeInterface", "::", "SCOPE_STORE", ")", ";", "r...
Return the countries supported by Apple Pay. @return array
[ "Return", "the", "countries", "supported", "by", "Apple", "Pay", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L595-L602
43,158
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getApplePayProcessingCertificatePassword
public function getApplePayProcessingCertificatePassword() { $pass = $this->scopeConfig->getValue( 'payment/checkout_com_applepay/processing_certificate_password', ScopeInterface::SCOPE_STORE ); trim($pass); return ($pass) ? $pass : ''; }
php
public function getApplePayProcessingCertificatePassword() { $pass = $this->scopeConfig->getValue( 'payment/checkout_com_applepay/processing_certificate_password', ScopeInterface::SCOPE_STORE ); trim($pass); return ($pass) ? $pass : ''; }
[ "public", "function", "getApplePayProcessingCertificatePassword", "(", ")", "{", "$", "pass", "=", "$", "this", "->", "scopeConfig", "->", "getValue", "(", "'payment/checkout_com_applepay/processing_certificate_password'", ",", "ScopeInterface", "::", "SCOPE_STORE", ")", ...
Gets the ApplePay processing certificate password. @return string
[ "Gets", "the", "ApplePay", "processing", "certificate", "password", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L657-L664
43,159
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getPublicKey
public function getPublicKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_PUBLIC_KEY, $this->storeManager->getStore() )); }
php
public function getPublicKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_PUBLIC_KEY, $this->storeManager->getStore() )); }
[ "public", "function", "getPublicKey", "(", ")", "{", "return", "(", "string", ")", "$", "this", "->", "encryptor", "->", "decrypt", "(", "$", "this", "->", "getValue", "(", "self", "::", "KEY_PUBLIC_KEY", ",", "$", "this", "->", "storeManager", "->", "ge...
Returns the public key for client-side functionality. @return string
[ "Returns", "the", "public", "key", "for", "client", "-", "side", "functionality", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L743-L748
43,160
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getSecretKey
public function getSecretKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_SECRET_KEY, $this->storeManager->getStore() )); }
php
public function getSecretKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_SECRET_KEY, $this->storeManager->getStore() )); }
[ "public", "function", "getSecretKey", "(", ")", "{", "return", "(", "string", ")", "$", "this", "->", "encryptor", "->", "decrypt", "(", "$", "this", "->", "getValue", "(", "self", "::", "KEY_SECRET_KEY", ",", "$", "this", "->", "storeManager", "->", "ge...
Returns the secret key for server-side functionality. @return string
[ "Returns", "the", "secret", "key", "for", "server", "-", "side", "functionality", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L755-L760
43,161
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getMadaBinsPath
public function getMadaBinsPath() { return (string) (($this->isLive()) ? $this->getValue( self::KEY_MADA_BINS_PATH, $this->storeManager->getStore() ) : $this->getValue( self::KEY_MADA_BINS_PATH_TEST, $this->storeManager->getStore() )); }
php
public function getMadaBinsPath() { return (string) (($this->isLive()) ? $this->getValue( self::KEY_MADA_BINS_PATH, $this->storeManager->getStore() ) : $this->getValue( self::KEY_MADA_BINS_PATH_TEST, $this->storeManager->getStore() )); }
[ "public", "function", "getMadaBinsPath", "(", ")", "{", "return", "(", "string", ")", "(", "(", "$", "this", "->", "isLive", "(", ")", ")", "?", "$", "this", "->", "getValue", "(", "self", "::", "KEY_MADA_BINS_PATH", ",", "$", "this", "->", "storeManag...
Return the MADA BINS file path. @return string
[ "Return", "the", "MADA", "BINS", "file", "path", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L779-L789
43,162
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getPrivateSharedKey
public function getPrivateSharedKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_PRIVATE_SHARED_KEY, $this->storeManager->getStore() )); }
php
public function getPrivateSharedKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_PRIVATE_SHARED_KEY, $this->storeManager->getStore() )); }
[ "public", "function", "getPrivateSharedKey", "(", ")", "{", "return", "(", "string", ")", "$", "this", "->", "encryptor", "->", "decrypt", "(", "$", "this", "->", "getValue", "(", "self", "::", "KEY_PRIVATE_SHARED_KEY", ",", "$", "this", "->", "storeManager"...
Returns the private shared key used for callback function. @return string
[ "Returns", "the", "private", "shared", "key", "used", "for", "callback", "function", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L796-L801
43,163
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getCustomCss
public function getCustomCss() { // Prepare the paths $base_url = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); $file_path = $this->getValue( 'payment/checkout_com/checkout_com_base_settings/custom_css', $this->storeManager->getStore() ); return $base_url . 'checkout_com/' . $file_path; }
php
public function getCustomCss() { // Prepare the paths $base_url = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); $file_path = $this->getValue( 'payment/checkout_com/checkout_com_base_settings/custom_css', $this->storeManager->getStore() ); return $base_url . 'checkout_com/' . $file_path; }
[ "public", "function", "getCustomCss", "(", ")", "{", "// Prepare the paths", "$", "base_url", "=", "$", "this", "->", "storeManager", "->", "getStore", "(", ")", "->", "getBaseUrl", "(", "\\", "Magento", "\\", "Framework", "\\", "UrlInterface", "::", "URL_TYPE...
Returns the custom CSS URL for embedded integration. @return string
[ "Returns", "the", "custom", "CSS", "URL", "for", "embedded", "integration", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L1004-L1013
43,164
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getCountrySpecificCardTypeConfig
public function getCountrySpecificCardTypeConfig() { $countriesCardTypes = unserialize($this->getValue( self::KEY_COUNTRY_CREDIT_CARD, $this->storeManager->getStore() )); return is_array($countriesCardTypes) ? $countriesCardTypes : []; }
php
public function getCountrySpecificCardTypeConfig() { $countriesCardTypes = unserialize($this->getValue( self::KEY_COUNTRY_CREDIT_CARD, $this->storeManager->getStore() )); return is_array($countriesCardTypes) ? $countriesCardTypes : []; }
[ "public", "function", "getCountrySpecificCardTypeConfig", "(", ")", "{", "$", "countriesCardTypes", "=", "unserialize", "(", "$", "this", "->", "getValue", "(", "self", "::", "KEY_COUNTRY_CREDIT_CARD", ",", "$", "this", "->", "storeManager", "->", "getStore", "(",...
Return the country specific card type config. @return array
[ "Return", "the", "country", "specific", "card", "type", "config", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L1044-L1051
43,165
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getCountryAvailableCardTypes
public function getCountryAvailableCardTypes($country) { $types = $this->getCountrySpecificCardTypeConfig(); return (!empty($types[$country])) ? $types[$country] : []; }
php
public function getCountryAvailableCardTypes($country) { $types = $this->getCountrySpecificCardTypeConfig(); return (!empty($types[$country])) ? $types[$country] : []; }
[ "public", "function", "getCountryAvailableCardTypes", "(", "$", "country", ")", "{", "$", "types", "=", "$", "this", "->", "getCountrySpecificCardTypeConfig", "(", ")", ";", "return", "(", "!", "empty", "(", "$", "types", "[", "$", "country", "]", ")", ")"...
Get list of card types available for country. @param string $country @return array
[ "Get", "list", "of", "card", "types", "available", "for", "country", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L1059-L1062
43,166
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getAvailableCardTypes
public function getAvailableCardTypes() { $ccTypes = $this->getValue( self::KEY_CC_TYPES, $this->storeManager->getStore() ); return ! empty($ccTypes) ? explode(',', $ccTypes) : []; }
php
public function getAvailableCardTypes() { $ccTypes = $this->getValue( self::KEY_CC_TYPES, $this->storeManager->getStore() ); return ! empty($ccTypes) ? explode(',', $ccTypes) : []; }
[ "public", "function", "getAvailableCardTypes", "(", ")", "{", "$", "ccTypes", "=", "$", "this", "->", "getValue", "(", "self", "::", "KEY_CC_TYPES", ",", "$", "this", "->", "storeManager", "->", "getStore", "(", ")", ")", ";", "return", "!", "empty", "("...
Retrieve available credit card types. @return array
[ "Retrieve", "available", "credit", "card", "types", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L1069-L1076
43,167
checkout/checkout-magento2-plugin
Model/Factory/VaultTokenFactory.php
VaultTokenFactory.create
public function create(array $card, $customerId = null) { $expiryMonth = str_pad($card['expiryMonth'], 2, '0', STR_PAD_LEFT); $expiryYear = $card['expiryYear']; $expiresAt = $this->getExpirationDate($expiryMonth, $expiryYear); $ccType = $this->ccTypeAdapter->getFromGateway($card['paymentMethod']); /** @var PaymentTokenInterface $paymentToken */ $paymentToken = $this->creditCardTokenFactory->create(); $paymentToken->setExpiresAt($expiresAt); if( array_key_exists('id', $card) ) { $paymentToken->setGatewayToken($card['id']); } $tokenDetails = [ 'type' => $ccType, 'maskedCC' => $card['last4'], 'expirationDate' => $expiryMonth . '/' . $expiryYear, ]; $paymentToken->setTokenDetails($this->convertDetailsToJSON($tokenDetails)); $paymentToken->setIsActive(true); $paymentToken->setPaymentMethodCode(ConfigProvider::CODE); if($customerId) { $paymentToken->setCustomerId($customerId); } $paymentToken->setPublicHash($this->generatePublicHash($paymentToken)); return $paymentToken; }
php
public function create(array $card, $customerId = null) { $expiryMonth = str_pad($card['expiryMonth'], 2, '0', STR_PAD_LEFT); $expiryYear = $card['expiryYear']; $expiresAt = $this->getExpirationDate($expiryMonth, $expiryYear); $ccType = $this->ccTypeAdapter->getFromGateway($card['paymentMethod']); /** @var PaymentTokenInterface $paymentToken */ $paymentToken = $this->creditCardTokenFactory->create(); $paymentToken->setExpiresAt($expiresAt); if( array_key_exists('id', $card) ) { $paymentToken->setGatewayToken($card['id']); } $tokenDetails = [ 'type' => $ccType, 'maskedCC' => $card['last4'], 'expirationDate' => $expiryMonth . '/' . $expiryYear, ]; $paymentToken->setTokenDetails($this->convertDetailsToJSON($tokenDetails)); $paymentToken->setIsActive(true); $paymentToken->setPaymentMethodCode(ConfigProvider::CODE); if($customerId) { $paymentToken->setCustomerId($customerId); } $paymentToken->setPublicHash($this->generatePublicHash($paymentToken)); return $paymentToken; }
[ "public", "function", "create", "(", "array", "$", "card", ",", "$", "customerId", "=", "null", ")", "{", "$", "expiryMonth", "=", "str_pad", "(", "$", "card", "[", "'expiryMonth'", "]", ",", "2", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "$", "expi...
Returns the prepared payment token. @param array $card @param int|null $customerId @return PaymentTokenInterface
[ "Returns", "the", "prepared", "payment", "token", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Factory/VaultTokenFactory.php#L60-L91
43,168
checkout/checkout-magento2-plugin
Model/Factory/VaultTokenFactory.php
VaultTokenFactory.getExpirationDate
private function getExpirationDate($expiryMonth, $expiryYear) { $expDate = new DateTime( $expiryYear . '-' . $expiryMonth . '-' . '01' . ' ' . '00:00:00', new DateTimeZone('UTC') ); return $expDate->add(new DateInterval('P1M'))->format('Y-m-d 00:00:00'); }
php
private function getExpirationDate($expiryMonth, $expiryYear) { $expDate = new DateTime( $expiryYear . '-' . $expiryMonth . '-' . '01' . ' ' . '00:00:00', new DateTimeZone('UTC') ); return $expDate->add(new DateInterval('P1M'))->format('Y-m-d 00:00:00'); }
[ "private", "function", "getExpirationDate", "(", "$", "expiryMonth", ",", "$", "expiryYear", ")", "{", "$", "expDate", "=", "new", "DateTime", "(", "$", "expiryYear", ".", "'-'", ".", "$", "expiryMonth", ".", "'-'", ".", "'01'", ".", "' '", ".", "'00:00:...
Returns the date time object with the given expiration month and year. @param string $expiryMonth @param string $expiryYear @return string
[ "Returns", "the", "date", "time", "object", "with", "the", "given", "expiration", "month", "and", "year", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Factory/VaultTokenFactory.php#L100-L113
43,169
checkout/checkout-magento2-plugin
Model/Factory/VaultTokenFactory.php
VaultTokenFactory.generatePublicHash
private function generatePublicHash(PaymentTokenInterface $paymentToken) { $hashKey = $paymentToken->getGatewayToken(); if ($paymentToken->getCustomerId()) { $hashKey = $paymentToken->getCustomerId(); } $hashKey .= $paymentToken->getPaymentMethodCode() . $paymentToken->getType() . $paymentToken->getTokenDetails(); return $this->encryptor->getHash($hashKey); }
php
private function generatePublicHash(PaymentTokenInterface $paymentToken) { $hashKey = $paymentToken->getGatewayToken(); if ($paymentToken->getCustomerId()) { $hashKey = $paymentToken->getCustomerId(); } $hashKey .= $paymentToken->getPaymentMethodCode() . $paymentToken->getType() . $paymentToken->getTokenDetails(); return $this->encryptor->getHash($hashKey); }
[ "private", "function", "generatePublicHash", "(", "PaymentTokenInterface", "$", "paymentToken", ")", "{", "$", "hashKey", "=", "$", "paymentToken", "->", "getGatewayToken", "(", ")", ";", "if", "(", "$", "paymentToken", "->", "getCustomerId", "(", ")", ")", "{...
Generate vault payment public hash @param PaymentTokenInterface $paymentToken @return string
[ "Generate", "vault", "payment", "public", "hash" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Factory/VaultTokenFactory.php#L121-L133
43,170
checkout/checkout-magento2-plugin
Gateway/Validator/ResponseValidator.php
ResponseValidator.validate
public function validate(array $validationSubject) { $isValid = true; $errorMessages = []; foreach($this->rules() as $rule) { $isRuleValid = $rule->isValid($validationSubject); if( ! $isRuleValid ) { $isValid = false; $errorMessages[] = $rule->getErrorMessage(); if($this->stopInFirstError) { break; } } } return $this->createResult($isValid, $errorMessages); }
php
public function validate(array $validationSubject) { $isValid = true; $errorMessages = []; foreach($this->rules() as $rule) { $isRuleValid = $rule->isValid($validationSubject); if( ! $isRuleValid ) { $isValid = false; $errorMessages[] = $rule->getErrorMessage(); if($this->stopInFirstError) { break; } } } return $this->createResult($isValid, $errorMessages); }
[ "public", "function", "validate", "(", "array", "$", "validationSubject", ")", "{", "$", "isValid", "=", "true", ";", "$", "errorMessages", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "rules", "(", ")", "as", "$", "rule", ")", "{", "$", ...
Performs domain-related validation for business object @param array $validationSubject @return ResultInterface
[ "Performs", "domain", "-", "related", "validation", "for", "business", "object" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Validator/ResponseValidator.php#L32-L52
43,171
checkout/checkout-magento2-plugin
Block/Adminhtml/Plan/AddRow.php
AddRow._construct
protected function _construct() { $this->_objectId = 'row_id'; $this->_blockGroup = 'CheckoutCom_Magento2'; $this->_controller = 'adminhtml_plan'; parent::_construct(); if ($this->_isAllowedAction('CheckoutCom_Magento2::add_row')) { $this->buttonList->update('save', 'label', __('Save')); } else { $this->buttonList->remove('save'); } $this->buttonList->remove('reset'); }
php
protected function _construct() { $this->_objectId = 'row_id'; $this->_blockGroup = 'CheckoutCom_Magento2'; $this->_controller = 'adminhtml_plan'; parent::_construct(); if ($this->_isAllowedAction('CheckoutCom_Magento2::add_row')) { $this->buttonList->update('save', 'label', __('Save')); } else { $this->buttonList->remove('save'); } $this->buttonList->remove('reset'); }
[ "protected", "function", "_construct", "(", ")", "{", "$", "this", "->", "_objectId", "=", "'row_id'", ";", "$", "this", "->", "_blockGroup", "=", "'CheckoutCom_Magento2'", ";", "$", "this", "->", "_controller", "=", "'adminhtml_plan'", ";", "parent", "::", ...
Initialize Imagegallery Images Edit Block.
[ "Initialize", "Imagegallery", "Images", "Edit", "Block", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Adminhtml/Plan/AddRow.php#L42-L54
43,172
checkout/checkout-magento2-plugin
Model/Fields/SubscriptionStatus.php
SubscriptionStatus.getOptions
public function getOptions() { $res = []; foreach ($this->getOptionArray() as $index => $value) { $res[] = ['value' => $index, 'label' => $value]; } return $res; }
php
public function getOptions() { $res = []; foreach ($this->getOptionArray() as $index => $value) { $res[] = ['value' => $index, 'label' => $value]; } return $res; }
[ "public", "function", "getOptions", "(", ")", "{", "$", "res", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getOptionArray", "(", ")", "as", "$", "index", "=>", "$", "value", ")", "{", "$", "res", "[", "]", "=", "[", "'value'", "=>", ...
Get Grid row type array for option element. @return array
[ "Get", "Grid", "row", "type", "array", "for", "option", "element", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Fields/SubscriptionStatus.php#L51-L58
43,173
checkout/checkout-magento2-plugin
Model/Adminhtml/Source/ApplePayNetworks.php
ApplePayNetworks.toOptionArray
public function toOptionArray() { return [ [ 'value' => self::CARD_VISA, 'label' => __('Visa') ], [ 'value' => self::CARD_MASTERCARD, 'label' => __('Mastercard') ], [ 'value' => self::CARD_AMEX, 'label' => __('American Express') ], ]; }
php
public function toOptionArray() { return [ [ 'value' => self::CARD_VISA, 'label' => __('Visa') ], [ 'value' => self::CARD_MASTERCARD, 'label' => __('Mastercard') ], [ 'value' => self::CARD_AMEX, 'label' => __('American Express') ], ]; }
[ "public", "function", "toOptionArray", "(", ")", "{", "return", "[", "[", "'value'", "=>", "self", "::", "CARD_VISA", ",", "'label'", "=>", "__", "(", "'Visa'", ")", "]", ",", "[", "'value'", "=>", "self", "::", "CARD_MASTERCARD", ",", "'label'", "=>", ...
Possible Apple Pay Cards @return array
[ "Possible", "Apple", "Pay", "Cards" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adminhtml/Source/ApplePayNetworks.php#L26-L41
43,174
checkout/checkout-magento2-plugin
Model/Adminhtml/Source/PaymentMode.php
PaymentMode.toOptionArray
public function toOptionArray() { return [ [ 'value' => self::MODE_CARDS, 'label' => __('Cards') ], [ 'value' => self::MODE_MIXED, 'label' => __('Mixed') ], [ 'value' => self::MODE_LOCAL, 'label' => __('Local payments') ] ]; }
php
public function toOptionArray() { return [ [ 'value' => self::MODE_CARDS, 'label' => __('Cards') ], [ 'value' => self::MODE_MIXED, 'label' => __('Mixed') ], [ 'value' => self::MODE_LOCAL, 'label' => __('Local payments') ] ]; }
[ "public", "function", "toOptionArray", "(", ")", "{", "return", "[", "[", "'value'", "=>", "self", "::", "MODE_CARDS", ",", "'label'", "=>", "__", "(", "'Cards'", ")", "]", ",", "[", "'value'", "=>", "self", "::", "MODE_MIXED", ",", "'label'", "=>", "_...
Possible payment modes @return array
[ "Possible", "payment", "modes" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adminhtml/Source/PaymentMode.php#L26-L41
43,175
checkout/checkout-magento2-plugin
Model/Fields/UserCards.php
UserCards.getOptionArray
public function getOptionArray() { // Prepare the options array $options = []; // Get the customer id // TODO get from model or user select $customerId = 2; // Get the cards list $cardList = $this->paymentTokenManagement->getListByCustomerId($customerId); // Prepare the options list foreach ($cardList as $card) { // Get the card data $cardData = $card->getData(); // Create the option //if ((int) $cardData->is_active == 1 && (int) $cardData->is_visible == 1) { if ($cardData) { $options[$cardData['gateway_token']] = $this->_getOptionString(json_decode($cardData['details'])); } } return $options; }
php
public function getOptionArray() { // Prepare the options array $options = []; // Get the customer id // TODO get from model or user select $customerId = 2; // Get the cards list $cardList = $this->paymentTokenManagement->getListByCustomerId($customerId); // Prepare the options list foreach ($cardList as $card) { // Get the card data $cardData = $card->getData(); // Create the option //if ((int) $cardData->is_active == 1 && (int) $cardData->is_visible == 1) { if ($cardData) { $options[$cardData['gateway_token']] = $this->_getOptionString(json_decode($cardData['details'])); } } return $options; }
[ "public", "function", "getOptionArray", "(", ")", "{", "// Prepare the options array", "$", "options", "=", "[", "]", ";", "// Get the customer id ", "// TODO get from model or user select", "$", "customerId", "=", "2", ";", "// Get the cards list", "$", "cardList", "="...
Get Grid row type labels array. @return array
[ "Get", "Grid", "row", "type", "labels", "array", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Fields/UserCards.php#L39-L64
43,176
checkout/checkout-magento2-plugin
Model/Service/CallbackService.php
CallbackService.getAssociatedOrder
private function getAssociatedOrder() { $orderId = $this->gatewayResponse['response']['message']['trackId']; $order = $this->orderFactory->create()->loadByIncrementId($orderId); if($order->isEmpty()) { throw new DomainException('The order does not exists.'); } return $order; }
php
private function getAssociatedOrder() { $orderId = $this->gatewayResponse['response']['message']['trackId']; $order = $this->orderFactory->create()->loadByIncrementId($orderId); if($order->isEmpty()) { throw new DomainException('The order does not exists.'); } return $order; }
[ "private", "function", "getAssociatedOrder", "(", ")", "{", "$", "orderId", "=", "$", "this", "->", "gatewayResponse", "[", "'response'", "]", "[", "'message'", "]", "[", "'trackId'", "]", ";", "$", "order", "=", "$", "this", "->", "orderFactory", "->", ...
Returns the order instance. @return \Magento\Sales\Model\Order @throws DomainException
[ "Returns", "the", "order", "instance", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Service/CallbackService.php#L261-L270
43,177
checkout/checkout-magento2-plugin
Model/Adapter/ChargeAmountAdapter.php
ChargeAmountAdapter.getGatewayAmountOfCurrency
public static function getGatewayAmountOfCurrency($amount, $currencyCode) { $currencyCode = strtoupper($currencyCode); if ( ! is_numeric($amount) ) { throw new InvalidArgumentException('The amount value is not numeric. The [' . $amount . '] value has been given.'); } $amount = (float) $amount; if ($amount < 0) { throw new InvalidArgumentException('The amount value must be positive. The [' . $amount . '] value has been given.'); } if( in_array($currencyCode, self::FULL_VALUE_CURRENCIES, true) ) { return (int) $amount; } if( in_array($currencyCode, self::DIV_1000_VALUE_CURRENCIES, true) ) { return (int) ($amount * self::DIV_1000); } return (int) ($amount * self::DIV_100); }
php
public static function getGatewayAmountOfCurrency($amount, $currencyCode) { $currencyCode = strtoupper($currencyCode); if ( ! is_numeric($amount) ) { throw new InvalidArgumentException('The amount value is not numeric. The [' . $amount . '] value has been given.'); } $amount = (float) $amount; if ($amount < 0) { throw new InvalidArgumentException('The amount value must be positive. The [' . $amount . '] value has been given.'); } if( in_array($currencyCode, self::FULL_VALUE_CURRENCIES, true) ) { return (int) $amount; } if( in_array($currencyCode, self::DIV_1000_VALUE_CURRENCIES, true) ) { return (int) ($amount * self::DIV_1000); } return (int) ($amount * self::DIV_100); }
[ "public", "static", "function", "getGatewayAmountOfCurrency", "(", "$", "amount", ",", "$", "currencyCode", ")", "{", "$", "currencyCode", "=", "strtoupper", "(", "$", "currencyCode", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "amount", ")", ")", "{...
Returns transformed amount by the given currency code which can be handled by the gateway API. @param float $amount Value from the store. @param string $currencyCode @return int @throws InvalidArgumentException
[ "Returns", "transformed", "amount", "by", "the", "given", "currency", "code", "which", "can", "be", "handled", "by", "the", "gateway", "API", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/ChargeAmountAdapter.php#L78-L100
43,178
checkout/checkout-magento2-plugin
Model/Adapter/ChargeAmountAdapter.php
ChargeAmountAdapter.getStoreAmountOfCurrency
public static function getStoreAmountOfCurrency($amount, $currencyCode) { $currencyCode = strtoupper($currencyCode); $amount = (int) $amount; if( in_array($currencyCode, self::FULL_VALUE_CURRENCIES, true) ) { return (float) $amount; } if( in_array($currencyCode, self::DIV_1000_VALUE_CURRENCIES, true) ) { return (float) ($amount / self::DIV_1000); } return (float) ($amount / self::DIV_100); }
php
public static function getStoreAmountOfCurrency($amount, $currencyCode) { $currencyCode = strtoupper($currencyCode); $amount = (int) $amount; if( in_array($currencyCode, self::FULL_VALUE_CURRENCIES, true) ) { return (float) $amount; } if( in_array($currencyCode, self::DIV_1000_VALUE_CURRENCIES, true) ) { return (float) ($amount / self::DIV_1000); } return (float) ($amount / self::DIV_100); }
[ "public", "static", "function", "getStoreAmountOfCurrency", "(", "$", "amount", ",", "$", "currencyCode", ")", "{", "$", "currencyCode", "=", "strtoupper", "(", "$", "currencyCode", ")", ";", "$", "amount", "=", "(", "int", ")", "$", "amount", ";", "if", ...
Returns transformed amount by the given currency code which can be handled by the store. @param string|int $amount Value from the gateway. @param $currencyCode @return float
[ "Returns", "transformed", "amount", "by", "the", "given", "currency", "code", "which", "can", "be", "handled", "by", "the", "store", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/ChargeAmountAdapter.php#L109-L122
43,179
checkout/checkout-magento2-plugin
Model/Adapter/ChargeAmountAdapter.php
ChargeAmountAdapter.getConfigArray
public static function getConfigArray() { $data = []; foreach(self::FULL_VALUE_CURRENCIES as $currency) { $data[ $currency ] = 1; } foreach(self::DIV_1000_VALUE_CURRENCIES as $currency) { $data[ $currency ] = self::DIV_1000; } $data['others'] = self::DIV_100; return $data; }
php
public static function getConfigArray() { $data = []; foreach(self::FULL_VALUE_CURRENCIES as $currency) { $data[ $currency ] = 1; } foreach(self::DIV_1000_VALUE_CURRENCIES as $currency) { $data[ $currency ] = self::DIV_1000; } $data['others'] = self::DIV_100; return $data; }
[ "public", "static", "function", "getConfigArray", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "self", "::", "FULL_VALUE_CURRENCIES", "as", "$", "currency", ")", "{", "$", "data", "[", "$", "currency", "]", "=", "1", ";", "}", "for...
Returns a config array for the JS implementation. @return array
[ "Returns", "a", "config", "array", "for", "the", "JS", "implementation", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/ChargeAmountAdapter.php#L129-L143
43,180
checkout/checkout-magento2-plugin
Model/Adapter/ChargeAmountAdapter.php
ChargeAmountAdapter.getPaymentFinalCurrencyCode
public static function getPaymentFinalCurrencyCode($orderCurrencyCode) { // Get the object manager $manager = \Magento\Framework\App\ObjectManager::getInstance(); // Load the gateway config and get the gateway payment currency $gatewayPaymentCurrency = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getPaymentCurrency(); // Get the storoe id $storeId = $manager->create('Magento\Checkout\Model\Session')->getQuote()->getStoreId(); // Get the user currency display $quote = $manager->create('Magento\Checkout\Model\Session')->getQuote(); $order = $manager->create('Magento\Checkout\Model\Session')->getLastRealOrder(); if ($quote) { $userCurrencyCode = $quote->getQuoteCurrencyCode(); } else if ($order) { $userCurrencyCode = $quote->getOrderCurrencyCode(); } else { $userCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getCurrentCurrencyCode(); } // Load the store currency $storeBaseCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getBaseCurrency()->getCode(); // Test the store and gateway config conditions if ($gatewayPaymentCurrency == self::BASE_CURRENCY) { // Use the store base currency code $finalCurrencyCode = $storeBaseCurrencyCode; } elseif ($gatewayPaymentCurrency == self::ORDER_CURRENCY) { // Use the order currency code $finalCurrencyCode = $userCurrencyCode; } else { // We have a specific currency code to use for the payment $finalCurrencyCode = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getCustomCurrency(); } return $finalCurrencyCode; }
php
public static function getPaymentFinalCurrencyCode($orderCurrencyCode) { // Get the object manager $manager = \Magento\Framework\App\ObjectManager::getInstance(); // Load the gateway config and get the gateway payment currency $gatewayPaymentCurrency = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getPaymentCurrency(); // Get the storoe id $storeId = $manager->create('Magento\Checkout\Model\Session')->getQuote()->getStoreId(); // Get the user currency display $quote = $manager->create('Magento\Checkout\Model\Session')->getQuote(); $order = $manager->create('Magento\Checkout\Model\Session')->getLastRealOrder(); if ($quote) { $userCurrencyCode = $quote->getQuoteCurrencyCode(); } else if ($order) { $userCurrencyCode = $quote->getOrderCurrencyCode(); } else { $userCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getCurrentCurrencyCode(); } // Load the store currency $storeBaseCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getBaseCurrency()->getCode(); // Test the store and gateway config conditions if ($gatewayPaymentCurrency == self::BASE_CURRENCY) { // Use the store base currency code $finalCurrencyCode = $storeBaseCurrencyCode; } elseif ($gatewayPaymentCurrency == self::ORDER_CURRENCY) { // Use the order currency code $finalCurrencyCode = $userCurrencyCode; } else { // We have a specific currency code to use for the payment $finalCurrencyCode = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getCustomCurrency(); } return $finalCurrencyCode; }
[ "public", "static", "function", "getPaymentFinalCurrencyCode", "(", "$", "orderCurrencyCode", ")", "{", "// Get the object manager", "$", "manager", "=", "\\", "Magento", "\\", "Framework", "\\", "App", "\\", "ObjectManager", "::", "getInstance", "(", ")", ";", "/...
Returns a converted currency code. @param string $orderCurrencyCode @return string
[ "Returns", "a", "converted", "currency", "code", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/ChargeAmountAdapter.php#L150-L195
43,181
checkout/checkout-magento2-plugin
Model/Adapter/ChargeAmountAdapter.php
ChargeAmountAdapter.getPaymentFinalCurrencyValue
public static function getPaymentFinalCurrencyValue($orderAmount) { // Get the object manager $manager = \Magento\Framework\App\ObjectManager::getInstance(); // Load the gateway config and get the gateway payment currency $gatewayPaymentCurrency = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getPaymentCurrency(); // Get the storoe id $storeId = $manager->create('Magento\Checkout\Model\Session')->getQuote()->getStoreId(); // Get the user currency display $quote = $manager->create('Magento\Checkout\Model\Session')->getQuote(); $order = $manager->create('Magento\Checkout\Model\Session')->getLastRealOrder(); if ($quote) { $userCurrencyCode = $quote->getQuoteCurrencyCode(); } else if ($order) { $userCurrencyCode = $quote->getOrderCurrencyCode(); } else { $userCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getCurrentCurrencyCode(); } // Load the store currency $storeBaseCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getBaseCurrency()->getCode(); // Test the store and gateway config conditions if ($gatewayPaymentCurrency == self::BASE_CURRENCY) { if ($userCurrencyCode == $storeBaseCurrencyCode) { // Convert the user currency amount to base currency amount $finalAmount = $orderAmount / $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode); } else { $finalAmount = $orderAmount; } } elseif ($gatewayPaymentCurrency == self::ORDER_CURRENCY) { if ($userCurrencyCode != $storeBaseCurrencyCode) { $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode); } else { // Convert the base amount to user currency amount $finalAmount = $orderAmount; } } else { if ($userCurrencyCode != $gatewayPaymentCurrency) { // We have a specific currency to use for the payment $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($userCurrencyCode)->getAnyRate($gatewayPaymentCurrency); } else { $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($gatewayPaymentCurrency); } } return $finalAmount; }
php
public static function getPaymentFinalCurrencyValue($orderAmount) { // Get the object manager $manager = \Magento\Framework\App\ObjectManager::getInstance(); // Load the gateway config and get the gateway payment currency $gatewayPaymentCurrency = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getPaymentCurrency(); // Get the storoe id $storeId = $manager->create('Magento\Checkout\Model\Session')->getQuote()->getStoreId(); // Get the user currency display $quote = $manager->create('Magento\Checkout\Model\Session')->getQuote(); $order = $manager->create('Magento\Checkout\Model\Session')->getLastRealOrder(); if ($quote) { $userCurrencyCode = $quote->getQuoteCurrencyCode(); } else if ($order) { $userCurrencyCode = $quote->getOrderCurrencyCode(); } else { $userCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getCurrentCurrencyCode(); } // Load the store currency $storeBaseCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getBaseCurrency()->getCode(); // Test the store and gateway config conditions if ($gatewayPaymentCurrency == self::BASE_CURRENCY) { if ($userCurrencyCode == $storeBaseCurrencyCode) { // Convert the user currency amount to base currency amount $finalAmount = $orderAmount / $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode); } else { $finalAmount = $orderAmount; } } elseif ($gatewayPaymentCurrency == self::ORDER_CURRENCY) { if ($userCurrencyCode != $storeBaseCurrencyCode) { $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode); } else { // Convert the base amount to user currency amount $finalAmount = $orderAmount; } } else { if ($userCurrencyCode != $gatewayPaymentCurrency) { // We have a specific currency to use for the payment $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($userCurrencyCode)->getAnyRate($gatewayPaymentCurrency); } else { $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($gatewayPaymentCurrency); } } return $finalAmount; }
[ "public", "static", "function", "getPaymentFinalCurrencyValue", "(", "$", "orderAmount", ")", "{", "// Get the object manager", "$", "manager", "=", "\\", "Magento", "\\", "Framework", "\\", "App", "\\", "ObjectManager", "::", "getInstance", "(", ")", ";", "// Loa...
Returns a converted currency value. @param float $orderAmount @return float
[ "Returns", "a", "converted", "currency", "value", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/ChargeAmountAdapter.php#L202-L264
43,182
checkout/checkout-magento2-plugin
Model/Resource/MobilePayment.php
MobilePayment.charge
public function charge($data) { // JSON post data to object $this->data = json_decode($data); // Load the customer from email $this->customer = $this->customerRepository->get(filter_var($this->data->email, FILTER_SANITIZE_EMAIL)); // If customer exists and amount is valid if ( (int) $this->customer->getId() > 0 && (float) $this->data->value > 0) { // Prepare the product list if ( isset($this->data->products) && is_array($this->data->products) && count($this->data->products) > 0 ) { // Submit request return (int) $this->submitRequest(); } } return false; }
php
public function charge($data) { // JSON post data to object $this->data = json_decode($data); // Load the customer from email $this->customer = $this->customerRepository->get(filter_var($this->data->email, FILTER_SANITIZE_EMAIL)); // If customer exists and amount is valid if ( (int) $this->customer->getId() > 0 && (float) $this->data->value > 0) { // Prepare the product list if ( isset($this->data->products) && is_array($this->data->products) && count($this->data->products) > 0 ) { // Submit request return (int) $this->submitRequest(); } } return false; }
[ "public", "function", "charge", "(", "$", "data", ")", "{", "// JSON post data to object", "$", "this", "->", "data", "=", "json_decode", "(", "$", "data", ")", ";", "// Load the customer from email", "$", "this", "->", "customer", "=", "$", "this", "->", "c...
Perfom a charge given the required parameters. @api @param mixed $data. @return int.
[ "Perfom", "a", "charge", "given", "the", "required", "parameters", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Resource/MobilePayment.php#L108-L127
43,183
checkout/checkout-magento2-plugin
Model/Fields/PaymentPlan.php
PaymentPlan.formatData
public function formatData(array $rows) { $options = []; if (($rows) && count($rows) > 0) { foreach ($rows as $row) { $options[$row['id']] = $row['plan_name']; } } return $options; }
php
public function formatData(array $rows) { $options = []; if (($rows) && count($rows) > 0) { foreach ($rows as $row) { $options[$row['id']] = $row['plan_name']; } } return $options; }
[ "public", "function", "formatData", "(", "array", "$", "rows", ")", "{", "$", "options", "=", "[", "]", ";", "if", "(", "(", "$", "rows", ")", "&&", "count", "(", "$", "rows", ")", ">", "0", ")", "{", "foreach", "(", "$", "rows", "as", "$", "...
Format the data from DB. @return array
[ "Format", "the", "data", "from", "DB", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Fields/PaymentPlan.php#L76-L87
43,184
checkout/checkout-magento2-plugin
Gateway/Response/TransactionHandler.php
TransactionHandler.vaultCard
public function vaultCard( array $response ){ if (isset($response['card'])) { // Get the card token $cardToken = $response['card']['id']; // Prepare the card data $cardData = []; $cardData['expiryMonth'] = $response['card']['expiryMonth']; $cardData['expiryYear'] = $response['card']['expiryYear']; $cardData['last4'] = $response['card']['last4']; $cardData['paymentMethod'] = $response['card']['paymentMethod']; // Get the payment token $paymentToken = $this->vaultTokenFactory->create($cardData, $this->customerSession->getCustomer()->getId()); try { // Check if the payment token exists $foundPaymentToken = $this->paymentTokenManagement->getByPublicHash( $paymentToken->getPublicHash(), $paymentToken->getCustomerId()); // If the token exists activate it, otherwise create it if ($foundPaymentToken) { $foundPaymentToken->setIsVisible(true); $foundPaymentToken->setIsActive(true); $this->paymentTokenRepository->save($foundPaymentToken); } else { $paymentToken->setGatewayToken($cardToken); $paymentToken->setIsVisible(true); $this->paymentTokenRepository->save($paymentToken); } $this->messageManager->addSuccessMessage( __('The payment card has been stored successfully') ); } catch (\Exception $ex) { $this->messageManager->addErrorMessage( $ex->getMessage() ); } } else { $this->messageManager->addErrorMessage( __('Invalid gateway response. Please contact the site administrator.') ); } }
php
public function vaultCard( array $response ){ if (isset($response['card'])) { // Get the card token $cardToken = $response['card']['id']; // Prepare the card data $cardData = []; $cardData['expiryMonth'] = $response['card']['expiryMonth']; $cardData['expiryYear'] = $response['card']['expiryYear']; $cardData['last4'] = $response['card']['last4']; $cardData['paymentMethod'] = $response['card']['paymentMethod']; // Get the payment token $paymentToken = $this->vaultTokenFactory->create($cardData, $this->customerSession->getCustomer()->getId()); try { // Check if the payment token exists $foundPaymentToken = $this->paymentTokenManagement->getByPublicHash( $paymentToken->getPublicHash(), $paymentToken->getCustomerId()); // If the token exists activate it, otherwise create it if ($foundPaymentToken) { $foundPaymentToken->setIsVisible(true); $foundPaymentToken->setIsActive(true); $this->paymentTokenRepository->save($foundPaymentToken); } else { $paymentToken->setGatewayToken($cardToken); $paymentToken->setIsVisible(true); $this->paymentTokenRepository->save($paymentToken); } $this->messageManager->addSuccessMessage( __('The payment card has been stored successfully') ); } catch (\Exception $ex) { $this->messageManager->addErrorMessage( $ex->getMessage() ); } } else { $this->messageManager->addErrorMessage( __('Invalid gateway response. Please contact the site administrator.') ); } }
[ "public", "function", "vaultCard", "(", "array", "$", "response", ")", "{", "if", "(", "isset", "(", "$", "response", "[", "'card'", "]", ")", ")", "{", "// Get the card token", "$", "cardToken", "=", "$", "response", "[", "'card'", "]", "[", "'id'", "...
Adds a new card. @param array $response @return void
[ "Adds", "a", "new", "card", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Response/TransactionHandler.php#L186-L226
43,185
checkout/checkout-magento2-plugin
Gateway/Response/TransactionHandler.php
TransactionHandler.setTransactionId
protected function setTransactionId(Payment $payment, $transactionId) { $payment->setTransactionId($transactionId); $payment->setLastTransId($transactionId); $payment->setCcTransId($transactionId); }
php
protected function setTransactionId(Payment $payment, $transactionId) { $payment->setTransactionId($transactionId); $payment->setLastTransId($transactionId); $payment->setCcTransId($transactionId); }
[ "protected", "function", "setTransactionId", "(", "Payment", "$", "payment", ",", "$", "transactionId", ")", "{", "$", "payment", "->", "setTransactionId", "(", "$", "transactionId", ")", ";", "$", "payment", "->", "setLastTransId", "(", "$", "transactionId", ...
Sets the transaction Ids for the payment. @param Payment $payment @param string $transactionId @return void
[ "Sets", "the", "transaction", "Ids", "for", "the", "payment", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Response/TransactionHandler.php#L235-L239
43,186
checkout/checkout-magento2-plugin
Controller/Payment/AbstractAction.php
AbstractAction.assignGuestEmail
protected function assignGuestEmail(Quote $quote, $email) { $quote->setCustomerEmail($email); $quote->getCustomer()->setEmail($email); $quote->getBillingAddress()->setEmail($email); }
php
protected function assignGuestEmail(Quote $quote, $email) { $quote->setCustomerEmail($email); $quote->getCustomer()->setEmail($email); $quote->getBillingAddress()->setEmail($email); }
[ "protected", "function", "assignGuestEmail", "(", "Quote", "$", "quote", ",", "$", "email", ")", "{", "$", "quote", "->", "setCustomerEmail", "(", "$", "email", ")", ";", "$", "quote", "->", "getCustomer", "(", ")", "->", "setEmail", "(", "$", "email", ...
Assigns the given email to the provided quote instance. @param Quote $quote @param $email
[ "Assigns", "the", "given", "email", "to", "the", "provided", "quote", "instance", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Controller/Payment/AbstractAction.php#L84-L88
43,187
checkout/checkout-magento2-plugin
Gateway/Http/Client/AbstractTransaction.php
AbstractTransaction.placeRequest
public function placeRequest(TransferInterface $transferObject) { if ($this->gatewayResponseHolder->hasCallbackResponse()) { $response = $this->gatewayResponseHolder->getGatewayResponse(); $this->logger->debug([ 'action' => 'callback', 'response' => $response, ]); return $response; } // Prepare the transfert data $this->prepareTransfer($transferObject); // Update the email field for guest users $this->updateGuestEmail($this->body); // Prepare some log data $log = [ 'request' => $this->body, 'request_uri' => $this->fullUri, 'request_headers' => $transferObject->getHeaders(), 'request_method' => $this->getMethod(), ]; $result = []; $client = $this->clientFactory; $client->setConfig($transferObject->getClientConfig()); $client->setMethod($this->getMethod()); switch($this->getMethod()) { case \Zend_Http_Client::GET: $client->setRawData( json_encode($this->body) ) ; break; case \Zend_Http_Client::POST: $client->setRawData( json_encode($this->body) ) ; break; default: throw new \LogicException( sprintf('Unsupported HTTP method %s', $transferObject->getMethod()) ); } $client->setHeaders($transferObject->getHeaders()); $client->setUri($this->fullUri); try { $response = $client->request(); $result = json_decode($response->getBody(), true); $log['response'] = $result; if( array_key_exists('errorCode', $result) ) { $exception = new ApiClientException($result['message'], $result['errorCode'], $result['eventId']); $this->messageManager->addErrorMessage( $exception->getFullMessage() ); throw $exception; } } catch (Zend_Http_Client_Exception $e) { throw new ClientException(__($e->getMessage())); } finally { $this->logger->debug($log); } return $result; }
php
public function placeRequest(TransferInterface $transferObject) { if ($this->gatewayResponseHolder->hasCallbackResponse()) { $response = $this->gatewayResponseHolder->getGatewayResponse(); $this->logger->debug([ 'action' => 'callback', 'response' => $response, ]); return $response; } // Prepare the transfert data $this->prepareTransfer($transferObject); // Update the email field for guest users $this->updateGuestEmail($this->body); // Prepare some log data $log = [ 'request' => $this->body, 'request_uri' => $this->fullUri, 'request_headers' => $transferObject->getHeaders(), 'request_method' => $this->getMethod(), ]; $result = []; $client = $this->clientFactory; $client->setConfig($transferObject->getClientConfig()); $client->setMethod($this->getMethod()); switch($this->getMethod()) { case \Zend_Http_Client::GET: $client->setRawData( json_encode($this->body) ) ; break; case \Zend_Http_Client::POST: $client->setRawData( json_encode($this->body) ) ; break; default: throw new \LogicException( sprintf('Unsupported HTTP method %s', $transferObject->getMethod()) ); } $client->setHeaders($transferObject->getHeaders()); $client->setUri($this->fullUri); try { $response = $client->request(); $result = json_decode($response->getBody(), true); $log['response'] = $result; if( array_key_exists('errorCode', $result) ) { $exception = new ApiClientException($result['message'], $result['errorCode'], $result['eventId']); $this->messageManager->addErrorMessage( $exception->getFullMessage() ); throw $exception; } } catch (Zend_Http_Client_Exception $e) { throw new ClientException(__($e->getMessage())); } finally { $this->logger->debug($log); } return $result; }
[ "public", "function", "placeRequest", "(", "TransferInterface", "$", "transferObject", ")", "{", "if", "(", "$", "this", "->", "gatewayResponseHolder", "->", "hasCallbackResponse", "(", ")", ")", "{", "$", "response", "=", "$", "this", "->", "gatewayResponseHold...
Places request to gateway. Returns result as ENV array @param TransferInterface $transferObject @return array @throws ClientException @throws ApiClientException @throws Zend_Http_Client_Exception @throws \LogicException
[ "Places", "request", "to", "gateway", ".", "Returns", "result", "as", "ENV", "array" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Http/Client/AbstractTransaction.php#L117-L187
43,188
checkout/checkout-magento2-plugin
Gateway/Http/Client/AbstractTransaction.php
AbstractTransaction.prepareTransfer
protected function prepareTransfer(TransferInterface $transferObject) { $uri = $this->getUri(); $body = $transferObject->getBody(); if( array_key_exists('chargeId', $body) ) { $uri = str_replace('{chargeId}', $body['chargeId'], $uri); unset($body['chargeId']); } $this->fullUri = $transferObject->getUri() . $uri; $this->body = $body; }
php
protected function prepareTransfer(TransferInterface $transferObject) { $uri = $this->getUri(); $body = $transferObject->getBody(); if( array_key_exists('chargeId', $body) ) { $uri = str_replace('{chargeId}', $body['chargeId'], $uri); unset($body['chargeId']); } $this->fullUri = $transferObject->getUri() . $uri; $this->body = $body; }
[ "protected", "function", "prepareTransfer", "(", "TransferInterface", "$", "transferObject", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", ")", ";", "$", "body", "=", "$", "transferObject", "->", "getBody", "(", ")", ";", "if", "(", "array...
Prepares the URI and body based on the given transfer object. @param TransferInterface $transferObject
[ "Prepares", "the", "URI", "and", "body", "based", "on", "the", "given", "transfer", "object", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Http/Client/AbstractTransaction.php#L209-L221
43,189
checkout/checkout-magento2-plugin
Model/Adapter/CcTypeAdapter.php
CcTypeAdapter.getFromGateway
public function getFromGateway($type) { $mapper = $this->config->getCcTypesMapper(); $type = strtolower($type); if( array_key_exists($type, $mapper) ) { return $mapper[$type]; } return 'OT'; }
php
public function getFromGateway($type) { $mapper = $this->config->getCcTypesMapper(); $type = strtolower($type); if( array_key_exists($type, $mapper) ) { return $mapper[$type]; } return 'OT'; }
[ "public", "function", "getFromGateway", "(", "$", "type", ")", "{", "$", "mapper", "=", "$", "this", "->", "config", "->", "getCcTypesMapper", "(", ")", ";", "$", "type", "=", "strtolower", "(", "$", "type", ")", ";", "if", "(", "array_key_exists", "("...
Returns Credit Card type for a store. @param string $type @return string
[ "Returns", "Credit", "Card", "type", "for", "a", "store", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/CcTypeAdapter.php#L36-L45
43,190
checkout/checkout-magento2-plugin
Model/Adminhtml/Source/GooglePayNetworks.php
GooglePayNetworks.toOptionArray
public function toOptionArray() { return [ [ 'value' => self::CARD_VISA, 'label' => __('Visa') ], [ 'value' => self::CARD_MASTERCARD, 'label' => __('Mastercard') ], [ 'value' => self::CARD_AMEX, 'label' => __('American Express') ], [ 'value' => self::CARD_JCB, 'label' => __('JCB') ], [ 'value' => self::CARD_DISCOVER, 'label' => __('Discover') ], ]; }
php
public function toOptionArray() { return [ [ 'value' => self::CARD_VISA, 'label' => __('Visa') ], [ 'value' => self::CARD_MASTERCARD, 'label' => __('Mastercard') ], [ 'value' => self::CARD_AMEX, 'label' => __('American Express') ], [ 'value' => self::CARD_JCB, 'label' => __('JCB') ], [ 'value' => self::CARD_DISCOVER, 'label' => __('Discover') ], ]; }
[ "public", "function", "toOptionArray", "(", ")", "{", "return", "[", "[", "'value'", "=>", "self", "::", "CARD_VISA", ",", "'label'", "=>", "__", "(", "'Visa'", ")", "]", ",", "[", "'value'", "=>", "self", "::", "CARD_MASTERCARD", ",", "'label'", "=>", ...
Possible Google Pay Cards @return array
[ "Possible", "Google", "Pay", "Cards" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adminhtml/Source/GooglePayNetworks.php#L28-L51
43,191
checkout/checkout-magento2-plugin
Gateway/Command/WebHookCommand.php
WebHookCommand.execute
public function execute(array $commandSubject) { $response = $this->gatewayResponseHolder->getGatewayResponse(); $this->handler->handle($commandSubject, $response); }
php
public function execute(array $commandSubject) { $response = $this->gatewayResponseHolder->getGatewayResponse(); $this->handler->handle($commandSubject, $response); }
[ "public", "function", "execute", "(", "array", "$", "commandSubject", ")", "{", "$", "response", "=", "$", "this", "->", "gatewayResponseHolder", "->", "getGatewayResponse", "(", ")", ";", "$", "this", "->", "handler", "->", "handle", "(", "$", "commandSubje...
Executes command basing on business object @param array $commandSubject @return null|Command\ResultInterface @throws CommandException
[ "Executes", "command", "basing", "on", "business", "object" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Command/WebHookCommand.php#L48-L52
43,192
checkout/checkout-magento2-plugin
Observer/OrderCancelObserver.php
OrderCancelObserver.execute
public function execute(Observer $observer) { // Get the order $order = $observer->getEvent()->getOrder(); // Get the payment method $paymentMethod = $order->getPayment()->getMethod(); // Test the current method used if ($paymentMethod == ConfigProvider::CODE || $paymentMethod == ConfigProvider::CC_VAULT_CODE || $paymentMethod == ConfigProvider::THREE_DS_CODE) { // Update the hub API for cancelled order $this->orderService->cancelTransactionToRemote($order); } return $this; }
php
public function execute(Observer $observer) { // Get the order $order = $observer->getEvent()->getOrder(); // Get the payment method $paymentMethod = $order->getPayment()->getMethod(); // Test the current method used if ($paymentMethod == ConfigProvider::CODE || $paymentMethod == ConfigProvider::CC_VAULT_CODE || $paymentMethod == ConfigProvider::THREE_DS_CODE) { // Update the hub API for cancelled order $this->orderService->cancelTransactionToRemote($order); } return $this; }
[ "public", "function", "execute", "(", "Observer", "$", "observer", ")", "{", "// Get the order", "$", "order", "=", "$", "observer", "->", "getEvent", "(", ")", "->", "getOrder", "(", ")", ";", "// Get the payment method", "$", "paymentMethod", "=", "$", "or...
Handles the observer for order cancellation. @param Observer $observer @return void
[ "Handles", "the", "observer", "for", "order", "cancellation", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Observer/OrderCancelObserver.php#L35-L51
43,193
checkout/checkout-magento2-plugin
Block/Form.php
Form.isVaultEnabled
public function isVaultEnabled() { $storeId = $this->_storeManager->getStore()->getId(); $vaultPayment = $this->getVaultPayment(); return $vaultPayment->isActive($storeId); }
php
public function isVaultEnabled() { $storeId = $this->_storeManager->getStore()->getId(); $vaultPayment = $this->getVaultPayment(); return $vaultPayment->isActive($storeId); }
[ "public", "function", "isVaultEnabled", "(", ")", "{", "$", "storeId", "=", "$", "this", "->", "_storeManager", "->", "getStore", "(", ")", "->", "getId", "(", ")", ";", "$", "vaultPayment", "=", "$", "this", "->", "getVaultPayment", "(", ")", ";", "re...
Determines if the gateway supports CC store for later use. @return bool
[ "Determines", "if", "the", "gateway", "supports", "CC", "store", "for", "later", "use", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Form.php#L64-L69
43,194
checkout/checkout-magento2-plugin
Block/Form.php
Form.getPaymentDataHelper
private function getPaymentDataHelper() { if ($this->paymentDataHelper === null) { $this->paymentDataHelper = ObjectManager::getInstance()->get(Data::class); } return $this->paymentDataHelper; }
php
private function getPaymentDataHelper() { if ($this->paymentDataHelper === null) { $this->paymentDataHelper = ObjectManager::getInstance()->get(Data::class); } return $this->paymentDataHelper; }
[ "private", "function", "getPaymentDataHelper", "(", ")", "{", "if", "(", "$", "this", "->", "paymentDataHelper", "===", "null", ")", "{", "$", "this", "->", "paymentDataHelper", "=", "ObjectManager", "::", "getInstance", "(", ")", "->", "get", "(", "Data", ...
Returns payment data helper instance. @return Data @throws \RuntimeException
[ "Returns", "payment", "data", "helper", "instance", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Form.php#L87-L92
43,195
checkout/checkout-magento2-plugin
Gateway/Http/TransferFactory.php
TransferFactory.create
public function create(array $request) { $headers = self::$headers; $headers['Authorization'] = $this->config->getSecretKey(); return $this->transferBuilder ->setClientConfig(self::$clientConfig) ->setHeaders($headers) ->setUri($this->config->getApiUrl()) ->setBody($request) ->build(); }
php
public function create(array $request) { $headers = self::$headers; $headers['Authorization'] = $this->config->getSecretKey(); return $this->transferBuilder ->setClientConfig(self::$clientConfig) ->setHeaders($headers) ->setUri($this->config->getApiUrl()) ->setBody($request) ->build(); }
[ "public", "function", "create", "(", "array", "$", "request", ")", "{", "$", "headers", "=", "self", "::", "$", "headers", ";", "$", "headers", "[", "'Authorization'", "]", "=", "$", "this", "->", "config", "->", "getSecretKey", "(", ")", ";", "return"...
Builds gateway transfer object @param array $request @return TransferInterface
[ "Builds", "gateway", "transfer", "object" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Http/TransferFactory.php#L61-L72
43,196
checkout/checkout-magento2-plugin
Controller/Adminhtml/Subscription/AddRow.php
AddRow.execute
public function execute() { $rowId = (int) $this->getRequest()->getParam('id'); $rowData = $this->_objectManager->create('CheckoutCom\Magento2\Model\Subscription'); if ($rowId) { $rowData = $rowData->load($rowId); $rowTitle = $rowData->getTitle(); if (!$rowData->getEntityId()) { $this->messageManager->addError(__('This item no longer exists.')); $this->_redirect('checkout_com/subscription/rowdata'); return; } } $this->_coreRegistry->register('row_data', $rowData); $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); $title = $rowId ? __('Edit Item').$rowTitle : __('Add New Item'); $resultPage->getConfig()->getTitle()->prepend($title); return $resultPage; }
php
public function execute() { $rowId = (int) $this->getRequest()->getParam('id'); $rowData = $this->_objectManager->create('CheckoutCom\Magento2\Model\Subscription'); if ($rowId) { $rowData = $rowData->load($rowId); $rowTitle = $rowData->getTitle(); if (!$rowData->getEntityId()) { $this->messageManager->addError(__('This item no longer exists.')); $this->_redirect('checkout_com/subscription/rowdata'); return; } } $this->_coreRegistry->register('row_data', $rowData); $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); $title = $rowId ? __('Edit Item').$rowTitle : __('Add New Item'); $resultPage->getConfig()->getTitle()->prepend($title); return $resultPage; }
[ "public", "function", "execute", "(", ")", "{", "$", "rowId", "=", "(", "int", ")", "$", "this", "->", "getRequest", "(", ")", "->", "getParam", "(", "'id'", ")", ";", "$", "rowData", "=", "$", "this", "->", "_objectManager", "->", "create", "(", "...
Add New Row Form page. @return \Magento\Backend\Model\View\Result\Page
[ "Add", "New", "Row", "Form", "page", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Controller/Adminhtml/Subscription/AddRow.php#L34-L53
43,197
checkout/checkout-magento2-plugin
Helper/Helper.php
Helper.getModuleVersion
public function getModuleVersion() { // Get the module path $module_path = $this->directoryReader->getModuleDir('', 'CheckoutCom_Magento2'); // Get the content of composer.json $json = file_get_contents($module_path . '/composer.json'); // Decode the data and return $data = json_decode($json); return $data->version; }
php
public function getModuleVersion() { // Get the module path $module_path = $this->directoryReader->getModuleDir('', 'CheckoutCom_Magento2'); // Get the content of composer.json $json = file_get_contents($module_path . '/composer.json'); // Decode the data and return $data = json_decode($json); return $data->version; }
[ "public", "function", "getModuleVersion", "(", ")", "{", "// Get the module path", "$", "module_path", "=", "$", "this", "->", "directoryReader", "->", "getModuleDir", "(", "''", ",", "'CheckoutCom_Magento2'", ")", ";", "// Get the content of composer.json", "$", "jso...
Get the module version from composer.json file
[ "Get", "the", "module", "version", "from", "composer", ".", "json", "file" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Helper/Helper.php#L66-L77
43,198
checkout/checkout-magento2-plugin
Helper/Helper.php
Helper.isMadaBin
public function isMadaBin($bin) { // Set the root path $csvPath = $this->directoryReader->getModuleDir('', 'CheckoutCom_Magento2') . '/' . $this->config->getMadaBinsPath(); // Get the data $csvData = $this->csvParser->getData($csvPath); // Remove the first row of csv columns unset($csvData[0]); // Build the MADA BIN array $binArray = []; foreach ($csvData as $row) { $binArray[] = $row[1]; } return in_array($bin, $binArray); }
php
public function isMadaBin($bin) { // Set the root path $csvPath = $this->directoryReader->getModuleDir('', 'CheckoutCom_Magento2') . '/' . $this->config->getMadaBinsPath(); // Get the data $csvData = $this->csvParser->getData($csvPath); // Remove the first row of csv columns unset($csvData[0]); // Build the MADA BIN array $binArray = []; foreach ($csvData as $row) { $binArray[] = $row[1]; } return in_array($bin, $binArray); }
[ "public", "function", "isMadaBin", "(", "$", "bin", ")", "{", "// Set the root path", "$", "csvPath", "=", "$", "this", "->", "directoryReader", "->", "getModuleDir", "(", "''", ",", "'CheckoutCom_Magento2'", ")", ".", "'/'", ".", "$", "this", "->", "config"...
Checks the MADA BIN @return bool
[ "Checks", "the", "MADA", "BIN" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Helper/Helper.php#L84-L101
43,199
checkout/checkout-magento2-plugin
Helper/Helper.php
Helper.prepareGuestQuote
public function prepareGuestQuote($quote, $email = null) { // Retrieve the user email $guestEmail = $email ?? $this->customerSession->getData('checkoutSessionData')['customerEmail'] ?? $quote->getCustomerEmail() ?? $quote->getBillingAddress()->getEmail() ?? $this->cookieManager->getCookie(self::EMAIL_COOKIE_NAME); // Set the quote as guest $quote->setCustomerId(null) ->setCustomerEmail($guestEmail) ->setCustomerIsGuest(true) ->setCustomerGroupId(GroupInterface::NOT_LOGGED_IN_ID); // Delete the cookie $this->cookieManager->deleteCookie(self::EMAIL_COOKIE_NAME); return $quote; }
php
public function prepareGuestQuote($quote, $email = null) { // Retrieve the user email $guestEmail = $email ?? $this->customerSession->getData('checkoutSessionData')['customerEmail'] ?? $quote->getCustomerEmail() ?? $quote->getBillingAddress()->getEmail() ?? $this->cookieManager->getCookie(self::EMAIL_COOKIE_NAME); // Set the quote as guest $quote->setCustomerId(null) ->setCustomerEmail($guestEmail) ->setCustomerIsGuest(true) ->setCustomerGroupId(GroupInterface::NOT_LOGGED_IN_ID); // Delete the cookie $this->cookieManager->deleteCookie(self::EMAIL_COOKIE_NAME); return $quote; }
[ "public", "function", "prepareGuestQuote", "(", "$", "quote", ",", "$", "email", "=", "null", ")", "{", "// Retrieve the user email ", "$", "guestEmail", "=", "$", "email", "??", "$", "this", "->", "customerSession", "->", "getData", "(", "'checkoutSessionData'"...
Sets the email for guest users @return bool
[ "Sets", "the", "email", "for", "guest", "users" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Helper/Helper.php#L108-L126