repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
adminarchitect/core
publishes/Dashboard/Factory.php
Factory.registerPanels
protected function registerPanels() { $this->dashboard ->row(function (DashboardRow $row) { $row->panel(new BlankPanel())->setWidth(12); }) // ->row(function (DashboardRow $row) { // $row->panel(new GoogleAnalyticsPanel)->setWidth(12); // }) ->row(function (DashboardRow $row) { $row->panel(new MembersPanel())->setWidth(6); $row->panel(new DatabasePanel())->setWidth(6); }); return $this->dashboard; }
php
protected function registerPanels() { $this->dashboard ->row(function (DashboardRow $row) { $row->panel(new BlankPanel())->setWidth(12); }) // ->row(function (DashboardRow $row) { // $row->panel(new GoogleAnalyticsPanel)->setWidth(12); // }) ->row(function (DashboardRow $row) { $row->panel(new MembersPanel())->setWidth(6); $row->panel(new DatabasePanel())->setWidth(6); }); return $this->dashboard; }
[ "protected", "function", "registerPanels", "(", ")", "{", "$", "this", "->", "dashboard", "->", "row", "(", "function", "(", "DashboardRow", "$", "row", ")", "{", "$", "row", "->", "panel", "(", "new", "BlankPanel", "(", ")", ")", "->", "setWidth", "("...
Register dashboard panels. @return Manager
[ "Register", "dashboard", "panels", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/publishes/Dashboard/Factory.php#L16-L31
train
adminarchitect/core
src/Services/CrudActions.php
CrudActions.batchActions
public function batchActions() { $actions = [RemoveSelected::class]; if ($this->module->model() instanceof Rankable) { array_push($actions, SaveOrder::class); } return $actions; }
php
public function batchActions() { $actions = [RemoveSelected::class]; if ($this->module->model() instanceof Rankable) { array_push($actions, SaveOrder::class); } return $actions; }
[ "public", "function", "batchActions", "(", ")", "{", "$", "actions", "=", "[", "RemoveSelected", "::", "class", "]", ";", "if", "(", "$", "this", "->", "module", "->", "model", "(", ")", "instanceof", "Rankable", ")", "{", "array_push", "(", "$", "acti...
Default list of batch actions. @return array
[ "Default", "list", "of", "batch", "actions", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Services/CrudActions.php#L48-L57
train
adminarchitect/core
src/Services/CrudActions.php
CrudActions.save
public function save($eloquent, UpdateRequest $request) { $saver = app('scaffold.module')->saver(); $saver = new $saver($eloquent, $request); if (!$saver instanceof Saver) { throw new Exception('Saver must implement '.Saver::class.' contract'); } return $saver->sync(); }
php
public function save($eloquent, UpdateRequest $request) { $saver = app('scaffold.module')->saver(); $saver = new $saver($eloquent, $request); if (!$saver instanceof Saver) { throw new Exception('Saver must implement '.Saver::class.' contract'); } return $saver->sync(); }
[ "public", "function", "save", "(", "$", "eloquent", ",", "UpdateRequest", "$", "request", ")", "{", "$", "saver", "=", "app", "(", "'scaffold.module'", ")", "->", "saver", "(", ")", ";", "$", "saver", "=", "new", "$", "saver", "(", "$", "eloquent", "...
Update item callback. @param $eloquent @param UpdateRequest $request @throws Exception @return string @internal param $repository
[ "Update", "item", "callback", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Services/CrudActions.php#L71-L81
train
adminarchitect/core
src/Services/CrudActions.php
CrudActions.detachFile
public function detachFile(Model $item, $attachment) { try { $item->$attachment = Attachment::NULL_ATTACHMENT; $item->save(); return true; } catch (\Exception $e) { return false; } }
php
public function detachFile(Model $item, $attachment) { try { $item->$attachment = Attachment::NULL_ATTACHMENT; $item->save(); return true; } catch (\Exception $e) { return false; } }
[ "public", "function", "detachFile", "(", "Model", "$", "item", ",", "$", "attachment", ")", "{", "try", "{", "$", "item", "->", "$", "attachment", "=", "Attachment", "::", "NULL_ATTACHMENT", ";", "$", "item", "->", "save", "(", ")", ";", "return", "tru...
Destroy an attachment. @param $item @param $attachment @return bool
[ "Destroy", "an", "attachment", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Services/CrudActions.php#L91-L101
train
adminarchitect/core
src/Services/CrudActions.php
CrudActions.delete
public function delete(Model $item) { if (method_exists($item, 'trashed') && $item->trashed()) { return $item->forceDelete(); } return $item->delete(); }
php
public function delete(Model $item) { if (method_exists($item, 'trashed') && $item->trashed()) { return $item->forceDelete(); } return $item->delete(); }
[ "public", "function", "delete", "(", "Model", "$", "item", ")", "{", "if", "(", "method_exists", "(", "$", "item", ",", "'trashed'", ")", "&&", "$", "item", "->", "trashed", "(", ")", ")", "{", "return", "$", "item", "->", "forceDelete", "(", ")", ...
Destroy item callback. @param Model $item @throws \Exception @return string
[ "Destroy", "item", "callback", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Services/CrudActions.php#L112-L119
train
adminarchitect/core
src/Form/Element.php
Element.setAttributes
public function setAttributes(array $attributes = []) { $this->attributes = array_merge($this->attributes, $attributes); $this->validateAttributes(); $this->decoupleOptionsFromAttributes(); return $this; }
php
public function setAttributes(array $attributes = []) { $this->attributes = array_merge($this->attributes, $attributes); $this->validateAttributes(); $this->decoupleOptionsFromAttributes(); return $this; }
[ "public", "function", "setAttributes", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "this", "->", "attributes", "=", "array_merge", "(", "$", "this", "->", "attributes", ",", "$", "attributes", ")", ";", "$", "this", "->", "validateAttr...
Init element from set of attributes. @param array $attributes @return $this
[ "Init", "element", "from", "set", "of", "attributes", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Form/Element.php#L58-L67
train
adminarchitect/core
src/Collection/Mutable.php
Mutable.insert
public function insert($element, $position, Closure $callback = null): self { $element = $this->createElement($element); if ($callback) { $callback($element); } if (is_string($position)) { $this->push($element); return $this->move($element->id(), $position); } if ($position >= $this->count()) { return $this->push($element); } if (0 === $position) { return $this->prepend($element); } $items = []; foreach ($this->all() as $index => $value) { if ($index === $position) { array_push($items, $element); } array_push($items, $value); } $this->items = $items; return $this; }
php
public function insert($element, $position, Closure $callback = null): self { $element = $this->createElement($element); if ($callback) { $callback($element); } if (is_string($position)) { $this->push($element); return $this->move($element->id(), $position); } if ($position >= $this->count()) { return $this->push($element); } if (0 === $position) { return $this->prepend($element); } $items = []; foreach ($this->all() as $index => $value) { if ($index === $position) { array_push($items, $element); } array_push($items, $value); } $this->items = $items; return $this; }
[ "public", "function", "insert", "(", "$", "element", ",", "$", "position", ",", "Closure", "$", "callback", "=", "null", ")", ":", "self", "{", "$", "element", "=", "$", "this", "->", "createElement", "(", "$", "element", ")", ";", "if", "(", "$", ...
Insert an element into collection at specified position. @param $element @param $position @param null|Closure $callback @return $this
[ "Insert", "an", "element", "into", "collection", "at", "specified", "position", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Collection/Mutable.php#L63-L96
train
adminarchitect/core
src/Collection/Mutable.php
Mutable.update
public function update(string $id, Closure $callback): self { if (str_contains($id, ',')) { collect(explode(',', $id)) ->map('trim') ->each(function ($element) use ($callback) { $this->update($element, $callback); }); return $this; } $element = $this->find($id); if ($element && $callback) { $callback($element); } return $this; }
php
public function update(string $id, Closure $callback): self { if (str_contains($id, ',')) { collect(explode(',', $id)) ->map('trim') ->each(function ($element) use ($callback) { $this->update($element, $callback); }); return $this; } $element = $this->find($id); if ($element && $callback) { $callback($element); } return $this; }
[ "public", "function", "update", "(", "string", "$", "id", ",", "Closure", "$", "callback", ")", ":", "self", "{", "if", "(", "str_contains", "(", "$", "id", ",", "','", ")", ")", "{", "collect", "(", "explode", "(", "','", ",", "$", "id", ")", ")...
Update elements behaviour. @param string $id @param Closure $callback @return $this
[ "Update", "elements", "behaviour", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Collection/Mutable.php#L143-L162
train
adminarchitect/core
src/Collection/Mutable.php
Mutable.updateMany
public function updateMany(array $ids = []): self { foreach ($ids as $id => $callback) { $this->update($id, $callback); } return $this; }
php
public function updateMany(array $ids = []): self { foreach ($ids as $id => $callback) { $this->update($id, $callback); } return $this; }
[ "public", "function", "updateMany", "(", "array", "$", "ids", "=", "[", "]", ")", ":", "self", "{", "foreach", "(", "$", "ids", "as", "$", "id", "=>", "$", "callback", ")", "{", "$", "this", "->", "update", "(", "$", "id", ",", "$", "callback", ...
Update many elements at once. @param $ids @return $this
[ "Update", "many", "elements", "at", "once", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Collection/Mutable.php#L171-L178
train
adminarchitect/core
src/Collection/Mutable.php
Mutable.moveBefore
public function moveBefore(string $id, $target) { if ($element = $this->find($id)) { $this->without($id); $targetPosition = $this->position($target); if ($targetPosition >= 0) { $this->insert($element, $targetPosition)->all(); } } return $this; }
php
public function moveBefore(string $id, $target) { if ($element = $this->find($id)) { $this->without($id); $targetPosition = $this->position($target); if ($targetPosition >= 0) { $this->insert($element, $targetPosition)->all(); } } return $this; }
[ "public", "function", "moveBefore", "(", "string", "$", "id", ",", "$", "target", ")", "{", "if", "(", "$", "element", "=", "$", "this", "->", "find", "(", "$", "id", ")", ")", "{", "$", "this", "->", "without", "(", "$", "id", ")", ";", "$", ...
Move element before another one. @param string $id @param $target @return $this
[ "Move", "element", "before", "another", "one", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Collection/Mutable.php#L219-L231
train
adminarchitect/core
src/Collection/Mutable.php
Mutable.moveAfter
public function moveAfter(string $id, $target): self { if ($element = $this->find($id)) { $this->without($id); $targetPosition = $this->position($target); if ($targetPosition >= 0) { $this->insert($element, $targetPosition + 1)->all(); } } return $this; }
php
public function moveAfter(string $id, $target): self { if ($element = $this->find($id)) { $this->without($id); $targetPosition = $this->position($target); if ($targetPosition >= 0) { $this->insert($element, $targetPosition + 1)->all(); } } return $this; }
[ "public", "function", "moveAfter", "(", "string", "$", "id", ",", "$", "target", ")", ":", "self", "{", "if", "(", "$", "element", "=", "$", "this", "->", "find", "(", "$", "id", ")", ")", "{", "$", "this", "->", "without", "(", "$", "id", ")",...
Move element after another one. @param string $id @param $target @return $this
[ "Move", "element", "after", "another", "one", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Collection/Mutable.php#L241-L254
train
adminarchitect/core
src/Collection/Mutable.php
Mutable.group
public function group(string $id, Closure $callback): self { $group = new Group($id); $callback($group); $this->push($group); return $this; }
php
public function group(string $id, Closure $callback): self { $group = new Group($id); $callback($group); $this->push($group); return $this; }
[ "public", "function", "group", "(", "string", "$", "id", ",", "Closure", "$", "callback", ")", ":", "self", "{", "$", "group", "=", "new", "Group", "(", "$", "id", ")", ";", "$", "callback", "(", "$", "group", ")", ";", "$", "this", "->", "push",...
Add a new elements group. @param string $id @param Closure $callback @return $this
[ "Add", "a", "new", "elements", "group", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Collection/Mutable.php#L264-L273
train
adminarchitect/core
src/Collection/Mutable.php
Mutable.stack
public function stack($elements, $groupId, $position = null): self { $group = new Group($groupId); $this->filter(function ($element) use ($elements) { return in_array($element->id(), $elements, true); })->each(function ($element) use ($group) { $group->push($element); $this->items = $this->without($element->id())->all(); }); if ($position) { $this->insert($group, $position); } else { $this->push($group); } return $this; }
php
public function stack($elements, $groupId, $position = null): self { $group = new Group($groupId); $this->filter(function ($element) use ($elements) { return in_array($element->id(), $elements, true); })->each(function ($element) use ($group) { $group->push($element); $this->items = $this->without($element->id())->all(); }); if ($position) { $this->insert($group, $position); } else { $this->push($group); } return $this; }
[ "public", "function", "stack", "(", "$", "elements", ",", "$", "groupId", ",", "$", "position", "=", "null", ")", ":", "self", "{", "$", "group", "=", "new", "Group", "(", "$", "groupId", ")", ";", "$", "this", "->", "filter", "(", "function", "(",...
Join existing elements to a group. @param $elements @param $groupId @param null $position @return $this
[ "Join", "existing", "elements", "to", "a", "group", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Collection/Mutable.php#L284-L302
train
adminarchitect/core
src/Collection/Mutable.php
Mutable.build
public function build($decorator) { return $this->map(function ($element) use ($decorator) { if ($element instanceof Group) { $element->map(function ($e) use ($decorator) { return $decorator->makeElement($e); }); return $element; } return $decorator->makeElement($element); }); }
php
public function build($decorator) { return $this->map(function ($element) use ($decorator) { if ($element instanceof Group) { $element->map(function ($e) use ($decorator) { return $decorator->makeElement($e); }); return $element; } return $decorator->makeElement($element); }); }
[ "public", "function", "build", "(", "$", "decorator", ")", "{", "return", "$", "this", "->", "map", "(", "function", "(", "$", "element", ")", "use", "(", "$", "decorator", ")", "{", "if", "(", "$", "element", "instanceof", "Group", ")", "{", "$", ...
Build a collection. @param $decorator @return static
[ "Build", "a", "collection", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Collection/Mutable.php#L311-L324
train
adminarchitect/core
src/Collection/Mutable.php
Mutable.position
public function position(string $id): int { $i = 0; foreach ($this->all() as $item) { if ($item->id() === $id) { return $i; } ++$i; } return $this->notFound($id); }
php
public function position(string $id): int { $i = 0; foreach ($this->all() as $item) { if ($item->id() === $id) { return $i; } ++$i; } return $this->notFound($id); }
[ "public", "function", "position", "(", "string", "$", "id", ")", ":", "int", "{", "$", "i", "=", "0", ";", "foreach", "(", "$", "this", "->", "all", "(", ")", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "id", "(", ")", "===", ...
Find an element position. @param string $id @return null|int|string
[ "Find", "an", "element", "position", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Collection/Mutable.php#L353-L365
train
adminarchitect/core
src/Collection/Mutable.php
Mutable.toPosition
protected function toPosition(string $id, $position): self { $element = $this->find($id); return $this ->without($id) ->insert($element, $position); }
php
protected function toPosition(string $id, $position): self { $element = $this->find($id); return $this ->without($id) ->insert($element, $position); }
[ "protected", "function", "toPosition", "(", "string", "$", "id", ",", "$", "position", ")", ":", "self", "{", "$", "element", "=", "$", "this", "->", "find", "(", "$", "id", ")", ";", "return", "$", "this", "->", "without", "(", "$", "id", ")", "...
Move an element to a position. @param string $id @param $position @return static
[ "Move", "an", "element", "to", "a", "position", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Collection/Mutable.php#L375-L382
train
adminarchitect/core
src/Controllers/BatchController.php
BatchController.batch
public function batch($page, Request $request) { $this->authorize($action = $request->get('batch_action'), $model = app('scaffold.module')->model()); $response = app('scaffold.actions')->exec('batch::'.$action, [$model, $request]); if ($response instanceof Response || $response instanceof Renderable) { return $response; } return back()->with( 'messages', [trans('administrator::messages.action_success')] ); }
php
public function batch($page, Request $request) { $this->authorize($action = $request->get('batch_action'), $model = app('scaffold.module')->model()); $response = app('scaffold.actions')->exec('batch::'.$action, [$model, $request]); if ($response instanceof Response || $response instanceof Renderable) { return $response; } return back()->with( 'messages', [trans('administrator::messages.action_success')] ); }
[ "public", "function", "batch", "(", "$", "page", ",", "Request", "$", "request", ")", "{", "$", "this", "->", "authorize", "(", "$", "action", "=", "$", "request", "->", "get", "(", "'batch_action'", ")", ",", "$", "model", "=", "app", "(", "'scaffol...
Perform a batch action against selected collection. @param $page @param Request $request @return \Illuminate\Http\RedirectResponse
[ "Perform", "a", "batch", "action", "against", "selected", "collection", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Controllers/BatchController.php#L19-L33
train
adminarchitect/core
src/Controllers/BatchController.php
BatchController.export
public function export($page, $format) { $this->authorize('index', app('scaffold.module')->model()); $query = app('scaffold.finder')->getQuery(); return app('scaffold.actions')->exec('export', [$query, $format]); }
php
public function export($page, $format) { $this->authorize('index', app('scaffold.module')->model()); $query = app('scaffold.finder')->getQuery(); return app('scaffold.actions')->exec('export', [$query, $format]); }
[ "public", "function", "export", "(", "$", "page", ",", "$", "format", ")", "{", "$", "this", "->", "authorize", "(", "'index'", ",", "app", "(", "'scaffold.module'", ")", "->", "model", "(", ")", ")", ";", "$", "query", "=", "app", "(", "'scaffold.fi...
Export collection. @param $page @param $format @return mixed
[ "Export", "collection", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Controllers/BatchController.php#L43-L50
train
adminarchitect/core
src/Traits/SortsObjectsCollection.php
SortsObjectsCollection.sortCollection
protected function sortCollection($objects) { $class = false; if ($objects instanceof Arrayable) { $class = get_class($objects); $objects = $objects->toArray(); } usort($objects, function ($aObj, $bObj) { list($aRank, $bRank) = $this->getRanks($aObj, $bObj); if ($this->equals($aRank, $bRank)) { return $this->sortByName($aObj, $bObj); } return $this->sortByValue($aRank, $bRank); }); return $class ? $class::make($objects) : $objects; }
php
protected function sortCollection($objects) { $class = false; if ($objects instanceof Arrayable) { $class = get_class($objects); $objects = $objects->toArray(); } usort($objects, function ($aObj, $bObj) { list($aRank, $bRank) = $this->getRanks($aObj, $bObj); if ($this->equals($aRank, $bRank)) { return $this->sortByName($aObj, $bObj); } return $this->sortByValue($aRank, $bRank); }); return $class ? $class::make($objects) : $objects; }
[ "protected", "function", "sortCollection", "(", "$", "objects", ")", "{", "$", "class", "=", "false", ";", "if", "(", "$", "objects", "instanceof", "Arrayable", ")", "{", "$", "class", "=", "get_class", "(", "$", "objects", ")", ";", "$", "objects", "=...
Sort collection of objects by order or class name. @param $objects @return array
[ "Sort", "collection", "of", "objects", "by", "order", "or", "class", "name", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Traits/SortsObjectsCollection.php#L16-L37
train
adminarchitect/core
src/Traits/LoopsOverRelations.php
LoopsOverRelations.fetchRelationValue
protected function fetchRelationValue($eloquent, $name, array $relations = [], $format = false) { $object = clone $eloquent; while ($relation = array_shift($relations)) { // Treat (Has)Many(ToMany|Through) listing relations as "count()" subQuery. if ($this->isCountableRelation($relation)) { return present($object, $name, $object->$name()->count()); } $object = call_user_func([$orig = $object, $relation]); // Treat BelongsToMany form relation as array of values. if ($object instanceof BelongsToMany) { return array_map( 'intval', \DB::table($object->getTable()) ->where($this->getQualifiedForeignKeyName($object), $orig->getKey()) ->pluck($this->getQualifiedRelatedKeyName($object)) ->toArray() ); } $object = $object->getResults(); } return ($object && is_object($object)) ? ($format ? \admin\helpers\eloquent_attribute($object, $name) : $object->$name) : null; }
php
protected function fetchRelationValue($eloquent, $name, array $relations = [], $format = false) { $object = clone $eloquent; while ($relation = array_shift($relations)) { // Treat (Has)Many(ToMany|Through) listing relations as "count()" subQuery. if ($this->isCountableRelation($relation)) { return present($object, $name, $object->$name()->count()); } $object = call_user_func([$orig = $object, $relation]); // Treat BelongsToMany form relation as array of values. if ($object instanceof BelongsToMany) { return array_map( 'intval', \DB::table($object->getTable()) ->where($this->getQualifiedForeignKeyName($object), $orig->getKey()) ->pluck($this->getQualifiedRelatedKeyName($object)) ->toArray() ); } $object = $object->getResults(); } return ($object && is_object($object)) ? ($format ? \admin\helpers\eloquent_attribute($object, $name) : $object->$name) : null; }
[ "protected", "function", "fetchRelationValue", "(", "$", "eloquent", ",", "$", "name", ",", "array", "$", "relations", "=", "[", "]", ",", "$", "format", "=", "false", ")", "{", "$", "object", "=", "clone", "$", "eloquent", ";", "while", "(", "$", "r...
Loops over provided relations to fetch value. @param $eloquent @param string $name @param array $relations @param bool $format @throws Exception @return mixed
[ "Loops", "over", "provided", "relations", "to", "fetch", "value", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Traits/LoopsOverRelations.php#L25-L53
train
adminarchitect/core
src/Services/Widgets.php
Widgets.filter
public function filter() { $widgets = $this->applyFilters(); return $widgets->sortBy(function (AbstractWidget $w1) { return $w1->getOrder(); }); }
php
public function filter() { $widgets = $this->applyFilters(); return $widgets->sortBy(function (AbstractWidget $w1) { return $w1->getOrder(); }); }
[ "public", "function", "filter", "(", ")", "{", "$", "widgets", "=", "$", "this", "->", "applyFilters", "(", ")", ";", "return", "$", "widgets", "->", "sortBy", "(", "function", "(", "AbstractWidget", "$", "w1", ")", "{", "return", "$", "w1", "->", "g...
Fetch widgets. @return array
[ "Fetch", "widgets", "." ]
817ead2640631b81ae15bc2a8555bc22159058bb
https://github.com/adminarchitect/core/blob/817ead2640631b81ae15bc2a8555bc22159058bb/src/Services/Widgets.php#L57-L64
train
silverstripe/silverstripe-admin
code/CMSBatchAction.php
CMSBatchAction.response
public function response($successMessage, $status) { $count = 0; $errors = 0; foreach ($status as $k => $v) { switch ($k) { case 'error': $errors += count($v); break; case 'success': $count += count($v); break; } } $response = Controller::curr()->getResponse(); if ($response) { $response->setStatusCode( 200, sprintf($successMessage, $count, $errors) ); } return json_encode($status); }
php
public function response($successMessage, $status) { $count = 0; $errors = 0; foreach ($status as $k => $v) { switch ($k) { case 'error': $errors += count($v); break; case 'success': $count += count($v); break; } } $response = Controller::curr()->getResponse(); if ($response) { $response->setStatusCode( 200, sprintf($successMessage, $count, $errors) ); } return json_encode($status); }
[ "public", "function", "response", "(", "$", "successMessage", ",", "$", "status", ")", "{", "$", "count", "=", "0", ";", "$", "errors", "=", "0", ";", "foreach", "(", "$", "status", "as", "$", "k", "=>", "$", "v", ")", "{", "switch", "(", "$", ...
Helper method for responding to a back action request @param string $successMessage The message to return as a notification. Can have up to two %d's in it. The first will be replaced by the number of successful changes, the second by the number of failures @param array $status A status array like batchactions builds. Should be key => value pairs, the key can be any string: "error" indicates errors, anything else indicates a type of success. The value is an array. We don't care what's in it, we just use count($value) to find the number of items that succeeded or failed @return string
[ "Helper", "method", "for", "responding", "to", "a", "back", "action", "request" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSBatchAction.php#L54-L80
train
silverstripe/silverstripe-admin
code/CMSBatchAction.php
CMSBatchAction.batchaction
public function batchaction(SS_List $objs, $helperMethod, $successMessage, $arguments = array()) { $status = array('modified' => array(), 'error' => array(), 'deleted' => array(), 'success' => array()); foreach ($objs as $obj) { // Perform the action $id = $obj->ID; if (!call_user_func_array(array($obj, $helperMethod), $arguments)) { $status['error'][$id] = $id; } else { $status['success'][$id] = $id; } // Now make sure the tree title is appropriately updated $publishedRecord = DataObject::get_by_id($this->managedClass, $id); if ($publishedRecord) { $status['modified'][$id] = array( 'TreeTitle' => $publishedRecord->TreeTitle, ); } else { $status['deleted'][$id] = $id; } $obj->destroy(); unset($obj); } return $this->response($successMessage, $status); }
php
public function batchaction(SS_List $objs, $helperMethod, $successMessage, $arguments = array()) { $status = array('modified' => array(), 'error' => array(), 'deleted' => array(), 'success' => array()); foreach ($objs as $obj) { // Perform the action $id = $obj->ID; if (!call_user_func_array(array($obj, $helperMethod), $arguments)) { $status['error'][$id] = $id; } else { $status['success'][$id] = $id; } // Now make sure the tree title is appropriately updated $publishedRecord = DataObject::get_by_id($this->managedClass, $id); if ($publishedRecord) { $status['modified'][$id] = array( 'TreeTitle' => $publishedRecord->TreeTitle, ); } else { $status['deleted'][$id] = $id; } $obj->destroy(); unset($obj); } return $this->response($successMessage, $status); }
[ "public", "function", "batchaction", "(", "SS_List", "$", "objs", ",", "$", "helperMethod", ",", "$", "successMessage", ",", "$", "arguments", "=", "array", "(", ")", ")", "{", "$", "status", "=", "array", "(", "'modified'", "=>", "array", "(", ")", ",...
Helper method for processing batch actions. Returns a set of status-updating JavaScript to return to the CMS. @param SS_List $objs The SS_List of objects to perform this batch action on. @param string $helperMethod The method to call on each of those objects. @param string $successMessage @param array $arguments @return string JSON encoded map in the following format: { 'modified': { 3: {'TreeTitle': 'Page3'}, 5: {'TreeTitle': 'Page5'} }, 'deleted': { // all deleted pages } }
[ "Helper", "method", "for", "processing", "batch", "actions", ".", "Returns", "a", "set", "of", "status", "-", "updating", "JavaScript", "to", "return", "to", "the", "CMS", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSBatchAction.php#L102-L129
train
silverstripe/silverstripe-admin
code/CMSBatchActionHandler.php
CMSBatchActionHandler.handleBatchAction
public function handleBatchAction($request) { // This method can't be called without ajax. if (!$request->isAjax()) { return $this->parentController->redirectBack(); } // Protect against CSRF on destructive action if (!SecurityToken::inst()->checkRequest($request)) { return $this->httpError(400); } // Find the action handler $action = $request->param('BatchAction'); $actionHandler = $this->actionByName($action); // Sanitise ID list and query the database for apges $csvIDs = $request->requestVar('csvIDs'); $ids = $this->cleanIDs($csvIDs); // Filter ids by those which are applicable to this action // Enforces front end filter in LeftAndMain.BatchActions.js:refreshSelected $ids = $actionHandler->applicablePages($ids); // Query ids and pass to action to process $pages = $this->getPages($ids); return $actionHandler->run($pages); }
php
public function handleBatchAction($request) { // This method can't be called without ajax. if (!$request->isAjax()) { return $this->parentController->redirectBack(); } // Protect against CSRF on destructive action if (!SecurityToken::inst()->checkRequest($request)) { return $this->httpError(400); } // Find the action handler $action = $request->param('BatchAction'); $actionHandler = $this->actionByName($action); // Sanitise ID list and query the database for apges $csvIDs = $request->requestVar('csvIDs'); $ids = $this->cleanIDs($csvIDs); // Filter ids by those which are applicable to this action // Enforces front end filter in LeftAndMain.BatchActions.js:refreshSelected $ids = $actionHandler->applicablePages($ids); // Query ids and pass to action to process $pages = $this->getPages($ids); return $actionHandler->run($pages); }
[ "public", "function", "handleBatchAction", "(", "$", "request", ")", "{", "// This method can't be called without ajax.", "if", "(", "!", "$", "request", "->", "isAjax", "(", ")", ")", "{", "return", "$", "this", "->", "parentController", "->", "redirectBack", "...
Invoke a batch action @param HTTPRequest $request @return HTTPResponse
[ "Invoke", "a", "batch", "action" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSBatchActionHandler.php#L132-L159
train
silverstripe/silverstripe-admin
code/CMSBatchActionHandler.php
CMSBatchActionHandler.handleApplicablePages
public function handleApplicablePages($request) { // Find the action handler $action = $request->param('BatchAction'); $actionHandler = $this->actionByName($action); // Sanitise ID list and query the database for apges $csvIDs = $request->requestVar('csvIDs'); $ids = $this->cleanIDs($csvIDs); // Filter by applicable pages if ($ids) { $applicableIDs = $actionHandler->applicablePages($ids); } else { $applicableIDs = array(); } $response = new HTTPResponse(json_encode($applicableIDs)); $response->addHeader("Content-type", "application/json"); return $response; }
php
public function handleApplicablePages($request) { // Find the action handler $action = $request->param('BatchAction'); $actionHandler = $this->actionByName($action); // Sanitise ID list and query the database for apges $csvIDs = $request->requestVar('csvIDs'); $ids = $this->cleanIDs($csvIDs); // Filter by applicable pages if ($ids) { $applicableIDs = $actionHandler->applicablePages($ids); } else { $applicableIDs = array(); } $response = new HTTPResponse(json_encode($applicableIDs)); $response->addHeader("Content-type", "application/json"); return $response; }
[ "public", "function", "handleApplicablePages", "(", "$", "request", ")", "{", "// Find the action handler", "$", "action", "=", "$", "request", "->", "param", "(", "'BatchAction'", ")", ";", "$", "actionHandler", "=", "$", "this", "->", "actionByName", "(", "$...
Respond with the list of applicable pages for a given filter @param HTTPRequest $request @return HTTPResponse
[ "Respond", "with", "the", "list", "of", "applicable", "pages", "for", "a", "given", "filter" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSBatchActionHandler.php#L167-L187
train
silverstripe/silverstripe-admin
code/CMSBatchActionHandler.php
CMSBatchActionHandler.handleConfirmation
public function handleConfirmation($request) { // Find the action handler $action = $request->param('BatchAction'); $actionHandler = $this->actionByName($action); // Sanitise ID list and query the database for apges $csvIDs = $request->requestVar('csvIDs'); $ids = $this->cleanIDs($csvIDs); // Check dialog if ($actionHandler->hasMethod('confirmationDialog')) { $response = new HTTPResponse(json_encode($actionHandler->confirmationDialog($ids))); } else { $response = new HTTPResponse(json_encode(array('alert' => false))); } $response->addHeader("Content-type", "application/json"); return $response; }
php
public function handleConfirmation($request) { // Find the action handler $action = $request->param('BatchAction'); $actionHandler = $this->actionByName($action); // Sanitise ID list and query the database for apges $csvIDs = $request->requestVar('csvIDs'); $ids = $this->cleanIDs($csvIDs); // Check dialog if ($actionHandler->hasMethod('confirmationDialog')) { $response = new HTTPResponse(json_encode($actionHandler->confirmationDialog($ids))); } else { $response = new HTTPResponse(json_encode(array('alert' => false))); } $response->addHeader("Content-type", "application/json"); return $response; }
[ "public", "function", "handleConfirmation", "(", "$", "request", ")", "{", "// Find the action handler", "$", "action", "=", "$", "request", "->", "param", "(", "'BatchAction'", ")", ";", "$", "actionHandler", "=", "$", "this", "->", "actionByName", "(", "$", ...
Check if this action has a confirmation step @param HTTPRequest $request @return HTTPResponse
[ "Check", "if", "this", "action", "has", "a", "confirmation", "step" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSBatchActionHandler.php#L195-L214
train
silverstripe/silverstripe-admin
code/CMSBatchActionHandler.php
CMSBatchActionHandler.actionByName
protected function actionByName($name) { // Find the action handler $actions = $this->batchActions(); if (!isset($actions[$name]['class'])) { throw new InvalidArgumentException("Invalid batch action: {$name}"); } return $this->buildAction($actions[$name]['class']); }
php
protected function actionByName($name) { // Find the action handler $actions = $this->batchActions(); if (!isset($actions[$name]['class'])) { throw new InvalidArgumentException("Invalid batch action: {$name}"); } return $this->buildAction($actions[$name]['class']); }
[ "protected", "function", "actionByName", "(", "$", "name", ")", "{", "// Find the action handler", "$", "actions", "=", "$", "this", "->", "batchActions", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "actions", "[", "$", "name", "]", "[", "'class'",...
Get an action for a given name @param string $name Name of the action @return CMSBatchAction An instance of the given batch action @throws InvalidArgumentException if invalid action name is passed.
[ "Get", "an", "action", "for", "a", "given", "name" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSBatchActionHandler.php#L223-L231
train
silverstripe/silverstripe-admin
code/CMSBatchActionHandler.php
CMSBatchActionHandler.cleanIDs
protected function cleanIDs($csvIDs) { $ids = preg_split('/ *, */', trim($csvIDs)); foreach ($ids as $k => $id) { $ids[$k] = (int)$id; } return array_filter($ids); }
php
protected function cleanIDs($csvIDs) { $ids = preg_split('/ *, */', trim($csvIDs)); foreach ($ids as $k => $id) { $ids[$k] = (int)$id; } return array_filter($ids); }
[ "protected", "function", "cleanIDs", "(", "$", "csvIDs", ")", "{", "$", "ids", "=", "preg_split", "(", "'/ *, */'", ",", "trim", "(", "$", "csvIDs", ")", ")", ";", "foreach", "(", "$", "ids", "as", "$", "k", "=>", "$", "id", ")", "{", "$", "ids",...
Sanitise ID list from string input @param string $csvIDs @return array List of IDs as ints
[ "Sanitise", "ID", "list", "from", "string", "input" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSBatchActionHandler.php#L281-L288
train
silverstripe/silverstripe-admin
code/CMSBatchActionHandler.php
CMSBatchActionHandler.getPages
protected function getPages($ids) { // Check empty set if (empty($ids)) { return new ArrayList(); } $recordClass = $this->recordClass; // Bypass translatable filter if (class_exists('Translatable') && $recordClass::has_extension('Translatable')) { Translatable::disable_locale_filter(); } // Bypass versioned filter if ($recordClass::has_extension(Versioned::class)) { // Workaround for get_including_deleted not supporting byIDs filter very well // Ensure we select both stage / live records $pages = Versioned::get_including_deleted($recordClass)->byIDs($ids); } else { $pages = DataObject::get($recordClass)->byIDs($ids); } if (class_exists('Translatable') && $recordClass::has_extension('Translatable')) { Translatable::enable_locale_filter(); } return $pages; }
php
protected function getPages($ids) { // Check empty set if (empty($ids)) { return new ArrayList(); } $recordClass = $this->recordClass; // Bypass translatable filter if (class_exists('Translatable') && $recordClass::has_extension('Translatable')) { Translatable::disable_locale_filter(); } // Bypass versioned filter if ($recordClass::has_extension(Versioned::class)) { // Workaround for get_including_deleted not supporting byIDs filter very well // Ensure we select both stage / live records $pages = Versioned::get_including_deleted($recordClass)->byIDs($ids); } else { $pages = DataObject::get($recordClass)->byIDs($ids); } if (class_exists('Translatable') && $recordClass::has_extension('Translatable')) { Translatable::enable_locale_filter(); } return $pages; }
[ "protected", "function", "getPages", "(", "$", "ids", ")", "{", "// Check empty set", "if", "(", "empty", "(", "$", "ids", ")", ")", "{", "return", "new", "ArrayList", "(", ")", ";", "}", "$", "recordClass", "=", "$", "this", "->", "recordClass", ";", ...
Safely query and return all pages queried @param array $ids @return SS_List
[ "Safely", "query", "and", "return", "all", "pages", "queried" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSBatchActionHandler.php#L312-L340
train
silverstripe/silverstripe-admin
thirdparty/tinymce/tiny_mce_gzip.php
TinyMCE_Compressor.renderTag
public static function renderTag($tagSettings, $return = false) { $settings = array_merge(self::$defaultSettings, $tagSettings); if (empty($settings["cache_dir"])) { $settings["cache_dir"] = dirname(__FILE__); } $scriptSrc = $settings["url"] . "?js=1"; // Add plugins if (isset($settings["plugins"])) { $scriptSrc .= "&plugins=" . (is_array($settings["plugins"]) ? implode(',', $settings["plugins"]) : $settings["plugins"]); } // Add themes if (isset($settings["themes"])) { $scriptSrc .= "&themes=" . (is_array($settings["themes"]) ? implode(',', $settings["themes"]) : $settings["themes"]); } // Add languages if (isset($settings["languages"])) { $scriptSrc .= "&languages=" . (is_array($settings["languages"]) ? implode(',', $settings["languages"]) : $settings["languages"]); } // Add disk_cache if (isset($settings["disk_cache"])) { $scriptSrc .= "&diskcache=" . ($settings["disk_cache"] === true ? "true" : "false"); } // Add any explicitly specified files if the default settings have been overriden by the tag ones /* * Specifying tag files will override (rather than merge with) any site-specific ones set in the * TinyMCE_Compressor object creation. Note that since the parameter parser limits content to alphanumeric * only base filenames can be specified. The file extension is assumed to be ".js" and the directory is * the TinyMCE root directory. A typical use of this is to include a script which initiates the TinyMCE object. */ if (isset($tagSettings["files"])) { $scriptSrc .= "&files=" .(is_array($settings["files"]) ? implode(',', $settings["files"]) : $settings["files"]); } // Add src flag if (isset($settings["source"])) { $scriptSrc .= "&src=" . ($settings["source"] === true ? "true" : "false"); } $scriptTag = '<script src="' . htmlspecialchars($scriptSrc) . '"></script>'; if ($return) { return $scriptTag; } else { echo $scriptTag; } }
php
public static function renderTag($tagSettings, $return = false) { $settings = array_merge(self::$defaultSettings, $tagSettings); if (empty($settings["cache_dir"])) { $settings["cache_dir"] = dirname(__FILE__); } $scriptSrc = $settings["url"] . "?js=1"; // Add plugins if (isset($settings["plugins"])) { $scriptSrc .= "&plugins=" . (is_array($settings["plugins"]) ? implode(',', $settings["plugins"]) : $settings["plugins"]); } // Add themes if (isset($settings["themes"])) { $scriptSrc .= "&themes=" . (is_array($settings["themes"]) ? implode(',', $settings["themes"]) : $settings["themes"]); } // Add languages if (isset($settings["languages"])) { $scriptSrc .= "&languages=" . (is_array($settings["languages"]) ? implode(',', $settings["languages"]) : $settings["languages"]); } // Add disk_cache if (isset($settings["disk_cache"])) { $scriptSrc .= "&diskcache=" . ($settings["disk_cache"] === true ? "true" : "false"); } // Add any explicitly specified files if the default settings have been overriden by the tag ones /* * Specifying tag files will override (rather than merge with) any site-specific ones set in the * TinyMCE_Compressor object creation. Note that since the parameter parser limits content to alphanumeric * only base filenames can be specified. The file extension is assumed to be ".js" and the directory is * the TinyMCE root directory. A typical use of this is to include a script which initiates the TinyMCE object. */ if (isset($tagSettings["files"])) { $scriptSrc .= "&files=" .(is_array($settings["files"]) ? implode(',', $settings["files"]) : $settings["files"]); } // Add src flag if (isset($settings["source"])) { $scriptSrc .= "&src=" . ($settings["source"] === true ? "true" : "false"); } $scriptTag = '<script src="' . htmlspecialchars($scriptSrc) . '"></script>'; if ($return) { return $scriptTag; } else { echo $scriptTag; } }
[ "public", "static", "function", "renderTag", "(", "$", "tagSettings", ",", "$", "return", "=", "false", ")", "{", "$", "settings", "=", "array_merge", "(", "self", "::", "$", "defaultSettings", ",", "$", "tagSettings", ")", ";", "if", "(", "empty", "(", ...
Renders a script tag that loads the TinyMCE script. @param Array $settings Name/value array with settings for the script tag. @param Bool $return The script tag is return instead of being output if true @return String the tag is returned if $return is true
[ "Renders", "a", "script", "tag", "that", "loads", "the", "TinyMCE", "script", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/thirdparty/tinymce/tiny_mce_gzip.php#L282-L334
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.getCombinedClientConfig
public function getCombinedClientConfig() { $combinedClientConfig = ['sections' => []]; $cmsClassNames = CMSMenu::get_cms_classes(LeftAndMain::class, true, CMSMenu::URL_PRIORITY); // append LeftAndMain to the list as well $cmsClassNames[] = LeftAndMain::class; foreach ($cmsClassNames as $className) { $combinedClientConfig['sections'][] = Injector::inst()->get($className)->getClientConfig(); } // Pass in base url (absolute and relative) $combinedClientConfig['baseUrl'] = Director::baseURL(); $combinedClientConfig['absoluteBaseUrl'] = Director::absoluteBaseURL(); $combinedClientConfig['adminUrl'] = AdminRootController::admin_url(); // Get "global" CSRF token for use in JavaScript $token = SecurityToken::inst(); $combinedClientConfig[$token->getName()] = $token->getValue(); // Set env $combinedClientConfig['environment'] = Director::get_environment_type(); $combinedClientConfig['debugging'] = LeftAndMain::config()->uninherited('client_debugging'); return json_encode($combinedClientConfig); }
php
public function getCombinedClientConfig() { $combinedClientConfig = ['sections' => []]; $cmsClassNames = CMSMenu::get_cms_classes(LeftAndMain::class, true, CMSMenu::URL_PRIORITY); // append LeftAndMain to the list as well $cmsClassNames[] = LeftAndMain::class; foreach ($cmsClassNames as $className) { $combinedClientConfig['sections'][] = Injector::inst()->get($className)->getClientConfig(); } // Pass in base url (absolute and relative) $combinedClientConfig['baseUrl'] = Director::baseURL(); $combinedClientConfig['absoluteBaseUrl'] = Director::absoluteBaseURL(); $combinedClientConfig['adminUrl'] = AdminRootController::admin_url(); // Get "global" CSRF token for use in JavaScript $token = SecurityToken::inst(); $combinedClientConfig[$token->getName()] = $token->getValue(); // Set env $combinedClientConfig['environment'] = Director::get_environment_type(); $combinedClientConfig['debugging'] = LeftAndMain::config()->uninherited('client_debugging'); return json_encode($combinedClientConfig); }
[ "public", "function", "getCombinedClientConfig", "(", ")", "{", "$", "combinedClientConfig", "=", "[", "'sections'", "=>", "[", "]", "]", ";", "$", "cmsClassNames", "=", "CMSMenu", "::", "get_cms_classes", "(", "LeftAndMain", "::", "class", ",", "true", ",", ...
Gets the combined configuration of all LeftAndMain subclasses required by the client app. @return string WARNING: Experimental API
[ "Gets", "the", "combined", "configuration", "of", "all", "LeftAndMain", "subclasses", "required", "by", "the", "client", "app", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L295-L320
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.getClientConfig
public function getClientConfig() { // Allows the section name to be overridden in config $name = $this->config()->get('section_name'); if (!$name) { $name = static::class; } $clientConfig = [ // Trim leading/trailing slash to make it easier to concatenate URL // and use in routing definitions. 'name' => $name, 'url' => trim($this->Link(), '/'), 'form' => [ 'EditorExternalLink' => [ 'schemaUrl' => $this->Link('methodSchema/Modals/EditorExternalLink'), ], 'EditorEmailLink' => [ 'schemaUrl' => $this->Link('methodSchema/Modals/EditorEmailLink'), ], ], ]; $this->extend('updateClientConfig', $clientConfig); return $clientConfig; }
php
public function getClientConfig() { // Allows the section name to be overridden in config $name = $this->config()->get('section_name'); if (!$name) { $name = static::class; } $clientConfig = [ // Trim leading/trailing slash to make it easier to concatenate URL // and use in routing definitions. 'name' => $name, 'url' => trim($this->Link(), '/'), 'form' => [ 'EditorExternalLink' => [ 'schemaUrl' => $this->Link('methodSchema/Modals/EditorExternalLink'), ], 'EditorEmailLink' => [ 'schemaUrl' => $this->Link('methodSchema/Modals/EditorEmailLink'), ], ], ]; $this->extend('updateClientConfig', $clientConfig); return $clientConfig; }
[ "public", "function", "getClientConfig", "(", ")", "{", "// Allows the section name to be overridden in config", "$", "name", "=", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'section_name'", ")", ";", "if", "(", "!", "$", "name", ")", "{", "$"...
Returns configuration required by the client app. @return array WARNING: Experimental API
[ "Returns", "configuration", "required", "by", "the", "client", "app", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L329-L356
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.jsonError
public function jsonError($errorCode, $errorMessage = null) { // Build error from message $error = [ 'type' => 'error', 'code' => $errorCode, ]; if ($errorMessage) { $error['value'] = $errorMessage; } // Support explicit error handling with status = error, or generic message handling // with a message of type = error $result = [ 'status' => 'error', 'errors' => [$error] ]; $response = HTTPResponse::create(json_encode($result), $errorCode) ->addHeader('Content-Type', 'application/json'); // Call a handler method such as onBeforeHTTPError404 $this->extend("onBeforeJSONError{$errorCode}", $request, $response); // Call a handler method such as onBeforeHTTPError, passing 404 as the first arg $this->extend('onBeforeJSONError', $errorCode, $request, $response); // Throw a new exception throw new HTTPResponse_Exception($response); }
php
public function jsonError($errorCode, $errorMessage = null) { // Build error from message $error = [ 'type' => 'error', 'code' => $errorCode, ]; if ($errorMessage) { $error['value'] = $errorMessage; } // Support explicit error handling with status = error, or generic message handling // with a message of type = error $result = [ 'status' => 'error', 'errors' => [$error] ]; $response = HTTPResponse::create(json_encode($result), $errorCode) ->addHeader('Content-Type', 'application/json'); // Call a handler method such as onBeforeHTTPError404 $this->extend("onBeforeJSONError{$errorCode}", $request, $response); // Call a handler method such as onBeforeHTTPError, passing 404 as the first arg $this->extend('onBeforeJSONError', $errorCode, $request, $response); // Throw a new exception throw new HTTPResponse_Exception($response); }
[ "public", "function", "jsonError", "(", "$", "errorCode", ",", "$", "errorMessage", "=", "null", ")", "{", "// Build error from message", "$", "error", "=", "[", "'type'", "=>", "'error'", ",", "'code'", "=>", "$", "errorCode", ",", "]", ";", "if", "(", ...
Return an error HTTPResponse encoded as json @param int $errorCode @param string $errorMessage @return HTTPResponse @throws HTTPResponse_Exception
[ "Return", "an", "error", "HTTPResponse", "encoded", "as", "json" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L426-L454
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.getRequiredPermissions
public static function getRequiredPermissions() { $class = get_called_class(); // If the user is accessing LeftAndMain directly, only generic permissions are required. if ($class === self::class) { return 'CMS_ACCESS'; } $code = Config::inst()->get($class, 'required_permission_codes'); if ($code === false) { return false; } if ($code) { return $code; } return 'CMS_ACCESS_' . $class; }
php
public static function getRequiredPermissions() { $class = get_called_class(); // If the user is accessing LeftAndMain directly, only generic permissions are required. if ($class === self::class) { return 'CMS_ACCESS'; } $code = Config::inst()->get($class, 'required_permission_codes'); if ($code === false) { return false; } if ($code) { return $code; } return 'CMS_ACCESS_' . $class; }
[ "public", "static", "function", "getRequiredPermissions", "(", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "// If the user is accessing LeftAndMain directly, only generic permissions are required.", "if", "(", "$", "class", "===", "self", "::", "class"...
Get list of required permissions @return array|string|bool Code, array of codes, or false if no permission required
[ "Get", "list", "of", "required", "permissions" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L580-L595
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.menu_icon_for_class
public static function menu_icon_for_class($class) { $icon = Config::inst()->get($class, 'menu_icon'); if (!empty($icon)) { $iconURL = ModuleResourceLoader::resourceURL($icon); $class = strtolower(Convert::raw2htmlname(str_replace('\\', '-', $class))); return ".icon.icon-16.icon-{$class} { background-image: url('{$iconURL}'); } "; } return ''; }
php
public static function menu_icon_for_class($class) { $icon = Config::inst()->get($class, 'menu_icon'); if (!empty($icon)) { $iconURL = ModuleResourceLoader::resourceURL($icon); $class = strtolower(Convert::raw2htmlname(str_replace('\\', '-', $class))); return ".icon.icon-16.icon-{$class} { background-image: url('{$iconURL}'); } "; } return ''; }
[ "public", "static", "function", "menu_icon_for_class", "(", "$", "class", ")", "{", "$", "icon", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "$", "class", ",", "'menu_icon'", ")", ";", "if", "(", "!", "empty", "(", "$", "icon", ")", ")...
Return styling for the menu icon, if a custom icon is set for this class Example: static $menu-icon = '/path/to/image/'; @param string $class @return string
[ "Return", "styling", "for", "the", "menu", "icon", "if", "a", "custom", "icon", "is", "set", "for", "this", "class" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L923-L932
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.getRecord
public function getRecord($id) { $className = $this->config()->get('tree_class'); if (!$className) { return null; } if ($id instanceof $className) { return $id; } if ($id === 'root') { return DataObject::singleton($className); } if (is_numeric($id)) { return DataObject::get_by_id($className, $id); } return null; }
php
public function getRecord($id) { $className = $this->config()->get('tree_class'); if (!$className) { return null; } if ($id instanceof $className) { return $id; } if ($id === 'root') { return DataObject::singleton($className); } if (is_numeric($id)) { return DataObject::get_by_id($className, $id); } return null; }
[ "public", "function", "getRecord", "(", "$", "id", ")", "{", "$", "className", "=", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'tree_class'", ")", ";", "if", "(", "!", "$", "className", ")", "{", "return", "null", ";", "}", "if", "...
Get dataobject from the current ID @param int|DataObject $id ID or object @return DataObject
[ "Get", "dataobject", "from", "the", "current", "ID" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L1152-L1168
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.getSearchFilter
protected function getSearchFilter() { if ($this->searchFilterCache) { return $this->searchFilterCache; } // Check for given FilterClass $params = $this->getRequest()->getVar('q'); if (empty($params['FilterClass'])) { return null; } // Validate classname $filterClass = $params['FilterClass']; $filterInfo = new ReflectionClass($filterClass); if (!$filterInfo->implementsInterface(LeftAndMain_SearchFilter::class)) { throw new InvalidArgumentException(sprintf('Invalid filter class passed: %s', $filterClass)); } return $this->searchFilterCache = Injector::inst()->createWithArgs($filterClass, array($params)); }
php
protected function getSearchFilter() { if ($this->searchFilterCache) { return $this->searchFilterCache; } // Check for given FilterClass $params = $this->getRequest()->getVar('q'); if (empty($params['FilterClass'])) { return null; } // Validate classname $filterClass = $params['FilterClass']; $filterInfo = new ReflectionClass($filterClass); if (!$filterInfo->implementsInterface(LeftAndMain_SearchFilter::class)) { throw new InvalidArgumentException(sprintf('Invalid filter class passed: %s', $filterClass)); } return $this->searchFilterCache = Injector::inst()->createWithArgs($filterClass, array($params)); }
[ "protected", "function", "getSearchFilter", "(", ")", "{", "if", "(", "$", "this", "->", "searchFilterCache", ")", "{", "return", "$", "this", "->", "searchFilterCache", ";", "}", "// Check for given FilterClass", "$", "params", "=", "$", "this", "->", "getReq...
Gets the current search filter for this request, if available @throws InvalidArgumentException @return LeftAndMain_SearchFilter
[ "Gets", "the", "current", "search", "filter", "for", "this", "request", "if", "available" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L1219-L1239
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.getNewItem
public function getNewItem($id, $setID = true) { $class = $this->config()->get('tree_class'); $object = Injector::inst()->create($class); if ($setID) { $object->ID = $id; } return $object; }
php
public function getNewItem($id, $setID = true) { $class = $this->config()->get('tree_class'); $object = Injector::inst()->create($class); if ($setID) { $object->ID = $id; } return $object; }
[ "public", "function", "getNewItem", "(", "$", "id", ",", "$", "setID", "=", "true", ")", "{", "$", "class", "=", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'tree_class'", ")", ";", "$", "object", "=", "Injector", "::", "inst", "(", ...
Create new item. @param string|int $id @param bool $setID @return DataObject
[ "Create", "new", "item", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L1298-L1306
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.getSilverStripeNavigator
public function getSilverStripeNavigator() { $page = $this->currentPage(); if ($page instanceof CMSPreviewable) { $navigator = new SilverStripeNavigator($page); return $navigator->renderWith($this->getTemplatesWithSuffix('_SilverStripeNavigator')); } return null; }
php
public function getSilverStripeNavigator() { $page = $this->currentPage(); if ($page instanceof CMSPreviewable) { $navigator = new SilverStripeNavigator($page); return $navigator->renderWith($this->getTemplatesWithSuffix('_SilverStripeNavigator')); } return null; }
[ "public", "function", "getSilverStripeNavigator", "(", ")", "{", "$", "page", "=", "$", "this", "->", "currentPage", "(", ")", ";", "if", "(", "$", "page", "instanceof", "CMSPreviewable", ")", "{", "$", "navigator", "=", "new", "SilverStripeNavigator", "(", ...
Used for preview controls, mainly links which switch between different states of the page. @return DBHTMLText
[ "Used", "for", "preview", "controls", "mainly", "links", "which", "switch", "between", "different", "states", "of", "the", "page", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L1629-L1637
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.CMSVersionNumber
public function CMSVersionNumber() { $moduleName = array_keys($this->getVersionProvider()->getModules())[0]; $lockModules = $this->getVersionProvider()->getModuleVersionFromComposer([$moduleName]); if (!isset($lockModules[$moduleName])) { return ''; } return $lockModules[$moduleName]; }
php
public function CMSVersionNumber() { $moduleName = array_keys($this->getVersionProvider()->getModules())[0]; $lockModules = $this->getVersionProvider()->getModuleVersionFromComposer([$moduleName]); if (!isset($lockModules[$moduleName])) { return ''; } return $lockModules[$moduleName]; }
[ "public", "function", "CMSVersionNumber", "(", ")", "{", "$", "moduleName", "=", "array_keys", "(", "$", "this", "->", "getVersionProvider", "(", ")", "->", "getModules", "(", ")", ")", "[", "0", "]", ";", "$", "lockModules", "=", "$", "this", "->", "g...
Return the version number of the CMS, ie. '4.2.1' @return string
[ "Return", "the", "version", "number", "of", "the", "CMS", "ie", ".", "4", ".", "2", ".", "1" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L1747-L1757
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.getHelpLinks
public function getHelpLinks() { $helpLinks = $this->config()->get('help_links'); $formattedLinks = []; $helpLink = $this->config()->get('help_link'); if ($helpLink) { Deprecation::notice('5.0', 'Use $help_links instead of $help_link'); $helpLinks['CMS User help'] = $helpLink; } foreach ($helpLinks as $key => $value) { $translationKey = str_replace(' ', '', $key); $formattedLinks[] = [ 'Title' => _t(__CLASS__ . '.' . $translationKey, $key), 'URL' => $value ]; } return ArrayList::create($formattedLinks); }
php
public function getHelpLinks() { $helpLinks = $this->config()->get('help_links'); $formattedLinks = []; $helpLink = $this->config()->get('help_link'); if ($helpLink) { Deprecation::notice('5.0', 'Use $help_links instead of $help_link'); $helpLinks['CMS User help'] = $helpLink; } foreach ($helpLinks as $key => $value) { $translationKey = str_replace(' ', '', $key); $formattedLinks[] = [ 'Title' => _t(__CLASS__ . '.' . $translationKey, $key), 'URL' => $value ]; } return ArrayList::create($formattedLinks); }
[ "public", "function", "getHelpLinks", "(", ")", "{", "$", "helpLinks", "=", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'help_links'", ")", ";", "$", "formattedLinks", "=", "[", "]", ";", "$", "helpLink", "=", "$", "this", "->", "config...
Returns help_links in a format readable by a template @return ArrayList
[ "Returns", "help_links", "in", "a", "format", "readable", "by", "a", "template" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L1797-L1818
train
silverstripe/silverstripe-admin
code/LeftAndMain.php
LeftAndMain.SectionTitle
public function SectionTitle() { $title = $this->menu_title(); if ($title) { return $title; } foreach ($this->MainMenu() as $menuItem) { if ($menuItem->LinkingMode != 'link') { return $menuItem->Title; } } return null; }
php
public function SectionTitle() { $title = $this->menu_title(); if ($title) { return $title; } foreach ($this->MainMenu() as $menuItem) { if ($menuItem->LinkingMode != 'link') { return $menuItem->Title; } } return null; }
[ "public", "function", "SectionTitle", "(", ")", "{", "$", "title", "=", "$", "this", "->", "menu_title", "(", ")", ";", "if", "(", "$", "title", ")", "{", "return", "$", "title", ";", "}", "foreach", "(", "$", "this", "->", "MainMenu", "(", ")", ...
Return the title of the current section. Either this is pulled from the current panel's menu_title or from the first active menu @return string
[ "Return", "the", "title", "of", "the", "current", "section", ".", "Either", "this", "is", "pulled", "from", "the", "current", "panel", "s", "menu_title", "or", "from", "the", "first", "active", "menu" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/LeftAndMain.php#L1870-L1883
train
silverstripe/silverstripe-admin
code/CMSMenu.php
CMSMenu.add_controller
public static function add_controller($controllerClass) { if ($menuItem = self::menuitem_for_controller($controllerClass)) { $code = static::get_menu_code($controllerClass); self::add_menu_item_obj($code, $menuItem); } }
php
public static function add_controller($controllerClass) { if ($menuItem = self::menuitem_for_controller($controllerClass)) { $code = static::get_menu_code($controllerClass); self::add_menu_item_obj($code, $menuItem); } }
[ "public", "static", "function", "add_controller", "(", "$", "controllerClass", ")", "{", "if", "(", "$", "menuItem", "=", "self", "::", "menuitem_for_controller", "(", "$", "controllerClass", ")", ")", "{", "$", "code", "=", "static", "::", "get_menu_code", ...
Add a LeftAndMain controller to the CMS menu. @param string $controllerClass The class name of the controller @todo A director rule is added when a controller link is added, but it won't be removed when the item is removed. Functionality needed in {@link Director}.
[ "Add", "a", "LeftAndMain", "controller", "to", "the", "CMS", "menu", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSMenu.php#L75-L81
train
silverstripe/silverstripe-admin
code/CMSMenu.php
CMSMenu.menuitem_for_controller
protected static function menuitem_for_controller($controllerClass) { $urlBase = AdminRootController::admin_url(); $urlSegment = Config::inst()->get($controllerClass, 'url_segment'); $menuPriority = Config::inst()->get($controllerClass, 'menu_priority'); $ignoreFromMenu = Config::inst()->get($controllerClass, 'ignore_menuitem'); // Don't add menu items defined the old way, or for controllers that are set to be ignored if (!$urlSegment || $ignoreFromMenu) { return null; } $link = Controller::join_links($urlBase, $urlSegment) . '/'; // doesn't work if called outside of a controller context (e.g. in _config.php) // as the locale won't be detected properly. Use {@link LeftAndMain->MainMenu()} to update // titles for existing menu entries $menuTitle = LeftAndMain::menu_title($controllerClass); return new CMSMenuItem($menuTitle, $link, $controllerClass, $menuPriority); }
php
protected static function menuitem_for_controller($controllerClass) { $urlBase = AdminRootController::admin_url(); $urlSegment = Config::inst()->get($controllerClass, 'url_segment'); $menuPriority = Config::inst()->get($controllerClass, 'menu_priority'); $ignoreFromMenu = Config::inst()->get($controllerClass, 'ignore_menuitem'); // Don't add menu items defined the old way, or for controllers that are set to be ignored if (!$urlSegment || $ignoreFromMenu) { return null; } $link = Controller::join_links($urlBase, $urlSegment) . '/'; // doesn't work if called outside of a controller context (e.g. in _config.php) // as the locale won't be detected properly. Use {@link LeftAndMain->MainMenu()} to update // titles for existing menu entries $menuTitle = LeftAndMain::menu_title($controllerClass); return new CMSMenuItem($menuTitle, $link, $controllerClass, $menuPriority); }
[ "protected", "static", "function", "menuitem_for_controller", "(", "$", "controllerClass", ")", "{", "$", "urlBase", "=", "AdminRootController", "::", "admin_url", "(", ")", ";", "$", "urlSegment", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "$"...
Return a CMSMenuItem to add the given controller to the CMSMenu @param string $controllerClass @return CMSMenuItem
[ "Return", "a", "CMSMenuItem", "to", "add", "the", "given", "controller", "to", "the", "CMSMenu" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSMenu.php#L89-L109
train
silverstripe/silverstripe-admin
code/CMSMenu.php
CMSMenu.add_link
public static function add_link($code, $menuTitle, $url, $priority = -1, $attributes = null, $iconClass = null) { return self::add_menu_item($code, $menuTitle, $url, null, $priority, $attributes, $iconClass); }
php
public static function add_link($code, $menuTitle, $url, $priority = -1, $attributes = null, $iconClass = null) { return self::add_menu_item($code, $menuTitle, $url, null, $priority, $attributes, $iconClass); }
[ "public", "static", "function", "add_link", "(", "$", "code", ",", "$", "menuTitle", ",", "$", "url", ",", "$", "priority", "=", "-", "1", ",", "$", "attributes", "=", "null", ",", "$", "iconClass", "=", "null", ")", "{", "return", "self", "::", "a...
Add an arbitrary URL to the CMS menu. @param string $code A unique identifier (used to create a CSS ID and its key in {@link $menu_items}) @param string $menuTitle The link's title in the CMS menu @param string $url The url of the link @param integer $priority The menu priority (sorting order) of the menu item. Higher priorities will be further left. @param array $attributes an array of attributes to include on the link. @param string $iconClass @return boolean The result of the operation.
[ "Add", "an", "arbitrary", "URL", "to", "the", "CMS", "menu", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSMenu.php#L125-L128
train
silverstripe/silverstripe-admin
code/CMSMenu.php
CMSMenu.add_menu_item
public static function add_menu_item( $code, $menuTitle, $url, $controllerClass = null, $priority = -1, $attributes = null, $iconClass = null ) { // If a class is defined, then force the use of that as a code. This helps prevent menu item duplication if ($controllerClass) { $code = self::get_menu_code($controllerClass); } return self::replace_menu_item( $code, $menuTitle, $url, $controllerClass, $priority, $attributes, $iconClass ); }
php
public static function add_menu_item( $code, $menuTitle, $url, $controllerClass = null, $priority = -1, $attributes = null, $iconClass = null ) { // If a class is defined, then force the use of that as a code. This helps prevent menu item duplication if ($controllerClass) { $code = self::get_menu_code($controllerClass); } return self::replace_menu_item( $code, $menuTitle, $url, $controllerClass, $priority, $attributes, $iconClass ); }
[ "public", "static", "function", "add_menu_item", "(", "$", "code", ",", "$", "menuTitle", ",", "$", "url", ",", "$", "controllerClass", "=", "null", ",", "$", "priority", "=", "-", "1", ",", "$", "attributes", "=", "null", ",", "$", "iconClass", "=", ...
Add a navigation item to the main administration menu showing in the top bar. uses {@link CMSMenu::$menu_items} @param string $code Unique identifier for this menu item (e.g. used by {@link replace_menu_item()} and {@link remove_menu_item}. Also used as a CSS-class for icon customization. @param string $menuTitle Localized title showing in the menu bar @param string $url A relative URL that will be linked in the menu bar. @param string $controllerClass The controller class for this menu, used to check permisssions. If blank, it's assumed that this is public, and always shown to users who have the rights to access some other part of the admin area. @param int $priority @param array $attributes an array of attributes to include on the link. @param string $iconClass @return bool Success
[ "Add", "a", "navigation", "item", "to", "the", "main", "administration", "menu", "showing", "in", "the", "top", "bar", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSMenu.php#L148-L171
train
silverstripe/silverstripe-admin
code/CMSMenu.php
CMSMenu.get_menu_item
public static function get_menu_item($code) { $menuItems = self::get_menu_items(); return (isset($menuItems[$code])) ? $menuItems[$code] : false; }
php
public static function get_menu_item($code) { $menuItems = self::get_menu_items(); return (isset($menuItems[$code])) ? $menuItems[$code] : false; }
[ "public", "static", "function", "get_menu_item", "(", "$", "code", ")", "{", "$", "menuItems", "=", "self", "::", "get_menu_items", "(", ")", ";", "return", "(", "isset", "(", "$", "menuItems", "[", "$", "code", "]", ")", ")", "?", "$", "menuItems", ...
Get a single menu item by its code value. @param string $code @return array
[ "Get", "a", "single", "menu", "item", "by", "its", "code", "value", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSMenu.php#L179-L183
train
silverstripe/silverstripe-admin
code/CMSMenu.php
CMSMenu.get_menu_items
public static function get_menu_items() { $menuItems = array(); // Set up default menu items if (!self::$menu_is_cleared) { $cmsClasses = self::get_cms_classes(); foreach ($cmsClasses as $cmsClass) { $menuItem = self::menuitem_for_controller($cmsClass); $menuCode = self::get_menu_code($cmsClass); if ($menuItem) { $menuItems[$menuCode] = $menuItem; } } } // Apply changes foreach (self::$menu_item_changes as $change) { switch ($change['type']) { case 'add': $menuItems[$change['code']] = $change['item']; break; case 'remove': unset($menuItems[$change['code']]); break; default: user_error("Bad menu item change type {$change['type']}", E_USER_WARNING); } } // Sort menu items according to priority, then title asc $menuPriority = array(); $menuTitle = array(); foreach ($menuItems as $key => $menuItem) { $menuPriority[$key] = is_numeric($menuItem->priority) ? $menuItem->priority : 0; $menuTitle[$key] = $menuItem->title; } array_multisort($menuPriority, SORT_DESC, $menuTitle, SORT_ASC, $menuItems); return $menuItems; }
php
public static function get_menu_items() { $menuItems = array(); // Set up default menu items if (!self::$menu_is_cleared) { $cmsClasses = self::get_cms_classes(); foreach ($cmsClasses as $cmsClass) { $menuItem = self::menuitem_for_controller($cmsClass); $menuCode = self::get_menu_code($cmsClass); if ($menuItem) { $menuItems[$menuCode] = $menuItem; } } } // Apply changes foreach (self::$menu_item_changes as $change) { switch ($change['type']) { case 'add': $menuItems[$change['code']] = $change['item']; break; case 'remove': unset($menuItems[$change['code']]); break; default: user_error("Bad menu item change type {$change['type']}", E_USER_WARNING); } } // Sort menu items according to priority, then title asc $menuPriority = array(); $menuTitle = array(); foreach ($menuItems as $key => $menuItem) { $menuPriority[$key] = is_numeric($menuItem->priority) ? $menuItem->priority : 0; $menuTitle[$key] = $menuItem->title; } array_multisort($menuPriority, SORT_DESC, $menuTitle, SORT_ASC, $menuItems); return $menuItems; }
[ "public", "static", "function", "get_menu_items", "(", ")", "{", "$", "menuItems", "=", "array", "(", ")", ";", "// Set up default menu items", "if", "(", "!", "self", "::", "$", "menu_is_cleared", ")", "{", "$", "cmsClasses", "=", "self", "::", "get_cms_cla...
Get all menu entries. @return array
[ "Get", "all", "menu", "entries", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSMenu.php#L201-L243
train
silverstripe/silverstripe-admin
code/CMSMenu.php
CMSMenu.replace_menu_item
public static function replace_menu_item( $code, $menuTitle, $url, $controllerClass = null, $priority = -1, $attributes = null, $iconClass = null ) { $item = new CMSMenuItem($menuTitle, $url, $controllerClass, $priority, $iconClass); if ($attributes) { $item->setAttributes($attributes); } self::$menu_item_changes[] = array( 'type' => 'add', 'code' => $code, 'item' => $item, ); }
php
public static function replace_menu_item( $code, $menuTitle, $url, $controllerClass = null, $priority = -1, $attributes = null, $iconClass = null ) { $item = new CMSMenuItem($menuTitle, $url, $controllerClass, $priority, $iconClass); if ($attributes) { $item->setAttributes($attributes); } self::$menu_item_changes[] = array( 'type' => 'add', 'code' => $code, 'item' => $item, ); }
[ "public", "static", "function", "replace_menu_item", "(", "$", "code", ",", "$", "menuTitle", ",", "$", "url", ",", "$", "controllerClass", "=", "null", ",", "$", "priority", "=", "-", "1", ",", "$", "attributes", "=", "null", ",", "$", "iconClass", "=...
Replace a navigation item to the main administration menu showing in the top bar. @param string $code Unique identifier for this menu item (e.g. used by {@link replace_menu_item()} and {@link remove_menu_item}. Also used as a CSS-class for icon customization. @param string $menuTitle Localized title showing in the menu bar @param string $url A relative URL that will be linked in the menu bar. Make sure to add a matching route via {@link Director::$rules} to this url. @param string $controllerClass The controller class for this menu, used to check permisssions. If blank, it's assumed that this is public, and always shown to users who have the rights to access some other part of the admin area. @param int $priority @param array $attributes an array of attributes to include on the link. @param string $iconClass @return bool Success
[ "Replace", "a", "navigation", "item", "to", "the", "main", "administration", "menu", "showing", "in", "the", "top", "bar", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSMenu.php#L330-L350
train
silverstripe/silverstripe-admin
code/CMSMenu.php
CMSMenu.provideI18nEntities
public function provideI18nEntities() { $cmsClasses = self::get_cms_classes(); $entities = array(); foreach ($cmsClasses as $cmsClass) { $defaultTitle = LeftAndMain::menu_title($cmsClass, false); $ownerModule = ClassLoader::inst()->getManifest()->getOwnerModule($cmsClass); $entities["{$cmsClass}.MENUTITLE"] = [ 'default' => $defaultTitle, 'module' => $ownerModule->getShortName() ]; } return $entities; }
php
public function provideI18nEntities() { $cmsClasses = self::get_cms_classes(); $entities = array(); foreach ($cmsClasses as $cmsClass) { $defaultTitle = LeftAndMain::menu_title($cmsClass, false); $ownerModule = ClassLoader::inst()->getManifest()->getOwnerModule($cmsClass); $entities["{$cmsClass}.MENUTITLE"] = [ 'default' => $defaultTitle, 'module' => $ownerModule->getShortName() ]; } return $entities; }
[ "public", "function", "provideI18nEntities", "(", ")", "{", "$", "cmsClasses", "=", "self", "::", "get_cms_classes", "(", ")", ";", "$", "entities", "=", "array", "(", ")", ";", "foreach", "(", "$", "cmsClasses", "as", "$", "cmsClass", ")", "{", "$", "...
Provide menu titles to the i18n entity provider
[ "Provide", "menu", "titles", "to", "the", "i18n", "entity", "provider" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/CMSMenu.php#L427-L440
train
silverstripe/silverstripe-admin
code/Forms/FormMessageBootstrapAdapter.php
FormMessageBootstrapExtension.getAlertType
public function getAlertType() { $type = $this->owner->getMessageType(); if (isset($this->bootstrapAlertsMap[$type])) { return $this->bootstrapAlertsMap[$type]; } // Fallback to original return $type; }
php
public function getAlertType() { $type = $this->owner->getMessageType(); if (isset($this->bootstrapAlertsMap[$type])) { return $this->bootstrapAlertsMap[$type]; } // Fallback to original return $type; }
[ "public", "function", "getAlertType", "(", ")", "{", "$", "type", "=", "$", "this", "->", "owner", "->", "getMessageType", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "bootstrapAlertsMap", "[", "$", "type", "]", ")", ")", "{", "return"...
Maps a SilverStripe message type to a Bootstrap alert type {@inheritdoc}
[ "Maps", "a", "SilverStripe", "message", "type", "to", "a", "Bootstrap", "alert", "type" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/Forms/FormMessageBootstrapAdapter.php#L27-L37
train
silverstripe/silverstripe-admin
code/ModelAdmin.php
ModelAdmin.init
protected function init() { parent::init(); $models = $this->getManagedModels(); if ($this->getRequest()->param('ModelClass')) { $this->modelClass = $this->unsanitiseClassName($this->getRequest()->param('ModelClass')); } else { reset($models); $this->modelClass = key($models); } // security check for valid models if (!array_key_exists($this->modelClass, $models)) { user_error('ModelAdmin::init(): Invalid Model class', E_USER_ERROR); } }
php
protected function init() { parent::init(); $models = $this->getManagedModels(); if ($this->getRequest()->param('ModelClass')) { $this->modelClass = $this->unsanitiseClassName($this->getRequest()->param('ModelClass')); } else { reset($models); $this->modelClass = key($models); } // security check for valid models if (!array_key_exists($this->modelClass, $models)) { user_error('ModelAdmin::init(): Invalid Model class', E_USER_ERROR); } }
[ "protected", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "$", "models", "=", "$", "this", "->", "getManagedModels", "(", ")", ";", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "param", "(", "'ModelClass'",...
Initialize the model admin interface. Sets up embedded jquery libraries and requisite plugins. Sets the `modelClass` field which determines which of the {@link DataObject} objects will have visible data. This is determined by the URL (with the first slug being the name of the DataObject class to represent. If this class is loaded without any URL, we pick the first DataObject from the list of {@link self::$managed_models}.
[ "Initialize", "the", "model", "admin", "interface", ".", "Sets", "up", "embedded", "jquery", "libraries", "and", "requisite", "plugins", "." ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/ModelAdmin.php#L136-L153
train
silverstripe/silverstripe-admin
code/ModelAdmin.php
ModelAdmin.SearchForm
public function SearchForm() { Deprecation::notice('4.3', 'Will be removed in favor of GridFieldFilterHeader in 5.0'); if (!$this->showSearchForm || (is_array($this->showSearchForm) && !in_array($this->modelClass, $this->showSearchForm)) ) { return false; } $gridField = $this->getEditForm()->fields() ->fieldByName($this->sanitiseClassName($this->modelClass)); $filterHeader = $gridField->getConfig() ->getComponentByType(GridFieldFilterHeader::class); $form = $filterHeader->getSearchForm($gridField); return $form; }
php
public function SearchForm() { Deprecation::notice('4.3', 'Will be removed in favor of GridFieldFilterHeader in 5.0'); if (!$this->showSearchForm || (is_array($this->showSearchForm) && !in_array($this->modelClass, $this->showSearchForm)) ) { return false; } $gridField = $this->getEditForm()->fields() ->fieldByName($this->sanitiseClassName($this->modelClass)); $filterHeader = $gridField->getConfig() ->getComponentByType(GridFieldFilterHeader::class); $form = $filterHeader->getSearchForm($gridField); return $form; }
[ "public", "function", "SearchForm", "(", ")", "{", "Deprecation", "::", "notice", "(", "'4.3'", ",", "'Will be removed in favor of GridFieldFilterHeader in 5.0'", ")", ";", "if", "(", "!", "$", "this", "->", "showSearchForm", "||", "(", "is_array", "(", "$", "t...
Returns the search form @deprecated 4.3.0 @return Form|bool
[ "Returns", "the", "search", "form" ]
8e76d64a24ed4cda9615b3a863b92b40c554d029
https://github.com/silverstripe/silverstripe-admin/blob/8e76d64a24ed4cda9615b3a863b92b40c554d029/code/ModelAdmin.php#L299-L318
train
kenjis/ci-phpunit-test
application/libraries/Seeder.php
Seeder.call
public function call($seeder, $callDependencies = true) { if ($this->seedPath === null) { $this->seedPath = APPPATH . 'database/seeds/'; } $obj = $this->loadSeeder($seeder); if ($callDependencies === true && $obj instanceof Seeder) { $obj->callDependencies($this->seedPath); } $obj->run(); }
php
public function call($seeder, $callDependencies = true) { if ($this->seedPath === null) { $this->seedPath = APPPATH . 'database/seeds/'; } $obj = $this->loadSeeder($seeder); if ($callDependencies === true && $obj instanceof Seeder) { $obj->callDependencies($this->seedPath); } $obj->run(); }
[ "public", "function", "call", "(", "$", "seeder", ",", "$", "callDependencies", "=", "true", ")", "{", "if", "(", "$", "this", "->", "seedPath", "===", "null", ")", "{", "$", "this", "->", "seedPath", "=", "APPPATH", ".", "'database/seeds/'", ";", "}",...
Run another seeder @param string $seeder Seeder classname @param bool $callDependencies
[ "Run", "another", "seeder" ]
3f2ea5cde0ee5814aa9402a5291772495f9250e0
https://github.com/kenjis/ci-phpunit-test/blob/3f2ea5cde0ee5814aa9402a5291772495f9250e0/application/libraries/Seeder.php#L34-L46
train
kenjis/ci-phpunit-test
application/libraries/Seeder.php
Seeder.callDependencies
public function callDependencies($seedPath) { foreach ($this->depends as $path => $seeders) { $this->seedPath = $seedPath; if (is_string($path)) { $this->setPath($path); } $this->callDependency($seeders); } $this->setPath($seedPath); }
php
public function callDependencies($seedPath) { foreach ($this->depends as $path => $seeders) { $this->seedPath = $seedPath; if (is_string($path)) { $this->setPath($path); } $this->callDependency($seeders); } $this->setPath($seedPath); }
[ "public", "function", "callDependencies", "(", "$", "seedPath", ")", "{", "foreach", "(", "$", "this", "->", "depends", "as", "$", "path", "=>", "$", "seeders", ")", "{", "$", "this", "->", "seedPath", "=", "$", "seedPath", ";", "if", "(", "is_string",...
Call dependency seeders @param string $seedPath
[ "Call", "dependency", "seeders" ]
3f2ea5cde0ee5814aa9402a5291772495f9250e0
https://github.com/kenjis/ci-phpunit-test/blob/3f2ea5cde0ee5814aa9402a5291772495f9250e0/application/libraries/Seeder.php#L67-L78
train
kenjis/ci-phpunit-test
application/libraries/Seeder.php
Seeder.callDependency
protected function callDependency($seederName) { if (is_array($seederName)) { array_map([$this, 'callDependency'], $seederName); return; } $seeder = $this->loadSeeder($seederName); if (is_string($this->seedPath)) { $seeder->setPath($this->seedPath); } $seeder->call($seederName, true); }
php
protected function callDependency($seederName) { if (is_array($seederName)) { array_map([$this, 'callDependency'], $seederName); return; } $seeder = $this->loadSeeder($seederName); if (is_string($this->seedPath)) { $seeder->setPath($this->seedPath); } $seeder->call($seederName, true); }
[ "protected", "function", "callDependency", "(", "$", "seederName", ")", "{", "if", "(", "is_array", "(", "$", "seederName", ")", ")", "{", "array_map", "(", "[", "$", "this", ",", "'callDependency'", "]", ",", "$", "seederName", ")", ";", "return", ";", ...
Call dependency seeder @param string|array $seederName
[ "Call", "dependency", "seeder" ]
3f2ea5cde0ee5814aa9402a5291772495f9250e0
https://github.com/kenjis/ci-phpunit-test/blob/3f2ea5cde0ee5814aa9402a5291772495f9250e0/application/libraries/Seeder.php#L85-L98
train
kenjis/ci-phpunit-test
lib/Installer.php
Installer.fixPath
private function fixPath() { $file = $this->app_dir.'/'.$this->test_dir.'/Bootstrap.php'; $contents = file_get_contents($file); if (! file_exists('system')) { if (file_exists('vendor/codeigniter/framework/system')) { $contents = str_replace( '$system_path = \'../../system\';', '$system_path = \'../../vendor/codeigniter/framework/system\';', $contents ); } else { throw new Exception('Can\'t find "system" folder.'); } } if (! file_exists('index.php')) { if (file_exists($this->pub_dir.'/index.php')) { // CodeIgniter 3.0.6 and after $contents = str_replace( "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", "define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').DIRECTORY_SEPARATOR);", $contents ); // CodeIgniter 3.0.5 and before $contents = str_replace( "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", "define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').'/');", $contents ); } elseif (file_exists($this->app_dir.'/public/index.php')) { // CodeIgniter 3.0.6 and after $contents = str_replace( "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", "define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);", $contents ); // CodeIgniter 3.0.5 and before $contents = str_replace( "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", "define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');", $contents ); if ($this->app_dir !== 'application') { $contents = str_replace( "\$application_folder = '../../application';", "\$application_folder = '../../{$this->app_dir}';", $contents ); } } else { throw new Exception('Can\'t find "index.php".'); } } file_put_contents($file, $contents); }
php
private function fixPath() { $file = $this->app_dir.'/'.$this->test_dir.'/Bootstrap.php'; $contents = file_get_contents($file); if (! file_exists('system')) { if (file_exists('vendor/codeigniter/framework/system')) { $contents = str_replace( '$system_path = \'../../system\';', '$system_path = \'../../vendor/codeigniter/framework/system\';', $contents ); } else { throw new Exception('Can\'t find "system" folder.'); } } if (! file_exists('index.php')) { if (file_exists($this->pub_dir.'/index.php')) { // CodeIgniter 3.0.6 and after $contents = str_replace( "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", "define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').DIRECTORY_SEPARATOR);", $contents ); // CodeIgniter 3.0.5 and before $contents = str_replace( "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", "define('FCPATH', realpath(dirname(__FILE__).'/../../{$this->pub_dir}').'/');", $contents ); } elseif (file_exists($this->app_dir.'/public/index.php')) { // CodeIgniter 3.0.6 and after $contents = str_replace( "define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", "define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);", $contents ); // CodeIgniter 3.0.5 and before $contents = str_replace( "define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", "define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');", $contents ); if ($this->app_dir !== 'application') { $contents = str_replace( "\$application_folder = '../../application';", "\$application_folder = '../../{$this->app_dir}';", $contents ); } } else { throw new Exception('Can\'t find "index.php".'); } } file_put_contents($file, $contents); }
[ "private", "function", "fixPath", "(", ")", "{", "$", "file", "=", "$", "this", "->", "app_dir", ".", "'/'", ".", "$", "this", "->", "test_dir", ".", "'/Bootstrap.php'", ";", "$", "contents", "=", "file_get_contents", "(", "$", "file", ")", ";", "if", ...
Fix paths in Bootstrap.php
[ "Fix", "paths", "in", "Bootstrap", ".", "php" ]
3f2ea5cde0ee5814aa9402a5291772495f9250e0
https://github.com/kenjis/ci-phpunit-test/blob/3f2ea5cde0ee5814aa9402a5291772495f9250e0/lib/Installer.php#L80-L137
train
rtconner/laravel-tagging
src/Taggable.php
Taggable.bootTaggable
public static function bootTaggable() { if(static::untagOnDelete()) { static::deleting(function($model) { $model->untag(); }); } static::saved(function ($model) { $model->autoTagPostSave(); }); static::$taggingUtility = app(TaggingUtility::class); }
php
public static function bootTaggable() { if(static::untagOnDelete()) { static::deleting(function($model) { $model->untag(); }); } static::saved(function ($model) { $model->autoTagPostSave(); }); static::$taggingUtility = app(TaggingUtility::class); }
[ "public", "static", "function", "bootTaggable", "(", ")", "{", "if", "(", "static", "::", "untagOnDelete", "(", ")", ")", "{", "static", "::", "deleting", "(", "function", "(", "$", "model", ")", "{", "$", "model", "->", "untag", "(", ")", ";", "}", ...
Boot the soft taggable trait for a model. @return void
[ "Boot", "the", "soft", "taggable", "trait", "for", "a", "model", "." ]
2b151ba2962b6ae6cc1499b5983b95c5174787d9
https://github.com/rtconner/laravel-tagging/blob/2b151ba2962b6ae6cc1499b5983b95c5174787d9/src/Taggable.php#L46-L59
train
rtconner/laravel-tagging
src/Taggable.php
Taggable.tag
public function tag($tagNames) { $tagNames = static::$taggingUtility->makeTagArray($tagNames); foreach($tagNames as $tagName) { $this->addTag($tagName); } }
php
public function tag($tagNames) { $tagNames = static::$taggingUtility->makeTagArray($tagNames); foreach($tagNames as $tagName) { $this->addTag($tagName); } }
[ "public", "function", "tag", "(", "$", "tagNames", ")", "{", "$", "tagNames", "=", "static", "::", "$", "taggingUtility", "->", "makeTagArray", "(", "$", "tagNames", ")", ";", "foreach", "(", "$", "tagNames", "as", "$", "tagName", ")", "{", "$", "this"...
Perform the action of tagging the model with the given string @param string|array $tagNames
[ "Perform", "the", "action", "of", "tagging", "the", "model", "with", "the", "given", "string" ]
2b151ba2962b6ae6cc1499b5983b95c5174787d9
https://github.com/rtconner/laravel-tagging/blob/2b151ba2962b6ae6cc1499b5983b95c5174787d9/src/Taggable.php#L99-L106
train
rtconner/laravel-tagging
src/Taggable.php
Taggable.untag
public function untag($tagNames=null) { if(is_null($tagNames)) { $tagNames = $this->tagNames(); } $tagNames = static::$taggingUtility->makeTagArray($tagNames); foreach($tagNames as $tagName) { $this->removeTag($tagName); } if(static::shouldDeleteUnused()) { static::$taggingUtility->deleteUnusedTags(); } }
php
public function untag($tagNames=null) { if(is_null($tagNames)) { $tagNames = $this->tagNames(); } $tagNames = static::$taggingUtility->makeTagArray($tagNames); foreach($tagNames as $tagName) { $this->removeTag($tagName); } if(static::shouldDeleteUnused()) { static::$taggingUtility->deleteUnusedTags(); } }
[ "public", "function", "untag", "(", "$", "tagNames", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "tagNames", ")", ")", "{", "$", "tagNames", "=", "$", "this", "->", "tagNames", "(", ")", ";", "}", "$", "tagNames", "=", "static", "::", ...
Remove the tag from this model @param string|array|null $tagNames (or null to remove all tags)
[ "Remove", "the", "tag", "from", "this", "model" ]
2b151ba2962b6ae6cc1499b5983b95c5174787d9
https://github.com/rtconner/laravel-tagging/blob/2b151ba2962b6ae6cc1499b5983b95c5174787d9/src/Taggable.php#L137-L152
train
rtconner/laravel-tagging
src/Taggable.php
Taggable.retag
public function retag($tagNames) { $tagNames = static::$taggingUtility->makeTagArray($tagNames); $currentTagNames = $this->tagNames(); $deletions = array_diff($currentTagNames, $tagNames); $additions = array_diff($tagNames, $currentTagNames); $this->untag($deletions); foreach($additions as $tagName) { $this->addTag($tagName); } }
php
public function retag($tagNames) { $tagNames = static::$taggingUtility->makeTagArray($tagNames); $currentTagNames = $this->tagNames(); $deletions = array_diff($currentTagNames, $tagNames); $additions = array_diff($tagNames, $currentTagNames); $this->untag($deletions); foreach($additions as $tagName) { $this->addTag($tagName); } }
[ "public", "function", "retag", "(", "$", "tagNames", ")", "{", "$", "tagNames", "=", "static", "::", "$", "taggingUtility", "->", "makeTagArray", "(", "$", "tagNames", ")", ";", "$", "currentTagNames", "=", "$", "this", "->", "tagNames", "(", ")", ";", ...
Replace the tags from this model @param string|array $tagNames
[ "Replace", "the", "tags", "from", "this", "model" ]
2b151ba2962b6ae6cc1499b5983b95c5174787d9
https://github.com/rtconner/laravel-tagging/blob/2b151ba2962b6ae6cc1499b5983b95c5174787d9/src/Taggable.php#L159-L172
train
rtconner/laravel-tagging
src/Util.php
Util.makeTagArray
public function makeTagArray($tagNames) { if(is_array($tagNames) && count($tagNames) == 1) { $tagNames = reset($tagNames); } if(is_string($tagNames)) { $tagNames = explode(',', $tagNames); } elseif(!is_array($tagNames)) { $tagNames = array(null); } $tagNames = array_map('trim', $tagNames); return array_values($tagNames); }
php
public function makeTagArray($tagNames) { if(is_array($tagNames) && count($tagNames) == 1) { $tagNames = reset($tagNames); } if(is_string($tagNames)) { $tagNames = explode(',', $tagNames); } elseif(!is_array($tagNames)) { $tagNames = array(null); } $tagNames = array_map('trim', $tagNames); return array_values($tagNames); }
[ "public", "function", "makeTagArray", "(", "$", "tagNames", ")", "{", "if", "(", "is_array", "(", "$", "tagNames", ")", "&&", "count", "(", "$", "tagNames", ")", "==", "1", ")", "{", "$", "tagNames", "=", "reset", "(", "$", "tagNames", ")", ";", "}...
Converts input into array @param string|array $tagNames @return array
[ "Converts", "input", "into", "array" ]
2b151ba2962b6ae6cc1499b5983b95c5174787d9
https://github.com/rtconner/laravel-tagging/blob/2b151ba2962b6ae6cc1499b5983b95c5174787d9/src/Util.php#L19-L34
train
rtconner/laravel-tagging
src/Model/Tag.php
Tag.setGroup
public function setGroup($groupName) { $tagGroup = TagGroup::where('slug', $this->taggingUtility->slug($groupName))->first(); if ($tagGroup) { $this->group()->associate($tagGroup); $this->save(); return $this; } else { throw new \RuntimeException('No Tag Group found: '. $groupName); } }
php
public function setGroup($groupName) { $tagGroup = TagGroup::where('slug', $this->taggingUtility->slug($groupName))->first(); if ($tagGroup) { $this->group()->associate($tagGroup); $this->save(); return $this; } else { throw new \RuntimeException('No Tag Group found: '. $groupName); } }
[ "public", "function", "setGroup", "(", "$", "groupName", ")", "{", "$", "tagGroup", "=", "TagGroup", "::", "where", "(", "'slug'", ",", "$", "this", "->", "taggingUtility", "->", "slug", "(", "$", "groupName", ")", ")", "->", "first", "(", ")", ";", ...
Tag group setter @param string $groupName @return Tag
[ "Tag", "group", "setter" ]
2b151ba2962b6ae6cc1499b5983b95c5174787d9
https://github.com/rtconner/laravel-tagging/blob/2b151ba2962b6ae6cc1499b5983b95c5174787d9/src/Model/Tag.php#L57-L69
train
rtconner/laravel-tagging
src/Model/Tag.php
Tag.removeGroup
public function removeGroup(string $groupName) { $tagGroup = TagGroup::query()->where('slug', $this->taggingUtility->slug($groupName))->first(); if ($tagGroup) { $this->group()->dissociate($tagGroup); $this->save(); return $this; } else { throw new \RuntimeException('No Tag Group found: '. $groupName); } }
php
public function removeGroup(string $groupName) { $tagGroup = TagGroup::query()->where('slug', $this->taggingUtility->slug($groupName))->first(); if ($tagGroup) { $this->group()->dissociate($tagGroup); $this->save(); return $this; } else { throw new \RuntimeException('No Tag Group found: '. $groupName); } }
[ "public", "function", "removeGroup", "(", "string", "$", "groupName", ")", "{", "$", "tagGroup", "=", "TagGroup", "::", "query", "(", ")", "->", "where", "(", "'slug'", ",", "$", "this", "->", "taggingUtility", "->", "slug", "(", "$", "groupName", ")", ...
Tag group remove @param string $groupName @return Tag
[ "Tag", "group", "remove" ]
2b151ba2962b6ae6cc1499b5983b95c5174787d9
https://github.com/rtconner/laravel-tagging/blob/2b151ba2962b6ae6cc1499b5983b95c5174787d9/src/Model/Tag.php#L76-L88
train
rtconner/laravel-tagging
src/Model/Tag.php
Tag.isInGroup
public function isInGroup($groupName): bool { if ($this->group && ($this->group->slug == $this->taggingUtility->slug($groupName))) { return true; } return false; }
php
public function isInGroup($groupName): bool { if ($this->group && ($this->group->slug == $this->taggingUtility->slug($groupName))) { return true; } return false; }
[ "public", "function", "isInGroup", "(", "$", "groupName", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "group", "&&", "(", "$", "this", "->", "group", "->", "slug", "==", "$", "this", "->", "taggingUtility", "->", "slug", "(", "$", "groupName...
Tag group helper function @param string $groupName @return bool
[ "Tag", "group", "helper", "function" ]
2b151ba2962b6ae6cc1499b5983b95c5174787d9
https://github.com/rtconner/laravel-tagging/blob/2b151ba2962b6ae6cc1499b5983b95c5174787d9/src/Model/Tag.php#L95-L101
train
rtconner/laravel-tagging
src/Model/Tag.php
Tag.scopeInGroup
public function scopeInGroup(Builder $query, $groupName) { $groupSlug = $this->taggingUtility->slug($groupName); return $query->whereHas('group', function (Builder $query) use ($groupSlug) { $query->where('slug', $groupSlug); }); }
php
public function scopeInGroup(Builder $query, $groupName) { $groupSlug = $this->taggingUtility->slug($groupName); return $query->whereHas('group', function (Builder $query) use ($groupSlug) { $query->where('slug', $groupSlug); }); }
[ "public", "function", "scopeInGroup", "(", "Builder", "$", "query", ",", "$", "groupName", ")", "{", "$", "groupSlug", "=", "$", "this", "->", "taggingUtility", "->", "slug", "(", "$", "groupName", ")", ";", "return", "$", "query", "->", "whereHas", "(",...
Get suggested tags @param Builder $query @param $groupName @return
[ "Get", "suggested", "tags" ]
2b151ba2962b6ae6cc1499b5983b95c5174787d9
https://github.com/rtconner/laravel-tagging/blob/2b151ba2962b6ae6cc1499b5983b95c5174787d9/src/Model/Tag.php#L125-L132
train
rtconner/laravel-tagging
src/Model/TagGroup.php
TagGroup.setNameAttribute
public function setNameAttribute($value) { $this->attributes['name'] = $value; $this->attributes['slug'] = Str::slug($value); }
php
public function setNameAttribute($value) { $this->attributes['name'] = $value; $this->attributes['slug'] = Str::slug($value); }
[ "public", "function", "setNameAttribute", "(", "$", "value", ")", "{", "$", "this", "->", "attributes", "[", "'name'", "]", "=", "$", "value", ";", "$", "this", "->", "attributes", "[", "'slug'", "]", "=", "Str", "::", "slug", "(", "$", "value", ")",...
sets the slug when setting the group name @return void
[ "sets", "the", "slug", "when", "setting", "the", "group", "name" ]
2b151ba2962b6ae6cc1499b5983b95c5174787d9
https://github.com/rtconner/laravel-tagging/blob/2b151ba2962b6ae6cc1499b5983b95c5174787d9/src/Model/TagGroup.php#L55-L59
train
recurly/recurly-client-php
lib/recurly/coupon.php
Recurly_Coupon.createUpdateXML
public function createUpdateXML() { $doc = $this->createDocument(); $root = $doc->appendChild($doc->createElement($this->getNodeName())); foreach ($this->getUpdatableAttributes() as $attr) { $val = $this->$attr; if ($val instanceof DateTime) { $val = $val->format('c'); } $root->appendChild($doc->createElement($attr, $val)); } return $this->renderXML($doc); }
php
public function createUpdateXML() { $doc = $this->createDocument(); $root = $doc->appendChild($doc->createElement($this->getNodeName())); foreach ($this->getUpdatableAttributes() as $attr) { $val = $this->$attr; if ($val instanceof DateTime) { $val = $val->format('c'); } $root->appendChild($doc->createElement($attr, $val)); } return $this->renderXML($doc); }
[ "public", "function", "createUpdateXML", "(", ")", "{", "$", "doc", "=", "$", "this", "->", "createDocument", "(", ")", ";", "$", "root", "=", "$", "doc", "->", "appendChild", "(", "$", "doc", "->", "createElement", "(", "$", "this", "->", "getNodeName...
only uses the updateable attributes
[ "only", "uses", "the", "updateable", "attributes" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/coupon.php#L111-L127
train
recurly/recurly-client-php
lib/recurly/client.php
Recurly_Client._sendRequest
private function _sendRequest($method, $uri, $data = '') { if(function_exists('mb_internal_encoding')) mb_internal_encoding(self::DEFAULT_ENCODING); if (substr($uri,0,4) != 'http') $uri = $this->baseUri() . $uri; $this->_verifyUri($uri); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); if (self::$CACertPath) { curl_setopt($ch, CURLOPT_CAINFO, self::$CACertPath); } curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); curl_setopt($ch, CURLOPT_MAXREDIRS, 1); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 45); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/xml; charset=utf-8', 'Accept: application/xml', Recurly_Client::__userAgent(), 'Accept-Language: ' . $this->_acceptLanguage, 'X-Api-Version: ' . Recurly_Client::$apiVersion )); curl_setopt($ch, CURLOPT_USERPWD, $this->apiKey()); if ('POST' == $method) { curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } else if ('PUT' == $method) { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } else if ('HEAD' == $method) { curl_setopt($ch, CURLOPT_NOBODY, TRUE); } else if('GET' != $method) { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); } $response = curl_exec($ch); if ($response === false) { $errorNumber = curl_errno($ch); $message = curl_error($ch); curl_close($ch); $this->_raiseCurlError($errorNumber, $message); } $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); list($header, $body) = explode("\r\n\r\n", $response, 2); // Larger responses end up prefixed by "HTTP/1.1 100 Continue\r\n\r\n" which // needs to be discarded. if (strpos($header," 100 Continue") !== false ) { list($header, $body) = explode("\r\n\r\n", $body, 2); } $headers = $this->_getHeaders($header); return new Recurly_ClientResponse($statusCode, $headers, $body); }
php
private function _sendRequest($method, $uri, $data = '') { if(function_exists('mb_internal_encoding')) mb_internal_encoding(self::DEFAULT_ENCODING); if (substr($uri,0,4) != 'http') $uri = $this->baseUri() . $uri; $this->_verifyUri($uri); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); if (self::$CACertPath) { curl_setopt($ch, CURLOPT_CAINFO, self::$CACertPath); } curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); curl_setopt($ch, CURLOPT_MAXREDIRS, 1); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 45); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/xml; charset=utf-8', 'Accept: application/xml', Recurly_Client::__userAgent(), 'Accept-Language: ' . $this->_acceptLanguage, 'X-Api-Version: ' . Recurly_Client::$apiVersion )); curl_setopt($ch, CURLOPT_USERPWD, $this->apiKey()); if ('POST' == $method) { curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } else if ('PUT' == $method) { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } else if ('HEAD' == $method) { curl_setopt($ch, CURLOPT_NOBODY, TRUE); } else if('GET' != $method) { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); } $response = curl_exec($ch); if ($response === false) { $errorNumber = curl_errno($ch); $message = curl_error($ch); curl_close($ch); $this->_raiseCurlError($errorNumber, $message); } $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); list($header, $body) = explode("\r\n\r\n", $response, 2); // Larger responses end up prefixed by "HTTP/1.1 100 Continue\r\n\r\n" which // needs to be discarded. if (strpos($header," 100 Continue") !== false ) { list($header, $body) = explode("\r\n\r\n", $body, 2); } $headers = $this->_getHeaders($header); return new Recurly_ClientResponse($statusCode, $headers, $body); }
[ "private", "function", "_sendRequest", "(", "$", "method", ",", "$", "uri", ",", "$", "data", "=", "''", ")", "{", "if", "(", "function_exists", "(", "'mb_internal_encoding'", ")", ")", "mb_internal_encoding", "(", "self", "::", "DEFAULT_ENCODING", ")", ";",...
Sends an HTTP request to the Recurly API @param string $method Specifies the HTTP method to be used for this request @param string $uri Target URI for this request (relative to the API root) @param mixed $data x-www-form-urlencoded data (or array) to be sent in a POST request body @return Recurly_ClientResponse @throws Recurly_Error
[ "Sends", "an", "HTTP", "request", "to", "the", "Recurly", "API" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/client.php#L135-L208
train
recurly/recurly-client-php
lib/recurly/client.php
Recurly_Client.getFile
public function getFile($uri, $file_pointer) { $this->_verifyUri($uri); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); curl_setopt($ch, CURLOPT_MAXREDIRS, 1); curl_setopt($ch, CURLOPT_HEADER, FALSE); // do not return headers curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_HTTPHEADER, array( Recurly_Client::__userAgent(), 'X-Api-Version: ' . Recurly_Client::$apiVersion )); curl_setopt($ch, CURLOPT_FILE, $file_pointer); $response = curl_exec($ch); if ($response === false) { $errorNumber = curl_errno($ch); $message = curl_error($ch); curl_close($ch); $this->_raiseCurlError($errorNumber, $message); } curl_close($ch); }
php
public function getFile($uri, $file_pointer) { $this->_verifyUri($uri); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); curl_setopt($ch, CURLOPT_MAXREDIRS, 1); curl_setopt($ch, CURLOPT_HEADER, FALSE); // do not return headers curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_HTTPHEADER, array( Recurly_Client::__userAgent(), 'X-Api-Version: ' . Recurly_Client::$apiVersion )); curl_setopt($ch, CURLOPT_FILE, $file_pointer); $response = curl_exec($ch); if ($response === false) { $errorNumber = curl_errno($ch); $message = curl_error($ch); curl_close($ch); $this->_raiseCurlError($errorNumber, $message); } curl_close($ch); }
[ "public", "function", "getFile", "(", "$", "uri", ",", "$", "file_pointer", ")", "{", "$", "this", "->", "_verifyUri", "(", "$", "uri", ")", ";", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$...
Saves the contents of a URI into a file handle. @param string $uri Target URI for the request (complete URL) @param resource $file_pointer Resourced returned from fopen() with write mode. @throws Recurly_Error
[ "Saves", "the", "contents", "of", "a", "URI", "into", "a", "file", "handle", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/client.php#L267-L295
train
recurly/recurly-client-php
lib/recurly/client.php
Recurly_Client.getPdf
public function getPdf($uri, $locale = null) { if (substr($uri,0,4) != 'http') $uri = $this->baseUri() . $uri; $this->_verifyUri($uri); if (is_null($locale)) $locale = $this->_acceptLanguage; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); curl_setopt($ch, CURLOPT_MAXREDIRS, 1); curl_setopt($ch, CURLOPT_HEADER, FALSE); // do not return headers curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Accept: application/pdf', Recurly_Client::__userAgent(), 'Accept-Language: ' . $locale, 'X-Api-Version: ' . Recurly_Client::$apiVersion )); curl_setopt($ch, CURLOPT_USERPWD, $this->apiKey()); $response = curl_exec($ch); if ($response === false) { $errorNumber = curl_errno($ch); $message = curl_error($ch); curl_close($ch); $this->_raiseCurlError($errorNumber, $message); } curl_close($ch); return $response; }
php
public function getPdf($uri, $locale = null) { if (substr($uri,0,4) != 'http') $uri = $this->baseUri() . $uri; $this->_verifyUri($uri); if (is_null($locale)) $locale = $this->_acceptLanguage; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); curl_setopt($ch, CURLOPT_MAXREDIRS, 1); curl_setopt($ch, CURLOPT_HEADER, FALSE); // do not return headers curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Accept: application/pdf', Recurly_Client::__userAgent(), 'Accept-Language: ' . $locale, 'X-Api-Version: ' . Recurly_Client::$apiVersion )); curl_setopt($ch, CURLOPT_USERPWD, $this->apiKey()); $response = curl_exec($ch); if ($response === false) { $errorNumber = curl_errno($ch); $message = curl_error($ch); curl_close($ch); $this->_raiseCurlError($errorNumber, $message); } curl_close($ch); return $response; }
[ "public", "function", "getPdf", "(", "$", "uri", ",", "$", "locale", "=", "null", ")", "{", "if", "(", "substr", "(", "$", "uri", ",", "0", ",", "4", ")", "!=", "'http'", ")", "$", "uri", "=", "$", "this", "->", "baseUri", "(", ")", ".", "$",...
Requests a PDF document from the given URI @param string $uri Target URI for this request (relative to the API root) @param string $locale Locale for the PDF invoice (e.g. "en-GB", "en-US", "fr") @return string $response PDF document @throws Recurly_Error
[ "Requests", "a", "PDF", "document", "from", "the", "given", "URI" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/client.php#L305-L346
train
recurly/recurly-client-php
lib/recurly/purchase.php
Recurly_Purchase.capture
public static function capture($transactionUUID, $client = null) { return Recurly_Base::_post('/purchases/transaction-uuid-' . rawurlencode($transactionUUID) . '/capture', null, $client); }
php
public static function capture($transactionUUID, $client = null) { return Recurly_Base::_post('/purchases/transaction-uuid-' . rawurlencode($transactionUUID) . '/capture', null, $client); }
[ "public", "static", "function", "capture", "(", "$", "transactionUUID", ",", "$", "client", "=", "null", ")", "{", "return", "Recurly_Base", "::", "_post", "(", "'/purchases/transaction-uuid-'", ".", "rawurlencode", "(", "$", "transactionUUID", ")", ".", "'/capt...
Capture an open Authorization request @param $transactionUUID string To get this uuid, do something like: $invoiceCollection->charge_invoice->transactions->current()->uuid;. @param Recurly_Client $client Optional client for the request, useful for mocking the client @return object Recurly_InvoiceCollection @throws Recurly_Error Note: To use this endpoint, you may have to contact Recurly support to have it enabled on your subdomain.
[ "Capture", "an", "open", "Authorization", "request" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/purchase.php#L74-L76
train
recurly/recurly-client-php
lib/recurly/purchase.php
Recurly_Purchase.cancel
public static function cancel($transactionUUID, $client = null) { return Recurly_Base::_post('/purchases/transaction-uuid-' . rawurlencode($transactionUUID) . '/cancel', null, $client); }
php
public static function cancel($transactionUUID, $client = null) { return Recurly_Base::_post('/purchases/transaction-uuid-' . rawurlencode($transactionUUID) . '/cancel', null, $client); }
[ "public", "static", "function", "cancel", "(", "$", "transactionUUID", ",", "$", "client", "=", "null", ")", "{", "return", "Recurly_Base", "::", "_post", "(", "'/purchases/transaction-uuid-'", ".", "rawurlencode", "(", "$", "transactionUUID", ")", ".", "'/cance...
Cancel an open Authorization request @param $transactionUUID string To get this uuid, do something like: $invoiceCollection->charge_invoice->transactions->current()->uuid;. @param Recurly_Client $client Optional client for the request, useful for mocking the client @return object Recurly_InvoiceCollection @throws Recurly_Error Note: To use this endpoint, you may have to contact Recurly support to have it enabled on your subdomain.
[ "Cancel", "an", "open", "Authorization", "request" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/purchase.php#L88-L90
train
recurly/recurly-client-php
lib/recurly/stub.php
Recurly_Stub.get
function get($params = null) { $uri = self::_uriWithParams($this->_href, $params); $object = self::_get($uri, $this->_client); if ($this->_href && !$object->getHref()) { $object->setHref($this->_href); } return $object; }
php
function get($params = null) { $uri = self::_uriWithParams($this->_href, $params); $object = self::_get($uri, $this->_client); if ($this->_href && !$object->getHref()) { $object->setHref($this->_href); } return $object; }
[ "function", "get", "(", "$", "params", "=", "null", ")", "{", "$", "uri", "=", "self", "::", "_uriWithParams", "(", "$", "this", "->", "_href", ",", "$", "params", ")", ";", "$", "object", "=", "self", "::", "_get", "(", "$", "uri", ",", "$", "...
Retrieve the stubbed resource. @param array $params @return object @throws Recurly_Error
[ "Retrieve", "the", "stubbed", "resource", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/stub.php#L26-L33
train
recurly/recurly-client-php
lib/recurly/transaction.php
Recurly_Transaction.get
public static function get($uuid, $client = null) { return Recurly_Base::_get(Recurly_Transaction::uriForTransaction($uuid), $client); }
php
public static function get($uuid, $client = null) { return Recurly_Base::_get(Recurly_Transaction::uriForTransaction($uuid), $client); }
[ "public", "static", "function", "get", "(", "$", "uuid", ",", "$", "client", "=", "null", ")", "{", "return", "Recurly_Base", "::", "_get", "(", "Recurly_Transaction", "::", "uriForTransaction", "(", "$", "uuid", ")", ",", "$", "client", ")", ";", "}" ]
Get Transaction by uuid @param string $uuid @param Recurly_Client $client Optional client for the request, useful for mocking the client @return object Recurly_Transaction @throws Recurly_Error
[ "Get", "Transaction", "by", "uuid" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/transaction.php#L47-L49
train
recurly/recurly-client-php
lib/recurly/transaction.php
Recurly_Transaction.refund
public function refund($amountInCents = null) { $uri = $this->uri(); if (!is_null($amountInCents)) { $uri .= '?amount_in_cents=' . strval(intval($amountInCents)); } $this->_save(Recurly_Client::DELETE, $uri); }
php
public function refund($amountInCents = null) { $uri = $this->uri(); if (!is_null($amountInCents)) { $uri .= '?amount_in_cents=' . strval(intval($amountInCents)); } $this->_save(Recurly_Client::DELETE, $uri); }
[ "public", "function", "refund", "(", "$", "amountInCents", "=", "null", ")", "{", "$", "uri", "=", "$", "this", "->", "uri", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "amountInCents", ")", ")", "{", "$", "uri", ".=", "'?amount_in_cents='", ...
Refund a previous, successful transaction @param int $amountInCents @throws Recurly_Error
[ "Refund", "a", "previous", "successful", "transaction" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/transaction.php#L64-L70
train
recurly/recurly-client-php
lib/recurly/pager.php
Recurly_Pager.count
public function count() { if (isset($this->_href)) { $headers = Recurly_Base::_head($this->_href, $this->_client); if (isset($headers['x-records'])) { return intval($headers['x-records']); } } elseif (isset($this->_objects) && is_array($this->_objects)) { return count($this->_objects); } return null; }
php
public function count() { if (isset($this->_href)) { $headers = Recurly_Base::_head($this->_href, $this->_client); if (isset($headers['x-records'])) { return intval($headers['x-records']); } } elseif (isset($this->_objects) && is_array($this->_objects)) { return count($this->_objects); } return null; }
[ "public", "function", "count", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_href", ")", ")", "{", "$", "headers", "=", "Recurly_Base", "::", "_head", "(", "$", "this", "->", "_href", ",", "$", "this", "->", "_client", ")", ";", "i...
If the pager has a URL this will send a HEAD request to get the count of all records. Otherwise it'll return the count of the cached _objects. @return integer number of records in list @throws Recurly_Error
[ "If", "the", "pager", "has", "a", "URL", "this", "will", "send", "a", "HEAD", "request", "to", "get", "the", "count", "of", "all", "records", ".", "Otherwise", "it", "ll", "return", "the", "count", "of", "the", "cached", "_objects", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/pager.php#L21-L32
train
recurly/recurly-client-php
lib/recurly/pager.php
Recurly_Pager.current
public function current() { // Work around pre-PHP 5.5 issue that prevents `empty($this->count())`: if (!isset($this->_objects)) { $this->_loadFrom($this->_href); } if ($this->_position >= sizeof($this->_objects)) { if (isset($this->_links['next'])) { $this->_loadFrom($this->_links['next']); $this->_position = 0; } else if (empty($this->_objects) && ($this->_position == 0)) { return null; } else { throw new Recurly_Error("Pager is not in a valid state"); } } return $this->_objects[$this->_position]; }
php
public function current() { // Work around pre-PHP 5.5 issue that prevents `empty($this->count())`: if (!isset($this->_objects)) { $this->_loadFrom($this->_href); } if ($this->_position >= sizeof($this->_objects)) { if (isset($this->_links['next'])) { $this->_loadFrom($this->_links['next']); $this->_position = 0; } else if (empty($this->_objects) && ($this->_position == 0)) { return null; } else { throw new Recurly_Error("Pager is not in a valid state"); } } return $this->_objects[$this->_position]; }
[ "public", "function", "current", "(", ")", "{", "// Work around pre-PHP 5.5 issue that prevents `empty($this->count())`:", "if", "(", "!", "isset", "(", "$", "this", "->", "_objects", ")", ")", "{", "$", "this", "->", "_loadFrom", "(", "$", "this", "->", "_href"...
The current object @return Recurly_Resource the current object @throws Recurly_Error
[ "The", "current", "object" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/pager.php#L50-L71
train
recurly/recurly-client-php
lib/recurly/pager.php
Recurly_Pager._loadFrom
protected function _loadFrom($uri) { if (empty($uri)) { return; } $response = $this->_client->request(Recurly_Client::GET, $uri); $response->assertValidResponse(); $this->_objects = array(); $this->__parseXmlToUpdateObject($response->body); $this->_afterParseResponse($response, $uri); }
php
protected function _loadFrom($uri) { if (empty($uri)) { return; } $response = $this->_client->request(Recurly_Client::GET, $uri); $response->assertValidResponse(); $this->_objects = array(); $this->__parseXmlToUpdateObject($response->body); $this->_afterParseResponse($response, $uri); }
[ "protected", "function", "_loadFrom", "(", "$", "uri", ")", "{", "if", "(", "empty", "(", "$", "uri", ")", ")", "{", "return", ";", "}", "$", "response", "=", "$", "this", "->", "_client", "->", "request", "(", "Recurly_Client", "::", "GET", ",", "...
Load another page of results into this pager. @param $uri @throws Recurly_Error
[ "Load", "another", "page", "of", "results", "into", "this", "pager", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/pager.php#L100-L111
train
recurly/recurly-client-php
lib/recurly/pager.php
Recurly_Pager._loadLinks
private function _loadLinks($response) { $this->_links = array(); if (isset($response->headers['link'])) { $links = $response->headers['link']; preg_match_all('/\<([^>]+)\>; rel=\"([^"]+)\"/', $links, $matches); if (sizeof($matches) > 2) { for ($i = 0; $i < sizeof($matches[1]); $i++) { $this->_links[$matches[2][$i]] = $matches[1][$i]; } } } }
php
private function _loadLinks($response) { $this->_links = array(); if (isset($response->headers['link'])) { $links = $response->headers['link']; preg_match_all('/\<([^>]+)\>; rel=\"([^"]+)\"/', $links, $matches); if (sizeof($matches) > 2) { for ($i = 0; $i < sizeof($matches[1]); $i++) { $this->_links[$matches[2][$i]] = $matches[1][$i]; } } } }
[ "private", "function", "_loadLinks", "(", "$", "response", ")", "{", "$", "this", "->", "_links", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "response", "->", "headers", "[", "'link'", "]", ")", ")", "{", "$", "links", "=", "$", "...
The 'Links' header contains links to the next, previous, and starting pages. This parses the links header into an array of links if the header is present. @param $response
[ "The", "Links", "header", "contains", "links", "to", "the", "next", "previous", "and", "starting", "pages", ".", "This", "parses", "the", "links", "header", "into", "an", "array", "of", "links", "if", "the", "header", "is", "present", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/pager.php#L132-L144
train
recurly/recurly-client-php
lib/recurly/gift_card.php
Recurly_GiftCard.get
public static function get($giftCardId, $client = null) { return Recurly_Base::_get(Recurly_GiftCard::uriForGiftCard($giftCardId), $client); }
php
public static function get($giftCardId, $client = null) { return Recurly_Base::_get(Recurly_GiftCard::uriForGiftCard($giftCardId), $client); }
[ "public", "static", "function", "get", "(", "$", "giftCardId", ",", "$", "client", "=", "null", ")", "{", "return", "Recurly_Base", "::", "_get", "(", "Recurly_GiftCard", "::", "uriForGiftCard", "(", "$", "giftCardId", ")", ",", "$", "client", ")", ";", ...
Get a gift card by the id @param string $giftCardId The gift card ID @param Recurly_Client $client Optional client for the request, useful for mocking the client @return object Recurly_Resource or null @throws Recurly_Error
[ "Get", "a", "gift", "card", "by", "the", "id" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/gift_card.php#L32-L34
train
recurly/recurly-client-php
lib/recurly/gift_card.php
Recurly_GiftCard.redeem
public function redeem($accountCode) { $doc = $this->createDocument(); $root = $doc->appendChild($doc->createElement('recipient_account')); $root->appendChild($doc->createElement('account_code', $accountCode)); $uri = Recurly_GiftCard::uriForGiftCard($this->redemption_code) . '/redeem'; $this->_save(Recurly_Client::POST, $uri, $this->renderXML($doc)); }
php
public function redeem($accountCode) { $doc = $this->createDocument(); $root = $doc->appendChild($doc->createElement('recipient_account')); $root->appendChild($doc->createElement('account_code', $accountCode)); $uri = Recurly_GiftCard::uriForGiftCard($this->redemption_code) . '/redeem'; $this->_save(Recurly_Client::POST, $uri, $this->renderXML($doc)); }
[ "public", "function", "redeem", "(", "$", "accountCode", ")", "{", "$", "doc", "=", "$", "this", "->", "createDocument", "(", ")", ";", "$", "root", "=", "$", "doc", "->", "appendChild", "(", "$", "doc", "->", "createElement", "(", "'recipient_account'",...
Redeem a gift card given an account code @param string $accountCode The account code @throws Recurly_Error
[ "Redeem", "a", "gift", "card", "given", "an", "account", "code" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/gift_card.php#L43-L50
train
recurly/recurly-client-php
lib/recurly/base.php
Recurly_Base._get
public static function _get($uri, $client = null) { if (is_null($client)) { $client = new Recurly_Client(); } $response = $client->request(Recurly_Client::GET, $uri); $response->assertValidResponse(); return Recurly_Base::__parseResponseToNewObject($response, $uri, $client); }
php
public static function _get($uri, $client = null) { if (is_null($client)) { $client = new Recurly_Client(); } $response = $client->request(Recurly_Client::GET, $uri); $response->assertValidResponse(); return Recurly_Base::__parseResponseToNewObject($response, $uri, $client); }
[ "public", "static", "function", "_get", "(", "$", "uri", ",", "$", "client", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "client", ")", ")", "{", "$", "client", "=", "new", "Recurly_Client", "(", ")", ";", "}", "$", "response", "=", "$...
Request the URI, validate the response and return the object. @param string Resource URI, if not fully qualified, the base URL will be prepended @param string Optional client for the request, useful for mocking the client @return object Recurly_Resource or null @throws Recurly_Error
[ "Request", "the", "URI", "validate", "the", "response", "and", "return", "the", "object", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/base.php#L27-L35
train
recurly/recurly-client-php
lib/recurly/base.php
Recurly_Base._head
public static function _head($uri, $client = null) { if (is_null($client)) { $client = new Recurly_Client(); } $response = $client->request(Recurly_Client::HEAD, $uri); $response->assertValidResponse(); return $response->headers; }
php
public static function _head($uri, $client = null) { if (is_null($client)) { $client = new Recurly_Client(); } $response = $client->request(Recurly_Client::HEAD, $uri); $response->assertValidResponse(); return $response->headers; }
[ "public", "static", "function", "_head", "(", "$", "uri", ",", "$", "client", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "client", ")", ")", "{", "$", "client", "=", "new", "Recurly_Client", "(", ")", ";", "}", "$", "response", "=", "...
Send a HEAD request to the URI, validate the response and return the headers. @param string Resource URI, if not fully qualified, the base URL will be prepended @param string Optional client for the request, useful for mocking the client @throws Recurly_Error
[ "Send", "a", "HEAD", "request", "to", "the", "URI", "validate", "the", "response", "and", "return", "the", "headers", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/base.php#L43-L51
train
recurly/recurly-client-php
lib/recurly/base.php
Recurly_Base._post
protected static function _post($uri, $data = null, $client = null) { if (is_null($client)) { $client = new Recurly_Client(); } $response = $client->request(Recurly_Client::POST, $uri, $data); $response->assertValidResponse(); $object = Recurly_Base::__parseResponseToNewObject($response, $uri, $client); $response->assertSuccessResponse($object); return $object; }
php
protected static function _post($uri, $data = null, $client = null) { if (is_null($client)) { $client = new Recurly_Client(); } $response = $client->request(Recurly_Client::POST, $uri, $data); $response->assertValidResponse(); $object = Recurly_Base::__parseResponseToNewObject($response, $uri, $client); $response->assertSuccessResponse($object); return $object; }
[ "protected", "static", "function", "_post", "(", "$", "uri", ",", "$", "data", "=", "null", ",", "$", "client", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "client", ")", ")", "{", "$", "client", "=", "new", "Recurly_Client", "(", ")", ...
Post to the URI, validate the response and return the object. @param string Resource URI, if not fully qualified, the base URL will be prepended @param string Data to post to the URI @param string Optional client for the request, useful for mocking the client @return object Recurly_Resource or null @throws Recurly_Error
[ "Post", "to", "the", "URI", "validate", "the", "response", "and", "return", "the", "object", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/base.php#L61-L71
train
recurly/recurly-client-php
lib/recurly/base.php
Recurly_Base._put
protected static function _put($uri, $client = null) { if (is_null($client)) { $client = new Recurly_Client(); } $response = $client->request(Recurly_Client::PUT, $uri); $response->assertValidResponse(); $object = null; if ($response->body) { $object = Recurly_Base::__parseResponseToNewObject($response, $uri, $client); } $response->assertSuccessResponse($object); return $object; }
php
protected static function _put($uri, $client = null) { if (is_null($client)) { $client = new Recurly_Client(); } $response = $client->request(Recurly_Client::PUT, $uri); $response->assertValidResponse(); $object = null; if ($response->body) { $object = Recurly_Base::__parseResponseToNewObject($response, $uri, $client); } $response->assertSuccessResponse($object); return $object; }
[ "protected", "static", "function", "_put", "(", "$", "uri", ",", "$", "client", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "client", ")", ")", "{", "$", "client", "=", "new", "Recurly_Client", "(", ")", ";", "}", "$", "response", "=", ...
Put to the URI, validate the response and return the object. @param string Resource URI, if not fully qualified, the base URL will be prepended @param string Optional client for the request, useful for mocking the client @return object Recurly_Resource or null @throws Recurly_Error
[ "Put", "to", "the", "URI", "validate", "the", "response", "and", "return", "the", "object", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/base.php#L80-L93
train
recurly/recurly-client-php
lib/recurly/base.php
Recurly_Base._delete
protected static function _delete($uri, $client = null) { if (is_null($client)) { $client = new Recurly_Client(); } $response = $client->request(Recurly_Client::DELETE, $uri); $response->assertValidResponse(); if ($response->body) { return Recurly_Base::__parseResponseToNewObject($response, $uri, $client); } return null; }
php
protected static function _delete($uri, $client = null) { if (is_null($client)) { $client = new Recurly_Client(); } $response = $client->request(Recurly_Client::DELETE, $uri); $response->assertValidResponse(); if ($response->body) { return Recurly_Base::__parseResponseToNewObject($response, $uri, $client); } return null; }
[ "protected", "static", "function", "_delete", "(", "$", "uri", ",", "$", "client", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "client", ")", ")", "{", "$", "client", "=", "new", "Recurly_Client", "(", ")", ";", "}", "$", "response", "="...
Delete the URI, validate the response and return the object. @param string Resource URI, if not fully qualified, the base URL will be appended @param string Optional client for the request, useful for mocking the client @return object Recurly_Resource or null @throws Recurly_Error
[ "Delete", "the", "URI", "validate", "the", "response", "and", "return", "the", "object", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/base.php#L102-L113
train
recurly/recurly-client-php
lib/recurly/base.php
Recurly_Base.__parseResponseToNewObject
protected static function __parseResponseToNewObject($response, $uri, $client) { $dom = new DOMDocument(); // Attempt to prevent XXE that could be exploited through loadXML() libxml_disable_entity_loader(true); if (empty($response->body) || !$dom->loadXML($response->body, LIBXML_NOBLANKS)) { return null; } $rootNode = $dom->documentElement; $obj = Recurly_Resource::__createNodeObject($rootNode, $client); Recurly_Resource::__parseXmlToObject($rootNode->firstChild, $obj, $client); if ($obj instanceof self) { $obj->_afterParseResponse($response, $uri); $obj->setHeaders($response->headers); } return $obj; }
php
protected static function __parseResponseToNewObject($response, $uri, $client) { $dom = new DOMDocument(); // Attempt to prevent XXE that could be exploited through loadXML() libxml_disable_entity_loader(true); if (empty($response->body) || !$dom->loadXML($response->body, LIBXML_NOBLANKS)) { return null; } $rootNode = $dom->documentElement; $obj = Recurly_Resource::__createNodeObject($rootNode, $client); Recurly_Resource::__parseXmlToObject($rootNode->firstChild, $obj, $client); if ($obj instanceof self) { $obj->_afterParseResponse($response, $uri); $obj->setHeaders($response->headers); } return $obj; }
[ "protected", "static", "function", "__parseResponseToNewObject", "(", "$", "response", ",", "$", "uri", ",", "$", "client", ")", "{", "$", "dom", "=", "new", "DOMDocument", "(", ")", ";", "// Attempt to prevent XXE that could be exploited through loadXML()", "libxml_d...
Use a valid Recurly_Response to populate a new object.
[ "Use", "a", "valid", "Recurly_Response", "to", "populate", "a", "new", "object", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/base.php#L283-L302
train
recurly/recurly-client-php
lib/recurly/subscription.php
Recurly_Subscription.preview
public function preview() { if ($this->uuid) { $this->_save(Recurly_Client::POST, $this->uri() . '/preview'); } else { $this->_save(Recurly_Client::POST, Recurly_Client::PATH_SUBSCRIPTIONS . '/preview'); } }
php
public function preview() { if ($this->uuid) { $this->_save(Recurly_Client::POST, $this->uri() . '/preview'); } else { $this->_save(Recurly_Client::POST, Recurly_Client::PATH_SUBSCRIPTIONS . '/preview'); } }
[ "public", "function", "preview", "(", ")", "{", "if", "(", "$", "this", "->", "uuid", ")", "{", "$", "this", "->", "_save", "(", "Recurly_Client", "::", "POST", ",", "$", "this", "->", "uri", "(", ")", ".", "'/preview'", ")", ";", "}", "else", "{...
Preview the creation and check for errors. Note: once preview() has been called you will not be able to call create() or save() without reassiging all the attributes. @throws Recurly_Error
[ "Preview", "the", "creation", "and", "check", "for", "errors", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/subscription.php#L80-L86
train
recurly/recurly-client-php
lib/recurly/subscription.php
Recurly_Subscription.postpone
public function postpone($nextRenewalDate, $bulk = false) { $this->_save(Recurly_Client::PUT, $this->uri() . '/postpone?next_renewal_date=' . $nextRenewalDate . '&bulk=' . ((bool) $bulk)); }
php
public function postpone($nextRenewalDate, $bulk = false) { $this->_save(Recurly_Client::PUT, $this->uri() . '/postpone?next_renewal_date=' . $nextRenewalDate . '&bulk=' . ((bool) $bulk)); }
[ "public", "function", "postpone", "(", "$", "nextRenewalDate", ",", "$", "bulk", "=", "false", ")", "{", "$", "this", "->", "_save", "(", "Recurly_Client", "::", "PUT", ",", "$", "this", "->", "uri", "(", ")", ".", "'/postpone?next_renewal_date='", ".", ...
Postpone a subscription's renewal date. @param string $nextRenewalDate ISO8601 DateTime String, postpone the subscription to this date @param bool $bulk for making bulk updates, setting to true bypasses api check for accidental duplicate subscriptions. @throws Recurly_Error
[ "Postpone", "a", "subscription", "s", "renewal", "date", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/subscription.php#L173-L175
train
recurly/recurly-client-php
lib/recurly/subscription.php
Recurly_Subscription.updateNotes
public function updateNotes($notes) { $this->setValues($notes)->_save(Recurly_Client::PUT, $this->uri() . '/notes'); }
php
public function updateNotes($notes) { $this->setValues($notes)->_save(Recurly_Client::PUT, $this->uri() . '/notes'); }
[ "public", "function", "updateNotes", "(", "$", "notes", ")", "{", "$", "this", "->", "setValues", "(", "$", "notes", ")", "->", "_save", "(", "Recurly_Client", "::", "PUT", ",", "$", "this", "->", "uri", "(", ")", ".", "'/notes'", ")", ";", "}" ]
Updates the notes fields of the subscription without generating a SubscriptionChange. @param array $notes Array of notes, allowed keys: (customer_notes, terms_and_conditions, vat_reverse_charge_notes) @throws Recurly_Error
[ "Updates", "the", "notes", "fields", "of", "the", "subscription", "without", "generating", "a", "SubscriptionChange", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/subscription.php#L183-L185
train
recurly/recurly-client-php
lib/recurly/subscription.php
Recurly_Subscription.pause
public function pause($remaining_pause_cycles) { $doc = $this->createDocument(); $root = $doc->appendChild($doc->createElement($this->getNodeName())); $root->appendChild($doc->createElement('remaining_pause_cycles', $remaining_pause_cycles)); $this->_save(Recurly_Client::PUT, $this->uri() . '/pause', $this->renderXML($doc)); }
php
public function pause($remaining_pause_cycles) { $doc = $this->createDocument(); $root = $doc->appendChild($doc->createElement($this->getNodeName())); $root->appendChild($doc->createElement('remaining_pause_cycles', $remaining_pause_cycles)); $this->_save(Recurly_Client::PUT, $this->uri() . '/pause', $this->renderXML($doc)); }
[ "public", "function", "pause", "(", "$", "remaining_pause_cycles", ")", "{", "$", "doc", "=", "$", "this", "->", "createDocument", "(", ")", ";", "$", "root", "=", "$", "doc", "->", "appendChild", "(", "$", "doc", "->", "createElement", "(", "$", "this...
Pauses a subscription or cancels a scheduled pause. - For an active subscription without a pause scheduled already, this will schedule a pause period to begin at the next renewal date for the specified number of billing cycles (remaining_pause_cycles). - For an active subscription with a scheduled pause, this will update the remaining pause cycles with the new value sent. When zero (0) remaining_pause_cycles is sent for a subscription with a scheduled pause, the pause will be canceled. - For a paused subscription, the remaining_pause_cycles will adjust the length of the current pause period. Sending zero (0) in the remaining_pause_cycles field will cause the subscription to be resumed at the next renewal date. @param integer $remaining_pause_cycles The number of billing cycles that the subscription will be paused. @throws Recurly_Error
[ "Pauses", "a", "subscription", "or", "cancels", "a", "scheduled", "pause", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/subscription.php#L203-L208
train
recurly/recurly-client-php
lib/recurly/invoice.php
Recurly_Invoice.get
public static function get($invoiceNumber, $client = null) { return self::_get(Recurly_Invoice::uriForInvoice($invoiceNumber), $client); }
php
public static function get($invoiceNumber, $client = null) { return self::_get(Recurly_Invoice::uriForInvoice($invoiceNumber), $client); }
[ "public", "static", "function", "get", "(", "$", "invoiceNumber", ",", "$", "client", "=", "null", ")", "{", "return", "self", "::", "_get", "(", "Recurly_Invoice", "::", "uriForInvoice", "(", "$", "invoiceNumber", ")", ",", "$", "client", ")", ";", "}" ...
Lookup an invoice by its ID @param string Invoice number @param Recurly_Client $client Optional client for the request, useful for mocking the client @return object Recurly_Invoice @throws Recurly_Error
[ "Lookup", "an", "invoice", "by", "its", "ID" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/invoice.php#L55-L57
train
recurly/recurly-client-php
lib/recurly/invoice.php
Recurly_Invoice.getInvoicePdf
public static function getInvoicePdf($invoiceNumber, $locale = null, $client = null) { $uri = self::uriForInvoice($invoiceNumber); if (is_null($client)) $client = new Recurly_Client(); return $client->getPdf($uri, $locale); }
php
public static function getInvoicePdf($invoiceNumber, $locale = null, $client = null) { $uri = self::uriForInvoice($invoiceNumber); if (is_null($client)) $client = new Recurly_Client(); return $client->getPdf($uri, $locale); }
[ "public", "static", "function", "getInvoicePdf", "(", "$", "invoiceNumber", ",", "$", "locale", "=", "null", ",", "$", "client", "=", "null", ")", "{", "$", "uri", "=", "self", "::", "uriForInvoice", "(", "$", "invoiceNumber", ")", ";", "if", "(", "is_...
Retrieve the PDF version of an invoice @param $invoiceNumber @param string $locale @param Recurly_Client $client Optional client for the request, useful for mocking the client @return string A binary string of pdf data @throws Recurly_Error
[ "Retrieve", "the", "PDF", "version", "of", "an", "invoice" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/invoice.php#L80-L87
train
recurly/recurly-client-php
lib/recurly/invoice.php
Recurly_Invoice.invoicePendingCharges
public static function invoicePendingCharges($accountCode, $attributes = array(), $client = null) { $uri = Recurly_Client::PATH_ACCOUNTS . '/' . rawurlencode($accountCode) . Recurly_Client::PATH_INVOICES; $invoice = new self(); return Recurly_InvoiceCollection::_post($uri, $invoice->setValues($attributes)->xml(), $client); }
php
public static function invoicePendingCharges($accountCode, $attributes = array(), $client = null) { $uri = Recurly_Client::PATH_ACCOUNTS . '/' . rawurlencode($accountCode) . Recurly_Client::PATH_INVOICES; $invoice = new self(); return Recurly_InvoiceCollection::_post($uri, $invoice->setValues($attributes)->xml(), $client); }
[ "public", "static", "function", "invoicePendingCharges", "(", "$", "accountCode", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "client", "=", "null", ")", "{", "$", "uri", "=", "Recurly_Client", "::", "PATH_ACCOUNTS", ".", "'/'", ".", "rawurle...
Creates an invoice for an account using its pending charges @param string $accountCode Unique account code @param array $attributes additional invoice attributes (see writeableAttributes) @param Recurly_Client $client Optional client for the request, useful for mocking the client @return object Recurly_InvoiceCollection collection of invoices on success @throws Recurly_Error
[ "Creates", "an", "invoice", "for", "an", "account", "using", "its", "pending", "charges" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/invoice.php#L98-L102
train
recurly/recurly-client-php
lib/recurly/invoice.php
Recurly_Invoice.enterOfflinePayment
public function enterOfflinePayment($transaction) { $uri = $this->uri() . '/transactions'; return Recurly_Transaction::_post($uri, $transaction->xml(), $this->_client); }
php
public function enterOfflinePayment($transaction) { $uri = $this->uri() . '/transactions'; return Recurly_Transaction::_post($uri, $transaction->xml(), $this->_client); }
[ "public", "function", "enterOfflinePayment", "(", "$", "transaction", ")", "{", "$", "uri", "=", "$", "this", "->", "uri", "(", ")", ".", "'/transactions'", ";", "return", "Recurly_Transaction", "::", "_post", "(", "$", "uri", ",", "$", "transaction", "->"...
Enters an offline payment for an invoice @param $transaction Recurly_Transaction additional transaction attributes. The attributes available to set are (payment_method, collected_at, amount_in_cents, description) @return object Recurly_Transaction transaction on success @throws Recurly_Error
[ "Enters", "an", "offline", "payment", "for", "an", "invoice" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/invoice.php#L156-L159
train
recurly/recurly-client-php
lib/recurly/invoice.php
Recurly_Invoice.refundAmount
public function refundAmount($amount_in_cents, $refund_method = 'credit_first') { $doc = $this->createDocument(); $root = $doc->appendChild($doc->createElement($this->getNodeName())); $root->appendChild($doc->createElement('refund_method', $refund_method)); $root->appendChild($doc->createElement('amount_in_cents', $amount_in_cents)); return $this->createRefundInvoice($this->renderXML($doc)); }
php
public function refundAmount($amount_in_cents, $refund_method = 'credit_first') { $doc = $this->createDocument(); $root = $doc->appendChild($doc->createElement($this->getNodeName())); $root->appendChild($doc->createElement('refund_method', $refund_method)); $root->appendChild($doc->createElement('amount_in_cents', $amount_in_cents)); return $this->createRefundInvoice($this->renderXML($doc)); }
[ "public", "function", "refundAmount", "(", "$", "amount_in_cents", ",", "$", "refund_method", "=", "'credit_first'", ")", "{", "$", "doc", "=", "$", "this", "->", "createDocument", "(", ")", ";", "$", "root", "=", "$", "doc", "->", "appendChild", "(", "$...
Refunds an open amount from the invoice and returns a collection of refund invoices @param int $amount_in_cents amount in cents to refund from this invoice @param string $refund_method indicates the refund order to apply, valid options: {'credit_first','transaction_first'}, defaults to 'credit_first' @return object Recurly_Invoice a new refund invoice @throws Recurly_Error
[ "Refunds", "an", "open", "amount", "from", "the", "invoice", "and", "returns", "a", "collection", "of", "refund", "invoices" ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/invoice.php#L168-L176
train
recurly/recurly-client-php
lib/recurly/adjustment.php
Recurly_Adjustment.toRefundAttributes
public function toRefundAttributes($quantity = null, $prorate = false) { if (is_null($quantity)) $quantity = $this->quantity; return array('uuid' => $this->uuid, 'quantity' => $quantity, 'prorate' => $prorate); }
php
public function toRefundAttributes($quantity = null, $prorate = false) { if (is_null($quantity)) $quantity = $this->quantity; return array('uuid' => $this->uuid, 'quantity' => $quantity, 'prorate' => $prorate); }
[ "public", "function", "toRefundAttributes", "(", "$", "quantity", "=", "null", ",", "$", "prorate", "=", "false", ")", "{", "if", "(", "is_null", "(", "$", "quantity", ")", ")", "$", "quantity", "=", "$", "this", "->", "quantity", ";", "return", "array...
Converts this adjustment into the attributes needed for a refund. @param Integer the quantity you wish to refund, defaults to refunding the entire quantity @param Boolean indicates whether you want this adjustment refund prorated @return Array an array of refund attributes to be fed into invoice->refund()
[ "Converts", "this", "adjustment", "into", "the", "attributes", "needed", "for", "a", "refund", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/adjustment.php#L75-L79
train
recurly/recurly-client-php
lib/recurly/export_file.php
Recurly_ExportFile.get
public static function get($date, $name, $client = null) { return self::_get('/export_dates/' . rawurlencode($date) . '/export_files/' . rawurlencode($name), $client); }
php
public static function get($date, $name, $client = null) { return self::_get('/export_dates/' . rawurlencode($date) . '/export_files/' . rawurlencode($name), $client); }
[ "public", "static", "function", "get", "(", "$", "date", ",", "$", "name", ",", "$", "client", "=", "null", ")", "{", "return", "self", "::", "_get", "(", "'/export_dates/'", ".", "rawurlencode", "(", "$", "date", ")", ".", "'/export_files/'", ".", "ra...
Look up a file by date and name. @param string date @param string name @param Recurly_Client $client Optional client for the request, useful for mocking the client @return object Recurly_ExportFile @throws Recurly_Error
[ "Look", "up", "a", "file", "by", "date", "and", "name", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/export_file.php#L16-L18
train
recurly/recurly-client-php
lib/recurly/export_file_list.php
Recurly_ExportFileList.get
public static function get($date, $params = null, $client = null) { return new self(self::_uriWithParams('/export_dates/' . rawurlencode($date) . '/export_files', $params), $client); }
php
public static function get($date, $params = null, $client = null) { return new self(self::_uriWithParams('/export_dates/' . rawurlencode($date) . '/export_files', $params), $client); }
[ "public", "static", "function", "get", "(", "$", "date", ",", "$", "params", "=", "null", ",", "$", "client", "=", "null", ")", "{", "return", "new", "self", "(", "self", "::", "_uriWithParams", "(", "'/export_dates/'", ".", "rawurlencode", "(", "$", "...
Fetch a list of export files for a given date. @param string $date Date in YYYY-MM-DD format. @param array $params An array of parameters to include with the request @param Recurly_Client $client Optional client for the request, useful for mocking the client @return Recurly_ExportFileList
[ "Fetch", "a", "list", "of", "export", "files", "for", "a", "given", "date", "." ]
28465f3caf50ee5bd03919534144640d06aba340
https://github.com/recurly/recurly-client-php/blob/28465f3caf50ee5bd03919534144640d06aba340/lib/recurly/export_file_list.php#L13-L15
train