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
39,500
Finesse/MicroDB
src/Connection.php
Connection.bindValue
protected function bindValue(\PDOStatement $statement, $name, $value) { if ($value !== null && !is_scalar($value)) { throw new InvalidArgumentException(sprintf( 'Bound value %s expected to be scalar or null, a %s given', is_int($name) ? '#'.$name : '`'.$name.'`', gettype($value) )); } if ($value === null) { $type = \PDO::PARAM_NULL; } elseif (is_bool($value)) { $type = \PDO::PARAM_BOOL; } elseif (is_integer($value)) { $type = \PDO::PARAM_INT; } else { $type = \PDO::PARAM_STR; } $statement->bindValue($name, $value, $type); }
php
protected function bindValue(\PDOStatement $statement, $name, $value) { if ($value !== null && !is_scalar($value)) { throw new InvalidArgumentException(sprintf( 'Bound value %s expected to be scalar or null, a %s given', is_int($name) ? '#'.$name : '`'.$name.'`', gettype($value) )); } if ($value === null) { $type = \PDO::PARAM_NULL; } elseif (is_bool($value)) { $type = \PDO::PARAM_BOOL; } elseif (is_integer($value)) { $type = \PDO::PARAM_INT; } else { $type = \PDO::PARAM_STR; } $statement->bindValue($name, $value, $type); }
[ "protected", "function", "bindValue", "(", "\\", "PDOStatement", "$", "statement", ",", "$", "name", ",", "$", "value", ")", "{", "if", "(", "$", "value", "!==", "null", "&&", "!", "is_scalar", "(", "$", "value", ")", ")", "{", "throw", "new", "Inval...
Binds a value to a PDO statement. @param \PDOStatement $statement PDO statement @param string|int $name Value placeholder name or index (if the placeholder is not named) @param string|int|float|boolean|null $value Value to bind @throws InvalidArgumentException @throws BasePDOException
[ "Binds", "a", "value", "to", "a", "PDO", "statement", "." ]
839ee9b2bbf7bf9811f946325ae7a0eb03d0c063
https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Connection.php#L295-L316
39,501
Finesse/MicroDB
src/Connection.php
Connection.makeReadResource
protected function makeReadResource($source) { if (is_resource($source)) { return $source; } if (is_string($source)) { $resource = @fopen($source, 'r'); if ($resource) { return $resource; } $errorInfo = error_get_last(); throw new FileException(sprintf( 'Unable to open the file `%s` for reading%s', $source, $errorInfo ? ': '.$errorInfo['message'] : '' )); } throw new InvalidArgumentException(sprintf( 'The given source expected to be a file path of a resource, a %s given', is_object($source) ? get_class($source).' instance' : gettype($source) )); }
php
protected function makeReadResource($source) { if (is_resource($source)) { return $source; } if (is_string($source)) { $resource = @fopen($source, 'r'); if ($resource) { return $resource; } $errorInfo = error_get_last(); throw new FileException(sprintf( 'Unable to open the file `%s` for reading%s', $source, $errorInfo ? ': '.$errorInfo['message'] : '' )); } throw new InvalidArgumentException(sprintf( 'The given source expected to be a file path of a resource, a %s given', is_object($source) ? get_class($source).' instance' : gettype($source) )); }
[ "protected", "function", "makeReadResource", "(", "$", "source", ")", "{", "if", "(", "is_resource", "(", "$", "source", ")", ")", "{", "return", "$", "source", ";", "}", "if", "(", "is_string", "(", "$", "source", ")", ")", "{", "$", "resource", "="...
Makes a resource for reading data. @param string|resource $source A file path or a read resource @return resource @throws FileException @throws InvalidArgumentException
[ "Makes", "a", "resource", "for", "reading", "data", "." ]
839ee9b2bbf7bf9811f946325ae7a0eb03d0c063
https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Connection.php#L326-L351
39,502
Finesse/MicroDB
src/Connection.php
Connection.wrapException
protected static function wrapException( \Throwable $exception, string $query = null, array $values = null ): \Throwable { if ($exception instanceof BasePDOException) { return PDOException::wrapBaseException($exception, $query, $values); } return $exception; }
php
protected static function wrapException( \Throwable $exception, string $query = null, array $values = null ): \Throwable { if ($exception instanceof BasePDOException) { return PDOException::wrapBaseException($exception, $query, $values); } return $exception; }
[ "protected", "static", "function", "wrapException", "(", "\\", "Throwable", "$", "exception", ",", "string", "$", "query", "=", "null", ",", "array", "$", "values", "=", "null", ")", ":", "\\", "Throwable", "{", "if", "(", "$", "exception", "instanceof", ...
Creates a library exception from a PHP exception if possible. @param \Throwable $exception @param string|null $query SQL query which caused the error (if caused by a query) @param array|null $values Bound values (if caused by a query) @return IException|\Throwable
[ "Creates", "a", "library", "exception", "from", "a", "PHP", "exception", "if", "possible", "." ]
839ee9b2bbf7bf9811f946325ae7a0eb03d0c063
https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Connection.php#L361-L371
39,503
Innmind/AMQP
src/Model/Queue/Declaration.php
Declaration.passive
public static function passive(string $name): self { $self = new self; $self->passive = true; return $self->withName($name); }
php
public static function passive(string $name): self { $self = new self; $self->passive = true; return $self->withName($name); }
[ "public", "static", "function", "passive", "(", "string", "$", "name", ")", ":", "self", "{", "$", "self", "=", "new", "self", ";", "$", "self", "->", "passive", "=", "true", ";", "return", "$", "self", "->", "withName", "(", "$", "name", ")", ";",...
Check if the queue exists on the server
[ "Check", "if", "the", "queue", "exists", "on", "the", "server" ]
c22b3a8f56162f7845a13c149cb3118e5fe7cffd
https://github.com/Innmind/AMQP/blob/c22b3a8f56162f7845a13c149cb3118e5fe7cffd/src/Model/Queue/Declaration.php#L34-L40
39,504
Innmind/AMQP
src/Model/Queue/Declaration.php
Declaration.exclusive
public function exclusive(): self { if ($this->isPassive()) { throw new ExclusivePassiveDeclarationNotAllowed; } $self = clone $this; $self->exclusive = true; return $self; }
php
public function exclusive(): self { if ($this->isPassive()) { throw new ExclusivePassiveDeclarationNotAllowed; } $self = clone $this; $self->exclusive = true; return $self; }
[ "public", "function", "exclusive", "(", ")", ":", "self", "{", "if", "(", "$", "this", "->", "isPassive", "(", ")", ")", "{", "throw", "new", "ExclusivePassiveDeclarationNotAllowed", ";", "}", "$", "self", "=", "clone", "$", "this", ";", "$", "self", "...
Make the queue only accessible to the current connection
[ "Make", "the", "queue", "only", "accessible", "to", "the", "current", "connection" ]
c22b3a8f56162f7845a13c149cb3118e5fe7cffd
https://github.com/Innmind/AMQP/blob/c22b3a8f56162f7845a13c149cb3118e5fe7cffd/src/Model/Queue/Declaration.php#L75-L85
39,505
Innmind/AMQP
src/Model/Queue/Declaration.php
Declaration.dontWait
public function dontWait(): self { if ($this->isPassive()) { throw new NotWaitingPassiveDeclarationDoesNothing; } $self = clone $this; $self->wait = false; return $self; }
php
public function dontWait(): self { if ($this->isPassive()) { throw new NotWaitingPassiveDeclarationDoesNothing; } $self = clone $this; $self->wait = false; return $self; }
[ "public", "function", "dontWait", "(", ")", ":", "self", "{", "if", "(", "$", "this", "->", "isPassive", "(", ")", ")", "{", "throw", "new", "NotWaitingPassiveDeclarationDoesNothing", ";", "}", "$", "self", "=", "clone", "$", "this", ";", "$", "self", ...
Don't wait for the server response
[ "Don", "t", "wait", "for", "the", "server", "response" ]
c22b3a8f56162f7845a13c149cb3118e5fe7cffd
https://github.com/Innmind/AMQP/blob/c22b3a8f56162f7845a13c149cb3118e5fe7cffd/src/Model/Queue/Declaration.php#L101-L111
39,506
Innmind/AMQP
src/Model/Queue/Declaration.php
Declaration.withName
public function withName(string $name): self { $self = clone $this; $self->name = $name; return $self; }
php
public function withName(string $name): self { $self = clone $this; $self->name = $name; return $self; }
[ "public", "function", "withName", "(", "string", "$", "name", ")", ":", "self", "{", "$", "self", "=", "clone", "$", "this", ";", "$", "self", "->", "name", "=", "$", "name", ";", "return", "$", "self", ";", "}" ]
Name the queue with the given string
[ "Name", "the", "queue", "with", "the", "given", "string" ]
c22b3a8f56162f7845a13c149cb3118e5fe7cffd
https://github.com/Innmind/AMQP/blob/c22b3a8f56162f7845a13c149cb3118e5fe7cffd/src/Model/Queue/Declaration.php#L127-L133
39,507
Innmind/AMQP
src/Model/Queue/Declaration.php
Declaration.withAutoGeneratedName
public function withAutoGeneratedName(): self { if ($this->isPassive()) { throw new PassiveQueueDeclarationMustHaveAName; } $self = clone $this; $self->name = null; return $self; }
php
public function withAutoGeneratedName(): self { if ($this->isPassive()) { throw new PassiveQueueDeclarationMustHaveAName; } $self = clone $this; $self->name = null; return $self; }
[ "public", "function", "withAutoGeneratedName", "(", ")", ":", "self", "{", "if", "(", "$", "this", "->", "isPassive", "(", ")", ")", "{", "throw", "new", "PassiveQueueDeclarationMustHaveAName", ";", "}", "$", "self", "=", "clone", "$", "this", ";", "$", ...
Let the server generate a name for the queue
[ "Let", "the", "server", "generate", "a", "name", "for", "the", "queue" ]
c22b3a8f56162f7845a13c149cb3118e5fe7cffd
https://github.com/Innmind/AMQP/blob/c22b3a8f56162f7845a13c149cb3118e5fe7cffd/src/Model/Queue/Declaration.php#L138-L148
39,508
cmsgears/module-core
common/models/forms/Login.php
Login.validatePassword
public function validatePassword( $attribute, $params ) { if( !$this->hasErrors() ) { $user = $this->getUser(); if( $user && !$user->validatePassword( $this->password ) ) { $this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_LOGIN_FAILED ) ); } } }
php
public function validatePassword( $attribute, $params ) { if( !$this->hasErrors() ) { $user = $this->getUser(); if( $user && !$user->validatePassword( $this->password ) ) { $this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_LOGIN_FAILED ) ); } } }
[ "public", "function", "validatePassword", "(", "$", "attribute", ",", "$", "params", ")", "{", "if", "(", "!", "$", "this", "->", "hasErrors", "(", ")", ")", "{", "$", "user", "=", "$", "this", "->", "getUser", "(", ")", ";", "if", "(", "$", "use...
Check whether the password provided by user is valid. @param string $attribute @param array $params
[ "Check", "whether", "the", "password", "provided", "by", "user", "is", "valid", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/forms/Login.php#L171-L182
39,509
cmsgears/module-core
common/models/forms/Login.php
Login.getUser
public function getUser() { // Find user having email or username if( empty( $this->user ) ) { $this->user = $this->userService->getByEmail( $this->email ); if( empty( $this->user ) ) { $this->user = $this->userService->getByUsername( $this->email ); } } return $this->user; }
php
public function getUser() { // Find user having email or username if( empty( $this->user ) ) { $this->user = $this->userService->getByEmail( $this->email ); if( empty( $this->user ) ) { $this->user = $this->userService->getByUsername( $this->email ); } } return $this->user; }
[ "public", "function", "getUser", "(", ")", "{", "// Find user having email or username", "if", "(", "empty", "(", "$", "this", "->", "user", ")", ")", "{", "$", "this", "->", "user", "=", "$", "this", "->", "userService", "->", "getByEmail", "(", "$", "t...
Find and return the user using given email or username. @return \cmsgears\core\common\models\entities\User
[ "Find", "and", "return", "the", "user", "using", "given", "email", "or", "username", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/forms/Login.php#L191-L205
39,510
cmsgears/module-core
common/models/forms/Login.php
Login.login
public function login() { if ( $this->validate() ) { $user = $this->getUser(); if( $this->admin ) { $user->loadPermissions(); if( !$user->isPermitted( CoreGlobal::PERM_ADMIN ) ) { $this->addError( "email", Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_ALLOWED ) ); return false; } } $user->lastLoginAt = DateUtil::getDateTime(); $user->save(); return Yii::$app->user->login( $user, $this->rememberMe ? $this->interval : 0 ); } return false; }
php
public function login() { if ( $this->validate() ) { $user = $this->getUser(); if( $this->admin ) { $user->loadPermissions(); if( !$user->isPermitted( CoreGlobal::PERM_ADMIN ) ) { $this->addError( "email", Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_ALLOWED ) ); return false; } } $user->lastLoginAt = DateUtil::getDateTime(); $user->save(); return Yii::$app->user->login( $user, $this->rememberMe ? $this->interval : 0 ); } return false; }
[ "public", "function", "login", "(", ")", "{", "if", "(", "$", "this", "->", "validate", "(", ")", ")", "{", "$", "user", "=", "$", "this", "->", "getUser", "(", ")", ";", "if", "(", "$", "this", "->", "admin", ")", "{", "$", "user", "->", "lo...
Login and remember the user for pre-defined interval. @return boolean
[ "Login", "and", "remember", "the", "user", "for", "pre", "-", "defined", "interval", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/forms/Login.php#L212-L238
39,511
spiral/exceptions
src/Style/HtmlStyle.php
HtmlStyle.getStyle
private function getStyle(array $token, array $previous): string { if (!empty($previous)) { foreach ($this->style as $style => $tokens) { if (in_array($previous[1] . $token[0], $tokens)) { return $style; } } } foreach ($this->style as $style => $tokens) { if (in_array($token[0], $tokens)) { return $style; } } return ''; }
php
private function getStyle(array $token, array $previous): string { if (!empty($previous)) { foreach ($this->style as $style => $tokens) { if (in_array($previous[1] . $token[0], $tokens)) { return $style; } } } foreach ($this->style as $style => $tokens) { if (in_array($token[0], $tokens)) { return $style; } } return ''; }
[ "private", "function", "getStyle", "(", "array", "$", "token", ",", "array", "$", "previous", ")", ":", "string", "{", "if", "(", "!", "empty", "(", "$", "previous", ")", ")", "{", "foreach", "(", "$", "this", "->", "style", "as", "$", "style", "=>...
Get styles for a given token. @param array $token @param array $previous @return string
[ "Get", "styles", "for", "a", "given", "token", "." ]
9735a00b189ce61317cd49a9d6ec630f68cee381
https://github.com/spiral/exceptions/blob/9735a00b189ce61317cd49a9d6ec630f68cee381/src/Style/HtmlStyle.php#L214-L231
39,512
hiqdev/yii2-hiam-authclient
src/Collection.php
Collection.getClient
public function getClient($id = null) { if ($id === null) { $id = array_keys($this->getClients())[0]; } return parent::getClient($id); }
php
public function getClient($id = null) { if ($id === null) { $id = array_keys($this->getClients())[0]; } return parent::getClient($id); }
[ "public", "function", "getClient", "(", "$", "id", "=", "null", ")", "{", "if", "(", "$", "id", "===", "null", ")", "{", "$", "id", "=", "array_keys", "(", "$", "this", "->", "getClients", "(", ")", ")", "[", "0", "]", ";", "}", "return", "pare...
Gets first client by default.
[ "Gets", "first", "client", "by", "default", "." ]
c0ef62196a1fde499cfa4d85e76e04dc26e41559
https://github.com/hiqdev/yii2-hiam-authclient/blob/c0ef62196a1fde499cfa4d85e76e04dc26e41559/src/Collection.php#L19-L26
39,513
mcaskill/charcoal-support
src/Cms/Metatag/DocumentTrait.php
DocumentTrait.parseDocumentTitle
protected function parseDocumentTitle(array $parts) { $parts = $this->parseDocumentTitleParts($parts); $delim = $this->parseDocumentTitleSeparator(); $title = implode($delim, $parts); return $title; }
php
protected function parseDocumentTitle(array $parts) { $parts = $this->parseDocumentTitleParts($parts); $delim = $this->parseDocumentTitleSeparator(); $title = implode($delim, $parts); return $title; }
[ "protected", "function", "parseDocumentTitle", "(", "array", "$", "parts", ")", "{", "$", "parts", "=", "$", "this", "->", "parseDocumentTitleParts", "(", "$", "parts", ")", ";", "$", "delim", "=", "$", "this", "->", "parseDocumentTitleSeparator", "(", ")", ...
Parse the document title. @param array $parts The document title parts. @return string The concatenated title.
[ "Parse", "the", "document", "title", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/Metatag/DocumentTrait.php#L56-L63
39,514
mcaskill/charcoal-support
src/Cms/Metatag/DocumentTrait.php
DocumentTrait.parseDocumentTitleParts
protected function parseDocumentTitleParts(array $parts) { $segments = []; foreach ($parts as $key => $value) { $value = $this->parseDocumentTitlePart($value, $key, $parts); if ($value === true) { $value = $parts[$key]; } if (is_bool($value) || (empty($value) && !is_numeric($value))) { continue; } $segments[$key] = (string)$value; } return $segments; }
php
protected function parseDocumentTitleParts(array $parts) { $segments = []; foreach ($parts as $key => $value) { $value = $this->parseDocumentTitlePart($value, $key, $parts); if ($value === true) { $value = $parts[$key]; } if (is_bool($value) || (empty($value) && !is_numeric($value))) { continue; } $segments[$key] = (string)$value; } return $segments; }
[ "protected", "function", "parseDocumentTitleParts", "(", "array", "$", "parts", ")", "{", "$", "segments", "=", "[", "]", ";", "foreach", "(", "$", "parts", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "value", "=", "$", "this", "->", "parseD...
Parse the document title segments. Iterates over each value in $parts passing them to {@see DocumentTrait::filterDocumentTitlePart}. If the method returns TRUE, the current value from $parts is concatenated into the title. @param array $parts The document title parts. @return array The parsed and filtered segments.
[ "Parse", "the", "document", "title", "segments", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/Metatag/DocumentTrait.php#L76-L93
39,515
locomotivemtl/charcoal-property
src/Charcoal/Property/ModelStructureProperty.php
ModelStructureProperty.structureMetadata
public function structureMetadata() { if ($this->structureMetadata === null || $this->isStructureFinalized === false) { $this->structureMetadata = $this->loadStructureMetadata(); } return $this->structureMetadata; }
php
public function structureMetadata() { if ($this->structureMetadata === null || $this->isStructureFinalized === false) { $this->structureMetadata = $this->loadStructureMetadata(); } return $this->structureMetadata; }
[ "public", "function", "structureMetadata", "(", ")", "{", "if", "(", "$", "this", "->", "structureMetadata", "===", "null", "||", "$", "this", "->", "isStructureFinalized", "===", "false", ")", "{", "$", "this", "->", "structureMetadata", "=", "$", "this", ...
Retrieve the property's structure. @return MetadataInterface|null
[ "Retrieve", "the", "property", "s", "structure", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ModelStructureProperty.php#L172-L179
39,516
locomotivemtl/charcoal-property
src/Charcoal/Property/ModelStructureProperty.php
ModelStructureProperty.setStructureMetadata
public function setStructureMetadata($data) { if ($data === null) { $this->structureMetadata = $data; $this->terminalStructureMetadata = $data; } elseif (is_array($data)) { $struct = $this->createStructureMetadata(); $struct->merge($data); $this->structureMetadata = $struct; $this->terminalStructureMetadata = $data; } elseif ($data instanceof MetadataInterface) { $this->structureMetadata = $data; $this->terminalStructureMetadata = $data; } else { throw new InvalidArgumentException(sprintf( 'Structure [%s] is invalid (must be array or an instance of %s).', (is_object($data) ? get_class($data) : gettype($data)), StructureMetadata::class )); } $this->isStructureFinalized = false; return $this; }
php
public function setStructureMetadata($data) { if ($data === null) { $this->structureMetadata = $data; $this->terminalStructureMetadata = $data; } elseif (is_array($data)) { $struct = $this->createStructureMetadata(); $struct->merge($data); $this->structureMetadata = $struct; $this->terminalStructureMetadata = $data; } elseif ($data instanceof MetadataInterface) { $this->structureMetadata = $data; $this->terminalStructureMetadata = $data; } else { throw new InvalidArgumentException(sprintf( 'Structure [%s] is invalid (must be array or an instance of %s).', (is_object($data) ? get_class($data) : gettype($data)), StructureMetadata::class )); } $this->isStructureFinalized = false; return $this; }
[ "public", "function", "setStructureMetadata", "(", "$", "data", ")", "{", "if", "(", "$", "data", "===", "null", ")", "{", "$", "this", "->", "structureMetadata", "=", "$", "data", ";", "$", "this", "->", "terminalStructureMetadata", "=", "$", "data", ";...
Set the property's structure. @param MetadataInterface|array|null $data The property's structure (fields, data). @throws InvalidArgumentException If the structure is invalid. @return self
[ "Set", "the", "property", "s", "structure", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ModelStructureProperty.php#L188-L213
39,517
locomotivemtl/charcoal-property
src/Charcoal/Property/ModelStructureProperty.php
ModelStructureProperty.addStructureInterface
public function addStructureInterface($interface) { if (!is_string($interface)) { throw new InvalidArgumentException(sprintf( 'Structure interface must to be a string, received %s', is_object($interface) ? get_class($interface) : gettype($interface) )); } if (!empty($interface)) { $interface = $this->parseStructureInterface($interface); $this->structureInterfaces[$interface] = true; $this->isStructureFinalized = false; } return $this; }
php
public function addStructureInterface($interface) { if (!is_string($interface)) { throw new InvalidArgumentException(sprintf( 'Structure interface must to be a string, received %s', is_object($interface) ? get_class($interface) : gettype($interface) )); } if (!empty($interface)) { $interface = $this->parseStructureInterface($interface); $this->structureInterfaces[$interface] = true; $this->isStructureFinalized = false; } return $this; }
[ "public", "function", "addStructureInterface", "(", "$", "interface", ")", "{", "if", "(", "!", "is_string", "(", "$", "interface", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Structure interface must to be a string, received %s'"...
Add the given metadata interfaces for the property to use as a structure. @param string $interface A metadata interface to use. @throws InvalidArgumentException If the interface is not a string. @return self
[ "Add", "the", "given", "metadata", "interfaces", "for", "the", "property", "to", "use", "as", "a", "structure", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ModelStructureProperty.php#L266-L283
39,518
locomotivemtl/charcoal-property
src/Charcoal/Property/ModelStructureProperty.php
ModelStructureProperty.loadStructureMetadata
protected function loadStructureMetadata() { $structureMetadata = null; if ($this->isStructureFinalized === false) { $this->isStructureFinalized = true; $structureInterfaces = $this->structureInterfaces(); if (!empty($structureInterfaces)) { $metadataLoader = $this->metadataLoader(); $metadataClass = $this->structureMetadataClass(); $structureKey = $structureInterfaces; array_unshift($structureKey, $this->ident()); $structureKey = 'property/structure='.$metadataLoader->serializeMetaKey($structureKey); $structureMetadata = $metadataLoader->load( $structureKey, $metadataClass, $structureInterfaces ); } } if ($structureMetadata === null) { $structureMetadata = $this->createStructureMetadata(); } if ($this->terminalStructureMetadata) { $structureMetadata->merge($this->terminalStructureMetadata); } return $structureMetadata; }
php
protected function loadStructureMetadata() { $structureMetadata = null; if ($this->isStructureFinalized === false) { $this->isStructureFinalized = true; $structureInterfaces = $this->structureInterfaces(); if (!empty($structureInterfaces)) { $metadataLoader = $this->metadataLoader(); $metadataClass = $this->structureMetadataClass(); $structureKey = $structureInterfaces; array_unshift($structureKey, $this->ident()); $structureKey = 'property/structure='.$metadataLoader->serializeMetaKey($structureKey); $structureMetadata = $metadataLoader->load( $structureKey, $metadataClass, $structureInterfaces ); } } if ($structureMetadata === null) { $structureMetadata = $this->createStructureMetadata(); } if ($this->terminalStructureMetadata) { $structureMetadata->merge($this->terminalStructureMetadata); } return $structureMetadata; }
[ "protected", "function", "loadStructureMetadata", "(", ")", "{", "$", "structureMetadata", "=", "null", ";", "if", "(", "$", "this", "->", "isStructureFinalized", "===", "false", ")", "{", "$", "this", "->", "isStructureFinalized", "=", "true", ";", "$", "st...
Load the property's structure. @return MetadataInterface
[ "Load", "the", "property", "s", "structure", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ModelStructureProperty.php#L290-L323
39,519
locomotivemtl/charcoal-property
src/Charcoal/Property/ModelStructureProperty.php
ModelStructureProperty.structureProto
public function structureProto() { if ($this->structurePrototype === null) { $model = $this->createStructureModel(); if ($model instanceof DescribableInterface) { $model->setMetadata($this->structureMetadata()); } $this->structurePrototype = $model; } return $this->structurePrototype; }
php
public function structureProto() { if ($this->structurePrototype === null) { $model = $this->createStructureModel(); if ($model instanceof DescribableInterface) { $model->setMetadata($this->structureMetadata()); } $this->structurePrototype = $model; } return $this->structurePrototype; }
[ "public", "function", "structureProto", "(", ")", "{", "if", "(", "$", "this", "->", "structurePrototype", "===", "null", ")", "{", "$", "model", "=", "$", "this", "->", "createStructureModel", "(", ")", ";", "if", "(", "$", "model", "instanceof", "Descr...
Retrieve a singleton of the structure model for prototyping. @return ArrayAccess|DescribableInterface
[ "Retrieve", "a", "singleton", "of", "the", "structure", "model", "for", "prototyping", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ModelStructureProperty.php#L331-L344
39,520
locomotivemtl/charcoal-property
src/Charcoal/Property/ModelStructureProperty.php
ModelStructureProperty.structureVal
public function structureVal($val, $options = []) { if ($val === null) { return ($this->multiple() ? [] : null); } $metadata = clone $this->structureMetadata(); if ($options instanceof MetadataInterface) { $metadata->merge($options); } elseif ($options === null) { $options = []; } elseif (is_array($options)) { if (isset($options['metadata'])) { $metadata->merge($options['metadata']); } } else { throw new InvalidArgumentException(sprintf( 'Structure value options must to be an array or an instance of %2$s, received %1$s', is_object($options) ? get_class($options) : gettype($options), StructureMetadata::class )); } $defaultData = []; if (isset($options['default_data'])) { if (is_bool($options['default_data'])) { $withDefaultData = $options['default_data']; if ($withDefaultData) { $defaultData = $metadata->defaultData(); } } elseif (is_array($options['default_data'])) { $withDefaultData = true; $defaultData = $options['default_data']; } } $val = $this->parseVal($val); if ($this->multiple()) { $entries = []; foreach ($val as $v) { $entries[] = $this->createStructureModelWith($metadata, $defaultData, $v); } return $entries; } else { return $this->createStructureModelWith($metadata, $defaultData, $val); } }
php
public function structureVal($val, $options = []) { if ($val === null) { return ($this->multiple() ? [] : null); } $metadata = clone $this->structureMetadata(); if ($options instanceof MetadataInterface) { $metadata->merge($options); } elseif ($options === null) { $options = []; } elseif (is_array($options)) { if (isset($options['metadata'])) { $metadata->merge($options['metadata']); } } else { throw new InvalidArgumentException(sprintf( 'Structure value options must to be an array or an instance of %2$s, received %1$s', is_object($options) ? get_class($options) : gettype($options), StructureMetadata::class )); } $defaultData = []; if (isset($options['default_data'])) { if (is_bool($options['default_data'])) { $withDefaultData = $options['default_data']; if ($withDefaultData) { $defaultData = $metadata->defaultData(); } } elseif (is_array($options['default_data'])) { $withDefaultData = true; $defaultData = $options['default_data']; } } $val = $this->parseVal($val); if ($this->multiple()) { $entries = []; foreach ($val as $v) { $entries[] = $this->createStructureModelWith($metadata, $defaultData, $v); } return $entries; } else { return $this->createStructureModelWith($metadata, $defaultData, $val); } }
[ "public", "function", "structureVal", "(", "$", "val", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "val", "===", "null", ")", "{", "return", "(", "$", "this", "->", "multiple", "(", ")", "?", "[", "]", ":", "null", ")", ";", ...
Convert the given value into a structure. Options: - `default_data` (_boolean_|_array_) — If TRUE, the default data defined in the structure's metadata is merged. If an array, that is merged. @param mixed $val The value to "structurize". @param array|MetadataInterface $options Optional structure options. @throws InvalidArgumentException If the options are invalid. @return ModelInterface|ModelInterface[]
[ "Convert", "the", "given", "value", "into", "a", "structure", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ModelStructureProperty.php#L388-L437
39,521
locomotivemtl/charcoal-property
src/Charcoal/Property/ModelStructureProperty.php
ModelStructureProperty.structureModelFactory
protected function structureModelFactory() { if (!isset($this->structureModelFactory)) { throw new RuntimeException(sprintf( 'Model Factory is not defined for "%s"', get_class($this) )); } return $this->structureModelFactory; }
php
protected function structureModelFactory() { if (!isset($this->structureModelFactory)) { throw new RuntimeException(sprintf( 'Model Factory is not defined for "%s"', get_class($this) )); } return $this->structureModelFactory; }
[ "protected", "function", "structureModelFactory", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "structureModelFactory", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Model Factory is not defined for \"%s\"'", ",", "ge...
Retrieve the structure model factory. @throws RuntimeException If the model factory was not previously set. @return FactoryInterface
[ "Retrieve", "the", "structure", "model", "factory", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ModelStructureProperty.php#L527-L537
39,522
locomotivemtl/charcoal-property
src/Charcoal/Property/IdProperty.php
IdProperty.setMode
public function setMode($mode) { $availableModes = $this->availableModes(); if (!in_array($mode, $availableModes)) { throw new InvalidArgumentException(sprintf( 'Invalid ID mode. Must be one of "%s"', implode(', ', $availableModes) )); } $this->mode = $mode; return $this; }
php
public function setMode($mode) { $availableModes = $this->availableModes(); if (!in_array($mode, $availableModes)) { throw new InvalidArgumentException(sprintf( 'Invalid ID mode. Must be one of "%s"', implode(', ', $availableModes) )); } $this->mode = $mode; return $this; }
[ "public", "function", "setMode", "(", "$", "mode", ")", "{", "$", "availableModes", "=", "$", "this", "->", "availableModes", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "mode", ",", "$", "availableModes", ")", ")", "{", "throw", "new", "Inv...
Set the allowed ID mode. @param string $mode The ID mode ("auto-increment", "custom", "uniqid" or "uuid"). @throws InvalidArgumentException If the mode is not one of the 4 valid modes. @return self
[ "Set", "the", "allowed", "ID", "mode", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/IdProperty.php#L134-L147
39,523
locomotivemtl/charcoal-property
src/Charcoal/Property/IdProperty.php
IdProperty.autoGenerate
public function autoGenerate() { $mode = $this->mode(); if ($mode === self::MODE_UNIQID) { return uniqid(); } elseif ($mode === self::MODE_UUID) { return $this->generateUuid(); } return null; }
php
public function autoGenerate() { $mode = $this->mode(); if ($mode === self::MODE_UNIQID) { return uniqid(); } elseif ($mode === self::MODE_UUID) { return $this->generateUuid(); } return null; }
[ "public", "function", "autoGenerate", "(", ")", "{", "$", "mode", "=", "$", "this", "->", "mode", "(", ")", ";", "if", "(", "$", "mode", "===", "self", "::", "MODE_UNIQID", ")", "{", "return", "uniqid", "(", ")", ";", "}", "elseif", "(", "$", "mo...
Auto-generate a value upon first save. - self::MODE_AUTOINCREMENT - null: The auto-generated value should be handled at the database driver level. - self::MODE_CUSTOM - null: Custom mode must be defined elsewhere. - self::MODE_UNIQID - A random 13-char `uniqid()` value. - self::MODE_UUID - A random RFC-4122 UUID value. @throws DomainException If the mode does not have a value generator. @return string|null
[ "Auto", "-", "generate", "a", "value", "upon", "first", "save", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/IdProperty.php#L191-L202
39,524
locomotivemtl/charcoal-property
src/Charcoal/Property/IdProperty.php
IdProperty.sqlPdoType
public function sqlPdoType() { $mode = $this->mode(); if ($mode === self::MODE_AUTO_INCREMENT) { return PDO::PARAM_INT; } else { return PDO::PARAM_STR; } }
php
public function sqlPdoType() { $mode = $this->mode(); if ($mode === self::MODE_AUTO_INCREMENT) { return PDO::PARAM_INT; } else { return PDO::PARAM_STR; } }
[ "public", "function", "sqlPdoType", "(", ")", "{", "$", "mode", "=", "$", "this", "->", "mode", "(", ")", ";", "if", "(", "$", "mode", "===", "self", "::", "MODE_AUTO_INCREMENT", ")", "{", "return", "PDO", "::", "PARAM_INT", ";", "}", "else", "{", ...
Get the PDO data type. @see StorablePropertyTrait::sqlPdoType() @return integer
[ "Get", "the", "PDO", "data", "type", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/IdProperty.php#L287-L296
39,525
nails/module-email
src/Service/Emailer.php
Emailer.discoverTypes
public static function discoverTypes(array &$aArray): void { $aLocations = [ NAILS_COMMON_PATH . 'config/email_types.php', ]; foreach (Components::modules() as $oModule) { $aLocations[] = $oModule->path . $oModule->moduleName . '/config/email_types.php'; } $aLocations[] = NAILS_APP_PATH . 'application/config/email_types.php'; foreach ($aLocations as $sPath) { static::loadTypes($sPath, $aArray); } }
php
public static function discoverTypes(array &$aArray): void { $aLocations = [ NAILS_COMMON_PATH . 'config/email_types.php', ]; foreach (Components::modules() as $oModule) { $aLocations[] = $oModule->path . $oModule->moduleName . '/config/email_types.php'; } $aLocations[] = NAILS_APP_PATH . 'application/config/email_types.php'; foreach ($aLocations as $sPath) { static::loadTypes($sPath, $aArray); } }
[ "public", "static", "function", "discoverTypes", "(", "array", "&", "$", "aArray", ")", ":", "void", "{", "$", "aLocations", "=", "[", "NAILS_COMMON_PATH", ".", "'config/email_types.php'", ",", "]", ";", "foreach", "(", "Components", "::", "modules", "(", ")...
Auto-discover all emails supplied by modules and the app @param array $aArray The array to populate with discoveries
[ "Auto", "-", "discover", "all", "emails", "supplied", "by", "modules", "and", "the", "app" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L96-L111
39,526
nails/module-email
src/Service/Emailer.php
Emailer.addType
protected static function addType(\stdClass $oData, array &$aArray): bool { if (!empty($oData->slug) && !empty($oData->template_body)) { $aArray[$oData->slug] = (object) [ 'slug' => $oData->slug, 'name' => $oData->name, 'description' => $oData->description, 'isUnsubscribable' => property_exists($oData, 'isUnsubscribable') ? (bool) $oData->isUnsubscribable : true, 'template_header' => empty($oData->template_header) ? 'email/structure/header' : $oData->template_header, 'template_body' => $oData->template_body, 'template_footer' => empty($oData->template_footer) ? 'email/structure/footer' : $oData->template_footer, 'default_subject' => $oData->default_subject, ]; return true; } return false; }
php
protected static function addType(\stdClass $oData, array &$aArray): bool { if (!empty($oData->slug) && !empty($oData->template_body)) { $aArray[$oData->slug] = (object) [ 'slug' => $oData->slug, 'name' => $oData->name, 'description' => $oData->description, 'isUnsubscribable' => property_exists($oData, 'isUnsubscribable') ? (bool) $oData->isUnsubscribable : true, 'template_header' => empty($oData->template_header) ? 'email/structure/header' : $oData->template_header, 'template_body' => $oData->template_body, 'template_footer' => empty($oData->template_footer) ? 'email/structure/footer' : $oData->template_footer, 'default_subject' => $oData->default_subject, ]; return true; } return false; }
[ "protected", "static", "function", "addType", "(", "\\", "stdClass", "$", "oData", ",", "array", "&", "$", "aArray", ")", ":", "bool", "{", "if", "(", "!", "empty", "(", "$", "oData", "->", "slug", ")", "&&", "!", "empty", "(", "$", "oData", "->", ...
Adds a new email type to the stack @param \stdClass $oData An object representing the email type @param array $aArray The array to populate @return boolean
[ "Adds", "a", "new", "email", "type", "to", "the", "stack" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L158-L177
39,527
nails/module-email
src/Service/Emailer.php
Emailer.resend
public function resend($mEmailIdRef) { if (is_numeric($mEmailIdRef)) { $oEmail = $this->getById($mEmailIdRef); } else { $oEmail = $this->getByRef($mEmailIdRef); } if (empty($oEmail)) { $this->setError('"' . $mEmailIdRef . '" is not a valid Email ID or reference.'); return false; } return $this->doSend($oEmail); }
php
public function resend($mEmailIdRef) { if (is_numeric($mEmailIdRef)) { $oEmail = $this->getById($mEmailIdRef); } else { $oEmail = $this->getByRef($mEmailIdRef); } if (empty($oEmail)) { $this->setError('"' . $mEmailIdRef . '" is not a valid Email ID or reference.'); return false; } return $this->doSend($oEmail); }
[ "public", "function", "resend", "(", "$", "mEmailIdRef", ")", "{", "if", "(", "is_numeric", "(", "$", "mEmailIdRef", ")", ")", "{", "$", "oEmail", "=", "$", "this", "->", "getById", "(", "$", "mEmailIdRef", ")", ";", "}", "else", "{", "$", "oEmail", ...
Sends an email again @todo This should probably create a new row @param mixed $mEmailIdRef The email's ID or ref @return boolean @throws EmailerException
[ "Sends", "an", "email", "again" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L372-L386
39,528
nails/module-email
src/Service/Emailer.php
Emailer.userHasUnsubscribed
public function userHasUnsubscribed($iUSerId, $sType) { $oDb = Factory::service('Database'); $oDb->where('user_id', $iUSerId); $oDb->where('type', $sType); return (bool) $oDb->count_all_results(NAILS_DB_PREFIX . 'user_email_blocker'); }
php
public function userHasUnsubscribed($iUSerId, $sType) { $oDb = Factory::service('Database'); $oDb->where('user_id', $iUSerId); $oDb->where('type', $sType); return (bool) $oDb->count_all_results(NAILS_DB_PREFIX . 'user_email_blocker'); }
[ "public", "function", "userHasUnsubscribed", "(", "$", "iUSerId", ",", "$", "sType", ")", "{", "$", "oDb", "=", "Factory", "::", "service", "(", "'Database'", ")", ";", "$", "oDb", "->", "where", "(", "'user_id'", ",", "$", "iUSerId", ")", ";", "$", ...
Determines whether the user has unsubscribed from this email type @param int $iUSerId The user ID to check for @param string $sType The type of email to check against @return boolean @throws \Nails\Common\Exception\FactoryException
[ "Determines", "whether", "the", "user", "has", "unsubscribed", "from", "this", "email", "type" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L399-L405
39,529
nails/module-email
src/Service/Emailer.php
Emailer.userIsSuspended
public function userIsSuspended($iUserId) { $oDb = Factory::service('Database'); $oDb->where('id', $iUserId); $oDb->where('is_suspended', true); return (bool) $oDb->count_all_results(NAILS_DB_PREFIX . 'user'); }
php
public function userIsSuspended($iUserId) { $oDb = Factory::service('Database'); $oDb->where('id', $iUserId); $oDb->where('is_suspended', true); return (bool) $oDb->count_all_results(NAILS_DB_PREFIX . 'user'); }
[ "public", "function", "userIsSuspended", "(", "$", "iUserId", ")", "{", "$", "oDb", "=", "Factory", "::", "service", "(", "'Database'", ")", ";", "$", "oDb", "->", "where", "(", "'id'", ",", "$", "iUserId", ")", ";", "$", "oDb", "->", "where", "(", ...
Determiens whether a suer is suspended @param integer $iUserId The user ID to check @return bool @throws \Nails\Common\Exception\FactoryException
[ "Determiens", "whether", "a", "suer", "is", "suspended" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L417-L423
39,530
nails/module-email
src/Service/Emailer.php
Emailer.unsubscribeUser
public function unsubscribeUser($user_id, $type) { if ($this->userHasUnsubscribed($user_id, $type)) { return true; } // -------------------------------------------------------------------------- $oDb = Factory::service('Database'); $oDb->set('user_id', $user_id); $oDb->set('type', $type); $oDb->set('created', 'NOW()', false); $oDb->insert(NAILS_DB_PREFIX . 'user_email_blocker'); return (bool) $oDb->affected_rows(); }
php
public function unsubscribeUser($user_id, $type) { if ($this->userHasUnsubscribed($user_id, $type)) { return true; } // -------------------------------------------------------------------------- $oDb = Factory::service('Database'); $oDb->set('user_id', $user_id); $oDb->set('type', $type); $oDb->set('created', 'NOW()', false); $oDb->insert(NAILS_DB_PREFIX . 'user_email_blocker'); return (bool) $oDb->affected_rows(); }
[ "public", "function", "unsubscribeUser", "(", "$", "user_id", ",", "$", "type", ")", "{", "if", "(", "$", "this", "->", "userHasUnsubscribed", "(", "$", "user_id", ",", "$", "type", ")", ")", "{", "return", "true", ";", "}", "// ---------------------------...
Unsubscribes a user from a particular email type @param int $user_id The user ID to unsubscribe @param string $type The type of email to unsubscribe from @return boolean @throws \Nails\Common\Exception\FactoryException
[ "Unsubscribes", "a", "user", "from", "a", "particular", "email", "type" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L436-L451
39,531
nails/module-email
src/Service/Emailer.php
Emailer.subscribeUser
public function subscribeUser($user_id, $type) { if (!$this->userHasUnsubscribed($user_id, $type)) { return true; } // -------------------------------------------------------------------------- $oDb = Factory::service('Database'); $oDb->where('user_id', $user_id); $oDb->where('type', $type); $oDb->delete(NAILS_DB_PREFIX . 'user_email_blocker'); return (bool) $oDb->affected_rows(); }
php
public function subscribeUser($user_id, $type) { if (!$this->userHasUnsubscribed($user_id, $type)) { return true; } // -------------------------------------------------------------------------- $oDb = Factory::service('Database'); $oDb->where('user_id', $user_id); $oDb->where('type', $type); $oDb->delete(NAILS_DB_PREFIX . 'user_email_blocker'); return (bool) $oDb->affected_rows(); }
[ "public", "function", "subscribeUser", "(", "$", "user_id", ",", "$", "type", ")", "{", "if", "(", "!", "$", "this", "->", "userHasUnsubscribed", "(", "$", "user_id", ",", "$", "type", ")", ")", "{", "return", "true", ";", "}", "// ----------------------...
Subscribe a user to a particular email type @param int $user_id The user ID to subscribe @param string $type The type of email to subscribe to @return boolean @throws \Nails\Common\Exception\FactoryException
[ "Subscribe", "a", "user", "to", "a", "particular", "email", "type" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L464-L478
39,532
nails/module-email
src/Service/Emailer.php
Emailer.getAllRawQuery
public function getAllRawQuery($page = null, $perPage = null, $data = []) { $oDb = Factory::service('Database'); $oDb->select('ea.id,ea.ref,ea.type,ea.email_vars,ea.user_email sent_to,ue.is_verified email_verified'); $oDb->select('ue.code email_verified_code,ea.sent,ea.status,ea.read_count,ea.link_click_count'); $oDb->select('u.first_name,u.last_name,u.id user_id,u.password user_password,u.group_id user_group'); $oDb->select('u.profile_img,u.gender,u.username'); // Apply common items; pass $data $this->getCountCommonEmail($data); // -------------------------------------------------------------------------- // Facilitate pagination if (!is_null($page)) { /** * Adjust the page variable, reduce by one so that the offset is calculated * correctly. Make sure we don't go into negative numbers */ $page--; $page = $page < 0 ? 0 : $page; // Work out what the offset should be $perPage = is_null($perPage) ? 50 : (int) $perPage; $offset = $page * $perPage; $oDb->limit($perPage, $offset); } return $oDb->get($this->sTable . ' ' . $this->sTableAlias); }
php
public function getAllRawQuery($page = null, $perPage = null, $data = []) { $oDb = Factory::service('Database'); $oDb->select('ea.id,ea.ref,ea.type,ea.email_vars,ea.user_email sent_to,ue.is_verified email_verified'); $oDb->select('ue.code email_verified_code,ea.sent,ea.status,ea.read_count,ea.link_click_count'); $oDb->select('u.first_name,u.last_name,u.id user_id,u.password user_password,u.group_id user_group'); $oDb->select('u.profile_img,u.gender,u.username'); // Apply common items; pass $data $this->getCountCommonEmail($data); // -------------------------------------------------------------------------- // Facilitate pagination if (!is_null($page)) { /** * Adjust the page variable, reduce by one so that the offset is calculated * correctly. Make sure we don't go into negative numbers */ $page--; $page = $page < 0 ? 0 : $page; // Work out what the offset should be $perPage = is_null($perPage) ? 50 : (int) $perPage; $offset = $page * $perPage; $oDb->limit($perPage, $offset); } return $oDb->get($this->sTable . ' ' . $this->sTableAlias); }
[ "public", "function", "getAllRawQuery", "(", "$", "page", "=", "null", ",", "$", "perPage", "=", "null", ",", "$", "data", "=", "[", "]", ")", "{", "$", "oDb", "=", "Factory", "::", "service", "(", "'Database'", ")", ";", "$", "oDb", "->", "select"...
Returns emails from the archive @param integer $page The page of results to retrieve @param integer $perPage The number of results per page @param array $data Data to pass to getCountCommonEmail() @return object @throws \Nails\Common\Exception\FactoryException
[ "Returns", "emails", "from", "the", "archive" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L720-L752
39,533
nails/module-email
src/Service/Emailer.php
Emailer.getAll
public function getAll($iPage = null, $iPerPage = null, $aData = []) { $oResults = $this->getAllRawQuery($iPage, $iPerPage, $aData); $aResults = $oResults->result(); $numResults = count($aResults); for ($i = 0; $i < $numResults; $i++) { $this->formatObject($aResults[$i]); } return $aResults; }
php
public function getAll($iPage = null, $iPerPage = null, $aData = []) { $oResults = $this->getAllRawQuery($iPage, $iPerPage, $aData); $aResults = $oResults->result(); $numResults = count($aResults); for ($i = 0; $i < $numResults; $i++) { $this->formatObject($aResults[$i]); } return $aResults; }
[ "public", "function", "getAll", "(", "$", "iPage", "=", "null", ",", "$", "iPerPage", "=", "null", ",", "$", "aData", "=", "[", "]", ")", "{", "$", "oResults", "=", "$", "this", "->", "getAllRawQuery", "(", "$", "iPage", ",", "$", "iPerPage", ",", ...
Fetches all emails from the archive and formats them, optionally paginated @param int $iPage The page number of the results, if null then no pagination @param int $iPerPage How many items per page of paginated results @param mixed $aData Any data to pass to getCountCommon() @return array @throws \Nails\Common\Exception\FactoryException
[ "Fetches", "all", "emails", "from", "the", "archive", "and", "formats", "them", "optionally", "paginated" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L766-L777
39,534
nails/module-email
src/Service/Emailer.php
Emailer.countAll
public function countAll($data) { $this->getCountCommonEmail($data); $oDb = Factory::service('Database'); return $oDb->count_all_results($this->sTable . ' ' . $this->sTableAlias); }
php
public function countAll($data) { $this->getCountCommonEmail($data); $oDb = Factory::service('Database'); return $oDb->count_all_results($this->sTable . ' ' . $this->sTableAlias); }
[ "public", "function", "countAll", "(", "$", "data", ")", "{", "$", "this", "->", "getCountCommonEmail", "(", "$", "data", ")", ";", "$", "oDb", "=", "Factory", "::", "service", "(", "'Database'", ")", ";", "return", "$", "oDb", "->", "count_all_results",...
Count the number of records in the archive @param array $data Data passed from the calling method @return mixed @throws \Nails\Common\Exception\FactoryException
[ "Count", "the", "number", "of", "records", "in", "the", "archive" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L856-L861
39,535
nails/module-email
src/Service/Emailer.php
Emailer.getById
public function getById($iId, $aData = []) { if (empty($aData['where'])) { $aData['where'] = []; } $aData['where'][] = [$this->sTableAlias . '.id', $iId]; $aEmails = $this->getAll(null, null, $aData); return !empty($aEmails) ? reset($aEmails) : false; }
php
public function getById($iId, $aData = []) { if (empty($aData['where'])) { $aData['where'] = []; } $aData['where'][] = [$this->sTableAlias . '.id', $iId]; $aEmails = $this->getAll(null, null, $aData); return !empty($aEmails) ? reset($aEmails) : false; }
[ "public", "function", "getById", "(", "$", "iId", ",", "$", "aData", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "aData", "[", "'where'", "]", ")", ")", "{", "$", "aData", "[", "'where'", "]", "=", "[", "]", ";", "}", "$", "aData",...
Get en email from the archive by its ID @param int $iId The email's ID @param array $aData The data array @return mixed stdClass on success, false on failure @throws \Nails\Common\Exception\FactoryException
[ "Get", "en", "email", "from", "the", "archive", "by", "its", "ID" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L874-L885
39,536
nails/module-email
src/Service/Emailer.php
Emailer.getByRef
public function getByRef($sRef, $aData = []) { if (empty($aData['where'])) { $aData['where'] = []; } $aData['where'][] = [$this->sTableAlias . '.ref', $sRef]; $aEmails = $this->getAll(null, null, $aData); return !empty($aEmails) ? reset($aEmails) : false; }
php
public function getByRef($sRef, $aData = []) { if (empty($aData['where'])) { $aData['where'] = []; } $aData['where'][] = [$this->sTableAlias . '.ref', $sRef]; $aEmails = $this->getAll(null, null, $aData); return !empty($aEmails) ? reset($aEmails) : false; }
[ "public", "function", "getByRef", "(", "$", "sRef", ",", "$", "aData", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "aData", "[", "'where'", "]", ")", ")", "{", "$", "aData", "[", "'where'", "]", "=", "[", "]", ";", "}", "$", "aData...
Get an email from the archive by its reference @param string $sRef The email's reference @param array $aData The data array @return mixed stdClass on success, false on failure @throws \Nails\Common\Exception\FactoryException
[ "Get", "an", "email", "from", "the", "archive", "by", "its", "reference" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L898-L909
39,537
nails/module-email
src/Service/Emailer.php
Emailer.validateHash
public function validateHash($sRef, $sGuid, $sHash) { return isAdmin() || $this->generateHash($sRef, $sGuid) === $sHash; }
php
public function validateHash($sRef, $sGuid, $sHash) { return isAdmin() || $this->generateHash($sRef, $sGuid) === $sHash; }
[ "public", "function", "validateHash", "(", "$", "sRef", ",", "$", "sGuid", ",", "$", "sHash", ")", "{", "return", "isAdmin", "(", ")", "||", "$", "this", "->", "generateHash", "(", "$", "sRef", ",", "$", "sGuid", ")", "===", "$", "sHash", ";", "}" ...
Validates an email hash @param string $sRef The email's ref @param string $sGuid The email's guid @param string $sHash The hash to validate @return bool
[ "Validates", "an", "email", "hash" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L922-L925
39,538
nails/module-email
src/Service/Emailer.php
Emailer.generateReference
protected function generateReference($exclude = []) { $oDb = Factory::service('Database'); do { $refOk = false; do { $ref = strtoupper(random_string('alnum', 10)); if (array_search($ref, $exclude) === false) { $refOk = true; } } while (!$refOk); $oDb->where('ref', $ref); $result = $oDb->get($this->sTable); } while ($result->num_rows()); return $ref; }
php
protected function generateReference($exclude = []) { $oDb = Factory::service('Database'); do { $refOk = false; do { $ref = strtoupper(random_string('alnum', 10)); if (array_search($ref, $exclude) === false) { $refOk = true; } } while (!$refOk); $oDb->where('ref', $ref); $result = $oDb->get($this->sTable); } while ($result->num_rows()); return $ref; }
[ "protected", "function", "generateReference", "(", "$", "exclude", "=", "[", "]", ")", "{", "$", "oDb", "=", "Factory", "::", "service", "(", "'Database'", ")", ";", "do", "{", "$", "refOk", "=", "false", ";", "do", "{", "$", "ref", "=", "strtoupper"...
Generates a unique reference for an email, optionally exclude strings @param array $exclude Strings to exclude from the reference @return string @throws \Nails\Common\Exception\FactoryException
[ "Generates", "a", "unique", "reference", "for", "an", "email", "optionally", "exclude", "strings" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L971-L994
39,539
nails/module-email
src/Service/Emailer.php
Emailer.printDebugger
protected function printDebugger($input, $body, $plaintext, $recent_errors) { /** * Debug mode, output data and don't actually send * Remove the reference to CI; takes up a ton'na space */ if (isset($input->data['ci'])) { $input->data['ci'] = '**REFERENCE TO CODEIGNITER INSTANCE**'; } // -------------------------------------------------------------------------- // Input variables echo '<pre>'; // Who's the email going to? echo '<strong>Sending to:</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; echo 'email: ' . $input->to->email . "\n"; echo 'first: ' . $input->to->first . "\n"; echo 'last: ' . $input->to->last . "\n"; // Who's the email being sent from? echo "\n\n" . '<strong>Sending from:</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; echo 'name: ' . $input->from->name . "\n"; echo 'email: ' . $input->from->email . "\n"; // Input data (system & supplied) echo "\n\n" . '<strong>Input variables (supplied + system):</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; print_r($input->data); // Template echo "\n\n" . '<strong>Email body:</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; echo 'Subject: ' . $input->subject . "\n"; echo 'Template Header: ' . $input->template_header . "\n"; echo 'Template Body: ' . $input->template_body . "\n"; echo 'Template Footer: ' . $input->template_footer . "\n"; if ($recent_errors) { echo "\n\n" . '<strong>Template Errors (' . count($recent_errors) . '):</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; foreach ($recent_errors as $error) { echo 'Severity: ' . $error->severity . "\n"; echo 'Mesage: ' . $error->message . "\n"; echo 'Filepath: ' . $error->filepath . "\n"; echo 'Line: ' . $error->line . "\n\n"; } } echo "\n\n" . '<strong>Rendered HTML:</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; $_rendered_body = str_replace('"', '\\"', $body); $_rendered_body = str_replace(["\r\n", "\r"], "\n", $_rendered_body); $_lines = explode("\n", $_rendered_body); $_new_lines = []; foreach ($_lines as $line) { if (!empty($line)) { $_new_lines[] = $line; } } $renderedBody = implode($_new_lines); $entityBody = htmlentities($body); $plaintextBody = nl2br($plaintext); $str = <<<EOT <iframe width="100%" height="900" src="" id="renderframe"></iframe> <script type="text/javascript"> var emailBody = "$renderedBody"; document.getElementById('renderframe').src = "data:text/html;charset=utf-8," + escape(emailBody); </script> <strong>HTML:</strong> ----------------------------------------------------------------- $entityBody <strong>Plain Text:</strong> ----------------------------------------------------------------- </pre>$plaintextBody</pre> EOT; }
php
protected function printDebugger($input, $body, $plaintext, $recent_errors) { /** * Debug mode, output data and don't actually send * Remove the reference to CI; takes up a ton'na space */ if (isset($input->data['ci'])) { $input->data['ci'] = '**REFERENCE TO CODEIGNITER INSTANCE**'; } // -------------------------------------------------------------------------- // Input variables echo '<pre>'; // Who's the email going to? echo '<strong>Sending to:</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; echo 'email: ' . $input->to->email . "\n"; echo 'first: ' . $input->to->first . "\n"; echo 'last: ' . $input->to->last . "\n"; // Who's the email being sent from? echo "\n\n" . '<strong>Sending from:</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; echo 'name: ' . $input->from->name . "\n"; echo 'email: ' . $input->from->email . "\n"; // Input data (system & supplied) echo "\n\n" . '<strong>Input variables (supplied + system):</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; print_r($input->data); // Template echo "\n\n" . '<strong>Email body:</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; echo 'Subject: ' . $input->subject . "\n"; echo 'Template Header: ' . $input->template_header . "\n"; echo 'Template Body: ' . $input->template_body . "\n"; echo 'Template Footer: ' . $input->template_footer . "\n"; if ($recent_errors) { echo "\n\n" . '<strong>Template Errors (' . count($recent_errors) . '):</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; foreach ($recent_errors as $error) { echo 'Severity: ' . $error->severity . "\n"; echo 'Mesage: ' . $error->message . "\n"; echo 'Filepath: ' . $error->filepath . "\n"; echo 'Line: ' . $error->line . "\n\n"; } } echo "\n\n" . '<strong>Rendered HTML:</strong>' . "\n"; echo '-----------------------------------------------------------------' . "\n"; $_rendered_body = str_replace('"', '\\"', $body); $_rendered_body = str_replace(["\r\n", "\r"], "\n", $_rendered_body); $_lines = explode("\n", $_rendered_body); $_new_lines = []; foreach ($_lines as $line) { if (!empty($line)) { $_new_lines[] = $line; } } $renderedBody = implode($_new_lines); $entityBody = htmlentities($body); $plaintextBody = nl2br($plaintext); $str = <<<EOT <iframe width="100%" height="900" src="" id="renderframe"></iframe> <script type="text/javascript"> var emailBody = "$renderedBody"; document.getElementById('renderframe').src = "data:text/html;charset=utf-8," + escape(emailBody); </script> <strong>HTML:</strong> ----------------------------------------------------------------- $entityBody <strong>Plain Text:</strong> ----------------------------------------------------------------- </pre>$plaintextBody</pre> EOT; }
[ "protected", "function", "printDebugger", "(", "$", "input", ",", "$", "body", ",", "$", "plaintext", ",", "$", "recent_errors", ")", "{", "/**\n * Debug mode, output data and don't actually send\n * Remove the reference to CI; takes up a ton'na space\n */",...
Renders the debugger @param \stdClass $input The email input object @param string $body The email's body @param string $plaintext The email's plaintext body @param array $recent_errors An array of any recent errors @return void
[ "Renders", "the", "debugger" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L1008-L1099
39,540
nails/module-email
src/Service/Emailer.php
Emailer.trackOpen
public function trackOpen($ref) { $oEmail = $this->getByRef($ref); if ($oEmail) { // Update the read count and a add a track data point $oDb = Factory::service('Database'); $oDb->set('read_count', 'read_count+1', false); $oDb->where('id', $oEmail->id); $oDb->update($this->sTable); $oDb->set('created', 'NOW()', false); $oDb->set('email_id', $oEmail->id); if (activeUser('id')) { $oDb->set('user_id', activeUser('id')); } $oDb->insert(NAILS_DB_PREFIX . 'email_archive_track_open'); } }
php
public function trackOpen($ref) { $oEmail = $this->getByRef($ref); if ($oEmail) { // Update the read count and a add a track data point $oDb = Factory::service('Database'); $oDb->set('read_count', 'read_count+1', false); $oDb->where('id', $oEmail->id); $oDb->update($this->sTable); $oDb->set('created', 'NOW()', false); $oDb->set('email_id', $oEmail->id); if (activeUser('id')) { $oDb->set('user_id', activeUser('id')); } $oDb->insert(NAILS_DB_PREFIX . 'email_archive_track_open'); } }
[ "public", "function", "trackOpen", "(", "$", "ref", ")", "{", "$", "oEmail", "=", "$", "this", "->", "getByRef", "(", "$", "ref", ")", ";", "if", "(", "$", "oEmail", ")", "{", "// Update the read count and a add a track data point", "$", "oDb", "=", "Fact...
Increments an email's open count and adds a tracking note @param string $ref The email's reference @return void
[ "Increments", "an", "email", "s", "open", "count", "and", "adds", "a", "tracking", "note" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L1110-L1130
39,541
nails/module-email
src/Service/Emailer.php
Emailer.trackLink
public function trackLink($sRef, $iLinkId) { $oEmail = $this->getByRef($sRef); if ($oEmail) { // Get the link which was clicked $oDb = Factory::service('Database'); $oDb->select('id, url'); $oDb->where('email_id', $oEmail->id); $oDb->where('id', $iLinkId); $oLink = $oDb->get(NAILS_DB_PREFIX . 'email_archive_link')->row(); if ($oLink) { // Update the read count and a add a track data point $oDb->set('link_click_count', 'link_click_count+1', false); $oDb->where('id', $oEmail->id); $oDb->update($this->sTable); // Add a link trackback $oDb->set('created', 'NOW()', false); $oDb->set('email_id', $oEmail->id); $oDb->set('link_id', $oLink->id); if (activeUser('id')) { $oDb->set('user_id', activeUser('id')); } $oDb->insert(NAILS_DB_PREFIX . 'email_archive_track_link'); // Return the URL to go to return $oLink->url; } else { return false; } } return false; }
php
public function trackLink($sRef, $iLinkId) { $oEmail = $this->getByRef($sRef); if ($oEmail) { // Get the link which was clicked $oDb = Factory::service('Database'); $oDb->select('id, url'); $oDb->where('email_id', $oEmail->id); $oDb->where('id', $iLinkId); $oLink = $oDb->get(NAILS_DB_PREFIX . 'email_archive_link')->row(); if ($oLink) { // Update the read count and a add a track data point $oDb->set('link_click_count', 'link_click_count+1', false); $oDb->where('id', $oEmail->id); $oDb->update($this->sTable); // Add a link trackback $oDb->set('created', 'NOW()', false); $oDb->set('email_id', $oEmail->id); $oDb->set('link_id', $oLink->id); if (activeUser('id')) { $oDb->set('user_id', activeUser('id')); } $oDb->insert(NAILS_DB_PREFIX . 'email_archive_track_link'); // Return the URL to go to return $oLink->url; } else { return false; } } return false; }
[ "public", "function", "trackLink", "(", "$", "sRef", ",", "$", "iLinkId", ")", "{", "$", "oEmail", "=", "$", "this", "->", "getByRef", "(", "$", "sRef", ")", ";", "if", "(", "$", "oEmail", ")", "{", "// Get the link which was clicked", "$", "oDb", "="...
Increments a link's open count and adds a tracking note @param string $sRef The email's reference @param integer $iLinkId The link's ID @return string @throws \Nails\Common\Exception\FactoryException
[ "Increments", "a", "link", "s", "open", "count", "and", "adds", "a", "tracking", "note" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L1143-L1183
39,542
nails/module-email
src/Service/Emailer.php
Emailer.processLinkGenerate
protected function processLinkGenerate($html, $url, $title, $is_html) { // Ensure URLs have a domain if (preg_match('/^\//', $url)) { $url = $this->getDomain() . $url; } /** * Generate a tracking URL for this link * Firstly, check this URL hasn't been processed already (for this email) */ if (isset($this->aTrackLinkCache[md5($url)])) { $trackingUrl = $this->aTrackLinkCache[md5($url)]; // Replace the URL and return the new tag $html = str_replace($url, $trackingUrl, $html); } else { /** * New URL, needs processed. We take the URL and the Title, store it in the * database and generate the new tracking link (inc. hashes etc). We'll cache * this link so we don't have to process it again. * * If the email we're sending to hasn't been verified yet we should set the * actual URL as the return_to value of the email verifier, that means that * every link in this email behaves as a verifying email. Obviously we shouldn't * do this for the actual email verifier... */ if ($this->mGenerateTrackingNeedsVerified) { // Make sure we're not applying this to an activation URL if (!preg_match('#email/verify/[0-9]*?/(.*?)#', $url)) { $_user_id = $this->mGenerateTrackingNeedsVerified['id']; $_code = $this->mGenerateTrackingNeedsVerified['code']; $_return = urlencode($url); $_url = site_url('email/verify/' . $_user_id . '/' . $_code . '?return_to=' . $_return); } else { $_url = $url; } } else { $_url = $url; } $oDb = Factory::service('Database'); $oDb->set('email_id', $this->iGenerateTrackingEmailId); $oDb->set('url', $_url); $oDb->set('title', $title); $oDb->set('created', 'NOW()', false); $oDb->set('is_html', $is_html); $oDb->insert(NAILS_DB_PREFIX . 'email_archive_link'); $_id = $oDb->insert_id(); if ($_id) { $_time = time(); $trackingUrl = 'email/tracker/link/' . $this->sGenerateTrackingEmailRef . '/' . $_time . '/'; $trackingUrl .= $this->generateHash($this->sGenerateTrackingEmailRef, $_time) . '/' . $_id; $trackingUrl = site_url($trackingUrl); $this->aTrackLinkCache[md5($url)] = $trackingUrl; // -------------------------------------------------------------------------- /** * Replace the URL and return the new tag. $url in quotes so we only replace * hyperlinks and not something else, such as an image's URL */ $html = str_replace('"' . $url . '"', $trackingUrl, $html); } } return $html; }
php
protected function processLinkGenerate($html, $url, $title, $is_html) { // Ensure URLs have a domain if (preg_match('/^\//', $url)) { $url = $this->getDomain() . $url; } /** * Generate a tracking URL for this link * Firstly, check this URL hasn't been processed already (for this email) */ if (isset($this->aTrackLinkCache[md5($url)])) { $trackingUrl = $this->aTrackLinkCache[md5($url)]; // Replace the URL and return the new tag $html = str_replace($url, $trackingUrl, $html); } else { /** * New URL, needs processed. We take the URL and the Title, store it in the * database and generate the new tracking link (inc. hashes etc). We'll cache * this link so we don't have to process it again. * * If the email we're sending to hasn't been verified yet we should set the * actual URL as the return_to value of the email verifier, that means that * every link in this email behaves as a verifying email. Obviously we shouldn't * do this for the actual email verifier... */ if ($this->mGenerateTrackingNeedsVerified) { // Make sure we're not applying this to an activation URL if (!preg_match('#email/verify/[0-9]*?/(.*?)#', $url)) { $_user_id = $this->mGenerateTrackingNeedsVerified['id']; $_code = $this->mGenerateTrackingNeedsVerified['code']; $_return = urlencode($url); $_url = site_url('email/verify/' . $_user_id . '/' . $_code . '?return_to=' . $_return); } else { $_url = $url; } } else { $_url = $url; } $oDb = Factory::service('Database'); $oDb->set('email_id', $this->iGenerateTrackingEmailId); $oDb->set('url', $_url); $oDb->set('title', $title); $oDb->set('created', 'NOW()', false); $oDb->set('is_html', $is_html); $oDb->insert(NAILS_DB_PREFIX . 'email_archive_link'); $_id = $oDb->insert_id(); if ($_id) { $_time = time(); $trackingUrl = 'email/tracker/link/' . $this->sGenerateTrackingEmailRef . '/' . $_time . '/'; $trackingUrl .= $this->generateHash($this->sGenerateTrackingEmailRef, $_time) . '/' . $_id; $trackingUrl = site_url($trackingUrl); $this->aTrackLinkCache[md5($url)] = $trackingUrl; // -------------------------------------------------------------------------- /** * Replace the URL and return the new tag. $url in quotes so we only replace * hyperlinks and not something else, such as an image's URL */ $html = str_replace('"' . $url . '"', $trackingUrl, $html); } } return $html; }
[ "protected", "function", "processLinkGenerate", "(", "$", "html", ",", "$", "url", ",", "$", "title", ",", "$", "is_html", ")", "{", "// Ensure URLs have a domain", "if", "(", "preg_match", "(", "'/^\\//'", ",", "$", "url", ")", ")", "{", "$", "url", "=...
Generate a tracking URL @param string $html The Link HTML @param string $url The Link's URL @param string $title The Link's Title @param boolean $is_html Whether this is HTML or not @return string @throws HostNotKnownException @throws \Nails\Common\Exception\FactoryException
[ "Generate", "a", "tracking", "URL" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L1298-L1380
39,543
nails/module-email
src/Service/Emailer.php
Emailer.getDomain
protected function getDomain() { if (!empty($this->sDomain)) { return $this->sDomain; } elseif (site_url() === '/') { $oInput = Factory::service('Input'); $sHost = $oInput->server('SERVER_NAME'); $sProtocol = $oInput->server('REQUEST_SCHEME') ?: 'http'; if (empty($sHost)) { throw new HostNotKnownException('Failed to resolve host; email links will be incomplete.'); } else { $this->sDomain = $sProtocol . '://' . $sHost . '/'; } } else { $this->sDomain = site_url(); } $this->sDomain = rtrim($this->sDomain, '/'); return $this->sDomain; }
php
protected function getDomain() { if (!empty($this->sDomain)) { return $this->sDomain; } elseif (site_url() === '/') { $oInput = Factory::service('Input'); $sHost = $oInput->server('SERVER_NAME'); $sProtocol = $oInput->server('REQUEST_SCHEME') ?: 'http'; if (empty($sHost)) { throw new HostNotKnownException('Failed to resolve host; email links will be incomplete.'); } else { $this->sDomain = $sProtocol . '://' . $sHost . '/'; } } else { $this->sDomain = site_url(); } $this->sDomain = rtrim($this->sDomain, '/'); return $this->sDomain; }
[ "protected", "function", "getDomain", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "sDomain", ")", ")", "{", "return", "$", "this", "->", "sDomain", ";", "}", "elseif", "(", "site_url", "(", ")", "===", "'/'", ")", "{", "$", "o...
Returns the domain to use for the email @return string @throws HostNotKnownException @throws \Nails\Common\Exception\FactoryException
[ "Returns", "the", "domain", "to", "use", "for", "the", "email" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/src/Service/Emailer.php#L1391-L1410
39,544
byjg/xmlutil
src/XmlUtil.php
XmlUtil.createXmlDocument
public static function createXmlDocument($docOptions = 0) { $xmldoc = new DOMDocument(self::XML_VERSION, self::XML_ENCODING); $xmldoc->preserveWhiteSpace = ($docOptions & XMLUTIL_OPT_DONT_PRESERVE_WHITESPACE) != XMLUTIL_OPT_DONT_PRESERVE_WHITESPACE ; $xmldoc->formatOutput = false; if (($docOptions & XMLUTIL_OPT_FORMAT_OUTPUT) == XMLUTIL_OPT_FORMAT_OUTPUT) { $xmldoc->preserveWhiteSpace = false; $xmldoc->formatOutput = true; } XmlUtil::$xmlNsPrefix[spl_object_hash($xmldoc)] = array(); return $xmldoc; }
php
public static function createXmlDocument($docOptions = 0) { $xmldoc = new DOMDocument(self::XML_VERSION, self::XML_ENCODING); $xmldoc->preserveWhiteSpace = ($docOptions & XMLUTIL_OPT_DONT_PRESERVE_WHITESPACE) != XMLUTIL_OPT_DONT_PRESERVE_WHITESPACE ; $xmldoc->formatOutput = false; if (($docOptions & XMLUTIL_OPT_FORMAT_OUTPUT) == XMLUTIL_OPT_FORMAT_OUTPUT) { $xmldoc->preserveWhiteSpace = false; $xmldoc->formatOutput = true; } XmlUtil::$xmlNsPrefix[spl_object_hash($xmldoc)] = array(); return $xmldoc; }
[ "public", "static", "function", "createXmlDocument", "(", "$", "docOptions", "=", "0", ")", "{", "$", "xmldoc", "=", "new", "DOMDocument", "(", "self", "::", "XML_VERSION", ",", "self", "::", "XML_ENCODING", ")", ";", "$", "xmldoc", "->", "preserveWhiteSpace...
Create an empty XmlDocument object with some default parameters @param int $docOptions @return DOMDocument object
[ "Create", "an", "empty", "XmlDocument", "object", "with", "some", "default", "parameters" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L43-L56
39,545
byjg/xmlutil
src/XmlUtil.php
XmlUtil.createXmlDocumentFromFile
public static function createXmlDocumentFromFile($filename, $docOptions = XMLUTIL_OPT_DONT_FIX_AMPERSAND) { if (!file_exists($filename)) { throw new XmlUtilException("Xml document $filename not found.", 250); } $xml = file_get_contents($filename); $xmldoc = self::createXmlDocumentFromStr($xml, $docOptions); return $xmldoc; }
php
public static function createXmlDocumentFromFile($filename, $docOptions = XMLUTIL_OPT_DONT_FIX_AMPERSAND) { if (!file_exists($filename)) { throw new XmlUtilException("Xml document $filename not found.", 250); } $xml = file_get_contents($filename); $xmldoc = self::createXmlDocumentFromStr($xml, $docOptions); return $xmldoc; }
[ "public", "static", "function", "createXmlDocumentFromFile", "(", "$", "filename", ",", "$", "docOptions", "=", "XMLUTIL_OPT_DONT_FIX_AMPERSAND", ")", "{", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "throw", "new", "XmlUtilException", "(...
Create a XmlDocument object from a file saved on disk. @param string $filename @param int $docOptions @return DOMDocument @throws \ByJG\Util\Exception\XmlUtilException
[ "Create", "a", "XmlDocument", "object", "from", "a", "file", "saved", "on", "disk", "." ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L66-L74
39,546
byjg/xmlutil
src/XmlUtil.php
XmlUtil.createXmlDocumentFromStr
public static function createXmlDocumentFromStr($xml, $docOptions = XMLUTIL_OPT_DONT_FIX_AMPERSAND) { set_error_handler(function ($number, $error) { $matches = []; if (preg_match('/^DOMDocument::loadXML\(\): (.+)$/', $error, $matches) === 1) { throw new \InvalidArgumentException("[Err #$number] ".$matches[1]); } }); $xmldoc = self::createXmlDocument($docOptions); $xmlFixed = XmlUtil::fixXmlHeader($xml); if (($docOptions & XMLUTIL_OPT_DONT_FIX_AMPERSAND) != XMLUTIL_OPT_DONT_FIX_AMPERSAND) { $xmlFixed = str_replace("&amp;", "&", $xmlFixed); } $xmldoc->loadXML($xmlFixed); XmlUtil::extractNamespaces($xmldoc); restore_error_handler(); return $xmldoc; }
php
public static function createXmlDocumentFromStr($xml, $docOptions = XMLUTIL_OPT_DONT_FIX_AMPERSAND) { set_error_handler(function ($number, $error) { $matches = []; if (preg_match('/^DOMDocument::loadXML\(\): (.+)$/', $error, $matches) === 1) { throw new \InvalidArgumentException("[Err #$number] ".$matches[1]); } }); $xmldoc = self::createXmlDocument($docOptions); $xmlFixed = XmlUtil::fixXmlHeader($xml); if (($docOptions & XMLUTIL_OPT_DONT_FIX_AMPERSAND) != XMLUTIL_OPT_DONT_FIX_AMPERSAND) { $xmlFixed = str_replace("&amp;", "&", $xmlFixed); } $xmldoc->loadXML($xmlFixed); XmlUtil::extractNamespaces($xmldoc); restore_error_handler(); return $xmldoc; }
[ "public", "static", "function", "createXmlDocumentFromStr", "(", "$", "xml", ",", "$", "docOptions", "=", "XMLUTIL_OPT_DONT_FIX_AMPERSAND", ")", "{", "set_error_handler", "(", "function", "(", "$", "number", ",", "$", "error", ")", "{", "$", "matches", "=", "[...
Create XML \DOMDocument from a string @param string $xml - XML string document @param int $docOptions @return DOMDocument @throws \ByJG\Util\Exception\XmlUtilException
[ "Create", "XML", "\\", "DOMDocument", "from", "a", "string" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L84-L107
39,547
byjg/xmlutil
src/XmlUtil.php
XmlUtil.createDocumentFromNode
public static function createDocumentFromNode(\DOMNode $node, $docOptions = 0) { $xmldoc = self::createXmlDocument($docOptions); XmlUtil::$xmlNsPrefix[spl_object_hash($xmldoc)] = array(); $root = $xmldoc->importNode($node, true); $xmldoc->appendChild($root); return $xmldoc; }
php
public static function createDocumentFromNode(\DOMNode $node, $docOptions = 0) { $xmldoc = self::createXmlDocument($docOptions); XmlUtil::$xmlNsPrefix[spl_object_hash($xmldoc)] = array(); $root = $xmldoc->importNode($node, true); $xmldoc->appendChild($root); return $xmldoc; }
[ "public", "static", "function", "createDocumentFromNode", "(", "\\", "DOMNode", "$", "node", ",", "$", "docOptions", "=", "0", ")", "{", "$", "xmldoc", "=", "self", "::", "createXmlDocument", "(", "$", "docOptions", ")", ";", "XmlUtil", "::", "$", "xmlNsPr...
Create a \DOMDocumentFragment from a node @param DOMNode $node @param int $docOptions @return DOMDocument
[ "Create", "a", "\\", "DOMDocumentFragment", "from", "a", "node" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L116-L123
39,548
byjg/xmlutil
src/XmlUtil.php
XmlUtil.fixXmlHeader
public static function fixXmlHeader($string) { $string = XmlUtil::removeBom($string); if (strpos($string, "<?xml") !== false) { $xmltagend = strpos($string, "?>"); if ($xmltagend !== false) { $xmltagend += 2; $xmlheader = substr($string, 0, $xmltagend); if ($xmlheader == "<?xml?>") { $xmlheader = "<?xml ?>"; } } else { throw new XmlUtilException("XML header bad formatted.", 251); } // Complete header elements $count = 0; $xmlheader = preg_replace( "/version=([\"'][\w\d\-\.]+[\"'])/", "version=\"".self::XML_VERSION."\"", $xmlheader, 1, $count ); if ($count == 0) { $xmlheader = substr($xmlheader, 0, 6)."version=\"".self::XML_VERSION."\" ".substr($xmlheader, 6); } $count = 0; $xmlheader = preg_replace( "/encoding=([\"'][\w\d\-\.]+[\"'])/", "encoding=\"".self::XML_ENCODING."\"", $xmlheader, 1, $count ); if ($count == 0) { $xmlheader = substr($xmlheader, 0, 6)."encoding=\"".self::XML_ENCODING."\" ".substr($xmlheader, 6); } // Fix header position (first version, after encoding) $xmlheader = preg_replace( "/<\?([\w\W]*)\s+(encoding=([\"'][\w\d\-\.]+[\"']))\s+(version=([\"'][\w\d\-\.]+[\"']))\s*\?>/", "<?\\1 \\4 \\2?>", $xmlheader, 1, $count ); return $xmlheader.substr($string, $xmltagend); } else { $xmlheader = '<?xml version="'.self::XML_VERSION.'" encoding="'.self::XML_ENCODING.'"?>'; return $xmlheader.$string; } }
php
public static function fixXmlHeader($string) { $string = XmlUtil::removeBom($string); if (strpos($string, "<?xml") !== false) { $xmltagend = strpos($string, "?>"); if ($xmltagend !== false) { $xmltagend += 2; $xmlheader = substr($string, 0, $xmltagend); if ($xmlheader == "<?xml?>") { $xmlheader = "<?xml ?>"; } } else { throw new XmlUtilException("XML header bad formatted.", 251); } // Complete header elements $count = 0; $xmlheader = preg_replace( "/version=([\"'][\w\d\-\.]+[\"'])/", "version=\"".self::XML_VERSION."\"", $xmlheader, 1, $count ); if ($count == 0) { $xmlheader = substr($xmlheader, 0, 6)."version=\"".self::XML_VERSION."\" ".substr($xmlheader, 6); } $count = 0; $xmlheader = preg_replace( "/encoding=([\"'][\w\d\-\.]+[\"'])/", "encoding=\"".self::XML_ENCODING."\"", $xmlheader, 1, $count ); if ($count == 0) { $xmlheader = substr($xmlheader, 0, 6)."encoding=\"".self::XML_ENCODING."\" ".substr($xmlheader, 6); } // Fix header position (first version, after encoding) $xmlheader = preg_replace( "/<\?([\w\W]*)\s+(encoding=([\"'][\w\d\-\.]+[\"']))\s+(version=([\"'][\w\d\-\.]+[\"']))\s*\?>/", "<?\\1 \\4 \\2?>", $xmlheader, 1, $count ); return $xmlheader.substr($string, $xmltagend); } else { $xmlheader = '<?xml version="'.self::XML_VERSION.'" encoding="'.self::XML_ENCODING.'"?>'; return $xmlheader.$string; } }
[ "public", "static", "function", "fixXmlHeader", "(", "$", "string", ")", "{", "$", "string", "=", "XmlUtil", "::", "removeBom", "(", "$", "string", ")", ";", "if", "(", "strpos", "(", "$", "string", ",", "\"<?xml\"", ")", "!==", "false", ")", "{", "$...
Adjust xml string to the proper format @param string $string - XML string document @return string - Return the string converted @throws \ByJG\Util\Exception\XmlUtilException
[ "Adjust", "xml", "string", "to", "the", "proper", "format" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L150-L205
39,549
byjg/xmlutil
src/XmlUtil.php
XmlUtil.getFormattedDocument
public static function getFormattedDocument($xml) { $oldValue = $xml->preserveWhiteSpace; $oldFormatOutput = $xml->formatOutput; $xml->preserveWhiteSpace = false; $xml->formatOutput = true; $document = $xml->saveXML(); $xml->preserveWhiteSpace = $oldValue; $xml->formatOutput = $oldFormatOutput; return $document; }
php
public static function getFormattedDocument($xml) { $oldValue = $xml->preserveWhiteSpace; $oldFormatOutput = $xml->formatOutput; $xml->preserveWhiteSpace = false; $xml->formatOutput = true; $document = $xml->saveXML(); $xml->preserveWhiteSpace = $oldValue; $xml->formatOutput = $oldFormatOutput; return $document; }
[ "public", "static", "function", "getFormattedDocument", "(", "$", "xml", ")", "{", "$", "oldValue", "=", "$", "xml", "->", "preserveWhiteSpace", ";", "$", "oldFormatOutput", "=", "$", "xml", "->", "formatOutput", ";", "$", "xml", "->", "preserveWhiteSpace", ...
Get document without xml parameters @param DOMDocument $xml @return string
[ "Get", "document", "without", "xml", "parameters" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L231-L244
39,550
byjg/xmlutil
src/XmlUtil.php
XmlUtil.addNodeFromFile
public static function addNodeFromFile(\DOMNode $rootNode, $filename, $nodetoadd) { if ($rootNode === null) { return; } if (!file_exists($filename)) { return; } $source = XmlUtil::createXmlDocumentFromFile($filename); $nodes = $source->getElementsByTagName($nodetoadd)->item(0)->childNodes; foreach ($nodes as $node) { $newNode = $rootNode->ownerDocument->importNode($node, true); $rootNode->appendChild($newNode); } }
php
public static function addNodeFromFile(\DOMNode $rootNode, $filename, $nodetoadd) { if ($rootNode === null) { return; } if (!file_exists($filename)) { return; } $source = XmlUtil::createXmlDocumentFromFile($filename); $nodes = $source->getElementsByTagName($nodetoadd)->item(0)->childNodes; foreach ($nodes as $node) { $newNode = $rootNode->ownerDocument->importNode($node, true); $rootNode->appendChild($newNode); } }
[ "public", "static", "function", "addNodeFromFile", "(", "\\", "DOMNode", "$", "rootNode", ",", "$", "filename", ",", "$", "nodetoadd", ")", "{", "if", "(", "$", "rootNode", "===", "null", ")", "{", "return", ";", "}", "if", "(", "!", "file_exists", "("...
Add node to specific XmlNode from file existing on disk @param \DOMNode $rootNode XmlNode receives node @param string $filename File to import node @param string $nodetoadd Node to be added @throws \ByJG\Util\Exception\XmlUtilException
[ "Add", "node", "to", "specific", "XmlNode", "from", "file", "existing", "on", "disk" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L279-L296
39,551
byjg/xmlutil
src/XmlUtil.php
XmlUtil.createChild
public static function createChild(\DOMNode $rootNode, $nodeName, $nodeText = "", $uri = "") { if (empty($nodeName)) { throw new XmlUtilException("Node name must be a string."); } $nodeworking = XmlUtil::createChildNode($rootNode, $nodeName, $uri); self::addTextNode($nodeworking, $nodeText); $rootNode->appendChild($nodeworking); return $nodeworking; }
php
public static function createChild(\DOMNode $rootNode, $nodeName, $nodeText = "", $uri = "") { if (empty($nodeName)) { throw new XmlUtilException("Node name must be a string."); } $nodeworking = XmlUtil::createChildNode($rootNode, $nodeName, $uri); self::addTextNode($nodeworking, $nodeText); $rootNode->appendChild($nodeworking); return $nodeworking; }
[ "public", "static", "function", "createChild", "(", "\\", "DOMNode", "$", "rootNode", ",", "$", "nodeName", ",", "$", "nodeText", "=", "\"\"", ",", "$", "uri", "=", "\"\"", ")", "{", "if", "(", "empty", "(", "$", "nodeName", ")", ")", "{", "throw", ...
Append child node from specific node and add text @param \DOMNode $rootNode Parent node @param string $nodeName Node to add string @param string $nodeText Text to add string @param string $uri @return DOMNode @throws \ByJG\Util\Exception\XmlUtilException
[ "Append", "child", "node", "from", "specific", "node", "and", "add", "text" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L328-L338
39,552
byjg/xmlutil
src/XmlUtil.php
XmlUtil.createChildBefore
public static function createChildBefore(\DOMNode $rootNode, $nodeName, $nodeText, $position = 0) { return self::createChildBeforeNode($nodeName, $nodeText, $rootNode->childNodes->item($position)); }
php
public static function createChildBefore(\DOMNode $rootNode, $nodeName, $nodeText, $position = 0) { return self::createChildBeforeNode($nodeName, $nodeText, $rootNode->childNodes->item($position)); }
[ "public", "static", "function", "createChildBefore", "(", "\\", "DOMNode", "$", "rootNode", ",", "$", "nodeName", ",", "$", "nodeText", ",", "$", "position", "=", "0", ")", "{", "return", "self", "::", "createChildBeforeNode", "(", "$", "nodeName", ",", "$...
Create child node on the top from specific node and add text @param \DOMNode $rootNode Parent node @param string $nodeName Node to add string @param string $nodeText Text to add string @param int $position @return DOMNode @throws \ByJG\Util\Exception\XmlUtilException
[ "Create", "child", "node", "on", "the", "top", "from", "specific", "node", "and", "add", "text" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L350-L353
39,553
byjg/xmlutil
src/XmlUtil.php
XmlUtil.addTextNode
public static function addTextNode(\DOMNode $rootNode, $text, $escapeChars = false) { if (!empty($text) || is_numeric($text)) { $owner = XmlUtil::getOwnerDocument($rootNode); if ($escapeChars) { $nodeworkingText = $owner->createCDATASection($text); } else { $nodeworkingText = $owner->createTextNode($text); } $rootNode->appendChild($nodeworkingText); } }
php
public static function addTextNode(\DOMNode $rootNode, $text, $escapeChars = false) { if (!empty($text) || is_numeric($text)) { $owner = XmlUtil::getOwnerDocument($rootNode); if ($escapeChars) { $nodeworkingText = $owner->createCDATASection($text); } else { $nodeworkingText = $owner->createTextNode($text); } $rootNode->appendChild($nodeworkingText); } }
[ "public", "static", "function", "addTextNode", "(", "\\", "DOMNode", "$", "rootNode", ",", "$", "text", ",", "$", "escapeChars", "=", "false", ")", "{", "if", "(", "!", "empty", "(", "$", "text", ")", "||", "is_numeric", "(", "$", "text", ")", ")", ...
Add text to node @param \DOMNode $rootNode Parent node @param string $text Text to add String @param bool $escapeChars (True create CData instead Text node) @throws \ByJG\Util\Exception\XmlUtilException
[ "Add", "text", "to", "node" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L379-L390
39,554
byjg/xmlutil
src/XmlUtil.php
XmlUtil.addAttribute
public static function addAttribute(\DOMNode $rootNode, $name, $value) { XmlUtil::checkIfPrefixWasDefined($rootNode, $name); $owner = XmlUtil::getOwnerDocument($rootNode); $attrNode = $owner->createAttribute($name); $attrNode->value = $value; $rootNode->setAttributeNode($attrNode); return $rootNode; }
php
public static function addAttribute(\DOMNode $rootNode, $name, $value) { XmlUtil::checkIfPrefixWasDefined($rootNode, $name); $owner = XmlUtil::getOwnerDocument($rootNode); $attrNode = $owner->createAttribute($name); $attrNode->value = $value; $rootNode->setAttributeNode($attrNode); return $rootNode; }
[ "public", "static", "function", "addAttribute", "(", "\\", "DOMNode", "$", "rootNode", ",", "$", "name", ",", "$", "value", ")", "{", "XmlUtil", "::", "checkIfPrefixWasDefined", "(", "$", "rootNode", ",", "$", "name", ")", ";", "$", "owner", "=", "XmlUti...
Add a attribute to specific node @param \DOMNode $rootNode Node to receive attribute @param string $name Attribute name string @param string $value Attribute value string @return DOMNode @throws \ByJG\Util\Exception\XmlUtilException
[ "Add", "a", "attribute", "to", "specific", "node" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L401-L410
39,555
byjg/xmlutil
src/XmlUtil.php
XmlUtil.selectNodes
public static function selectNodes(\DOMNode $pNode, $xPath, $arNamespace = null) // <- Retorna N&#65533;! { if (preg_match('~^/[^/]~', $xPath)) { $xPath = substr($xPath, 1); } $owner = XmlUtil::getOwnerDocument($pNode); $xpath = new DOMXPath($owner); XmlUtil::registerNamespaceForFilter($xpath, $arNamespace); $rNodeList = $xpath->query($xPath, $pNode); return $rNodeList; }
php
public static function selectNodes(\DOMNode $pNode, $xPath, $arNamespace = null) // <- Retorna N&#65533;! { if (preg_match('~^/[^/]~', $xPath)) { $xPath = substr($xPath, 1); } $owner = XmlUtil::getOwnerDocument($pNode); $xpath = new DOMXPath($owner); XmlUtil::registerNamespaceForFilter($xpath, $arNamespace); $rNodeList = $xpath->query($xPath, $pNode); return $rNodeList; }
[ "public", "static", "function", "selectNodes", "(", "\\", "DOMNode", "$", "pNode", ",", "$", "xPath", ",", "$", "arNamespace", "=", "null", ")", "// <- Retorna N&#65533;!", "{", "if", "(", "preg_match", "(", "'~^/[^/]~'", ",", "$", "xPath", ")", ")", "{", ...
Returns a \DOMNodeList from a relative xPath from other \DOMNode @param \DOMNode $pNode @param string $xPath @param array $arNamespace @return DOMNodeList @throws \ByJG\Util\Exception\XmlUtilException
[ "Returns", "a", "\\", "DOMNodeList", "from", "a", "relative", "xPath", "from", "other", "\\", "DOMNode" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L421-L433
39,556
byjg/xmlutil
src/XmlUtil.php
XmlUtil.selectSingleNode
public static function selectSingleNode(\DOMNode $pNode, $xPath, $arNamespace = null) // <- Retorna { $rNodeList = self::selectNodes($pNode, $xPath, $arNamespace); return $rNodeList->item(0); }
php
public static function selectSingleNode(\DOMNode $pNode, $xPath, $arNamespace = null) // <- Retorna { $rNodeList = self::selectNodes($pNode, $xPath, $arNamespace); return $rNodeList->item(0); }
[ "public", "static", "function", "selectSingleNode", "(", "\\", "DOMNode", "$", "pNode", ",", "$", "xPath", ",", "$", "arNamespace", "=", "null", ")", "// <- Retorna", "{", "$", "rNodeList", "=", "self", "::", "selectNodes", "(", "$", "pNode", ",", "$", "...
Returns a \DOMElement from a relative xPath from other \DOMNode @param \DOMNode $pNode @param string $xPath xPath string format @param array $arNamespace @return DOMElement @throws \ByJG\Util\Exception\XmlUtilException
[ "Returns", "a", "\\", "DOMElement", "from", "a", "relative", "xPath", "from", "other", "\\", "DOMNode" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L444-L449
39,557
byjg/xmlutil
src/XmlUtil.php
XmlUtil.innerXML
public static function innerXML(\DOMNode $node, $xmlstring) { $xmlstring = str_replace("<br>", "<br/>", $xmlstring); $len = strlen($xmlstring); $endText = ""; $close = strrpos($xmlstring, '>'); if ($close !== false && $close < $len - 1) { $endText = substr($xmlstring, $close + 1); $xmlstring = substr($xmlstring, 0, $close + 1); } $open = strpos($xmlstring, '<'); if ($open === false) { $node->nodeValue .= $xmlstring; } else { if ($open > 0) { $text = substr($xmlstring, 0, $open); $xmlstring = substr($xmlstring, $open); $node->nodeValue .= $text; } $dom = XmlUtil::getOwnerDocument($node); $xmlstring = "<rootxml>$xmlstring</rootxml>"; $sxe = @simplexml_load_string($xmlstring); if ($sxe === false) { throw new XmlUtilException("Cannot load XML string.", 252); } $domSimpleXml = dom_import_simplexml($sxe); if (!$domSimpleXml) { throw new XmlUtilException("XML Parsing error.", 253); } $domSimpleXml = $dom->importNode($domSimpleXml, true); $childs = $domSimpleXml->childNodes->length; for ($i = 0; $i < $childs; $i++) { $node->appendChild($domSimpleXml->childNodes->item($i)->cloneNode(true)); } } if (!empty($endText) && $endText != "") { $textNode = $dom->createTextNode($endText); $node->appendChild($textNode); } return $node->firstChild; }
php
public static function innerXML(\DOMNode $node, $xmlstring) { $xmlstring = str_replace("<br>", "<br/>", $xmlstring); $len = strlen($xmlstring); $endText = ""; $close = strrpos($xmlstring, '>'); if ($close !== false && $close < $len - 1) { $endText = substr($xmlstring, $close + 1); $xmlstring = substr($xmlstring, 0, $close + 1); } $open = strpos($xmlstring, '<'); if ($open === false) { $node->nodeValue .= $xmlstring; } else { if ($open > 0) { $text = substr($xmlstring, 0, $open); $xmlstring = substr($xmlstring, $open); $node->nodeValue .= $text; } $dom = XmlUtil::getOwnerDocument($node); $xmlstring = "<rootxml>$xmlstring</rootxml>"; $sxe = @simplexml_load_string($xmlstring); if ($sxe === false) { throw new XmlUtilException("Cannot load XML string.", 252); } $domSimpleXml = dom_import_simplexml($sxe); if (!$domSimpleXml) { throw new XmlUtilException("XML Parsing error.", 253); } $domSimpleXml = $dom->importNode($domSimpleXml, true); $childs = $domSimpleXml->childNodes->length; for ($i = 0; $i < $childs; $i++) { $node->appendChild($domSimpleXml->childNodes->item($i)->cloneNode(true)); } } if (!empty($endText) && $endText != "") { $textNode = $dom->createTextNode($endText); $node->appendChild($textNode); } return $node->firstChild; }
[ "public", "static", "function", "innerXML", "(", "\\", "DOMNode", "$", "node", ",", "$", "xmlstring", ")", "{", "$", "xmlstring", "=", "str_replace", "(", "\"<br>\"", ",", "\"<br/>\"", ",", "$", "xmlstring", ")", ";", "$", "len", "=", "strlen", "(", "$...
Concat a xml string in the node @param \DOMNode $node @param string $xmlstring @return \DOMNode @throws \ByJG\Util\Exception\XmlUtilException
[ "Concat", "a", "xml", "string", "in", "the", "node" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L473-L513
39,558
byjg/xmlutil
src/XmlUtil.php
XmlUtil.saveXmlNodeToString
public static function saveXmlNodeToString(\DOMNode $node) { $doc = XmlUtil::getOwnerDocument($node); $string = $doc->saveXML($node); return $string; }
php
public static function saveXmlNodeToString(\DOMNode $node) { $doc = XmlUtil::getOwnerDocument($node); $string = $doc->saveXML($node); return $string; }
[ "public", "static", "function", "saveXmlNodeToString", "(", "\\", "DOMNode", "$", "node", ")", "{", "$", "doc", "=", "XmlUtil", "::", "getOwnerDocument", "(", "$", "node", ")", ";", "$", "string", "=", "$", "doc", "->", "saveXML", "(", "$", "node", ")"...
Return the part node in xml document @param \DOMNode $node @return string @throws \ByJG\Util\Exception\XmlUtilException
[ "Return", "the", "part", "node", "in", "xml", "document" ]
adeded5814b3f66bb995c259fc4e081603faff8f
https://github.com/byjg/xmlutil/blob/adeded5814b3f66bb995c259fc4e081603faff8f/src/XmlUtil.php#L561-L566
39,559
fxpio/fxp-cache
Adapter/ApcuAdapter.php
ApcuAdapter.doClearItem
protected function doClearItem(array $item, $prefix) { $id = $item['info']; $key = substr($id, strrpos($id, ':') + 1); $res = true; if ('' === $prefix || 0 === strpos($id, $prefix)) { $res = $this->deleteItem($key); } return $res; }
php
protected function doClearItem(array $item, $prefix) { $id = $item['info']; $key = substr($id, strrpos($id, ':') + 1); $res = true; if ('' === $prefix || 0 === strpos($id, $prefix)) { $res = $this->deleteItem($key); } return $res; }
[ "protected", "function", "doClearItem", "(", "array", "$", "item", ",", "$", "prefix", ")", "{", "$", "id", "=", "$", "item", "[", "'info'", "]", ";", "$", "key", "=", "substr", "(", "$", "id", ",", "strrpos", "(", "$", "id", ",", "':'", ")", "...
Delete the key that starting by the prefix. @param array $item The cache item @param string $prefix The full prefix @return bool
[ "Delete", "the", "key", "that", "starting", "by", "the", "prefix", "." ]
55abf44a954890080fa2bfb080914ce7228ea769
https://github.com/fxpio/fxp-cache/blob/55abf44a954890080fa2bfb080914ce7228ea769/Adapter/ApcuAdapter.php#L47-L58
39,560
cmsgears/module-core
common/models/entities/Permission.php
Permission.getRolesIdList
public function getRolesIdList() { $roles = $this->roleMappingList; $rolesList = array(); foreach ( $roles as $role ) { array_push( $rolesList, $role->roleId ); } return $rolesList; }
php
public function getRolesIdList() { $roles = $this->roleMappingList; $rolesList = array(); foreach ( $roles as $role ) { array_push( $rolesList, $role->roleId ); } return $rolesList; }
[ "public", "function", "getRolesIdList", "(", ")", "{", "$", "roles", "=", "$", "this", "->", "roleMappingList", ";", "$", "rolesList", "=", "array", "(", ")", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "array_push", "(", "$", "ro...
Generate and return the array having id of mapped roles. @return array
[ "Generate", "and", "return", "the", "array", "having", "id", "of", "mapped", "roles", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/Permission.php#L216-L227
39,561
cmsgears/module-core
common/models/entities/Permission.php
Permission.findGroupPermissions
public static function findGroupPermissions( $ids = [], $config = [] ) { $permissionTable = CoreTables::getTableName( CoreTables::TABLE_PERMISSION ); $hierarchyTable = CoreTables::getTableName( CoreTables::TABLE_MODEL_HIERARCHY ); $idStr = join( ",", $ids ); return Permission::find()->leftJoin( $hierarchyTable, "`$permissionTable`.`id` = `$hierarchyTable`.`childId`" ) ->where( "`$hierarchyTable`.`parentType` = 'permission' AND `$hierarchyTable`.`parentId` IN ($idStr)" )->all(); }
php
public static function findGroupPermissions( $ids = [], $config = [] ) { $permissionTable = CoreTables::getTableName( CoreTables::TABLE_PERMISSION ); $hierarchyTable = CoreTables::getTableName( CoreTables::TABLE_MODEL_HIERARCHY ); $idStr = join( ",", $ids ); return Permission::find()->leftJoin( $hierarchyTable, "`$permissionTable`.`id` = `$hierarchyTable`.`childId`" ) ->where( "`$hierarchyTable`.`parentType` = 'permission' AND `$hierarchyTable`.`parentId` IN ($idStr)" )->all(); }
[ "public", "static", "function", "findGroupPermissions", "(", "$", "ids", "=", "[", "]", ",", "$", "config", "=", "[", "]", ")", "{", "$", "permissionTable", "=", "CoreTables", "::", "getTableName", "(", "CoreTables", "::", "TABLE_PERMISSION", ")", ";", "$"...
Find and return the children of given permissions id. @param array $ids L0 id list @param array $config @return Permission[]
[ "Find", "and", "return", "the", "children", "of", "given", "permissions", "id", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/Permission.php#L292-L300
39,562
phPoirot/Std
src/CriteriaLexer/ParsedCriteria.php
ParsedCriteria._buildStringFromParsed
protected function _buildStringFromParsed(array $parts, $params = []) { if ($params instanceof \Traversable) $params = StdTravers::of($params)->toArray(); if (! is_array($params) ) throw new \InvalidArgumentException(sprintf( 'Parameters must be an array or Traversable; given: (%s).' , \Poirot\Std\flatten($params) )); // regard to recursive function call $isOptional = false; $args = func_get_args(); if ($args && isset($args[2])) $isOptional = $args[2]; # Check For Presented Values in Optional Segment // consider this "/[@:username{{\w+}}][-:userid{{\w+}}]" // if username not presented as params injected then first part include @ as literal // not rendered. // optional part only render when all parameter is present if ($isOptional) { foreach ($parts as $parsed) { if (! isset($parsed['_parameter_']) ) continue; ## need parameter $neededParameterName = $parsed['_parameter_']; if (! (isset($params[$neededParameterName]) && $params[$neededParameterName] !== '') ) return ''; } } $return = ''; // [0 => ['_literal_' => 'localhost'], 1=>['_optional' => ..] ..] foreach ($parts as $parsed) { $definition_name = key($parsed); $definition_value = $parsed[$definition_name]; // $parsed can also have extra parsed data options // _parameter_ String(3) => tld \ // tld String(4) => .com switch ($definition_name) { case '_literal_': $return .= $definition_value; break; case '_parameter_': if (! isset($params[$definition_value]) ) { if ($isOptional) return ''; throw new \InvalidArgumentException(sprintf( 'Missing parameter (%s).' , $definition_value )); } if (! \Poirot\Std\isStringify($params[$definition_value]) ) throw new \Exception(sprintf( 'Parameter %s is not stringify; given: (%s).' , $definition_value , \Poirot\Std\flatten($params[$definition_value]) )); $return .= $params[$definition_value]; break; case '_optional_': $optionalPart = $this->_buildStringFromParsed($definition_value, $params, true); if ($optionalPart !== '') $return .= $optionalPart; break; } } return $return; }
php
protected function _buildStringFromParsed(array $parts, $params = []) { if ($params instanceof \Traversable) $params = StdTravers::of($params)->toArray(); if (! is_array($params) ) throw new \InvalidArgumentException(sprintf( 'Parameters must be an array or Traversable; given: (%s).' , \Poirot\Std\flatten($params) )); // regard to recursive function call $isOptional = false; $args = func_get_args(); if ($args && isset($args[2])) $isOptional = $args[2]; # Check For Presented Values in Optional Segment // consider this "/[@:username{{\w+}}][-:userid{{\w+}}]" // if username not presented as params injected then first part include @ as literal // not rendered. // optional part only render when all parameter is present if ($isOptional) { foreach ($parts as $parsed) { if (! isset($parsed['_parameter_']) ) continue; ## need parameter $neededParameterName = $parsed['_parameter_']; if (! (isset($params[$neededParameterName]) && $params[$neededParameterName] !== '') ) return ''; } } $return = ''; // [0 => ['_literal_' => 'localhost'], 1=>['_optional' => ..] ..] foreach ($parts as $parsed) { $definition_name = key($parsed); $definition_value = $parsed[$definition_name]; // $parsed can also have extra parsed data options // _parameter_ String(3) => tld \ // tld String(4) => .com switch ($definition_name) { case '_literal_': $return .= $definition_value; break; case '_parameter_': if (! isset($params[$definition_value]) ) { if ($isOptional) return ''; throw new \InvalidArgumentException(sprintf( 'Missing parameter (%s).' , $definition_value )); } if (! \Poirot\Std\isStringify($params[$definition_value]) ) throw new \Exception(sprintf( 'Parameter %s is not stringify; given: (%s).' , $definition_value , \Poirot\Std\flatten($params[$definition_value]) )); $return .= $params[$definition_value]; break; case '_optional_': $optionalPart = $this->_buildStringFromParsed($definition_value, $params, true); if ($optionalPart !== '') $return .= $optionalPart; break; } } return $return; }
[ "protected", "function", "_buildStringFromParsed", "(", "array", "$", "parts", ",", "$", "params", "=", "[", "]", ")", "{", "if", "(", "$", "params", "instanceof", "\\", "Traversable", ")", "$", "params", "=", "StdTravers", "::", "of", "(", "$", "params"...
Build String Representation From Given Parts and Params @param array $parts @param array|\Traversable $params @return string
[ "Build", "String", "Representation", "From", "Given", "Parts", "and", "Params" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/CriteriaLexer/ParsedCriteria.php#L169-L249
39,563
cmsgears/module-core
common/models/traits/mappers/ModelFollowerTrait.php
ModelFollowerTrait.generateFollowCounts
protected function generateFollowCounts() { $returnArr = [ IFollower::TYPE_LIKE => [ 0 => 0, 1 => 0 ], IFollower::TYPE_DISLIKE => [ 0 => 0, 1 => 0 ], IFollower::TYPE_FOLLOW => [ 0 => 0, 1 => 0 ], IFollower::TYPE_WISHLIST => [ 0 => 0, 1 => 0 ] ]; $followerTable = ModelFollower::tableName(); $query = new Query(); $query->select( [ 'type', 'active', 'count(id) as total' ] ) ->from( $followerTable ) ->where( [ 'parentId' => $this->id, 'parentType' => $this->modelType, 'active' => true ] ) ->groupBy( [ 'type', 'active' ] ); $counts = $query->all(); foreach( $counts as $count ) { $returnArr[ $count[ 'type' ] ][ $count[ 'active' ] ] = $count[ 'total' ]; } return $returnArr; }
php
protected function generateFollowCounts() { $returnArr = [ IFollower::TYPE_LIKE => [ 0 => 0, 1 => 0 ], IFollower::TYPE_DISLIKE => [ 0 => 0, 1 => 0 ], IFollower::TYPE_FOLLOW => [ 0 => 0, 1 => 0 ], IFollower::TYPE_WISHLIST => [ 0 => 0, 1 => 0 ] ]; $followerTable = ModelFollower::tableName(); $query = new Query(); $query->select( [ 'type', 'active', 'count(id) as total' ] ) ->from( $followerTable ) ->where( [ 'parentId' => $this->id, 'parentType' => $this->modelType, 'active' => true ] ) ->groupBy( [ 'type', 'active' ] ); $counts = $query->all(); foreach( $counts as $count ) { $returnArr[ $count[ 'type' ] ][ $count[ 'active' ] ] = $count[ 'total' ]; } return $returnArr; }
[ "protected", "function", "generateFollowCounts", "(", ")", "{", "$", "returnArr", "=", "[", "IFollower", "::", "TYPE_LIKE", "=>", "[", "0", "=>", "0", ",", "1", "=>", "0", "]", ",", "IFollower", "::", "TYPE_DISLIKE", "=>", "[", "0", "=>", "0", ",", "...
Generate and return the follow counts. @return array
[ "Generate", "and", "return", "the", "follow", "counts", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/traits/mappers/ModelFollowerTrait.php#L141-L166
39,564
cmsgears/module-core
common/models/traits/mappers/ModelFollowerTrait.php
ModelFollowerTrait.generateUserFollows
protected function generateUserFollows() { $user = Yii::$app->user->identity; $returnArr = [ IFollower::TYPE_LIKE => false, IFollower::TYPE_DISLIKE => false, IFollower::TYPE_FOLLOW => false, IFollower::TYPE_WISHLIST => false ]; if( isset( $user ) ) { $followerTable = ModelFollower::tableName(); $query = new Query(); $query->select( [ 'type', 'active' ] ) ->from( $followerTable ) ->where( [ 'parentId' => $this->id, 'parentType' => $this->modelType, 'modelId' => $user->id ] ); $follows = $query->all(); foreach ( $follows as $follow ) { $returnArr[ $follow[ 'type' ] ] = $follow[ 'active' ]; } } return $returnArr; }
php
protected function generateUserFollows() { $user = Yii::$app->user->identity; $returnArr = [ IFollower::TYPE_LIKE => false, IFollower::TYPE_DISLIKE => false, IFollower::TYPE_FOLLOW => false, IFollower::TYPE_WISHLIST => false ]; if( isset( $user ) ) { $followerTable = ModelFollower::tableName(); $query = new Query(); $query->select( [ 'type', 'active' ] ) ->from( $followerTable ) ->where( [ 'parentId' => $this->id, 'parentType' => $this->modelType, 'modelId' => $user->id ] ); $follows = $query->all(); foreach ( $follows as $follow ) { $returnArr[ $follow[ 'type' ] ] = $follow[ 'active' ]; } } return $returnArr; }
[ "protected", "function", "generateUserFollows", "(", ")", "{", "$", "user", "=", "Yii", "::", "$", "app", "->", "user", "->", "identity", ";", "$", "returnArr", "=", "[", "IFollower", "::", "TYPE_LIKE", "=>", "false", ",", "IFollower", "::", "TYPE_DISLIKE"...
Generate and return the user follows. @return array
[ "Generate", "and", "return", "the", "user", "follows", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/traits/mappers/ModelFollowerTrait.php#L227-L250
39,565
willwashburn/stream
src/Stream/Stream.php
Stream.peek
public function peek($characters) { if ( strlen($this->stream_string) < $this->strpos + $characters ) { throw new StreamBufferTooSmallException('Not enough of the stream available.'); } return substr($this->stream_string, $this->strpos, $characters); }
php
public function peek($characters) { if ( strlen($this->stream_string) < $this->strpos + $characters ) { throw new StreamBufferTooSmallException('Not enough of the stream available.'); } return substr($this->stream_string, $this->strpos, $characters); }
[ "public", "function", "peek", "(", "$", "characters", ")", "{", "if", "(", "strlen", "(", "$", "this", "->", "stream_string", ")", "<", "$", "this", "->", "strpos", "+", "$", "characters", ")", "{", "throw", "new", "StreamBufferTooSmallException", "(", "...
Get characters from the string but don't move the pointer @param $characters @return string @throws StreamBufferTooSmallException
[ "Get", "characters", "from", "the", "string", "but", "don", "t", "move", "the", "pointer" ]
17b32f35401640a63d624add1d5d8a04876422c2
https://github.com/willwashburn/stream/blob/17b32f35401640a63d624add1d5d8a04876422c2/src/Stream/Stream.php#L33-L40
39,566
willwashburn/stream
src/Stream/Stream.php
Stream.read
public function read($characters) { $result = $this->peek($characters); $this->strpos += $characters; return $result; }
php
public function read($characters) { $result = $this->peek($characters); $this->strpos += $characters; return $result; }
[ "public", "function", "read", "(", "$", "characters", ")", "{", "$", "result", "=", "$", "this", "->", "peek", "(", "$", "characters", ")", ";", "$", "this", "->", "strpos", "+=", "$", "characters", ";", "return", "$", "result", ";", "}" ]
Get Characters from the string @param $characters @return string @throws StreamBufferTooSmallException
[ "Get", "Characters", "from", "the", "string" ]
17b32f35401640a63d624add1d5d8a04876422c2
https://github.com/willwashburn/stream/blob/17b32f35401640a63d624add1d5d8a04876422c2/src/Stream/Stream.php#L50-L57
39,567
mcaskill/charcoal-support
src/Cms/AbstractWebTemplate.php
AbstractWebTemplate.currentUrl
public function currentUrl() { $context = $this->contextObject(); if ($context && isset($context['url'])) { return $this->createAbsoluteUrl($context['url']); } return null; }
php
public function currentUrl() { $context = $this->contextObject(); if ($context && isset($context['url'])) { return $this->createAbsoluteUrl($context['url']); } return null; }
[ "public", "function", "currentUrl", "(", ")", "{", "$", "context", "=", "$", "this", "->", "contextObject", "(", ")", ";", "if", "(", "$", "context", "&&", "isset", "(", "$", "context", "[", "'url'", "]", ")", ")", "{", "return", "$", "this", "->",...
Retrieve the current URI of the context. @return \Psr\Http\Message\UriInterface|null
[ "Retrieve", "the", "current", "URI", "of", "the", "context", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/AbstractWebTemplate.php#L102-L111
39,568
mcaskill/charcoal-support
src/Cms/AbstractWebTemplate.php
AbstractWebTemplate.currentLocale
public function currentLocale() { $langCode = $this->translator()->getLocale(); $locales = $this->translator()->locales(); if (isset($locales[$langCode])) { $locale = $locales[$langCode]; if (isset($locale['locale'])) { return $locale['locale']; } else { return $langCode; } } return null; }
php
public function currentLocale() { $langCode = $this->translator()->getLocale(); $locales = $this->translator()->locales(); if (isset($locales[$langCode])) { $locale = $locales[$langCode]; if (isset($locale['locale'])) { return $locale['locale']; } else { return $langCode; } } return null; }
[ "public", "function", "currentLocale", "(", ")", "{", "$", "langCode", "=", "$", "this", "->", "translator", "(", ")", "->", "getLocale", "(", ")", ";", "$", "locales", "=", "$", "this", "->", "translator", "(", ")", "->", "locales", "(", ")", ";", ...
Retrieve the current locale. @return string|null
[ "Retrieve", "the", "current", "locale", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/AbstractWebTemplate.php#L118-L132
39,569
mcaskill/charcoal-support
src/Cms/AbstractWebTemplate.php
AbstractWebTemplate.metaTitle
public function metaTitle() { $context = $this->contextObject(); $title = null; if ($context instanceof HasMetatagInterface) { $title = (string)$context['meta_title']; } if (!$title) { $title = (string)$this->fallbackMetaTitle(); } return $title; }
php
public function metaTitle() { $context = $this->contextObject(); $title = null; if ($context instanceof HasMetatagInterface) { $title = (string)$context['meta_title']; } if (!$title) { $title = (string)$this->fallbackMetaTitle(); } return $title; }
[ "public", "function", "metaTitle", "(", ")", "{", "$", "context", "=", "$", "this", "->", "contextObject", "(", ")", ";", "$", "title", "=", "null", ";", "if", "(", "$", "context", "instanceof", "HasMetatagInterface", ")", "{", "$", "title", "=", "(", ...
Retrieve the name or title of the object. @return string|null
[ "Retrieve", "the", "name", "or", "title", "of", "the", "object", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/AbstractWebTemplate.php#L177-L191
39,570
mcaskill/charcoal-support
src/Cms/AbstractWebTemplate.php
AbstractWebTemplate.metaDescription
public function metaDescription() { $context = $this->contextObject(); $desc = null; if ($context instanceof HasMetatagInterface) { $desc = (string)$context['meta_description']; } if (!$desc) { $desc = (string)$this->fallbackMetaDescription(); } return $desc; }
php
public function metaDescription() { $context = $this->contextObject(); $desc = null; if ($context instanceof HasMetatagInterface) { $desc = (string)$context['meta_description']; } if (!$desc) { $desc = (string)$this->fallbackMetaDescription(); } return $desc; }
[ "public", "function", "metaDescription", "(", ")", "{", "$", "context", "=", "$", "this", "->", "contextObject", "(", ")", ";", "$", "desc", "=", "null", ";", "if", "(", "$", "context", "instanceof", "HasMetatagInterface", ")", "{", "$", "desc", "=", "...
Retrieve the description of the object. @return string|null
[ "Retrieve", "the", "description", "of", "the", "object", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/AbstractWebTemplate.php#L210-L224
39,571
mcaskill/charcoal-support
src/Cms/AbstractWebTemplate.php
AbstractWebTemplate.hasSeoMetadata
public function hasSeoMetadata() { if ($this->seoMetadata instanceof ArrayIterator) { return (count($this->seoMetadata) > 0); } return !empty($this->seoMetadata); }
php
public function hasSeoMetadata() { if ($this->seoMetadata instanceof ArrayIterator) { return (count($this->seoMetadata) > 0); } return !empty($this->seoMetadata); }
[ "public", "function", "hasSeoMetadata", "(", ")", "{", "if", "(", "$", "this", "->", "seoMetadata", "instanceof", "ArrayIterator", ")", "{", "return", "(", "count", "(", "$", "this", "->", "seoMetadata", ")", ">", "0", ")", ";", "}", "return", "!", "em...
Determine if we have additional SEO metadata. @return boolean
[ "Determine", "if", "we", "have", "additional", "SEO", "metadata", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/AbstractWebTemplate.php#L431-L438
39,572
mcaskill/charcoal-support
src/Cms/AbstractWebTemplate.php
AbstractWebTemplate.setSeoMetadata
protected function setSeoMetadata(array $metadata) { if (is_array($this->seoMetadata)) { $this->seoMetadata = new ArrayIterator($this->seoMetadata); } foreach ($metadata as $key => $value) { if (is_array($value)) { $value = implode(',', $value); } $this->seoMetadata[] = [ 'name' => $key, 'content' => (string)$value ]; } return $this; }
php
protected function setSeoMetadata(array $metadata) { if (is_array($this->seoMetadata)) { $this->seoMetadata = new ArrayIterator($this->seoMetadata); } foreach ($metadata as $key => $value) { if (is_array($value)) { $value = implode(',', $value); } $this->seoMetadata[] = [ 'name' => $key, 'content' => (string)$value ]; } return $this; }
[ "protected", "function", "setSeoMetadata", "(", "array", "$", "metadata", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "seoMetadata", ")", ")", "{", "$", "this", "->", "seoMetadata", "=", "new", "ArrayIterator", "(", "$", "this", "->", "seoMe...
Set additional SEO metadata. @param array $metadata Map of metadata keys and values. @return self
[ "Set", "additional", "SEO", "metadata", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/AbstractWebTemplate.php#L446-L464
39,573
cmsgears/module-core
common/models/entities/Site.php
Site.getMembers
public function getMembers() { $siteMemberTable = CoreTables::getTableName( CoreTables::TABLE_SITE_MEMBER ); return $this->hasMany( User::class, [ 'id' => 'userId' ] ) ->viaTable( $siteMemberTable, [ 'siteId' => 'id' ] ); }
php
public function getMembers() { $siteMemberTable = CoreTables::getTableName( CoreTables::TABLE_SITE_MEMBER ); return $this->hasMany( User::class, [ 'id' => 'userId' ] ) ->viaTable( $siteMemberTable, [ 'siteId' => 'id' ] ); }
[ "public", "function", "getMembers", "(", ")", "{", "$", "siteMemberTable", "=", "CoreTables", "::", "getTableName", "(", "CoreTables", "::", "TABLE_SITE_MEMBER", ")", ";", "return", "$", "this", "->", "hasMany", "(", "User", "::", "class", ",", "[", "'id'", ...
Return members of the site. @return User[]
[ "Return", "members", "of", "the", "site", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/Site.php#L255-L261
39,574
spiral/exceptions
src/HtmlHandler.php
HtmlHandler.render
private function render(string $view, array $options = []): string { extract($options, EXTR_OVERWRITE); ob_start(); require $this->getFilename($view); return ob_get_clean(); }
php
private function render(string $view, array $options = []): string { extract($options, EXTR_OVERWRITE); ob_start(); require $this->getFilename($view); return ob_get_clean(); }
[ "private", "function", "render", "(", "string", "$", "view", ",", "array", "$", "options", "=", "[", "]", ")", ":", "string", "{", "extract", "(", "$", "options", ",", "EXTR_OVERWRITE", ")", ";", "ob_start", "(", ")", ";", "require", "$", "this", "->...
Render PHP template. @param string $view @param array $options @return string
[ "Render", "PHP", "template", "." ]
9735a00b189ce61317cd49a9d6ec630f68cee381
https://github.com/spiral/exceptions/blob/9735a00b189ce61317cd49a9d6ec630f68cee381/src/HtmlHandler.php#L111-L119
39,575
cmsgears/module-core
common/models/entities/Role.php
Role.getPermissionsIdList
public function getPermissionsIdList() { $permissions = $this->permissionMappingList; $permissionsList = []; foreach ( $permissions as $permission ) { array_push( $permissionsList, $permission->permissionId ); } return $permissionsList; }
php
public function getPermissionsIdList() { $permissions = $this->permissionMappingList; $permissionsList = []; foreach ( $permissions as $permission ) { array_push( $permissionsList, $permission->permissionId ); } return $permissionsList; }
[ "public", "function", "getPermissionsIdList", "(", ")", "{", "$", "permissions", "=", "$", "this", "->", "permissionMappingList", ";", "$", "permissionsList", "=", "[", "]", ";", "foreach", "(", "$", "permissions", "as", "$", "permission", ")", "{", "array_p...
Generate and return the array having id of mapped permissions. @return array
[ "Generate", "and", "return", "the", "array", "having", "id", "of", "mapped", "permissions", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/Role.php#L220-L231
39,576
cmsgears/module-core
common/models/entities/Role.php
Role.getPermissionsSlugList
public function getPermissionsSlugList() { $slugList = []; $idList = []; // TODO: Use roles hierarchy recursively to get child roles if( !empty( $this->gridCache ) ) { return $this->getGridCacheAttribute( 'permissionsSlugList' ); } else { // Generate L0 Slugs and Ids List $permissions = $this->permissions; foreach( $permissions as $permission ) { if( !in_array( $permission->slug, $slugList ) ) { array_push( $slugList, $permission->slug ); if( $permission->group ) { array_push( $idList, $permission->id ); } } } // Add child permission slugs recursively till all leaf nodes get exhausted. while( count( $idList ) > 0 ) { $permissions = Permission::findGroupPermissions( $idList ); $idList = []; foreach( $permissions as $permission ) { if( !in_array( $permission->slug, $slugList ) ) { array_push( $slugList, $permission->slug ); if( $permission->group ) { array_push( $idList, $permission->id ); } } } if( count( $idList ) == 0 ) { break; } }; } return $slugList; }
php
public function getPermissionsSlugList() { $slugList = []; $idList = []; // TODO: Use roles hierarchy recursively to get child roles if( !empty( $this->gridCache ) ) { return $this->getGridCacheAttribute( 'permissionsSlugList' ); } else { // Generate L0 Slugs and Ids List $permissions = $this->permissions; foreach( $permissions as $permission ) { if( !in_array( $permission->slug, $slugList ) ) { array_push( $slugList, $permission->slug ); if( $permission->group ) { array_push( $idList, $permission->id ); } } } // Add child permission slugs recursively till all leaf nodes get exhausted. while( count( $idList ) > 0 ) { $permissions = Permission::findGroupPermissions( $idList ); $idList = []; foreach( $permissions as $permission ) { if( !in_array( $permission->slug, $slugList ) ) { array_push( $slugList, $permission->slug ); if( $permission->group ) { array_push( $idList, $permission->id ); } } } if( count( $idList ) == 0 ) { break; } }; } return $slugList; }
[ "public", "function", "getPermissionsSlugList", "(", ")", "{", "$", "slugList", "=", "[", "]", ";", "$", "idList", "=", "[", "]", ";", "// TODO: Use roles hierarchy recursively to get child roles", "if", "(", "!", "empty", "(", "$", "this", "->", "gridCache", ...
Generate and return the array having slug of mapped permissions. @return array
[ "Generate", "and", "return", "the", "array", "having", "slug", "of", "mapped", "permissions", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/Role.php#L238-L295
39,577
cmsgears/module-core
common/models/traits/base/ApprovalTrait.php
ApprovalTrait.isEditable
public function isEditable() { $editable = [ IApproval::STATUS_SUBMITTED, IApproval::STATUS_RE_SUBMIT, IApproval::STATUS_UPLIFT_FREEZE, IApproval::STATUS_UPLIFT_BLOCK ]; return !in_array( $this->status, $editable ); }
php
public function isEditable() { $editable = [ IApproval::STATUS_SUBMITTED, IApproval::STATUS_RE_SUBMIT, IApproval::STATUS_UPLIFT_FREEZE, IApproval::STATUS_UPLIFT_BLOCK ]; return !in_array( $this->status, $editable ); }
[ "public", "function", "isEditable", "(", ")", "{", "$", "editable", "=", "[", "IApproval", "::", "STATUS_SUBMITTED", ",", "IApproval", "::", "STATUS_RE_SUBMIT", ",", "IApproval", "::", "STATUS_UPLIFT_FREEZE", ",", "IApproval", "::", "STATUS_UPLIFT_BLOCK", "]", ";"...
The model owner cannot update it in the states defined within this method. @return boolean
[ "The", "model", "owner", "cannot", "update", "it", "in", "the", "states", "defined", "within", "this", "method", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/traits/base/ApprovalTrait.php#L353-L358
39,578
cmsgears/module-core
common/models/traits/base/ApprovalTrait.php
ApprovalTrait.isSubmittable
public function isSubmittable() { return $this->isRegistration() || $this->status == IApproval::STATUS_REJECTED || $this->status == IApproval::STATUS_FROJEN || $this->status == IApproval::STATUS_BLOCKED; }
php
public function isSubmittable() { return $this->isRegistration() || $this->status == IApproval::STATUS_REJECTED || $this->status == IApproval::STATUS_FROJEN || $this->status == IApproval::STATUS_BLOCKED; }
[ "public", "function", "isSubmittable", "(", ")", "{", "return", "$", "this", "->", "isRegistration", "(", ")", "||", "$", "this", "->", "status", "==", "IApproval", "::", "STATUS_REJECTED", "||", "$", "this", "->", "status", "==", "IApproval", "::", "STATU...
The model owner can submit the model for limit removal in selected states i.e. new, rejected, frozen or blocked. defined within this method. @return boolean
[ "The", "model", "owner", "can", "submit", "the", "model", "for", "limit", "removal", "in", "selected", "states", "i", ".", "e", ".", "new", "rejected", "frozen", "or", "blocked", ".", "defined", "within", "this", "method", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/traits/base/ApprovalTrait.php#L366-L370
39,579
cmsgears/module-core
common/models/traits/base/ApprovalTrait.php
ApprovalTrait.isApprovable
public function isApprovable() { return $this->status == IApproval::STATUS_SUBMITTED || $this->status == IApproval::STATUS_FROJEN || $this->status == IApproval::STATUS_UPLIFT_FREEZE || $this->status == IApproval::STATUS_BLOCKED || $this->status == IApproval::STATUS_UPLIFT_BLOCK; }
php
public function isApprovable() { return $this->status == IApproval::STATUS_SUBMITTED || $this->status == IApproval::STATUS_FROJEN || $this->status == IApproval::STATUS_UPLIFT_FREEZE || $this->status == IApproval::STATUS_BLOCKED || $this->status == IApproval::STATUS_UPLIFT_BLOCK; }
[ "public", "function", "isApprovable", "(", ")", "{", "return", "$", "this", "->", "status", "==", "IApproval", "::", "STATUS_SUBMITTED", "||", "$", "this", "->", "status", "==", "IApproval", "::", "STATUS_FROJEN", "||", "$", "this", "->", "status", "==", "...
Admin can check whether the model is ready for approval in selected states i.e. frozen, uplift-freeze, blocked or uplift-block defined within this method. A model can be activated only in the states specified within this method. @return boolean
[ "Admin", "can", "check", "whether", "the", "model", "is", "ready", "for", "approval", "in", "selected", "states", "i", ".", "e", ".", "frozen", "uplift", "-", "freeze", "blocked", "or", "uplift", "-", "block", "defined", "within", "this", "method", ".", ...
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/traits/base/ApprovalTrait.php#L379-L384
39,580
paulbunyannet/bandolier
src/Bandolier/Validate/WritableLocation.php
WritableLocation.isWritable
protected function isWritable() { if (!is_writable($this->path)) { throw new LocationIsWritable( $this->getPath() . ' is not writable!', self::WRITABLE_IS_NOT_WRITABLE_ERROR ); } return true; }
php
protected function isWritable() { if (!is_writable($this->path)) { throw new LocationIsWritable( $this->getPath() . ' is not writable!', self::WRITABLE_IS_NOT_WRITABLE_ERROR ); } return true; }
[ "protected", "function", "isWritable", "(", ")", "{", "if", "(", "!", "is_writable", "(", "$", "this", "->", "path", ")", ")", "{", "throw", "new", "LocationIsWritable", "(", "$", "this", "->", "getPath", "(", ")", ".", "' is not writable!'", ",", "self"...
Check if path is writable @return bool @throws LocationIsWritable
[ "Check", "if", "path", "is", "writable" ]
a98cb30bf63a18a7e3fc81418bf561ac36e9cd84
https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Validate/WritableLocation.php#L87-L96
39,581
paulbunyannet/bandolier
src/Bandolier/Validate/WritableLocation.php
WritableLocation.isADirectory
protected function isADirectory() { if (file_exists($this->path) && !is_dir($this->path)) { throw new LocationIsADirectory( $this->getPath() .' already exists but is not a directory!', self::WRITABLE_IS_NOT_A_DIR_ERROR ); } return true; }
php
protected function isADirectory() { if (file_exists($this->path) && !is_dir($this->path)) { throw new LocationIsADirectory( $this->getPath() .' already exists but is not a directory!', self::WRITABLE_IS_NOT_A_DIR_ERROR ); } return true; }
[ "protected", "function", "isADirectory", "(", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "path", ")", "&&", "!", "is_dir", "(", "$", "this", "->", "path", ")", ")", "{", "throw", "new", "LocationIsADirectory", "(", "$", "this", "->", ...
Check if path is a directory @return bool @throws LocationIsADirectory
[ "Check", "if", "path", "is", "a", "directory" ]
a98cb30bf63a18a7e3fc81418bf561ac36e9cd84
https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Validate/WritableLocation.php#L121-L130
39,582
fxpio/fxp-cache
Adapter/FilesystemAdapter.php
FilesystemAdapter.doClearFile
private function doClearFile(&$ok, \SplFileInfo $file, $prefix): void { $keys = []; if ($file->isFile()) { $key = $this->getFileKey($file); if (null !== $key && ('' === $prefix || 0 === strpos($key, $prefix))) { $keys[] = $key; } } $ok = ($file->isDir() || $this->deleteItems($keys) || !file_exists($file)) && $ok; }
php
private function doClearFile(&$ok, \SplFileInfo $file, $prefix): void { $keys = []; if ($file->isFile()) { $key = $this->getFileKey($file); if (null !== $key && ('' === $prefix || 0 === strpos($key, $prefix))) { $keys[] = $key; } } $ok = ($file->isDir() || $this->deleteItems($keys) || !file_exists($file)) && $ok; }
[ "private", "function", "doClearFile", "(", "&", "$", "ok", ",", "\\", "SplFileInfo", "$", "file", ",", "$", "prefix", ")", ":", "void", "{", "$", "keys", "=", "[", "]", ";", "if", "(", "$", "file", "->", "isFile", "(", ")", ")", "{", "$", "key"...
Action to clear all items in file starting with the prefix. @param bool $ok The delete status @param \SplFileInfo $file The spl file info @param string $prefix The prefix
[ "Action", "to", "clear", "all", "items", "in", "file", "starting", "with", "the", "prefix", "." ]
55abf44a954890080fa2bfb080914ce7228ea769
https://github.com/fxpio/fxp-cache/blob/55abf44a954890080fa2bfb080914ce7228ea769/Adapter/FilesystemAdapter.php#L51-L64
39,583
fxpio/fxp-cache
Adapter/FilesystemAdapter.php
FilesystemAdapter.getFileKey
private function getFileKey(\SplFileInfo $file) { $key = null; if ($h = @fopen($file, 'r')) { rawurldecode(rtrim(fgets($h))); $value = stream_get_contents($h); fclose($h); $key = substr($value, 0, strpos($value, "\n")); } return $key; }
php
private function getFileKey(\SplFileInfo $file) { $key = null; if ($h = @fopen($file, 'r')) { rawurldecode(rtrim(fgets($h))); $value = stream_get_contents($h); fclose($h); $key = substr($value, 0, strpos($value, "\n")); } return $key; }
[ "private", "function", "getFileKey", "(", "\\", "SplFileInfo", "$", "file", ")", "{", "$", "key", "=", "null", ";", "if", "(", "$", "h", "=", "@", "fopen", "(", "$", "file", ",", "'r'", ")", ")", "{", "rawurldecode", "(", "rtrim", "(", "fgets", "...
Get the key of file. @param \SplFileInfo $file The spl file info @return null|string
[ "Get", "the", "key", "of", "file", "." ]
55abf44a954890080fa2bfb080914ce7228ea769
https://github.com/fxpio/fxp-cache/blob/55abf44a954890080fa2bfb080914ce7228ea769/Adapter/FilesystemAdapter.php#L73-L85
39,584
mcaskill/charcoal-support
src/App/Routing/SluggableTrait.php
SluggableTrait.url
public function url($lang = null) { if ($this->url === null) { if (!$this->id()) { return null; } $this->url = $this->generateUri(); } if ($lang && $this->url instanceof Translation) { return $this->url[$lang]; } return strval($this->url); }
php
public function url($lang = null) { if ($this->url === null) { if (!$this->id()) { return null; } $this->url = $this->generateUri(); } if ($lang && $this->url instanceof Translation) { return $this->url[$lang]; } return strval($this->url); }
[ "public", "function", "url", "(", "$", "lang", "=", "null", ")", "{", "if", "(", "$", "this", "->", "url", "===", "null", ")", "{", "if", "(", "!", "$", "this", "->", "id", "(", ")", ")", "{", "return", "null", ";", "}", "$", "this", "->", ...
Retrieve the object's URI. @param string|null $lang If object is multilingual, return the object route for the specified locale. @return Translation|string|null
[ "Retrieve", "the", "object", "s", "URI", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/App/Routing/SluggableTrait.php#L36-L51
39,585
mcaskill/charcoal-support
src/App/Routing/SluggableTrait.php
SluggableTrait.generateSlug
public function generateSlug() { $translator = $this->translator(); $languages = $translator->availableLocales(); $patterns = $this->slugPattern(); $curSlug = $this->slug(); $newSlug = []; $origLang = $translator->getLocale(); foreach ($languages as $lang) { $pattern = $patterns[$lang]; $translator->setLocale($lang); if ($this->isSlugEditable() && isset($curSlug[$lang]) && strlen($curSlug[$lang])) { $newSlug[$lang] = $curSlug[$lang]; } else { $newSlug[$lang] = $this->generateRoutePattern($pattern); if (!strlen($newSlug[$lang])) { throw new UnexpectedValueException(sprintf( 'The slug is empty; the pattern is "%s"', $pattern )); } } } $translator->setLocale($origLang); return $translator->translation($newSlug); }
php
public function generateSlug() { $translator = $this->translator(); $languages = $translator->availableLocales(); $patterns = $this->slugPattern(); $curSlug = $this->slug(); $newSlug = []; $origLang = $translator->getLocale(); foreach ($languages as $lang) { $pattern = $patterns[$lang]; $translator->setLocale($lang); if ($this->isSlugEditable() && isset($curSlug[$lang]) && strlen($curSlug[$lang])) { $newSlug[$lang] = $curSlug[$lang]; } else { $newSlug[$lang] = $this->generateRoutePattern($pattern); if (!strlen($newSlug[$lang])) { throw new UnexpectedValueException(sprintf( 'The slug is empty; the pattern is "%s"', $pattern )); } } } $translator->setLocale($origLang); return $translator->translation($newSlug); }
[ "public", "function", "generateSlug", "(", ")", "{", "$", "translator", "=", "$", "this", "->", "translator", "(", ")", ";", "$", "languages", "=", "$", "translator", "->", "availableLocales", "(", ")", ";", "$", "patterns", "=", "$", "this", "->", "sl...
Generate a URI slug from the object's URL slug pattern. Note: This method bypasses routable affixes and {@see \Charcoal\Object\ObjectRoute}. @see RoutableTrait::generateSlug() @throws UnexpectedValueException If the slug is empty. @return Translation|string|null
[ "Generate", "a", "URI", "slug", "from", "the", "object", "s", "URL", "slug", "pattern", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/App/Routing/SluggableTrait.php#L62-L90
39,586
fxpio/fxp-cache
Adapter/PhpArrayAdapter.php
PhpArrayAdapter.clearItems
private function clearItems(AdapterInterface $fallbackPool, array $prefixes) { $cleared = $fallbackPool->clearByPrefixes($prefixes); $keys = AdapterUtil::getPropertyValue($this, 'keys') ?: []; $values = AdapterUtil::getPropertyValue($this, 'values') ?: []; $warmValues = []; foreach ($keys as $key => $valuePrefix) { foreach ($prefixes as $prefix) { if ('' === $prefix || 0 !== strpos($key, $prefix)) { $warmValues[$key] = $values[$valuePrefix]; } } } if (\count($values) !== \count($warmValues)) { $this->warmUp($warmValues); } return $cleared; }
php
private function clearItems(AdapterInterface $fallbackPool, array $prefixes) { $cleared = $fallbackPool->clearByPrefixes($prefixes); $keys = AdapterUtil::getPropertyValue($this, 'keys') ?: []; $values = AdapterUtil::getPropertyValue($this, 'values') ?: []; $warmValues = []; foreach ($keys as $key => $valuePrefix) { foreach ($prefixes as $prefix) { if ('' === $prefix || 0 !== strpos($key, $prefix)) { $warmValues[$key] = $values[$valuePrefix]; } } } if (\count($values) !== \count($warmValues)) { $this->warmUp($warmValues); } return $cleared; }
[ "private", "function", "clearItems", "(", "AdapterInterface", "$", "fallbackPool", ",", "array", "$", "prefixes", ")", "{", "$", "cleared", "=", "$", "fallbackPool", "->", "clearByPrefixes", "(", "$", "prefixes", ")", ";", "$", "keys", "=", "AdapterUtil", ":...
Clear the items. @param AdapterInterface $fallbackPool The fallback pool @param string[] $prefixes The prefixes @return bool
[ "Clear", "the", "items", "." ]
55abf44a954890080fa2bfb080914ce7228ea769
https://github.com/fxpio/fxp-cache/blob/55abf44a954890080fa2bfb080914ce7228ea769/Adapter/PhpArrayAdapter.php#L66-L86
39,587
World-Architects/cakephp-fixture-check
src/Shell/FixtureCheckShell.php
FixtureCheckShell._compareFields
public function _compareFields($fixtureFields, $liveFields) { // Warn only about relevant fields $list = [ 'autoIncrement', 'default', 'length', 'null', 'precision', 'type', 'unsigned', ]; $errors = []; foreach ($fixtureFields as $fieldName => $fixtureField) { if (!isset($liveFields[$fieldName])) { $this->out('Field ' . $fieldName . ' is missing from the live DB!'); continue; } $liveField = $liveFields[$fieldName]; foreach ($fixtureField as $key => $value) { if (!in_array($key, $list)) { continue; } if (!isset($liveField[$key]) && $value !== null) { $errors[] = ' * ' . sprintf('Field attribute `%s` is missing from the live DB!', $fieldName . ':' . $key); continue; } if ($liveField[$key] !== $value) { $errors[] = ' * ' . sprintf( 'Field attribute `%s` differs from live DB! (`%s` vs `%s` live)', $fieldName . ':' . $key, Debugger::exportVar($value, true), Debugger::exportVar($liveField[$key], true) ); } } } if (!$errors) { return; } $this->warn('The following field attributes mismatch:'); $this->out($errors); $this->_issuesFound = true; $this->out($this->nl(0)); }
php
public function _compareFields($fixtureFields, $liveFields) { // Warn only about relevant fields $list = [ 'autoIncrement', 'default', 'length', 'null', 'precision', 'type', 'unsigned', ]; $errors = []; foreach ($fixtureFields as $fieldName => $fixtureField) { if (!isset($liveFields[$fieldName])) { $this->out('Field ' . $fieldName . ' is missing from the live DB!'); continue; } $liveField = $liveFields[$fieldName]; foreach ($fixtureField as $key => $value) { if (!in_array($key, $list)) { continue; } if (!isset($liveField[$key]) && $value !== null) { $errors[] = ' * ' . sprintf('Field attribute `%s` is missing from the live DB!', $fieldName . ':' . $key); continue; } if ($liveField[$key] !== $value) { $errors[] = ' * ' . sprintf( 'Field attribute `%s` differs from live DB! (`%s` vs `%s` live)', $fieldName . ':' . $key, Debugger::exportVar($value, true), Debugger::exportVar($liveField[$key], true) ); } } } if (!$errors) { return; } $this->warn('The following field attributes mismatch:'); $this->out($errors); $this->_issuesFound = true; $this->out($this->nl(0)); }
[ "public", "function", "_compareFields", "(", "$", "fixtureFields", ",", "$", "liveFields", ")", "{", "// Warn only about relevant fields", "$", "list", "=", "[", "'autoIncrement'", ",", "'default'", ",", "'length'", ",", "'null'", ",", "'precision'", ",", "'type'"...
Compare the fields present. @param array $fixtureFields The fixtures fields array. @param array $liveFields The live DB fields @return void
[ "Compare", "the", "fields", "present", "." ]
3a2add52036309c60d4d7c4dee6edd5c72bec467
https://github.com/World-Architects/cakephp-fixture-check/blob/3a2add52036309c60d4d7c4dee6edd5c72bec467/src/Shell/FixtureCheckShell.php#L140-L190
39,588
cmsgears/module-core
common/services/entities/ThemeService.php
ThemeService.makeDefault
public function makeDefault( Theme $model, $config = [] ) { $modelClass = static::$modelClass; $type = CoreGlobal::TYPE_SITE; if( $model->type !== $type ) { return false; } // Disable All $modelClass::updateAll( [ 'default' => false ], "`default`=1 AND `type`='$type'" ); // Make Default $model->default = true; // Update return parent::update( $model, [ 'attributes' => [ 'default' ] ]); }
php
public function makeDefault( Theme $model, $config = [] ) { $modelClass = static::$modelClass; $type = CoreGlobal::TYPE_SITE; if( $model->type !== $type ) { return false; } // Disable All $modelClass::updateAll( [ 'default' => false ], "`default`=1 AND `type`='$type'" ); // Make Default $model->default = true; // Update return parent::update( $model, [ 'attributes' => [ 'default' ] ]); }
[ "public", "function", "makeDefault", "(", "Theme", "$", "model", ",", "$", "config", "=", "[", "]", ")", "{", "$", "modelClass", "=", "static", "::", "$", "modelClass", ";", "$", "type", "=", "CoreGlobal", "::", "TYPE_SITE", ";", "if", "(", "$", "mod...
Make the default theme available for all sites in case no theme is selected. @param type $model @param type $config @return type
[ "Make", "the", "default", "theme", "available", "for", "all", "sites", "in", "case", "no", "theme", "is", "selected", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/ThemeService.php#L289-L310
39,589
rodrigoiii/skeleton-core
src/classes/AppPhinx.php
AppPhinx.loadEnvironment
private function loadEnvironment() { /** * Application Environment */ $required_env = [ # application configuration 'APP_NAME', 'APP_ENV', 'APP_KEY', # database configuration 'DB_HOSTNAME', 'DB_PORT', 'DB_USERNAME', 'DB_PASSWORD', 'DB_NAME', # application mode 'APP_MODE' ]; $root = $_SERVER['PWD']; $dotenv = new Dotenv($root); $dotenv->overload(); $dotenv->required($required_env); }
php
private function loadEnvironment() { /** * Application Environment */ $required_env = [ # application configuration 'APP_NAME', 'APP_ENV', 'APP_KEY', # database configuration 'DB_HOSTNAME', 'DB_PORT', 'DB_USERNAME', 'DB_PASSWORD', 'DB_NAME', # application mode 'APP_MODE' ]; $root = $_SERVER['PWD']; $dotenv = new Dotenv($root); $dotenv->overload(); $dotenv->required($required_env); }
[ "private", "function", "loadEnvironment", "(", ")", "{", "/**\n * Application Environment\n */", "$", "required_env", "=", "[", "# application configuration", "'APP_NAME'", ",", "'APP_ENV'", ",", "'APP_KEY'", ",", "# database configuration", "'DB_HOSTNAME'", "...
Load the environment of the Application Phinx. @return void
[ "Load", "the", "environment", "of", "the", "Application", "Phinx", "." ]
5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0
https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/AppPhinx.php#L51-L72
39,590
apioo/psx-http
src/Parser/ParserAbstract.php
ParserAbstract.splitMessage
protected function splitMessage($message) { if ($this->mode == self::MODE_STRICT) { $pos = strpos($message, Http::NEW_LINE . Http::NEW_LINE); $header = substr($message, 0, $pos); $body = trim(substr($message, $pos + 1)); } elseif ($this->mode == self::MODE_LOOSE) { $lines = explode("\n", $message); $header = ''; $body = ''; $found = false; $count = count($lines); foreach ($lines as $i => $line) { $line = trim($line); if (!$found && empty($line)) { $found = true; continue; } if (!$found) { $header.= $line . Http::NEW_LINE; } else { $body.= $line . ($i < $count - 1 ? "\n" : ''); } } } return array($header, $body); }
php
protected function splitMessage($message) { if ($this->mode == self::MODE_STRICT) { $pos = strpos($message, Http::NEW_LINE . Http::NEW_LINE); $header = substr($message, 0, $pos); $body = trim(substr($message, $pos + 1)); } elseif ($this->mode == self::MODE_LOOSE) { $lines = explode("\n", $message); $header = ''; $body = ''; $found = false; $count = count($lines); foreach ($lines as $i => $line) { $line = trim($line); if (!$found && empty($line)) { $found = true; continue; } if (!$found) { $header.= $line . Http::NEW_LINE; } else { $body.= $line . ($i < $count - 1 ? "\n" : ''); } } } return array($header, $body); }
[ "protected", "function", "splitMessage", "(", "$", "message", ")", "{", "if", "(", "$", "this", "->", "mode", "==", "self", "::", "MODE_STRICT", ")", "{", "$", "pos", "=", "strpos", "(", "$", "message", ",", "Http", "::", "NEW_LINE", ".", "Http", "::...
Splits an given http message into the header and body part @param string $message @return array
[ "Splits", "an", "given", "http", "message", "into", "the", "header", "and", "body", "part" ]
c54d7212cfb513df84f810429aa34c6ac9942c01
https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Parser/ParserAbstract.php#L72-L102
39,591
apioo/psx-http
src/Parser/ParserAbstract.php
ParserAbstract.headerToArray
protected function headerToArray(MessageInterface $message, $header) { $lines = explode(Http::NEW_LINE, $header); foreach ($lines as $line) { $parts = explode(':', $line, 2); if (isset($parts[0]) && isset($parts[1])) { $key = $parts[0]; $value = substr($parts[1], 1); $message->addHeader($key, $value); } } }
php
protected function headerToArray(MessageInterface $message, $header) { $lines = explode(Http::NEW_LINE, $header); foreach ($lines as $line) { $parts = explode(':', $line, 2); if (isset($parts[0]) && isset($parts[1])) { $key = $parts[0]; $value = substr($parts[1], 1); $message->addHeader($key, $value); } } }
[ "protected", "function", "headerToArray", "(", "MessageInterface", "$", "message", ",", "$", "header", ")", "{", "$", "lines", "=", "explode", "(", "Http", "::", "NEW_LINE", ",", "$", "header", ")", ";", "foreach", "(", "$", "lines", "as", "$", "line", ...
Parses an raw http header string into an Message object @param \PSX\Http\MessageInterface $message @param string $header
[ "Parses", "an", "raw", "http", "header", "string", "into", "an", "Message", "object" ]
c54d7212cfb513df84f810429aa34c6ac9942c01
https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Parser/ParserAbstract.php#L127-L141
39,592
cmsgears/module-core
common/services/traits/mappers/CategoryTrait.php
CategoryTrait.getPinnedByCategoryId
public function getPinnedByCategoryId( $categoryId, $config = [] ) { $modelClass = static::$modelClass; $modelTable = $this->getModelTable(); $config[ 'page' ] = isset( $config[ 'page' ] ) ? $config[ 'page' ] : false; $config[ 'query' ] = isset( $config[ 'query' ] ) ? $config[ 'query' ] : $modelClass::find(); $config[ 'limit' ] = isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 10; $config[ 'active' ] = isset( $config[ 'active' ] ) ? $config[ 'active' ] : true; if( $config[ 'active' ] ) { $config[ 'query' ]->joinWith( 'activeCategories' )->andWhere( [ 'modelId' => $categoryId, "$modelTable.pinned" => true ] ); } else { $config[ 'query' ]->joinWith( 'categories' )->andWhere( [ 'modelId' => $categoryId, "$modelTable.pinned" => true ] ); } if( $config[ 'page' ] ) { $page = $this->getPublicPage( $config ); return $page->getModels(); } return $config[ 'query' ]->limit( $config[ 'limit' ] )->all(); }
php
public function getPinnedByCategoryId( $categoryId, $config = [] ) { $modelClass = static::$modelClass; $modelTable = $this->getModelTable(); $config[ 'page' ] = isset( $config[ 'page' ] ) ? $config[ 'page' ] : false; $config[ 'query' ] = isset( $config[ 'query' ] ) ? $config[ 'query' ] : $modelClass::find(); $config[ 'limit' ] = isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 10; $config[ 'active' ] = isset( $config[ 'active' ] ) ? $config[ 'active' ] : true; if( $config[ 'active' ] ) { $config[ 'query' ]->joinWith( 'activeCategories' )->andWhere( [ 'modelId' => $categoryId, "$modelTable.pinned" => true ] ); } else { $config[ 'query' ]->joinWith( 'categories' )->andWhere( [ 'modelId' => $categoryId, "$modelTable.pinned" => true ] ); } if( $config[ 'page' ] ) { $page = $this->getPublicPage( $config ); return $page->getModels(); } return $config[ 'query' ]->limit( $config[ 'limit' ] )->all(); }
[ "public", "function", "getPinnedByCategoryId", "(", "$", "categoryId", ",", "$", "config", "=", "[", "]", ")", "{", "$", "modelClass", "=", "static", "::", "$", "modelClass", ";", "$", "modelTable", "=", "$", "this", "->", "getModelTable", "(", ")", ";",...
Works only with models having pinned column
[ "Works", "only", "with", "models", "having", "pinned", "column" ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/traits/mappers/CategoryTrait.php#L104-L131
39,593
cmsgears/module-core
common/components/FormDesigner.php
FormDesigner.getFieldHtml
public function getFieldHtml( $form, $model, $config, $key, $field ) { switch( $field->type ) { case FormField::TYPE_TEXT: { return $this->getTextHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_HIDDEN: { return $this->getHiddenHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_PASSWORD: { return $this->getPasswordHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_TEXTAREA: { return $this->getTextareaHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_CHECKBOX: { return $form->field( $model, $key )->checkbox( $field->htmlOptions ); } case FormField::TYPE_TOGGLE: { return $form->field( $model, $key, [ 'class' => 'switch' ] )->checkbox( $field->htmlOptions ); } case FormField::TYPE_CHECKBOX_GROUP: { return $this->getCheckboxGroupHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_RADIO: { return $form->field( $model, $key )->radio( $field->htmlOptions ); } case FormField::TYPE_RADIO_GROUP: { return $this->getRadioGroupHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_SELECT: { return $this->getSelectHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_RATING : { return $this->getRatingHtml( $form, $model, $config, $key, $field ); } } }
php
public function getFieldHtml( $form, $model, $config, $key, $field ) { switch( $field->type ) { case FormField::TYPE_TEXT: { return $this->getTextHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_HIDDEN: { return $this->getHiddenHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_PASSWORD: { return $this->getPasswordHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_TEXTAREA: { return $this->getTextareaHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_CHECKBOX: { return $form->field( $model, $key )->checkbox( $field->htmlOptions ); } case FormField::TYPE_TOGGLE: { return $form->field( $model, $key, [ 'class' => 'switch' ] )->checkbox( $field->htmlOptions ); } case FormField::TYPE_CHECKBOX_GROUP: { return $this->getCheckboxGroupHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_RADIO: { return $form->field( $model, $key )->radio( $field->htmlOptions ); } case FormField::TYPE_RADIO_GROUP: { return $this->getRadioGroupHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_SELECT: { return $this->getSelectHtml( $form, $model, $config, $key, $field ); } case FormField::TYPE_RATING : { return $this->getRatingHtml( $form, $model, $config, $key, $field ); } } }
[ "public", "function", "getFieldHtml", "(", "$", "form", ",", "$", "model", ",", "$", "config", ",", "$", "key", ",", "$", "field", ")", "{", "switch", "(", "$", "field", "->", "type", ")", "{", "case", "FormField", "::", "TYPE_TEXT", ":", "{", "ret...
Generate field html using Yii Form Widget. @param FormField $field
[ "Generate", "field", "html", "using", "Yii", "Form", "Widget", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/FormDesigner.php#L63-L112
39,594
cmsgears/module-core
common/components/FormDesigner.php
FormDesigner.getApixFieldHtml
public function getApixFieldHtml( $config, $field, $value = null ) { switch( $field->type ) { case FormField::TYPE_TEXT: { return $this->getApixTextHtml( $config, $field, $value ); } case FormField::TYPE_HIDDEN: { return $this->getApixHiddenHtml( $config, $field, $value ); } case FormField::TYPE_PASSWORD: { return $this->getApixPasswordHtml( $config, $field ); } case FormField::TYPE_TEXTAREA: { return $this->getApixTextareaHtml( $config, $field, $value ); } case FormField::TYPE_CHECKBOX: { return $this->getApixCheckboxHtml( $config, $field, $value ); } case FormField::TYPE_TOGGLE: { return $this->getApixToggleHtml( $config, $field, $value ); } case FormField::TYPE_CHECKBOX_GROUP: { return $this->getApixCheckboxGroupHtml( $config, $field, $value ); } case FormField::TYPE_RADIO: { return $this->getApixRadioHtml( $config, $field, $value ); } case FormField::TYPE_RADIO_GROUP: { return $this->getApixRadioGroupHtml( $config, $field, $value ); } case FormField::TYPE_SELECT: { return $this->getApixSelectHtml( $config, $field, $value ); } case FormField::TYPE_RATING: { return $this->getApixRatingHtml( $config, $field, $value ); } case FormField::TYPE_DATE: { return $this->getApixDateHtml( $config, $field, $value ); } } }
php
public function getApixFieldHtml( $config, $field, $value = null ) { switch( $field->type ) { case FormField::TYPE_TEXT: { return $this->getApixTextHtml( $config, $field, $value ); } case FormField::TYPE_HIDDEN: { return $this->getApixHiddenHtml( $config, $field, $value ); } case FormField::TYPE_PASSWORD: { return $this->getApixPasswordHtml( $config, $field ); } case FormField::TYPE_TEXTAREA: { return $this->getApixTextareaHtml( $config, $field, $value ); } case FormField::TYPE_CHECKBOX: { return $this->getApixCheckboxHtml( $config, $field, $value ); } case FormField::TYPE_TOGGLE: { return $this->getApixToggleHtml( $config, $field, $value ); } case FormField::TYPE_CHECKBOX_GROUP: { return $this->getApixCheckboxGroupHtml( $config, $field, $value ); } case FormField::TYPE_RADIO: { return $this->getApixRadioHtml( $config, $field, $value ); } case FormField::TYPE_RADIO_GROUP: { return $this->getApixRadioGroupHtml( $config, $field, $value ); } case FormField::TYPE_SELECT: { return $this->getApixSelectHtml( $config, $field, $value ); } case FormField::TYPE_RATING: { return $this->getApixRatingHtml( $config, $field, $value ); } case FormField::TYPE_DATE: { return $this->getApixDateHtml( $config, $field, $value ); } } }
[ "public", "function", "getApixFieldHtml", "(", "$", "config", ",", "$", "field", ",", "$", "value", "=", "null", ")", "{", "switch", "(", "$", "field", "->", "type", ")", "{", "case", "FormField", "::", "TYPE_TEXT", ":", "{", "return", "$", "this", "...
Generate field html for CMGTools JS Library. @param FormField $field
[ "Generate", "field", "html", "for", "CMGTools", "JS", "Library", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/FormDesigner.php#L347-L400
39,595
cmsgears/module-core
common/components/FormDesigner.php
FormDesigner.getRatingStars
public function getRatingStars( $config = [] ) { $class = isset( $config[ 'class' ] ) && !empty( $config[ 'class' ] ) ? $config[ 'class' ] : 'cmt-rating'; $stars = isset( $config[ 'stars' ] ) ? $config[ 'stars' ] : 5; $selected = isset( $config[ 'selected' ] ) ? $config[ 'selected' ] : 0; $disabled = isset( $config[ 'disabled' ] ) ? $config[ 'disabled' ] : false; $readonly = isset( $config[ 'readonly' ] ) ? $config[ 'readonly' ] : false; if( $disabled ) { $class = "$class disabled"; } if( $readonly ) { $class = "$class read-only"; } $ratingHtml = "<div class=\"$class\"><div class=\"wrap-stars\">"; for( $i = 1; $i <= $stars; $i++ ) { if( $selected > 0 && $selected == $i ) { $icon = "<span star=\"$i\" class=\"star selected\"></span>"; } else { $icon = "<span star=\"$i\" class=\"star\"></span>"; } $ratingHtml .= $icon; } $ratingHtml .= "</div></div>"; return $ratingHtml; }
php
public function getRatingStars( $config = [] ) { $class = isset( $config[ 'class' ] ) && !empty( $config[ 'class' ] ) ? $config[ 'class' ] : 'cmt-rating'; $stars = isset( $config[ 'stars' ] ) ? $config[ 'stars' ] : 5; $selected = isset( $config[ 'selected' ] ) ? $config[ 'selected' ] : 0; $disabled = isset( $config[ 'disabled' ] ) ? $config[ 'disabled' ] : false; $readonly = isset( $config[ 'readonly' ] ) ? $config[ 'readonly' ] : false; if( $disabled ) { $class = "$class disabled"; } if( $readonly ) { $class = "$class read-only"; } $ratingHtml = "<div class=\"$class\"><div class=\"wrap-stars\">"; for( $i = 1; $i <= $stars; $i++ ) { if( $selected > 0 && $selected == $i ) { $icon = "<span star=\"$i\" class=\"star selected\"></span>"; } else { $icon = "<span star=\"$i\" class=\"star\"></span>"; } $ratingHtml .= $icon; } $ratingHtml .= "</div></div>"; return $ratingHtml; }
[ "public", "function", "getRatingStars", "(", "$", "config", "=", "[", "]", ")", "{", "$", "class", "=", "isset", "(", "$", "config", "[", "'class'", "]", ")", "&&", "!", "empty", "(", "$", "config", "[", "'class'", "]", ")", "?", "$", "config", "...
Generate and return stars html without field. Field must be added within same parent in case selected value has to be preserved. @param type $config @return string
[ "Generate", "and", "return", "stars", "html", "without", "field", ".", "Field", "must", "be", "added", "within", "same", "parent", "in", "case", "selected", "value", "has", "to", "be", "preserved", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/FormDesigner.php#L1130-L1167
39,596
cmsgears/module-core
common/components/FormDesigner.php
FormDesigner.getRatingField
public function getRatingField( $config = [] ) { $class = isset( $config[ 'class' ] ) && !empty( $config[ 'class' ] ) ? $config[ 'class' ] : 'cmt-rating'; $stars = isset( $config[ 'stars' ] ) ? $config[ 'stars' ] : 5; $label = isset( $config[ 'label' ] ) ? $config[ 'label' ] : null; $readOnly = isset( $config[ 'readOnly' ] ) ? $config[ 'readOnly' ] : false; $selected = isset( $config[ 'selected' ] ) ? $config[ 'selected' ] : 0; $disabled = isset( $config[ 'disabled' ] ) ? $config[ 'disabled' ] : false; // By default message provided for 5 stars $starMessage = isset( $config[ 'message' ] ) ? $config[ 'message' ] : [ "Poor", "Good", "Very Good", "Perfect", "Excellent" ]; $modelName = $config[ 'modelName' ]; $fieldName = isset( $config[ 'fieldName' ] ) ? $config[ 'fieldName' ] : 'rating'; $fieldName = $modelName . "[$fieldName]"; if( $readOnly ) { $class = "$class read-only"; } if( $disabled ) { $class = "$class disabled"; } if( isset( $label ) ) { // element-60 will work if form is configured for 40-60 split, else it will behave as normal field $ratingHtml = "<label>$label</label><div class=\"element-60 $class\">"; } else { $ratingHtml = "<div class=\"$class\">"; } $ratingHtml .= '<span class="wrap-stars">'; for( $i = 1; $i <= $stars; $i++ ) { if( $selected == $i ) { $icon = "<span star=\"$i\" class=\"star selected\"></span>"; } else { $icon = "<span star=\"$i\" class=\"star\"></span>"; } $ratingHtml .= $icon; } $ratingHtml .= '</span>'; $ratingHtml .= '<span class="wrap-messages">'; for( $i = 1; $i <= $stars; $i++ ) { $message = $starMessage[ $i - 1 ]; if( $selected == $i ) { $icon = "<span star-message=\"$i\" class=\"star-message selected\">$message</span>"; } else { $icon = "<span star-message=\"$i\" class=\"star-message\">$message</span>"; } $ratingHtml .= $icon; } $ratingHtml .= '</span>'; $ratingHtml .= '<input class="star-selected" type="hidden" name="' . $fieldName . '" value="' . $selected . '">'; $ratingHtml .= "</div>"; return $ratingHtml; }
php
public function getRatingField( $config = [] ) { $class = isset( $config[ 'class' ] ) && !empty( $config[ 'class' ] ) ? $config[ 'class' ] : 'cmt-rating'; $stars = isset( $config[ 'stars' ] ) ? $config[ 'stars' ] : 5; $label = isset( $config[ 'label' ] ) ? $config[ 'label' ] : null; $readOnly = isset( $config[ 'readOnly' ] ) ? $config[ 'readOnly' ] : false; $selected = isset( $config[ 'selected' ] ) ? $config[ 'selected' ] : 0; $disabled = isset( $config[ 'disabled' ] ) ? $config[ 'disabled' ] : false; // By default message provided for 5 stars $starMessage = isset( $config[ 'message' ] ) ? $config[ 'message' ] : [ "Poor", "Good", "Very Good", "Perfect", "Excellent" ]; $modelName = $config[ 'modelName' ]; $fieldName = isset( $config[ 'fieldName' ] ) ? $config[ 'fieldName' ] : 'rating'; $fieldName = $modelName . "[$fieldName]"; if( $readOnly ) { $class = "$class read-only"; } if( $disabled ) { $class = "$class disabled"; } if( isset( $label ) ) { // element-60 will work if form is configured for 40-60 split, else it will behave as normal field $ratingHtml = "<label>$label</label><div class=\"element-60 $class\">"; } else { $ratingHtml = "<div class=\"$class\">"; } $ratingHtml .= '<span class="wrap-stars">'; for( $i = 1; $i <= $stars; $i++ ) { if( $selected == $i ) { $icon = "<span star=\"$i\" class=\"star selected\"></span>"; } else { $icon = "<span star=\"$i\" class=\"star\"></span>"; } $ratingHtml .= $icon; } $ratingHtml .= '</span>'; $ratingHtml .= '<span class="wrap-messages">'; for( $i = 1; $i <= $stars; $i++ ) { $message = $starMessage[ $i - 1 ]; if( $selected == $i ) { $icon = "<span star-message=\"$i\" class=\"star-message selected\">$message</span>"; } else { $icon = "<span star-message=\"$i\" class=\"star-message\">$message</span>"; } $ratingHtml .= $icon; } $ratingHtml .= '</span>'; $ratingHtml .= '<input class="star-selected" type="hidden" name="' . $fieldName . '" value="' . $selected . '">'; $ratingHtml .= "</div>"; return $ratingHtml; }
[ "public", "function", "getRatingField", "(", "$", "config", "=", "[", "]", ")", "{", "$", "class", "=", "isset", "(", "$", "config", "[", "'class'", "]", ")", "&&", "!", "empty", "(", "$", "config", "[", "'class'", "]", ")", "?", "$", "config", "...
Generate and return stars html with hidden field. @param type $config @return string
[ "Generate", "and", "return", "stars", "html", "with", "hidden", "field", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/FormDesigner.php#L1175-L1254
39,597
Innmind/AMQP
src/Model/Exchange/Declaration.php
Declaration.passive
public static function passive(string $name, Type $type): self { $self = new self($name, $type); $self->passive = true; return $self; }
php
public static function passive(string $name, Type $type): self { $self = new self($name, $type); $self->passive = true; return $self; }
[ "public", "static", "function", "passive", "(", "string", "$", "name", ",", "Type", "$", "type", ")", ":", "self", "{", "$", "self", "=", "new", "self", "(", "$", "name", ",", "$", "type", ")", ";", "$", "self", "->", "passive", "=", "true", ";",...
Check if the exchange with the given name exists on the server
[ "Check", "if", "the", "exchange", "with", "the", "given", "name", "exists", "on", "the", "server" ]
c22b3a8f56162f7845a13c149cb3118e5fe7cffd
https://github.com/Innmind/AMQP/blob/c22b3a8f56162f7845a13c149cb3118e5fe7cffd/src/Model/Exchange/Declaration.php#L32-L38
39,598
Innmind/AMQP
src/Model/Exchange/Declaration.php
Declaration.durable
public static function durable(string $name, Type $type): self { $self = new self($name, $type); $self->durable = true; return $self; }
php
public static function durable(string $name, Type $type): self { $self = new self($name, $type); $self->durable = true; return $self; }
[ "public", "static", "function", "durable", "(", "string", "$", "name", ",", "Type", "$", "type", ")", ":", "self", "{", "$", "self", "=", "new", "self", "(", "$", "name", ",", "$", "type", ")", ";", "$", "self", "->", "durable", "=", "true", ";",...
The exchange will survive after a server restart
[ "The", "exchange", "will", "survive", "after", "a", "server", "restart" ]
c22b3a8f56162f7845a13c149cb3118e5fe7cffd
https://github.com/Innmind/AMQP/blob/c22b3a8f56162f7845a13c149cb3118e5fe7cffd/src/Model/Exchange/Declaration.php#L43-L49
39,599
Innmind/AMQP
src/Model/Exchange/Declaration.php
Declaration.autoDelete
public static function autoDelete(string $name, Type $type): self { $self = new self($name, $type); $self->autoDelete = true; $self->durable = false; return $self; }
php
public static function autoDelete(string $name, Type $type): self { $self = new self($name, $type); $self->autoDelete = true; $self->durable = false; return $self; }
[ "public", "static", "function", "autoDelete", "(", "string", "$", "name", ",", "Type", "$", "type", ")", ":", "self", "{", "$", "self", "=", "new", "self", "(", "$", "name", ",", "$", "type", ")", ";", "$", "self", "->", "autoDelete", "=", "true", ...
The exchange will disappear once it's no longer used
[ "The", "exchange", "will", "disappear", "once", "it", "s", "no", "longer", "used" ]
c22b3a8f56162f7845a13c149cb3118e5fe7cffd
https://github.com/Innmind/AMQP/blob/c22b3a8f56162f7845a13c149cb3118e5fe7cffd/src/Model/Exchange/Declaration.php#L62-L69