id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26,100 | balintsera/evista-perform | src/FormMarkupTranspiler.php | FormMarkupTranspiler.runIfNotCached | private function runIfNotCached($variableName, callable $function)
{
if (null === $this->{$variableName}) {
// Only assign that don't returns
if (null !== $result = $function()) {
$this->{$variableName} = $result;
}
}
} | php | private function runIfNotCached($variableName, callable $function)
{
if (null === $this->{$variableName}) {
// Only assign that don't returns
if (null !== $result = $function()) {
$this->{$variableName} = $result;
}
}
} | [
"private",
"function",
"runIfNotCached",
"(",
"$",
"variableName",
",",
"callable",
"$",
"function",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"{",
"$",
"variableName",
"}",
")",
"{",
"// Only assign that don't returns",
"if",
"(",
"null",
"!=="... | Check if a variable is empty and run function to
@param $variableName
@param callable $function | [
"Check",
"if",
"a",
"variable",
"is",
"empty",
"and",
"run",
"function",
"to"
] | 2b8723852ebe824ed721f30293e1e0d2c14f4b21 | https://github.com/balintsera/evista-perform/blob/2b8723852ebe824ed721f30293e1e0d2c14f4b21/src/FormMarkupTranspiler.php#L248-L256 |
26,101 | spiral/orm | source/Spiral/ORM/Entities/Relations/HasManyRelation.php | HasManyRelation.detach | public function detach(RecordInterface $record): RecordInterface
{
$this->loadData(true);
foreach ($this->instances as $index => $instance) {
if ($this->match($instance, $record)) {
//Remove from save
unset($this->instances[$index]);
retur... | php | public function detach(RecordInterface $record): RecordInterface
{
$this->loadData(true);
foreach ($this->instances as $index => $instance) {
if ($this->match($instance, $record)) {
//Remove from save
unset($this->instances[$index]);
retur... | [
"public",
"function",
"detach",
"(",
"RecordInterface",
"$",
"record",
")",
":",
"RecordInterface",
"{",
"$",
"this",
"->",
"loadData",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"instances",
"as",
"$",
"index",
"=>",
"$",
"instance",
")",... | Detach given object from set of instances but do not delete it in database, use it to
transfer object between sets.
@param \Spiral\ORM\RecordInterface $record
@return \Spiral\ORM\RecordInterface
@throws RelationException When object not presented in a set. | [
"Detach",
"given",
"object",
"from",
"set",
"of",
"instances",
"but",
"do",
"not",
"delete",
"it",
"in",
"database",
"use",
"it",
"to",
"transfer",
"object",
"between",
"sets",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/HasManyRelation.php#L143-L156 |
26,102 | spiral/orm | source/Spiral/ORM/Entities/Relations/HasManyRelation.php | HasManyRelation.loadRelated | protected function loadRelated(): array
{
$innerKey = $this->parent->getField($this->key(Record::INNER_KEY));
if (!empty($innerKey)) {
return $this->createSelector($innerKey)->fetchData();
}
return [];
} | php | protected function loadRelated(): array
{
$innerKey = $this->parent->getField($this->key(Record::INNER_KEY));
if (!empty($innerKey)) {
return $this->createSelector($innerKey)->fetchData();
}
return [];
} | [
"protected",
"function",
"loadRelated",
"(",
")",
":",
"array",
"{",
"$",
"innerKey",
"=",
"$",
"this",
"->",
"parent",
"->",
"getField",
"(",
"$",
"this",
"->",
"key",
"(",
"Record",
"::",
"INNER_KEY",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
... | Fetch data from database. Lazy load.
@return array | [
"Fetch",
"data",
"from",
"database",
".",
"Lazy",
"load",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/HasManyRelation.php#L227-L235 |
26,103 | spiral/orm | source/Spiral/ORM/Entities/Relations/HasManyRelation.php | HasManyRelation.createSelector | protected function createSelector($innerKey): RecordSelector
{
$selector = $this->orm->selector($this->class)->where(
$this->key(Record::OUTER_KEY),
$innerKey
);
$decorator = new AliasDecorator($selector, 'where', $selector->getAlias());
if (!empty($this->sch... | php | protected function createSelector($innerKey): RecordSelector
{
$selector = $this->orm->selector($this->class)->where(
$this->key(Record::OUTER_KEY),
$innerKey
);
$decorator = new AliasDecorator($selector, 'where', $selector->getAlias());
if (!empty($this->sch... | [
"protected",
"function",
"createSelector",
"(",
"$",
"innerKey",
")",
":",
"RecordSelector",
"{",
"$",
"selector",
"=",
"$",
"this",
"->",
"orm",
"->",
"selector",
"(",
"$",
"this",
"->",
"class",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"key",
"(",... | Create outer selector for a given inner key value.
@param mixed $innerKey
@return RecordSelector | [
"Create",
"outer",
"selector",
"for",
"a",
"given",
"inner",
"key",
"value",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/HasManyRelation.php#L244-L271 |
26,104 | rinvex/cortex-foundation | src/Relations/BelongsToMorph.php | BelongsToMorph.build | public static function build(Model $parent, $related, $name, $type = null, $id = null, $otherKey = null, $relation = null)
{
// If no relation name was given, we will use this debug backtrace to extract
// the calling method's name and use that as the relationship name as most
// of the time... | php | public static function build(Model $parent, $related, $name, $type = null, $id = null, $otherKey = null, $relation = null)
{
// If no relation name was given, we will use this debug backtrace to extract
// the calling method's name and use that as the relationship name as most
// of the time... | [
"public",
"static",
"function",
"build",
"(",
"Model",
"$",
"parent",
",",
"$",
"related",
",",
"$",
"name",
",",
"$",
"type",
"=",
"null",
",",
"$",
"id",
"=",
"null",
",",
"$",
"otherKey",
"=",
"null",
",",
"$",
"relation",
"=",
"null",
")",
"{... | Define an inverse morph relationship.
@param Model $parent
@param string $related
@param string $name
@param string $type
@param string $id
@param string $otherKey
@param string $relation
@return \Illuminate\Database\Eloquent\Relations\BelongsTo | [
"Define",
"an",
"inverse",
"morph",
"relationship",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Relations/BelongsToMorph.php#L109-L134 |
26,105 | spiral/orm | source/Spiral/ORM/Entities/Relations/Traits/SyncedTrait.php | SyncedTrait.isSynced | protected function isSynced(RecordInterface $inner, RecordInterface $outer): bool
{
if (empty($inner->primaryKey()) || empty($outer->primaryKey())) {
//Parent not saved
return false;
}
//Comparing FK values
return $outer->getField(
$this->key(... | php | protected function isSynced(RecordInterface $inner, RecordInterface $outer): bool
{
if (empty($inner->primaryKey()) || empty($outer->primaryKey())) {
//Parent not saved
return false;
}
//Comparing FK values
return $outer->getField(
$this->key(... | [
"protected",
"function",
"isSynced",
"(",
"RecordInterface",
"$",
"inner",
",",
"RecordInterface",
"$",
"outer",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"inner",
"->",
"primaryKey",
"(",
")",
")",
"||",
"empty",
"(",
"$",
"outer",
"->",
"p... | If record not synced or can't be synced. Only work for PK based relations.
@param RecordInterface $inner
@param RecordInterface $outer
@return bool | [
"If",
"record",
"not",
"synced",
"or",
"can",
"t",
"be",
"synced",
".",
"Only",
"work",
"for",
"PK",
"based",
"relations",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/Traits/SyncedTrait.php#L26-L39 |
26,106 | spiral/orm | source/Spiral/ORM/Entities/Loaders/ManyToManyLoader.php | ManyToManyLoader.pivotKey | protected function pivotKey(string $key)
{
if (!isset($this->schema[$key])) {
return null;
}
return $this->pivotAlias() . '.' . $this->schema[$key];
} | php | protected function pivotKey(string $key)
{
if (!isset($this->schema[$key])) {
return null;
}
return $this->pivotAlias() . '.' . $this->schema[$key];
} | [
"protected",
"function",
"pivotKey",
"(",
"string",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"schema",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"pivotAlias",
"(",
... | Key related to pivot table. Must include pivot table alias.
@see pivotKey()
@param string $key
@return null|string | [
"Key",
"related",
"to",
"pivot",
"table",
".",
"Must",
"include",
"pivot",
"table",
"alias",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Loaders/ManyToManyLoader.php#L251-L258 |
26,107 | spiral/orm | source/Spiral/ORM/RecordEntity.php | RecordEntity.handleInsert | private function handleInsert(InsertCommand $command)
{
//Mounting PK
$this->setField($this->primaryColumn(), $command->getInsertID(), true, false);
//Once command executed we will know some information about it's context
//(for exampled added FKs), this information must already be ... | php | private function handleInsert(InsertCommand $command)
{
//Mounting PK
$this->setField($this->primaryColumn(), $command->getInsertID(), true, false);
//Once command executed we will know some information about it's context
//(for exampled added FKs), this information must already be ... | [
"private",
"function",
"handleInsert",
"(",
"InsertCommand",
"$",
"command",
")",
"{",
"//Mounting PK",
"$",
"this",
"->",
"setField",
"(",
"$",
"this",
"->",
"primaryColumn",
"(",
")",
",",
"$",
"command",
"->",
"getInsertID",
"(",
")",
",",
"true",
",",
... | Handle result of insert command.
@param InsertCommand $command | [
"Handle",
"result",
"of",
"insert",
"command",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/RecordEntity.php#L445-L459 |
26,108 | spiral/orm | source/Spiral/ORM/RecordEntity.php | RecordEntity.handleUpdate | private function handleUpdate(UpdateCommand $command)
{
//Once command executed we will know some information about it's context (for exampled added FKs)
foreach ($command->getContext() as $name => $value) {
$this->setField($name, $value, true, false);
}
$this->state = O... | php | private function handleUpdate(UpdateCommand $command)
{
//Once command executed we will know some information about it's context (for exampled added FKs)
foreach ($command->getContext() as $name => $value) {
$this->setField($name, $value, true, false);
}
$this->state = O... | [
"private",
"function",
"handleUpdate",
"(",
"UpdateCommand",
"$",
"command",
")",
"{",
"//Once command executed we will know some information about it's context (for exampled added FKs)",
"foreach",
"(",
"$",
"command",
"->",
"getContext",
"(",
")",
"as",
"$",
"name",
"=>",... | Handle result of update command.
@param UpdateCommand $command | [
"Handle",
"result",
"of",
"update",
"command",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/RecordEntity.php#L466-L475 |
26,109 | spiral/orm | source/Spiral/ORM/RecordEntity.php | RecordEntity.handleDelete | private function handleDelete(DeleteCommand $command)
{
$this->state = ORMInterface::STATE_DELETED;
$this->dispatch('deleted', new RecordEvent($this, $command));
} | php | private function handleDelete(DeleteCommand $command)
{
$this->state = ORMInterface::STATE_DELETED;
$this->dispatch('deleted', new RecordEvent($this, $command));
} | [
"private",
"function",
"handleDelete",
"(",
"DeleteCommand",
"$",
"command",
")",
"{",
"$",
"this",
"->",
"state",
"=",
"ORMInterface",
"::",
"STATE_DELETED",
";",
"$",
"this",
"->",
"dispatch",
"(",
"'deleted'",
",",
"new",
"RecordEvent",
"(",
"$",
"this",
... | Handle result of delete command.
@param DeleteCommand $command | [
"Handle",
"result",
"of",
"delete",
"command",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/RecordEntity.php#L482-L486 |
26,110 | spiral/orm | source/Spiral/ORM/EntityMap.php | EntityMap.remember | public function remember(RecordInterface $entity, bool $ignoreLimit = false): RecordInterface
{
if (!$ignoreLimit && !is_null($this->maxSize) && count($this->entities) > $this->maxSize - 1) {
throw new MapException('Entity cache size exceeded');
}
if (empty($entity->primaryKey()... | php | public function remember(RecordInterface $entity, bool $ignoreLimit = false): RecordInterface
{
if (!$ignoreLimit && !is_null($this->maxSize) && count($this->entities) > $this->maxSize - 1) {
throw new MapException('Entity cache size exceeded');
}
if (empty($entity->primaryKey()... | [
"public",
"function",
"remember",
"(",
"RecordInterface",
"$",
"entity",
",",
"bool",
"$",
"ignoreLimit",
"=",
"false",
")",
":",
"RecordInterface",
"{",
"if",
"(",
"!",
"$",
"ignoreLimit",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"maxSize",
")",
"&... | Add Record to entity cache. Primary key value will be used as
identifier.
Attention, existed entity will be replaced!
@param RecordInterface $entity
@param bool $ignoreLimit Cache overflow will be ignored.
@return RecordInterface Returns given entity.
@throws MapException When cache size exceeded. | [
"Add",
"Record",
"to",
"entity",
"cache",
".",
"Primary",
"key",
"value",
"will",
"be",
"used",
"as",
"identifier",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/EntityMap.php#L59-L72 |
26,111 | spiral/orm | source/Spiral/ORM/EntityMap.php | EntityMap.forget | public function forget(RecordInterface $entity)
{
$cacheID = get_class($entity) . ':' . $entity->primaryKey();
unset($this->entities[$cacheID]);
} | php | public function forget(RecordInterface $entity)
{
$cacheID = get_class($entity) . ':' . $entity->primaryKey();
unset($this->entities[$cacheID]);
} | [
"public",
"function",
"forget",
"(",
"RecordInterface",
"$",
"entity",
")",
"{",
"$",
"cacheID",
"=",
"get_class",
"(",
"$",
"entity",
")",
".",
"':'",
".",
"$",
"entity",
"->",
"primaryKey",
"(",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"entities",
... | Remove entity record from entity cache. Primary key value will be used as identifier.
@param RecordInterface $entity | [
"Remove",
"entity",
"record",
"from",
"entity",
"cache",
".",
"Primary",
"key",
"value",
"will",
"be",
"used",
"as",
"identifier",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/EntityMap.php#L79-L83 |
26,112 | spiral/orm | source/Spiral/ORM/EntityMap.php | EntityMap.get | public function get(string $class, string $identity)
{
if (!$this->has($class, $identity)) {
return null;
}
return $this->entities["{$class}:{$identity}"];
} | php | public function get(string $class, string $identity)
{
if (!$this->has($class, $identity)) {
return null;
}
return $this->entities["{$class}:{$identity}"];
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"class",
",",
"string",
"$",
"identity",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"class",
",",
"$",
"identity",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this... | Fetch entity from cache.
@param string $class
@param string $identity
@return null|mixed | [
"Fetch",
"entity",
"from",
"cache",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/EntityMap.php#L106-L113 |
26,113 | spiral/orm | source/Spiral/ORM/Entities/Nodes/PivotedRootNode.php | PivotedRootNode.duplicateCriteria | protected function duplicateCriteria(array &$data)
{
$pivotData = $data[ORMInterface::PIVOT_DATA];
//Unique row criteria
return $pivotData[$this->innerPivotKey] . '.' . $pivotData[$this->outerPivotKey];
} | php | protected function duplicateCriteria(array &$data)
{
$pivotData = $data[ORMInterface::PIVOT_DATA];
//Unique row criteria
return $pivotData[$this->innerPivotKey] . '.' . $pivotData[$this->outerPivotKey];
} | [
"protected",
"function",
"duplicateCriteria",
"(",
"array",
"&",
"$",
"data",
")",
"{",
"$",
"pivotData",
"=",
"$",
"data",
"[",
"ORMInterface",
"::",
"PIVOT_DATA",
"]",
";",
"//Unique row criteria",
"return",
"$",
"pivotData",
"[",
"$",
"this",
"->",
"inner... | De-duplication in pivot tables based on values in pivot table.
@param array $data
@return string | [
"De",
"-",
"duplication",
"in",
"pivot",
"tables",
"based",
"on",
"values",
"in",
"pivot",
"table",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/PivotedRootNode.php#L94-L100 |
26,114 | rinvex/cortex-foundation | src/Traits/Auditable.php | Auditable.bootAuditable | public static function bootAuditable()
{
static::creating(function (Model $model) {
$model->created_by_id || $model->created_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey();
$model->created_by_type || $model->created_by_type = optional(auth()->guard(reque... | php | public static function bootAuditable()
{
static::creating(function (Model $model) {
$model->created_by_id || $model->created_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey();
$model->created_by_type || $model->created_by_type = optional(auth()->guard(reque... | [
"public",
"static",
"function",
"bootAuditable",
"(",
")",
"{",
"static",
"::",
"creating",
"(",
"function",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"model",
"->",
"created_by_id",
"||",
"$",
"model",
"->",
"created_by_id",
"=",
"optional",
"(",
"auth",... | Boot the Auditable trait for the model.
@return void | [
"Boot",
"the",
"Auditable",
"trait",
"for",
"the",
"model",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Traits/Auditable.php#L48-L62 |
26,115 | rinvex/cortex-foundation | src/Traits/Auditable.php | Auditable.scopeOfCreator | public function scopeOfCreator(Builder $builder, Model $user): Builder
{
return $builder->where('created_by_type', $user->getMorphClass())->where('created_by_id', $user->getKey());
} | php | public function scopeOfCreator(Builder $builder, Model $user): Builder
{
return $builder->where('created_by_type', $user->getMorphClass())->where('created_by_id', $user->getKey());
} | [
"public",
"function",
"scopeOfCreator",
"(",
"Builder",
"$",
"builder",
",",
"Model",
"$",
"user",
")",
":",
"Builder",
"{",
"return",
"$",
"builder",
"->",
"where",
"(",
"'created_by_type'",
",",
"$",
"user",
"->",
"getMorphClass",
"(",
")",
")",
"->",
... | Get audits of the given creator.
@param \Illuminate\Database\Eloquent\Builder $builder
@param \Illuminate\Database\Eloquent\Model $user
@return \Illuminate\Database\Eloquent\Builder | [
"Get",
"audits",
"of",
"the",
"given",
"creator",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Traits/Auditable.php#L92-L95 |
26,116 | rinvex/cortex-foundation | src/Traits/Auditable.php | Auditable.scopeOfUpdater | public function scopeOfUpdater(Builder $builder, Model $user): Builder
{
return $builder->where('updated_by_type', $user->getMorphClass())->where('updated_by_id', $user->getKey());
} | php | public function scopeOfUpdater(Builder $builder, Model $user): Builder
{
return $builder->where('updated_by_type', $user->getMorphClass())->where('updated_by_id', $user->getKey());
} | [
"public",
"function",
"scopeOfUpdater",
"(",
"Builder",
"$",
"builder",
",",
"Model",
"$",
"user",
")",
":",
"Builder",
"{",
"return",
"$",
"builder",
"->",
"where",
"(",
"'updated_by_type'",
",",
"$",
"user",
"->",
"getMorphClass",
"(",
")",
")",
"->",
... | Get audits of the given updater.
@param \Illuminate\Database\Eloquent\Builder $builder
@param \Illuminate\Database\Eloquent\Model $user
@return \Illuminate\Database\Eloquent\Builder | [
"Get",
"audits",
"of",
"the",
"given",
"updater",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Traits/Auditable.php#L105-L108 |
26,117 | spiral/orm | source/Spiral/ORM/Entities/RecordIterator.php | RecordIterator.getIterator | public function getIterator(): \Generator
{
foreach ($this->data as $index => $data) {
if (isset($data[ORMInterface::PIVOT_DATA])) {
/*
* When pivot data is provided we are able to use it as array key.
*/
$index = $data[ORMInterfa... | php | public function getIterator(): \Generator
{
foreach ($this->data as $index => $data) {
if (isset($data[ORMInterface::PIVOT_DATA])) {
/*
* When pivot data is provided we are able to use it as array key.
*/
$index = $data[ORMInterfa... | [
"public",
"function",
"getIterator",
"(",
")",
":",
"\\",
"Generator",
"{",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"index",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"ORMInterface",
"::",
"PIVOT_DATA",
"]"... | Generate over data.
Method will use pibot
@return \Generator | [
"Generate",
"over",
"data",
".",
"Method",
"will",
"use",
"pibot"
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/RecordIterator.php#L57-L75 |
26,118 | spiral/orm | source/Spiral/ORM/Entities/Relations/HasOneRelation.php | HasOneRelation.queueRelated | private function queueRelated(ContextualCommandInterface $parentCommand): CommandInterface
{
if (empty($this->instance)) {
return new NullCommand();
}
//Related entity store command
$innerCommand = $this->instance->queueStore(true);
//Inversed version of Belongs... | php | private function queueRelated(ContextualCommandInterface $parentCommand): CommandInterface
{
if (empty($this->instance)) {
return new NullCommand();
}
//Related entity store command
$innerCommand = $this->instance->queueStore(true);
//Inversed version of Belongs... | [
"private",
"function",
"queueRelated",
"(",
"ContextualCommandInterface",
"$",
"parentCommand",
")",
":",
"CommandInterface",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"instance",
")",
")",
"{",
"return",
"new",
"NullCommand",
"(",
")",
";",
"}",
"//R... | Store related instance.
@param ContextualCommandInterface $parentCommand
@return CommandInterface | [
"Store",
"related",
"instance",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/HasOneRelation.php#L83-L112 |
26,119 | robertlemke/RobertLemke.Plugin.Blog | Classes/Service/NotificationService.php | NotificationService.sendNewCommentNotification | public function sendNewCommentNotification(NodeInterface $commentNode, NodeInterface $postNode)
{
if ($this->settings['notifications']['to']['email'] === '') {
return;
}
if (!class_exists('Neos\SwiftMailer\Message')) {
$this->systemLogger->log('The package "Neos.Swif... | php | public function sendNewCommentNotification(NodeInterface $commentNode, NodeInterface $postNode)
{
if ($this->settings['notifications']['to']['email'] === '') {
return;
}
if (!class_exists('Neos\SwiftMailer\Message')) {
$this->systemLogger->log('The package "Neos.Swif... | [
"public",
"function",
"sendNewCommentNotification",
"(",
"NodeInterface",
"$",
"commentNode",
",",
"NodeInterface",
"$",
"postNode",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"settings",
"[",
"'notifications'",
"]",
"[",
"'to'",
"]",
"[",
"'email'",
"]",
"===",
... | Send a new notification that a comment has been created
@param NodeInterface $commentNode The comment node
@param NodeInterface $postNode The post node
@return void | [
"Send",
"a",
"new",
"notification",
"that",
"a",
"comment",
"has",
"been",
"created"
] | 7780d7e37022056ebe31088c7917ecaad8881dde | https://github.com/robertlemke/RobertLemke.Plugin.Blog/blob/7780d7e37022056ebe31088c7917ecaad8881dde/Classes/Service/NotificationService.php#L53-L77 |
26,120 | flownative/flow-google-cloudstorage | Classes/StorageFactory.php | StorageFactory.create | public function create($credentialsProfileName = 'default')
{
if (!isset($this->credentialProfiles[$credentialsProfileName])) {
throw new Exception(sprintf('The specified Google Cloud Storage credentials profile "%s" does not exist, please check your settings.', $credentialsProfileName), 1446553... | php | public function create($credentialsProfileName = 'default')
{
if (!isset($this->credentialProfiles[$credentialsProfileName])) {
throw new Exception(sprintf('The specified Google Cloud Storage credentials profile "%s" does not exist, please check your settings.', $credentialsProfileName), 1446553... | [
"public",
"function",
"create",
"(",
"$",
"credentialsProfileName",
"=",
"'default'",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"credentialProfiles",
"[",
"$",
"credentialsProfileName",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
... | Creates a new Storage instance and authenticates against the Google API
@param string $credentialsProfileName
@return \Google\Cloud\Storage\StorageClient
@throws Exception | [
"Creates",
"a",
"new",
"Storage",
"instance",
"and",
"authenticates",
"against",
"the",
"Google",
"API"
] | 78c76b2a0eb10fa514bbae71f93f351ee58dacd3 | https://github.com/flownative/flow-google-cloudstorage/blob/78c76b2a0eb10fa514bbae71f93f351ee58dacd3/Classes/StorageFactory.php#L43-L69 |
26,121 | spiral/orm | source/Spiral/ORM/Schemas/Relations/ManyToManySchema.php | ManyToManySchema.pivotTable | protected function pivotTable(): string
{
if (!empty($this->option(Record::PIVOT_TABLE))) {
return $this->option(Record::PIVOT_TABLE);
}
$source = $this->definition->sourceContext();
$target = $this->definition->targetContext();
//Generating pivot table name
... | php | protected function pivotTable(): string
{
if (!empty($this->option(Record::PIVOT_TABLE))) {
return $this->option(Record::PIVOT_TABLE);
}
$source = $this->definition->sourceContext();
$target = $this->definition->targetContext();
//Generating pivot table name
... | [
"protected",
"function",
"pivotTable",
"(",
")",
":",
"string",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"option",
"(",
"Record",
"::",
"PIVOT_TABLE",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"option",
"(",
"Record",
"::",
"PIVOT... | Generate name of pivot table or fetch if from schema.
@return string | [
"Generate",
"name",
"of",
"pivot",
"table",
"or",
"fetch",
"if",
"from",
"schema",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/ManyToManySchema.php#L301-L315 |
26,122 | robertlemke/RobertLemke.Plugin.Blog | Classes/Eel/FilterByReferenceOperation.php | FilterByReferenceOperation.evaluate | public function evaluate(FlowQuery $flowQuery, array $arguments) {
if (empty($arguments[0])) {
throw new FlowQueryException('filterByReference() needs reference property name by which nodes should be filtered', 1545778273);
}
if (empty($arguments[1])) {
throw new FlowQuer... | php | public function evaluate(FlowQuery $flowQuery, array $arguments) {
if (empty($arguments[0])) {
throw new FlowQueryException('filterByReference() needs reference property name by which nodes should be filtered', 1545778273);
}
if (empty($arguments[1])) {
throw new FlowQuer... | [
"public",
"function",
"evaluate",
"(",
"FlowQuery",
"$",
"flowQuery",
",",
"array",
"$",
"arguments",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"arguments",
"[",
"0",
"]",
")",
")",
"{",
"throw",
"new",
"FlowQueryException",
"(",
"'filterByReference() needs re... | First argument is property to filter by, must be of reference of references type.
Second is object to filter by, must be Node.
@param FlowQuery $flowQuery
@param array $arguments The arguments for this operation.
@return void
@throws FlowQueryException
@throws \Neos\ContentRepository\Exception\NodeException | [
"First",
"argument",
"is",
"property",
"to",
"filter",
"by",
"must",
"be",
"of",
"reference",
"of",
"references",
"type",
".",
"Second",
"is",
"object",
"to",
"filter",
"by",
"must",
"be",
"Node",
"."
] | 7780d7e37022056ebe31088c7917ecaad8881dde | https://github.com/robertlemke/RobertLemke.Plugin.Blog/blob/7780d7e37022056ebe31088c7917ecaad8881dde/Classes/Eel/FilterByReferenceOperation.php#L47-L68 |
26,123 | spiral/orm | source/Spiral/ORM/Entities/Relations/ManyToMorphedRelation.php | ManyToMorphedRelation.getVariation | public function getVariation(string $variation): ManyToManyRelation
{
if (isset($this->nested[$variation])) {
return $this->nested[$variation];
}
if (!isset($this->schema[Record::MORPHED_ALIASES][$variation])) {
throw new RelationException("Undefined morphed variatio... | php | public function getVariation(string $variation): ManyToManyRelation
{
if (isset($this->nested[$variation])) {
return $this->nested[$variation];
}
if (!isset($this->schema[Record::MORPHED_ALIASES][$variation])) {
throw new RelationException("Undefined morphed variatio... | [
"public",
"function",
"getVariation",
"(",
"string",
"$",
"variation",
")",
":",
"ManyToManyRelation",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"nested",
"[",
"$",
"variation",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"nested",
"[",
"$"... | Get nested relation for a given variation.
@param string $variation
@return ManyToManyRelation
@throws RelationException | [
"Get",
"nested",
"relation",
"for",
"a",
"given",
"variation",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToMorphedRelation.php#L101-L121 |
26,124 | spiral/orm | source/Spiral/ORM/Entities/Relations/ManyToMorphedRelation.php | ManyToMorphedRelation.makeSchema | protected function makeSchema(string $class): array
{
//Using as basement
$schema = $this->schema;
unset($schema[Record::MORPHED_ALIASES]);
//We do not have this information in morphed relation but it's required for ManyToMany
$schema[Record::WHERE] = [];
//This mus... | php | protected function makeSchema(string $class): array
{
//Using as basement
$schema = $this->schema;
unset($schema[Record::MORPHED_ALIASES]);
//We do not have this information in morphed relation but it's required for ManyToMany
$schema[Record::WHERE] = [];
//This mus... | [
"protected",
"function",
"makeSchema",
"(",
"string",
"$",
"class",
")",
":",
"array",
"{",
"//Using as basement",
"$",
"schema",
"=",
"$",
"this",
"->",
"schema",
";",
"unset",
"(",
"$",
"schema",
"[",
"Record",
"::",
"MORPHED_ALIASES",
"]",
")",
";",
"... | Create relation schema for nested relation.
@param string $class
@return array | [
"Create",
"relation",
"schema",
"for",
"nested",
"relation",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToMorphedRelation.php#L182-L196 |
26,125 | spiral/orm | source/Spiral/ORM/AbstractRecord.php | AbstractRecord.packChanges | protected function packChanges(bool $skipPrimary = false): array
{
if (!$this->hasChanges() && !$this->isSolid()) {
return [];
}
if ($this->isSolid()) {
//Solid record always updated as one big solid
$updates = $this->packValue();
} else {
... | php | protected function packChanges(bool $skipPrimary = false): array
{
if (!$this->hasChanges() && !$this->isSolid()) {
return [];
}
if ($this->isSolid()) {
//Solid record always updated as one big solid
$updates = $this->packValue();
} else {
... | [
"protected",
"function",
"packChanges",
"(",
"bool",
"$",
"skipPrimary",
"=",
"false",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasChanges",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"isSolid",
"(",
")",
")",
"{",
"return",
"[",
"]... | Create set of fields to be sent to UPDATE statement.
@param bool $skipPrimary Skip primary key
@return array | [
"Create",
"set",
"of",
"fields",
"to",
"be",
"sent",
"to",
"UPDATE",
"statement",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/AbstractRecord.php#L297-L332 |
26,126 | rinvex/cortex-foundation | src/Http/Controllers/AbstractController.php | AbstractController.guessGuard | protected function guessGuard(): string
{
$accessarea = str_before(Route::currentRouteName(), '.');
$guard = str_plural(mb_strstr($accessarea, 'area', true));
return config('auth.guards.'.$guard) ? $guard : config('auth.defaults.guard');
} | php | protected function guessGuard(): string
{
$accessarea = str_before(Route::currentRouteName(), '.');
$guard = str_plural(mb_strstr($accessarea, 'area', true));
return config('auth.guards.'.$guard) ? $guard : config('auth.defaults.guard');
} | [
"protected",
"function",
"guessGuard",
"(",
")",
":",
"string",
"{",
"$",
"accessarea",
"=",
"str_before",
"(",
"Route",
"::",
"currentRouteName",
"(",
")",
",",
"'.'",
")",
";",
"$",
"guard",
"=",
"str_plural",
"(",
"mb_strstr",
"(",
"$",
"accessarea",
... | Guess guard from accessarea.
@return string | [
"Guess",
"guard",
"from",
"accessarea",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Http/Controllers/AbstractController.php#L73-L79 |
26,127 | rinvex/cortex-foundation | src/Http/Controllers/AbstractController.php | AbstractController.guessPasswordResetBroker | protected function guessPasswordResetBroker(): string
{
$accessarea = str_before(Route::currentRouteName(), '.');
$passwordResetBroker = str_plural(mb_strstr($accessarea, 'area', true));
return config('auth.passwords.'.$passwordResetBroker) ? $passwordResetBroker : config('auth.defaults.pas... | php | protected function guessPasswordResetBroker(): string
{
$accessarea = str_before(Route::currentRouteName(), '.');
$passwordResetBroker = str_plural(mb_strstr($accessarea, 'area', true));
return config('auth.passwords.'.$passwordResetBroker) ? $passwordResetBroker : config('auth.defaults.pas... | [
"protected",
"function",
"guessPasswordResetBroker",
"(",
")",
":",
"string",
"{",
"$",
"accessarea",
"=",
"str_before",
"(",
"Route",
"::",
"currentRouteName",
"(",
")",
",",
"'.'",
")",
";",
"$",
"passwordResetBroker",
"=",
"str_plural",
"(",
"mb_strstr",
"(... | Guess password reset broker from accessarea.
@return string | [
"Guess",
"password",
"reset",
"broker",
"from",
"accessarea",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Http/Controllers/AbstractController.php#L114-L120 |
26,128 | rinvex/cortex-foundation | src/Http/Controllers/AbstractController.php | AbstractController.guessEmailVerificationBroker | protected function guessEmailVerificationBroker(): string
{
$accessarea = str_before(Route::currentRouteName(), '.');
$emailVerificationBroker = str_plural(mb_strstr($accessarea, 'area', true));
return config('auth.passwords.'.$emailVerificationBroker) ? $emailVerificationBroker : config('a... | php | protected function guessEmailVerificationBroker(): string
{
$accessarea = str_before(Route::currentRouteName(), '.');
$emailVerificationBroker = str_plural(mb_strstr($accessarea, 'area', true));
return config('auth.passwords.'.$emailVerificationBroker) ? $emailVerificationBroker : config('a... | [
"protected",
"function",
"guessEmailVerificationBroker",
"(",
")",
":",
"string",
"{",
"$",
"accessarea",
"=",
"str_before",
"(",
"Route",
"::",
"currentRouteName",
"(",
")",
",",
"'.'",
")",
";",
"$",
"emailVerificationBroker",
"=",
"str_plural",
"(",
"mb_strst... | Guess email verification broker from accessarea.
@return string | [
"Guess",
"email",
"verification",
"broker",
"from",
"accessarea",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Http/Controllers/AbstractController.php#L137-L143 |
26,129 | spiral/orm | source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php | MorphedTrait.findOuter | protected function findOuter(SchemaBuilder $builder)
{
foreach ($this->findTargets($builder) as $schema) {
$outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase());
$outerKey = $this->option(Record::OUTER_KEY);
if ($outerKey == ORMInterface::R_PR... | php | protected function findOuter(SchemaBuilder $builder)
{
foreach ($this->findTargets($builder) as $schema) {
$outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase());
$outerKey = $this->option(Record::OUTER_KEY);
if ($outerKey == ORMInterface::R_PR... | [
"protected",
"function",
"findOuter",
"(",
"SchemaBuilder",
"$",
"builder",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"findTargets",
"(",
"$",
"builder",
")",
"as",
"$",
"schema",
")",
"{",
"$",
"outerTable",
"=",
"$",
"builder",
"->",
"requestTable",
... | Resolving outer key.
@param \Spiral\ORM\Schemas\SchemaBuilder $builder
@return \Spiral\Database\Schemas\Prototypes\AbstractColumn|null When no outer records found
NULL will be returned. | [
"Resolving",
"outer",
"key",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php#L30-L52 |
26,130 | spiral/orm | source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php | MorphedTrait.verifyOuter | protected function verifyOuter(SchemaBuilder $builder, AbstractColumn $column)
{
foreach ($this->findTargets($builder) as $schema) {
$outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase());
if (!$outerTable->hasColumn($column->getName())) {
... | php | protected function verifyOuter(SchemaBuilder $builder, AbstractColumn $column)
{
foreach ($this->findTargets($builder) as $schema) {
$outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase());
if (!$outerTable->hasColumn($column->getName())) {
... | [
"protected",
"function",
"verifyOuter",
"(",
"SchemaBuilder",
"$",
"builder",
",",
"AbstractColumn",
"$",
"column",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"findTargets",
"(",
"$",
"builder",
")",
"as",
"$",
"schema",
")",
"{",
"$",
"outerTable",
"=",... | Make sure all tables have same outer key.
@param \Spiral\ORM\Schemas\SchemaBuilder $builder
@param \Spiral\Database\Schemas\Prototypes\AbstractColumn $column
@throws RelationSchemaException | [
"Make",
"sure",
"all",
"tables",
"have",
"same",
"outer",
"key",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php#L62-L83 |
26,131 | spiral/orm | source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php | MorphedTrait.findTargets | protected function findTargets(SchemaBuilder $builder): \Generator
{
foreach ($builder->getSchemas() as $schema) {
if (!is_a($schema->getClass(), $this->getDefinition()->getTarget(), true)) {
//Not our targets
continue;
}
yield $schema;
... | php | protected function findTargets(SchemaBuilder $builder): \Generator
{
foreach ($builder->getSchemas() as $schema) {
if (!is_a($schema->getClass(), $this->getDefinition()->getTarget(), true)) {
//Not our targets
continue;
}
yield $schema;
... | [
"protected",
"function",
"findTargets",
"(",
"SchemaBuilder",
"$",
"builder",
")",
":",
"\\",
"Generator",
"{",
"foreach",
"(",
"$",
"builder",
"->",
"getSchemas",
"(",
")",
"as",
"$",
"schema",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"schema",
"->... | Find all matched schemas.
@param \Spiral\ORM\Schemas\SchemaBuilder $builder
@return \Generator|\Spiral\ORM\Schemas\SchemaInterface[] | [
"Find",
"all",
"matched",
"schemas",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php#L92-L101 |
26,132 | swoft-cloud/swoft-rpc-server | src/Router/HandlerMapping.php | HandlerMapping.getHandler | public function getHandler(...$params): array
{
list($interfaceClass, $version, $method) = $params;
return $this->match($interfaceClass, $version, $method);
} | php | public function getHandler(...$params): array
{
list($interfaceClass, $version, $method) = $params;
return $this->match($interfaceClass, $version, $method);
} | [
"public",
"function",
"getHandler",
"(",
"...",
"$",
"params",
")",
":",
"array",
"{",
"list",
"(",
"$",
"interfaceClass",
",",
"$",
"version",
",",
"$",
"method",
")",
"=",
"$",
"params",
";",
"return",
"$",
"this",
"->",
"match",
"(",
"$",
"interfa... | Get handler from router
@param array ...$params
@return array
@throws \InvalidArgumentException | [
"Get",
"handler",
"from",
"router"
] | 527ce20421ad46919b16ebdcc12658f0e3807a07 | https://github.com/swoft-cloud/swoft-rpc-server/blob/527ce20421ad46919b16ebdcc12658f0e3807a07/src/Router/HandlerMapping.php#L28-L32 |
26,133 | swoft-cloud/swoft-rpc-server | src/Router/HandlerMapping.php | HandlerMapping.getServiceKey | private function getServiceKey(string $interfaceClass, string $version, string $method): string
{
return \sprintf('%s_%s_%s', $interfaceClass, $version, $method);
} | php | private function getServiceKey(string $interfaceClass, string $version, string $method): string
{
return \sprintf('%s_%s_%s', $interfaceClass, $version, $method);
} | [
"private",
"function",
"getServiceKey",
"(",
"string",
"$",
"interfaceClass",
",",
"string",
"$",
"version",
",",
"string",
"$",
"method",
")",
":",
"string",
"{",
"return",
"\\",
"sprintf",
"(",
"'%s_%s_%s'",
",",
"$",
"interfaceClass",
",",
"$",
"version",... | Get service key
@param string $interfaceClass
@param string $version
@param string $method
@return string | [
"Get",
"service",
"key"
] | 527ce20421ad46919b16ebdcc12658f0e3807a07 | https://github.com/swoft-cloud/swoft-rpc-server/blob/527ce20421ad46919b16ebdcc12658f0e3807a07/src/Router/HandlerMapping.php#L101-L104 |
26,134 | spiral/orm | source/Spiral/ORM/Schemas/Relations/AbstractSchema.php | AbstractSchema.isConstrained | public function isConstrained()
{
$source = $this->definition->sourceContext();
$target = $this->definition->targetContext();
if (empty($target)) {
return false;
}
if ($source->getDatabase() != $target->getDatabase()) {
//Unable to create constrains f... | php | public function isConstrained()
{
$source = $this->definition->sourceContext();
$target = $this->definition->targetContext();
if (empty($target)) {
return false;
}
if ($source->getDatabase() != $target->getDatabase()) {
//Unable to create constrains f... | [
"public",
"function",
"isConstrained",
"(",
")",
"{",
"$",
"source",
"=",
"$",
"this",
"->",
"definition",
"->",
"sourceContext",
"(",
")",
";",
"$",
"target",
"=",
"$",
"this",
"->",
"definition",
"->",
"targetContext",
"(",
")",
";",
"if",
"(",
"empt... | Check if relation requests foreign key constraints to be created.
@return bool | [
"Check",
"if",
"relation",
"requests",
"foreign",
"key",
"constraints",
"to",
"be",
"created",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/AbstractSchema.php#L126-L140 |
26,135 | spiral/orm | source/Spiral/ORM/Entities/Nodes/AbstractNode.php | AbstractNode.getReferences | public function getReferences(): array
{
if (empty($this->parent)) {
throw new NodeException("Unable to aggregate reference values, parent is missing");
}
if (empty($this->parent->references[$this->outerKey])) {
return [];
}
return array_keys($this->... | php | public function getReferences(): array
{
if (empty($this->parent)) {
throw new NodeException("Unable to aggregate reference values, parent is missing");
}
if (empty($this->parent->references[$this->outerKey])) {
return [];
}
return array_keys($this->... | [
"public",
"function",
"getReferences",
"(",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"parent",
")",
")",
"{",
"throw",
"new",
"NodeException",
"(",
"\"Unable to aggregate reference values, parent is missing\"",
")",
";",
"}",
"if",
"... | Get list of reference key values aggregated by parent.
@return array
@throws NodeException | [
"Get",
"list",
"of",
"reference",
"key",
"values",
"aggregated",
"by",
"parent",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L118-L129 |
26,136 | spiral/orm | source/Spiral/ORM/Entities/Nodes/AbstractNode.php | AbstractNode.registerNode | final public function registerNode(string $container, AbstractNode $node)
{
$node->container = $container;
$node->parent = $this;
$this->nodes[$container] = $node;
if (!empty($node->outerKey)) {
//This will make parser to aggregate such key in order to be used in later ... | php | final public function registerNode(string $container, AbstractNode $node)
{
$node->container = $container;
$node->parent = $this;
$this->nodes[$container] = $node;
if (!empty($node->outerKey)) {
//This will make parser to aggregate such key in order to be used in later ... | [
"final",
"public",
"function",
"registerNode",
"(",
"string",
"$",
"container",
",",
"AbstractNode",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"container",
"=",
"$",
"container",
";",
"$",
"node",
"->",
"parent",
"=",
"$",
"this",
";",
"$",
"this",
"->... | Register new node into NodeTree. Nodes used to convert flat results into tree representation
using reference aggregations.
@param string $container
@param AbstractNode $node
@throws NodeException | [
"Register",
"new",
"node",
"into",
"NodeTree",
".",
"Nodes",
"used",
"to",
"convert",
"flat",
"results",
"into",
"tree",
"representation",
"using",
"reference",
"aggregations",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L140-L151 |
26,137 | spiral/orm | source/Spiral/ORM/Entities/Nodes/AbstractNode.php | AbstractNode.fetchNode | final public function fetchNode(string $container): AbstractNode
{
if (!isset($this->nodes[$container])) {
throw new NodeException("Undefined node {$container}");
}
return $this->nodes[$container];
} | php | final public function fetchNode(string $container): AbstractNode
{
if (!isset($this->nodes[$container])) {
throw new NodeException("Undefined node {$container}");
}
return $this->nodes[$container];
} | [
"final",
"public",
"function",
"fetchNode",
"(",
"string",
"$",
"container",
")",
":",
"AbstractNode",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"nodes",
"[",
"$",
"container",
"]",
")",
")",
"{",
"throw",
"new",
"NodeException",
"(",
"\"Un... | Fetch sub node.
@param string $container
@return AbstractNode
@throws NodeException | [
"Fetch",
"sub",
"node",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L173-L180 |
26,138 | spiral/orm | source/Spiral/ORM/Entities/Nodes/AbstractNode.php | AbstractNode.parseRow | final public function parseRow(int $dataOffset, array $row): int
{
//Fetching Node specific data from resulted row
$data = $this->fetchData($dataOffset, $row);
if ($this->deduplicate($data)) {
//Create reference keys
$this->collectReferences($data);
//Ma... | php | final public function parseRow(int $dataOffset, array $row): int
{
//Fetching Node specific data from resulted row
$data = $this->fetchData($dataOffset, $row);
if ($this->deduplicate($data)) {
//Create reference keys
$this->collectReferences($data);
//Ma... | [
"final",
"public",
"function",
"parseRow",
"(",
"int",
"$",
"dataOffset",
",",
"array",
"$",
"row",
")",
":",
"int",
"{",
"//Fetching Node specific data from resulted row",
"$",
"data",
"=",
"$",
"this",
"->",
"fetchData",
"(",
"$",
"dataOffset",
",",
"$",
"... | Parser result work, fetch data and mount it into parent tree.
@param int $dataOffset
@param array $row
@return int Must return number of handled columns. | [
"Parser",
"result",
"work",
"fetch",
"data",
"and",
"mount",
"it",
"into",
"parent",
"tree",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L190-L233 |
26,139 | spiral/orm | source/Spiral/ORM/Entities/Nodes/AbstractNode.php | AbstractNode.fetchData | protected function fetchData(int $dataOffset, array $line): array
{
if (empty($this->columns)) {
return $line;
}
try {
//Combine column names with sliced piece of row
return array_combine(
$this->columns,
array_slice($line,... | php | protected function fetchData(int $dataOffset, array $line): array
{
if (empty($this->columns)) {
return $line;
}
try {
//Combine column names with sliced piece of row
return array_combine(
$this->columns,
array_slice($line,... | [
"protected",
"function",
"fetchData",
"(",
"int",
"$",
"dataOffset",
",",
"array",
"$",
"line",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"columns",
")",
")",
"{",
"return",
"$",
"line",
";",
"}",
"try",
"{",
"//Combine colu... | Fetch record columns from query row, must use data offset to slice required part of query.
@param int $dataOffset
@param array $line
@return array | [
"Fetch",
"record",
"columns",
"from",
"query",
"row",
"must",
"use",
"data",
"offset",
"to",
"slice",
"required",
"part",
"of",
"query",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L357-L372 |
26,140 | spiral/orm | source/Spiral/ORM/Entities/Nodes/AbstractNode.php | AbstractNode.ensurePlaceholders | private function ensurePlaceholders(array &$data)
{
//Let's force placeholders for every sub loaded
foreach ($this->nodes as $name => $node) {
$data[$name] = $node instanceof ArrayInterface ? [] : null;
}
} | php | private function ensurePlaceholders(array &$data)
{
//Let's force placeholders for every sub loaded
foreach ($this->nodes as $name => $node) {
$data[$name] = $node instanceof ArrayInterface ? [] : null;
}
} | [
"private",
"function",
"ensurePlaceholders",
"(",
"array",
"&",
"$",
"data",
")",
"{",
"//Let's force placeholders for every sub loaded",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"name",
"=>",
"$",
"node",
")",
"{",
"$",
"data",
"[",
"$",
"name... | Create placeholders for each of sub nodes.
@param array $data | [
"Create",
"placeholders",
"for",
"each",
"of",
"sub",
"nodes",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L398-L404 |
26,141 | spiral/orm | source/Spiral/ORM/Entities/Nodes/AbstractNode.php | AbstractNode.trackReference | private function trackReference(string $key)
{
if (!in_array($key, $this->columns)) {
throw new NodeException("Unable to create reference, key {$key} does not exist");
}
if (!in_array($key, $this->trackReferences)) {
//We are only tracking unique references
... | php | private function trackReference(string $key)
{
if (!in_array($key, $this->columns)) {
throw new NodeException("Unable to create reference, key {$key} does not exist");
}
if (!in_array($key, $this->trackReferences)) {
//We are only tracking unique references
... | [
"private",
"function",
"trackReference",
"(",
"string",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"columns",
")",
")",
"{",
"throw",
"new",
"NodeException",
"(",
"\"Unable to create reference, key {$key} does no... | Add key to be tracked
@param string $key
@throws NodeException | [
"Add",
"key",
"to",
"be",
"tracked"
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L413-L423 |
26,142 | spiral/orm | source/Spiral/ORM/Entities/Loaders/RootLoader.php | RootLoader.withColumns | public function withColumns(array $columns): self
{
$loader = clone $this;
$loader->columns = array_merge(
[$loader->schema[Record::SH_PRIMARY_KEY]],
$columns
);
return $loader;
} | php | public function withColumns(array $columns): self
{
$loader = clone $this;
$loader->columns = array_merge(
[$loader->schema[Record::SH_PRIMARY_KEY]],
$columns
);
return $loader;
} | [
"public",
"function",
"withColumns",
"(",
"array",
"$",
"columns",
")",
":",
"self",
"{",
"$",
"loader",
"=",
"clone",
"$",
"this",
";",
"$",
"loader",
"->",
"columns",
"=",
"array_merge",
"(",
"[",
"$",
"loader",
"->",
"schema",
"[",
"Record",
"::",
... | Columns to be selected, please note, primary will always be included, DO not include
column aliases in here, aliases will be added automatically. Creates new loader tree copy.
@param array $columns
@return RootLoader | [
"Columns",
"to",
"be",
"selected",
"please",
"note",
"primary",
"will",
"always",
"be",
"included",
"DO",
"not",
"include",
"column",
"aliases",
"in",
"here",
"aliases",
"will",
"be",
"added",
"automatically",
".",
"Creates",
"new",
"loader",
"tree",
"copy",
... | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Loaders/RootLoader.php#L70-L79 |
26,143 | spiral/orm | source/Spiral/ORM/Entities/Relations/MultipleRelation.php | MultipleRelation.matchOne | public function matchOne($query)
{
foreach ($this->loadData(true)->instances as $instance) {
if ($this->match($instance, $query)) {
return $instance;
}
}
return null;
} | php | public function matchOne($query)
{
foreach ($this->loadData(true)->instances as $instance) {
if ($this->match($instance, $query)) {
return $instance;
}
}
return null;
} | [
"public",
"function",
"matchOne",
"(",
"$",
"query",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"loadData",
"(",
"true",
")",
"->",
"instances",
"as",
"$",
"instance",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"match",
"(",
"$",
"instance",
",",
"$... | Fine one entity for a given query or return null. Method will autoload data.
Example: ->matchOne(['value' => 'something', ...]);
@param array|RecordInterface|mixed $query Fields, entity or PK.
@return RecordInterface|null | [
"Fine",
"one",
"entity",
"for",
"a",
"given",
"query",
"or",
"return",
"null",
".",
"Method",
"will",
"autoload",
"data",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/MultipleRelation.php#L108-L117 |
26,144 | spiral/orm | source/Spiral/ORM/Entities/Relations/MultipleRelation.php | MultipleRelation.matchMultiple | public function matchMultiple($query)
{
$result = [];
foreach ($this->loadData(true)->instances as $instance) {
if ($this->match($instance, $query)) {
$result[] = $instance;
}
}
return new \ArrayIterator($result);
} | php | public function matchMultiple($query)
{
$result = [];
foreach ($this->loadData(true)->instances as $instance) {
if ($this->match($instance, $query)) {
$result[] = $instance;
}
}
return new \ArrayIterator($result);
} | [
"public",
"function",
"matchMultiple",
"(",
"$",
"query",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"loadData",
"(",
"true",
")",
"->",
"instances",
"as",
"$",
"instance",
")",
"{",
"if",
"(",
"$",
"this",
"->"... | Return only instances matched given query, performed in memory! Only simple conditions are
allowed. Not "find" due trademark violation. Method will autoload data.
Example: ->matchMultiple(['value' => 'something', ...]);
@param array|RecordInterface|mixed $query Fields, entity or PK.
@return \ArrayIterator | [
"Return",
"only",
"instances",
"matched",
"given",
"query",
"performed",
"in",
"memory!",
"Only",
"simple",
"conditions",
"are",
"allowed",
".",
"Not",
"find",
"due",
"trademark",
"violation",
".",
"Method",
"will",
"autoload",
"data",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/MultipleRelation.php#L129-L139 |
26,145 | spiral/orm | source/Spiral/ORM/Entities/Relations/MultipleRelation.php | MultipleRelation.initInstances | protected function initInstances(): self
{
if (is_array($this->data) && !empty($this->data)) {
//Iterates and instantiate records
$iterator = new RecordIterator($this->data, $this->class, $this->orm);
foreach ($iterator as $item) {
if (in_array($item, $th... | php | protected function initInstances(): self
{
if (is_array($this->data) && !empty($this->data)) {
//Iterates and instantiate records
$iterator = new RecordIterator($this->data, $this->class, $this->orm);
foreach ($iterator as $item) {
if (in_array($item, $th... | [
"protected",
"function",
"initInstances",
"(",
")",
":",
"self",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"data",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"//Iterates and instantiate records",
"$",
"iterator",
"=... | Init pre-loaded data.
@return HasManyRelation|self | [
"Init",
"pre",
"-",
"loaded",
"data",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/MultipleRelation.php#L174-L194 |
26,146 | spiral/orm | source/Spiral/ORM/Entities/Relations/Traits/MatchTrait.php | MatchTrait.match | protected function match(RecordInterface $record, $query): bool
{
if ($record === $query) {
//Strict search
return true;
}
//Primary key comparision
if (is_scalar($query) && $record->primaryKey() == $query) {
return true;
}
//Reco... | php | protected function match(RecordInterface $record, $query): bool
{
if ($record === $query) {
//Strict search
return true;
}
//Primary key comparision
if (is_scalar($query) && $record->primaryKey() == $query) {
return true;
}
//Reco... | [
"protected",
"function",
"match",
"(",
"RecordInterface",
"$",
"record",
",",
"$",
"query",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"record",
"===",
"$",
"query",
")",
"{",
"//Strict search",
"return",
"true",
";",
"}",
"//Primary key comparision",
"if",
"(... | Match entity by field intersection, instance values or primary key.
@param RecordInterface $record
@param RecordInterface|array|mixed $query
@return bool | [
"Match",
"entity",
"by",
"field",
"intersection",
"instance",
"values",
"or",
"primary",
"key",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/Traits/MatchTrait.php#L25-L58 |
26,147 | spiral/orm | source/Spiral/ORM/ORM.php | ORM.schemaBuilder | public function schemaBuilder(bool $locate = true): SchemaBuilder
{
/**
* @var SchemaBuilder $builder
*/
$builder = $this->getFactory()->make(SchemaBuilder::class, ['manager' => $this->manager]);
if ($locate) {
foreach ($this->locator->locateSchemas() as $schem... | php | public function schemaBuilder(bool $locate = true): SchemaBuilder
{
/**
* @var SchemaBuilder $builder
*/
$builder = $this->getFactory()->make(SchemaBuilder::class, ['manager' => $this->manager]);
if ($locate) {
foreach ($this->locator->locateSchemas() as $schem... | [
"public",
"function",
"schemaBuilder",
"(",
"bool",
"$",
"locate",
"=",
"true",
")",
":",
"SchemaBuilder",
"{",
"/**\n * @var SchemaBuilder $builder\n */",
"$",
"builder",
"=",
"$",
"this",
"->",
"getFactory",
"(",
")",
"->",
"make",
"(",
"SchemaBu... | Create instance of ORM SchemaBuilder.
@param bool $locate Set to true to automatically locate available records and record sources
sources in a project files (based on tokenizer scope).
@return SchemaBuilder
@throws SchemaException | [
"Create",
"instance",
"of",
"ORM",
"SchemaBuilder",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/ORM.php#L158-L176 |
26,148 | spiral/orm | source/Spiral/ORM/ORM.php | ORM.getFactory | protected function getFactory(): FactoryInterface
{
if ($this->container instanceof FactoryInterface) {
return $this->container;
}
return $this->container->get(FactoryInterface::class);
} | php | protected function getFactory(): FactoryInterface
{
if ($this->container instanceof FactoryInterface) {
return $this->container;
}
return $this->container->get(FactoryInterface::class);
} | [
"protected",
"function",
"getFactory",
"(",
")",
":",
"FactoryInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"container",
"instanceof",
"FactoryInterface",
")",
"{",
"return",
"$",
"this",
"->",
"container",
";",
"}",
"return",
"$",
"this",
"->",
"container"... | Get ODM specific factory.
@return FactoryInterface | [
"Get",
"ODM",
"specific",
"factory",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/ORM.php#L429-L436 |
26,149 | robertlemke/RobertLemke.Plugin.Blog | Classes/Controller/CommentController.php | CommentController.createAction | public function createAction(NodeInterface $postNode, NodeTemplate $newComment)
{
# Workaround until we can validate node templates properly:
if (strlen($newComment->getProperty('author')) < 2) {
$this->throwStatus(400, 'Your comment was NOT created - please specify your name.');
... | php | public function createAction(NodeInterface $postNode, NodeTemplate $newComment)
{
# Workaround until we can validate node templates properly:
if (strlen($newComment->getProperty('author')) < 2) {
$this->throwStatus(400, 'Your comment was NOT created - please specify your name.');
... | [
"public",
"function",
"createAction",
"(",
"NodeInterface",
"$",
"postNode",
",",
"NodeTemplate",
"$",
"newComment",
")",
"{",
"# Workaround until we can validate node templates properly:",
"if",
"(",
"strlen",
"(",
"$",
"newComment",
"->",
"getProperty",
"(",
"'author'... | Creates a new comment
@param NodeInterface $postNode The post node which will contain the new comment
@param NodeTemplate<RobertLemke.Plugin.Blog:Comment> $newComment
@return string | [
"Creates",
"a",
"new",
"comment"
] | 7780d7e37022056ebe31088c7917ecaad8881dde | https://github.com/robertlemke/RobertLemke.Plugin.Blog/blob/7780d7e37022056ebe31088c7917ecaad8881dde/Classes/Controller/CommentController.php#L48-L79 |
26,150 | spiral/orm | source/Spiral/ORM/Entities/Relations/AbstractRelation.php | AbstractRelation.primaryColumnOf | protected function primaryColumnOf(RecordInterface $record): string
{
return $this->orm->define(get_class($record), ORMInterface::R_PRIMARY_KEY);
} | php | protected function primaryColumnOf(RecordInterface $record): string
{
return $this->orm->define(get_class($record), ORMInterface::R_PRIMARY_KEY);
} | [
"protected",
"function",
"primaryColumnOf",
"(",
"RecordInterface",
"$",
"record",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"orm",
"->",
"define",
"(",
"get_class",
"(",
"$",
"record",
")",
",",
"ORMInterface",
"::",
"R_PRIMARY_KEY",
")",
";",
... | Get primary key column
@param RecordInterface $record
@return string | [
"Get",
"primary",
"key",
"column"
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/AbstractRelation.php#L140-L143 |
26,151 | spiral/orm | source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php | ManyToManyRelation.getPivot | public function getPivot(RecordInterface $record): array
{
if (empty($matched = $this->matchOne($record))) {
return [];
}
return $this->pivotData->offsetGet($matched);
} | php | public function getPivot(RecordInterface $record): array
{
if (empty($matched = $this->matchOne($record))) {
return [];
}
return $this->pivotData->offsetGet($matched);
} | [
"public",
"function",
"getPivot",
"(",
"RecordInterface",
"$",
"record",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"matched",
"=",
"$",
"this",
"->",
"matchOne",
"(",
"$",
"record",
")",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"ret... | Get pivot data associated with specific instance.
@param RecordInterface $record
@return array | [
"Get",
"pivot",
"data",
"associated",
"with",
"specific",
"instance",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php#L150-L157 |
26,152 | spiral/orm | source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php | ManyToManyRelation.link | public function link(RecordInterface $record, array $pivotData = []): self
{
$this->loadData(true);
$this->assertValid($record);
$this->assertPivot($pivotData);
//Ensure reference
$record = $this->matchOne($record) ?? $record;
if (in_array($record, $this->instances,... | php | public function link(RecordInterface $record, array $pivotData = []): self
{
$this->loadData(true);
$this->assertValid($record);
$this->assertPivot($pivotData);
//Ensure reference
$record = $this->matchOne($record) ?? $record;
if (in_array($record, $this->instances,... | [
"public",
"function",
"link",
"(",
"RecordInterface",
"$",
"record",
",",
"array",
"$",
"pivotData",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"this",
"->",
"loadData",
"(",
"true",
")",
";",
"$",
"this",
"->",
"assertValid",
"(",
"$",
"record",
")"... | Link record with parent entity. Only record instances is accepted.
Attention, attached instances MIGHT be de-referenced IF parent object was reselected in a
different scope.
@param RecordInterface $record
@param array $pivotData
@return self
@throws RelationException | [
"Link",
"record",
"with",
"parent",
"entity",
".",
"Only",
"record",
"instances",
"is",
"accepted",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php#L172-L199 |
26,153 | spiral/orm | source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php | ManyToManyRelation.unlink | public function unlink(RecordInterface $record): self
{
$this->loadData(true);
//Ensure reference
$record = $this->matchOne($record) ?? $record;
foreach ($this->instances as $index => $linked) {
if ($this->match($linked, $record)) {
//Removing locally
... | php | public function unlink(RecordInterface $record): self
{
$this->loadData(true);
//Ensure reference
$record = $this->matchOne($record) ?? $record;
foreach ($this->instances as $index => $linked) {
if ($this->match($linked, $record)) {
//Removing locally
... | [
"public",
"function",
"unlink",
"(",
"RecordInterface",
"$",
"record",
")",
":",
"self",
"{",
"$",
"this",
"->",
"loadData",
"(",
"true",
")",
";",
"//Ensure reference",
"$",
"record",
"=",
"$",
"this",
"->",
"matchOne",
"(",
"$",
"record",
")",
"??",
... | Unlink specific entity from relation. Will load relation data! Record to delete will be
automatically matched to a give record.
@param RecordInterface $record
@return self
@throws RelationException When entity not linked. | [
"Unlink",
"specific",
"entity",
"from",
"relation",
".",
"Will",
"load",
"relation",
"data!",
"Record",
"to",
"delete",
"will",
"be",
"automatically",
"matched",
"to",
"a",
"give",
"record",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php#L211-L234 |
26,154 | spiral/orm | source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php | ManyToManyRelation.loadRelated | protected function loadRelated(): array
{
$innerKey = $this->parent->getField($this->key(Record::INNER_KEY));
if (empty($innerKey)) {
return [];
}
//Work with pre-build query
$query = $this->createQuery($innerKey);
//Use custom node to parse data
... | php | protected function loadRelated(): array
{
$innerKey = $this->parent->getField($this->key(Record::INNER_KEY));
if (empty($innerKey)) {
return [];
}
//Work with pre-build query
$query = $this->createQuery($innerKey);
//Use custom node to parse data
... | [
"protected",
"function",
"loadRelated",
"(",
")",
":",
"array",
"{",
"$",
"innerKey",
"=",
"$",
"this",
"->",
"parent",
"->",
"getField",
"(",
"$",
"this",
"->",
"key",
"(",
"Record",
"::",
"INNER_KEY",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
... | Fetch data from database. Lazy load. Method require a bit of love.
@return array | [
"Fetch",
"data",
"from",
"database",
".",
"Lazy",
"load",
".",
"Method",
"require",
"a",
"bit",
"of",
"love",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php#L372-L401 |
26,155 | spiral/orm | source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php | ManyToManyRelation.createQuery | protected function createQuery($innerKey): SelectQuery
{
$table = $this->orm->table($this->class);
$query = $table->select();
//Loader will take care of query configuration
$loader = new ManyToManyLoader(
$this->class,
$table->getName(),
$this->sc... | php | protected function createQuery($innerKey): SelectQuery
{
$table = $this->orm->table($this->class);
$query = $table->select();
//Loader will take care of query configuration
$loader = new ManyToManyLoader(
$this->class,
$table->getName(),
$this->sc... | [
"protected",
"function",
"createQuery",
"(",
"$",
"innerKey",
")",
":",
"SelectQuery",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"orm",
"->",
"table",
"(",
"$",
"this",
"->",
"class",
")",
";",
"$",
"query",
"=",
"$",
"table",
"->",
"select",
"(",
... | Create query for lazy loading.
@param mixed $innerKey
@return SelectQuery | [
"Create",
"query",
"for",
"lazy",
"loading",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php#L410-L455 |
26,156 | spiral/orm | source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php | ManyToManyRelation.initInstances | protected function initInstances(): MultipleRelation
{
if (is_array($this->data) && !empty($this->data)) {
//Iterates and instantiate records
$iterator = new RecordIterator($this->data, $this->class, $this->orm);
foreach ($iterator as $pivotData => $item) {
... | php | protected function initInstances(): MultipleRelation
{
if (is_array($this->data) && !empty($this->data)) {
//Iterates and instantiate records
$iterator = new RecordIterator($this->data, $this->class, $this->orm);
foreach ($iterator as $pivotData => $item) {
... | [
"protected",
"function",
"initInstances",
"(",
")",
":",
"MultipleRelation",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"data",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"//Iterates and instantiate records",
"$",
"ite... | Init relations and populate pivot map.
@return self|MultipleRelation | [
"Init",
"relations",
"and",
"populate",
"pivot",
"map",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php#L462-L483 |
26,157 | spiral/orm | source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php | ManyToManyRelation.assertPivot | private function assertPivot(array $pivotData)
{
if ($diff = array_diff(array_keys($pivotData), $this->schema[Record::PIVOT_COLUMNS])) {
throw new RelationException(
"Invalid pivot data, undefined columns found: " . join(', ', $diff)
);
}
} | php | private function assertPivot(array $pivotData)
{
if ($diff = array_diff(array_keys($pivotData), $this->schema[Record::PIVOT_COLUMNS])) {
throw new RelationException(
"Invalid pivot data, undefined columns found: " . join(', ', $diff)
);
}
} | [
"private",
"function",
"assertPivot",
"(",
"array",
"$",
"pivotData",
")",
"{",
"if",
"(",
"$",
"diff",
"=",
"array_diff",
"(",
"array_keys",
"(",
"$",
"pivotData",
")",
",",
"$",
"this",
"->",
"schema",
"[",
"Record",
"::",
"PIVOT_COLUMNS",
"]",
")",
... | Make sure that pivot data in a valid format.
@param array $pivotData
@throws RelationException | [
"Make",
"sure",
"that",
"pivot",
"data",
"in",
"a",
"valid",
"format",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php#L508-L515 |
26,158 | spiral/orm | source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php | ManyToManyRelation.targetRole | private function targetRole(): string
{
return $this->targetRole ?? $this->orm->define(
get_class($this->parent),
ORMInterface::R_ROLE_NAME
);
} | php | private function targetRole(): string
{
return $this->targetRole ?? $this->orm->define(
get_class($this->parent),
ORMInterface::R_ROLE_NAME
);
} | [
"private",
"function",
"targetRole",
"(",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"targetRole",
"??",
"$",
"this",
"->",
"orm",
"->",
"define",
"(",
"get_class",
"(",
"$",
"this",
"->",
"parent",
")",
",",
"ORMInterface",
"::",
"R_ROLE_NAME... | Defined role to be used in morphed relations.
@return string | [
"Defined",
"role",
"to",
"be",
"used",
"in",
"morphed",
"relations",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php#L522-L528 |
26,159 | spiral/orm | source/Spiral/ORM/Transaction.php | Transaction.getCommands | public function getCommands()
{
foreach ($this->commands as $command) {
if ($command instanceof \Traversable) {
//Nested commands
yield from $command;
}
yield $command;
}
} | php | public function getCommands()
{
foreach ($this->commands as $command) {
if ($command instanceof \Traversable) {
//Nested commands
yield from $command;
}
yield $command;
}
} | [
"public",
"function",
"getCommands",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"commands",
"as",
"$",
"command",
")",
"{",
"if",
"(",
"$",
"command",
"instanceof",
"\\",
"Traversable",
")",
"{",
"//Nested commands",
"yield",
"from",
"$",
"command",... | Will return flattened list of commands.
@return \Generator | [
"Will",
"return",
"flattened",
"list",
"of",
"commands",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Transaction.php#L68-L78 |
26,160 | rinvex/cortex-foundation | src/Providers/FoundationServiceProvider.php | FoundationServiceProvider.overrideNotificationMiddleware | protected function overrideNotificationMiddleware(): void
{
$this->app->singleton('Cortex\Foundation\Http\Middleware\NotificationMiddleware', function ($app) {
return new NotificationMiddleware(
$app['session.store'],
$app['notification'],
$app['co... | php | protected function overrideNotificationMiddleware(): void
{
$this->app->singleton('Cortex\Foundation\Http\Middleware\NotificationMiddleware', function ($app) {
return new NotificationMiddleware(
$app['session.store'],
$app['notification'],
$app['co... | [
"protected",
"function",
"overrideNotificationMiddleware",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'Cortex\\Foundation\\Http\\Middleware\\NotificationMiddleware'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"N... | Override notification middleware.
@return void | [
"Override",
"notification",
"middleware",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Providers/FoundationServiceProvider.php#L163-L172 |
26,161 | rinvex/cortex-foundation | src/Providers/FoundationServiceProvider.php | FoundationServiceProvider.bindBladeCompiler | protected function bindBladeCompiler(): void
{
$this->app->afterResolving('blade.compiler', function (BladeCompiler $bladeCompiler) {
// @alerts('container')
$bladeCompiler->directive('alerts', function ($container = null) {
if (strcasecmp('()', $container) === 0) {
... | php | protected function bindBladeCompiler(): void
{
$this->app->afterResolving('blade.compiler', function (BladeCompiler $bladeCompiler) {
// @alerts('container')
$bladeCompiler->directive('alerts', function ($container = null) {
if (strcasecmp('()', $container) === 0) {
... | [
"protected",
"function",
"bindBladeCompiler",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"app",
"->",
"afterResolving",
"(",
"'blade.compiler'",
",",
"function",
"(",
"BladeCompiler",
"$",
"bladeCompiler",
")",
"{",
"// @alerts('container')",
"$",
"bladeCompil... | Bind blade compiler.
@return void | [
"Bind",
"blade",
"compiler",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Providers/FoundationServiceProvider.php#L179-L192 |
26,162 | rinvex/cortex-foundation | src/Providers/FoundationServiceProvider.php | FoundationServiceProvider.overrideRedirector | protected function overrideRedirector(): void
{
$this->app->singleton('redirect', function ($app) {
$redirector = new Redirector($app['url']);
// If the session is set on the application instance, we'll inject it into
// the redirector instance. This allows the redirect ... | php | protected function overrideRedirector(): void
{
$this->app->singleton('redirect', function ($app) {
$redirector = new Redirector($app['url']);
// If the session is set on the application instance, we'll inject it into
// the redirector instance. This allows the redirect ... | [
"protected",
"function",
"overrideRedirector",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'redirect'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"redirector",
"=",
"new",
"Redirector",
"(",
"$",
"app",
"[",
"'... | Override the Redirector instance.
@return void | [
"Override",
"the",
"Redirector",
"instance",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Providers/FoundationServiceProvider.php#L199-L213 |
26,163 | rinvex/cortex-foundation | src/Providers/FoundationServiceProvider.php | FoundationServiceProvider.overrideUrlGenerator | protected function overrideUrlGenerator(): void
{
$this->app->singleton('url', function ($app) {
$routes = $app['router']->getRoutes();
// The URL generator needs the route collection that exists on the router.
// Keep in mind this is an object, so we're passing by refer... | php | protected function overrideUrlGenerator(): void
{
$this->app->singleton('url', function ($app) {
$routes = $app['router']->getRoutes();
// The URL generator needs the route collection that exists on the router.
// Keep in mind this is an object, so we're passing by refer... | [
"protected",
"function",
"overrideUrlGenerator",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'url'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"routes",
"=",
"$",
"app",
"[",
"'router'",
"]",
"->",
"getRoutes",... | Override the UrlGenerator instance.
@return void | [
"Override",
"the",
"UrlGenerator",
"instance",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Providers/FoundationServiceProvider.php#L220-L249 |
26,164 | rinvex/cortex-foundation | src/Providers/FoundationServiceProvider.php | FoundationServiceProvider.bindPresenceVerifier | protected function bindPresenceVerifier(): void
{
$this->app->bind('cortex.foundation.presence.verifier', function ($app) {
return new EloquentPresenceVerifier($app['db'], new $app[AbstractModel::class]());
});
} | php | protected function bindPresenceVerifier(): void
{
$this->app->bind('cortex.foundation.presence.verifier', function ($app) {
return new EloquentPresenceVerifier($app['db'], new $app[AbstractModel::class]());
});
} | [
"protected",
"function",
"bindPresenceVerifier",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'cortex.foundation.presence.verifier'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"EloquentPresenceVerifier",
"(",
"$",
... | Bind presence verifier.
@return void | [
"Bind",
"presence",
"verifier",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Providers/FoundationServiceProvider.php#L337-L342 |
26,165 | rinvex/cortex-foundation | src/Providers/FoundationServiceProvider.php | FoundationServiceProvider.bindBlueprintMacro | protected function bindBlueprintMacro(): void
{
Blueprint::macro('auditable', function () {
$this->integer('created_by_id')->unsigned()->after('created_at')->nullable();
$this->string('created_by_type')->after('created_at')->nullable();
$this->integer('updated_by_id')->un... | php | protected function bindBlueprintMacro(): void
{
Blueprint::macro('auditable', function () {
$this->integer('created_by_id')->unsigned()->after('created_at')->nullable();
$this->string('created_by_type')->after('created_at')->nullable();
$this->integer('updated_by_id')->un... | [
"protected",
"function",
"bindBlueprintMacro",
"(",
")",
":",
"void",
"{",
"Blueprint",
"::",
"macro",
"(",
"'auditable'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"integer",
"(",
"'created_by_id'",
")",
"->",
"unsigned",
"(",
")",
"->",
"after",... | Bind blueprint macro.
@return void | [
"Bind",
"blueprint",
"macro",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Providers/FoundationServiceProvider.php#L349-L384 |
26,166 | rinvex/cortex-foundation | src/Console/Commands/DataTableMakeCommand.php | DataTableMakeCommand.replaceClasses | protected function replaceClasses($stub, $model, $transformer = null): string
{
if ($transformer) {
$transformer = str_replace('/', '\\', $transformer);
$namespaceTransformer = $this->rootNamespace().'\Transformers\\'.$transformer;
if (starts_with($transformer, '\\')) {... | php | protected function replaceClasses($stub, $model, $transformer = null): string
{
if ($transformer) {
$transformer = str_replace('/', '\\', $transformer);
$namespaceTransformer = $this->rootNamespace().'\Transformers\\'.$transformer;
if (starts_with($transformer, '\\')) {... | [
"protected",
"function",
"replaceClasses",
"(",
"$",
"stub",
",",
"$",
"model",
",",
"$",
"transformer",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"$",
"transformer",
")",
"{",
"$",
"transformer",
"=",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
"... | Replace the model and transformer for the given stub.
@param string $stub
@param string $model
@param string $transformer
@return string | [
"Replace",
"the",
"model",
"and",
"transformer",
"for",
"the",
"given",
"stub",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Console/Commands/DataTableMakeCommand.php#L80-L123 |
26,167 | spiral/orm | source/Spiral/ORM/Helpers/RelationOptions.php | RelationOptions.define | public function define(string $option)
{
if (!array_key_exists($option, $this->options)) {
throw new OptionsException("Undefined relation option '{$option}'");
}
return $this->options[$option];
} | php | public function define(string $option)
{
if (!array_key_exists($option, $this->options)) {
throw new OptionsException("Undefined relation option '{$option}'");
}
return $this->options[$option];
} | [
"public",
"function",
"define",
"(",
"string",
"$",
"option",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"options",
")",
")",
"{",
"throw",
"new",
"OptionsException",
"(",
"\"Undefined relation option '{$option}'\... | Get value for a specific option. Attention, option MUST exist in template in order to
be retrievable.
@param string $option
@return mixed
@throws OptionsException | [
"Get",
"value",
"for",
"a",
"specific",
"option",
".",
"Attention",
"option",
"MUST",
"exist",
"in",
"template",
"in",
"order",
"to",
"be",
"retrievable",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Helpers/RelationOptions.php#L73-L80 |
26,168 | spiral/orm | source/Spiral/ORM/Helpers/RelationOptions.php | RelationOptions.calculateOptions | protected function calculateOptions(array $userOptions): array
{
foreach ($this->template as $property => $pattern) {
if (isset($userOptions[$property])) {
//Specified by user
continue;
}
if (!is_string($pattern)) {
//Some ... | php | protected function calculateOptions(array $userOptions): array
{
foreach ($this->template as $property => $pattern) {
if (isset($userOptions[$property])) {
//Specified by user
continue;
}
if (!is_string($pattern)) {
//Some ... | [
"protected",
"function",
"calculateOptions",
"(",
"array",
"$",
"userOptions",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"this",
"->",
"template",
"as",
"$",
"property",
"=>",
"$",
"pattern",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"userOptions",
"[",... | Calculate options based on given template
@param array $userOptions Options provided by user.
@return array Calculated options. | [
"Calculate",
"options",
"based",
"on",
"given",
"template"
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Helpers/RelationOptions.php#L101-L123 |
26,169 | spiral/orm | source/Spiral/ORM/Helpers/RelationOptions.php | RelationOptions.proposedOptions | protected function proposedOptions(array $userOptions): array
{
$source = $this->definition->sourceContext();
$proposed = [
//Relation name
'relation:name' => $this->definition->getName(),
//Relation name in plural form
'relation:plural' => Inf... | php | protected function proposedOptions(array $userOptions): array
{
$source = $this->definition->sourceContext();
$proposed = [
//Relation name
'relation:name' => $this->definition->getName(),
//Relation name in plural form
'relation:plural' => Inf... | [
"protected",
"function",
"proposedOptions",
"(",
"array",
"$",
"userOptions",
")",
":",
"array",
"{",
"$",
"source",
"=",
"$",
"this",
"->",
"definition",
"->",
"sourceContext",
"(",
")",
";",
"$",
"proposed",
"=",
"[",
"//Relation name",
"'relation:name'",
... | Create set of options to specify missing relation definition fields.
@param array $userOptions User options.
@return array | [
"Create",
"set",
"of",
"options",
"to",
"specify",
"missing",
"relation",
"definition",
"fields",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Helpers/RelationOptions.php#L132-L186 |
26,170 | spiral/orm | source/Spiral/ORM/Entities/RecordSelector.php | RecordSelector.withColumns | public function withColumns(array $columns): self
{
$selector = clone $this;
$selector->loader = $selector->loader->withColumns($columns);
return $selector;
} | php | public function withColumns(array $columns): self
{
$selector = clone $this;
$selector->loader = $selector->loader->withColumns($columns);
return $selector;
} | [
"public",
"function",
"withColumns",
"(",
"array",
"$",
"columns",
")",
":",
"self",
"{",
"$",
"selector",
"=",
"clone",
"$",
"this",
";",
"$",
"selector",
"->",
"loader",
"=",
"$",
"selector",
"->",
"loader",
"->",
"withColumns",
"(",
"$",
"columns",
... | Columns to be selected, please note, primary will always be included, DO not include
column aliases in here, aliases will be added automatically. Creates selector as response.
@param array $columns
@return RecordSelector | [
"Columns",
"to",
"be",
"selected",
"please",
"note",
"primary",
"will",
"always",
"be",
"included",
"DO",
"not",
"include",
"column",
"aliases",
"in",
"here",
"aliases",
"will",
"be",
"added",
"automatically",
".",
"Creates",
"selector",
"as",
"response",
"."
... | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/RecordSelector.php#L122-L128 |
26,171 | spiral/orm | source/Spiral/ORM/Entities/RecordSelector.php | RecordSelector.load | public function load($relation, array $options = []): self
{
if (is_array($relation)) {
foreach ($relation as $name => $subOption) {
if (is_string($subOption)) {
//Array of relation names
$this->load($subOption, $options);
}... | php | public function load($relation, array $options = []): self
{
if (is_array($relation)) {
foreach ($relation as $name => $subOption) {
if (is_string($subOption)) {
//Array of relation names
$this->load($subOption, $options);
}... | [
"public",
"function",
"load",
"(",
"$",
"relation",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"self",
"{",
"if",
"(",
"is_array",
"(",
"$",
"relation",
")",
")",
"{",
"foreach",
"(",
"$",
"relation",
"as",
"$",
"name",
"=>",
"$",
"su... | Request primary selector loader to pre-load relation name. Any type of loader can be used
for
data preloading. ORM loaders by default will select the most efficient way to load related
data which might include additional select query or left join. Loaded data will
automatically pre-populate record relations. You can sp... | [
"Request",
"primary",
"selector",
"loader",
"to",
"pre",
"-",
"load",
"relation",
"name",
".",
"Any",
"type",
"of",
"loader",
"can",
"be",
"used",
"for",
"data",
"preloading",
".",
"ORM",
"loaders",
"by",
"default",
"will",
"select",
"the",
"most",
"effici... | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/RecordSelector.php#L189-L209 |
26,172 | spiral/orm | source/Spiral/ORM/Entities/RecordSelector.php | RecordSelector.wherePK | public function wherePK($id): self
{
if (empty($this->loader->primaryKey())) {
//This MUST never happen due ORM requires PK now for every entity
throw new SelectorException("Unable to set wherePK condition, no proper PK were defined");
}
//Adding condition to initial... | php | public function wherePK($id): self
{
if (empty($this->loader->primaryKey())) {
//This MUST never happen due ORM requires PK now for every entity
throw new SelectorException("Unable to set wherePK condition, no proper PK were defined");
}
//Adding condition to initial... | [
"public",
"function",
"wherePK",
"(",
"$",
"id",
")",
":",
"self",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"loader",
"->",
"primaryKey",
"(",
")",
")",
")",
"{",
"//This MUST never happen due ORM requires PK now for every entity",
"throw",
"new",
"Sel... | Shortcut to where method to set AND condition for parent record primary key.
@param string|int $id
@return RecordSelector
@throws SelectorException | [
"Shortcut",
"to",
"where",
"method",
"to",
"set",
"AND",
"condition",
"for",
"parent",
"record",
"primary",
"key",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/RecordSelector.php#L319-L333 |
26,173 | spiral/orm | source/Spiral/ORM/Entities/RecordSelector.php | RecordSelector.findOne | public function findOne(array $query = null)
{
$data = (clone $this)->where($query)->fetchData();
if (empty($data[0])) {
return null;
}
return $this->orm->make($this->class, $data[0], ORMInterface::STATE_LOADED, true);
} | php | public function findOne(array $query = null)
{
$data = (clone $this)->where($query)->fetchData();
if (empty($data[0])) {
return null;
}
return $this->orm->make($this->class, $data[0], ORMInterface::STATE_LOADED, true);
} | [
"public",
"function",
"findOne",
"(",
"array",
"$",
"query",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"(",
"clone",
"$",
"this",
")",
"->",
"where",
"(",
"$",
"query",
")",
"->",
"fetchData",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
... | Find one entity or return null.
@param array|null $query
@return EntityInterface|null | [
"Find",
"one",
"entity",
"or",
"return",
"null",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/RecordSelector.php#L342-L351 |
26,174 | spiral/orm | source/Spiral/ORM/Entities/RecordSelector.php | RecordSelector.fetchAll | public function fetchAll(
string $cacheKey = '',
$ttl = 0,
CacheInterface $cache = null
): array {
return iterator_to_array($this->getIterator($cacheKey, $ttl, $cache));
} | php | public function fetchAll(
string $cacheKey = '',
$ttl = 0,
CacheInterface $cache = null
): array {
return iterator_to_array($this->getIterator($cacheKey, $ttl, $cache));
} | [
"public",
"function",
"fetchAll",
"(",
"string",
"$",
"cacheKey",
"=",
"''",
",",
"$",
"ttl",
"=",
"0",
",",
"CacheInterface",
"$",
"cache",
"=",
"null",
")",
":",
"array",
"{",
"return",
"iterator_to_array",
"(",
"$",
"this",
"->",
"getIterator",
"(",
... | Fetch all records in a form of array.
@param string $cacheKey
@param int|\DateInterval $ttl
@param CacheInterface|null $cache Can be automatically resoled via ORM container scope.
@return RecordInterface[] | [
"Fetch",
"all",
"records",
"in",
"a",
"form",
"of",
"array",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/RecordSelector.php#L362-L368 |
26,175 | spiral/orm | source/Spiral/ORM/Entities/RecordSelector.php | RecordSelector.count | public function count(string $column = null): int
{
if (is_null($column)) {
if (!empty($this->loader->primaryKey())) {
//@tuneyourserver solves the issue with counting on queries with joins.
$column = "DISTINCT({$this->loader->primaryKey()})";
} else {... | php | public function count(string $column = null): int
{
if (is_null($column)) {
if (!empty($this->loader->primaryKey())) {
//@tuneyourserver solves the issue with counting on queries with joins.
$column = "DISTINCT({$this->loader->primaryKey()})";
} else {... | [
"public",
"function",
"count",
"(",
"string",
"$",
"column",
"=",
"null",
")",
":",
"int",
"{",
"if",
"(",
"is_null",
"(",
"$",
"column",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"loader",
"->",
"primaryKey",
"(",
")",
")",... | Attention, column will be quoted by driver!
@param string|null $column When column is null DISTINCT(PK) will be generated.
@return int | [
"Attention",
"column",
"will",
"be",
"quoted",
"by",
"driver!"
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/RecordSelector.php#L413-L425 |
26,176 | spiral/orm | source/Spiral/ORM/Entities/RecordSelector.php | RecordSelector.fetchData | public function fetchData(OutputNode $node = null): array
{
/** @var OutputNode $node */
$node = $node ?? $this->loader->createNode();
//Working with parser defined by loader itself
$this->loader->loadData($node);
return $node->getResult();
} | php | public function fetchData(OutputNode $node = null): array
{
/** @var OutputNode $node */
$node = $node ?? $this->loader->createNode();
//Working with parser defined by loader itself
$this->loader->loadData($node);
return $node->getResult();
} | [
"public",
"function",
"fetchData",
"(",
"OutputNode",
"$",
"node",
"=",
"null",
")",
":",
"array",
"{",
"/** @var OutputNode $node */",
"$",
"node",
"=",
"$",
"node",
"??",
"$",
"this",
"->",
"loader",
"->",
"createNode",
"(",
")",
";",
"//Working with parse... | Load data tree from databases and linked loaders in a form of array.
@param OutputNode $node When empty node will be created automatically by root relation
loader.
@return array | [
"Load",
"data",
"tree",
"from",
"databases",
"and",
"linked",
"loaders",
"in",
"a",
"form",
"of",
"array",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/RecordSelector.php#L465-L474 |
26,177 | spiral/orm | source/Spiral/ORM/Configs/MutatorsConfig.php | MutatorsConfig.getMutators | public function getMutators(string $type): array
{
$type = $this->resolveAlias($type);
$mutators = $this->config['mutators'];
return isset($mutators[$type]) ? $mutators[$type] : [];
} | php | public function getMutators(string $type): array
{
$type = $this->resolveAlias($type);
$mutators = $this->config['mutators'];
return isset($mutators[$type]) ? $mutators[$type] : [];
} | [
"public",
"function",
"getMutators",
"(",
"string",
"$",
"type",
")",
":",
"array",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"resolveAlias",
"(",
"$",
"type",
")",
";",
"$",
"mutators",
"=",
"$",
"this",
"->",
"config",
"[",
"'mutators'",
"]",
";",
... | Get list of mutators associated with given field type.
@param string $type
@return array | [
"Get",
"list",
"of",
"mutators",
"associated",
"with",
"given",
"field",
"type",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Configs/MutatorsConfig.php#L41-L47 |
26,178 | spiral/orm | source/Spiral/ORM/Helpers/ColumnRenderer.php | ColumnRenderer.renderColumns | public function renderColumns(
array $fields,
array $defaults,
AbstractTable $table
): AbstractTable {
foreach ($fields as $name => $definition) {
$column = $table->column($name);
//Declaring our column
$this->declareColumn(
$colum... | php | public function renderColumns(
array $fields,
array $defaults,
AbstractTable $table
): AbstractTable {
foreach ($fields as $name => $definition) {
$column = $table->column($name);
//Declaring our column
$this->declareColumn(
$colum... | [
"public",
"function",
"renderColumns",
"(",
"array",
"$",
"fields",
",",
"array",
"$",
"defaults",
",",
"AbstractTable",
"$",
"table",
")",
":",
"AbstractTable",
"{",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"name",
"=>",
"$",
"definition",
")",
"{",
"$... | Render columns in table based on string definition.
Example:
renderColumns([
'id' => 'primary',
'time' => 'datetime, nullable',
'status' => 'enum(active, disabled)'
], [
'status' => 'active',
'time' => null, //idential as if define column as null
], $table);
Attention, new table instance will be returned!
@p... | [
"Render",
"columns",
"in",
"table",
"based",
"on",
"string",
"definition",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Helpers/ColumnRenderer.php#L48-L66 |
26,179 | spiral/orm | source/Spiral/ORM/Helpers/ColumnRenderer.php | ColumnRenderer.castDefault | public function castDefault(AbstractColumn $column)
{
if (in_array($column->abstractType(), ['timestamp', 'datetime', 'time', 'date'])) {
return 0;
}
if ($column->abstractType() == 'enum') {
//We can use first enum value as default
return $column->getEnum... | php | public function castDefault(AbstractColumn $column)
{
if (in_array($column->abstractType(), ['timestamp', 'datetime', 'time', 'date'])) {
return 0;
}
if ($column->abstractType() == 'enum') {
//We can use first enum value as default
return $column->getEnum... | [
"public",
"function",
"castDefault",
"(",
"AbstractColumn",
"$",
"column",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"column",
"->",
"abstractType",
"(",
")",
",",
"[",
"'timestamp'",
",",
"'datetime'",
",",
"'time'",
",",
"'date'",
"]",
")",
")",
"{",
... | Cast default value based on column type. Required to prevent conflicts when not nullable
column added to existed table with data in.
@param AbstractColumn $column
@return mixed | [
"Cast",
"default",
"value",
"based",
"on",
"column",
"type",
".",
"Required",
"to",
"prevent",
"conflicts",
"when",
"not",
"nullable",
"column",
"added",
"to",
"existed",
"table",
"with",
"data",
"in",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Helpers/ColumnRenderer.php#L177-L198 |
26,180 | spiral/orm | source/Spiral/ORM/Schemas/SchemaBuilder.php | SchemaBuilder.addSchema | public function addSchema(SchemaInterface $schema): SchemaBuilder
{
$this->schemas[$schema->getClass()] = $schema;
return $this;
} | php | public function addSchema(SchemaInterface $schema): SchemaBuilder
{
$this->schemas[$schema->getClass()] = $schema;
return $this;
} | [
"public",
"function",
"addSchema",
"(",
"SchemaInterface",
"$",
"schema",
")",
":",
"SchemaBuilder",
"{",
"$",
"this",
"->",
"schemas",
"[",
"$",
"schema",
"->",
"getClass",
"(",
")",
"]",
"=",
"$",
"schema",
";",
"return",
"$",
"this",
";",
"}"
] | Add new model schema into pool.
@param SchemaInterface $schema
@return self|$this | [
"Add",
"new",
"model",
"schema",
"into",
"pool",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/SchemaBuilder.php#L69-L74 |
26,181 | spiral/orm | source/Spiral/ORM/Schemas/SchemaBuilder.php | SchemaBuilder.hasChanges | public function hasChanges(): bool
{
foreach ($this->getTables() as $table) {
if ($table->getComparator()->hasChanges()) {
return true;
}
}
return false;
} | php | public function hasChanges(): bool
{
foreach ($this->getTables() as $table) {
if ($table->getComparator()->hasChanges()) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasChanges",
"(",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getTables",
"(",
")",
"as",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"table",
"->",
"getComparator",
"(",
")",
"->",
"hasChanges",
"(",
")",
")",
"{"... | Indication that tables in database require syncing before being matched with ORM models.
@return bool | [
"Indication",
"that",
"tables",
"in",
"database",
"require",
"syncing",
"before",
"being",
"matched",
"with",
"ORM",
"models",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/SchemaBuilder.php#L297-L306 |
26,182 | spiral/orm | source/Spiral/ORM/Schemas/SchemaBuilder.php | SchemaBuilder.renderModels | protected function renderModels()
{
foreach ($this->schemas as $schema) {
/**
* Attention, this method will request table schema from DBAL and will empty it's state
* so schema can define it from ground zero!
*/
$table = $this->requestTable(
... | php | protected function renderModels()
{
foreach ($this->schemas as $schema) {
/**
* Attention, this method will request table schema from DBAL and will empty it's state
* so schema can define it from ground zero!
*/
$table = $this->requestTable(
... | [
"protected",
"function",
"renderModels",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"schemas",
"as",
"$",
"schema",
")",
"{",
"/**\n * Attention, this method will request table schema from DBAL and will empty it's state\n * so schema can define it fro... | Walk thought schemas and define structure of associated tables.
@throws SchemaException
@throws DBALException | [
"Walk",
"thought",
"schemas",
"and",
"define",
"structure",
"of",
"associated",
"tables",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/SchemaBuilder.php#L379-L424 |
26,183 | spiral/orm | source/Spiral/ORM/Schemas/SchemaBuilder.php | SchemaBuilder.renderRelations | protected function renderRelations()
{
foreach ($this->schemas as $schema) {
foreach ($schema->getRelations() as $name => $relation) {
//Source context defines where relation comes from
$sourceContext = RelationContext::createContent(
$schema,... | php | protected function renderRelations()
{
foreach ($this->schemas as $schema) {
foreach ($schema->getRelations() as $name => $relation) {
//Source context defines where relation comes from
$sourceContext = RelationContext::createContent(
$schema,... | [
"protected",
"function",
"renderRelations",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"schemas",
"as",
"$",
"schema",
")",
"{",
"foreach",
"(",
"$",
"schema",
"->",
"getRelations",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"relation",
")",
"{",
... | Walk thought all record schemas, fetch and declare needed relations using relation manager.
@throws SchemaException
@throws DefinitionException | [
"Walk",
"thought",
"all",
"record",
"schemas",
"fetch",
"and",
"declare",
"needed",
"relations",
"using",
"relation",
"manager",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/SchemaBuilder.php#L432-L462 |
26,184 | spiral/orm | source/Spiral/ORM/Schemas/SchemaBuilder.php | SchemaBuilder.pushTable | protected function pushTable(AbstractTable $schema)
{
//We have to make sure that local table name is used
$table = substr($schema->getName(), strlen($schema->getPrefix()));
if (empty($this->tables[$schema->getDriver()->getName() . '.' . $table])) {
throw new SchemaException("Ab... | php | protected function pushTable(AbstractTable $schema)
{
//We have to make sure that local table name is used
$table = substr($schema->getName(), strlen($schema->getPrefix()));
if (empty($this->tables[$schema->getDriver()->getName() . '.' . $table])) {
throw new SchemaException("Ab... | [
"protected",
"function",
"pushTable",
"(",
"AbstractTable",
"$",
"schema",
")",
"{",
"//We have to make sure that local table name is used",
"$",
"table",
"=",
"substr",
"(",
"$",
"schema",
"->",
"getName",
"(",
")",
",",
"strlen",
"(",
"$",
"schema",
"->",
"get... | Update table state.
@param AbstractTable $schema
@throws SchemaException | [
"Update",
"table",
"state",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/SchemaBuilder.php#L471-L481 |
26,185 | spiral/orm | source/Spiral/ORM/Schemas/Relations/Traits/TablesTrait.php | TablesTrait.sourceTable | protected function sourceTable(SchemaBuilder $builder): AbstractTable
{
$source = $this->getDefinition()->sourceContext();
return $builder->requestTable($source->getTable(), $source->getDatabase());
} | php | protected function sourceTable(SchemaBuilder $builder): AbstractTable
{
$source = $this->getDefinition()->sourceContext();
return $builder->requestTable($source->getTable(), $source->getDatabase());
} | [
"protected",
"function",
"sourceTable",
"(",
"SchemaBuilder",
"$",
"builder",
")",
":",
"AbstractTable",
"{",
"$",
"source",
"=",
"$",
"this",
"->",
"getDefinition",
"(",
")",
"->",
"sourceContext",
"(",
")",
";",
"return",
"$",
"builder",
"->",
"requestTabl... | Get table linked with source relation model.
@param SchemaBuilder $builder
@return AbstractTable
@throws RelationSchemaException | [
"Get",
"table",
"linked",
"with",
"source",
"relation",
"model",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/Traits/TablesTrait.php#L26-L31 |
26,186 | spiral/orm | source/Spiral/ORM/Schemas/Relations/Traits/TablesTrait.php | TablesTrait.targetTable | protected function targetTable(SchemaBuilder $builder): AbstractTable
{
$target = $this->getDefinition()->targetContext();
if (empty($target)) {
throw new RelationSchemaException(sprintf(
"Unable to get target context '%s' in '%s'.'%s'",
$this->getDefiniti... | php | protected function targetTable(SchemaBuilder $builder): AbstractTable
{
$target = $this->getDefinition()->targetContext();
if (empty($target)) {
throw new RelationSchemaException(sprintf(
"Unable to get target context '%s' in '%s'.'%s'",
$this->getDefiniti... | [
"protected",
"function",
"targetTable",
"(",
"SchemaBuilder",
"$",
"builder",
")",
":",
"AbstractTable",
"{",
"$",
"target",
"=",
"$",
"this",
"->",
"getDefinition",
"(",
")",
"->",
"targetContext",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"target",
... | Get table linked with target relation model.
@param SchemaBuilder $builder
@return AbstractTable
@throws RelationSchemaException | [
"Get",
"table",
"linked",
"with",
"target",
"relation",
"model",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/Traits/TablesTrait.php#L42-L55 |
26,187 | spiral/orm | source/Spiral/ORM/Record.php | Record.save | public function save(TransactionInterface $transaction = null, bool $queueRelations = true): int
{
/*
* First, per interface agreement calculate entity state after save command being called.
*/
if (!$this->isLoaded()) {
$state = self::CREATED;
} elseif (!$this->... | php | public function save(TransactionInterface $transaction = null, bool $queueRelations = true): int
{
/*
* First, per interface agreement calculate entity state after save command being called.
*/
if (!$this->isLoaded()) {
$state = self::CREATED;
} elseif (!$this->... | [
"public",
"function",
"save",
"(",
"TransactionInterface",
"$",
"transaction",
"=",
"null",
",",
"bool",
"$",
"queueRelations",
"=",
"true",
")",
":",
"int",
"{",
"/*\n * First, per interface agreement calculate entity state after save command being called.\n */... | Sync entity with database, when no transaction is given ActiveRecord will create and run it
automatically.
@param TransactionInterface|null $transaction
@param bool $queueRelations
@return int | [
"Sync",
"entity",
"with",
"database",
"when",
"no",
"transaction",
"is",
"given",
"ActiveRecord",
"will",
"create",
"and",
"run",
"it",
"automatically",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Record.php#L26-L51 |
26,188 | spiral/orm | source/Spiral/ORM/Record.php | Record.delete | public function delete(TransactionInterface $transaction = null)
{
if (empty($transaction)) {
/*
* When no transaction is given we will create our own and run it immediately.
*/
$transaction = $transaction ?? new Transaction();
$transaction->dele... | php | public function delete(TransactionInterface $transaction = null)
{
if (empty($transaction)) {
/*
* When no transaction is given we will create our own and run it immediately.
*/
$transaction = $transaction ?? new Transaction();
$transaction->dele... | [
"public",
"function",
"delete",
"(",
"TransactionInterface",
"$",
"transaction",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"transaction",
")",
")",
"{",
"/*\n * When no transaction is given we will create our own and run it immediately.\n */... | Delete entity in database, when no transaction is given ActiveRecord will create and run it
automatically.
@param TransactionInterface|null $transaction | [
"Delete",
"entity",
"in",
"database",
"when",
"no",
"transaction",
"is",
"given",
"ActiveRecord",
"will",
"create",
"and",
"run",
"it",
"automatically",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Record.php#L59-L71 |
26,189 | rinvex/cortex-foundation | src/DataTables/AbstractDataTable.php | AbstractDataTable.filename | protected function filename(): string
{
$model = $this->model ?? trim(str_replace('DataTable', '', mb_strrchr(static::class, '\\')), " \t\n\r\0\x0B\\");
$resource = str_plural(mb_strtolower(array_last(explode(class_exists($model) ? '\\' : '.', $model))));
return $resource.'-export-'.date('... | php | protected function filename(): string
{
$model = $this->model ?? trim(str_replace('DataTable', '', mb_strrchr(static::class, '\\')), " \t\n\r\0\x0B\\");
$resource = str_plural(mb_strtolower(array_last(explode(class_exists($model) ? '\\' : '.', $model))));
return $resource.'-export-'.date('... | [
"protected",
"function",
"filename",
"(",
")",
":",
"string",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
"??",
"trim",
"(",
"str_replace",
"(",
"'DataTable'",
",",
"''",
",",
"mb_strrchr",
"(",
"static",
"::",
"class",
",",
"'\\\\'",
")",
")",... | Get filename for export.
@return string | [
"Get",
"filename",
"for",
"export",
"."
] | 230c100d98131c76f777e5036b3e7cd83af49e6e | https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/DataTables/AbstractDataTable.php#L197-L204 |
26,190 | swoft-cloud/swoft-rpc-server | src/Command/RpcCommand.php | RpcCommand.start | public function start()
{
$rpcServer = $this->getRpcServer();
// 是否正在运行
if ($rpcServer->isRunning()) {
$serverStatus = $rpcServer->getServerSetting();
\output()->writeln("<error>The server have been running!(PID: {$serverStatus['masterPid']})</error>", true, true);
... | php | public function start()
{
$rpcServer = $this->getRpcServer();
// 是否正在运行
if ($rpcServer->isRunning()) {
$serverStatus = $rpcServer->getServerSetting();
\output()->writeln("<error>The server have been running!(PID: {$serverStatus['masterPid']})</error>", true, true);
... | [
"public",
"function",
"start",
"(",
")",
"{",
"$",
"rpcServer",
"=",
"$",
"this",
"->",
"getRpcServer",
"(",
")",
";",
"// 是否正在运行",
"if",
"(",
"$",
"rpcServer",
"->",
"isRunning",
"(",
")",
")",
"{",
"$",
"serverStatus",
"=",
"$",
"rpcServer",
"->",
... | start rpc server
@Usage {fullCommand} [-d|--daemon]
@Options
-d, --daemon Run server on the background
@Example
{fullCommand}
{fullCommand} -d | [
"start",
"rpc",
"server"
] | 527ce20421ad46919b16ebdcc12658f0e3807a07 | https://github.com/swoft-cloud/swoft-rpc-server/blob/527ce20421ad46919b16ebdcc12658f0e3807a07/src/Command/RpcCommand.php#L24-L55 |
26,191 | swoft-cloud/swoft-rpc-server | src/Command/RpcCommand.php | RpcCommand.reload | public function reload()
{
$rpcServer = $this->getRpcServer();
// 是否已启动
if (! $rpcServer->isRunning()) {
output()->writeln('<error>The server is not running! cannot reload</error>', true, true);
}
// 打印信息
output()->writeln(sprintf('<info>Server %s is rel... | php | public function reload()
{
$rpcServer = $this->getRpcServer();
// 是否已启动
if (! $rpcServer->isRunning()) {
output()->writeln('<error>The server is not running! cannot reload</error>', true, true);
}
// 打印信息
output()->writeln(sprintf('<info>Server %s is rel... | [
"public",
"function",
"reload",
"(",
")",
"{",
"$",
"rpcServer",
"=",
"$",
"this",
"->",
"getRpcServer",
"(",
")",
";",
"// 是否已启动",
"if",
"(",
"!",
"$",
"rpcServer",
"->",
"isRunning",
"(",
")",
")",
"{",
"output",
"(",
")",
"->",
"writeln",
"(",
"... | reload worker process
@Usage
{fullCommand} [arguments] [options]
@Options
-t Only to reload task processes, default to reload worker and task
@Example
php swoft.php rpc:reload | [
"reload",
"worker",
"process"
] | 527ce20421ad46919b16ebdcc12658f0e3807a07 | https://github.com/swoft-cloud/swoft-rpc-server/blob/527ce20421ad46919b16ebdcc12658f0e3807a07/src/Command/RpcCommand.php#L67-L83 |
26,192 | swoft-cloud/swoft-rpc-server | src/Command/RpcCommand.php | RpcCommand.stop | public function stop()
{
$rpcServer = $this->getRpcServer();
// 是否已启动
if (! $rpcServer->isRunning()) {
\output()->writeln('<error>The server is not running! cannot stop</error>', true, true);
}
// pid文件
$serverStatus = $rpcServer->getServerSetting();
... | php | public function stop()
{
$rpcServer = $this->getRpcServer();
// 是否已启动
if (! $rpcServer->isRunning()) {
\output()->writeln('<error>The server is not running! cannot stop</error>', true, true);
}
// pid文件
$serverStatus = $rpcServer->getServerSetting();
... | [
"public",
"function",
"stop",
"(",
")",
"{",
"$",
"rpcServer",
"=",
"$",
"this",
"->",
"getRpcServer",
"(",
")",
";",
"// 是否已启动",
"if",
"(",
"!",
"$",
"rpcServer",
"->",
"isRunning",
"(",
")",
")",
"{",
"\\",
"output",
"(",
")",
"->",
"writeln",
"(... | stop rpc server
@Usage {fullCommand}
@Example {fullCommand} | [
"stop",
"rpc",
"server"
] | 527ce20421ad46919b16ebdcc12658f0e3807a07 | https://github.com/swoft-cloud/swoft-rpc-server/blob/527ce20421ad46919b16ebdcc12658f0e3807a07/src/Command/RpcCommand.php#L91-L116 |
26,193 | swoft-cloud/swoft-rpc-server | src/Command/RpcCommand.php | RpcCommand.restart | public function restart()
{
$rpcServer = $this->getRpcServer();
// 是否已启动
if ($rpcServer->isRunning()) {
$this->stop();
}
// 重启默认是守护进程
$rpcServer->setDaemonize();
$this->start();
} | php | public function restart()
{
$rpcServer = $this->getRpcServer();
// 是否已启动
if ($rpcServer->isRunning()) {
$this->stop();
}
// 重启默认是守护进程
$rpcServer->setDaemonize();
$this->start();
} | [
"public",
"function",
"restart",
"(",
")",
"{",
"$",
"rpcServer",
"=",
"$",
"this",
"->",
"getRpcServer",
"(",
")",
";",
"// 是否已启动",
"if",
"(",
"$",
"rpcServer",
"->",
"isRunning",
"(",
")",
")",
"{",
"$",
"this",
"->",
"stop",
"(",
")",
";",
"}",
... | restart rpc server
@Usage {fullCommand}
@Options
-d, --daemon Run server on the background
@Example
{fullCommand}
{fullCommand} -d | [
"restart",
"rpc",
"server"
] | 527ce20421ad46919b16ebdcc12658f0e3807a07 | https://github.com/swoft-cloud/swoft-rpc-server/blob/527ce20421ad46919b16ebdcc12658f0e3807a07/src/Command/RpcCommand.php#L128-L140 |
26,194 | spiral/orm | source/Spiral/ORM/Traits/SourceTrait.php | SourceTrait.source | public static function source(): RecordSource
{
/**
* Container to be received via global scope.
*
* @var ContainerInterface $container
*/
//Via global scope
$container = self::staticContainer();
if (empty($container)) {
//Via global s... | php | public static function source(): RecordSource
{
/**
* Container to be received via global scope.
*
* @var ContainerInterface $container
*/
//Via global scope
$container = self::staticContainer();
if (empty($container)) {
//Via global s... | [
"public",
"static",
"function",
"source",
"(",
")",
":",
"RecordSource",
"{",
"/**\n * Container to be received via global scope.\n *\n * @var ContainerInterface $container\n */",
"//Via global scope",
"$",
"container",
"=",
"self",
"::",
"staticContai... | Instance of RecordSource associated with specific model.
@see Component::staticContainer()
*
@return RecordSource
@throws ScopeException | [
"Instance",
"of",
"RecordSource",
"associated",
"with",
"specific",
"model",
"."
] | a301cd1b664e65496dab648d77ee92bf4fb6949b | https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Traits/SourceTrait.php#L87-L106 |
26,195 | swoft-cloud/swoft-rpc-server | src/Validator/ServiceValidator.php | ServiceValidator.getServiceArgs | private function getServiceArgs(array $serviceHandler, array $serviceData): array
{
list($className, $method) = $serviceHandler;
$rc = new \ReflectionClass($className);
$rm = $rc->getMethod($method);
$mps = $rm->getParameters();
$params = $serviceData['params'] ?? [];
... | php | private function getServiceArgs(array $serviceHandler, array $serviceData): array
{
list($className, $method) = $serviceHandler;
$rc = new \ReflectionClass($className);
$rm = $rc->getMethod($method);
$mps = $rm->getParameters();
$params = $serviceData['params'] ?? [];
... | [
"private",
"function",
"getServiceArgs",
"(",
"array",
"$",
"serviceHandler",
",",
"array",
"$",
"serviceData",
")",
":",
"array",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"method",
")",
"=",
"$",
"serviceHandler",
";",
"$",
"rc",
"=",
"new",
"\\",
... | get args of called function
@param array $serviceHandler
@param array $serviceData
@return array
@throws \ReflectionException | [
"get",
"args",
"of",
"called",
"function"
] | 527ce20421ad46919b16ebdcc12658f0e3807a07 | https://github.com/swoft-cloud/swoft-rpc-server/blob/527ce20421ad46919b16ebdcc12658f0e3807a07/src/Validator/ServiceValidator.php#L56-L80 |
26,196 | mirko-pagliai/cakephp-assets | src/Utility/AssetsCreator.php | AssetsCreator.resolveAssetPath | protected function resolveAssetPath()
{
$basename = md5(serialize(array_map(function ($path) {
return [$path, filemtime($path)];
}, $this->paths)));
return Configure::read('Assets.target') . DS . $basename . '.' . $this->type;
} | php | protected function resolveAssetPath()
{
$basename = md5(serialize(array_map(function ($path) {
return [$path, filemtime($path)];
}, $this->paths)));
return Configure::read('Assets.target') . DS . $basename . '.' . $this->type;
} | [
"protected",
"function",
"resolveAssetPath",
"(",
")",
"{",
"$",
"basename",
"=",
"md5",
"(",
"serialize",
"(",
"array_map",
"(",
"function",
"(",
"$",
"path",
")",
"{",
"return",
"[",
"$",
"path",
",",
"filemtime",
"(",
"$",
"path",
")",
"]",
";",
"... | Internal method to resolve the asset path
@return string Asset full path
@use $paths
@use $type | [
"Internal",
"method",
"to",
"resolve",
"the",
"asset",
"path"
] | 5bbe4963e177bfbd4c152e92edaa5eeeb0c6d64b | https://github.com/mirko-pagliai/cakephp-assets/blob/5bbe4963e177bfbd4c152e92edaa5eeeb0c6d64b/src/Utility/AssetsCreator.php#L73-L80 |
26,197 | mirko-pagliai/cakephp-assets | src/Utility/AssetsCreator.php | AssetsCreator.resolveFilePaths | protected function resolveFilePaths($paths)
{
$loadedPlugins = Plugin::loaded();
return array_map(function ($path) use ($loadedPlugins) {
$pluginSplit = pluginSplit($path);
//Note that using `pluginSplit()` is not sufficient, because
// `$path` may still contai... | php | protected function resolveFilePaths($paths)
{
$loadedPlugins = Plugin::loaded();
return array_map(function ($path) use ($loadedPlugins) {
$pluginSplit = pluginSplit($path);
//Note that using `pluginSplit()` is not sufficient, because
// `$path` may still contai... | [
"protected",
"function",
"resolveFilePaths",
"(",
"$",
"paths",
")",
"{",
"$",
"loadedPlugins",
"=",
"Plugin",
"::",
"loaded",
"(",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"path",
")",
"use",
"(",
"$",
"loadedPlugins",
")",
"{",
"$",
... | Internal method to resolve partial file paths and return full paths
@param string|array $paths Partial file paths
@return array Full file paths
@use $type | [
"Internal",
"method",
"to",
"resolve",
"partial",
"file",
"paths",
"and",
"return",
"full",
"paths"
] | 5bbe4963e177bfbd4c152e92edaa5eeeb0c6d64b | https://github.com/mirko-pagliai/cakephp-assets/blob/5bbe4963e177bfbd4c152e92edaa5eeeb0c6d64b/src/Utility/AssetsCreator.php#L88-L111 |
26,198 | mirko-pagliai/cakephp-assets | src/Utility/AssetsCreator.php | AssetsCreator.create | public function create()
{
$File = new File($this->path());
if (!$File->readable()) {
$minifier = $this->type === 'css' ? new Minify\CSS() : new Minify\JS();
array_map([$minifier, 'add'], $this->paths);
//Writes the file
$success = $File->write($mini... | php | public function create()
{
$File = new File($this->path());
if (!$File->readable()) {
$minifier = $this->type === 'css' ? new Minify\CSS() : new Minify\JS();
array_map([$minifier, 'add'], $this->paths);
//Writes the file
$success = $File->write($mini... | [
"public",
"function",
"create",
"(",
")",
"{",
"$",
"File",
"=",
"new",
"File",
"(",
"$",
"this",
"->",
"path",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"File",
"->",
"readable",
"(",
")",
")",
"{",
"$",
"minifier",
"=",
"$",
"this",
"->",
"t... | Creates the asset
@return string
@throws RuntimeException
@uses filename()
@uses path()
@uses $paths
@uses $type | [
"Creates",
"the",
"asset"
] | 5bbe4963e177bfbd4c152e92edaa5eeeb0c6d64b | https://github.com/mirko-pagliai/cakephp-assets/blob/5bbe4963e177bfbd4c152e92edaa5eeeb0c6d64b/src/Utility/AssetsCreator.php#L122-L136 |
26,199 | spiral/security | src/Matcher.php | Matcher.matches | public function matches(string $string, string $pattern): bool
{
if ($string === $pattern) {
return true;
}
if (!$this->isPattern($pattern)) {
return false;
}
return (bool)preg_match($this->getRegex($pattern), $string);
} | php | public function matches(string $string, string $pattern): bool
{
if ($string === $pattern) {
return true;
}
if (!$this->isPattern($pattern)) {
return false;
}
return (bool)preg_match($this->getRegex($pattern), $string);
} | [
"public",
"function",
"matches",
"(",
"string",
"$",
"string",
",",
"string",
"$",
"pattern",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"string",
"===",
"$",
"pattern",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isPatter... | Checks if string matches given pattent.
@param string $string
@param string $pattern
@return bool | [
"Checks",
"if",
"string",
"matches",
"given",
"pattent",
"."
] | a36decbf237460e1e2059bb12b41c69a1cd59ec3 | https://github.com/spiral/security/blob/a36decbf237460e1e2059bb12b41c69a1cd59ec3/src/Matcher.php#L39-L48 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.