repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
brightnucleus/dependencies | src/DependencyManager.php | DependencyManager.enqueue_fallback_handle | protected function enqueue_fallback_handle( $handle ) {
$result = false;
foreach ( $this->handlers as $handler ) {
$result = $result || $handler->maybe_enqueue( $handle );
}
return $result;
} | php | protected function enqueue_fallback_handle( $handle ) {
$result = false;
foreach ( $this->handlers as $handler ) {
$result = $result || $handler->maybe_enqueue( $handle );
}
return $result;
} | [
"protected",
"function",
"enqueue_fallback_handle",
"(",
"$",
"handle",
")",
"{",
"$",
"result",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"handler",
")",
"{",
"$",
"result",
"=",
"$",
"result",
"||",
"$",
"handler",
... | Enqueue a single dependency from the WP-registered dependencies,
retrieved by its handle.
@since 0.2.4
@param string $handle The dependency handle to enqueue.
@return bool Returns whether the handle was found or not. | [
"Enqueue",
"a",
"single",
"dependency",
"from",
"the",
"WP",
"-",
"registered",
"dependencies",
"retrieved",
"by",
"its",
"handle",
"."
] | b51ba30c32d98817b34ca710382a633bb4138a7b | https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L389-L395 | train |
brightnucleus/dependencies | src/DependencyManager.php | DependencyManager.enqueue_dependency_type | protected function enqueue_dependency_type( $dependencies, $dependency_type, $context = null ) {
$context['dependency_type'] = $dependency_type;
array_walk( $dependencies, [ $this, 'enqueue_dependency' ], $context );
} | php | protected function enqueue_dependency_type( $dependencies, $dependency_type, $context = null ) {
$context['dependency_type'] = $dependency_type;
array_walk( $dependencies, [ $this, 'enqueue_dependency' ], $context );
} | [
"protected",
"function",
"enqueue_dependency_type",
"(",
"$",
"dependencies",
",",
"$",
"dependency_type",
",",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"context",
"[",
"'dependency_type'",
"]",
"=",
"$",
"dependency_type",
";",
"array_walk",
"(",
"$",
"dep... | Enqueue all dependencies of a specific type.
@since 0.1.0
@param array $dependencies The dependencies to enqueue.
@param string $dependency_type The type of the dependencies.
@param mixed $context Optional. The context to pass to the
dependencies. | [
"Enqueue",
"all",
"dependencies",
"of",
"a",
"specific",
"type",
"."
] | b51ba30c32d98817b34ca710382a633bb4138a7b | https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L407-L410 | train |
brightnucleus/dependencies | src/DependencyManager.php | DependencyManager.register_dependency_type | protected function register_dependency_type( $dependencies, $dependency_type, $context = null ) {
$context['dependency_type'] = $dependency_type;
array_walk( $dependencies, [ $this, 'register_dependency' ], $context );
} | php | protected function register_dependency_type( $dependencies, $dependency_type, $context = null ) {
$context['dependency_type'] = $dependency_type;
array_walk( $dependencies, [ $this, 'register_dependency' ], $context );
} | [
"protected",
"function",
"register_dependency_type",
"(",
"$",
"dependencies",
",",
"$",
"dependency_type",
",",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"context",
"[",
"'dependency_type'",
"]",
"=",
"$",
"dependency_type",
";",
"array_walk",
"(",
"$",
"de... | Register all dependencies of a specific type.
@since 0.1.0
@param array $dependencies The dependencies to register.
@param string $dependency_type The type of the dependencies.
@param mixed $context Optional. The context to pass to the
dependencies. | [
"Register",
"all",
"dependencies",
"of",
"a",
"specific",
"type",
"."
] | b51ba30c32d98817b34ca710382a633bb4138a7b | https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L422-L425 | train |
brightnucleus/dependencies | src/DependencyManager.php | DependencyManager.register_dependency | protected function register_dependency( $dependency, $dependency_key, $context = null ) {
$handler = $this->handlers[ $context['dependency_type'] ];
$handler->register( $dependency );
if ( $this->enqueue_immediately ) {
$this->register_enqueue_hooks( $dependency, $context );
}
} | php | protected function register_dependency( $dependency, $dependency_key, $context = null ) {
$handler = $this->handlers[ $context['dependency_type'] ];
$handler->register( $dependency );
if ( $this->enqueue_immediately ) {
$this->register_enqueue_hooks( $dependency, $context );
}
} | [
"protected",
"function",
"register_dependency",
"(",
"$",
"dependency",
",",
"$",
"dependency_key",
",",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"handler",
"=",
"$",
"this",
"->",
"handlers",
"[",
"$",
"context",
"[",
"'dependency_type'",
"]",
"]",
";"... | Register a single dependency.
@since 0.1.0
@param array $dependency Configuration data of the dependency.
@param string $dependency_key Config key of the dependency.
@param mixed $context Optional. Context to pass to the
dependencies. Contains the type of the
dependency at key
'dependency_type'. | [
"Register",
"a",
"single",
"dependency",
"."
] | b51ba30c32d98817b34ca710382a633bb4138a7b | https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L439-L446 | train |
brightnucleus/dependencies | src/DependencyManager.php | DependencyManager.register_enqueue_hooks | protected function register_enqueue_hooks( $dependency, $context = null ) {
$priority = $this->get_priority( $dependency );
foreach ( [ 'wp_enqueue_scripts', 'admin_enqueue_scripts' ] as $hook ) {
add_action( $hook, [ $this, 'enqueue' ], $priority, 1 );
}
$this->maybe_localize( $dependency, $context );
$this->maybe_add_inline_script( $dependency, $context );
} | php | protected function register_enqueue_hooks( $dependency, $context = null ) {
$priority = $this->get_priority( $dependency );
foreach ( [ 'wp_enqueue_scripts', 'admin_enqueue_scripts' ] as $hook ) {
add_action( $hook, [ $this, 'enqueue' ], $priority, 1 );
}
$this->maybe_localize( $dependency, $context );
$this->maybe_add_inline_script( $dependency, $context );
} | [
"protected",
"function",
"register_enqueue_hooks",
"(",
"$",
"dependency",
",",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"priority",
"=",
"$",
"this",
"->",
"get_priority",
"(",
"$",
"dependency",
")",
";",
"foreach",
"(",
"[",
"'wp_enqueue_scripts'",
","... | Register the enqueueing to WordPress hooks.
@since 0.2.2
@param array $dependency Configuration data of the dependency.
@param mixed $context Optional. Context to pass to the dependencies.
Contains the type of the dependency at key
'dependency_type'. | [
"Register",
"the",
"enqueueing",
"to",
"WordPress",
"hooks",
"."
] | b51ba30c32d98817b34ca710382a633bb4138a7b | https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L458-L467 | train |
symbiote-library/silverstripe-elastica | src/Symbiote/Elastica/DataDiscovery.php | DataDiscovery.updateElasticMappings | public function updateElasticMappings($mappings)
{
$mappings['BoostTerms'] = ['type' => 'keyword'];
$mappings['Categories'] = ['type' => 'keyword'];
$mappings['Keywords'] = ['type' => 'text'];
$mappings['Tags'] = ['type' => 'keyword'];
if ($this->owner instanceof \SiteTree) {
// store the SS_URL for consistency
$mappings['SS_URL'] = ['type' => 'text'];
}
} | php | public function updateElasticMappings($mappings)
{
$mappings['BoostTerms'] = ['type' => 'keyword'];
$mappings['Categories'] = ['type' => 'keyword'];
$mappings['Keywords'] = ['type' => 'text'];
$mappings['Tags'] = ['type' => 'keyword'];
if ($this->owner instanceof \SiteTree) {
// store the SS_URL for consistency
$mappings['SS_URL'] = ['type' => 'text'];
}
} | [
"public",
"function",
"updateElasticMappings",
"(",
"$",
"mappings",
")",
"{",
"$",
"mappings",
"[",
"'BoostTerms'",
"]",
"=",
"[",
"'type'",
"=>",
"'keyword'",
"]",
";",
"$",
"mappings",
"[",
"'Categories'",
"]",
"=",
"[",
"'type'",
"=>",
"'keyword'",
"]"... | Sets appropriate mappings for fields that need to be subsequently faceted upon
@param type $mappings | [
"Sets",
"appropriate",
"mappings",
"for",
"fields",
"that",
"need",
"to",
"be",
"subsequently",
"faceted",
"upon"
] | 8d978034fb5191d06906206830a80f6caa788f6a | https://github.com/symbiote-library/silverstripe-elastica/blob/8d978034fb5191d06906206830a80f6caa788f6a/src/Symbiote/Elastica/DataDiscovery.php#L29-L41 | train |
phptuts/StarterBundleForSymfony | src/Service/FormSerializer.php | FormSerializer.createFormErrorArray | public function createFormErrorArray(Form $data)
{
$form = [];
$errors = [];
foreach ($data->getErrors() as $error) {
$errors[] = $this->getErrorMessage($error);
}
if ($errors) {
$form['errors'] = $errors;
}
$children = [];
foreach ($data->all() as $child) {
if ($child instanceof Form) {
$children[$child->getName()] = $this->createFormErrorArray($child);
}
}
if ($children) {
$form['children'] = $children;
}
return $form;
} | php | public function createFormErrorArray(Form $data)
{
$form = [];
$errors = [];
foreach ($data->getErrors() as $error) {
$errors[] = $this->getErrorMessage($error);
}
if ($errors) {
$form['errors'] = $errors;
}
$children = [];
foreach ($data->all() as $child) {
if ($child instanceof Form) {
$children[$child->getName()] = $this->createFormErrorArray($child);
}
}
if ($children) {
$form['children'] = $children;
}
return $form;
} | [
"public",
"function",
"createFormErrorArray",
"(",
"Form",
"$",
"data",
")",
"{",
"$",
"form",
"=",
"[",
"]",
";",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"->",
"getErrors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"$",
"er... | Recursively loops through the form object and returns an array of errors
@param Form $data
@return array | [
"Recursively",
"loops",
"through",
"the",
"form",
"object",
"and",
"returns",
"an",
"array",
"of",
"errors"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/FormSerializer.php#L37-L61 | train |
dadajuice/zephyrus | src/Zephyrus/Application/Controller.php | Controller.ssePolling | protected function ssePolling($data, $eventId = 'stream', $retry = 1000): Response
{
return ResponseFactory::getInstance()->buildPollingSse($data, $eventId, $retry);
} | php | protected function ssePolling($data, $eventId = 'stream', $retry = 1000): Response
{
return ResponseFactory::getInstance()->buildPollingSse($data, $eventId, $retry);
} | [
"protected",
"function",
"ssePolling",
"(",
"$",
"data",
",",
"$",
"eventId",
"=",
"'stream'",
",",
"$",
"retry",
"=",
"1000",
")",
":",
"Response",
"{",
"return",
"ResponseFactory",
"::",
"getInstance",
"(",
")",
"->",
"buildPollingSse",
"(",
"$",
"data",... | Does a simple server-sent event response which will do a simple polling.
@param mixed $data
@param string $eventId
@param int $retry
@return Response | [
"Does",
"a",
"simple",
"server",
"-",
"sent",
"event",
"response",
"which",
"will",
"do",
"a",
"simple",
"polling",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Controller.php#L148-L151 | train |
dadajuice/zephyrus | src/Zephyrus/Application/Controller.php | Controller.sseStreaming | protected function sseStreaming($callback, $eventId = 'stream', $sleep = 1): Response
{
return ResponseFactory::getInstance()->buildStreamingSse($callback, $eventId, $sleep);
} | php | protected function sseStreaming($callback, $eventId = 'stream', $sleep = 1): Response
{
return ResponseFactory::getInstance()->buildStreamingSse($callback, $eventId, $sleep);
} | [
"protected",
"function",
"sseStreaming",
"(",
"$",
"callback",
",",
"$",
"eventId",
"=",
"'stream'",
",",
"$",
"sleep",
"=",
"1",
")",
":",
"Response",
"{",
"return",
"ResponseFactory",
"::",
"getInstance",
"(",
")",
"->",
"buildStreamingSse",
"(",
"$",
"c... | Does a streaming server-sent event response which will loop and execute
the specified callback indefinitely and update the client only when
needed.
@param $callback
@param string $eventId
@param int $retry
@return Response | [
"Does",
"a",
"streaming",
"server",
"-",
"sent",
"event",
"response",
"which",
"will",
"loop",
"and",
"execute",
"the",
"specified",
"callback",
"indefinitely",
"and",
"update",
"the",
"client",
"only",
"when",
"needed",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Controller.php#L163-L166 | train |
webeweb/core-bundle | Twig/Extension/Plugin/AbstractMaterialDesignColorPaletteTwigExtension.php | AbstractMaterialDesignColorPaletteTwigExtension.materialDesignColorPalette | protected function materialDesignColorPalette($type, $name, $value) {
$color = $this->getColors()[0];
foreach ($this->getColors() as $current) {
if ($name !== $current->getName()) {
continue;
}
$color = $current;
}
$html = [];
$html[] = "mdc";
$html[] = $type;
$html[] = $color->getName();
if (null !== $value && true === array_key_exists($value, $color->getColors())) {
$html[] = $value;
}
return implode("-", $html);
} | php | protected function materialDesignColorPalette($type, $name, $value) {
$color = $this->getColors()[0];
foreach ($this->getColors() as $current) {
if ($name !== $current->getName()) {
continue;
}
$color = $current;
}
$html = [];
$html[] = "mdc";
$html[] = $type;
$html[] = $color->getName();
if (null !== $value && true === array_key_exists($value, $color->getColors())) {
$html[] = $value;
}
return implode("-", $html);
} | [
"protected",
"function",
"materialDesignColorPalette",
"(",
"$",
"type",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"color",
"=",
"$",
"this",
"->",
"getColors",
"(",
")",
"[",
"0",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getColors",
"... | Displays a Material Design Color Palette.
@param string $type The type.
@param string $name The name.
@param string $value The value.
@return string Returns the Material Design Color Palette. | [
"Displays",
"a",
"Material",
"Design",
"Color",
"Palette",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/Plugin/AbstractMaterialDesignColorPaletteTwigExtension.php#L62-L83 | train |
Mihai-P/yii2-core | components/TagsBehavior.php | TagsBehavior.getTags | public function getTags() {
return implode(",", array_keys(ArrayHelper::map($this->owner->getModelTags()->asArray()->all(), 'name', 'name')));
} | php | public function getTags() {
return implode(",", array_keys(ArrayHelper::map($this->owner->getModelTags()->asArray()->all(), 'name', 'name')));
} | [
"public",
"function",
"getTags",
"(",
")",
"{",
"return",
"implode",
"(",
"\",\"",
",",
"array_keys",
"(",
"ArrayHelper",
"::",
"map",
"(",
"$",
"this",
"->",
"owner",
"->",
"getModelTags",
"(",
")",
"->",
"asArray",
"(",
")",
"->",
"all",
"(",
")",
... | Get the tags separated by ','. It uses the relation called modelTags from the model
@return string | [
"Get",
"the",
"tags",
"separated",
"by",
".",
"It",
"uses",
"the",
"relation",
"called",
"modelTags",
"from",
"the",
"model"
] | c52753c9c8e133b2f1ca708ae02178b51eb2e5a3 | https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/TagsBehavior.php#L63-L65 | train |
Mihai-P/yii2-core | components/TagsBehavior.php | TagsBehavior.tagsRelationTable | public function tagsRelationTable() {
$model_name = $this->owner->formName();
if($model_name > 'Tag') {
$relationship_table = 'Tag_' . $model_name;
} else {
$relationship_table = $model_name . '_Tag';
}
return $relationship_table;
} | php | public function tagsRelationTable() {
$model_name = $this->owner->formName();
if($model_name > 'Tag') {
$relationship_table = 'Tag_' . $model_name;
} else {
$relationship_table = $model_name . '_Tag';
}
return $relationship_table;
} | [
"public",
"function",
"tagsRelationTable",
"(",
")",
"{",
"$",
"model_name",
"=",
"$",
"this",
"->",
"owner",
"->",
"formName",
"(",
")",
";",
"if",
"(",
"$",
"model_name",
">",
"'Tag'",
")",
"{",
"$",
"relationship_table",
"=",
"'Tag_'",
".",
"$",
"mo... | Get the name of the relationship table
@return string | [
"Get",
"the",
"name",
"of",
"the",
"relationship",
"table"
] | c52753c9c8e133b2f1ca708ae02178b51eb2e5a3 | https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/TagsBehavior.php#L80-L88 | train |
dadajuice/zephyrus | src/Zephyrus/Database/TransactionPDO.php | TransactionPDO.beginTransaction | public function beginTransaction()
{
if ($this->currentTransactionLevel == 0 || !$this->nestable()) {
parent::beginTransaction();
} else {
$this->exec("SAVEPOINT LEVEL{$this->currentTransactionLevel}");
}
++$this->currentTransactionLevel;
return true;
} | php | public function beginTransaction()
{
if ($this->currentTransactionLevel == 0 || !$this->nestable()) {
parent::beginTransaction();
} else {
$this->exec("SAVEPOINT LEVEL{$this->currentTransactionLevel}");
}
++$this->currentTransactionLevel;
return true;
} | [
"public",
"function",
"beginTransaction",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentTransactionLevel",
"==",
"0",
"||",
"!",
"$",
"this",
"->",
"nestable",
"(",
")",
")",
"{",
"parent",
"::",
"beginTransaction",
"(",
")",
";",
"}",
"else",
"... | PDO begin transaction override to work with savepoint capabilities for
supported SGBD. Allows nested transactions. | [
"PDO",
"begin",
"transaction",
"override",
"to",
"work",
"with",
"savepoint",
"capabilities",
"for",
"supported",
"SGBD",
".",
"Allows",
"nested",
"transactions",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Database/TransactionPDO.php#L16-L25 | train |
dadajuice/zephyrus | src/Zephyrus/Database/TransactionPDO.php | TransactionPDO.commit | public function commit()
{
--$this->currentTransactionLevel;
if ($this->currentTransactionLevel == 0 || !$this->nestable()) {
parent::commit();
} else {
$this->exec("RELEASE SAVEPOINT LEVEL{$this->currentTransactionLevel}");
}
} | php | public function commit()
{
--$this->currentTransactionLevel;
if ($this->currentTransactionLevel == 0 || !$this->nestable()) {
parent::commit();
} else {
$this->exec("RELEASE SAVEPOINT LEVEL{$this->currentTransactionLevel}");
}
} | [
"public",
"function",
"commit",
"(",
")",
"{",
"--",
"$",
"this",
"->",
"currentTransactionLevel",
";",
"if",
"(",
"$",
"this",
"->",
"currentTransactionLevel",
"==",
"0",
"||",
"!",
"$",
"this",
"->",
"nestable",
"(",
")",
")",
"{",
"parent",
"::",
"c... | PDO commit override to work with savepoint capabilities for supported
SGBD. Allows nested transactions. | [
"PDO",
"commit",
"override",
"to",
"work",
"with",
"savepoint",
"capabilities",
"for",
"supported",
"SGBD",
".",
"Allows",
"nested",
"transactions",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Database/TransactionPDO.php#L31-L39 | train |
dadajuice/zephyrus | src/Zephyrus/Database/TransactionPDO.php | TransactionPDO.rollBack | public function rollBack()
{
--$this->currentTransactionLevel;
if ($this->currentTransactionLevel == 0 || !$this->nestable()) {
parent::rollBack();
} else {
$this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->currentTransactionLevel}");
}
} | php | public function rollBack()
{
--$this->currentTransactionLevel;
if ($this->currentTransactionLevel == 0 || !$this->nestable()) {
parent::rollBack();
} else {
$this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->currentTransactionLevel}");
}
} | [
"public",
"function",
"rollBack",
"(",
")",
"{",
"--",
"$",
"this",
"->",
"currentTransactionLevel",
";",
"if",
"(",
"$",
"this",
"->",
"currentTransactionLevel",
"==",
"0",
"||",
"!",
"$",
"this",
"->",
"nestable",
"(",
")",
")",
"{",
"parent",
"::",
... | PDO rollback override to work with savepoint capabilities for
supported SGBD. Allows nested transactions. | [
"PDO",
"rollback",
"override",
"to",
"work",
"with",
"savepoint",
"capabilities",
"for",
"supported",
"SGBD",
".",
"Allows",
"nested",
"transactions",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Database/TransactionPDO.php#L45-L53 | train |
reliv/Rcm | core/src/Repository/Site.php | Site.getSiteInfo | public function getSiteInfo($siteId)
{
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select(
'partial site.{
owner,
theme,
status,
favIcon,
loginPage,
notAuthorizedPage,
siteLayout,
siteTitle,
siteId
},
language,
country'
)->from(\Rcm\Entity\Site::class, 'site')
->join('site.country', 'country')
->join('site.language', 'language')
->where('site.siteId = :siteId')
->setParameter('siteId', $siteId);
try {
return $queryBuilder->getQuery()->getSingleResult(
Query::HYDRATE_ARRAY
);
} catch (NoResultException $e) {
return null;
}
} | php | public function getSiteInfo($siteId)
{
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select(
'partial site.{
owner,
theme,
status,
favIcon,
loginPage,
notAuthorizedPage,
siteLayout,
siteTitle,
siteId
},
language,
country'
)->from(\Rcm\Entity\Site::class, 'site')
->join('site.country', 'country')
->join('site.language', 'language')
->where('site.siteId = :siteId')
->setParameter('siteId', $siteId);
try {
return $queryBuilder->getQuery()->getSingleResult(
Query::HYDRATE_ARRAY
);
} catch (NoResultException $e) {
return null;
}
} | [
"public",
"function",
"getSiteInfo",
"(",
"$",
"siteId",
")",
"{",
"/** @var \\Doctrine\\ORM\\QueryBuilder $queryBuilder */",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"... | Get Site Info
@param integer $siteId Site Id
@return mixed|null | [
"Get",
"Site",
"Info"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Site.php#L40-L71 | train |
reliv/Rcm | core/src/Repository/Site.php | Site.getSites | public function getSites($mustBeActive = false)
{
$repo = $this->_em
->getRepository(\Rcm\Entity\Site::class);
if ($mustBeActive) {
return $repo->findBy(['status' => \Rcm\Entity\Site::STATUS_ACTIVE]);
} else {
return $repo->findAll();
}
} | php | public function getSites($mustBeActive = false)
{
$repo = $this->_em
->getRepository(\Rcm\Entity\Site::class);
if ($mustBeActive) {
return $repo->findBy(['status' => \Rcm\Entity\Site::STATUS_ACTIVE]);
} else {
return $repo->findAll();
}
} | [
"public",
"function",
"getSites",
"(",
"$",
"mustBeActive",
"=",
"false",
")",
"{",
"$",
"repo",
"=",
"$",
"this",
"->",
"_em",
"->",
"getRepository",
"(",
"\\",
"Rcm",
"\\",
"Entity",
"\\",
"Site",
"::",
"class",
")",
";",
"if",
"(",
"$",
"mustBeAct... | Get All Active Site Objects
@param bool $mustBeActive
@return array array of site objects | [
"Get",
"All",
"Active",
"Site",
"Objects"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Site.php#L80-L89 | train |
reliv/Rcm | core/src/Repository/Site.php | Site.isValidSiteId | public function isValidSiteId($siteId, $checkActive = false)
{
if (empty($siteId) || !is_numeric($siteId)) {
return false;
}
if ($checkActive && in_array($siteId, $this->activeSiteIdCache)) {
return true;
}
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select('site.siteId')
->from(\Rcm\Entity\Site::class, 'site')
->where('site.siteId = :siteId')
->setParameter('siteId', $siteId);
if ($checkActive) {
$queryBuilder->andWhere('site.status = :status');
$queryBuilder->setParameter('status', \Rcm\Entity\Site::STATUS_ACTIVE);
}
$result = $queryBuilder->getQuery()->getScalarResult();
if (!empty($result)) {
if ($checkActive) {
$this->activeSiteIdCache[] = $siteId;
}
return true;
}
return false;
} | php | public function isValidSiteId($siteId, $checkActive = false)
{
if (empty($siteId) || !is_numeric($siteId)) {
return false;
}
if ($checkActive && in_array($siteId, $this->activeSiteIdCache)) {
return true;
}
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select('site.siteId')
->from(\Rcm\Entity\Site::class, 'site')
->where('site.siteId = :siteId')
->setParameter('siteId', $siteId);
if ($checkActive) {
$queryBuilder->andWhere('site.status = :status');
$queryBuilder->setParameter('status', \Rcm\Entity\Site::STATUS_ACTIVE);
}
$result = $queryBuilder->getQuery()->getScalarResult();
if (!empty($result)) {
if ($checkActive) {
$this->activeSiteIdCache[] = $siteId;
}
return true;
}
return false;
} | [
"public",
"function",
"isValidSiteId",
"(",
"$",
"siteId",
",",
"$",
"checkActive",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"siteId",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"siteId",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
... | Is Valid Site Id
@param integer $siteId Site Id To Check
@param boolean $checkActive Should only check active sites. Default: true
@return boolean | [
"Is",
"Valid",
"Site",
"Id"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Site.php#L99-L131 | train |
reliv/Rcm | core/src/Repository/Site.php | Site.getSiteByDomain | public function getSiteByDomain($domain)
{
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select('domain, site, primaryDomain')
->from(\Rcm\Entity\Domain::class, 'domain')
->leftJoin('domain.site', 'site')
->leftJoin('domain.primaryDomain', 'primaryDomain')
->where('domain.domain = :domainName')
->setParameter('domainName', $domain);
try {
/** @var \Rcm\Entity\Domain $domain */
$domain = $queryBuilder->getQuery()->getSingleResult();
} catch (NoResultException $e) {
return null;
}
if ($domain->getPrimary()) {
$site = $domain->getPrimary()->getSite();
$this->_em->detach($site);
$this->_em->detach($domain);
$site->setDomain($domain);
} else {
$site = $domain->getSite();
}
return $site;
} | php | public function getSiteByDomain($domain)
{
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select('domain, site, primaryDomain')
->from(\Rcm\Entity\Domain::class, 'domain')
->leftJoin('domain.site', 'site')
->leftJoin('domain.primaryDomain', 'primaryDomain')
->where('domain.domain = :domainName')
->setParameter('domainName', $domain);
try {
/** @var \Rcm\Entity\Domain $domain */
$domain = $queryBuilder->getQuery()->getSingleResult();
} catch (NoResultException $e) {
return null;
}
if ($domain->getPrimary()) {
$site = $domain->getPrimary()->getSite();
$this->_em->detach($site);
$this->_em->detach($domain);
$site->setDomain($domain);
} else {
$site = $domain->getSite();
}
return $site;
} | [
"public",
"function",
"getSiteByDomain",
"(",
"$",
"domain",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"'domain, site, primaryDomain'",
")",
"->",
"from",
... | Gets site from db by domain name
@param $domain
@return null|SiteEntity | [
"Gets",
"site",
"from",
"db",
"by",
"domain",
"name"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Site.php#L170-L197 | train |
reliv/Rcm | core/src/Repository/Site.php | Site.getPrimaryDomain | protected function getPrimaryDomain($domain)
{
/** @var \Rcm\Entity\Domain $domain */
$domain = $this->_em->getRepository(\Rcm\Entity\Domain::class)
->findOneBy(['domain' => $domain]);
if (empty($domain)) {
return null;
}
$primary = $domain->getPrimary();
if (!$primary->getPrimary()) {
return $primary;
}
return $this->getPrimaryDomain($primary->getDomainName());
} | php | protected function getPrimaryDomain($domain)
{
/** @var \Rcm\Entity\Domain $domain */
$domain = $this->_em->getRepository(\Rcm\Entity\Domain::class)
->findOneBy(['domain' => $domain]);
if (empty($domain)) {
return null;
}
$primary = $domain->getPrimary();
if (!$primary->getPrimary()) {
return $primary;
}
return $this->getPrimaryDomain($primary->getDomainName());
} | [
"protected",
"function",
"getPrimaryDomain",
"(",
"$",
"domain",
")",
"{",
"/** @var \\Rcm\\Entity\\Domain $domain */",
"$",
"domain",
"=",
"$",
"this",
"->",
"_em",
"->",
"getRepository",
"(",
"\\",
"Rcm",
"\\",
"Entity",
"\\",
"Domain",
"::",
"class",
")",
"... | Get the Primary Domain for site lookup
@param $domain
@return null|\Rcm\Entity\Domain | [
"Get",
"the",
"Primary",
"Domain",
"for",
"site",
"lookup"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Site.php#L206-L223 | train |
laravelflare/flare | src/Flare/Http/Controllers/Edge/AdminController.php | AdminController.getDashboard | public function getDashboard()
{
$view = 'admin.dashboard';
if (!view()->exists($view)) {
$view = 'flare::'.$view;
}
return view($view, ['widgets' => (new WidgetAdminManager())]);
} | php | public function getDashboard()
{
$view = 'admin.dashboard';
if (!view()->exists($view)) {
$view = 'flare::'.$view;
}
return view($view, ['widgets' => (new WidgetAdminManager())]);
} | [
"public",
"function",
"getDashboard",
"(",
")",
"{",
"$",
"view",
"=",
"'admin.dashboard'",
";",
"if",
"(",
"!",
"view",
"(",
")",
"->",
"exists",
"(",
"$",
"view",
")",
")",
"{",
"$",
"view",
"=",
"'flare::'",
".",
"$",
"view",
";",
"}",
"return",... | Show the Dashboard.
@return \Illuminate\Http\Response | [
"Show",
"the",
"Dashboard",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Http/Controllers/Edge/AdminController.php#L53-L62 | train |
russsiq/bixbite | app/Models/Traits/FullTextSearch.php | FullTextSearch.fullTextWildcards | protected function fullTextWildcards($term)
{
// removing symbols used by MySQL
$reservedSymbols = ['-', '+', '<', '>', '@', '(', ')', '~'];
$term = str_replace($reservedSymbols, '', $term);
$words = explode(' ', $term);
foreach ($words as $key => $word) {
/*
* applying + operator (required word) only big words
* because smaller ones are not indexed by mysql
*/
if (strlen($word) >= 3) {
// $words[$key] = '+' . $word . '*';
$words[$key] = $word.'*';
}
}
$searchTerm = implode(' ', $words);
return $searchTerm;
} | php | protected function fullTextWildcards($term)
{
// removing symbols used by MySQL
$reservedSymbols = ['-', '+', '<', '>', '@', '(', ')', '~'];
$term = str_replace($reservedSymbols, '', $term);
$words = explode(' ', $term);
foreach ($words as $key => $word) {
/*
* applying + operator (required word) only big words
* because smaller ones are not indexed by mysql
*/
if (strlen($word) >= 3) {
// $words[$key] = '+' . $word . '*';
$words[$key] = $word.'*';
}
}
$searchTerm = implode(' ', $words);
return $searchTerm;
} | [
"protected",
"function",
"fullTextWildcards",
"(",
"$",
"term",
")",
"{",
"// removing symbols used by MySQL",
"$",
"reservedSymbols",
"=",
"[",
"'-'",
",",
"'+'",
",",
"'<'",
",",
"'>'",
",",
"'@'",
",",
"'('",
",",
"')'",
",",
"'~'",
"]",
";",
"$",
"te... | Replaces spaces with full text search wildcards
@param string $term
@return string | [
"Replaces",
"spaces",
"with",
"full",
"text",
"search",
"wildcards"
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/Traits/FullTextSearch.php#L17-L39 | train |
russsiq/bixbite | app/Models/Traits/FullTextSearch.php | FullTextSearch.scopeSearch | public function scopeSearch($query, $term)
{
$columns = implode(',', $this->searchable);
$query->whereRaw("MATCH ({$columns}) AGAINST (? IN BOOLEAN MODE)", $this->fullTextWildcards($term));
// $term = $this->fullTextWildcards($term);
//
// $query
// ->selectRaw('MATCH (title, content) AGAINST (? in boolean mode) as REL', [$term])
// ->whereRaw('MATCH (title, content) AGAINST (? in boolean mode)' , $term)
// ->orderBy('REL', 'desc')
// ;
return $query;
} | php | public function scopeSearch($query, $term)
{
$columns = implode(',', $this->searchable);
$query->whereRaw("MATCH ({$columns}) AGAINST (? IN BOOLEAN MODE)", $this->fullTextWildcards($term));
// $term = $this->fullTextWildcards($term);
//
// $query
// ->selectRaw('MATCH (title, content) AGAINST (? in boolean mode) as REL', [$term])
// ->whereRaw('MATCH (title, content) AGAINST (? in boolean mode)' , $term)
// ->orderBy('REL', 'desc')
// ;
return $query;
} | [
"public",
"function",
"scopeSearch",
"(",
"$",
"query",
",",
"$",
"term",
")",
"{",
"$",
"columns",
"=",
"implode",
"(",
"','",
",",
"$",
"this",
"->",
"searchable",
")",
";",
"$",
"query",
"->",
"whereRaw",
"(",
"\"MATCH ({$columns}) AGAINST (? IN BOOLEAN M... | Scope a query that matches a full text search of term.
@param \Illuminate\Database\Eloquent\Builder $query
@param string $term
@return \Illuminate\Database\Eloquent\Builder | [
"Scope",
"a",
"query",
"that",
"matches",
"a",
"full",
"text",
"search",
"of",
"term",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/Traits/FullTextSearch.php#L48-L63 | train |
warezgibzzz/QueryBusBundle | src/DependencyInjection/Compiler/RegisterHandlers.php | RegisterHandlers.process | public function process(ContainerBuilder $container)
{
if (!$container->has($this->serviceId)) {
return;
}
$definition = $container->findDefinition($this->serviceId);
$handlers = array();
$this->collectServiceIds(
$container,
$this->tag,
$this->keyAttribute,
function ($key, $serviceId, array $tagAttributes) use (&$handlers) {
if (isset($tagAttributes['method'])) {
$callable = [$serviceId, $tagAttributes['method']];
} else {
$callable = $serviceId;
}
$handlers[ltrim($key, '\\')] = $callable;
}
);
$definition->replaceArgument(0, $handlers);
} | php | public function process(ContainerBuilder $container)
{
if (!$container->has($this->serviceId)) {
return;
}
$definition = $container->findDefinition($this->serviceId);
$handlers = array();
$this->collectServiceIds(
$container,
$this->tag,
$this->keyAttribute,
function ($key, $serviceId, array $tagAttributes) use (&$handlers) {
if (isset($tagAttributes['method'])) {
$callable = [$serviceId, $tagAttributes['method']];
} else {
$callable = $serviceId;
}
$handlers[ltrim($key, '\\')] = $callable;
}
);
$definition->replaceArgument(0, $handlers);
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"$",
"container",
"->",
"has",
"(",
"$",
"this",
"->",
"serviceId",
")",
")",
"{",
"return",
";",
"}",
"$",
"definition",
"=",
"$",
"container",
"->",... | Search for message handler services and provide them as a constructor argument to the message handler map
service.
@param ContainerBuilder $container | [
"Search",
"for",
"message",
"handler",
"services",
"and",
"provide",
"them",
"as",
"a",
"constructor",
"argument",
"to",
"the",
"message",
"handler",
"map",
"service",
"."
] | 4eb38a5d1cf5692eae229ede981a4aaffb767a9d | https://github.com/warezgibzzz/QueryBusBundle/blob/4eb38a5d1cf5692eae229ede981a4aaffb767a9d/src/DependencyInjection/Compiler/RegisterHandlers.php#L38-L59 | train |
RogerWaters/react-thread-pool | src/ThreadConnection.php | ThreadConnection.writeAsync | public function writeAsync($data)
{
$this->dataBuffer .= $this->buffer->encodeMessage(serialize($data));
if ($this->writeEvent === false)
{
$this->loop->addWriteStream($this->connection, function ($stream, LoopInterface $loop)
{
if (strlen($this->dataBuffer) > 0)
{
$dataWritten = fwrite($stream,$this->dataBuffer);
$this->dataBuffer = substr($this->dataBuffer,$dataWritten);
if(strlen($this->dataBuffer) <= 0)
{
$loop->removeWriteStream($stream);
$this->writeEvent = false;
}
}
});
$this->writeEvent = true;
}
} | php | public function writeAsync($data)
{
$this->dataBuffer .= $this->buffer->encodeMessage(serialize($data));
if ($this->writeEvent === false)
{
$this->loop->addWriteStream($this->connection, function ($stream, LoopInterface $loop)
{
if (strlen($this->dataBuffer) > 0)
{
$dataWritten = fwrite($stream,$this->dataBuffer);
$this->dataBuffer = substr($this->dataBuffer,$dataWritten);
if(strlen($this->dataBuffer) <= 0)
{
$loop->removeWriteStream($stream);
$this->writeEvent = false;
}
}
});
$this->writeEvent = true;
}
} | [
"public",
"function",
"writeAsync",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"dataBuffer",
".=",
"$",
"this",
"->",
"buffer",
"->",
"encodeMessage",
"(",
"serialize",
"(",
"$",
"data",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"writeEvent",
... | Encode the data given into binary message.
The message is send to the endpoint
@param array|mixed $data | [
"Encode",
"the",
"data",
"given",
"into",
"binary",
"message",
".",
"The",
"message",
"is",
"send",
"to",
"the",
"endpoint"
] | cdbbe172f5953c84f6b412a7cea94e425ff065df | https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/ThreadConnection.php#L73-L93 | train |
RogerWaters/react-thread-pool | src/ThreadConnection.php | ThreadConnection.readSync | public function readSync()
{
$this->ThrowOnConnectionInvalid();
$this->loop->removeReadStream($this->connection);
$this->readToBuffer();
$this->attachReadStream();
} | php | public function readSync()
{
$this->ThrowOnConnectionInvalid();
$this->loop->removeReadStream($this->connection);
$this->readToBuffer();
$this->attachReadStream();
} | [
"public",
"function",
"readSync",
"(",
")",
"{",
"$",
"this",
"->",
"ThrowOnConnectionInvalid",
"(",
")",
";",
"$",
"this",
"->",
"loop",
"->",
"removeReadStream",
"(",
"$",
"this",
"->",
"connection",
")",
";",
"$",
"this",
"->",
"readToBuffer",
"(",
")... | Reads a singe message from the remote stream | [
"Reads",
"a",
"singe",
"message",
"from",
"the",
"remote",
"stream"
] | cdbbe172f5953c84f6b412a7cea94e425ff065df | https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/ThreadConnection.php#L115-L121 | train |
RogerWaters/react-thread-pool | src/ThreadConnection.php | ThreadConnection.close | public function close()
{
if($this->connection !== null)
{
if ($this->writeEvent) {
$this->loop->removeWriteStream($this->connection);
}
$this->loop->removeReadStream($this->connection);
fclose($this->connection);
$this->emit('close', array($this));
}
$this->connection = null;
} | php | public function close()
{
if($this->connection !== null)
{
if ($this->writeEvent) {
$this->loop->removeWriteStream($this->connection);
}
$this->loop->removeReadStream($this->connection);
fclose($this->connection);
$this->emit('close', array($this));
}
$this->connection = null;
} | [
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connection",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"writeEvent",
")",
"{",
"$",
"this",
"->",
"loop",
"->",
"removeWriteStream",
"(",
"$",
"this",
"->",
"... | Closes any underlying stream and removes events | [
"Closes",
"any",
"underlying",
"stream",
"and",
"removes",
"events"
] | cdbbe172f5953c84f6b412a7cea94e425ff065df | https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/ThreadConnection.php#L126-L138 | train |
RogerWaters/react-thread-pool | src/ThreadConnection.php | ThreadConnection.attachReadStream | protected function attachReadStream()
{
$this->ThrowOnConnectionInvalid();
$this->loop->addReadStream($this->connection, function () {
$this->readToBuffer();
});
} | php | protected function attachReadStream()
{
$this->ThrowOnConnectionInvalid();
$this->loop->addReadStream($this->connection, function () {
$this->readToBuffer();
});
} | [
"protected",
"function",
"attachReadStream",
"(",
")",
"{",
"$",
"this",
"->",
"ThrowOnConnectionInvalid",
"(",
")",
";",
"$",
"this",
"->",
"loop",
"->",
"addReadStream",
"(",
"$",
"this",
"->",
"connection",
",",
"function",
"(",
")",
"{",
"$",
"this",
... | setup the readStream event | [
"setup",
"the",
"readStream",
"event"
] | cdbbe172f5953c84f6b412a7cea94e425ff065df | https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/ThreadConnection.php#L143-L149 | train |
RogerWaters/react-thread-pool | src/ThreadConnection.php | ThreadConnection.readToBuffer | protected function readToBuffer()
{
$this->ThrowOnConnectionInvalid();
$message = stream_socket_recvfrom($this->connection, 1024, 0, $peer);
//$message = fread($conn,1024);
if ($message !== '' && $message !== false) {
$this->buffer->pushData($message);
foreach ($this->buffer->getMessages() as $messageData) {
$messageData = unserialize($messageData);
$this->emit('message', array($this, $messageData));
}
} else {
$this->close();
}
} | php | protected function readToBuffer()
{
$this->ThrowOnConnectionInvalid();
$message = stream_socket_recvfrom($this->connection, 1024, 0, $peer);
//$message = fread($conn,1024);
if ($message !== '' && $message !== false) {
$this->buffer->pushData($message);
foreach ($this->buffer->getMessages() as $messageData) {
$messageData = unserialize($messageData);
$this->emit('message', array($this, $messageData));
}
} else {
$this->close();
}
} | [
"protected",
"function",
"readToBuffer",
"(",
")",
"{",
"$",
"this",
"->",
"ThrowOnConnectionInvalid",
"(",
")",
";",
"$",
"message",
"=",
"stream_socket_recvfrom",
"(",
"$",
"this",
"->",
"connection",
",",
"1024",
",",
"0",
",",
"$",
"peer",
")",
";",
... | reads a block of data to the buffer | [
"reads",
"a",
"block",
"of",
"data",
"to",
"the",
"buffer"
] | cdbbe172f5953c84f6b412a7cea94e425ff065df | https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/ThreadConnection.php#L154-L168 | train |
juliangut/slim-doctrine-middleware | src/DoctrineMiddleware.php | DoctrineMiddleware.setup | public function setup()
{
$app = $this->getApplication();
$options = $app->config('doctrine');
if (is_array($options)) {
$this->setOptions($this->options, $options);
}
$proxyDir = $this->getOption('proxy_path');
$cache = DoctrineCacheFactory::configureCache($this->getOption('cache_driver'));
$config = Setup::createConfiguration(!!$app->config('debug'), $proxyDir, $cache);
$config->setNamingStrategy(new UnderscoreNamingStrategy());
$this->setupAnnotationMetadata();
if (!$this->setupMetadataDriver($config)) {
throw new \RuntimeException('No Metadata Driver defined');
}
$config->setAutoGenerateProxyClasses($this->getOption('auto_generate_proxies', true) == true);
$connection = $this->getOption('connection');
$app->container->singleton(
'entityManager',
function () use ($connection, $config) {
return EntityManager::create($connection, $config);
}
);
} | php | public function setup()
{
$app = $this->getApplication();
$options = $app->config('doctrine');
if (is_array($options)) {
$this->setOptions($this->options, $options);
}
$proxyDir = $this->getOption('proxy_path');
$cache = DoctrineCacheFactory::configureCache($this->getOption('cache_driver'));
$config = Setup::createConfiguration(!!$app->config('debug'), $proxyDir, $cache);
$config->setNamingStrategy(new UnderscoreNamingStrategy());
$this->setupAnnotationMetadata();
if (!$this->setupMetadataDriver($config)) {
throw new \RuntimeException('No Metadata Driver defined');
}
$config->setAutoGenerateProxyClasses($this->getOption('auto_generate_proxies', true) == true);
$connection = $this->getOption('connection');
$app->container->singleton(
'entityManager',
function () use ($connection, $config) {
return EntityManager::create($connection, $config);
}
);
} | [
"public",
"function",
"setup",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"getApplication",
"(",
")",
";",
"$",
"options",
"=",
"$",
"app",
"->",
"config",
"(",
"'doctrine'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
... | Set up Doctrine Entity Manager Slim service
@throws \RuntimeException | [
"Set",
"up",
"Doctrine",
"Entity",
"Manager",
"Slim",
"service"
] | db35958148d24981fc56b1d7beea3f65f88cfadb | https://github.com/juliangut/slim-doctrine-middleware/blob/db35958148d24981fc56b1d7beea3f65f88cfadb/src/DoctrineMiddleware.php#L96-L126 | train |
phptuts/StarterBundleForSymfony | src/Security/Provider/TokenProvider.php | TokenProvider.loadUserByUsername | public function loadUserByUsername($username)
{
if (!$this->authTokenService->isValid($username)) {
throw new UsernameNotFoundException("Invalid Token.");
}
try {
return $this->authTokenService->getUser($username);
} catch (ProgrammerException $ex) {
throw new UsernameNotFoundException($ex->getMessage(), $ex->getCode());
}
} | php | public function loadUserByUsername($username)
{
if (!$this->authTokenService->isValid($username)) {
throw new UsernameNotFoundException("Invalid Token.");
}
try {
return $this->authTokenService->getUser($username);
} catch (ProgrammerException $ex) {
throw new UsernameNotFoundException($ex->getMessage(), $ex->getCode());
}
} | [
"public",
"function",
"loadUserByUsername",
"(",
"$",
"username",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"authTokenService",
"->",
"isValid",
"(",
"$",
"username",
")",
")",
"{",
"throw",
"new",
"UsernameNotFoundException",
"(",
"\"Invalid Token.\"",
")"... | Returns a user from the token payload if the token is valid and user_id in the payload is found otherwise
throws an exception
@param string $username
@return null|BaseUser | [
"Returns",
"a",
"user",
"from",
"the",
"token",
"payload",
"if",
"the",
"token",
"is",
"valid",
"and",
"user_id",
"in",
"the",
"payload",
"is",
"found",
"otherwise",
"throws",
"an",
"exception"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Provider/TokenProvider.php#L44-L56 | train |
webeweb/core-bundle | Helper/AssetsHelper.php | AssetsHelper.listAssets | protected static function listAssets($directory) {
if (false === is_dir($directory)) {
throw new InvalidArgumentException(sprintf("\"%s\" is not a directory", $directory));
}
$assets = [];
foreach (new DirectoryIterator(realpath($directory)) as $current) {
// Check the filename and his extension.
if (true === in_array($current->getFilename(), [".", ".."]) || 0 === preg_match("/\.zip$/", $current->getFilename())) {
continue;
}
$assets[] = $current->getPathname();
}
sort($assets);
return $assets;
} | php | protected static function listAssets($directory) {
if (false === is_dir($directory)) {
throw new InvalidArgumentException(sprintf("\"%s\" is not a directory", $directory));
}
$assets = [];
foreach (new DirectoryIterator(realpath($directory)) as $current) {
// Check the filename and his extension.
if (true === in_array($current->getFilename(), [".", ".."]) || 0 === preg_match("/\.zip$/", $current->getFilename())) {
continue;
}
$assets[] = $current->getPathname();
}
sort($assets);
return $assets;
} | [
"protected",
"static",
"function",
"listAssets",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"false",
"===",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"\\\"%s\\\" is not a directory\"",
","... | List all assets.
@param string $directory The directory.
@return array Returns the assets.
@throws InvalidArgumentException Throw an invalid argument exception if the directory is not a directory. | [
"List",
"all",
"assets",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Helper/AssetsHelper.php#L33-L54 | train |
webeweb/core-bundle | Helper/AssetsHelper.php | AssetsHelper.unzipAssets | public static function unzipAssets($src, $dst) {
if (false === is_dir($dst)) {
throw new InvalidArgumentException(sprintf("\"%s\" is not a directory", $dst));
}
$result = [];
foreach (static::listAssets($src) as $current) {
$zip = new ZipArchive();
if (true === $zip->open($current)) {
$result[$current] = $zip->extractTo(realpath($dst));
$zip->close();
}
}
return $result;
} | php | public static function unzipAssets($src, $dst) {
if (false === is_dir($dst)) {
throw new InvalidArgumentException(sprintf("\"%s\" is not a directory", $dst));
}
$result = [];
foreach (static::listAssets($src) as $current) {
$zip = new ZipArchive();
if (true === $zip->open($current)) {
$result[$current] = $zip->extractTo(realpath($dst));
$zip->close();
}
}
return $result;
} | [
"public",
"static",
"function",
"unzipAssets",
"(",
"$",
"src",
",",
"$",
"dst",
")",
"{",
"if",
"(",
"false",
"===",
"is_dir",
"(",
"$",
"dst",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"\\\"%s\\\" is not a directory\... | Unzip all assets.
@param string $src The source directory.
@param string $dst The destination directory.
@return array Returns the assets.
@throws InvalidArgumentException Throw an invalid argument if a directory is not a directory. | [
"Unzip",
"all",
"assets",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Helper/AssetsHelper.php#L64-L83 | train |
reliv/Rcm | core/src/Controller/AbstractPluginRestfulController.php | AbstractPluginRestfulController.getInstanceConfig | protected function getInstanceConfig($instanceId = 0)
{
/** @var \Rcm\Service\PluginManager $pluginManager */
$pluginManager = $this->getServiceLocator()->get(
'Rcm\Service\PluginManager'
);
$instanceConfig = [];
$pluginName = $this->getRcmPluginName();
if ($instanceId > 0) {
try {
$instanceConfig = $pluginManager->getInstanceConfig($instanceId);
} catch (PluginInstanceNotFoundException $e) {
// ignore error
}
}
if (empty($instanceConfig)) {
$instanceConfig = $pluginManager->getDefaultInstanceConfig(
$pluginName
);
}
return $instanceConfig;
} | php | protected function getInstanceConfig($instanceId = 0)
{
/** @var \Rcm\Service\PluginManager $pluginManager */
$pluginManager = $this->getServiceLocator()->get(
'Rcm\Service\PluginManager'
);
$instanceConfig = [];
$pluginName = $this->getRcmPluginName();
if ($instanceId > 0) {
try {
$instanceConfig = $pluginManager->getInstanceConfig($instanceId);
} catch (PluginInstanceNotFoundException $e) {
// ignore error
}
}
if (empty($instanceConfig)) {
$instanceConfig = $pluginManager->getDefaultInstanceConfig(
$pluginName
);
}
return $instanceConfig;
} | [
"protected",
"function",
"getInstanceConfig",
"(",
"$",
"instanceId",
"=",
"0",
")",
"{",
"/** @var \\Rcm\\Service\\PluginManager $pluginManager */",
"$",
"pluginManager",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'Rcm\\Service\\PluginMan... | getInstanceConfig by instance id
@param int $instanceId
@return array | [
"getInstanceConfig",
"by",
"instance",
"id"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Controller/AbstractPluginRestfulController.php#L88-L114 | train |
webeweb/core-bundle | Helper/ColorHelper.php | ColorHelper.getMaterialDesignColorPalette | public static function getMaterialDesignColorPalette() {
return [
new RedColorProvider(),
new PinkColorProvider(),
new PurpleColorProvider(),
new DeepPurpleColorProvider(),
new IndigoColorProvider(),
new BlueColorProvider(),
new LightBlueColorProvider(),
new CyanColorProvider(),
new TealColorProvider(),
new GreenColorProvider(),
new LightGreenColorProvider(),
new LimeColorProvider(),
new YellowColorProvider(),
new AmberColorProvider(),
new OrangeColorProvider(),
new DeepOrangeColorProvider(),
new BrownColorProvider(),
new GreyColorProvider(),
new BlueGreyColorProvider(),
new BlackColorProvider(),
new WhiteColorProvider(),
];
} | php | public static function getMaterialDesignColorPalette() {
return [
new RedColorProvider(),
new PinkColorProvider(),
new PurpleColorProvider(),
new DeepPurpleColorProvider(),
new IndigoColorProvider(),
new BlueColorProvider(),
new LightBlueColorProvider(),
new CyanColorProvider(),
new TealColorProvider(),
new GreenColorProvider(),
new LightGreenColorProvider(),
new LimeColorProvider(),
new YellowColorProvider(),
new AmberColorProvider(),
new OrangeColorProvider(),
new DeepOrangeColorProvider(),
new BrownColorProvider(),
new GreyColorProvider(),
new BlueGreyColorProvider(),
new BlackColorProvider(),
new WhiteColorProvider(),
];
} | [
"public",
"static",
"function",
"getMaterialDesignColorPalette",
"(",
")",
"{",
"return",
"[",
"new",
"RedColorProvider",
"(",
")",
",",
"new",
"PinkColorProvider",
"(",
")",
",",
"new",
"PurpleColorProvider",
"(",
")",
",",
"new",
"DeepPurpleColorProvider",
"(",
... | Get the Material Design Color Palette.
@return ColorProviderInterface[] Returns the Material Design Color Palette. | [
"Get",
"the",
"Material",
"Design",
"Color",
"Palette",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Helper/ColorHelper.php#L60-L84 | train |
phptuts/StarterBundleForSymfony | src/Controller/BaseRestController.php | BaseRestController.serializeFormError | public function serializeFormError(FormInterface $form)
{
$errors = $this->formSerializer->createFormErrorArray($form);
$responseModel = new ResponseFormErrorModel($errors);
return new JsonResponse($responseModel->getBody(), Response::HTTP_BAD_REQUEST);
} | php | public function serializeFormError(FormInterface $form)
{
$errors = $this->formSerializer->createFormErrorArray($form);
$responseModel = new ResponseFormErrorModel($errors);
return new JsonResponse($responseModel->getBody(), Response::HTTP_BAD_REQUEST);
} | [
"public",
"function",
"serializeFormError",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"errors",
"=",
"$",
"this",
"->",
"formSerializer",
"->",
"createFormErrorArray",
"(",
"$",
"form",
")",
";",
"$",
"responseModel",
"=",
"new",
"ResponseFormErrorModel"... | Returns a serialized error response
@param FormInterface $form
@return JsonResponse | [
"Returns",
"a",
"serialized",
"error",
"response"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Controller/BaseRestController.php#L38-L45 | train |
dadajuice/zephyrus | src/Zephyrus/Security/Session/SessionExpiration.php | SessionExpiration.isObsolete | public function isObsolete()
{
if ($this->refreshNthRequests == 1 || $this->isRefreshNeededByProbability()) {
return true;
}
if (isset($_SESSION['__HANDLER_REQUESTS_BEFORE_REFRESH'])) {
if ($_SESSION['__HANDLER_REQUESTS_BEFORE_REFRESH'] <= 1) {
return true; // @codeCoverageIgnore
}
$_SESSION['__HANDLER_REQUESTS_BEFORE_REFRESH']--;
}
if (isset($_SESSION['__HANDLER_SECONDS_BEFORE_REFRESH'])) {
$timeDifference = time() - $_SESSION['__HANDLER_LAST_ACTIVITY_TIMESTAMP'];
if ($timeDifference >= $_SESSION['__HANDLER_SECONDS_BEFORE_REFRESH']) {
return true;
}
}
return false;
} | php | public function isObsolete()
{
if ($this->refreshNthRequests == 1 || $this->isRefreshNeededByProbability()) {
return true;
}
if (isset($_SESSION['__HANDLER_REQUESTS_BEFORE_REFRESH'])) {
if ($_SESSION['__HANDLER_REQUESTS_BEFORE_REFRESH'] <= 1) {
return true; // @codeCoverageIgnore
}
$_SESSION['__HANDLER_REQUESTS_BEFORE_REFRESH']--;
}
if (isset($_SESSION['__HANDLER_SECONDS_BEFORE_REFRESH'])) {
$timeDifference = time() - $_SESSION['__HANDLER_LAST_ACTIVITY_TIMESTAMP'];
if ($timeDifference >= $_SESSION['__HANDLER_SECONDS_BEFORE_REFRESH']) {
return true;
}
}
return false;
} | [
"public",
"function",
"isObsolete",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"refreshNthRequests",
"==",
"1",
"||",
"$",
"this",
"->",
"isRefreshNeededByProbability",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_S... | Determines if the session needs to be refreshed either because the
maximum number of allowed requests has been reached or the timeout has
finished.
@return bool | [
"Determines",
"if",
"the",
"session",
"needs",
"to",
"be",
"refreshed",
"either",
"because",
"the",
"maximum",
"number",
"of",
"allowed",
"requests",
"has",
"been",
"reached",
"or",
"the",
"timeout",
"has",
"finished",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/Session/SessionExpiration.php#L47-L65 | train |
dadajuice/zephyrus | src/Zephyrus/Security/Session/SessionExpiration.php | SessionExpiration.isRefreshNeededByProbability | private function isRefreshNeededByProbability()
{
if (is_null($this->refreshProbability)) {
return false;
}
$rand = (float) mt_rand() / (float) mt_getrandmax();
if ($this->refreshProbability == 1.0 || $rand <= $this->refreshProbability) {
return true;
}
return false; // @codeCoverageIgnore
} | php | private function isRefreshNeededByProbability()
{
if (is_null($this->refreshProbability)) {
return false;
}
$rand = (float) mt_rand() / (float) mt_getrandmax();
if ($this->refreshProbability == 1.0 || $rand <= $this->refreshProbability) {
return true;
}
return false; // @codeCoverageIgnore
} | [
"private",
"function",
"isRefreshNeededByProbability",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"refreshProbability",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"rand",
"=",
"(",
"float",
")",
"mt_rand",
"(",
")",
"/",
"(",
"f... | Determines if the probability test of session refresh succeeded
according to the desired percent.
@return bool | [
"Determines",
"if",
"the",
"probability",
"test",
"of",
"session",
"refresh",
"succeeded",
"according",
"to",
"the",
"desired",
"percent",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/Session/SessionExpiration.php#L73-L83 | train |
russsiq/bixbite | app/Support/Factories/WidgetFactory.php | WidgetFactory.make | public function make()
{
try {
$args = func_get_args();
$active = $args[1]['active'] ?? true;
// If widget has non active status.
if (! $active) {
return false;
}
$this->widgetName = trim((string) array_shift($args));
$this->widgetParams = (array) array_shift($args);
$this->widget = $this->getWidget();
return $this->getContentFromCache();
} catch (\Exception $e) {
return sprintf(
trans('common.msg.error'), $e->getMessage()
);
}
} | php | public function make()
{
try {
$args = func_get_args();
$active = $args[1]['active'] ?? true;
// If widget has non active status.
if (! $active) {
return false;
}
$this->widgetName = trim((string) array_shift($args));
$this->widgetParams = (array) array_shift($args);
$this->widget = $this->getWidget();
return $this->getContentFromCache();
} catch (\Exception $e) {
return sprintf(
trans('common.msg.error'), $e->getMessage()
);
}
} | [
"public",
"function",
"make",
"(",
")",
"{",
"try",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"active",
"=",
"$",
"args",
"[",
"1",
"]",
"[",
"'active'",
"]",
"??",
"true",
";",
"// If widget has non active status.",
"if",
"(",
"!",
... | Generate a widget.
@return mixed | [
"Generate",
"a",
"widget",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/Factories/WidgetFactory.php#L51-L72 | train |
russsiq/bixbite | app/Support/Factories/WidgetFactory.php | WidgetFactory.getWidgetPath | protected function getWidgetPath()
{
$name = html_clean($this->widgetName);
$name = str_replace(['.', '_'], ' ', $name);
$name = str_replace(' ', '', ucwords($name));
$name = $this->namespace . '\\' . $name . 'Widget';
if (! is_subclass_of($name, WidgetAbstract::class)) {
throw new \Exception(sprintf(
'Widget class `%s` not available!', $name
));
}
return $name;
} | php | protected function getWidgetPath()
{
$name = html_clean($this->widgetName);
$name = str_replace(['.', '_'], ' ', $name);
$name = str_replace(' ', '', ucwords($name));
$name = $this->namespace . '\\' . $name . 'Widget';
if (! is_subclass_of($name, WidgetAbstract::class)) {
throw new \Exception(sprintf(
'Widget class `%s` not available!', $name
));
}
return $name;
} | [
"protected",
"function",
"getWidgetPath",
"(",
")",
"{",
"$",
"name",
"=",
"html_clean",
"(",
"$",
"this",
"->",
"widgetName",
")",
";",
"$",
"name",
"=",
"str_replace",
"(",
"[",
"'.'",
",",
"'_'",
"]",
",",
"' '",
",",
"$",
"name",
")",
";",
"$",... | Get full path with name to widget class location.
@throws \Exception
@return string | [
"Get",
"full",
"path",
"with",
"name",
"to",
"widget",
"class",
"location",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/Factories/WidgetFactory.php#L92-L106 | train |
russsiq/bixbite | app/Support/Factories/WidgetFactory.php | WidgetFactory.getContent | protected function getContent()
{
$widget = (object) $this->widget->execute();
$widget->cache_key = $this->widget->cacheKeys();
return trim(preg_replace('/(\s|\r|\n)+</', '<',
view($this->widget->template(), compact('widget'))->render()
));
// Debug function if App has error:
// `Cannot end a section without first starting one.`
return view($this->widget->template(), compact('widget'));
} | php | protected function getContent()
{
$widget = (object) $this->widget->execute();
$widget->cache_key = $this->widget->cacheKeys();
return trim(preg_replace('/(\s|\r|\n)+</', '<',
view($this->widget->template(), compact('widget'))->render()
));
// Debug function if App has error:
// `Cannot end a section without first starting one.`
return view($this->widget->template(), compact('widget'));
} | [
"protected",
"function",
"getContent",
"(",
")",
"{",
"$",
"widget",
"=",
"(",
"object",
")",
"$",
"this",
"->",
"widget",
"->",
"execute",
"(",
")",
";",
"$",
"widget",
"->",
"cache_key",
"=",
"$",
"this",
"->",
"widget",
"->",
"cacheKeys",
"(",
")"... | Make call and get widget content.
@return mixed Html compiled string. | [
"Make",
"call",
"and",
"get",
"widget",
"content",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/Factories/WidgetFactory.php#L113-L125 | train |
russsiq/bixbite | app/Support/Factories/WidgetFactory.php | WidgetFactory.getContentFromCache | protected function getContentFromCache()
{
$cache_key = $this->widget->cacheKey();
$cache_time = $this->widget->cacheTime();
// Check the existence of the cache.
if (! cache()->has($cache_key)) {
// If cache is empty and validation is fails.
$this->checkWidgetParams();
// If cache is empty and template file does not exists.
$this->checkWidgetTemplate();
}
return cache()->remember($cache_key, $cache_time, function () {
return $this->getContent();
});
} | php | protected function getContentFromCache()
{
$cache_key = $this->widget->cacheKey();
$cache_time = $this->widget->cacheTime();
// Check the existence of the cache.
if (! cache()->has($cache_key)) {
// If cache is empty and validation is fails.
$this->checkWidgetParams();
// If cache is empty and template file does not exists.
$this->checkWidgetTemplate();
}
return cache()->remember($cache_key, $cache_time, function () {
return $this->getContent();
});
} | [
"protected",
"function",
"getContentFromCache",
"(",
")",
"{",
"$",
"cache_key",
"=",
"$",
"this",
"->",
"widget",
"->",
"cacheKey",
"(",
")",
";",
"$",
"cache_time",
"=",
"$",
"this",
"->",
"widget",
"->",
"cacheTime",
"(",
")",
";",
"// Check the existen... | Gets content from cache or runs widget class otherwise.
@return mixed | [
"Gets",
"content",
"from",
"cache",
"or",
"runs",
"widget",
"class",
"otherwise",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/Factories/WidgetFactory.php#L132-L148 | train |
nathanjdunn/chargebee-php-sdk | src/Api/AbstractApi.php | AbstractApi.url | protected function url(string $endpoint, ...$replacements): string
{
return $this->client->baseUrl.vsprintf($endpoint, $replacements);
} | php | protected function url(string $endpoint, ...$replacements): string
{
return $this->client->baseUrl.vsprintf($endpoint, $replacements);
} | [
"protected",
"function",
"url",
"(",
"string",
"$",
"endpoint",
",",
"...",
"$",
"replacements",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"baseUrl",
".",
"vsprintf",
"(",
"$",
"endpoint",
",",
"$",
"replacements",
")",
";",
... | Generate URL from base url and given endpoint.
@param string $endpoint
@param array $replacements
@return string | [
"Generate",
"URL",
"from",
"base",
"url",
"and",
"given",
"endpoint",
"."
] | 65cf68c040b33ee50c3173db9bf25c3f8da6a852 | https://github.com/nathanjdunn/chargebee-php-sdk/blob/65cf68c040b33ee50c3173db9bf25c3f8da6a852/src/Api/AbstractApi.php#L96-L99 | train |
nathanjdunn/chargebee-php-sdk | src/Api/AbstractApi.php | AbstractApi.createOptionsResolver | protected function createOptionsResolver(): OptionsResolver
{
$resolver = new OptionsResolver();
$resolver->setDefined('limit')
->setAllowedTypes('limit', 'int')
->setAllowedValues('limit', function ($value) {
return $value > 0;
});
$resolver->setDefined('offset')
->setAllowedTypes('offset', 'string');
return $resolver;
} | php | protected function createOptionsResolver(): OptionsResolver
{
$resolver = new OptionsResolver();
$resolver->setDefined('limit')
->setAllowedTypes('limit', 'int')
->setAllowedValues('limit', function ($value) {
return $value > 0;
});
$resolver->setDefined('offset')
->setAllowedTypes('offset', 'string');
return $resolver;
} | [
"protected",
"function",
"createOptionsResolver",
"(",
")",
":",
"OptionsResolver",
"{",
"$",
"resolver",
"=",
"new",
"OptionsResolver",
"(",
")",
";",
"$",
"resolver",
"->",
"setDefined",
"(",
"'limit'",
")",
"->",
"setAllowedTypes",
"(",
"'limit'",
",",
"'in... | Create a new OptionsResolver with page and per_page options.
@return OptionsResolver | [
"Create",
"a",
"new",
"OptionsResolver",
"with",
"page",
"and",
"per_page",
"options",
"."
] | 65cf68c040b33ee50c3173db9bf25c3f8da6a852 | https://github.com/nathanjdunn/chargebee-php-sdk/blob/65cf68c040b33ee50c3173db9bf25c3f8da6a852/src/Api/AbstractApi.php#L121-L135 | train |
dzarezenko/Asymptix-PHP-HTML-DOM-Parser | lib/HtmlDomParser/HtmlDomNode.php | HtmlDomNode.hasClass | public static function hasClass($domElement, $className) {
$classAttr = $domElement->class;
$classNames = explode(" ", $classAttr);
return in_array($className, $classNames);
} | php | public static function hasClass($domElement, $className) {
$classAttr = $domElement->class;
$classNames = explode(" ", $classAttr);
return in_array($className, $classNames);
} | [
"public",
"static",
"function",
"hasClass",
"(",
"$",
"domElement",
",",
"$",
"className",
")",
"{",
"$",
"classAttr",
"=",
"$",
"domElement",
"->",
"class",
";",
"$",
"classNames",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"classAttr",
")",
";",
"return",... | Detects if DOM Element has some class in class attribute list.
@param DOMElement $domElement DOM Element.
@param string $className Name of the class.
@return boolean TRUE or FALSE, depends on class presence in class attribute
list. | [
"Detects",
"if",
"DOM",
"Element",
"has",
"some",
"class",
"in",
"class",
"attribute",
"list",
"."
] | bdfd6649211b76f3fb4ed7e3e13008588cc9a412 | https://github.com/dzarezenko/Asymptix-PHP-HTML-DOM-Parser/blob/bdfd6649211b76f3fb4ed7e3e13008588cc9a412/lib/HtmlDomParser/HtmlDomNode.php#L50-L55 | train |
phptuts/StarterBundleForSymfony | src/Controller/ControllerTrait.php | ControllerTrait.serializeSingleObject | public function serializeSingleObject(array $data, $type, $statusCode = Response::HTTP_OK)
{
$model = new ResponseModel($data, $type);
return new JsonResponse($model->getBody(), $statusCode);
} | php | public function serializeSingleObject(array $data, $type, $statusCode = Response::HTTP_OK)
{
$model = new ResponseModel($data, $type);
return new JsonResponse($model->getBody(), $statusCode);
} | [
"public",
"function",
"serializeSingleObject",
"(",
"array",
"$",
"data",
",",
"$",
"type",
",",
"$",
"statusCode",
"=",
"Response",
"::",
"HTTP_OK",
")",
"{",
"$",
"model",
"=",
"new",
"ResponseModel",
"(",
"$",
"data",
",",
"$",
"type",
")",
";",
"re... | Serializes the json response
@param array $data
@param string $type
@param int $statusCode http response status code
@return \Symfony\Component\HttpFoundation\JsonResponse | [
"Serializes",
"the",
"json",
"response"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Controller/ControllerTrait.php#L24-L29 | train |
phptuts/StarterBundleForSymfony | src/Controller/ControllerTrait.php | ControllerTrait.serializeList | public function serializeList(PageModel $pageModel, $type, $page, $statusCode = Response::HTTP_OK)
{
$page = new ResponsePageModel($pageModel, $type, $page);
return new JsonResponse($page->getBody(), $statusCode);
} | php | public function serializeList(PageModel $pageModel, $type, $page, $statusCode = Response::HTTP_OK)
{
$page = new ResponsePageModel($pageModel, $type, $page);
return new JsonResponse($page->getBody(), $statusCode);
} | [
"public",
"function",
"serializeList",
"(",
"PageModel",
"$",
"pageModel",
",",
"$",
"type",
",",
"$",
"page",
",",
"$",
"statusCode",
"=",
"Response",
"::",
"HTTP_OK",
")",
"{",
"$",
"page",
"=",
"new",
"ResponsePageModel",
"(",
"$",
"pageModel",
",",
"... | Serializes a paged response
@param PageModel $pageModel
@param string $type represents the type
@param int $page the current page number
@param int $statusCode http response status code
@return \Symfony\Component\HttpFoundation\JsonResponse | [
"Serializes",
"a",
"paged",
"response"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Controller/ControllerTrait.php#L40-L45 | train |
russsiq/bixbite | app/Http/Controllers/Admin/TemplatesController.php | TemplatesController.edit | public function edit(TemplateRequest $request, $template)
{
try {
$template = $request->template;
$path = theme_path('views').$template;
return response()->json([
'status' => true, 'message' => null,
'file' => [
'content' => \File::get($path),
'size' => formatBytes(\File::size($path)),
'modified' => strftime('%Y-%m-%d %H:%M', \File::lastModified($path))
]
], 200);
} catch (ValidationException $e) {
$message = $e->validator->errors()->first();
return response()->json(['status' => false, 'message' => $message], 200);
} catch (\Exception $e) {
$message = $e->getMessage();
return response()->json(['status' => false, 'message' => $message], 404 );
}
} | php | public function edit(TemplateRequest $request, $template)
{
try {
$template = $request->template;
$path = theme_path('views').$template;
return response()->json([
'status' => true, 'message' => null,
'file' => [
'content' => \File::get($path),
'size' => formatBytes(\File::size($path)),
'modified' => strftime('%Y-%m-%d %H:%M', \File::lastModified($path))
]
], 200);
} catch (ValidationException $e) {
$message = $e->validator->errors()->first();
return response()->json(['status' => false, 'message' => $message], 200);
} catch (\Exception $e) {
$message = $e->getMessage();
return response()->json(['status' => false, 'message' => $message], 404 );
}
} | [
"public",
"function",
"edit",
"(",
"TemplateRequest",
"$",
"request",
",",
"$",
"template",
")",
"{",
"try",
"{",
"$",
"template",
"=",
"$",
"request",
"->",
"template",
";",
"$",
"path",
"=",
"theme_path",
"(",
"'views'",
")",
".",
"$",
"template",
";... | Edit template file by path. | [
"Edit",
"template",
"file",
"by",
"path",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Http/Controllers/Admin/TemplatesController.php#L58-L80 | train |
russsiq/bixbite | app/Http/Controllers/Admin/TemplatesController.php | TemplatesController.update | public function update(TemplateRequest $request, $template)
{
try {
$template = $request->template;
$path = theme_path('views').$template;
$content = $request->content;
// Notify if file was not changed.
if (\File::exists($path) and \File::get($path) == $content) {
return response()->json([
'status' => false,
'message' => sprintf(__('msg.not_updated'), $template),
], 200);
}
\File::put($path, $content, true);
return response()->json([
'status' => true,
'message' => sprintf(__('msg.updated'), $template),
'file' => [
'size' => formatBytes(\File::size($path)),
'modified' => strftime('%Y-%m-%d %H:%M', \File::lastModified($path))
]
], 200);
} catch (ValidationException $e) {
$message = $e->validator->errors()->first();
return response()->json(['status' => false, 'message' => $message], 200);
} catch (\Exception $e) {
$message = $e->getMessage();
return response()->json(['status' => false, 'message' => $message], 404 );
}
} | php | public function update(TemplateRequest $request, $template)
{
try {
$template = $request->template;
$path = theme_path('views').$template;
$content = $request->content;
// Notify if file was not changed.
if (\File::exists($path) and \File::get($path) == $content) {
return response()->json([
'status' => false,
'message' => sprintf(__('msg.not_updated'), $template),
], 200);
}
\File::put($path, $content, true);
return response()->json([
'status' => true,
'message' => sprintf(__('msg.updated'), $template),
'file' => [
'size' => formatBytes(\File::size($path)),
'modified' => strftime('%Y-%m-%d %H:%M', \File::lastModified($path))
]
], 200);
} catch (ValidationException $e) {
$message = $e->validator->errors()->first();
return response()->json(['status' => false, 'message' => $message], 200);
} catch (\Exception $e) {
$message = $e->getMessage();
return response()->json(['status' => false, 'message' => $message], 404 );
}
} | [
"public",
"function",
"update",
"(",
"TemplateRequest",
"$",
"request",
",",
"$",
"template",
")",
"{",
"try",
"{",
"$",
"template",
"=",
"$",
"request",
"->",
"template",
";",
"$",
"path",
"=",
"theme_path",
"(",
"'views'",
")",
".",
"$",
"template",
... | Update template file by path. | [
"Update",
"template",
"file",
"by",
"path",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Http/Controllers/Admin/TemplatesController.php#L85-L118 | train |
russsiq/bixbite | app/Http/Controllers/Admin/TemplatesController.php | TemplatesController.destroy | public function destroy(TemplateRequest $request, $template)
{
$template = $request->template;
$path = theme_path('views').$template;
// Block and notify if file does not exist.
if (! \File::exists($path)) {
return $this->makeRedirect(false, 'admin.templates.index', sprintf(
__('msg.not_exists'), $template
));
}
// Block if file not delete.
if (! \File::delete($path)) {
return $this->makeRedirect(false, 'admin.templates.index', sprintf(
__('msg.not_deleted'), $template
));
}
return $this->makeRedirect(true, 'admin.templates.index', sprintf(
__('msg.deleted'), $template
));
} | php | public function destroy(TemplateRequest $request, $template)
{
$template = $request->template;
$path = theme_path('views').$template;
// Block and notify if file does not exist.
if (! \File::exists($path)) {
return $this->makeRedirect(false, 'admin.templates.index', sprintf(
__('msg.not_exists'), $template
));
}
// Block if file not delete.
if (! \File::delete($path)) {
return $this->makeRedirect(false, 'admin.templates.index', sprintf(
__('msg.not_deleted'), $template
));
}
return $this->makeRedirect(true, 'admin.templates.index', sprintf(
__('msg.deleted'), $template
));
} | [
"public",
"function",
"destroy",
"(",
"TemplateRequest",
"$",
"request",
",",
"$",
"template",
")",
"{",
"$",
"template",
"=",
"$",
"request",
"->",
"template",
";",
"$",
"path",
"=",
"theme_path",
"(",
"'views'",
")",
".",
"$",
"template",
";",
"// Bloc... | Unlink template file by path. | [
"Unlink",
"template",
"file",
"by",
"path",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Http/Controllers/Admin/TemplatesController.php#L123-L145 | train |
reliv/Rcm | admin/src/InputFilter/SitePageCreateInputFilter.php | SitePageCreateInputFilter.build | protected function build()
{
$factory = $this->getFactory();
foreach ($this->filterConfig as $field => $config) {
$this->add(
$factory->createInput(
$config
)
);
}
} | php | protected function build()
{
$factory = $this->getFactory();
foreach ($this->filterConfig as $field => $config) {
$this->add(
$factory->createInput(
$config
)
);
}
} | [
"protected",
"function",
"build",
"(",
")",
"{",
"$",
"factory",
"=",
"$",
"this",
"->",
"getFactory",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"filterConfig",
"as",
"$",
"field",
"=>",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"add",
"(... | build input filter from config
@return void | [
"build",
"input",
"filter",
"from",
"config"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/InputFilter/SitePageCreateInputFilter.php#L132-L143 | train |
webeweb/core-bundle | Helper/FormHelper.php | FormHelper.checkCollection | public function checkCollection($collection, $notification, $redirectURL, $expected = 1) {
if (null === $collection || (false === is_array($collection) && false === ($collection instanceof Countable))) {
throw new InvalidArgumentException("The collection must be a countable");
}
if ($expected <= count($collection)) {
return;
}
$eventName = NotificationEvents::NOTIFICATION_WARNING;
if (null !== $this->getEventDispatcher() && true === $this->getEventDispatcher()->hasListeners($eventName)) {
$notification = NotificationFactory::newWarningNotification($notification);
$event = new NotificationEvent($eventName, $notification);
$this->getEventDispatcher()->dispatch($eventName, $event);
}
throw new RedirectResponseException($redirectURL, null);
} | php | public function checkCollection($collection, $notification, $redirectURL, $expected = 1) {
if (null === $collection || (false === is_array($collection) && false === ($collection instanceof Countable))) {
throw new InvalidArgumentException("The collection must be a countable");
}
if ($expected <= count($collection)) {
return;
}
$eventName = NotificationEvents::NOTIFICATION_WARNING;
if (null !== $this->getEventDispatcher() && true === $this->getEventDispatcher()->hasListeners($eventName)) {
$notification = NotificationFactory::newWarningNotification($notification);
$event = new NotificationEvent($eventName, $notification);
$this->getEventDispatcher()->dispatch($eventName, $event);
}
throw new RedirectResponseException($redirectURL, null);
} | [
"public",
"function",
"checkCollection",
"(",
"$",
"collection",
",",
"$",
"notification",
",",
"$",
"redirectURL",
",",
"$",
"expected",
"=",
"1",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"collection",
"||",
"(",
"false",
"===",
"is_array",
"(",
"$",
... | Check a collection.
@param Countable $collection The collection.
@param string $notification The notification.
@param string $redirectURL The redirect URL.
@param int $expected The expected count.
@throws InvalidArgumentException Throws an invalid argument exception if collection is null.
@throws RedirectResponseException Throws a redirect response exception if the collection is less than $expected. | [
"Check",
"a",
"collection",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Helper/FormHelper.php#L66-L86 | train |
webeweb/core-bundle | Helper/FormHelper.php | FormHelper.onPostHandleRequestWithCollection | public function onPostHandleRequestWithCollection(Collection $oldCollection, Collection $newCollection) {
$deleted = 0;
foreach ($oldCollection as $current) {
if (true === $newCollection->contains($current)) {
continue;
}
$this->getObjectManager()->remove($current);
++$deleted;
}
return $deleted;
} | php | public function onPostHandleRequestWithCollection(Collection $oldCollection, Collection $newCollection) {
$deleted = 0;
foreach ($oldCollection as $current) {
if (true === $newCollection->contains($current)) {
continue;
}
$this->getObjectManager()->remove($current);
++$deleted;
}
return $deleted;
} | [
"public",
"function",
"onPostHandleRequestWithCollection",
"(",
"Collection",
"$",
"oldCollection",
",",
"Collection",
"$",
"newCollection",
")",
"{",
"$",
"deleted",
"=",
"0",
";",
"foreach",
"(",
"$",
"oldCollection",
"as",
"$",
"current",
")",
"{",
"if",
"(... | On post handle request with collection.
@param Collection $oldCollection The old collection.
@param Collection $newCollection The new collection.
@return int Returns the deleted count. | [
"On",
"post",
"handle",
"request",
"with",
"collection",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Helper/FormHelper.php#L95-L105 | train |
webeweb/core-bundle | Helper/FormHelper.php | FormHelper.onPreHandleRequestWithCollection | public function onPreHandleRequestWithCollection(Collection $collection) {
$output = new ArrayCollection();
foreach ($collection as $current) {
$output->add($current);
}
return $output;
} | php | public function onPreHandleRequestWithCollection(Collection $collection) {
$output = new ArrayCollection();
foreach ($collection as $current) {
$output->add($current);
}
return $output;
} | [
"public",
"function",
"onPreHandleRequestWithCollection",
"(",
"Collection",
"$",
"collection",
")",
"{",
"$",
"output",
"=",
"new",
"ArrayCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"current",
")",
"{",
"$",
"output",
"->",
"ad... | On pre handle request with collection.
@param Collection $collection The collection.
@return Collection Returns the cloned collection. | [
"On",
"pre",
"handle",
"request",
"with",
"collection",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Helper/FormHelper.php#L113-L119 | train |
andreas-glaser/php-helpers | src/ValueHelper.php | ValueHelper.isInteger | public static function isInteger($value)
{
if (is_int($value)) {
return true;
} elseif (!is_string($value)) {
return false;
}
return preg_match('/^\d+$/', $value) > 0;
} | php | public static function isInteger($value)
{
if (is_int($value)) {
return true;
} elseif (!is_string($value)) {
return false;
}
return preg_match('/^\d+$/', $value) > 0;
} | [
"public",
"static",
"function",
"isInteger",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
... | Checks if given value is of type "integer"
@param $value
@return bool | [
"Checks",
"if",
"given",
"value",
"is",
"of",
"type",
"integer"
] | 84d8b98b72d01c262a5df0fb8545cb80a63afcc4 | https://github.com/andreas-glaser/php-helpers/blob/84d8b98b72d01c262a5df0fb8545cb80a63afcc4/src/ValueHelper.php#L42-L51 | train |
andreas-glaser/php-helpers | src/ValueHelper.php | ValueHelper.isFloat | public static function isFloat($value)
{
if (is_float($value)) {
return true;
} elseif (!is_string($value)) {
return false;
}
return preg_match('/^[0-9]+\.[0-9]+$/', $value) > 0;
} | php | public static function isFloat($value)
{
if (is_float($value)) {
return true;
} elseif (!is_string($value)) {
return false;
}
return preg_match('/^[0-9]+\.[0-9]+$/', $value) > 0;
} | [
"public",
"static",
"function",
"isFloat",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_float",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
... | Checks if given value is of type "float"
@param $value
@return bool | [
"Checks",
"if",
"given",
"value",
"is",
"of",
"type",
"float"
] | 84d8b98b72d01c262a5df0fb8545cb80a63afcc4 | https://github.com/andreas-glaser/php-helpers/blob/84d8b98b72d01c262a5df0fb8545cb80a63afcc4/src/ValueHelper.php#L60-L69 | train |
andreas-glaser/php-helpers | src/ValueHelper.php | ValueHelper.isDateTime | public static function isDateTime($date, string $format = null): bool
{
if ($date instanceof \DateTime) {
return true;
}
if (false === is_string($date)) {
return false;
}
if ($format) {
return \DateTime::createFromFormat($format, $date) instanceof \DateTime;
}
return (bool)strtotime($date);
} | php | public static function isDateTime($date, string $format = null): bool
{
if ($date instanceof \DateTime) {
return true;
}
if (false === is_string($date)) {
return false;
}
if ($format) {
return \DateTime::createFromFormat($format, $date) instanceof \DateTime;
}
return (bool)strtotime($date);
} | [
"public",
"static",
"function",
"isDateTime",
"(",
"$",
"date",
",",
"string",
"$",
"format",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"date",
"instanceof",
"\\",
"DateTime",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"false",
"===",... | Checks if given value is a valid PHP "datetime"
@param string|\DateTime $date
@param string|null $format
@return bool | [
"Checks",
"if",
"given",
"value",
"is",
"a",
"valid",
"PHP",
"datetime"
] | 84d8b98b72d01c262a5df0fb8545cb80a63afcc4 | https://github.com/andreas-glaser/php-helpers/blob/84d8b98b72d01c262a5df0fb8545cb80a63afcc4/src/ValueHelper.php#L79-L94 | train |
noodle69/EdgarEzUICronBundle | src/lib/Repository/EdgarEzCronRepository.php | EdgarEzCronRepository.updateCron | public function updateCron(EdgarEzCron $cron): bool
{
try {
$this->getEntityManager()->persist($cron);
$this->getEntityManager()->flush();
} catch (ORMException $e) {
return false;
}
return true;
} | php | public function updateCron(EdgarEzCron $cron): bool
{
try {
$this->getEntityManager()->persist($cron);
$this->getEntityManager()->flush();
} catch (ORMException $e) {
return false;
}
return true;
} | [
"public",
"function",
"updateCron",
"(",
"EdgarEzCron",
"$",
"cron",
")",
":",
"bool",
"{",
"try",
"{",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"persist",
"(",
"$",
"cron",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",... | Update cron object.
@param EdgarEzCron $cron
@return bool | [
"Update",
"cron",
"object",
"."
] | 54f31e1cd13a9fddc0d67b0481333ed64849c70a | https://github.com/noodle69/EdgarEzUICronBundle/blob/54f31e1cd13a9fddc0d67b0481333ed64849c70a/src/lib/Repository/EdgarEzCronRepository.php#L43-L53 | train |
phptuts/StarterBundleForSymfony | src/Factory/S3ClientFactory.php | S3ClientFactory.getClient | public function getClient()
{
return new S3Client([
'version' => $this->apiVersion,
'region' => $this->region,
'credentials' => [
'key' => $this->key,
'secret' => $this->secret,
]
]);
} | php | public function getClient()
{
return new S3Client([
'version' => $this->apiVersion,
'region' => $this->region,
'credentials' => [
'key' => $this->key,
'secret' => $this->secret,
]
]);
} | [
"public",
"function",
"getClient",
"(",
")",
"{",
"return",
"new",
"S3Client",
"(",
"[",
"'version'",
"=>",
"$",
"this",
"->",
"apiVersion",
",",
"'region'",
"=>",
"$",
"this",
"->",
"region",
",",
"'credentials'",
"=>",
"[",
"'key'",
"=>",
"$",
"this",
... | Creates a s3 client
@return S3Client | [
"Creates",
"a",
"s3",
"client"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Factory/S3ClientFactory.php#L50-L60 | train |
ARCANEDEV/LaravelImpersonator | src/ImpersonatorServiceProvider.php | ImpersonatorServiceProvider.extendAuthDriver | private function extendAuthDriver()
{
/** @var \Illuminate\Auth\AuthManager $auth */
$auth = $this->app['auth'];
$this->app['auth']->extend('session', function (Application $app, $name, array $config) use ($auth) {
$provider = $auth->createUserProvider($config['provider']);
return tap(new Guard\SessionGuard($name, $provider, $app['session.store']), function ($guard) use ($app) {
if (method_exists($guard, 'setCookieJar'))
$guard->setCookieJar($app['cookie']);
if (method_exists($guard, 'setDispatcher'))
$guard->setDispatcher($app['events']);
if (method_exists($guard, 'setRequest'))
$guard->setRequest($app->refresh('request', $guard, 'setRequest'));
});
});
} | php | private function extendAuthDriver()
{
/** @var \Illuminate\Auth\AuthManager $auth */
$auth = $this->app['auth'];
$this->app['auth']->extend('session', function (Application $app, $name, array $config) use ($auth) {
$provider = $auth->createUserProvider($config['provider']);
return tap(new Guard\SessionGuard($name, $provider, $app['session.store']), function ($guard) use ($app) {
if (method_exists($guard, 'setCookieJar'))
$guard->setCookieJar($app['cookie']);
if (method_exists($guard, 'setDispatcher'))
$guard->setDispatcher($app['events']);
if (method_exists($guard, 'setRequest'))
$guard->setRequest($app->refresh('request', $guard, 'setRequest'));
});
});
} | [
"private",
"function",
"extendAuthDriver",
"(",
")",
"{",
"/** @var \\Illuminate\\Auth\\AuthManager $auth */",
"$",
"auth",
"=",
"$",
"this",
"->",
"app",
"[",
"'auth'",
"]",
";",
"$",
"this",
"->",
"app",
"[",
"'auth'",
"]",
"->",
"extend",
"(",
"'session'"... | Extend the auth session driver. | [
"Extend",
"the",
"auth",
"session",
"driver",
"."
] | f72bc3f1bcd11530887b23f62a9975c6321efdf8 | https://github.com/ARCANEDEV/LaravelImpersonator/blob/f72bc3f1bcd11530887b23f62a9975c6321efdf8/src/ImpersonatorServiceProvider.php#L76-L95 | train |
dzarezenko/Asymptix-PHP-HTML-DOM-Parser | lib/HtmlDomParser/HtmlDomParser.php | HtmlDomParser.loadUrl | public function loadUrl($url, $curl = false) {
if ($curl) {
$content = self::loadContent($url);
if (empty($content)) {
throw new Exception("Can't get content from " . $url);
}
$this->loadString($content);
} else {
$this->load_file($url);
}
} | php | public function loadUrl($url, $curl = false) {
if ($curl) {
$content = self::loadContent($url);
if (empty($content)) {
throw new Exception("Can't get content from " . $url);
}
$this->loadString($content);
} else {
$this->load_file($url);
}
} | [
"public",
"function",
"loadUrl",
"(",
"$",
"url",
",",
"$",
"curl",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"curl",
")",
"{",
"$",
"content",
"=",
"self",
"::",
"loadContent",
"(",
"$",
"url",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"content",
... | Inits HtmlDomParser with HTML content by URL.
@param string $url URL of the page.
@param boolean $curl Use CURL to load content or file_get_contents($url)
method.
@throws Exception If content loading error occurred. | [
"Inits",
"HtmlDomParser",
"with",
"HTML",
"content",
"by",
"URL",
"."
] | bdfd6649211b76f3fb4ed7e3e13008588cc9a412 | https://github.com/dzarezenko/Asymptix-PHP-HTML-DOM-Parser/blob/bdfd6649211b76f3fb4ed7e3e13008588cc9a412/lib/HtmlDomParser/HtmlDomParser.php#L35-L45 | train |
dzarezenko/Asymptix-PHP-HTML-DOM-Parser | lib/HtmlDomParser/HtmlDomParser.php | HtmlDomParser.loadContent | private static function loadContent($url) {
//TODO: implement URL content load functionality with CURL and proxy
$ch = curl_init($url);
$options = array(
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
if ($content === false) {
throw new Exception("Can't get content from " . $url);
}
return $content;
} | php | private static function loadContent($url) {
//TODO: implement URL content load functionality with CURL and proxy
$ch = curl_init($url);
$options = array(
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
if ($content === false) {
throw new Exception("Can't get content from " . $url);
}
return $content;
} | [
"private",
"static",
"function",
"loadContent",
"(",
"$",
"url",
")",
"{",
"//TODO: implement URL content load functionality with CURL and proxy",
"$",
"ch",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"$",
"options",
"=",
"array",
"(",
"CURLOPT_RETURNTRANSFER",
"=... | Loads HTML content using CURL.
@param string $url URL of the page.
@return string HTML content (on success).
@throws Exception If content loading error occurred. | [
"Loads",
"HTML",
"content",
"using",
"CURL",
"."
] | bdfd6649211b76f3fb4ed7e3e13008588cc9a412 | https://github.com/dzarezenko/Asymptix-PHP-HTML-DOM-Parser/blob/bdfd6649211b76f3fb4ed7e3e13008588cc9a412/lib/HtmlDomParser/HtmlDomParser.php#L55-L72 | train |
proem/proem | lib/Proem/Service/Asset.php | Asset.validate | protected function validate($object)
{
$object = (object) $object;
if ($object instanceof $this->is) {
return $object;
}
throw new \DomainException(
sprintf(
"The Asset advertised as being of type %s is actually of type %s",
$this->is,
get_class($object)
)
);
} | php | protected function validate($object)
{
$object = (object) $object;
if ($object instanceof $this->is) {
return $object;
}
throw new \DomainException(
sprintf(
"The Asset advertised as being of type %s is actually of type %s",
$this->is,
get_class($object)
)
);
} | [
"protected",
"function",
"validate",
"(",
"$",
"object",
")",
"{",
"$",
"object",
"=",
"(",
"object",
")",
"$",
"object",
";",
"if",
"(",
"$",
"object",
"instanceof",
"$",
"this",
"->",
"is",
")",
"{",
"return",
"$",
"object",
";",
"}",
"throw",
"n... | Validate that this object is what it advertises.
@param object | [
"Validate",
"that",
"this",
"object",
"is",
"what",
"it",
"advertises",
"."
] | 31e00b315a12d6bfa65803ad49b3117d8b9c4da4 | https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Service/Asset.php#L72-L87 | train |
proem/proem | lib/Proem/Service/Asset.php | Asset.is | public function is($type = null)
{
if ($type === null) {
return $this->is;
} else {
return $type == $this->is;
}
} | php | public function is($type = null)
{
if ($type === null) {
return $this->is;
} else {
return $type == $this->is;
}
} | [
"public",
"function",
"is",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"is",
";",
"}",
"else",
"{",
"return",
"$",
"type",
"==",
"$",
"this",
"->",
"is",
";",
"}",
"}... | Retrieve the type of object this asset is, or test it's type
@return string | [
"Retrieve",
"the",
"type",
"of",
"object",
"this",
"asset",
"is",
"or",
"test",
"it",
"s",
"type"
] | 31e00b315a12d6bfa65803ad49b3117d8b9c4da4 | https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Service/Asset.php#L119-L126 | train |
proem/proem | lib/Proem/Service/Asset.php | Asset.single | public function single(\Closure $closure)
{
if ($this->asset === null) {
$this->asset = function ($asset = null, $assetManager = null) use ($closure) {
static $obj;
if ($obj === null) {
$obj = $this->validate($closure($asset, $assetManager));
}
return $obj;
};
}
return $this;
} | php | public function single(\Closure $closure)
{
if ($this->asset === null) {
$this->asset = function ($asset = null, $assetManager = null) use ($closure) {
static $obj;
if ($obj === null) {
$obj = $this->validate($closure($asset, $assetManager));
}
return $obj;
};
}
return $this;
} | [
"public",
"function",
"single",
"(",
"\\",
"Closure",
"$",
"closure",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"asset",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"asset",
"=",
"function",
"(",
"$",
"asset",
"=",
"null",
",",
"$",
"assetManager",
"... | Store an asset in such a way that when it is retrieved it will always return
the same instance.
Here we wrap a closure within a closure and store the returned value (an asset)
of the inner closure within a static variable in the outer closure. This insures
that whenever this Asset is retrieved it will always return the same instance.
<code>
$foo = (new Asset('Foo'))->single(function() {
return new Foo;
});
</code>
@param closure $closure | [
"Store",
"an",
"asset",
"in",
"such",
"a",
"way",
"that",
"when",
"it",
"is",
"retrieved",
"it",
"will",
"always",
"return",
"the",
"same",
"instance",
"."
] | 31e00b315a12d6bfa65803ad49b3117d8b9c4da4 | https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Service/Asset.php#L165-L177 | train |
dadajuice/zephyrus | src/Zephyrus/Utilities/Pager.php | Pager.createFullPages | private function createFullPages()
{
$pageStart = 1;
$pageEnd = $this->maxPage;
$tmp = $this->currentPage;
$pager = [];
while (($pageEnd - $tmp) < 4) {
$tmp--; // @codeCoverageIgnore
}
if ($tmp != $this->currentPage) {
$pageStart = 1 + ($tmp - 5); // @codeCoverageIgnore
}
if ($this->currentPage > 5 && $this->currentPage == $tmp) {
$pageStart = 1 + ($this->currentPage - 5);
}
$page = 0;
for ($i = $pageStart; $i < $tmp; $i++) {
$pager[$page] = '<a href="' . $this->buildHref($i) . '">' . $i . '</a>';
$page++;
}
for ($i = $tmp; $i <= $pageEnd && $page < 9; $i++) {
$pager[$page] = $this->buildAnchor($i);
$page++;
}
return $pager;
} | php | private function createFullPages()
{
$pageStart = 1;
$pageEnd = $this->maxPage;
$tmp = $this->currentPage;
$pager = [];
while (($pageEnd - $tmp) < 4) {
$tmp--; // @codeCoverageIgnore
}
if ($tmp != $this->currentPage) {
$pageStart = 1 + ($tmp - 5); // @codeCoverageIgnore
}
if ($this->currentPage > 5 && $this->currentPage == $tmp) {
$pageStart = 1 + ($this->currentPage - 5);
}
$page = 0;
for ($i = $pageStart; $i < $tmp; $i++) {
$pager[$page] = '<a href="' . $this->buildHref($i) . '">' . $i . '</a>';
$page++;
}
for ($i = $tmp; $i <= $pageEnd && $page < 9; $i++) {
$pager[$page] = $this->buildAnchor($i);
$page++;
}
return $pager;
} | [
"private",
"function",
"createFullPages",
"(",
")",
"{",
"$",
"pageStart",
"=",
"1",
";",
"$",
"pageEnd",
"=",
"$",
"this",
"->",
"maxPage",
";",
"$",
"tmp",
"=",
"$",
"this",
"->",
"currentPage",
";",
"$",
"pager",
"=",
"[",
"]",
";",
"while",
"("... | Generates anchors to be displayed when max page is over 9.
@return array | [
"Generates",
"anchors",
"to",
"be",
"displayed",
"when",
"max",
"page",
"is",
"over",
"9",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Utilities/Pager.php#L103-L132 | train |
dadajuice/zephyrus | src/Zephyrus/Utilities/Pager.php | Pager.createSimplePages | private function createSimplePages()
{
$pager = [];
for ($i = 1; $i <= $this->maxPage; $i++) {
$pager[$i - 1] = $this->buildAnchor($i);
}
return $pager;
} | php | private function createSimplePages()
{
$pager = [];
for ($i = 1; $i <= $this->maxPage; $i++) {
$pager[$i - 1] = $this->buildAnchor($i);
}
return $pager;
} | [
"private",
"function",
"createSimplePages",
"(",
")",
"{",
"$",
"pager",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"this",
"->",
"maxPage",
";",
"$",
"i",
"++",
")",
"{",
"$",
"pager",
"[",
"$",
"i",
"-",
... | Generates anchors to be displayed when max page is under 10.
@return array | [
"Generates",
"anchors",
"to",
"be",
"displayed",
"when",
"max",
"page",
"is",
"under",
"10",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Utilities/Pager.php#L139-L146 | train |
dadajuice/zephyrus | src/Zephyrus/Utilities/Pager.php | Pager.displayPager | private function displayPager()
{
$pager = ($this->maxPage > 9) ? $this->createFullPages() : $this->createSimplePages();
echo '<div class="pager">';
$this->displayLeftSide();
for ($i = 0; $i < count($pager); $i++) {
echo $pager[$i];
}
$this->displayRightSide();
echo "</div>";
} | php | private function displayPager()
{
$pager = ($this->maxPage > 9) ? $this->createFullPages() : $this->createSimplePages();
echo '<div class="pager">';
$this->displayLeftSide();
for ($i = 0; $i < count($pager); $i++) {
echo $pager[$i];
}
$this->displayRightSide();
echo "</div>";
} | [
"private",
"function",
"displayPager",
"(",
")",
"{",
"$",
"pager",
"=",
"(",
"$",
"this",
"->",
"maxPage",
">",
"9",
")",
"?",
"$",
"this",
"->",
"createFullPages",
"(",
")",
":",
"$",
"this",
"->",
"createSimplePages",
"(",
")",
";",
"echo",
"'<div... | Display the complete pager architecture. | [
"Display",
"the",
"complete",
"pager",
"architecture",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Utilities/Pager.php#L151-L161 | train |
phptuts/StarterBundleForSymfony | src/Service/SaveService.php | SaveService.save | public function save(SaveEntityInterface $entity)
{
$entity = $this->persist($entity);
$this->flush();
return $entity;
} | php | public function save(SaveEntityInterface $entity)
{
$entity = $this->persist($entity);
$this->flush();
return $entity;
} | [
"public",
"function",
"save",
"(",
"SaveEntityInterface",
"$",
"entity",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"persist",
"(",
"$",
"entity",
")",
";",
"$",
"this",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"entity",
";",
"}"
] | Saves an entity to the database
@param SaveEntityInterface $entity
@return SaveEntityInterface | [
"Saves",
"an",
"entity",
"to",
"the",
"database"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/SaveService.php#L64-L70 | train |
brightnucleus/injector | src/InjectionChain.php | InjectionChain.getByIndex | public function getByIndex($index)
{
if (! is_numeric($index)) {
throw new RuntimeException('Index needs to be a numeric value.');
}
$index = (int)$index;
if ($index < 0) {
$index += count($this->chain);
}
return isset($this->chain[$index])
? $this->chain[$index]
: false;
} | php | public function getByIndex($index)
{
if (! is_numeric($index)) {
throw new RuntimeException('Index needs to be a numeric value.');
}
$index = (int)$index;
if ($index < 0) {
$index += count($this->chain);
}
return isset($this->chain[$index])
? $this->chain[$index]
: false;
} | [
"public",
"function",
"getByIndex",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"index",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Index needs to be a numeric value.'",
")",
";",
"}",
"$",
"index",
"=",
"(",
"int",
... | Get the instantiation at a specific index.
The first (root) instantiation is 0, with each subsequent level adding 1
more to the index.
Provide a negative index to step back from the end of the chain.
Example: `getByIndex( -2 )` will return the second-to-last element.
@since 0.3.0
@param int $index Element index to retrieve. Negative value to fetch from the end of the chain.
@return string|false Class name of the element at the specified index. False if index not found.
@throws RuntimeException If the index is not a numeric value. | [
"Get",
"the",
"instantiation",
"at",
"a",
"specific",
"index",
"."
] | e1de664630bb48edadad55e8f8ff307dfaf8f140 | https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/InjectionChain.php#L79-L94 | train |
reliv/Rcm | admin/src/EventListener/DispatchListener.php | DispatchListener.getAdminPanel | public function getAdminPanel(MvcEvent $event)
{
$matchRoute = $event->getRouteMatch();
if (empty($matchRoute)) {
return null;
}
/** @var \RcmAdmin\Controller\AdminPanelController $adminPanelController */
$adminPanelController = $this->serviceLocator->get(
\RcmAdmin\Controller\AdminPanelController::class
);
$adminPanelController->setEvent($event);
$adminWrapper = $adminPanelController->getAdminWrapperAction();
if (!$adminWrapper instanceof ViewModel) {
return;
}
/** @var \Zend\View\Model\ViewModel $viewModel */
$layout = $event->getViewModel();
$layout->addChild($adminWrapper, 'rcmAdminPanel');
} | php | public function getAdminPanel(MvcEvent $event)
{
$matchRoute = $event->getRouteMatch();
if (empty($matchRoute)) {
return null;
}
/** @var \RcmAdmin\Controller\AdminPanelController $adminPanelController */
$adminPanelController = $this->serviceLocator->get(
\RcmAdmin\Controller\AdminPanelController::class
);
$adminPanelController->setEvent($event);
$adminWrapper = $adminPanelController->getAdminWrapperAction();
if (!$adminWrapper instanceof ViewModel) {
return;
}
/** @var \Zend\View\Model\ViewModel $viewModel */
$layout = $event->getViewModel();
$layout->addChild($adminWrapper, 'rcmAdminPanel');
} | [
"public",
"function",
"getAdminPanel",
"(",
"MvcEvent",
"$",
"event",
")",
"{",
"$",
"matchRoute",
"=",
"$",
"event",
"->",
"getRouteMatch",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"matchRoute",
")",
")",
"{",
"return",
"null",
";",
"}",
"/** @var... | Get Admin Panel
@param MvcEvent $event Zend MVC Event
@return void | [
"Get",
"Admin",
"Panel"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/EventListener/DispatchListener.php#L47-L71 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelCloning.php | ModelCloning.clone | public function clone($modelitemId)
{
event(new BeforeClone($this));
$this->beforeClone();
$this->doClone();
$this->afterClone();
event(new AfterClone($this));
} | php | public function clone($modelitemId)
{
event(new BeforeClone($this));
$this->beforeClone();
$this->doClone();
$this->afterClone();
event(new AfterClone($this));
} | [
"public",
"function",
"clone",
"(",
"$",
"modelitemId",
")",
"{",
"event",
"(",
"new",
"BeforeClone",
"(",
"$",
"this",
")",
")",
";",
"$",
"this",
"->",
"beforeClone",
"(",
")",
";",
"$",
"this",
"->",
"doClone",
"(",
")",
";",
"$",
"this",
"->",
... | Clone Action.
Fires off beforeClone(), doClone() and afterClone()
@param int $modelitemId
@return | [
"Clone",
"Action",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelCloning.php#L25-L36 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelCloning.php | ModelCloning.excludeOnClone | public function excludeOnClone()
{
return [
$this->model->getKeyName(),
$this->model->getCreatedAtColumn(),
$this->model->getUpdatedAtColumn(),
];
} | php | public function excludeOnClone()
{
return [
$this->model->getKeyName(),
$this->model->getCreatedAtColumn(),
$this->model->getUpdatedAtColumn(),
];
} | [
"public",
"function",
"excludeOnClone",
"(",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"model",
"->",
"getKeyName",
"(",
")",
",",
"$",
"this",
"->",
"model",
"->",
"getCreatedAtColumn",
"(",
")",
",",
"$",
"this",
"->",
"model",
"->",
"getUpdatedAtCol... | An Array of Fields to Exclude on Clone.
When cloning a Model ceratin data might need to be skipped
either because it is irrelevant (such as datestamps) or
because it is primary or unique data in the database.
@return array | [
"An",
"Array",
"of",
"Fields",
"to",
"Exclude",
"on",
"Clone",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelCloning.php#L75-L82 | train |
webeweb/core-bundle | Twig/Extension/Plugin/AbstractMaterialDesignIconicFontTwigExtension.php | AbstractMaterialDesignIconicFontTwigExtension.materialDesignIconicFontIcon | protected function materialDesignIconicFontIcon(MaterialDesignIconicFontIconInterface $icon) {
$attributes = [];
$attributes["class"][] = "zmdi";
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderName($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderSize($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderFixedWidth($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderBorder($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderPull($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderSpin($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderRotate($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderFlip($icon);
$attributes["style"] = MaterialDesignIconicFontIconRenderer::renderStyle($icon);
return static::coreHTMLElement("i", null, $attributes);
} | php | protected function materialDesignIconicFontIcon(MaterialDesignIconicFontIconInterface $icon) {
$attributes = [];
$attributes["class"][] = "zmdi";
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderName($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderSize($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderFixedWidth($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderBorder($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderPull($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderSpin($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderRotate($icon);
$attributes["class"][] = MaterialDesignIconicFontIconRenderer::renderFlip($icon);
$attributes["style"] = MaterialDesignIconicFontIconRenderer::renderStyle($icon);
return static::coreHTMLElement("i", null, $attributes);
} | [
"protected",
"function",
"materialDesignIconicFontIcon",
"(",
"MaterialDesignIconicFontIconInterface",
"$",
"icon",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"$",
"attributes",
"[",
"\"class\"",
"]",
"[",
"]",
"=",
"\"zmdi\"",
";",
"$",
"attributes",
"[",... | Displays a Material Design Iconic Font icon.
@param MaterialDesignIconicFontIconInterface $icon The icon.
@return string Returns the Material Design Iconic Font icon. | [
"Displays",
"a",
"Material",
"Design",
"Iconic",
"Font",
"icon",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/Plugin/AbstractMaterialDesignIconicFontTwigExtension.php#L34-L50 | train |
webeweb/core-bundle | Twig/Extension/Plugin/AbstractMaterialDesignIconicFontTwigExtension.php | AbstractMaterialDesignIconicFontTwigExtension.materialDesignIconicFontList | protected function materialDesignIconicFontList($items) {
$innerHTML = true === is_array($items) ? implode("\n", $items) : $items;
return static::coreHTMLElement("ul", $innerHTML, ["class" => "zmdi-hc-ul"]);
} | php | protected function materialDesignIconicFontList($items) {
$innerHTML = true === is_array($items) ? implode("\n", $items) : $items;
return static::coreHTMLElement("ul", $innerHTML, ["class" => "zmdi-hc-ul"]);
} | [
"protected",
"function",
"materialDesignIconicFontList",
"(",
"$",
"items",
")",
"{",
"$",
"innerHTML",
"=",
"true",
"===",
"is_array",
"(",
"$",
"items",
")",
"?",
"implode",
"(",
"\"\\n\"",
",",
"$",
"items",
")",
":",
"$",
"items",
";",
"return",
"sta... | Displays a Material Design Iconic Font list.
@param array|string $items The items.
@return string Returns the Material Design Iconic Font list. | [
"Displays",
"a",
"Material",
"Design",
"Iconic",
"Font",
"list",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/Plugin/AbstractMaterialDesignIconicFontTwigExtension.php#L58-L63 | train |
webeweb/core-bundle | Twig/Extension/Plugin/AbstractMaterialDesignIconicFontTwigExtension.php | AbstractMaterialDesignIconicFontTwigExtension.materialDesignIconicFontListIcon | protected function materialDesignIconicFontListIcon($icon, $content) {
$glyphicon = null !== $icon ? StringHelper::replace($icon, ["class=\"zmdi"], ["class=\"zmdi-hc-li zmdi"]) : "";
$innerHTML = null !== $content ? $content : "";
return static::coreHTMLElement("li", $glyphicon . $innerHTML);
} | php | protected function materialDesignIconicFontListIcon($icon, $content) {
$glyphicon = null !== $icon ? StringHelper::replace($icon, ["class=\"zmdi"], ["class=\"zmdi-hc-li zmdi"]) : "";
$innerHTML = null !== $content ? $content : "";
return static::coreHTMLElement("li", $glyphicon . $innerHTML);
} | [
"protected",
"function",
"materialDesignIconicFontListIcon",
"(",
"$",
"icon",
",",
"$",
"content",
")",
"{",
"$",
"glyphicon",
"=",
"null",
"!==",
"$",
"icon",
"?",
"StringHelper",
"::",
"replace",
"(",
"$",
"icon",
",",
"[",
"\"class=\\\"zmdi\"",
"]",
",",... | Displays a Material Design Iconic Font list icon.
@param string $icon The icon.
@param string $content The content.
@return string Returns the Material Design Iconic Font list icon. | [
"Displays",
"a",
"Material",
"Design",
"Iconic",
"Font",
"list",
"icon",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/Plugin/AbstractMaterialDesignIconicFontTwigExtension.php#L72-L78 | train |
phptuts/StarterBundleForSymfony | src/Service/S3Service.php | S3Service.uploadFileWithFolderAndName | public function uploadFileWithFolderAndName(UploadedFile $file, $folderPath, $fileName)
{
$folderPath = !empty($folderPath) ? $folderPath . '/' : '';
$path = $this->env . '/' . $folderPath . $fileName . '.'. $file->guessClientExtension();
/** @var Result $result */
$result = $this->client->putObject([
'ACL' => 'public-read',
'Bucket' => $this->bucketName,
'SourceFile' => $file->getRealPath(),
'Key' => $path
]);
return new FileUploadedModel($path, $result->get('ObjectURL'), FileUploadedModel::VENDOR_S3);
} | php | public function uploadFileWithFolderAndName(UploadedFile $file, $folderPath, $fileName)
{
$folderPath = !empty($folderPath) ? $folderPath . '/' : '';
$path = $this->env . '/' . $folderPath . $fileName . '.'. $file->guessClientExtension();
/** @var Result $result */
$result = $this->client->putObject([
'ACL' => 'public-read',
'Bucket' => $this->bucketName,
'SourceFile' => $file->getRealPath(),
'Key' => $path
]);
return new FileUploadedModel($path, $result->get('ObjectURL'), FileUploadedModel::VENDOR_S3);
} | [
"public",
"function",
"uploadFileWithFolderAndName",
"(",
"UploadedFile",
"$",
"file",
",",
"$",
"folderPath",
",",
"$",
"fileName",
")",
"{",
"$",
"folderPath",
"=",
"!",
"empty",
"(",
"$",
"folderPath",
")",
"?",
"$",
"folderPath",
".",
"'/'",
":",
"''",... | Uploads a file to amazon s3 using
@param UploadedFile $file
@param string $folderPath
@param string $fileName
@return string | [
"Uploads",
"a",
"file",
"to",
"amazon",
"s3",
"using"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/S3Service.php#L43-L57 | train |
phptuts/StarterBundleForSymfony | src/Service/S3Service.php | S3Service.uploadFile | public function uploadFile(UploadedFile $file)
{
$path = $this->env . '/' . md5(time() . random_int(1,100000)) . '.'. $file->guessClientExtension();
/** @var Result $result */
$result = $this->client->putObject([
'ACL' => 'public-read',
'Bucket' => $this->bucketName,
'SourceFile' => $file->getRealPath(),
'Key' => $path
]);
return new FileUploadedModel($path, $result->get('ObjectURL'), FileUploadedModel::VENDOR_S3);
} | php | public function uploadFile(UploadedFile $file)
{
$path = $this->env . '/' . md5(time() . random_int(1,100000)) . '.'. $file->guessClientExtension();
/** @var Result $result */
$result = $this->client->putObject([
'ACL' => 'public-read',
'Bucket' => $this->bucketName,
'SourceFile' => $file->getRealPath(),
'Key' => $path
]);
return new FileUploadedModel($path, $result->get('ObjectURL'), FileUploadedModel::VENDOR_S3);
} | [
"public",
"function",
"uploadFile",
"(",
"UploadedFile",
"$",
"file",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"env",
".",
"'/'",
".",
"md5",
"(",
"time",
"(",
")",
".",
"random_int",
"(",
"1",
",",
"100000",
")",
")",
".",
"'.'",
".",
"$",... | Generates a name for the file and uploads it to s3
@param UploadedFile $file
@return FileUploadedModel | [
"Generates",
"a",
"name",
"for",
"the",
"file",
"and",
"uploads",
"it",
"to",
"s3"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/S3Service.php#L65-L77 | train |
dadajuice/zephyrus | src/Zephyrus/Network/Cookie.php | Cookie.send | public function send()
{
$args = [
$this->name,
$this->value,
time() + $this->lifetime,
$this->path,
$this->domain,
$this->secure,
$this->httpOnly
];
$function = (!$this->urlEncodedValue) ? 'setrawcookie' : 'setcookie';
call_user_func_array($function, $args);
$_COOKIE[$this->name] = $this->value;
} | php | public function send()
{
$args = [
$this->name,
$this->value,
time() + $this->lifetime,
$this->path,
$this->domain,
$this->secure,
$this->httpOnly
];
$function = (!$this->urlEncodedValue) ? 'setrawcookie' : 'setcookie';
call_user_func_array($function, $args);
$_COOKIE[$this->name] = $this->value;
} | [
"public",
"function",
"send",
"(",
")",
"{",
"$",
"args",
"=",
"[",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
",",
"time",
"(",
")",
"+",
"$",
"this",
"->",
"lifetime",
",",
"$",
"this",
"->",
"path",
",",
"$",
"this",
"->",
... | Save the cookie in the HTTP response header using the default PHP
functions setcookie or setrawcookie depending on the need to save the
cookie value without url encoding.
@see http://php.net/manual/en/function.setcookie.php
@see http://php.net/manual/en/function.setrawcookie.php | [
"Save",
"the",
"cookie",
"in",
"the",
"HTTP",
"response",
"header",
"using",
"the",
"default",
"PHP",
"functions",
"setcookie",
"or",
"setrawcookie",
"depending",
"on",
"the",
"need",
"to",
"save",
"the",
"cookie",
"value",
"without",
"url",
"encoding",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Network/Cookie.php#L80-L94 | train |
c9s/CodeGen | src/UserClass.php | UserClass.extendClass | public function extendClass($className, $useAlias = true)
{
if ($className[0] === '\\' && $useAlias) {
$className = ltrim($className, '\\');
$this->useClass($className);
$_p = explode('\\', $className);
$shortClassName = end($_p);
$this->extends = new ClassName($shortClassName);
} else {
$this->extends = new ClassName($className);
}
} | php | public function extendClass($className, $useAlias = true)
{
if ($className[0] === '\\' && $useAlias) {
$className = ltrim($className, '\\');
$this->useClass($className);
$_p = explode('\\', $className);
$shortClassName = end($_p);
$this->extends = new ClassName($shortClassName);
} else {
$this->extends = new ClassName($className);
}
} | [
"public",
"function",
"extendClass",
"(",
"$",
"className",
",",
"$",
"useAlias",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"className",
"[",
"0",
"]",
"===",
"'\\\\'",
"&&",
"$",
"useAlias",
")",
"{",
"$",
"className",
"=",
"ltrim",
"(",
"$",
"classNam... | Add extends property
@param boolean $useAlias means append 'use' statement automatically. | [
"Add",
"extends",
"property"
] | 4fd58c53d65efd42d4612a8e627a59a51986ccb1 | https://github.com/c9s/CodeGen/blob/4fd58c53d65efd42d4612a8e627a59a51986ccb1/src/UserClass.php#L91-L103 | train |
c9s/CodeGen | src/UserClass.php | UserClass.generatePsr0ClassUnder | public function generatePsr0ClassUnder($directory, array $args = array())
{
$code = "<?php\n" . $this->render($args);
$classPath = $this->getPsr0ClassPath();
$path = $directory . DIRECTORY_SEPARATOR . $classPath;
if ($dir = dirname($path)) {
if (!file_exists($dir)) {
mkdir($dir, 0755, true);
}
}
if (file_put_contents($path, $code) === false) {
return false;
}
return $path;
} | php | public function generatePsr0ClassUnder($directory, array $args = array())
{
$code = "<?php\n" . $this->render($args);
$classPath = $this->getPsr0ClassPath();
$path = $directory . DIRECTORY_SEPARATOR . $classPath;
if ($dir = dirname($path)) {
if (!file_exists($dir)) {
mkdir($dir, 0755, true);
}
}
if (file_put_contents($path, $code) === false) {
return false;
}
return $path;
} | [
"public",
"function",
"generatePsr0ClassUnder",
"(",
"$",
"directory",
",",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"code",
"=",
"\"<?php\\n\"",
".",
"$",
"this",
"->",
"render",
"(",
"$",
"args",
")",
";",
"$",
"classPath",
"=",
... | for Foo\Bar class,
$this->generatePsr0ClassUnder('src');
will generate class at src/Foo/Bar.php | [
"for",
"Foo",
"\\",
"Bar",
"class"
] | 4fd58c53d65efd42d4612a8e627a59a51986ccb1 | https://github.com/c9s/CodeGen/blob/4fd58c53d65efd42d4612a8e627a59a51986ccb1/src/UserClass.php#L369-L383 | train |
noodle69/EdgarEzUICronBundle | src/bundle/Service/EzCronService.php | EzCronService.getCron | public function getCron(string $alias): ?EdgarEzCron
{
if ($cron = $this->repository->getCron($alias)) {
return $cron;
}
$crons = $this->getCrons();
if (isset($crons[$alias])) {
$cron = new EdgarEzCron();
$cron->setAlias($alias);
$cron->setExpression($crons[$alias]['expression']);
$cron->setArguments($crons[$alias]['arguments']);
$cron->setPriority($crons[$alias]['priority']);
$cron->setEnabled($crons[$alias]['enabled']);
return $cron;
}
return null;
} | php | public function getCron(string $alias): ?EdgarEzCron
{
if ($cron = $this->repository->getCron($alias)) {
return $cron;
}
$crons = $this->getCrons();
if (isset($crons[$alias])) {
$cron = new EdgarEzCron();
$cron->setAlias($alias);
$cron->setExpression($crons[$alias]['expression']);
$cron->setArguments($crons[$alias]['arguments']);
$cron->setPriority($crons[$alias]['priority']);
$cron->setEnabled($crons[$alias]['enabled']);
return $cron;
}
return null;
} | [
"public",
"function",
"getCron",
"(",
"string",
"$",
"alias",
")",
":",
"?",
"EdgarEzCron",
"{",
"if",
"(",
"$",
"cron",
"=",
"$",
"this",
"->",
"repository",
"->",
"getCron",
"(",
"$",
"alias",
")",
")",
"{",
"return",
"$",
"cron",
";",
"}",
"$",
... | Get Cron by alias.
@param string $alias
@return EdgarEzCron|null | [
"Get",
"Cron",
"by",
"alias",
"."
] | 54f31e1cd13a9fddc0d67b0481333ed64849c70a | https://github.com/noodle69/EdgarEzUICronBundle/blob/54f31e1cd13a9fddc0d67b0481333ed64849c70a/src/bundle/Service/EzCronService.php#L63-L82 | train |
noodle69/EdgarEzUICronBundle | src/bundle/Service/EzCronService.php | EzCronService.getCrons | public function getCrons(): array
{
/** @var CronInterface[] $crons */
$crons = $this->cronService->getCrons();
/** @var EdgarEzCron[] $ezCrons */
$ezCrons = $this->repository->listCrons();
$return = [];
foreach ($ezCrons as $ezCron) {
$return[$ezCron->getAlias()] = [
'alias' => $ezCron->getAlias(),
'expression' => $ezCron->getExpression(),
'arguments' => $ezCron->getArguments(),
'priority' => (int)$ezCron->getPriority(),
'enabled' => (int)$ezCron->getEnabled() == 1,
];
}
foreach ($crons as $cron) {
if (!isset($return[$cron->getAlias()])) {
$return[$cron->getAlias()] = [
'alias' => $cron->getAlias(),
'expression' => $cron->getExpression(),
'arguments' => $cron->getArguments(),
'priority' => (int)$cron->getPriority(),
'enabled' => true,
];
}
}
return $return;
} | php | public function getCrons(): array
{
/** @var CronInterface[] $crons */
$crons = $this->cronService->getCrons();
/** @var EdgarEzCron[] $ezCrons */
$ezCrons = $this->repository->listCrons();
$return = [];
foreach ($ezCrons as $ezCron) {
$return[$ezCron->getAlias()] = [
'alias' => $ezCron->getAlias(),
'expression' => $ezCron->getExpression(),
'arguments' => $ezCron->getArguments(),
'priority' => (int)$ezCron->getPriority(),
'enabled' => (int)$ezCron->getEnabled() == 1,
];
}
foreach ($crons as $cron) {
if (!isset($return[$cron->getAlias()])) {
$return[$cron->getAlias()] = [
'alias' => $cron->getAlias(),
'expression' => $cron->getExpression(),
'arguments' => $cron->getArguments(),
'priority' => (int)$cron->getPriority(),
'enabled' => true,
];
}
}
return $return;
} | [
"public",
"function",
"getCrons",
"(",
")",
":",
"array",
"{",
"/** @var CronInterface[] $crons */",
"$",
"crons",
"=",
"$",
"this",
"->",
"cronService",
"->",
"getCrons",
"(",
")",
";",
"/** @var EdgarEzCron[] $ezCrons */",
"$",
"ezCrons",
"=",
"$",
"this",
"->... | Return cron list detail.
@return array cron list | [
"Return",
"cron",
"list",
"detail",
"."
] | 54f31e1cd13a9fddc0d67b0481333ed64849c70a | https://github.com/noodle69/EdgarEzUICronBundle/blob/54f31e1cd13a9fddc0d67b0481333ed64849c70a/src/bundle/Service/EzCronService.php#L124-L155 | train |
webeweb/core-bundle | Form/Renderer/FormRenderer.php | FormRenderer.renderOption | public static function renderOption($option, TranslatorInterface $translator = null) {
if (null === $option) {
return null !== $translator ? $translator->trans("label.empty_selection") : "Empty selection";
}
// Check the implementation.
if (true === ($option instanceof TranslatedChoiceLabelInterface)) {
$output = $option->getTranslatedChoiceLabel($translator);
} else if (true === ($option instanceof ChoiceLabelInterface)) {
$output = $option->getChoiceLabel();
} else {
$output = "This option must implements [Translated]ChoiceLabelInterface";
}
if (true === ($option instanceof AlphabeticalTreeNodeInterface)) {
$multiplier = AlphabeticalTreeNodeHelper::getLevel($option);
$nbsp = html_entity_decode(" ");
$symbol = html_entity_decode(0 === $multiplier ? "─" : "└");
$output = implode("", [str_repeat($nbsp, $multiplier * 3), $symbol, $nbsp, $output]);
}
return $output;
} | php | public static function renderOption($option, TranslatorInterface $translator = null) {
if (null === $option) {
return null !== $translator ? $translator->trans("label.empty_selection") : "Empty selection";
}
// Check the implementation.
if (true === ($option instanceof TranslatedChoiceLabelInterface)) {
$output = $option->getTranslatedChoiceLabel($translator);
} else if (true === ($option instanceof ChoiceLabelInterface)) {
$output = $option->getChoiceLabel();
} else {
$output = "This option must implements [Translated]ChoiceLabelInterface";
}
if (true === ($option instanceof AlphabeticalTreeNodeInterface)) {
$multiplier = AlphabeticalTreeNodeHelper::getLevel($option);
$nbsp = html_entity_decode(" ");
$symbol = html_entity_decode(0 === $multiplier ? "─" : "└");
$output = implode("", [str_repeat($nbsp, $multiplier * 3), $symbol, $nbsp, $output]);
}
return $output;
} | [
"public",
"static",
"function",
"renderOption",
"(",
"$",
"option",
",",
"TranslatorInterface",
"$",
"translator",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"option",
")",
"{",
"return",
"null",
"!==",
"$",
"translator",
"?",
"$",
"translator",... | Render an option.
@param mixed $option The option.
@param TranslatorInterface|null $translator The translator service.
@return string Returns the rendered option. | [
"Render",
"an",
"option",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Form/Renderer/FormRenderer.php#L35-L58 | train |
webeweb/core-bundle | Form/Factory/FormFactory.php | FormFactory.newEntityType | public static function newEntityType($class, array $choices = [], array $options = []) {
// Check the options.
if (false === array_key_exists("empty", $options)) {
$options["empty"] = false;
}
if (false === array_key_exists("translator", $options)) {
$options["translator"] = null;
}
// Initialize the output.
$output = [
"class" => $class,
"choices" => [],
"choice_label" => function($entity) use ($options) {
return FormRenderer::renderOption($entity, $options["translator"]);
},
];
// Add an empty choice.
if (true === $options["empty"]) {
$output["choices"][] = null;
}
// Add all choices.
$output["choices"] = array_merge($output["choices"], $choices);
return $output;
} | php | public static function newEntityType($class, array $choices = [], array $options = []) {
// Check the options.
if (false === array_key_exists("empty", $options)) {
$options["empty"] = false;
}
if (false === array_key_exists("translator", $options)) {
$options["translator"] = null;
}
// Initialize the output.
$output = [
"class" => $class,
"choices" => [],
"choice_label" => function($entity) use ($options) {
return FormRenderer::renderOption($entity, $options["translator"]);
},
];
// Add an empty choice.
if (true === $options["empty"]) {
$output["choices"][] = null;
}
// Add all choices.
$output["choices"] = array_merge($output["choices"], $choices);
return $output;
} | [
"public",
"static",
"function",
"newEntityType",
"(",
"$",
"class",
",",
"array",
"$",
"choices",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"// Check the options.",
"if",
"(",
"false",
"===",
"array_key_exists",
"(",
"\"empty\""... | Create an entity type.
@param string $class The class.
@param array $choices The choices.
@param array $options The options.
@return array $choices Returns the entity type. | [
"Create",
"an",
"entity",
"type",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Form/Factory/FormFactory.php#L44-L72 | train |
noodle69/EdgarEzUICronBundle | src/bundle/Controller/CronController.php | CronController.listAction | public function listAction(): Response
{
$this->permissionAccess('uicron', 'list');
$crons = $this->cronService->getCrons();
return $this->render('@EdgarEzUICron/cron/list.html.twig', [
'crons' => $crons,
]);
} | php | public function listAction(): Response
{
$this->permissionAccess('uicron', 'list');
$crons = $this->cronService->getCrons();
return $this->render('@EdgarEzUICron/cron/list.html.twig', [
'crons' => $crons,
]);
} | [
"public",
"function",
"listAction",
"(",
")",
":",
"Response",
"{",
"$",
"this",
"->",
"permissionAccess",
"(",
"'uicron'",
",",
"'list'",
")",
";",
"$",
"crons",
"=",
"$",
"this",
"->",
"cronService",
"->",
"getCrons",
"(",
")",
";",
"return",
"$",
"t... | List all crons.
@return Response | [
"List",
"all",
"crons",
"."
] | 54f31e1cd13a9fddc0d67b0481333ed64849c70a | https://github.com/noodle69/EdgarEzUICronBundle/blob/54f31e1cd13a9fddc0d67b0481333ed64849c70a/src/bundle/Controller/CronController.php#L79-L88 | train |
noodle69/EdgarEzUICronBundle | src/bundle/Controller/CronController.php | CronController.permissionAccess | protected function permissionAccess(string $module, string $function): ?RedirectResponse
{
if (!$this->permissionResolver->hasAccess($module, $function)) {
$this->notificationHandler->error(
$this->translator->trans(
'edgar.ezuicron.permission.failed',
[],
'edgarezuicron'
)
);
return new RedirectResponse($this->generateUrl('ezplatform.dashboard', []));
}
return null;
} | php | protected function permissionAccess(string $module, string $function): ?RedirectResponse
{
if (!$this->permissionResolver->hasAccess($module, $function)) {
$this->notificationHandler->error(
$this->translator->trans(
'edgar.ezuicron.permission.failed',
[],
'edgarezuicron'
)
);
return new RedirectResponse($this->generateUrl('ezplatform.dashboard', []));
}
return null;
} | [
"protected",
"function",
"permissionAccess",
"(",
"string",
"$",
"module",
",",
"string",
"$",
"function",
")",
":",
"?",
"RedirectResponse",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"permissionResolver",
"->",
"hasAccess",
"(",
"$",
"module",
",",
"$",
"fu... | Check if user has permissions to access cron functions.
@param string $module
@param string $function
@return null|RedirectResponse | [
"Check",
"if",
"user",
"has",
"permissions",
"to",
"access",
"cron",
"functions",
"."
] | 54f31e1cd13a9fddc0d67b0481333ed64849c70a | https://github.com/noodle69/EdgarEzUICronBundle/blob/54f31e1cd13a9fddc0d67b0481333ed64849c70a/src/bundle/Controller/CronController.php#L185-L200 | train |
russsiq/bixbite | app/Models/File.php | File.path | public function path(string $thumbSize = null)
{
return $this->attributes['type']
.DS.$this->attributes['category']
.($thumbSize ? DS.$thumbSize : '')
.DS.$this->attributes['name'].'.'.$this->attributes['extension'];
} | php | public function path(string $thumbSize = null)
{
return $this->attributes['type']
.DS.$this->attributes['category']
.($thumbSize ? DS.$thumbSize : '')
.DS.$this->attributes['name'].'.'.$this->attributes['extension'];
} | [
"public",
"function",
"path",
"(",
"string",
"$",
"thumbSize",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"attributes",
"[",
"'type'",
"]",
".",
"DS",
".",
"$",
"this",
"->",
"attributes",
"[",
"'category'",
"]",
".",
"(",
"$",
"thumbSize",
... | Get path to file.
Used in `BBCMS\Models\Mutators\FileMutators` and `BBCMS\Models\Observers\FileObserver`.
@param string|null $thumbSize Thumbnail size for the image file.
@return string | [
"Get",
"path",
"to",
"file",
".",
"Used",
"in",
"BBCMS",
"\\",
"Models",
"\\",
"Mutators",
"\\",
"FileMutators",
"and",
"BBCMS",
"\\",
"Models",
"\\",
"Observers",
"\\",
"FileObserver",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/File.php#L83-L89 | train |
russsiq/bixbite | app/Models/File.php | File.storeAsZip | protected function storeAsZip(UploadedFile $file, array $data)
{
$disk = $this->storageDisk($data['disk']);
// Make zip archive name with full path.
$zipname = $disk->getDriver()->getAdapter()->getPathPrefix()
.$data['type'].DS.$data['category'].DS
.$data['name'].'.'.$data['extension'] . '.zip';
// Check if new file exists
if ($disk->exists($zipname)) {
throw new FileException(sprintf(
'File with name `%s` already exists!', $zipname
));
}
// Storing zip.
$zip = new \ZipArchive;
$zip->open($zipname, \ZipArchive::CREATE);
$zip->addFile($file->getRealPath(), $data['name'].'.'.$data['extension']);
$zip->close();
$this->attributes['name'] = $data['name'].'.'.$data['extension'];
$this->attributes['extension'] = 'zip';
$this->attributes['filesize'] = filesize($zipname);
} | php | protected function storeAsZip(UploadedFile $file, array $data)
{
$disk = $this->storageDisk($data['disk']);
// Make zip archive name with full path.
$zipname = $disk->getDriver()->getAdapter()->getPathPrefix()
.$data['type'].DS.$data['category'].DS
.$data['name'].'.'.$data['extension'] . '.zip';
// Check if new file exists
if ($disk->exists($zipname)) {
throw new FileException(sprintf(
'File with name `%s` already exists!', $zipname
));
}
// Storing zip.
$zip = new \ZipArchive;
$zip->open($zipname, \ZipArchive::CREATE);
$zip->addFile($file->getRealPath(), $data['name'].'.'.$data['extension']);
$zip->close();
$this->attributes['name'] = $data['name'].'.'.$data['extension'];
$this->attributes['extension'] = 'zip';
$this->attributes['filesize'] = filesize($zipname);
} | [
"protected",
"function",
"storeAsZip",
"(",
"UploadedFile",
"$",
"file",
",",
"array",
"$",
"data",
")",
"{",
"$",
"disk",
"=",
"$",
"this",
"->",
"storageDisk",
"(",
"$",
"data",
"[",
"'disk'",
"]",
")",
";",
"// Make zip archive name with full path.",
"$",... | Manipulate whith archive file. | [
"Manipulate",
"whith",
"archive",
"file",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/File.php#L147-L172 | train |
russsiq/bixbite | app/Models/File.php | File.storeAsImage | protected function storeAsImage(UploadedFile $file, array $data)
{
// Store uploaded image, to work it.
$this->storeAsFile($file, $data);
// Prepare local variables.
$properties = [];
$disk = $this->storageDisk($data['disk']);
$path_prefix = $data['type'].DS.$data['category'].DS;
$path_suffix = DS.$data['name'].'.'.$data['extension'];
$quality = setting('files.images_quality', 75);
$is_convert = setting('files.images_is_convert', true);
// Resave original file.
$image = $this->imageResave(
$this->getAbsolutePathAttribute(),
$disk->path($path_prefix.trim($path_suffix, DS)),
setting('files.images_max_width', 3840),
setting('files.images_max_height', 2160),
$quality, $is_convert
);
if ($image) {
// If extension has changed, then delete original file.
if ($data['extension'] != $image['extension']) {
$disk->delete($this->path);
}
// Revision attributes.
$this->attributes['mime_type'] = $image['mime_type'];
$this->attributes['extension'] = $image['extension'];
$this->attributes['filesize'] = $image['filesize'];
$properties = [
'width' => $image['width'],
'height' => $image['height'],
];
$path_suffix = DS.$data['name'].'.'.$image['extension'];
}
// Cutting images.
foreach ($this->thumbSizes() as $key => $value) {
@$disk->makeDirectory($path_prefix.$key);
$image = $this->imageResave(
$this->getAbsolutePathAttribute(),
$disk->path($path_prefix.$key.$path_suffix),
setting('files.images_'.$key.'_width', $value),
setting('files.images_'.$key.'_height', $value),
$quality, $is_convert
);
if (! $image) break;
// Add to options.
$properties += [
$key => [
'width' => $image['width'],
'height' => $image['height'],
'filesize' => $image['filesize'],
]
];
}
return $this->setAttribute('properties', $properties);
} | php | protected function storeAsImage(UploadedFile $file, array $data)
{
// Store uploaded image, to work it.
$this->storeAsFile($file, $data);
// Prepare local variables.
$properties = [];
$disk = $this->storageDisk($data['disk']);
$path_prefix = $data['type'].DS.$data['category'].DS;
$path_suffix = DS.$data['name'].'.'.$data['extension'];
$quality = setting('files.images_quality', 75);
$is_convert = setting('files.images_is_convert', true);
// Resave original file.
$image = $this->imageResave(
$this->getAbsolutePathAttribute(),
$disk->path($path_prefix.trim($path_suffix, DS)),
setting('files.images_max_width', 3840),
setting('files.images_max_height', 2160),
$quality, $is_convert
);
if ($image) {
// If extension has changed, then delete original file.
if ($data['extension'] != $image['extension']) {
$disk->delete($this->path);
}
// Revision attributes.
$this->attributes['mime_type'] = $image['mime_type'];
$this->attributes['extension'] = $image['extension'];
$this->attributes['filesize'] = $image['filesize'];
$properties = [
'width' => $image['width'],
'height' => $image['height'],
];
$path_suffix = DS.$data['name'].'.'.$image['extension'];
}
// Cutting images.
foreach ($this->thumbSizes() as $key => $value) {
@$disk->makeDirectory($path_prefix.$key);
$image = $this->imageResave(
$this->getAbsolutePathAttribute(),
$disk->path($path_prefix.$key.$path_suffix),
setting('files.images_'.$key.'_width', $value),
setting('files.images_'.$key.'_height', $value),
$quality, $is_convert
);
if (! $image) break;
// Add to options.
$properties += [
$key => [
'width' => $image['width'],
'height' => $image['height'],
'filesize' => $image['filesize'],
]
];
}
return $this->setAttribute('properties', $properties);
} | [
"protected",
"function",
"storeAsImage",
"(",
"UploadedFile",
"$",
"file",
",",
"array",
"$",
"data",
")",
"{",
"// Store uploaded image, to work it.",
"$",
"this",
"->",
"storeAsFile",
"(",
"$",
"file",
",",
"$",
"data",
")",
";",
"// Prepare local variables.",
... | Manipulate whith image file.
@param Illuminate\Http\UploadedFile $file
@param array $data
@return mixed | [
"Manipulate",
"whith",
"image",
"file",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/File.php#L181-L245 | train |
Kryptonit3/Sonarr | src/Sonarr.php | Sonarr.getCommand | public function getCommand($id = null)
{
$uri = ($id) ? 'command/' . $id : 'command';
$response = [
'uri' => $uri,
'type' => 'get',
'data' => []
];
return $this->processRequest($response);
} | php | public function getCommand($id = null)
{
$uri = ($id) ? 'command/' . $id : 'command';
$response = [
'uri' => $uri,
'type' => 'get',
'data' => []
];
return $this->processRequest($response);
} | [
"public",
"function",
"getCommand",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"uri",
"=",
"(",
"$",
"id",
")",
"?",
"'command/'",
".",
"$",
"id",
":",
"'command'",
";",
"$",
"response",
"=",
"[",
"'uri'",
"=>",
"$",
"uri",
",",
"'type'",
"=>",
... | Queries the status of a previously started command, or all currently started commands.
@param null $id Unique ID of the command
@return array|object|string | [
"Queries",
"the",
"status",
"of",
"a",
"previously",
"started",
"command",
"or",
"all",
"currently",
"started",
"commands",
"."
] | e30c5c783a837270bcef81571ca9b95909c52e5e | https://github.com/Kryptonit3/Sonarr/blob/e30c5c783a837270bcef81571ca9b95909c52e5e/src/Sonarr.php#L80-L91 | train |
Kryptonit3/Sonarr | src/Sonarr.php | Sonarr.postCommand | public function postCommand($name, array $params = null)
{
$uri = 'command';
$uriData = [
'name' => $name
];
if (is_array($params)) {
foreach($params as $key=>$value) {
$uriData[$key] = $value;
}
}
$response = [
'uri' => $uri,
'type' => 'post',
'data' => $uriData
];
return $this->processRequest($response);
} | php | public function postCommand($name, array $params = null)
{
$uri = 'command';
$uriData = [
'name' => $name
];
if (is_array($params)) {
foreach($params as $key=>$value) {
$uriData[$key] = $value;
}
}
$response = [
'uri' => $uri,
'type' => 'post',
'data' => $uriData
];
return $this->processRequest($response);
} | [
"public",
"function",
"postCommand",
"(",
"$",
"name",
",",
"array",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"uri",
"=",
"'command'",
";",
"$",
"uriData",
"=",
"[",
"'name'",
"=>",
"$",
"name",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"params"... | Publish a new command for Sonarr to run.
These commands are executed asynchronously; use GET to retrieve the current status.
Commands and their parameters can be found here:
https://github.com/Sonarr/Sonarr/wiki/Command#commands
@param $name
@param array|null $params
@return string | [
"Publish",
"a",
"new",
"command",
"for",
"Sonarr",
"to",
"run",
".",
"These",
"commands",
"are",
"executed",
"asynchronously",
";",
"use",
"GET",
"to",
"retrieve",
"the",
"current",
"status",
"."
] | e30c5c783a837270bcef81571ca9b95909c52e5e | https://github.com/Kryptonit3/Sonarr/blob/e30c5c783a837270bcef81571ca9b95909c52e5e/src/Sonarr.php#L104-L124 | train |
Kryptonit3/Sonarr | src/Sonarr.php | Sonarr.getRelease | public function getRelease($episodeId)
{
$uri = 'release';
$uriData = [
'episodeId' => $episodeId
];
$response = [
'uri' => $uri,
'type' => 'get',
'data' => $uriData
];
return $this->processRequest($response);
} | php | public function getRelease($episodeId)
{
$uri = 'release';
$uriData = [
'episodeId' => $episodeId
];
$response = [
'uri' => $uri,
'type' => 'get',
'data' => $uriData
];
return $this->processRequest($response);
} | [
"public",
"function",
"getRelease",
"(",
"$",
"episodeId",
")",
"{",
"$",
"uri",
"=",
"'release'",
";",
"$",
"uriData",
"=",
"[",
"'episodeId'",
"=>",
"$",
"episodeId",
"]",
";",
"$",
"response",
"=",
"[",
"'uri'",
"=>",
"$",
"uri",
",",
"'type'",
"=... | Get release by episode id
@param $episodeId
@return string | [
"Get",
"release",
"by",
"episode",
"id"
] | e30c5c783a837270bcef81571ca9b95909c52e5e | https://github.com/Kryptonit3/Sonarr/blob/e30c5c783a837270bcef81571ca9b95909c52e5e/src/Sonarr.php#L361-L375 | train |
Kryptonit3/Sonarr | src/Sonarr.php | Sonarr.postReleasePush | public function postReleasePush($title, $downloadUrl, $downloadProtocol, $publishDate)
{
$uri = 'release';
$uriData = [
'title' => $title,
'downloadUrl' => $downloadUrl,
'downloadProtocol' => $downloadProtocol,
'publishDate' => $publishDate
];
$response = [
'uri' => $uri,
'type' => 'post',
'data' => $uriData
];
return $this->processRequest($response);
} | php | public function postReleasePush($title, $downloadUrl, $downloadProtocol, $publishDate)
{
$uri = 'release';
$uriData = [
'title' => $title,
'downloadUrl' => $downloadUrl,
'downloadProtocol' => $downloadProtocol,
'publishDate' => $publishDate
];
$response = [
'uri' => $uri,
'type' => 'post',
'data' => $uriData
];
return $this->processRequest($response);
} | [
"public",
"function",
"postReleasePush",
"(",
"$",
"title",
",",
"$",
"downloadUrl",
",",
"$",
"downloadProtocol",
",",
"$",
"publishDate",
")",
"{",
"$",
"uri",
"=",
"'release'",
";",
"$",
"uriData",
"=",
"[",
"'title'",
"=>",
"$",
"title",
",",
"'downl... | Push a release to download client
@param $title
@param $downloadUrl
@param $downloadProtocol (Usenet or Torrent)
@param $publishDate (ISO8601 Date)
@return string | [
"Push",
"a",
"release",
"to",
"download",
"client"
] | e30c5c783a837270bcef81571ca9b95909c52e5e | https://github.com/Kryptonit3/Sonarr/blob/e30c5c783a837270bcef81571ca9b95909c52e5e/src/Sonarr.php#L410-L427 | train |
Kryptonit3/Sonarr | src/Sonarr.php | Sonarr.postSeries | public function postSeries(array $data, $onlyFutureEpisodes = true)
{
$uri = 'series';
$uriData = [];
// Required
$uriData['tvdbId'] = $data['tvdbId'];
$uriData['title'] = $data['title'];
$uriData['qualityProfileId'] = $data['qualityProfileId'];
if ( array_key_exists('titleSlug', $data) ) { $uriData['titleSlug'] = $data['titleSlug']; }
if ( array_key_exists('seasons', $data) ) { $uriData['seasons'] = $data['seasons']; }
if ( array_key_exists('path', $data) ) { $uriData['path'] = $data['path']; }
if ( array_key_exists('rootFolderPath', $data) ) { $uriData['rootFolderPath'] = $data['rootFolderPath']; }
if ( array_key_exists('tvRageId', $data) ) { $uriData['tvRageId'] = $data['tvRageId']; }
$uriData['seasonFolder'] = ( array_key_exists('seasonFolder', $data) ) ? $data['seasonFolder'] : true;
if ( array_key_exists('monitored', $data) ) { $uriData['monitored'] = $data['monitored']; }
if ( $onlyFutureEpisodes ) {
$uriData['addOptions'] = [
'ignoreEpisodesWithFiles' => true,
'ignoreEpisodesWithoutFiles' => true
];
}
$response = [
'uri' => $uri,
'type' => 'post',
'data' => $uriData
];
return $this->processRequest($response);
} | php | public function postSeries(array $data, $onlyFutureEpisodes = true)
{
$uri = 'series';
$uriData = [];
// Required
$uriData['tvdbId'] = $data['tvdbId'];
$uriData['title'] = $data['title'];
$uriData['qualityProfileId'] = $data['qualityProfileId'];
if ( array_key_exists('titleSlug', $data) ) { $uriData['titleSlug'] = $data['titleSlug']; }
if ( array_key_exists('seasons', $data) ) { $uriData['seasons'] = $data['seasons']; }
if ( array_key_exists('path', $data) ) { $uriData['path'] = $data['path']; }
if ( array_key_exists('rootFolderPath', $data) ) { $uriData['rootFolderPath'] = $data['rootFolderPath']; }
if ( array_key_exists('tvRageId', $data) ) { $uriData['tvRageId'] = $data['tvRageId']; }
$uriData['seasonFolder'] = ( array_key_exists('seasonFolder', $data) ) ? $data['seasonFolder'] : true;
if ( array_key_exists('monitored', $data) ) { $uriData['monitored'] = $data['monitored']; }
if ( $onlyFutureEpisodes ) {
$uriData['addOptions'] = [
'ignoreEpisodesWithFiles' => true,
'ignoreEpisodesWithoutFiles' => true
];
}
$response = [
'uri' => $uri,
'type' => 'post',
'data' => $uriData
];
return $this->processRequest($response);
} | [
"public",
"function",
"postSeries",
"(",
"array",
"$",
"data",
",",
"$",
"onlyFutureEpisodes",
"=",
"true",
")",
"{",
"$",
"uri",
"=",
"'series'",
";",
"$",
"uriData",
"=",
"[",
"]",
";",
"// Required\r",
"$",
"uriData",
"[",
"'tvdbId'",
"]",
"=",
"$",... | Adds a new series to your collection
NOTE: if you do not add the required params, then the series wont function.
Some of these without the others can indeed make a "series". But it wont function properly in Sonarr.
Required: tvdbId (int) title (string) qualityProfileId (int) titleSlug (string) seasons (array)
See GET output for format
path (string) - full path to the series on disk or rootFolderPath (string)
Full path will be created by combining the rootFolderPath with the series title
Optional: tvRageId (int) seasonFolder (bool) monitored (bool)
@param array $data
@param bool|true $onlyFutureEpisodes It can be used to control which episodes Sonarr monitors
after adding the series, setting to true (default) will only monitor future episodes.
@return array|object|string | [
"Adds",
"a",
"new",
"series",
"to",
"your",
"collection"
] | e30c5c783a837270bcef81571ca9b95909c52e5e | https://github.com/Kryptonit3/Sonarr/blob/e30c5c783a837270bcef81571ca9b95909c52e5e/src/Sonarr.php#L485-L516 | train |
Kryptonit3/Sonarr | src/Sonarr.php | Sonarr.deleteSeries | public function deleteSeries($id, $deleteFiles = true)
{
$uri = 'series';
$uriData = [];
$uriData['deleteFiles'] = ($deleteFiles) ? 'true' : 'false';
$response = [
'uri' => $uri . '/' . $id,
'type' => 'delete',
'data' => $uriData
];
return $this->processRequest($response);
} | php | public function deleteSeries($id, $deleteFiles = true)
{
$uri = 'series';
$uriData = [];
$uriData['deleteFiles'] = ($deleteFiles) ? 'true' : 'false';
$response = [
'uri' => $uri . '/' . $id,
'type' => 'delete',
'data' => $uriData
];
return $this->processRequest($response);
} | [
"public",
"function",
"deleteSeries",
"(",
"$",
"id",
",",
"$",
"deleteFiles",
"=",
"true",
")",
"{",
"$",
"uri",
"=",
"'series'",
";",
"$",
"uriData",
"=",
"[",
"]",
";",
"$",
"uriData",
"[",
"'deleteFiles'",
"]",
"=",
"(",
"$",
"deleteFiles",
")",
... | Delete the series with the given ID
@param int $id
@param bool|true $deleteFiles
@return string | [
"Delete",
"the",
"series",
"with",
"the",
"given",
"ID"
] | e30c5c783a837270bcef81571ca9b95909c52e5e | https://github.com/Kryptonit3/Sonarr/blob/e30c5c783a837270bcef81571ca9b95909c52e5e/src/Sonarr.php#L525-L538 | train |
Kryptonit3/Sonarr | src/Sonarr.php | Sonarr.processRequest | protected function processRequest(array $request)
{
try {
$response = $this->_request(
[
'uri' => $request['uri'],
'type' => $request['type'],
'data' => $request['data']
]
);
} catch ( \Exception $e ) {
echo json_encode(array(
'error' => array(
'msg' => $e->getMessage(),
'code' => $e->getCode(),
),
));
exit();
}
return $response->getBody()->getContents();
} | php | protected function processRequest(array $request)
{
try {
$response = $this->_request(
[
'uri' => $request['uri'],
'type' => $request['type'],
'data' => $request['data']
]
);
} catch ( \Exception $e ) {
echo json_encode(array(
'error' => array(
'msg' => $e->getMessage(),
'code' => $e->getCode(),
),
));
exit();
}
return $response->getBody()->getContents();
} | [
"protected",
"function",
"processRequest",
"(",
"array",
"$",
"request",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"_request",
"(",
"[",
"'uri'",
"=>",
"$",
"request",
"[",
"'uri'",
"]",
",",
"'type'",
"=>",
"$",
"request",
"[",
... | Process requests, catch exceptions, return json response
@param array $request uri, type, data from method
@return string json encoded response | [
"Process",
"requests",
"catch",
"exceptions",
"return",
"json",
"response"
] | e30c5c783a837270bcef81571ca9b95909c52e5e | https://github.com/Kryptonit3/Sonarr/blob/e30c5c783a837270bcef81571ca9b95909c52e5e/src/Sonarr.php#L637-L659 | train |
laravelflare/flare | src/Flare/Admin/Models/AttributeCollection.php | AttributeCollection.add | public function add($items = [])
{
if (!is_array($items) || func_num_args() > 1) {
$items = func_get_args();
}
$this->push($this->formatInnerField(null, $items));
} | php | public function add($items = [])
{
if (!is_array($items) || func_num_args() > 1) {
$items = func_get_args();
}
$this->push($this->formatInnerField(null, $items));
} | [
"public",
"function",
"add",
"(",
"$",
"items",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"items",
")",
"||",
"func_num_args",
"(",
")",
">",
"1",
")",
"{",
"$",
"items",
"=",
"func_get_args",
"(",
")",
";",
"}",
"$",
"this... | Allows adding fields to the Attribute Collection.
@param array $items | [
"Allows",
"adding",
"fields",
"to",
"the",
"Attribute",
"Collection",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/AttributeCollection.php#L70-L77 | train |
laravelflare/flare | src/Flare/Admin/Models/AttributeCollection.php | AttributeCollection.createField | private function createField($type, $name, $value, $inner)
{
if ($this->hasOptionsMethod($name)) {
$inner = array_merge($inner, ['options' => $this->getOptions($name)]);
}
return $this->fields->create($type, $name, $this->getValue($name), $inner);
} | php | private function createField($type, $name, $value, $inner)
{
if ($this->hasOptionsMethod($name)) {
$inner = array_merge($inner, ['options' => $this->getOptions($name)]);
}
return $this->fields->create($type, $name, $this->getValue($name), $inner);
} | [
"private",
"function",
"createField",
"(",
"$",
"type",
",",
"$",
"name",
",",
"$",
"value",
",",
"$",
"inner",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasOptionsMethod",
"(",
"$",
"name",
")",
")",
"{",
"$",
"inner",
"=",
"array_merge",
"(",
"$",... | Create and return a Field Instance.
@param mixed $type
@param string $name
@param string $value
@param mixed $inner
@return | [
"Create",
"and",
"return",
"a",
"Field",
"Instance",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/AttributeCollection.php#L137-L144 | train |
webeweb/core-bundle | Helper/CommandHelper.php | CommandHelper.getCheckbox | public static function getCheckbox($checked) {
if (true === $checked) {
return sprintf("<fg=green;options=bold>%s</>", OSHelper::isWindows() ? "OK" : "\xE2\x9C\x94");
}
return sprintf("<fg=yellow;options=bold>%s</>", OSHelper::isWindows() ? "KO" : "!");
} | php | public static function getCheckbox($checked) {
if (true === $checked) {
return sprintf("<fg=green;options=bold>%s</>", OSHelper::isWindows() ? "OK" : "\xE2\x9C\x94");
}
return sprintf("<fg=yellow;options=bold>%s</>", OSHelper::isWindows() ? "KO" : "!");
} | [
"public",
"static",
"function",
"getCheckbox",
"(",
"$",
"checked",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"checked",
")",
"{",
"return",
"sprintf",
"(",
"\"<fg=green;options=bold>%s</>\"",
",",
"OSHelper",
"::",
"isWindows",
"(",
")",
"?",
"\"OK\"",
":",
... | Get a checkbox.
@param bool $checked Checked ?
@return string Returns the checkbox. | [
"Get",
"a",
"checkbox",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Helper/CommandHelper.php#L28-L33 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.