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
ec-europa/oe-robo
src/SettingsProcessor.php
SettingsProcessor.getStatement
private function getStatement($variable, $name, $value) { $output = var_export($value, TRUE); if (is_array($value)) { $output = str_replace(' ', '', $output); $output = str_replace("\n", "", $output); $output = str_replace("=>", " => ", $output); $output = str_replace(",)", ")", $output); $output = str_replace("),", "), ", $output); } return sprintf('$%s["%s"] = %s;', $variable, $name, $output); }
php
private function getStatement($variable, $name, $value) { $output = var_export($value, TRUE); if (is_array($value)) { $output = str_replace(' ', '', $output); $output = str_replace("\n", "", $output); $output = str_replace("=>", " => ", $output); $output = str_replace(",)", ")", $output); $output = str_replace("),", "), ", $output); } return sprintf('$%s["%s"] = %s;', $variable, $name, $output); }
[ "private", "function", "getStatement", "(", "$", "variable", ",", "$", "name", ",", "$", "value", ")", "{", "$", "output", "=", "var_export", "(", "$", "value", ",", "TRUE", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", ...
Get variable assignment statement. @param string $variable Variable name. @param string $name Setting name. @param mixed $value Setting value. @return string Full statement.
[ "Get", "variable", "assignment", "statement", "." ]
ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02
https://github.com/ec-europa/oe-robo/blob/ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02/src/SettingsProcessor.php#L97-L107
train
cmsgears/module-core
common/services/entities/UserService.php
UserService.create
public function create( $model, $config = [] ) { $avatar = isset( $config[ 'avatar' ] ) ? $config[ 'avatar' ] : null; $banner = isset( $config[ 'banner' ] ) ? $config[ 'banner' ] : null; $video = isset( $config[ 'video' ] ) ? $config[ 'video' ] : null; // Set Attributes $model->registeredAt = DateUtil::getDateTime(); if( empty( $model->status ) ) { $model->status = User::STATUS_NEW; } if( empty( $model->type ) ) { $model->type = CoreGlobal::TYPE_DEFAULT; } if( empty( $model->slug ) ) { $model->slug = $model->username; } // Generate Tokens $model->generateVerifyToken(); $model->generateAuthKey(); $model->generateOtp(); // Save Files $this->fileService->saveFiles( $model, [ 'avatarId' => $avatar, 'bannerId' => $banner, 'videoId' => $video ] ); return parent::create( $model, $config ); }
php
public function create( $model, $config = [] ) { $avatar = isset( $config[ 'avatar' ] ) ? $config[ 'avatar' ] : null; $banner = isset( $config[ 'banner' ] ) ? $config[ 'banner' ] : null; $video = isset( $config[ 'video' ] ) ? $config[ 'video' ] : null; // Set Attributes $model->registeredAt = DateUtil::getDateTime(); if( empty( $model->status ) ) { $model->status = User::STATUS_NEW; } if( empty( $model->type ) ) { $model->type = CoreGlobal::TYPE_DEFAULT; } if( empty( $model->slug ) ) { $model->slug = $model->username; } // Generate Tokens $model->generateVerifyToken(); $model->generateAuthKey(); $model->generateOtp(); // Save Files $this->fileService->saveFiles( $model, [ 'avatarId' => $avatar, 'bannerId' => $banner, 'videoId' => $video ] ); return parent::create( $model, $config ); }
[ "public", "function", "create", "(", "$", "model", ",", "$", "config", "=", "[", "]", ")", "{", "$", "avatar", "=", "isset", "(", "$", "config", "[", "'avatar'", "]", ")", "?", "$", "config", "[", "'avatar'", "]", ":", "null", ";", "$", "banner",...
Create the user and associate avatar, banner or video. @param User $model @param array $config @return User
[ "Create", "the", "user", "and", "associate", "avatar", "banner", "or", "video", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L490-L523
train
cmsgears/module-core
common/services/entities/UserService.php
UserService.register
public function register( $model, $config = [] ) { $status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : User::STATUS_NEW; $user = isset( $config[ 'user' ] ) ? $config[ 'user' ] : $this->getModelObject(); $date = DateUtil::getDateTime(); $user->email = $model->email; $user->username = $model->username; $user->title = $model->title; $user->firstName = $model->firstName; $user->middleName = $model->middleName; $user->lastName = $model->lastName; $user->mobile = $model->mobile; $user->dob = $model->dob; $user->registeredAt = $date; $user->status = $status; $user->type = $model->type; $user->generatePassword( $model->password ); $user->generateVerifyToken(); $user->generateAuthKey(); $user->generateOtp(); $user->save(); return $user; }
php
public function register( $model, $config = [] ) { $status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : User::STATUS_NEW; $user = isset( $config[ 'user' ] ) ? $config[ 'user' ] : $this->getModelObject(); $date = DateUtil::getDateTime(); $user->email = $model->email; $user->username = $model->username; $user->title = $model->title; $user->firstName = $model->firstName; $user->middleName = $model->middleName; $user->lastName = $model->lastName; $user->mobile = $model->mobile; $user->dob = $model->dob; $user->registeredAt = $date; $user->status = $status; $user->type = $model->type; $user->generatePassword( $model->password ); $user->generateVerifyToken(); $user->generateAuthKey(); $user->generateOtp(); $user->save(); return $user; }
[ "public", "function", "register", "(", "$", "model", ",", "$", "config", "=", "[", "]", ")", "{", "$", "status", "=", "isset", "(", "$", "config", "[", "'status'", "]", ")", "?", "$", "config", "[", "'status'", "]", ":", "User", "::", "STATUS_NEW",...
Register User - It register the user and set status to new. It also generate verification token. @param RegisterForm $model @return User
[ "Register", "User", "-", "It", "register", "the", "user", "and", "set", "status", "to", "new", ".", "It", "also", "generate", "verification", "token", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L531-L558
train
cmsgears/module-core
common/services/entities/UserService.php
UserService.verify
public function verify( $user, $token ) { // Check Token if( $user->isVerifyTokenValid( $token ) ) { $modelClass = static::$modelClass; // Find existing user $userToUpdate = $modelClass::findById( $user->id ); // User need admin approval if( Yii::$app->core->isUserApproval() ) { $userToUpdate->verify(); } // Direct approval and activation else { $userToUpdate->status = User::STATUS_ACTIVE; } $userToUpdate->unsetVerifyToken(); $userToUpdate->update(); return true; } return false; }
php
public function verify( $user, $token ) { // Check Token if( $user->isVerifyTokenValid( $token ) ) { $modelClass = static::$modelClass; // Find existing user $userToUpdate = $modelClass::findById( $user->id ); // User need admin approval if( Yii::$app->core->isUserApproval() ) { $userToUpdate->verify(); } // Direct approval and activation else { $userToUpdate->status = User::STATUS_ACTIVE; } $userToUpdate->unsetVerifyToken(); $userToUpdate->update(); return true; } return false; }
[ "public", "function", "verify", "(", "$", "user", ",", "$", "token", ")", "{", "// Check Token", "if", "(", "$", "user", "->", "isVerifyTokenValid", "(", "$", "token", ")", ")", "{", "$", "modelClass", "=", "static", "::", "$", "modelClass", ";", "// F...
Confirm User - The method verify and confirm user by accepting valid token sent via mail. It also set user status to active. @param User $user @param string $token @return boolean
[ "Confirm", "User", "-", "The", "method", "verify", "and", "confirm", "user", "by", "accepting", "valid", "token", "sent", "via", "mail", ".", "It", "also", "set", "user", "status", "to", "active", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L603-L632
train
cmsgears/module-core
common/services/entities/UserService.php
UserService.forgotPassword
public function forgotPassword( $user ) { $modelClass = static::$modelClass; // Find existing user $userToUpdate = $modelClass::findById( $user->id ); // Generate Token $userToUpdate->generateResetToken(); $userToUpdate->generateOtp(); // Update User $userToUpdate->update(); return $userToUpdate; }
php
public function forgotPassword( $user ) { $modelClass = static::$modelClass; // Find existing user $userToUpdate = $modelClass::findById( $user->id ); // Generate Token $userToUpdate->generateResetToken(); $userToUpdate->generateOtp(); // Update User $userToUpdate->update(); return $userToUpdate; }
[ "public", "function", "forgotPassword", "(", "$", "user", ")", "{", "$", "modelClass", "=", "static", "::", "$", "modelClass", ";", "// Find existing user", "$", "userToUpdate", "=", "$", "modelClass", "::", "findById", "(", "$", "user", "->", "id", ")", "...
The method generate a new reset token which can be used later to update user password. @param User $user @return User
[ "The", "method", "generate", "a", "new", "reset", "token", "which", "can", "be", "used", "later", "to", "update", "user", "password", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L682-L697
train
cmsgears/module-core
common/services/entities/UserService.php
UserService.resetPassword
public function resetPassword( $user, $resetForm ) { $modelClass = static::$modelClass; // Find existing user $userToUpdate = $modelClass::findById( $user->id ); // Generate Password $userToUpdate->generatePassword( $resetForm->password ); $userToUpdate->unsetResetToken(); // User need admin approval if( Yii::$app->core->isUserApproval() ) { $userToUpdate->verify(); } // Direct approval and activation else { $userToUpdate->status = User::STATUS_ACTIVE; } // Update User $userToUpdate->update(); return $userToUpdate; }
php
public function resetPassword( $user, $resetForm ) { $modelClass = static::$modelClass; // Find existing user $userToUpdate = $modelClass::findById( $user->id ); // Generate Password $userToUpdate->generatePassword( $resetForm->password ); $userToUpdate->unsetResetToken(); // User need admin approval if( Yii::$app->core->isUserApproval() ) { $userToUpdate->verify(); } // Direct approval and activation else { $userToUpdate->status = User::STATUS_ACTIVE; } // Update User $userToUpdate->update(); return $userToUpdate; }
[ "public", "function", "resetPassword", "(", "$", "user", ",", "$", "resetForm", ")", "{", "$", "modelClass", "=", "static", "::", "$", "modelClass", ";", "// Find existing user", "$", "userToUpdate", "=", "$", "modelClass", "::", "findById", "(", "$", "user"...
The method generate a new secure password for the given password and unset the reset token. It also activate user. @param User $user @param ResetPasswordForm $resetForm @param boolean $activate @return User
[ "The", "method", "generate", "a", "new", "secure", "password", "for", "the", "given", "password", "and", "unset", "the", "reset", "token", ".", "It", "also", "activate", "user", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L706-L732
train
cmsgears/module-core
common/services/entities/UserService.php
UserService.delete
public function delete( $model, $config = [] ) { // Delete Files $this->fileService->deleteMultiple( [ $model->avatar, $model->banner, $model->video ] ); // Delete Notifications Yii::$app->eventManager->deleteNotificationsByUserId( $model->id ); // Delete model return parent::delete( $model, $config ); }
php
public function delete( $model, $config = [] ) { // Delete Files $this->fileService->deleteMultiple( [ $model->avatar, $model->banner, $model->video ] ); // Delete Notifications Yii::$app->eventManager->deleteNotificationsByUserId( $model->id ); // Delete model return parent::delete( $model, $config ); }
[ "public", "function", "delete", "(", "$", "model", ",", "$", "config", "=", "[", "]", ")", "{", "// Delete Files", "$", "this", "->", "fileService", "->", "deleteMultiple", "(", "[", "$", "model", "->", "avatar", ",", "$", "model", "->", "banner", ",",...
The project must extend this class to delete project specific resources associated with the user. @param \cmsgears\core\common\models\entities\User $model @param array $config @return boolean
[ "The", "project", "must", "extend", "this", "class", "to", "delete", "project", "specific", "resources", "associated", "with", "the", "user", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L758-L768
train
mcaskill/charcoal-support
src/View/Mustache/DateTimeHelpers.php
DateTimeHelpers.parseDateTime
private function parseDateTime($time) { if (is_string($time)) { try { $time = new DateTimeImmutable($time); } catch (Exception $e) { throw new InvalidArgumentException(sprintf( 'Invalid date/time value: %s', $e->getMessage() ), $e->getCode(), $e); } } if ($time instanceof DateTime) { try { $time = DateTimeImmutable::createFromMutable($time); } catch (Exception $e) { throw new InvalidArgumentException(sprintf( 'Invalid date/time value: %s', $e->getMessage() ), $e->getCode(), $e); } } if ($time instanceof DateTimeImmutable) { $time = $time->setTimezone(static::$now->getTimezone()); } else { throw new InvalidArgumentException('Invalid date/time for the presenter.'); } return $time; }
php
private function parseDateTime($time) { if (is_string($time)) { try { $time = new DateTimeImmutable($time); } catch (Exception $e) { throw new InvalidArgumentException(sprintf( 'Invalid date/time value: %s', $e->getMessage() ), $e->getCode(), $e); } } if ($time instanceof DateTime) { try { $time = DateTimeImmutable::createFromMutable($time); } catch (Exception $e) { throw new InvalidArgumentException(sprintf( 'Invalid date/time value: %s', $e->getMessage() ), $e->getCode(), $e); } } if ($time instanceof DateTimeImmutable) { $time = $time->setTimezone(static::$now->getTimezone()); } else { throw new InvalidArgumentException('Invalid date/time for the presenter.'); } return $time; }
[ "private", "function", "parseDateTime", "(", "$", "time", ")", "{", "if", "(", "is_string", "(", "$", "time", ")", ")", "{", "try", "{", "$", "time", "=", "new", "DateTimeImmutable", "(", "$", "time", ")", ";", "}", "catch", "(", "Exception", "$", ...
Parse the given date and time into a DateTime object. @param DateTimeInterface|string $time A date/time string or a DateTime object. @throws InvalidArgumentException If the date/time value is invalid. @return DateTimeImmutable
[ "Parse", "the", "given", "date", "and", "time", "into", "a", "DateTime", "object", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/View/Mustache/DateTimeHelpers.php#L111-L142
train
mcaskill/charcoal-support
src/View/Mustache/DateTimeHelpers.php
DateTimeHelpers.offsetSet
public function offsetSet($key, $value) { if (!is_string($key)) { throw new InvalidArgumentException('The name of the macro must be a string.'); } if (!is_callable($value)) { throw new InvalidArgumentException('The macro must be a callable value.'); } $this->macros[$key] = $value; }
php
public function offsetSet($key, $value) { if (!is_string($key)) { throw new InvalidArgumentException('The name of the macro must be a string.'); } if (!is_callable($value)) { throw new InvalidArgumentException('The macro must be a callable value.'); } $this->macros[$key] = $value; }
[ "public", "function", "offsetSet", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The name of the macro must be a string.'", ")", ";", "}", "if", ...
Set the macro at a given offset. @param mixed $key The name of the macro. @param mixed $value The macro's effect. @throws InvalidArgumentException If the $key or $value are invalid. @return void
[ "Set", "the", "macro", "at", "a", "given", "offset", "." ]
2138a34463ca6865bf3a60635aa11381a9ae73c5
https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/View/Mustache/DateTimeHelpers.php#L433-L444
train
spiral/exceptions
src/AbstractHandler.php
AbstractHandler.getStacktrace
protected function getStacktrace(\Throwable $e): array { $stacktrace = $e->getTrace(); if (empty($stacktrace)) { return []; } //Let's let's clarify exception location $header = [ 'file' => $e->getFile(), 'line' => $e->getLine() ] + $stacktrace[0]; if ($stacktrace[0] != $header) { array_unshift($stacktrace, $header); } return $stacktrace; }
php
protected function getStacktrace(\Throwable $e): array { $stacktrace = $e->getTrace(); if (empty($stacktrace)) { return []; } //Let's let's clarify exception location $header = [ 'file' => $e->getFile(), 'line' => $e->getLine() ] + $stacktrace[0]; if ($stacktrace[0] != $header) { array_unshift($stacktrace, $header); } return $stacktrace; }
[ "protected", "function", "getStacktrace", "(", "\\", "Throwable", "$", "e", ")", ":", "array", "{", "$", "stacktrace", "=", "$", "e", "->", "getTrace", "(", ")", ";", "if", "(", "empty", "(", "$", "stacktrace", ")", ")", "{", "return", "[", "]", ";...
Normalized exception stacktrace. @param \Throwable $e @return array
[ "Normalized", "exception", "stacktrace", "." ]
9735a00b189ce61317cd49a9d6ec630f68cee381
https://github.com/spiral/exceptions/blob/9735a00b189ce61317cd49a9d6ec630f68cee381/src/AbstractHandler.php#L31-L49
train
nails/module-email
admin/controllers/Email.php
Email.resend
public function resend() { if (!userHasPermission('admin:email:email:resend')) { unauthorised(); } // -------------------------------------------------------------------------- $oEmailer = Factory::service('Emailer', 'nails/module-email'); // -------------------------------------------------------------------------- $oUri = Factory::service('Uri'); $iEmailId = $oUri->segment(5); $sReturn = $this->input->get('return') ? $this->input->get('return') : 'admin/email/index'; if ($oEmailer->resend($iEmailId)) { $sStatus = 'success'; $sMessage = 'Message was resent successfully.'; } else { $sStatus = 'error'; $sMessage = 'Message failed to resend. ' . $oEmailer->lastError(); } $oSession = Factory::service('Session', 'nails/module-auth'); $oSession->setFlashData($sStatus, $sMessage); redirect($sReturn); }
php
public function resend() { if (!userHasPermission('admin:email:email:resend')) { unauthorised(); } // -------------------------------------------------------------------------- $oEmailer = Factory::service('Emailer', 'nails/module-email'); // -------------------------------------------------------------------------- $oUri = Factory::service('Uri'); $iEmailId = $oUri->segment(5); $sReturn = $this->input->get('return') ? $this->input->get('return') : 'admin/email/index'; if ($oEmailer->resend($iEmailId)) { $sStatus = 'success'; $sMessage = 'Message was resent successfully.'; } else { $sStatus = 'error'; $sMessage = 'Message failed to resend. ' . $oEmailer->lastError(); } $oSession = Factory::service('Session', 'nails/module-auth'); $oSession->setFlashData($sStatus, $sMessage); redirect($sReturn); }
[ "public", "function", "resend", "(", ")", "{", "if", "(", "!", "userHasPermission", "(", "'admin:email:email:resend'", ")", ")", "{", "unauthorised", "(", ")", ";", "}", "// --------------------------------------------------------------------------", "$", "oEmailer", "=...
Resent an email @return void
[ "Resent", "an", "email" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/admin/controllers/Email.php#L154-L181
train
ethical-jobs/ethical-jobs-foundation-php
src/Utils/ApiResources.php
ApiResources.getTransformerFromResource
public static function getTransformerFromResource($resource) { if (! in_array($resource, static::getResources())) { return ''; } $resourceName = studly_case(str_singular($resource)); return 'App\Transformers\\'.$resourceName.'s\\'.$resourceName.'Transformer'; }
php
public static function getTransformerFromResource($resource) { if (! in_array($resource, static::getResources())) { return ''; } $resourceName = studly_case(str_singular($resource)); return 'App\Transformers\\'.$resourceName.'s\\'.$resourceName.'Transformer'; }
[ "public", "static", "function", "getTransformerFromResource", "(", "$", "resource", ")", "{", "if", "(", "!", "in_array", "(", "$", "resource", ",", "static", "::", "getResources", "(", ")", ")", ")", "{", "return", "''", ";", "}", "$", "resourceName", "...
Returns transformer class from a REST resource identifier @param String $resource @return String
[ "Returns", "transformer", "class", "from", "a", "REST", "resource", "identifier" ]
35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8
https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Utils/ApiResources.php#L53-L62
train
rodrigoiii/skeleton-core
src/classes/BaseCommand.php
BaseCommand.configure
protected function configure() { $this->setName($this->name); $this->setDescription($this->description); foreach ($this->arguments as $argument) { $this->getDefinition()->addArgument($argument); } foreach ($this->options as $option) { $this->getDefinition()->addOption($option); } }
php
protected function configure() { $this->setName($this->name); $this->setDescription($this->description); foreach ($this->arguments as $argument) { $this->getDefinition()->addArgument($argument); } foreach ($this->options as $option) { $this->getDefinition()->addOption($option); } }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "setName", "(", "$", "this", "->", "name", ")", ";", "$", "this", "->", "setDescription", "(", "$", "this", "->", "description", ")", ";", "foreach", "(", "$", "this", "->", "arg...
Set the name and description @return void
[ "Set", "the", "name", "and", "description" ]
5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0
https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/BaseCommand.php#L68-L80
train
locomotivemtl/charcoal-property
src/Charcoal/Property/ImageProperty.php
ImageProperty.imageFactory
public function imageFactory() { if ($this->imageFactory === null) { $this->imageFactory = $this->createImageFactory(); } return $this->imageFactory; }
php
public function imageFactory() { if ($this->imageFactory === null) { $this->imageFactory = $this->createImageFactory(); } return $this->imageFactory; }
[ "public", "function", "imageFactory", "(", ")", "{", "if", "(", "$", "this", "->", "imageFactory", "===", "null", ")", "{", "$", "this", "->", "imageFactory", "=", "$", "this", "->", "createImageFactory", "(", ")", ";", "}", "return", "$", "this", "->"...
Retrieve the image factory. @return ImageFactory
[ "Retrieve", "the", "image", "factory", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ImageProperty.php#L74-L81
train
locomotivemtl/charcoal-property
src/Charcoal/Property/ImageProperty.php
ImageProperty.setDriverType
public function setDriverType($type) { if (!is_string($type)) { throw new InvalidArgumentException(sprintf( 'Image driver type must be a string, received %s', (is_object($type) ? get_class($type) : gettype($type)) )); } $this->driverType = $type; return $this; }
php
public function setDriverType($type) { if (!is_string($type)) { throw new InvalidArgumentException(sprintf( 'Image driver type must be a string, received %s', (is_object($type) ? get_class($type) : gettype($type)) )); } $this->driverType = $type; return $this; }
[ "public", "function", "setDriverType", "(", "$", "type", ")", "{", "if", "(", "!", "is_string", "(", "$", "type", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Image driver type must be a string, received %s'", ",", "(", "is_o...
Set the name of the property's image processing driver. @param string $type The processing engine. @throws InvalidArgumentException If the drive type is not a string. @return ImageProperty Chainable
[ "Set", "the", "name", "of", "the", "property", "s", "image", "processing", "driver", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ImageProperty.php#L92-L104
train
locomotivemtl/charcoal-property
src/Charcoal/Property/ImageProperty.php
ImageProperty.setApplyEffects
public function setApplyEffects($event) { if ($event === false) { $this->applyEffects = self::EFFECTS_EVENT_NEVER; return $this; } if ($event === null || $event === '') { $this->applyEffects = self::EFFECTS_EVENT_SAVE; return $this; } if (!in_array($event, $this->acceptedEffectsEvents())) { if (!is_string($event)) { $event = (is_object($event) ? get_class($event) : gettype($event)); } throw new OutOfBoundsException(sprintf( 'Unsupported image property event "%s" provided', $event )); } $this->applyEffects = $event; return $this; }
php
public function setApplyEffects($event) { if ($event === false) { $this->applyEffects = self::EFFECTS_EVENT_NEVER; return $this; } if ($event === null || $event === '') { $this->applyEffects = self::EFFECTS_EVENT_SAVE; return $this; } if (!in_array($event, $this->acceptedEffectsEvents())) { if (!is_string($event)) { $event = (is_object($event) ? get_class($event) : gettype($event)); } throw new OutOfBoundsException(sprintf( 'Unsupported image property event "%s" provided', $event )); } $this->applyEffects = $event; return $this; }
[ "public", "function", "setApplyEffects", "(", "$", "event", ")", "{", "if", "(", "$", "event", "===", "false", ")", "{", "$", "this", "->", "applyEffects", "=", "self", "::", "EFFECTS_EVENT_NEVER", ";", "return", "$", "this", ";", "}", "if", "(", "$", ...
Set whether effects should be applied. @param mixed $event When to apply affects. @throws OutOfBoundsException If the effects event does not exist. @return ImageProperty Chainable
[ "Set", "whether", "effects", "should", "be", "applied", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ImageProperty.php#L123-L148
train
locomotivemtl/charcoal-property
src/Charcoal/Property/ImageProperty.php
ImageProperty.applyEffects
public function applyEffects($event = null) { if ($event !== null) { if (!in_array($event, $this->acceptedEffectsEvents())) { if (!is_string($event)) { $event = (is_object($event) ? get_class($event) : gettype($event)); } throw new OutOfBoundsException(sprintf( 'Unsupported image property event "%s" provided', $event )); } return $this->applyEffects === $event; } return $this->applyEffects; }
php
public function applyEffects($event = null) { if ($event !== null) { if (!in_array($event, $this->acceptedEffectsEvents())) { if (!is_string($event)) { $event = (is_object($event) ? get_class($event) : gettype($event)); } throw new OutOfBoundsException(sprintf( 'Unsupported image property event "%s" provided', $event )); } return $this->applyEffects === $event; } return $this->applyEffects; }
[ "public", "function", "applyEffects", "(", "$", "event", "=", "null", ")", "{", "if", "(", "$", "event", "!==", "null", ")", "{", "if", "(", "!", "in_array", "(", "$", "event", ",", "$", "this", "->", "acceptedEffectsEvents", "(", ")", ")", ")", "{...
Determine if effects should be applied. @param string|boolean $event A specific event to check or a global flag to set. @throws OutOfBoundsException If the effects event does not exist. @return mixed If an $event is provided, returns TRUE or FALSE if the property applies effects for the given event. Otherwise, returns the property's condition on effects.
[ "Determine", "if", "effects", "should", "be", "applied", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ImageProperty.php#L158-L175
train
rodrigoiii/skeleton-core
src/classes/Console/Commands/MakeModelCommand.php
MakeModelCommand.makeTemplate
private function makeTemplate($sub_directories, $pre_model_path, $model, $no_get_id) { $file = __DIR__ . "/../templates/model/"; $file .= $no_get_id ? "model.php.dist" : "model-with-get-id.php.dist"; if (file_exists($file)) { $template = strtr(file_get_contents($file), [ '{{namespace}}' => get_app_namespace(), '{{sub_directories}}' => $sub_directories, '{{model}}' => $model ]); $file_path = "{$pre_model_path}/{$model}.php"; $file = fopen($file_path, "w"); fwrite($file, $template); fclose($file); return file_exists($file_path); } return false; }
php
private function makeTemplate($sub_directories, $pre_model_path, $model, $no_get_id) { $file = __DIR__ . "/../templates/model/"; $file .= $no_get_id ? "model.php.dist" : "model-with-get-id.php.dist"; if (file_exists($file)) { $template = strtr(file_get_contents($file), [ '{{namespace}}' => get_app_namespace(), '{{sub_directories}}' => $sub_directories, '{{model}}' => $model ]); $file_path = "{$pre_model_path}/{$model}.php"; $file = fopen($file_path, "w"); fwrite($file, $template); fclose($file); return file_exists($file_path); } return false; }
[ "private", "function", "makeTemplate", "(", "$", "sub_directories", ",", "$", "pre_model_path", ",", "$", "model", ",", "$", "no_get_id", ")", "{", "$", "file", "=", "__DIR__", ".", "\"/../templates/model/\"", ";", "$", "file", ".=", "$", "no_get_id", "?", ...
Create the model template @depends handle @param string $sub_directories @param string $pre_model_path @param string $model @param boolean $no_get_id @return boolean
[ "Create", "the", "model", "template" ]
5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0
https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/Console/Commands/MakeModelCommand.php#L85-L108
train
apioo/psx-http
src/MediaType.php
MediaType.match
public function match(MediaType $mediaType) { return ($this->type == '*' && $this->subType == '*') || ($this->type == $mediaType->getType() && $this->subType == $mediaType->getSubType()) || ($this->type == $mediaType->getType() && $this->subType == '*'); }
php
public function match(MediaType $mediaType) { return ($this->type == '*' && $this->subType == '*') || ($this->type == $mediaType->getType() && $this->subType == $mediaType->getSubType()) || ($this->type == $mediaType->getType() && $this->subType == '*'); }
[ "public", "function", "match", "(", "MediaType", "$", "mediaType", ")", "{", "return", "(", "$", "this", "->", "type", "==", "'*'", "&&", "$", "this", "->", "subType", "==", "'*'", ")", "||", "(", "$", "this", "->", "type", "==", "$", "mediaType", ...
Checks whether the given media type would match @param \PSX\Http\MediaType $mediaType @return boolean
[ "Checks", "whether", "the", "given", "media", "type", "would", "match" ]
c54d7212cfb513df84f810429aa34c6ac9942c01
https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/MediaType.php#L121-L126
train
phPoirot/Std
src/Struct/CollectionObject.php
CollectionObject.del
function del($hashOrObject) { $hash = $this->_attainHash($hashOrObject); if (!array_key_exists($hash, $this->_objs)) return false; unset($this->_objs[$hash]); return true; }
php
function del($hashOrObject) { $hash = $this->_attainHash($hashOrObject); if (!array_key_exists($hash, $this->_objs)) return false; unset($this->_objs[$hash]); return true; }
[ "function", "del", "(", "$", "hashOrObject", ")", "{", "$", "hash", "=", "$", "this", "->", "_attainHash", "(", "$", "hashOrObject", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "hash", ",", "$", "this", "->", "_objs", ")", ")", "return", ...
Detach By ETag Hash Or Object Match @param string|object $hashOrObject @return boolean Return true on detach match otherwise false
[ "Detach", "By", "ETag", "Hash", "Or", "Object", "Match" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/CollectionObject.php#L123-L131
train
phPoirot/Std
src/Struct/CollectionObject.php
CollectionObject.getData
function getData($object) { if (! $this->has($object) ) throw new \Exception('Object Not Found.'); $hash = $this->genETag($object); return $this->_objs[$hash]['data']; }
php
function getData($object) { if (! $this->has($object) ) throw new \Exception('Object Not Found.'); $hash = $this->genETag($object); return $this->_objs[$hash]['data']; }
[ "function", "getData", "(", "$", "object", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "object", ")", ")", "throw", "new", "\\", "Exception", "(", "'Object Not Found.'", ")", ";", "$", "hash", "=", "$", "this", "->", "genETag", "(...
Get Tag Data Of Specific Object note: use ETag to attain target object for performance @param $object @throws \Exception Object not stored @return array
[ "Get", "Tag", "Data", "Of", "Specific", "Object" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/CollectionObject.php#L209-L217
train
phPoirot/Std
src/Struct/CollectionObject.php
CollectionObject.setData
function setData($object, array $data) { if (! $this->has($object) ) throw new \Exception('Object Not Found.'); if ($data == array_values($data)) throw new \InvalidArgumentException('Data tags must be associative array.'); $hash = $this->genETag($object); $this->_objs[$hash]['data'] = $data; return $this; }
php
function setData($object, array $data) { if (! $this->has($object) ) throw new \Exception('Object Not Found.'); if ($data == array_values($data)) throw new \InvalidArgumentException('Data tags must be associative array.'); $hash = $this->genETag($object); $this->_objs[$hash]['data'] = $data; return $this; }
[ "function", "setData", "(", "$", "object", ",", "array", "$", "data", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "object", ")", ")", "throw", "new", "\\", "Exception", "(", "'Object Not Found.'", ")", ";", "if", "(", "$", "data",...
Set Data For Stored Object note: use ETag to attain target object for performance @param object $object @param array $data Associative Array @throws \Exception Object not stored @return $this
[ "Set", "Data", "For", "Stored", "Object" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/CollectionObject.php#L231-L243
train
phPoirot/Std
src/Struct/CollectionObject.php
CollectionObject.genETag
function genETag($object) { $this->doValidateObject($object); $hash = md5(\Poirot\Std\flatten($object)); return $hash; }
php
function genETag($object) { $this->doValidateObject($object); $hash = md5(\Poirot\Std\flatten($object)); return $hash; }
[ "function", "genETag", "(", "$", "object", ")", "{", "$", "this", "->", "doValidateObject", "(", "$", "object", ")", ";", "$", "hash", "=", "md5", "(", "\\", "Poirot", "\\", "Std", "\\", "flatten", "(", "$", "object", ")", ")", ";", "return", "$", ...
Calculate a unique identifier for the contained objects @param object $object @return string
[ "Calculate", "a", "unique", "identifier", "for", "the", "contained", "objects" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/CollectionObject.php#L252-L258
train
phPoirot/Std
src/fixes/Mixin.php
Mixin.bindTo
function bindTo($class) { if (!is_object($class)) throw new \Exception(sprintf( 'Given class must be an object (%s) given.' , \Poirot\Std\flatten($class) )); $this->_t__bindTo = $class; return $this; }
php
function bindTo($class) { if (!is_object($class)) throw new \Exception(sprintf( 'Given class must be an object (%s) given.' , \Poirot\Std\flatten($class) )); $this->_t__bindTo = $class; return $this; }
[ "function", "bindTo", "(", "$", "class", ")", "{", "if", "(", "!", "is_object", "(", "$", "class", ")", ")", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Given class must be an object (%s) given.'", ",", "\\", "Poirot", "\\", "Std", "\\", "fla...
Bind Current Methods to Given Object @param $class @throws \Exception @return $this
[ "Bind", "Current", "Methods", "to", "Given", "Object" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/fixes/Mixin.php#L61-L72
train
phPoirot/Std
src/fixes/Mixin.php
Mixin.hasMethod
function hasMethod($methodName) { if (isset($this->_t__methods[$methodName])) return true; # check bind object $return = false; $bind = $this->getBindTo(); if (!$bind instanceof self) { $return = method_exists($bind, $methodName); } return $return; }
php
function hasMethod($methodName) { if (isset($this->_t__methods[$methodName])) return true; # check bind object $return = false; $bind = $this->getBindTo(); if (!$bind instanceof self) { $return = method_exists($bind, $methodName); } return $return; }
[ "function", "hasMethod", "(", "$", "methodName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_t__methods", "[", "$", "methodName", "]", ")", ")", "return", "true", ";", "# check bind object", "$", "return", "=", "false", ";", "$", "bind", "=...
Has Method Name Exists? @param string $methodName @return bool
[ "Has", "Method", "Name", "Exists?" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/fixes/Mixin.php#L109-L123
train
nails/module-email
email/controllers/View.php
View.index
public function index() { $oUri = Factory::service('Uri'); $oEmailer = Factory::service('Emailer', 'nails/module-email'); $sRef = $oUri->segment(3); $sGuid = $oUri->segment(4); $sHash = $oUri->segment(5); // -------------------------------------------------------------------------- // Fetch the email if (is_numeric($sRef)) { $oEmail = $oEmailer->getById($sRef); } else { $oEmail = $oEmailer->getByRef($sRef); } if (!$oEmail || !$oEmailer->validateHash($oEmail->ref, $sGuid, $sHash)) { show404(); } if (Environment::is(Environment::ENV_DEV)) { $oAsset = Factory::service('Asset'); $oAsset->load('debugger.min.css', 'nails/module-email'); Factory::service('View') ->setData([ 'oEmail' => $oEmail, ]) ->load([ 'structure/header/blank', 'email/view', 'structure/footer/blank', ]); } else { $oOutput = Factory::service('Output'); $oOutput->set_output($oEmail->body->html); } }
php
public function index() { $oUri = Factory::service('Uri'); $oEmailer = Factory::service('Emailer', 'nails/module-email'); $sRef = $oUri->segment(3); $sGuid = $oUri->segment(4); $sHash = $oUri->segment(5); // -------------------------------------------------------------------------- // Fetch the email if (is_numeric($sRef)) { $oEmail = $oEmailer->getById($sRef); } else { $oEmail = $oEmailer->getByRef($sRef); } if (!$oEmail || !$oEmailer->validateHash($oEmail->ref, $sGuid, $sHash)) { show404(); } if (Environment::is(Environment::ENV_DEV)) { $oAsset = Factory::service('Asset'); $oAsset->load('debugger.min.css', 'nails/module-email'); Factory::service('View') ->setData([ 'oEmail' => $oEmail, ]) ->load([ 'structure/header/blank', 'email/view', 'structure/footer/blank', ]); } else { $oOutput = Factory::service('Output'); $oOutput->set_output($oEmail->body->html); } }
[ "public", "function", "index", "(", ")", "{", "$", "oUri", "=", "Factory", "::", "service", "(", "'Uri'", ")", ";", "$", "oEmailer", "=", "Factory", "::", "service", "(", "'Emailer'", ",", "'nails/module-email'", ")", ";", "$", "sRef", "=", "$", "oUri"...
Handle view online requests
[ "Handle", "view", "online", "requests" ]
42183b33a0465ab302f66a7b4f881410275eb6a4
https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/email/controllers/View.php#L22-L62
train
locomotivemtl/charcoal-property
src/Charcoal/Property/StorablePropertyTrait.php
StorablePropertyTrait.fields
public function fields($val) { if (empty($this->fields)) { $this->generateFields($val); } else { $this->updatedFields($val); } return $this->fields; }
php
public function fields($val) { if (empty($this->fields)) { $this->generateFields($val); } else { $this->updatedFields($val); } return $this->fields; }
[ "public", "function", "fields", "(", "$", "val", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "fields", ")", ")", "{", "$", "this", "->", "generateFields", "(", "$", "val", ")", ";", "}", "else", "{", "$", "this", "->", "updatedFields", ...
Retrieve the property's storage fields. @param mixed $val The value to set as field value. @return PropertyField[]
[ "Retrieve", "the", "property", "s", "storage", "fields", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L69-L78
train
locomotivemtl/charcoal-property
src/Charcoal/Property/StorablePropertyTrait.php
StorablePropertyTrait.fieldNames
public function fieldNames() { $fields = []; if ($this->l10n()) { foreach ($this->translator()->availableLocales() as $langCode) { $fields[$langCode] = $this->l10nIdent($langCode); } } else { $fields[] = $this->ident(); } return $fields; }
php
public function fieldNames() { $fields = []; if ($this->l10n()) { foreach ($this->translator()->availableLocales() as $langCode) { $fields[$langCode] = $this->l10nIdent($langCode); } } else { $fields[] = $this->ident(); } return $fields; }
[ "public", "function", "fieldNames", "(", ")", "{", "$", "fields", "=", "[", "]", ";", "if", "(", "$", "this", "->", "l10n", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "translator", "(", ")", "->", "availableLocales", "(", ")", "as", "...
Retrieve the property's storage field names. @return string[]
[ "Retrieve", "the", "property", "s", "storage", "field", "names", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L85-L97
train
locomotivemtl/charcoal-property
src/Charcoal/Property/StorablePropertyTrait.php
StorablePropertyTrait.storageVal
public function storageVal($val) { if ($val === null) { // Do not json_encode NULL values return null; } if (!$this->l10n() && $val instanceof Translation) { $val = (string)$val; } if ($this->multiple()) { if (is_array($val)) { $val = implode($this->multipleSeparator(), $val); } } if (!is_scalar($val)) { return json_encode($val, JSON_UNESCAPED_UNICODE); } return $val; }
php
public function storageVal($val) { if ($val === null) { // Do not json_encode NULL values return null; } if (!$this->l10n() && $val instanceof Translation) { $val = (string)$val; } if ($this->multiple()) { if (is_array($val)) { $val = implode($this->multipleSeparator(), $val); } } if (!is_scalar($val)) { return json_encode($val, JSON_UNESCAPED_UNICODE); } return $val; }
[ "public", "function", "storageVal", "(", "$", "val", ")", "{", "if", "(", "$", "val", "===", "null", ")", "{", "// Do not json_encode NULL values", "return", "null", ";", "}", "if", "(", "!", "$", "this", "->", "l10n", "(", ")", "&&", "$", "val", "in...
Retrieve the property's value in a format suitable for storage. @param mixed $val The value to convert for storage. @return mixed
[ "Retrieve", "the", "property", "s", "value", "in", "a", "format", "suitable", "for", "storage", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L105-L127
train
locomotivemtl/charcoal-property
src/Charcoal/Property/StorablePropertyTrait.php
StorablePropertyTrait.updatedFields
private function updatedFields($val) { if (empty($this->fields)) { return $this->generateFields($val); } if ($this->l10n()) { foreach ($this->translator()->availableLocales() as $langCode) { $this->fields[$langCode]->setVal($this->fieldVal($langCode, $val)); } } else { $this->fields[0]->setVal($this->storageVal($val)); } return $this->fields; }
php
private function updatedFields($val) { if (empty($this->fields)) { return $this->generateFields($val); } if ($this->l10n()) { foreach ($this->translator()->availableLocales() as $langCode) { $this->fields[$langCode]->setVal($this->fieldVal($langCode, $val)); } } else { $this->fields[0]->setVal($this->storageVal($val)); } return $this->fields; }
[ "private", "function", "updatedFields", "(", "$", "val", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "fields", ")", ")", "{", "return", "$", "this", "->", "generateFields", "(", "$", "val", ")", ";", "}", "if", "(", "$", "this", "->", "...
Update the property's storage fields. @param mixed $val The value to set as field value. @return PropertyField[]
[ "Update", "the", "property", "s", "storage", "fields", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L206-L221
train
locomotivemtl/charcoal-property
src/Charcoal/Property/StorablePropertyTrait.php
StorablePropertyTrait.generateFields
private function generateFields($val) { $this->fields = []; if ($this->l10n()) { foreach ($this->translator()->availableLocales() as $langCode) { $ident = $this->l10nIdent($langCode); $field = $this->createPropertyField([ 'ident' => $ident, 'sqlType' => $this->sqlType(), 'sqlPdoType' => $this->sqlPdoType(), 'sqlEncoding' => $this->sqlEncoding(), 'extra' => $this->sqlExtra(), 'val' => $this->fieldVal($langCode, $val), 'defaultVal' => null, 'allowNull' => $this->allowNull() ]); $this->fields[$langCode] = $field; } } else { $field = $this->createPropertyField([ 'ident' => $this->ident(), 'sqlType' => $this->sqlType(), 'sqlPdoType' => $this->sqlPdoType(), 'sqlEncoding' => $this->sqlEncoding(), 'extra' => $this->sqlExtra(), 'val' => $this->storageVal($val), 'defaultVal' => null, 'allowNull' => $this->allowNull() ]); $this->fields[] = $field; } return $this->fields; }
php
private function generateFields($val) { $this->fields = []; if ($this->l10n()) { foreach ($this->translator()->availableLocales() as $langCode) { $ident = $this->l10nIdent($langCode); $field = $this->createPropertyField([ 'ident' => $ident, 'sqlType' => $this->sqlType(), 'sqlPdoType' => $this->sqlPdoType(), 'sqlEncoding' => $this->sqlEncoding(), 'extra' => $this->sqlExtra(), 'val' => $this->fieldVal($langCode, $val), 'defaultVal' => null, 'allowNull' => $this->allowNull() ]); $this->fields[$langCode] = $field; } } else { $field = $this->createPropertyField([ 'ident' => $this->ident(), 'sqlType' => $this->sqlType(), 'sqlPdoType' => $this->sqlPdoType(), 'sqlEncoding' => $this->sqlEncoding(), 'extra' => $this->sqlExtra(), 'val' => $this->storageVal($val), 'defaultVal' => null, 'allowNull' => $this->allowNull() ]); $this->fields[] = $field; } return $this->fields; }
[ "private", "function", "generateFields", "(", "$", "val", ")", "{", "$", "this", "->", "fields", "=", "[", "]", ";", "if", "(", "$", "this", "->", "l10n", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "translator", "(", ")", "->", "avail...
Reset the property's storage fields. @param mixed $val The value to set as field value. @return PropertyField[]
[ "Reset", "the", "property", "s", "storage", "fields", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L229-L262
train
locomotivemtl/charcoal-property
src/Charcoal/Property/StorablePropertyTrait.php
StorablePropertyTrait.fieldVal
private function fieldVal($fieldIdent, $val) { if ($val === null) { return null; } if (is_scalar($val)) { return $this->storageVal($val); } if (isset($val[$fieldIdent])) { return $this->storageVal($val[$fieldIdent]); } else { return null; } }
php
private function fieldVal($fieldIdent, $val) { if ($val === null) { return null; } if (is_scalar($val)) { return $this->storageVal($val); } if (isset($val[$fieldIdent])) { return $this->storageVal($val[$fieldIdent]); } else { return null; } }
[ "private", "function", "fieldVal", "(", "$", "fieldIdent", ",", "$", "val", ")", "{", "if", "(", "$", "val", "===", "null", ")", "{", "return", "null", ";", "}", "if", "(", "is_scalar", "(", "$", "val", ")", ")", "{", "return", "$", "this", "->",...
Retrieve the value of the property's given storage field. @param string $fieldIdent The property field identifier. @param mixed $val The value to set as field value. @return mixed
[ "Retrieve", "the", "value", "of", "the", "property", "s", "given", "storage", "field", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L271-L286
train
apioo/psx-http
src/Server/RequestFactory.php
RequestFactory.getRequestMethod
protected function getRequestMethod() { if (isset($this->server['REQUEST_METHOD'])) { // check for X-HTTP-Method-Override if (isset($this->server['HTTP_X_HTTP_METHOD_OVERRIDE']) && in_array($this->server['HTTP_X_HTTP_METHOD_OVERRIDE'], ['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'PATCH'])) { return $this->server['HTTP_X_HTTP_METHOD_OVERRIDE']; } else { return $this->server['REQUEST_METHOD']; } } else { return 'GET'; } }
php
protected function getRequestMethod() { if (isset($this->server['REQUEST_METHOD'])) { // check for X-HTTP-Method-Override if (isset($this->server['HTTP_X_HTTP_METHOD_OVERRIDE']) && in_array($this->server['HTTP_X_HTTP_METHOD_OVERRIDE'], ['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'PATCH'])) { return $this->server['HTTP_X_HTTP_METHOD_OVERRIDE']; } else { return $this->server['REQUEST_METHOD']; } } else { return 'GET'; } }
[ "protected", "function", "getRequestMethod", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "server", "[", "'REQUEST_METHOD'", "]", ")", ")", "{", "// check for X-HTTP-Method-Override", "if", "(", "isset", "(", "$", "this", "->", "server", "[", ...
Tries to detect the current request method. It considers the X-HTTP-METHOD-OVERRIDE header. @return string
[ "Tries", "to", "detect", "the", "current", "request", "method", ".", "It", "considers", "the", "X", "-", "HTTP", "-", "METHOD", "-", "OVERRIDE", "header", "." ]
c54d7212cfb513df84f810429aa34c6ac9942c01
https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Server/RequestFactory.php#L136-L148
train
apioo/psx-http
src/Server/RequestFactory.php
RequestFactory.getRequestHeaders
protected function getRequestHeaders() { $contentKeys = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true); $headers = array(); foreach ($this->server as $key => $value) { if (strpos($key, 'HTTP_') === 0) { $headers[str_replace('_', '-', substr($key, 5))] = $value; } elseif (isset($contentKeys[$key])) { $headers[str_replace('_', '-', $key)] = $value; } } if (!isset($headers['AUTHORIZATION'])) { if (isset($this->server['REDIRECT_HTTP_AUTHORIZATION'])) { $headers['AUTHORIZATION'] = $this->server['REDIRECT_HTTP_AUTHORIZATION']; } elseif (isset($this->server['PHP_AUTH_USER'])) { $headers['AUTHORIZATION'] = 'Basic ' . base64_encode($this->server['PHP_AUTH_USER'] . ':' . (isset($this->server['PHP_AUTH_PW']) ? $this->server['PHP_AUTH_PW'] : '')); } elseif (isset($this->server['PHP_AUTH_DIGEST'])) { $headers['AUTHORIZATION'] = $this->server['PHP_AUTH_DIGEST']; } } return $headers; }
php
protected function getRequestHeaders() { $contentKeys = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true); $headers = array(); foreach ($this->server as $key => $value) { if (strpos($key, 'HTTP_') === 0) { $headers[str_replace('_', '-', substr($key, 5))] = $value; } elseif (isset($contentKeys[$key])) { $headers[str_replace('_', '-', $key)] = $value; } } if (!isset($headers['AUTHORIZATION'])) { if (isset($this->server['REDIRECT_HTTP_AUTHORIZATION'])) { $headers['AUTHORIZATION'] = $this->server['REDIRECT_HTTP_AUTHORIZATION']; } elseif (isset($this->server['PHP_AUTH_USER'])) { $headers['AUTHORIZATION'] = 'Basic ' . base64_encode($this->server['PHP_AUTH_USER'] . ':' . (isset($this->server['PHP_AUTH_PW']) ? $this->server['PHP_AUTH_PW'] : '')); } elseif (isset($this->server['PHP_AUTH_DIGEST'])) { $headers['AUTHORIZATION'] = $this->server['PHP_AUTH_DIGEST']; } } return $headers; }
[ "protected", "function", "getRequestHeaders", "(", ")", "{", "$", "contentKeys", "=", "array", "(", "'CONTENT_LENGTH'", "=>", "true", ",", "'CONTENT_MD5'", "=>", "true", ",", "'CONTENT_TYPE'", "=>", "true", ")", ";", "$", "headers", "=", "array", "(", ")", ...
Returns all request headers @return array
[ "Returns", "all", "request", "headers" ]
c54d7212cfb513df84f810429aa34c6ac9942c01
https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Server/RequestFactory.php#L155-L179
train
cmsgears/module-core
common/utilities/DateUtil.php
DateUtil.lessThan
public static function lessThan( $sourceDate, $targetDate, $equal = false ) { $source = is_string( $sourceDate ) ? strtotime( $sourceDate ) : $sourceDate->getTimestamp(); $test = is_string( $targetDate ) ? strtotime( $targetDate ) : $targetDate->getTimestamp(); // Test less than if( $equal ) { return $test <= $source; } return $test < $source; }
php
public static function lessThan( $sourceDate, $targetDate, $equal = false ) { $source = is_string( $sourceDate ) ? strtotime( $sourceDate ) : $sourceDate->getTimestamp(); $test = is_string( $targetDate ) ? strtotime( $targetDate ) : $targetDate->getTimestamp(); // Test less than if( $equal ) { return $test <= $source; } return $test < $source; }
[ "public", "static", "function", "lessThan", "(", "$", "sourceDate", ",", "$", "targetDate", ",", "$", "equal", "=", "false", ")", "{", "$", "source", "=", "is_string", "(", "$", "sourceDate", ")", "?", "strtotime", "(", "$", "sourceDate", ")", ":", "$"...
Compare the target date with source date to check whether target date is lesser than or equal to source date. @param type $sourceDate @param type $targetDate @param type $equal @return boolean
[ "Compare", "the", "target", "date", "with", "source", "date", "to", "check", "whether", "target", "date", "is", "lesser", "than", "or", "equal", "to", "source", "date", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/utilities/DateUtil.php#L330-L342
train
cmsgears/module-core
common/utilities/DateUtil.php
DateUtil.inBetween
public static function inBetween( $startDate, $endDate, $date ) { $start = is_string( $startDate ) ? strtotime( $startDate ) : $startDate->getTimestamp(); $end = is_string( $endDate ) ? strtotime( $endDate ) : $endDate->getTimestamp(); $test = is_string( $date ) ? strtotime( $date ) : $date->getTimestamp(); // Test in between start and end return ( ( $test >= $start ) && ( $test <= $end ) ); }
php
public static function inBetween( $startDate, $endDate, $date ) { $start = is_string( $startDate ) ? strtotime( $startDate ) : $startDate->getTimestamp(); $end = is_string( $endDate ) ? strtotime( $endDate ) : $endDate->getTimestamp(); $test = is_string( $date ) ? strtotime( $date ) : $date->getTimestamp(); // Test in between start and end return ( ( $test >= $start ) && ( $test <= $end ) ); }
[ "public", "static", "function", "inBetween", "(", "$", "startDate", ",", "$", "endDate", ",", "$", "date", ")", "{", "$", "start", "=", "is_string", "(", "$", "startDate", ")", "?", "strtotime", "(", "$", "startDate", ")", ":", "$", "startDate", "->", ...
Compare the given date and check whether it's between the start date and end date. @param type $startDate @param type $endDate @param type $date @return type
[ "Compare", "the", "given", "date", "and", "check", "whether", "it", "s", "between", "the", "start", "date", "and", "end", "date", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/utilities/DateUtil.php#L352-L360
train
tamago-db/LinkedinImporterBundle
Importer/Importer.php
Importer.resetState
public function resetState($value = null) { if (!$value) { $value = md5(mt_rand(1, 1000000) . 'IAMTHEVERYMODELOFAMODERNMAJORGENERAL' //some salt . __CLASS__ . mt_rand(1, 1000000) ); } $value = (string) $value; $session = $this->_session; //$session->invalidate(); // @todo why were we invalidating the session? $session->set('linkedin_state', $value); return $this; }
php
public function resetState($value = null) { if (!$value) { $value = md5(mt_rand(1, 1000000) . 'IAMTHEVERYMODELOFAMODERNMAJORGENERAL' //some salt . __CLASS__ . mt_rand(1, 1000000) ); } $value = (string) $value; $session = $this->_session; //$session->invalidate(); // @todo why were we invalidating the session? $session->set('linkedin_state', $value); return $this; }
[ "public", "function", "resetState", "(", "$", "value", "=", "null", ")", "{", "if", "(", "!", "$", "value", ")", "{", "$", "value", "=", "md5", "(", "mt_rand", "(", "1", ",", "1000000", ")", ".", "'IAMTHEVERYMODELOFAMODERNMAJORGENERAL'", "//some salt", "...
Reinitializes the value of linkedin_state in the session @param string $value @return \CCC\LinkedinImporterBundle\Importer\Importer
[ "Reinitializes", "the", "value", "of", "linkedin_state", "in", "the", "session" ]
bf510a675311c181995b17744e1420fc4fbb2e60
https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Importer/Importer.php#L49-L65
train
tamago-db/LinkedinImporterBundle
Importer/Importer.php
Importer.getAuthenticationUrl
public function getAuthenticationUrl($type = 'private') { if (!$this->getRedirect()) { throw new \Exception('please set a redirect url for your permissions request'); } $config = $this->getConfig(); if (!isset($config['dataset'][$type])) { // @todo Is this configurable? throw new \Exception('unknown action. please check your apiconfig.yml file for the available types'); } $params = array(); $params['response_type'] = 'code'; $params['client_id'] = $config['api_key']; $params['redirect_uri'] = $this->getRedirect(); $params['scope'] = $config['dataset'][$type]['scope']; $params['state'] = $this->resetState()->getState(); $url = $config['urls']['auth'] . '?' . http_build_query($params); return $url; }
php
public function getAuthenticationUrl($type = 'private') { if (!$this->getRedirect()) { throw new \Exception('please set a redirect url for your permissions request'); } $config = $this->getConfig(); if (!isset($config['dataset'][$type])) { // @todo Is this configurable? throw new \Exception('unknown action. please check your apiconfig.yml file for the available types'); } $params = array(); $params['response_type'] = 'code'; $params['client_id'] = $config['api_key']; $params['redirect_uri'] = $this->getRedirect(); $params['scope'] = $config['dataset'][$type]['scope']; $params['state'] = $this->resetState()->getState(); $url = $config['urls']['auth'] . '?' . http_build_query($params); return $url; }
[ "public", "function", "getAuthenticationUrl", "(", "$", "type", "=", "'private'", ")", "{", "if", "(", "!", "$", "this", "->", "getRedirect", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'please set a redirect url for your permissions request'", ...
Return the url of the LinkedIn authentication page
[ "Return", "the", "url", "of", "the", "LinkedIn", "authentication", "page" ]
bf510a675311c181995b17744e1420fc4fbb2e60
https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Importer/Importer.php#L120-L142
train
tamago-db/LinkedinImporterBundle
Importer/Importer.php
Importer.setPublicProfileUrl
public function setPublicProfileUrl($url) { // Avoids errors like: "[invalid.param.url]. Public profile URL is not correct, {url=xyz should be // {https://www.linkedin.com/pub/[member-name/]x/y/z}. LinkedIn won't validate it's own public urls that // have a language / country code appended $matches = array(); preg_match('"^https?://((www|\w\w)\.)?linkedin.com/((in/[^/]+/?)|(pub/[^/]+/((\w|\d)+/?){3}))"', $url, $matches); if (count($matches)) { $url = current($matches); } $url = rtrim($url, '/'); //according to their manual and forums, all linkedin public urls should begin with 'https://www.linkedin.com' //(they said they'd always support it even if it did ever change, which is highly unlikely) //so just chop it off and force it to be that $url = preg_replace('/^(.*)linkedin.com\//i', 'https://www.linkedin.com/', $url); $this->_public_profile_url = $url; return $this; }
php
public function setPublicProfileUrl($url) { // Avoids errors like: "[invalid.param.url]. Public profile URL is not correct, {url=xyz should be // {https://www.linkedin.com/pub/[member-name/]x/y/z}. LinkedIn won't validate it's own public urls that // have a language / country code appended $matches = array(); preg_match('"^https?://((www|\w\w)\.)?linkedin.com/((in/[^/]+/?)|(pub/[^/]+/((\w|\d)+/?){3}))"', $url, $matches); if (count($matches)) { $url = current($matches); } $url = rtrim($url, '/'); //according to their manual and forums, all linkedin public urls should begin with 'https://www.linkedin.com' //(they said they'd always support it even if it did ever change, which is highly unlikely) //so just chop it off and force it to be that $url = preg_replace('/^(.*)linkedin.com\//i', 'https://www.linkedin.com/', $url); $this->_public_profile_url = $url; return $this; }
[ "public", "function", "setPublicProfileUrl", "(", "$", "url", ")", "{", "// Avoids errors like: \"[invalid.param.url]. Public profile URL is not correct, {url=xyz should be", "// {https://www.linkedin.com/pub/[member-name/]x/y/z}. LinkedIn won't validate it's own public urls that", "// have a l...
Sets a sanity-checked public profile url @param string $url @return \CCC\LinkedinImporterBundle\Importer\Importer
[ "Sets", "a", "sanity", "-", "checked", "public", "profile", "url" ]
bf510a675311c181995b17744e1420fc4fbb2e60
https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Importer/Importer.php#L158-L178
train
tamago-db/LinkedinImporterBundle
Importer/Importer.php
Importer.requestAccessToken
public function requestAccessToken() { $config = $this->getConfig(); $token_url = $config['urls']['token']; $params = array(); $params['client_id'] = $config['api_key']; $params['redirect_uri'] = $this->getRedirect(); $params['code'] = $this->getCode(); $params['grant_type'] = 'authorization_code'; $params['client_secret'] = $config['secret_key']; //get access token $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $token_url); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't worry about bad ssl certs curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); // @todo why post a get query? $response = curl_exec($ch); if (!$response) { throw new \Exception('no response from linkedin'); } $response = json_decode($response); if (!isset($response->access_token) || !$response->access_token) { throw new \Exception('no access token received from linkedin'); } $this->setAccessToken($response->access_token); return (string) $response->access_token; }
php
public function requestAccessToken() { $config = $this->getConfig(); $token_url = $config['urls']['token']; $params = array(); $params['client_id'] = $config['api_key']; $params['redirect_uri'] = $this->getRedirect(); $params['code'] = $this->getCode(); $params['grant_type'] = 'authorization_code'; $params['client_secret'] = $config['secret_key']; //get access token $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $token_url); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't worry about bad ssl certs curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); // @todo why post a get query? $response = curl_exec($ch); if (!$response) { throw new \Exception('no response from linkedin'); } $response = json_decode($response); if (!isset($response->access_token) || !$response->access_token) { throw new \Exception('no access token received from linkedin'); } $this->setAccessToken($response->access_token); return (string) $response->access_token; }
[ "public", "function", "requestAccessToken", "(", ")", "{", "$", "config", "=", "$", "this", "->", "getConfig", "(", ")", ";", "$", "token_url", "=", "$", "config", "[", "'urls'", "]", "[", "'token'", "]", ";", "$", "params", "=", "array", "(", ")", ...
Gets access token from linkedin @throws \Exception @return string
[ "Gets", "access", "token", "from", "linkedin" ]
bf510a675311c181995b17744e1420fc4fbb2e60
https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Importer/Importer.php#L223-L258
train
tamago-db/LinkedinImporterBundle
Importer/Importer.php
Importer.requestUserData
public function requestUserData($type = 'private', $access_token = null) { $config = $this->getConfig(); $access_token = ($access_token) ? $access_token : $this->getAccessToken(); $url = null; switch ($type) { case 'public': //error if no profile set if (!$this->getPublicProfileUrl()) { throw new \Exception('please set the public profile you want to pull'); } $url = $config['urls']['public'] . urlencode(urldecode($this->getPublicProfileUrl())) // make sure the url is encoded; avoid double encoding . $config['dataset'][$type]['fields']; break; case 'private': case 'login': default: $url = $config['urls']['private'] . $config['dataset'][$type]['fields']; break; } //add access token to request url $url .= '?' . http_build_query(array('oauth2_access_token' => $access_token, 'secure-urls' => 'true')); //send it $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't worry about bad ssl certs curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-Language: en-US, ja")); $response = curl_exec($ch); $data = simplexml_load_string($response); return $data; }
php
public function requestUserData($type = 'private', $access_token = null) { $config = $this->getConfig(); $access_token = ($access_token) ? $access_token : $this->getAccessToken(); $url = null; switch ($type) { case 'public': //error if no profile set if (!$this->getPublicProfileUrl()) { throw new \Exception('please set the public profile you want to pull'); } $url = $config['urls']['public'] . urlencode(urldecode($this->getPublicProfileUrl())) // make sure the url is encoded; avoid double encoding . $config['dataset'][$type]['fields']; break; case 'private': case 'login': default: $url = $config['urls']['private'] . $config['dataset'][$type]['fields']; break; } //add access token to request url $url .= '?' . http_build_query(array('oauth2_access_token' => $access_token, 'secure-urls' => 'true')); //send it $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't worry about bad ssl certs curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-Language: en-US, ja")); $response = curl_exec($ch); $data = simplexml_load_string($response); return $data; }
[ "public", "function", "requestUserData", "(", "$", "type", "=", "'private'", ",", "$", "access_token", "=", "null", ")", "{", "$", "config", "=", "$", "this", "->", "getConfig", "(", ")", ";", "$", "access_token", "=", "(", "$", "access_token", ")", "?...
Gets user data from linkedin. @param string $type @param string $access_token @throws \Exception @return \SimpleXMLElement
[ "Gets", "user", "data", "from", "linkedin", "." ]
bf510a675311c181995b17744e1420fc4fbb2e60
https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Importer/Importer.php#L269-L309
train
apioo/psx-http
src/Request.php
Request.toString
public function toString() { $request = Parser\RequestParser::buildStatusLine($this) . Http::NEW_LINE; $headers = Parser\RequestParser::buildHeaderFromMessage($this); foreach ($headers as $header) { $request.= $header . Http::NEW_LINE; } $request.= Http::NEW_LINE; $request.= (string) $this->getBody(); return $request; }
php
public function toString() { $request = Parser\RequestParser::buildStatusLine($this) . Http::NEW_LINE; $headers = Parser\RequestParser::buildHeaderFromMessage($this); foreach ($headers as $header) { $request.= $header . Http::NEW_LINE; } $request.= Http::NEW_LINE; $request.= (string) $this->getBody(); return $request; }
[ "public", "function", "toString", "(", ")", "{", "$", "request", "=", "Parser", "\\", "RequestParser", "::", "buildStatusLine", "(", "$", "this", ")", ".", "Http", "::", "NEW_LINE", ";", "$", "headers", "=", "Parser", "\\", "RequestParser", "::", "buildHea...
Converts the request object to an http request string @return string
[ "Converts", "the", "request", "object", "to", "an", "http", "request", "string" ]
c54d7212cfb513df84f810429aa34c6ac9942c01
https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Request.php#L147-L160
train
cmsgears/module-core
common/models/resources/ModelMessage.php
ModelMessage.findByNameTypeLocaleId
public static function findByNameTypeLocaleId( $parentId, $parentType, $name, $type, $localeId ) { return self::find()->where( 'parentId=:pid AND parentType=:ptype AND name=:name AND type=:type AND localeId=:lid' ) ->addParams( [ ':pid' => $parentId, ':ptype' => $parentType, ':name' => $name, ':type' => $type, ':lid' => $localeId ] ) ->one(); }
php
public static function findByNameTypeLocaleId( $parentId, $parentType, $name, $type, $localeId ) { return self::find()->where( 'parentId=:pid AND parentType=:ptype AND name=:name AND type=:type AND localeId=:lid' ) ->addParams( [ ':pid' => $parentId, ':ptype' => $parentType, ':name' => $name, ':type' => $type, ':lid' => $localeId ] ) ->one(); }
[ "public", "static", "function", "findByNameTypeLocaleId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "name", ",", "$", "type", ",", "$", "localeId", ")", "{", "return", "self", "::", "find", "(", ")", "->", "where", "(", "'parentId=:pid AND pa...
Find and return the message specific to given name, type and locale id. @param integer $parentId @param string $parentType @param string $name @param string $type @param int $localeId @return ModelMessage by name, type and locale id
[ "Find", "and", "return", "the", "message", "specific", "to", "given", "name", "type", "and", "locale", "id", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelMessage.php#L203-L208
train
cmsgears/module-core
common/models/resources/ModelMessage.php
ModelMessage.isExistByNameTypeLocaleId
public static function isExistByNameTypeLocaleId( $parentId, $parentType, $name, $type, $localeId ) { $message = self::findByNameLocaleId( $parentId, $parentType, $name, $type, $localeId ); return isset( $message ); }
php
public static function isExistByNameTypeLocaleId( $parentId, $parentType, $name, $type, $localeId ) { $message = self::findByNameLocaleId( $parentId, $parentType, $name, $type, $localeId ); return isset( $message ); }
[ "public", "static", "function", "isExistByNameTypeLocaleId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "name", ",", "$", "type", ",", "$", "localeId", ")", "{", "$", "message", "=", "self", "::", "findByNameLocaleId", "(", "$", "parentId", ",...
Check whether the message exists for given name, type and locale id. @param integer $parentId @param string $parentType @param string $name @param int $localeId @return boolean
[ "Check", "whether", "the", "message", "exists", "for", "given", "name", "type", "and", "locale", "id", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelMessage.php#L219-L224
train
Innmind/AMQP
src/Model/Basic/Qos.php
Qos.global
public static function global(int $prefetchSize, int $prefetchCount): self { $self = new self($prefetchSize, $prefetchCount); $self->global = true; return $self; }
php
public static function global(int $prefetchSize, int $prefetchCount): self { $self = new self($prefetchSize, $prefetchCount); $self->global = true; return $self; }
[ "public", "static", "function", "global", "(", "int", "$", "prefetchSize", ",", "int", "$", "prefetchCount", ")", ":", "self", "{", "$", "self", "=", "new", "self", "(", "$", "prefetchSize", ",", "$", "prefetchCount", ")", ";", "$", "self", "->", "glob...
Will apply the definition for the whole connection
[ "Will", "apply", "the", "definition", "for", "the", "whole", "connection" ]
c22b3a8f56162f7845a13c149cb3118e5fe7cffd
https://github.com/Innmind/AMQP/blob/c22b3a8f56162f7845a13c149cb3118e5fe7cffd/src/Model/Basic/Qos.php#L33-L39
train
cmsgears/module-core
common/base/MessageSource.php
MessageSource.getMessage
public function getMessage( $key, $params = [], $language = null ) { // Retrieve Message $message = $this->messageDb[ $key ]; // Return formatted message return $this->formatter->format( $message, $params, $language ); }
php
public function getMessage( $key, $params = [], $language = null ) { // Retrieve Message $message = $this->messageDb[ $key ]; // Return formatted message return $this->formatter->format( $message, $params, $language ); }
[ "public", "function", "getMessage", "(", "$", "key", ",", "$", "params", "=", "[", "]", ",", "$", "language", "=", "null", ")", "{", "// Retrieve Message", "$", "message", "=", "$", "this", "->", "messageDb", "[", "$", "key", "]", ";", "// Return forma...
Find the message corresponding to given message key and returns the formatted message using the message parameters and language. @param string $key @param array $params @param string $language @return string
[ "Find", "the", "message", "corresponding", "to", "given", "message", "key", "and", "returns", "the", "formatted", "message", "using", "the", "message", "parameters", "and", "language", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/base/MessageSource.php#L63-L70
train
apioo/psx-http
src/Stream/Util.php
Util.toString
public static function toString(StreamInterface $stream) { if (!$stream->isReadable()) { return ''; } if ($stream->isSeekable()) { $pos = $stream->tell(); $content = $stream->__toString(); $stream->seek($pos); } else { $content = $stream->__toString(); } return $content; }
php
public static function toString(StreamInterface $stream) { if (!$stream->isReadable()) { return ''; } if ($stream->isSeekable()) { $pos = $stream->tell(); $content = $stream->__toString(); $stream->seek($pos); } else { $content = $stream->__toString(); } return $content; }
[ "public", "static", "function", "toString", "(", "StreamInterface", "$", "stream", ")", "{", "if", "(", "!", "$", "stream", "->", "isReadable", "(", ")", ")", "{", "return", "''", ";", "}", "if", "(", "$", "stream", "->", "isSeekable", "(", ")", ")",...
Converts an stream into an string and returns the result. The position of the pointer will not change if the stream is seekable. Note this copies the complete content of the stream into the memory @param \Psr\Http\Message\StreamInterface $stream @return string
[ "Converts", "an", "stream", "into", "an", "string", "and", "returns", "the", "result", ".", "The", "position", "of", "the", "pointer", "will", "not", "change", "if", "the", "stream", "is", "seekable", ".", "Note", "this", "copies", "the", "complete", "cont...
c54d7212cfb513df84f810429aa34c6ac9942c01
https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Stream/Util.php#L42-L58
train
locomotivemtl/charcoal-property
src/Charcoal/Property/DescribablePropertyTrait.php
DescribablePropertyTrait.hasProperty
public function hasProperty($propertyIdent) { if (!is_string($propertyIdent)) { throw new InvalidArgumentException( 'Property identifier must be a string.' ); } $metadata = $this->metadata(); $properties = $metadata->properties(); return isset($properties[$propertyIdent]); }
php
public function hasProperty($propertyIdent) { if (!is_string($propertyIdent)) { throw new InvalidArgumentException( 'Property identifier must be a string.' ); } $metadata = $this->metadata(); $properties = $metadata->properties(); return isset($properties[$propertyIdent]); }
[ "public", "function", "hasProperty", "(", "$", "propertyIdent", ")", "{", "if", "(", "!", "is_string", "(", "$", "propertyIdent", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Property identifier must be a string.'", ")", ";", "}", "$", "meta...
Determine if the model has the given property. @param string $propertyIdent The property identifier to lookup. @throws InvalidArgumentException If the property identifier is not a string. @return boolean
[ "Determine", "if", "the", "model", "has", "the", "given", "property", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/DescribablePropertyTrait.php#L103-L115
train
975L/IncludeLibraryBundle
Twig/IncludeLibraryContent.php
IncludeLibraryContent.Content
public function Content($name, $type, $version = 'latest') { $type = strtolower($type); //Gets type for local file $local = false; if ('local' == $type) { $local = true; $type = strtolower(substr($name, strrpos($name, '.') + 1)); } //Gets data for local file if ($local) { $data = 'css' == $type ? array('href' => $name) : array('src' => $name); //Gets data for external library } else { $data = $this->includeLibraryService->getData($name, $type, $version); } //Returns the content from href or src part if (null != $data) { $content = null; if ('css' == $type) { $content = '<style type="text/css">' . file_get_contents($data['href']) . '</style>'; } elseif ('js' == $type) { $content = '<script type="text/javascript">' . file_get_contents($data['src']) . '</script>'; } return $content; } //Throws an error if not found throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_content()" was not found. Please check name and supported library/versions.'); }
php
public function Content($name, $type, $version = 'latest') { $type = strtolower($type); //Gets type for local file $local = false; if ('local' == $type) { $local = true; $type = strtolower(substr($name, strrpos($name, '.') + 1)); } //Gets data for local file if ($local) { $data = 'css' == $type ? array('href' => $name) : array('src' => $name); //Gets data for external library } else { $data = $this->includeLibraryService->getData($name, $type, $version); } //Returns the content from href or src part if (null != $data) { $content = null; if ('css' == $type) { $content = '<style type="text/css">' . file_get_contents($data['href']) . '</style>'; } elseif ('js' == $type) { $content = '<script type="text/javascript">' . file_get_contents($data['src']) . '</script>'; } return $content; } //Throws an error if not found throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_content()" was not found. Please check name and supported library/versions.'); }
[ "public", "function", "Content", "(", "$", "name", ",", "$", "type", ",", "$", "version", "=", "'latest'", ")", "{", "$", "type", "=", "strtolower", "(", "$", "type", ")", ";", "//Gets type for local file", "$", "local", "=", "false", ";", "if", "(", ...
Returns the content of the requested library @return string @throws Error
[ "Returns", "the", "content", "of", "the", "requested", "library" ]
74f9140551d6f20c1308213c4c142f7fff43eb52
https://github.com/975L/IncludeLibraryBundle/blob/74f9140551d6f20c1308213c4c142f7fff43eb52/Twig/IncludeLibraryContent.php#L53-L86
train
cmsgears/module-core
common/models/resources/Option.php
Option.findByCategoryId
public static function findByCategoryId( $categoryId ) { $optionTable = CoreTables::getTableName( CoreTables::TABLE_OPTION ); return self::find()->where( "$optionTable.categoryId=:id", [ ':id' => $categoryId ] )->all(); }
php
public static function findByCategoryId( $categoryId ) { $optionTable = CoreTables::getTableName( CoreTables::TABLE_OPTION ); return self::find()->where( "$optionTable.categoryId=:id", [ ':id' => $categoryId ] )->all(); }
[ "public", "static", "function", "findByCategoryId", "(", "$", "categoryId", ")", "{", "$", "optionTable", "=", "CoreTables", "::", "getTableName", "(", "CoreTables", "::", "TABLE_OPTION", ")", ";", "return", "self", "::", "find", "(", ")", "->", "where", "("...
Return the options available for given category id. @param integer $categoryId @return Option[]
[ "Return", "the", "options", "available", "for", "given", "category", "id", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/Option.php#L202-L207
train
cmsgears/module-core
common/models/resources/Option.php
Option.findByNameCategoryId
public static function findByNameCategoryId( $name, $categoryId ) { $optionTable = CoreTables::getTableName( CoreTables::TABLE_OPTION ); return self::find()->where( "$optionTable.name=:name AND $optionTable.categoryId=:id", [ ':name' => $name, ':id' => $categoryId ] )->one(); }
php
public static function findByNameCategoryId( $name, $categoryId ) { $optionTable = CoreTables::getTableName( CoreTables::TABLE_OPTION ); return self::find()->where( "$optionTable.name=:name AND $optionTable.categoryId=:id", [ ':name' => $name, ':id' => $categoryId ] )->one(); }
[ "public", "static", "function", "findByNameCategoryId", "(", "$", "name", ",", "$", "categoryId", ")", "{", "$", "optionTable", "=", "CoreTables", "::", "getTableName", "(", "CoreTables", "::", "TABLE_OPTION", ")", ";", "return", "self", "::", "find", "(", "...
Return the option using given name and category id. @param string $name @param integer $categoryId @return Option
[ "Return", "the", "option", "using", "given", "name", "and", "category", "id", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/Option.php#L216-L221
train
cmsgears/module-core
common/models/resources/Option.php
Option.isExistByNameCategoryId
public static function isExistByNameCategoryId( $name, $categoryId ) { $option = self::findByNameCategoryId( $name, $categoryId ); return isset( $option ); }
php
public static function isExistByNameCategoryId( $name, $categoryId ) { $option = self::findByNameCategoryId( $name, $categoryId ); return isset( $option ); }
[ "public", "static", "function", "isExistByNameCategoryId", "(", "$", "name", ",", "$", "categoryId", ")", "{", "$", "option", "=", "self", "::", "findByNameCategoryId", "(", "$", "name", ",", "$", "categoryId", ")", ";", "return", "isset", "(", "$", "optio...
Check whether option exist by name and category id. @return boolean
[ "Check", "whether", "option", "exist", "by", "name", "and", "category", "id", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/Option.php#L228-L233
train
phPoirot/Std
src/Type/StdArray.fix.php
StdArray.makeFlattenFace
function makeFlattenFace() { $_f_build = function($data) use (&$_f_build) { $args = func_get_args(); $isNested = isset($args[1]); foreach ($data as $k => $d) { // Build PHP Array Request Params Compatible With Curl // meta => ['name' => (string)] ---> meta['name'] = (string) if ( is_array($d) ) { foreach ($d as $i => $v) { if (is_array($v)) { // Nested Array foreach ($d = $_f_build($v, true) as $kn => $kv) { $kn = ( false !== strpos($kn, '[') ) ? $kn : '['.$kn.']'; $data[$k . '[' . $i . ']' . $kn] = $kv; } } else { if ($isNested) $data['[' . $k . ']' . '[' . $i . ']'] = $v; else $data[$k . '[' . $i . ']'] = $v; } } unset($data[$k]); } } return $data; }; $data = $_f_build($this->value); return new static($data); }
php
function makeFlattenFace() { $_f_build = function($data) use (&$_f_build) { $args = func_get_args(); $isNested = isset($args[1]); foreach ($data as $k => $d) { // Build PHP Array Request Params Compatible With Curl // meta => ['name' => (string)] ---> meta['name'] = (string) if ( is_array($d) ) { foreach ($d as $i => $v) { if (is_array($v)) { // Nested Array foreach ($d = $_f_build($v, true) as $kn => $kv) { $kn = ( false !== strpos($kn, '[') ) ? $kn : '['.$kn.']'; $data[$k . '[' . $i . ']' . $kn] = $kv; } } else { if ($isNested) $data['[' . $k . ']' . '[' . $i . ']'] = $v; else $data[$k . '[' . $i . ']'] = $v; } } unset($data[$k]); } } return $data; }; $data = $_f_build($this->value); return new static($data); }
[ "function", "makeFlattenFace", "(", ")", "{", "$", "_f_build", "=", "function", "(", "$", "data", ")", "use", "(", "&", "$", "_f_build", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "isNested", "=", "isset", "(", "$", "args", "[...
Flatten An Array @return static
[ "Flatten", "An", "Array" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdArray.fix.php#L185-L220
train
phPoirot/Std
src/Type/StdArray.fix.php
StdArray.withMergeRecursive
function withMergeRecursive($b, $reserve = false) { if ($b instanceof StdArray) $b = $b->value; else $b = (array) $b; $a = $this->value; foreach ($b as $key => $value) { if (! array_key_exists($key, $a)) { // key not exists so simply add it to array $a[$key] = $value; continue; } if ( is_int($key) ) { // [ 'value' ] if value not exists append to array! if (! in_array($value, $a) ) $a[] = $value; } elseif (is_array($value) && is_array($a[$key])) { // a= [k=>[]] , b=[k=>['value']] $m = new StdArray($a[$key]); $a[$key] = $m->withMergeRecursive($value, $reserve)->value; } else { if ($reserve) { // save old value and push them into new array list $cv = $a[$key]; $a[$key] = array(); $pa = &$a[$key]; array_push($pa, $cv); array_push($pa, $value); } else { $a[$key] = $value; } } } return new StdArray($a); }
php
function withMergeRecursive($b, $reserve = false) { if ($b instanceof StdArray) $b = $b->value; else $b = (array) $b; $a = $this->value; foreach ($b as $key => $value) { if (! array_key_exists($key, $a)) { // key not exists so simply add it to array $a[$key] = $value; continue; } if ( is_int($key) ) { // [ 'value' ] if value not exists append to array! if (! in_array($value, $a) ) $a[] = $value; } elseif (is_array($value) && is_array($a[$key])) { // a= [k=>[]] , b=[k=>['value']] $m = new StdArray($a[$key]); $a[$key] = $m->withMergeRecursive($value, $reserve)->value; } else { if ($reserve) { // save old value and push them into new array list $cv = $a[$key]; $a[$key] = array(); $pa = &$a[$key]; array_push($pa, $cv); array_push($pa, $value); } else { $a[$key] = $value; } } } return new StdArray($a); }
[ "function", "withMergeRecursive", "(", "$", "b", ",", "$", "reserve", "=", "false", ")", "{", "if", "(", "$", "b", "instanceof", "StdArray", ")", "$", "b", "=", "$", "b", "->", "value", ";", "else", "$", "b", "=", "(", "array", ")", "$", "b", "...
Merge two arrays together, reserve previous values @param array|StdArray $b @return StdArray
[ "Merge", "two", "arrays", "together", "reserve", "previous", "values" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdArray.fix.php#L333-L376
train
phPoirot/Std
src/Type/StdArray.fix.php
StdArray.exclude
function exclude(array $exclusionFields = [], $exclusionBehave = self::EXCLUDE_DISALLOW) { $exclude = []; foreach ($this->value as $field => $term) { if (!empty($exclusionFields)) { $flag = in_array($field, $exclusionFields); ($exclusionBehave != self::EXCLUDE_ALLOW) ?: $flag = !$flag; if ($flag) // The Field not considered as Expression Term continue; } $exclude[$field] = $term; }// end foreach return new StdArray($exclude); }
php
function exclude(array $exclusionFields = [], $exclusionBehave = self::EXCLUDE_DISALLOW) { $exclude = []; foreach ($this->value as $field => $term) { if (!empty($exclusionFields)) { $flag = in_array($field, $exclusionFields); ($exclusionBehave != self::EXCLUDE_ALLOW) ?: $flag = !$flag; if ($flag) // The Field not considered as Expression Term continue; } $exclude[$field] = $term; }// end foreach return new StdArray($exclude); }
[ "function", "exclude", "(", "array", "$", "exclusionFields", "=", "[", "]", ",", "$", "exclusionBehave", "=", "self", "::", "EXCLUDE_DISALLOW", ")", "{", "$", "exclude", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "value", "as", "$", "field"...
Exclude From Array @param array $exclusionFields The fields that is in query string but must not used in expression @param string $exclusionBehave allow|disallow @return self @throws \Exception
[ "Exclude", "From", "Array" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdArray.fix.php#L387-L409
train
ethical-jobs/ethical-jobs-foundation-php
src/Laravel/LoggingServiceProvider.php
LoggingServiceProvider.registerLogger
public function registerLogger() { $this->app->extend('log', function($log) { return new Writer($log->getMonolog(), $log->getEventDispatcher()); }); }
php
public function registerLogger() { $this->app->extend('log', function($log) { return new Writer($log->getMonolog(), $log->getEventDispatcher()); }); }
[ "public", "function", "registerLogger", "(", ")", "{", "$", "this", "->", "app", "->", "extend", "(", "'log'", ",", "function", "(", "$", "log", ")", "{", "return", "new", "Writer", "(", "$", "log", "->", "getMonolog", "(", ")", ",", "$", "log", "-...
Extend the logger. @return \Illuminate\Log\Writer
[ "Extend", "the", "logger", "." ]
35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8
https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Laravel/LoggingServiceProvider.php#L41-L46
train
ethical-jobs/ethical-jobs-foundation-php
src/Laravel/LoggingServiceProvider.php
LoggingServiceProvider.registerRollbar
public function registerRollbar() { if (in_array(App::environment(), ['production', 'staging'])) { $this->extendConfig(); $this->app->register(\Rollbar\Laravel\RollbarServiceProvider::class); } }
php
public function registerRollbar() { if (in_array(App::environment(), ['production', 'staging'])) { $this->extendConfig(); $this->app->register(\Rollbar\Laravel\RollbarServiceProvider::class); } }
[ "public", "function", "registerRollbar", "(", ")", "{", "if", "(", "in_array", "(", "App", "::", "environment", "(", ")", ",", "[", "'production'", ",", "'staging'", "]", ")", ")", "{", "$", "this", "->", "extendConfig", "(", ")", ";", "$", "this", "...
Register rollbar logger @return \Illuminate\Log\Writer
[ "Register", "rollbar", "logger" ]
35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8
https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Laravel/LoggingServiceProvider.php#L53-L61
train
rodrigoiii/skeleton-core
src/classes/Console/Commands/MakeControllerCommand.php
MakeControllerCommand.getTemplate
private function getTemplate($sub_directories, $controller, $is_resource = false) { $file = __DIR__ . "/../templates/controller/"; $file .= $is_resource ? "controller-with-resource.php.dist" : "controller.php.dist"; if (file_exists($file)) { $template = file_get_contents($file); return strtr($template, [ '{{namespace}}' => get_app_namespace(), '{{sub_directories}}' => $sub_directories, '{{controller}}' => $controller ]); } return false; }
php
private function getTemplate($sub_directories, $controller, $is_resource = false) { $file = __DIR__ . "/../templates/controller/"; $file .= $is_resource ? "controller-with-resource.php.dist" : "controller.php.dist"; if (file_exists($file)) { $template = file_get_contents($file); return strtr($template, [ '{{namespace}}' => get_app_namespace(), '{{sub_directories}}' => $sub_directories, '{{controller}}' => $controller ]); } return false; }
[ "private", "function", "getTemplate", "(", "$", "sub_directories", ",", "$", "controller", ",", "$", "is_resource", "=", "false", ")", "{", "$", "file", "=", "__DIR__", ".", "\"/../templates/controller/\"", ";", "$", "file", ".=", "$", "is_resource", "?", "\...
Get the controller template. @param string $sub_directories @param string $controller @param boolean $is_resource @return mixed
[ "Get", "the", "controller", "template", "." ]
5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0
https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/Console/Commands/MakeControllerCommand.php#L100-L117
train
cmsgears/module-core
common/models/entities/Region.php
Region.findUnique
public static function findUnique( $name, $countryId, $provinceId ) { return self::find()->where( 'name=:name AND countryId=:cid AND provinceId=:pid', [ ':name' => $name, ':cid' => $countryId, ':pid' => $provinceId ] )->one(); }
php
public static function findUnique( $name, $countryId, $provinceId ) { return self::find()->where( 'name=:name AND countryId=:cid AND provinceId=:pid', [ ':name' => $name, ':cid' => $countryId, ':pid' => $provinceId ] )->one(); }
[ "public", "static", "function", "findUnique", "(", "$", "name", ",", "$", "countryId", ",", "$", "provinceId", ")", "{", "return", "self", "::", "find", "(", ")", "->", "where", "(", "'name=:name AND countryId=:cid AND provinceId=:pid'", ",", "[", "':name'", "...
Try to find out a region having unique name within province. @param string $name @param integer $countryId @param integer $provinceId @return Region by name, country id and province id
[ "Try", "to", "find", "out", "a", "region", "having", "unique", "name", "within", "province", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/Region.php#L265-L268
train
cmsgears/module-core
common/models/entities/Region.php
Region.isUniqueExist
public static function isUniqueExist( $name, $countryId, $provinceId ) { $region = self::findUnique( $name, $countryId, $provinceId ); return isset( $region ); }
php
public static function isUniqueExist( $name, $countryId, $provinceId ) { $region = self::findUnique( $name, $countryId, $provinceId ); return isset( $region ); }
[ "public", "static", "function", "isUniqueExist", "(", "$", "name", ",", "$", "countryId", ",", "$", "provinceId", ")", "{", "$", "region", "=", "self", "::", "findUnique", "(", "$", "name", ",", "$", "countryId", ",", "$", "provinceId", ")", ";", "retu...
Check whether a region already exist using given name within province. @param string $name @param integer $countryId @param integer $provinceId @return boolean
[ "Check", "whether", "a", "region", "already", "exist", "using", "given", "name", "within", "province", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/Region.php#L278-L283
train
cmsgears/module-core
common/components/TemplateManager.php
TemplateManager.renderViewGeneric
public function renderViewGeneric( $template, $models, $viewFile, $config = [] ) { $config[ 'viewFile' ] = isset( $config[ 'viewFile' ] ) ? $config[ 'viewFile' ] : $viewFile; $config[ 'page' ] = isset( $config[ 'page' ] ) ? $config[ 'page' ] : true; return $this->renderView( $template, $models, $config ); }
php
public function renderViewGeneric( $template, $models, $viewFile, $config = [] ) { $config[ 'viewFile' ] = isset( $config[ 'viewFile' ] ) ? $config[ 'viewFile' ] : $viewFile; $config[ 'page' ] = isset( $config[ 'page' ] ) ? $config[ 'page' ] : true; return $this->renderView( $template, $models, $config ); }
[ "public", "function", "renderViewGeneric", "(", "$", "template", ",", "$", "models", ",", "$", "viewFile", ",", "$", "config", "=", "[", "]", ")", "{", "$", "config", "[", "'viewFile'", "]", "=", "isset", "(", "$", "config", "[", "'viewFile'", "]", "...
Default Page Views
[ "Default", "Page", "Views" ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/TemplateManager.php#L185-L191
train
cmsgears/module-core
common/components/TemplateManager.php
TemplateManager.renderViewAdmin
public function renderViewAdmin( $template, $models, $config = [] ) { return $this->renderViewGeneric( $template, $models, CoreGlobal::TPL_VIEW_ADMIN, $config ); }
php
public function renderViewAdmin( $template, $models, $config = [] ) { return $this->renderViewGeneric( $template, $models, CoreGlobal::TPL_VIEW_ADMIN, $config ); }
[ "public", "function", "renderViewAdmin", "(", "$", "template", ",", "$", "models", ",", "$", "config", "=", "[", "]", ")", "{", "return", "$", "this", "->", "renderViewGeneric", "(", "$", "template", ",", "$", "models", ",", "CoreGlobal", "::", "TPL_VIEW...
Admin view to be used for review purpose for data created by site users. The data collected by user will be submitted for admin review as part of approval process.
[ "Admin", "view", "to", "be", "used", "for", "review", "purpose", "for", "data", "created", "by", "site", "users", ".", "The", "data", "collected", "by", "user", "will", "be", "submitted", "for", "admin", "review", "as", "part", "of", "approval", "process",...
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/TemplateManager.php#L196-L199
train
cmsgears/module-core
common/components/TemplateManager.php
TemplateManager.renderViewPrivate
public function renderViewPrivate( $template, $models, $config = [] ) { return $this->renderViewGeneric( $template, $models, CoreGlobal::TPL_VIEW_PRIVATE, $config ); }
php
public function renderViewPrivate( $template, $models, $config = [] ) { return $this->renderViewGeneric( $template, $models, CoreGlobal::TPL_VIEW_PRIVATE, $config ); }
[ "public", "function", "renderViewPrivate", "(", "$", "template", ",", "$", "models", ",", "$", "config", "=", "[", "]", ")", "{", "return", "$", "this", "->", "renderViewGeneric", "(", "$", "template", ",", "$", "models", ",", "CoreGlobal", "::", "TPL_VI...
Private view to be viewed by logged in users. It's required for specific cases where views are different for logged in vs non logged in users.
[ "Private", "view", "to", "be", "viewed", "by", "logged", "in", "users", ".", "It", "s", "required", "for", "specific", "cases", "where", "views", "are", "different", "for", "logged", "in", "vs", "non", "logged", "in", "users", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/TemplateManager.php#L204-L207
train
cmsgears/module-core
common/components/TemplateManager.php
TemplateManager.renderViewPublic
public function renderViewPublic( $template, $models, $config = [] ) { return $this->renderViewGeneric( $template, $models, CoreGlobal::TPL_VIEW_PUBLIC, $config ); }
php
public function renderViewPublic( $template, $models, $config = [] ) { return $this->renderViewGeneric( $template, $models, CoreGlobal::TPL_VIEW_PUBLIC, $config ); }
[ "public", "function", "renderViewPublic", "(", "$", "template", ",", "$", "models", ",", "$", "config", "=", "[", "]", ")", "{", "return", "$", "this", "->", "renderViewGeneric", "(", "$", "template", ",", "$", "models", ",", "CoreGlobal", "::", "TPL_VIE...
Public view to be viewed by all users. Private view might override in specific scenarios.
[ "Public", "view", "to", "be", "viewed", "by", "all", "users", ".", "Private", "view", "might", "override", "in", "specific", "scenarios", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/TemplateManager.php#L212-L215
train
cmsgears/module-core
common/models/forms/FormModel.php
FormModel.load
public function load( $data, $formName = null ) { if( isset( $formName ) && isset( $data[ $formName ] ) ) { $this->data = $data[ $formName ]; } return parent::load( $data, $formName ); }
php
public function load( $data, $formName = null ) { if( isset( $formName ) && isset( $data[ $formName ] ) ) { $this->data = $data[ $formName ]; } return parent::load( $data, $formName ); }
[ "public", "function", "load", "(", "$", "data", ",", "$", "formName", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "formName", ")", "&&", "isset", "(", "$", "data", "[", "$", "formName", "]", ")", ")", "{", "$", "this", "->", "data", "=...
It process the submitted form data and store the form data using given form name. The model attributes will be set by the parent class. @param array $data @param string $formName @return boolean
[ "It", "process", "the", "submitted", "form", "data", "and", "store", "the", "form", "data", "using", "given", "form", "name", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/forms/FormModel.php#L69-L77
train
locomotivemtl/charcoal-property
src/Charcoal/Property/Structure/StructureMetadata.php
StructureMetadata.setIdent
public function setIdent($ident) { if ($ident === null) { $this->ident = null; return $this; } if (!is_string($ident)) { throw new InvalidArgumentException( sprintf( '[%s] Identifier must be a string; received %s', get_called_class(), (is_object($ident) ? get_class($ident) : gettype($ident)) ) ); } $this->ident = $ident; return $this; }
php
public function setIdent($ident) { if ($ident === null) { $this->ident = null; return $this; } if (!is_string($ident)) { throw new InvalidArgumentException( sprintf( '[%s] Identifier must be a string; received %s', get_called_class(), (is_object($ident) ? get_class($ident) : gettype($ident)) ) ); } $this->ident = $ident; return $this; }
[ "public", "function", "setIdent", "(", "$", "ident", ")", "{", "if", "(", "$", "ident", "===", "null", ")", "{", "$", "this", "->", "ident", "=", "null", ";", "return", "$", "this", ";", "}", "if", "(", "!", "is_string", "(", "$", "ident", ")", ...
Set the metadata identifier. @param string $ident The metadata identifier. @throws InvalidArgumentException If identifier is not a string. @return StructureMetadata Chainable
[ "Set", "the", "metadata", "identifier", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/Structure/StructureMetadata.php#L36-L56
train
locomotivemtl/charcoal-property
src/Charcoal/Property/Structure/StructureMetadata.php
StructureMetadata.setDefaultData
public function setDefaultData(array $data) { foreach ($data as $key => $val) { $this->defaultData[$key] = $val; } return $this; }
php
public function setDefaultData(array $data) { foreach ($data as $key => $val) { $this->defaultData[$key] = $val; } return $this; }
[ "public", "function", "setDefaultData", "(", "array", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "this", "->", "defaultData", "[", "$", "key", "]", "=", "$", "val", ";", "}", "return", "...
Set the object's default values. @param array $data An associative array. @return StructureMetadata
[ "Set", "the", "object", "s", "default", "values", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/Structure/StructureMetadata.php#L74-L81
train
locomotivemtl/charcoal-property
src/Charcoal/Property/Structure/StructureMetadata.php
StructureMetadata.setProperties
public function setProperties(array $properties) { foreach ($properties as $propertyIdent => $propertyMetadata) { if (isset($this->properties[$propertyIdent])) { $this->properties[$propertyIdent] = array_replace_recursive( $this->properties[$propertyIdent], $propertyMetadata ); } else { $this->properties[$propertyIdent] = $propertyMetadata; } } return $this; }
php
public function setProperties(array $properties) { foreach ($properties as $propertyIdent => $propertyMetadata) { if (isset($this->properties[$propertyIdent])) { $this->properties[$propertyIdent] = array_replace_recursive( $this->properties[$propertyIdent], $propertyMetadata ); } else { $this->properties[$propertyIdent] = $propertyMetadata; } } return $this; }
[ "public", "function", "setProperties", "(", "array", "$", "properties", ")", "{", "foreach", "(", "$", "properties", "as", "$", "propertyIdent", "=>", "$", "propertyMetadata", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "properties", "[", "$", ...
Set the properties. @param array $properties One or more properties. @return StructureMetadata
[ "Set", "the", "properties", "." ]
5ff339a0edb78a909537a9d2bb7f9b783255316b
https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/Structure/StructureMetadata.php#L89-L103
train
cmsgears/module-core
common/services/resources/FileService.php
FileService.create
public function create( $model, $config = [] ) { // model class $modelClass = static::$modelClass; // Default visibility if( !isset( $model->visibility ) ) { $model->visibility = File::VISIBILITY_PUBLIC; } $model->siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId; // Default sharing if( !isset( $model->shared ) ) { $model->shared = false; } // Create File $model->save(); // Return File return $model; }
php
public function create( $model, $config = [] ) { // model class $modelClass = static::$modelClass; // Default visibility if( !isset( $model->visibility ) ) { $model->visibility = File::VISIBILITY_PUBLIC; } $model->siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId; // Default sharing if( !isset( $model->shared ) ) { $model->shared = false; } // Create File $model->save(); // Return File return $model; }
[ "public", "function", "create", "(", "$", "model", ",", "$", "config", "=", "[", "]", ")", "{", "// model class", "$", "modelClass", "=", "static", "::", "$", "modelClass", ";", "// Default visibility", "if", "(", "!", "isset", "(", "$", "model", "->", ...
It create the file with visibility set to public by default. It also disallow the file to be shared among multiple models. If file sharing is set to false, it will be deleted with model and can't be browsed using file browser.
[ "It", "create", "the", "file", "with", "visibility", "set", "to", "public", "by", "default", ".", "It", "also", "disallow", "the", "file", "to", "be", "shared", "among", "multiple", "models", ".", "If", "file", "sharing", "is", "set", "to", "false", "it"...
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/resources/FileService.php#L257-L281
train
cmsgears/module-core
common/services/resources/FileService.php
FileService.saveFile
public function saveFile( $file, $args = [] ) { // Save only when filename is provided if( strlen( $file->name ) > 0 ) { $fileManager = Yii::$app->fileManager; $model = null; $attribute = null; // The model and it's attribute used to refer to image if( isset( $args[ 'model' ] ) ) $model = $args[ 'model' ]; if( isset( $args[ 'attribute' ] ) ) $attribute = $args[ 'attribute' ]; // Update File $fileId = $file->id; if( $file->changed ) { $fileManager->processFile( $file ); } // New File if( !isset( $fileId ) || strlen( $fileId ) <= 0 ) { // Unset Id $file->id = null; // Update File Size $file->resetSize(); // Create $this->create( $file ); // Update model attribute if( isset( $model ) && isset( $attribute ) ) { $model->setAttribute( $attribute, $file->id ); } } // Existing File - File Changed else if( $file->changed ) { // Update File Size $file->resetSize(); $this->updateData( $file ); } // Existing File - Info Changed else if( isset( $fileId ) && intval( $fileId ) > 0 ) { $this->update( $file ); } $file->changed = false; } return $file; }
php
public function saveFile( $file, $args = [] ) { // Save only when filename is provided if( strlen( $file->name ) > 0 ) { $fileManager = Yii::$app->fileManager; $model = null; $attribute = null; // The model and it's attribute used to refer to image if( isset( $args[ 'model' ] ) ) $model = $args[ 'model' ]; if( isset( $args[ 'attribute' ] ) ) $attribute = $args[ 'attribute' ]; // Update File $fileId = $file->id; if( $file->changed ) { $fileManager->processFile( $file ); } // New File if( !isset( $fileId ) || strlen( $fileId ) <= 0 ) { // Unset Id $file->id = null; // Update File Size $file->resetSize(); // Create $this->create( $file ); // Update model attribute if( isset( $model ) && isset( $attribute ) ) { $model->setAttribute( $attribute, $file->id ); } } // Existing File - File Changed else if( $file->changed ) { // Update File Size $file->resetSize(); $this->updateData( $file ); } // Existing File - Info Changed else if( isset( $fileId ) && intval( $fileId ) > 0 ) { $this->update( $file ); } $file->changed = false; } return $file; }
[ "public", "function", "saveFile", "(", "$", "file", ",", "$", "args", "=", "[", "]", ")", "{", "// Save only when filename is provided", "if", "(", "strlen", "(", "$", "file", "->", "name", ")", ">", "0", ")", "{", "$", "fileManager", "=", "Yii", "::",...
Save pre-uploaded file to respective directory. @param CmgFile $file @param array $args
[ "Save", "pre", "-", "uploaded", "file", "to", "respective", "directory", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/resources/FileService.php#L431-L488
train
cmsgears/module-core
common/services/resources/FileService.php
FileService.delete
public function delete( $model, $config = [] ) { $admin = isset( $config[ 'admin' ] ) ? $config[ 'admin' ] : false; if( isset( $model ) ) { // Only admin is authorised to delete a shared file using file browser. if( $admin || !$model->shared ) { // Delete mappings Yii::$app->factory->get( 'modelFileService' )->deleteByModelId( $model->id ); // Delete from disk $model->clearDisk(); // Delete model return parent::delete( $model, $config ); } } return false; }
php
public function delete( $model, $config = [] ) { $admin = isset( $config[ 'admin' ] ) ? $config[ 'admin' ] : false; if( isset( $model ) ) { // Only admin is authorised to delete a shared file using file browser. if( $admin || !$model->shared ) { // Delete mappings Yii::$app->factory->get( 'modelFileService' )->deleteByModelId( $model->id ); // Delete from disk $model->clearDisk(); // Delete model return parent::delete( $model, $config ); } } return false; }
[ "public", "function", "delete", "(", "$", "model", ",", "$", "config", "=", "[", "]", ")", "{", "$", "admin", "=", "isset", "(", "$", "config", "[", "'admin'", "]", ")", "?", "$", "config", "[", "'admin'", "]", ":", "false", ";", "if", "(", "is...
Delete the file and corresponding mappings. @param \cmsgears\core\common\models\resources\File $model @param array $config @return boolean
[ "Delete", "the", "file", "and", "corresponding", "mappings", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/resources/FileService.php#L517-L538
train
cmsgears/module-core
common/services/traits/base/ApprovalTrait.php
ApprovalTrait.getPageByOwnerId
public function getPageByOwnerId( $ownerId, $config = [] ) { $owner = $config[ 'owner' ] ?? false; $modelTable = $this->getModelTable(); if( $owner ) { $config[ 'conditions' ][ "$modelTable.holderId" ] = $ownerId; } else { $config[ 'conditions' ][ "$modelTable.createdBy" ] = $ownerId; } return $this->getPage( $config ); }
php
public function getPageByOwnerId( $ownerId, $config = [] ) { $owner = $config[ 'owner' ] ?? false; $modelTable = $this->getModelTable(); if( $owner ) { $config[ 'conditions' ][ "$modelTable.holderId" ] = $ownerId; } else { $config[ 'conditions' ][ "$modelTable.createdBy" ] = $ownerId; } return $this->getPage( $config ); }
[ "public", "function", "getPageByOwnerId", "(", "$", "ownerId", ",", "$", "config", "=", "[", "]", ")", "{", "$", "owner", "=", "$", "config", "[", "'owner'", "]", "??", "false", ";", "$", "modelTable", "=", "$", "this", "->", "getModelTable", "(", ")...
It expects the model to support either of createdBy or ownerId column. If both exist, ownerId will dominate.
[ "It", "expects", "the", "model", "to", "support", "either", "of", "createdBy", "or", "ownerId", "column", ".", "If", "both", "exist", "ownerId", "will", "dominate", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/traits/base/ApprovalTrait.php#L53-L68
train
cmsgears/module-core
common/services/traits/base/ApprovalTrait.php
ApprovalTrait.getPageByAuthorityId
public function getPageByAuthorityId( $id, $config = [] ) { $modelClass = static::$modelClass; $modelTable = $this->getModelTable(); $query = null; $owner = $config[ 'owner' ] ?? false; if( $owner ) { $query = $modelClass::queryWithOwnerAuthor(); $query->andWhere( "$modelTable.holderId =:oid OR ($modelTable.holderId IS NULL AND $modelTable.createdBy =:cid )", [ ':oid' => $id, ':cid' => $id ] ); } else { $query = $modelClass::queryWithAuthor(); $query->andWhere( "$modelTable.createdBy =:cid", [ ':cid' => $id ] ); } $config[ 'query' ] = $query; return $this->getPage( $config ); }
php
public function getPageByAuthorityId( $id, $config = [] ) { $modelClass = static::$modelClass; $modelTable = $this->getModelTable(); $query = null; $owner = $config[ 'owner' ] ?? false; if( $owner ) { $query = $modelClass::queryWithOwnerAuthor(); $query->andWhere( "$modelTable.holderId =:oid OR ($modelTable.holderId IS NULL AND $modelTable.createdBy =:cid )", [ ':oid' => $id, ':cid' => $id ] ); } else { $query = $modelClass::queryWithAuthor(); $query->andWhere( "$modelTable.createdBy =:cid", [ ':cid' => $id ] ); } $config[ 'query' ] = $query; return $this->getPage( $config ); }
[ "public", "function", "getPageByAuthorityId", "(", "$", "id", ",", "$", "config", "=", "[", "]", ")", "{", "$", "modelClass", "=", "static", "::", "$", "modelClass", ";", "$", "modelTable", "=", "$", "this", "->", "getModelTable", "(", ")", ";", "$", ...
It expects the model to support either createdBy or createdBy and ownerId columns
[ "It", "expects", "the", "model", "to", "support", "either", "createdBy", "or", "createdBy", "and", "ownerId", "columns" ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/traits/base/ApprovalTrait.php#L82-L106
train
cmsgears/module-core
common/services/traits/base/ApprovalTrait.php
ApprovalTrait.toggleFrojen
public function toggleFrojen( $model, $notify = true, $config = [] ) { $oldStatus = $model->getStatusStr(); $model->toggleFrojen(); $model->save(); $newStatus = $model->getStatusStr(); if( $notify ) { $title = $model->isActive( true ) ? $model->getClassName() . ' Activated' : $model->getClassName() . ' Frozen'; $config[ 'template' ] = $model->isActive( true ) ? CoreGlobal::TPL_NOTIFY_STATUS_ACTIVE : CoreGlobal::TPL_NOTIFY_STATUS_FREEZE; $config[ 'data' ][ 'oldStatus' ] = $oldStatus; $config[ 'data' ][ 'newStatus' ] = $newStatus; $this->notifyUser( $model, $config, $title ); } return $model; }
php
public function toggleFrojen( $model, $notify = true, $config = [] ) { $oldStatus = $model->getStatusStr(); $model->toggleFrojen(); $model->save(); $newStatus = $model->getStatusStr(); if( $notify ) { $title = $model->isActive( true ) ? $model->getClassName() . ' Activated' : $model->getClassName() . ' Frozen'; $config[ 'template' ] = $model->isActive( true ) ? CoreGlobal::TPL_NOTIFY_STATUS_ACTIVE : CoreGlobal::TPL_NOTIFY_STATUS_FREEZE; $config[ 'data' ][ 'oldStatus' ] = $oldStatus; $config[ 'data' ][ 'newStatus' ] = $newStatus; $this->notifyUser( $model, $config, $title ); } return $model; }
[ "public", "function", "toggleFrojen", "(", "$", "model", ",", "$", "notify", "=", "true", ",", "$", "config", "=", "[", "]", ")", "{", "$", "oldStatus", "=", "$", "model", "->", "getStatusStr", "(", ")", ";", "$", "model", "->", "toggleFrojen", "(", ...
Toggle the model between Frozen and Active states. @param \cmsgears\core\common\models\interfaces\base\IApproval $model @param boolean $notify @param array $config @return \cmsgears\core\common\models\interfaces\base\IApproval
[ "Toggle", "the", "model", "between", "Frozen", "and", "Active", "states", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/traits/base/ApprovalTrait.php#L549-L571
train
cmsgears/module-core
common/services/traits/base/ApprovalTrait.php
ApprovalTrait.toggleBlock
public function toggleBlock( $model, $notify = true, $config = [] ) { $oldStatus = $model->getStatusStr(); $model->toggleBlock(); $model->save(); $newStatus = $model->getStatusStr(); if( $notify ) { $title = $model->isActive( true ) ? $model->getClassName() . ' Activated' : $model->getClassName() . ' Blocked'; $config[ 'template' ] = $model->isActive( true ) ? CoreGlobal::TPL_NOTIFY_STATUS_ACTIVE : CoreGlobal::TPL_NOTIFY_STATUS_BLOCK; $config[ 'data' ][ 'oldStatus' ] = $oldStatus; $config[ 'data' ][ 'newStatus' ] = $newStatus; $this->notifyUser( $model, $config, $title ); } return $model; }
php
public function toggleBlock( $model, $notify = true, $config = [] ) { $oldStatus = $model->getStatusStr(); $model->toggleBlock(); $model->save(); $newStatus = $model->getStatusStr(); if( $notify ) { $title = $model->isActive( true ) ? $model->getClassName() . ' Activated' : $model->getClassName() . ' Blocked'; $config[ 'template' ] = $model->isActive( true ) ? CoreGlobal::TPL_NOTIFY_STATUS_ACTIVE : CoreGlobal::TPL_NOTIFY_STATUS_BLOCK; $config[ 'data' ][ 'oldStatus' ] = $oldStatus; $config[ 'data' ][ 'newStatus' ] = $newStatus; $this->notifyUser( $model, $config, $title ); } return $model; }
[ "public", "function", "toggleBlock", "(", "$", "model", ",", "$", "notify", "=", "true", ",", "$", "config", "=", "[", "]", ")", "{", "$", "oldStatus", "=", "$", "model", "->", "getStatusStr", "(", ")", ";", "$", "model", "->", "toggleBlock", "(", ...
Toggle the model between Blocked and Active states. @param \cmsgears\core\common\models\interfaces\base\IApproval $model @param boolean $notify @param array $config @return \cmsgears\core\common\models\interfaces\base\IApproval
[ "Toggle", "the", "model", "between", "Blocked", "and", "Active", "states", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/traits/base/ApprovalTrait.php#L581-L603
train
apioo/psx-http
src/Parser/RequestParser.php
RequestParser.parse
public function parse($content) { $content = $this->normalize($content); list($method, $path, $scheme) = $this->getStatus($content); // resolve uri path if ($this->baseUrl !== null) { $path = UriResolver::resolve($this->baseUrl, new Uri($path)); } else { $path = new Uri($path); } $request = new Request($path, $method); $request->setProtocolVersion($scheme); list($header, $body) = $this->splitMessage($content); $this->headerToArray($request, $header); $request->setBody(new StringStream($body)); return $request; }
php
public function parse($content) { $content = $this->normalize($content); list($method, $path, $scheme) = $this->getStatus($content); // resolve uri path if ($this->baseUrl !== null) { $path = UriResolver::resolve($this->baseUrl, new Uri($path)); } else { $path = new Uri($path); } $request = new Request($path, $method); $request->setProtocolVersion($scheme); list($header, $body) = $this->splitMessage($content); $this->headerToArray($request, $header); $request->setBody(new StringStream($body)); return $request; }
[ "public", "function", "parse", "(", "$", "content", ")", "{", "$", "content", "=", "$", "this", "->", "normalize", "(", "$", "content", ")", ";", "list", "(", "$", "method", ",", "$", "path", ",", "$", "scheme", ")", "=", "$", "this", "->", "getS...
Converts an raw http request into an PSX\Http\Request object @param string $content @return \PSX\Http\Request @throws \PSX\Http\Parser\ParseException
[ "Converts", "an", "raw", "http", "request", "into", "an", "PSX", "\\", "Http", "\\", "Request", "object" ]
c54d7212cfb513df84f810429aa34c6ac9942c01
https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Parser/RequestParser.php#L55-L78
train
apioo/psx-http
src/Parser/RequestParser.php
RequestParser.convert
public static function convert($content, Url $baseUrl = null, $mode = ParserAbstract::MODE_STRICT) { $parser = new self($baseUrl, $mode); return $parser->parse($content); }
php
public static function convert($content, Url $baseUrl = null, $mode = ParserAbstract::MODE_STRICT) { $parser = new self($baseUrl, $mode); return $parser->parse($content); }
[ "public", "static", "function", "convert", "(", "$", "content", ",", "Url", "$", "baseUrl", "=", "null", ",", "$", "mode", "=", "ParserAbstract", "::", "MODE_STRICT", ")", "{", "$", "parser", "=", "new", "self", "(", "$", "baseUrl", ",", "$", "mode", ...
Parses an raw http request into an PSX\Http\Request object. Throws an exception if the request has not an valid format @param string $content @param \PSX\Uri\Url $baseUrl @param integer $mode @return \PSX\Http\RequestInterface @throws \PSX\Http\Parser\ParseException
[ "Parses", "an", "raw", "http", "request", "into", "an", "PSX", "\\", "Http", "\\", "Request", "object", ".", "Throws", "an", "exception", "if", "the", "request", "has", "not", "an", "valid", "format" ]
c54d7212cfb513df84f810429aa34c6ac9942c01
https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Parser/RequestParser.php#L136-L141
train
phPoirot/Std
src/Struct/fixes/aDataOptions.php
aDataOptions.doWhichMethodIgnored
protected function doWhichMethodIgnored() { if (!$this->_c_is_process_ignored_notation) { ## Detect/Default Ignored ### Detect: by docblock $this->__ignoreFromDocBlock(); ### Default: isFulfilled and isEmpty is public internal method and not option $x = &$this->_t_options__ignored; $x[] = 'isFulfilled'; $x[] = 'isEmpty'; $x[] = 'getIterator'; $this->_c_is_process_ignored_notation = true; } return $this->_t_options__ignored; }
php
protected function doWhichMethodIgnored() { if (!$this->_c_is_process_ignored_notation) { ## Detect/Default Ignored ### Detect: by docblock $this->__ignoreFromDocBlock(); ### Default: isFulfilled and isEmpty is public internal method and not option $x = &$this->_t_options__ignored; $x[] = 'isFulfilled'; $x[] = 'isEmpty'; $x[] = 'getIterator'; $this->_c_is_process_ignored_notation = true; } return $this->_t_options__ignored; }
[ "protected", "function", "doWhichMethodIgnored", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_c_is_process_ignored_notation", ")", "{", "## Detect/Default Ignored", "### Detect: by docblock", "$", "this", "->", "__ignoreFromDocBlock", "(", ")", ";", "### Defaul...
Get List Of Ignored Methods @return array
[ "Get", "List", "Of", "Ignored", "Methods" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/fixes/aDataOptions.php#L71-L88
train
phPoirot/Std
src/Struct/fixes/aDataOptions.php
aDataOptions._fix__getIterator
protected function _fix__getIterator() { $arr = array(); foreach($this->_getProperties() as $p) { if (!$p->isReadable()) continue; $val = $this->__get($p->getKey()); $arr[(string) $p] = $val; } return new \ArrayIterator($arr); }
php
protected function _fix__getIterator() { $arr = array(); foreach($this->_getProperties() as $p) { if (!$p->isReadable()) continue; $val = $this->__get($p->getKey()); $arr[(string) $p] = $val; } return new \ArrayIterator($arr); }
[ "protected", "function", "_fix__getIterator", "(", ")", "{", "$", "arr", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_getProperties", "(", ")", "as", "$", "p", ")", "{", "if", "(", "!", "$", "p", "->", "isReadable", "(", ")", ...
DO_LEAST_PHPVER_SUPPORT v5.5 yeild
[ "DO_LEAST_PHPVER_SUPPORT", "v5", ".", "5", "yeild" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/fixes/aDataOptions.php#L118-L129
train
phPoirot/Std
src/Struct/fixes/aDataOptions.php
aDataOptions._normalize
protected function _normalize($key, $type) { $type = strtolower($type); if ($type !== 'external' && $type !== 'internal') throw new \InvalidArgumentException; if ($type === 'external') $return = $this->_normalizeExternal($key); else $return = $this->_normalizeInternal($key); return $return; }
php
protected function _normalize($key, $type) { $type = strtolower($type); if ($type !== 'external' && $type !== 'internal') throw new \InvalidArgumentException; if ($type === 'external') $return = $this->_normalizeExternal($key); else $return = $this->_normalizeInternal($key); return $return; }
[ "protected", "function", "_normalize", "(", "$", "key", ",", "$", "type", ")", "{", "$", "type", "=", "strtolower", "(", "$", "type", ")", ";", "if", "(", "$", "type", "!==", "'external'", "&&", "$", "type", "!==", "'internal'", ")", "throw", "new", ...
Property Key Normalizer @param string $key @param string $type internal|external @return string
[ "Property", "Key", "Normalizer" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/fixes/aDataOptions.php#L452-L465
train
phPoirot/Std
src/Struct/fixes/aDataOptions.php
aDataOptions.__isValueMatchAsExpected
protected function __isValueMatchAsExpected($value, $expectedString) { $match = false; if ($expectedString === null) ## undefined expected values must not be NULL ## except when it write down on docblock "@return void" return $value === null; $valueType = strtolower(gettype($value)); /** * @return string|null|object|\Stdclass|void */ $expectedString = explode('|', $expectedString); foreach($expectedString as $ext) { $ext = strtolower(trim($ext)); if ($ext == '') continue; if ($value === VOID && $ext == 'void') $match = true; elseif ($valueType === $ext && $value != null) $match = true; elseif ($valueType === 'object') { if (is_a($value, $ext)) $match = true; } if ($match) break; } return $match; }
php
protected function __isValueMatchAsExpected($value, $expectedString) { $match = false; if ($expectedString === null) ## undefined expected values must not be NULL ## except when it write down on docblock "@return void" return $value === null; $valueType = strtolower(gettype($value)); /** * @return string|null|object|\Stdclass|void */ $expectedString = explode('|', $expectedString); foreach($expectedString as $ext) { $ext = strtolower(trim($ext)); if ($ext == '') continue; if ($value === VOID && $ext == 'void') $match = true; elseif ($valueType === $ext && $value != null) $match = true; elseif ($valueType === 'object') { if (is_a($value, $ext)) $match = true; } if ($match) break; } return $match; }
[ "protected", "function", "__isValueMatchAsExpected", "(", "$", "value", ",", "$", "expectedString", ")", "{", "$", "match", "=", "false", ";", "if", "(", "$", "expectedString", "===", "null", ")", "## undefined expected values must not be NULL", "## except when it wri...
Match a value against expected docblock comment @param mixed $value @param string $expectedString @return bool
[ "Match", "a", "value", "against", "expected", "docblock", "comment" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/fixes/aDataOptions.php#L545-L577
train
phPoirot/Std
src/Struct/fixes/aDataOptions.php
aDataOptions.__ignoreFromDocBlock
protected function __ignoreFromDocBlock() { $ref = $this->_newReflection(); // ignored methods from Class DocComment: $classDocComment = $ref->getDocComment(); if ($classDocComment !== false && preg_match_all('/.*[\n]?/', $classDocComment, $lines)) { $lines = $lines[0]; $regex = '/.+(@method).+((?P<method_name>\b\w+)\(.*\))\s@ignore\s/'; foreach($lines as $line) { if (preg_match($regex, $line, $matches)) $this->ignore($matches['method_name']); } } // ignored methods from Method DocBlock $methods = $ref->getMethods(ReflectionMethod::IS_PUBLIC); foreach($methods as $m) { $mc = $m->getDocComment(); if ($mc !== false && preg_match('/@ignore\s/', $mc, $matches)) $this->ignore($m->getName()); } }
php
protected function __ignoreFromDocBlock() { $ref = $this->_newReflection(); // ignored methods from Class DocComment: $classDocComment = $ref->getDocComment(); if ($classDocComment !== false && preg_match_all('/.*[\n]?/', $classDocComment, $lines)) { $lines = $lines[0]; $regex = '/.+(@method).+((?P<method_name>\b\w+)\(.*\))\s@ignore\s/'; foreach($lines as $line) { if (preg_match($regex, $line, $matches)) $this->ignore($matches['method_name']); } } // ignored methods from Method DocBlock $methods = $ref->getMethods(ReflectionMethod::IS_PUBLIC); foreach($methods as $m) { $mc = $m->getDocComment(); if ($mc !== false && preg_match('/@ignore\s/', $mc, $matches)) $this->ignore($m->getName()); } }
[ "protected", "function", "__ignoreFromDocBlock", "(", ")", "{", "$", "ref", "=", "$", "this", "->", "_newReflection", "(", ")", ";", "// ignored methods from Class DocComment:", "$", "classDocComment", "=", "$", "ref", "->", "getDocComment", "(", ")", ";", "if",...
Ignore Methods that Commented as DocBlocks
[ "Ignore", "Methods", "that", "Commented", "as", "DocBlocks" ]
67883b1b1dd2cea80fec3d98a199c403b8a23b4d
https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/fixes/aDataOptions.php#L583-L605
train
rodrigoiii/skeleton-core
src/classes/AppCli.php
AppCli.boot
public function boot() { $this->loadDatabaseConnection(); $this->loadLibraries(); if (file_exists(system_path("registered-libraries-cli.php"))) { require system_path("registered-libraries-cli.php"); } if (file_exists(system_path("registered-global-middlewares-cli.php"))) { require system_path("registered-global-middlewares-cli.php"); } $application_commands = $this->getApplicationCommands(glob(app_path('Commands/*.php'))); $skeleton_commands = $this->getSkeletonCoreCommands(glob(__DIR__ . "/Console/Commands/*.php")); $modules_commands = $this->getModulesCommands(); $this->cli_app = new Application(config('app.name')); $this->cli_app->addCommands(array_merge($application_commands, $skeleton_commands, $modules_commands)); }
php
public function boot() { $this->loadDatabaseConnection(); $this->loadLibraries(); if (file_exists(system_path("registered-libraries-cli.php"))) { require system_path("registered-libraries-cli.php"); } if (file_exists(system_path("registered-global-middlewares-cli.php"))) { require system_path("registered-global-middlewares-cli.php"); } $application_commands = $this->getApplicationCommands(glob(app_path('Commands/*.php'))); $skeleton_commands = $this->getSkeletonCoreCommands(glob(__DIR__ . "/Console/Commands/*.php")); $modules_commands = $this->getModulesCommands(); $this->cli_app = new Application(config('app.name')); $this->cli_app->addCommands(array_merge($application_commands, $skeleton_commands, $modules_commands)); }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "loadDatabaseConnection", "(", ")", ";", "$", "this", "->", "loadLibraries", "(", ")", ";", "if", "(", "file_exists", "(", "system_path", "(", "\"registered-libraries-cli.php\"", ")", ")", ")", ...
Boot the cli application. @return void
[ "Boot", "the", "cli", "application", "." ]
5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0
https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/AppCli.php#L139-L160
train
yawik/Orders
src/Entity/Order.php
Order.setPrice
public function setPrice($amount) { $tax = $this->getTaxRate() / 100; $taxAmount = $amount * $tax; $this->prices = [ 'pretax' => round($amount, 2), 'tax' => round($taxAmount, 2), 'net' => round($amount + $taxAmount, 2), ]; return $this; }
php
public function setPrice($amount) { $tax = $this->getTaxRate() / 100; $taxAmount = $amount * $tax; $this->prices = [ 'pretax' => round($amount, 2), 'tax' => round($taxAmount, 2), 'net' => round($amount + $taxAmount, 2), ]; return $this; }
[ "public", "function", "setPrice", "(", "$", "amount", ")", "{", "$", "tax", "=", "$", "this", "->", "getTaxRate", "(", ")", "/", "100", ";", "$", "taxAmount", "=", "$", "amount", "*", "$", "tax", ";", "$", "this", "->", "prices", "=", "[", "'pret...
Sets the total amount without tax. Discount and sconti should be calculated before hand. @param int $amount @return self
[ "Sets", "the", "total", "amount", "without", "tax", "." ]
2c21bfc3b927002531aba1caa2967d56561ac501
https://github.com/yawik/Orders/blob/2c21bfc3b927002531aba1caa2967d56561ac501/src/Entity/Order.php#L251-L263
train
yawik/Orders
src/Entity/Order.php
Order.calculatePrices
public function calculatePrices() { if ($this->getId()) { return; } $taxFactor = $this->getTaxRate() / 100; $total = $pretax = $tax = 0; $sums = []; /* @var ProductInterface $product */ foreach ($this->getProducts() as $product) { $pPreTax = $product->getPrice(); $pTax = $pPreTax * $taxFactor; $pTotal = $pPreTax + $pTax; $pQuantity = $product->getQuantity(); $ptPreTax = $pQuantity * $pPreTax; $ptTax = $pQuantity * $pTax; $ptTotal = $pQuantity * $pTotal; $sums[$product->getName()] = [ 'single_pretax' => $pPreTax, 'single_tax' => $pTax, 'single_total' => $pTotal, 'pretax' => $ptPreTax, 'tax' => $ptTax, 'total' => $ptTotal, ]; $total += $ptTotal; $pretax += $ptPreTax; $tax += $ptTax; } $this->prices = [ 'products' => $sums, 'total' => $total, 'tax' => $tax, 'pretax' => $pretax, ]; }
php
public function calculatePrices() { if ($this->getId()) { return; } $taxFactor = $this->getTaxRate() / 100; $total = $pretax = $tax = 0; $sums = []; /* @var ProductInterface $product */ foreach ($this->getProducts() as $product) { $pPreTax = $product->getPrice(); $pTax = $pPreTax * $taxFactor; $pTotal = $pPreTax + $pTax; $pQuantity = $product->getQuantity(); $ptPreTax = $pQuantity * $pPreTax; $ptTax = $pQuantity * $pTax; $ptTotal = $pQuantity * $pTotal; $sums[$product->getName()] = [ 'single_pretax' => $pPreTax, 'single_tax' => $pTax, 'single_total' => $pTotal, 'pretax' => $ptPreTax, 'tax' => $ptTax, 'total' => $ptTotal, ]; $total += $ptTotal; $pretax += $ptPreTax; $tax += $ptTax; } $this->prices = [ 'products' => $sums, 'total' => $total, 'tax' => $tax, 'pretax' => $pretax, ]; }
[ "public", "function", "calculatePrices", "(", ")", "{", "if", "(", "$", "this", "->", "getId", "(", ")", ")", "{", "return", ";", "}", "$", "taxFactor", "=", "$", "this", "->", "getTaxRate", "(", ")", "/", "100", ";", "$", "total", "=", "$", "pre...
Calculates the prices. Not used at the moment.
[ "Calculates", "the", "prices", "." ]
2c21bfc3b927002531aba1caa2967d56561ac501
https://github.com/yawik/Orders/blob/2c21bfc3b927002531aba1caa2967d56561ac501/src/Entity/Order.php#L295-L335
train
cmsgears/module-core
common/models/resources/Form.php
Form.getFieldsMap
public function getFieldsMap() { $formFields = $this->fields; $fieldsMap = []; foreach( $formFields as $formField ) { $fieldsMap[ $formField->name ] = $formField; } return $fieldsMap; }
php
public function getFieldsMap() { $formFields = $this->fields; $fieldsMap = []; foreach( $formFields as $formField ) { $fieldsMap[ $formField->name ] = $formField; } return $fieldsMap; }
[ "public", "function", "getFieldsMap", "(", ")", "{", "$", "formFields", "=", "$", "this", "->", "fields", ";", "$", "fieldsMap", "=", "[", "]", ";", "foreach", "(", "$", "formFields", "as", "$", "formField", ")", "{", "$", "fieldsMap", "[", "$", "for...
Return map of form fields having field name as key and field itself as value. @return array FormField map
[ "Return", "map", "of", "form", "fields", "having", "field", "name", "as", "key", "and", "field", "itself", "as", "value", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/Form.php#L275-L286
train
cmsgears/module-core
common/models/base/ModelMapper.php
ModelMapper.isActiveMapping
public function isActiveMapping( $parentId, $parentType ) { return $this->active && $this->parentId == $parentId && $this->parentType == $parentType; }
php
public function isActiveMapping( $parentId, $parentType ) { return $this->active && $this->parentId == $parentId && $this->parentType == $parentType; }
[ "public", "function", "isActiveMapping", "(", "$", "parentId", ",", "$", "parentType", ")", "{", "return", "$", "this", "->", "active", "&&", "$", "this", "->", "parentId", "==", "$", "parentId", "&&", "$", "this", "->", "parentType", "==", "$", "parentT...
Check whether mapping is active using given parent id and type. @param integer $parentId @param string $parentType @return boolean
[ "Check", "whether", "mapping", "is", "active", "using", "given", "parent", "id", "and", "type", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelMapper.php#L156-L159
train
cmsgears/module-core
common/models/base/ModelMapper.php
ModelMapper.queryByParent
public static function queryByParent( $parentId, $parentType ) { $tableName = static::tableName(); return self::queryWithModel()->where( "$tableName.parentId=:pid AND $tableName.parentType=:ptype", [ ':pid' => $parentId, ':ptype' => $parentType ] ); }
php
public static function queryByParent( $parentId, $parentType ) { $tableName = static::tableName(); return self::queryWithModel()->where( "$tableName.parentId=:pid AND $tableName.parentType=:ptype", [ ':pid' => $parentId, ':ptype' => $parentType ] ); }
[ "public", "static", "function", "queryByParent", "(", "$", "parentId", ",", "$", "parentType", ")", "{", "$", "tableName", "=", "static", "::", "tableName", "(", ")", ";", "return", "self", "::", "queryWithModel", "(", ")", "->", "where", "(", "\"$tableNam...
Return query to find the mapping for given parent id and parent type. @param integer $parentId @param string $parentType @return \yii\db\ActiveQuery to find using parent id and parent type.
[ "Return", "query", "to", "find", "the", "mapping", "for", "given", "parent", "id", "and", "parent", "type", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelMapper.php#L215-L220
train
cmsgears/module-core
common/models/base/ModelMapper.php
ModelMapper.queryByParentModelId
public static function queryByParentModelId( $parentId, $parentType, $modelId ) { $tableName = static::tableName(); return self::queryWithModel()->where( "$tableName.parentId=:pid AND $tableName.parentType=:ptype AND $tableName.modelId=:mid", [ ':pid' => $parentId, ':ptype' => $parentType, ':mid' => $modelId ] ); }
php
public static function queryByParentModelId( $parentId, $parentType, $modelId ) { $tableName = static::tableName(); return self::queryWithModel()->where( "$tableName.parentId=:pid AND $tableName.parentType=:ptype AND $tableName.modelId=:mid", [ ':pid' => $parentId, ':ptype' => $parentType, ':mid' => $modelId ] ); }
[ "public", "static", "function", "queryByParentModelId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "modelId", ")", "{", "$", "tableName", "=", "static", "::", "tableName", "(", ")", ";", "return", "self", "::", "queryWithModel", "(", ")", "->"...
Return query to find the mapping for given parent id, parent type and model id. @param integer $parentId @param string $parentType @param integer $modelId @return \yii\db\ActiveQuery to find using parent id and parent type.
[ "Return", "query", "to", "find", "the", "mapping", "for", "given", "parent", "id", "parent", "type", "and", "model", "id", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelMapper.php#L243-L248
train
cmsgears/module-core
common/models/base/ModelMapper.php
ModelMapper.queryByTypeParent
public static function queryByTypeParent( $parentId, $parentType, $type ) { $tableName = static::tableName(); return self::queryWithModel()->where( "$tableName.parentId=:pid AND $tableName.parentType=:ptype AND $tableName.type=:type", [ ':pid' => $parentId, ':ptype' => $parentType, ':type' => $type ] ); }
php
public static function queryByTypeParent( $parentId, $parentType, $type ) { $tableName = static::tableName(); return self::queryWithModel()->where( "$tableName.parentId=:pid AND $tableName.parentType=:ptype AND $tableName.type=:type", [ ':pid' => $parentId, ':ptype' => $parentType, ':type' => $type ] ); }
[ "public", "static", "function", "queryByTypeParent", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "type", ")", "{", "$", "tableName", "=", "static", "::", "tableName", "(", ")", ";", "return", "self", "::", "queryWithModel", "(", ")", "->", "w...
Return query to find the mapping for given parent id, parent type and mapping type. @param integer $parentId @param string $parentType @param string $type @return \yii\db\ActiveQuery to find using parent id, parent type and mapping type.
[ "Return", "query", "to", "find", "the", "mapping", "for", "given", "parent", "id", "parent", "type", "and", "mapping", "type", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelMapper.php#L258-L263
train
cmsgears/module-core
common/models/base/ModelMapper.php
ModelMapper.findByParentModelId
public static function findByParentModelId( $parentId, $parentType, $modelId ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->all(); }
php
public static function findByParentModelId( $parentId, $parentType, $modelId ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->all(); }
[ "public", "static", "function", "findByParentModelId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "modelId", ")", "{", "return", "self", "::", "queryByParentModelId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "modelId", ")", "->", ...
Find and return the mappings for given parent id, parent type and model id. @param integer $parentId @param string $parentType @param integer $modelId @return \cmsgears\core\common\models\base\ActiveRecord[]
[ "Find", "and", "return", "the", "mappings", "for", "given", "parent", "id", "parent", "type", "and", "model", "id", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelMapper.php#L321-L324
train
cmsgears/module-core
common/models/base/ModelMapper.php
ModelMapper.findFirstByParentModelId
public static function findFirstByParentModelId( $parentId, $parentType, $modelId ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->one(); }
php
public static function findFirstByParentModelId( $parentId, $parentType, $modelId ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->one(); }
[ "public", "static", "function", "findFirstByParentModelId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "modelId", ")", "{", "return", "self", "::", "queryByParentModelId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "modelId", ")", "...
Find and return the first mapping for given parent id, parent type and model id. It's useful for the cases where only one mapping is allowed for a parent and model. @param integer $parentId @param string $parentType @param integer $modelId @return \cmsgears\core\common\models\base\ActiveRecord
[ "Find", "and", "return", "the", "first", "mapping", "for", "given", "parent", "id", "parent", "type", "and", "model", "id", ".", "It", "s", "useful", "for", "the", "cases", "where", "only", "one", "mapping", "is", "allowed", "for", "a", "parent", "and", ...
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelMapper.php#L335-L338
train
cmsgears/module-core
common/models/base/ModelMapper.php
ModelMapper.findByParentModelIdType
public static function findByParentModelIdType( $parentId, $parentType, $modelId, $type ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->andWhere( 'type=:type', [ ':type' => $type ] )->all(); }
php
public static function findByParentModelIdType( $parentId, $parentType, $modelId, $type ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->andWhere( 'type=:type', [ ':type' => $type ] )->all(); }
[ "public", "static", "function", "findByParentModelIdType", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "modelId", ",", "$", "type", ")", "{", "return", "self", "::", "queryByParentModelId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", ...
Find and return the mappings for given parent id, parent type, model id and type. @param integer $parentId @param string $parentType @param integer $modelId @param integer $type @return \cmsgears\core\common\models\base\ActiveRecord[]
[ "Find", "and", "return", "the", "mappings", "for", "given", "parent", "id", "parent", "type", "model", "id", "and", "type", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelMapper.php#L361-L364
train
cmsgears/module-core
common/models/base/ModelMapper.php
ModelMapper.findFirstByParentModelIdType
public static function findFirstByParentModelIdType( $parentId, $parentType, $modelId, $type ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->andWhere( 'type=:type', [ ':type' => $type ] )->one(); }
php
public static function findFirstByParentModelIdType( $parentId, $parentType, $modelId, $type ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->andWhere( 'type=:type', [ ':type' => $type ] )->one(); }
[ "public", "static", "function", "findFirstByParentModelIdType", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "modelId", ",", "$", "type", ")", "{", "return", "self", "::", "queryByParentModelId", "(", "$", "parentId", ",", "$", "parentType", ",", ...
Find and return the mapping for given parent id, parent type, model id and type. It's useful for the cases where only one mapping is allowed for a parent, model and type. @param integer $parentId @param string $parentType @param integer $modelId @param integer $type @return \cmsgears\core\common\models\base\ActiveRecord
[ "Find", "and", "return", "the", "mapping", "for", "given", "parent", "id", "parent", "type", "model", "id", "and", "type", ".", "It", "s", "useful", "for", "the", "cases", "where", "only", "one", "mapping", "is", "allowed", "for", "a", "parent", "model",...
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelMapper.php#L376-L379
train
cmsgears/module-core
common/models/base/ModelMapper.php
ModelMapper.findActiveByParentModelId
public static function findActiveByParentModelId( $parentId, $parentType, $modelId ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->andWhere( 'active=1' )->all(); }
php
public static function findActiveByParentModelId( $parentId, $parentType, $modelId ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->andWhere( 'active=1' )->all(); }
[ "public", "static", "function", "findActiveByParentModelId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "modelId", ")", "{", "return", "self", "::", "queryByParentModelId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "modelId", ")", ...
Find and return the active mappings for parent id, parent type and model id. @param integer $parentId @param string $parentType @param integer $modelId @return \cmsgears\core\common\models\base\ActiveRecord[]
[ "Find", "and", "return", "the", "active", "mappings", "for", "parent", "id", "parent", "type", "and", "model", "id", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelMapper.php#L435-L438
train
cmsgears/module-core
common/models/base/ModelMapper.php
ModelMapper.findFirstActiveByParentModelId
public static function findFirstActiveByParentModelId( $parentId, $parentType, $modelId ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->andWhere( 'active=1' )->one(); }
php
public static function findFirstActiveByParentModelId( $parentId, $parentType, $modelId ) { return self::queryByParentModelId( $parentId, $parentType, $modelId )->andWhere( 'active=1' )->one(); }
[ "public", "static", "function", "findFirstActiveByParentModelId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "modelId", ")", "{", "return", "self", "::", "queryByParentModelId", "(", "$", "parentId", ",", "$", "parentType", ",", "$", "modelId", ")...
Find and return the active mappings for parent id, parent type and model id. It's useful for the cases where only one active mapping is allowed for a parent and model. @param integer $parentId @param string $parentType @param integer $modelId @return \cmsgears\core\common\models\base\ActiveRecord
[ "Find", "and", "return", "the", "active", "mappings", "for", "parent", "id", "parent", "type", "and", "model", "id", ".", "It", "s", "useful", "for", "the", "cases", "where", "only", "one", "active", "mapping", "is", "allowed", "for", "a", "parent", "and...
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelMapper.php#L449-L452
train
cmsgears/module-core
common/models/base/ModelMapper.php
ModelMapper.disableByParent
public static function disableByParent( $parentId, $parentType ) { $tableName = static::tableName(); // Disable all mappings $query = "UPDATE $tableName SET `active`=0 WHERE `parentType`='$parentType' AND `parentId`=$parentId"; $command = Yii::$app->db->createCommand( $query ); $command->execute(); }
php
public static function disableByParent( $parentId, $parentType ) { $tableName = static::tableName(); // Disable all mappings $query = "UPDATE $tableName SET `active`=0 WHERE `parentType`='$parentType' AND `parentId`=$parentId"; $command = Yii::$app->db->createCommand( $query ); $command->execute(); }
[ "public", "static", "function", "disableByParent", "(", "$", "parentId", ",", "$", "parentType", ")", "{", "$", "tableName", "=", "static", "::", "tableName", "(", ")", ";", "// Disable all mappings", "$", "query", "=", "\"UPDATE $tableName SET `active`=0 WHERE `par...
Disable all the mappings for given parent id and parent type. @param integer $parentId @param string $parentType @return integer number of rows. @throws Exception in case query failed.
[ "Disable", "all", "the", "mappings", "for", "given", "parent", "id", "and", "parent", "type", "." ]
ce1b1f7afff2931847d71afa152c72355f374dc6
https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelMapper.php#L507-L516
train
spiffyjr/spiffy-framework
src/Application.php
Application.bootstrap
public function bootstrap() { $event = $this->getEvent(); $event->setType(self::EVENT_BOOTSTRAP); $this->events()->fire($event); return $this; }
php
public function bootstrap() { $event = $this->getEvent(); $event->setType(self::EVENT_BOOTSTRAP); $this->events()->fire($event); return $this; }
[ "public", "function", "bootstrap", "(", ")", "{", "$", "event", "=", "$", "this", "->", "getEvent", "(", ")", ";", "$", "event", "->", "setType", "(", "self", "::", "EVENT_BOOTSTRAP", ")", ";", "$", "this", "->", "events", "(", ")", "->", "fire", "...
Bootstrap the application by firing EVENT_BOOTSTRAP. Certain services are expected to exist After bootstrapping. If you override the default plugins you are required to ensure they exist. There are no safety checks! The following is a list of expected services: - Dispatcher - PackageManager - Router - ViewManager @return $this
[ "Bootstrap", "the", "application", "by", "firing", "EVENT_BOOTSTRAP", ".", "Certain", "services", "are", "expected", "to", "exist", "After", "bootstrapping", ".", "If", "you", "override", "the", "default", "plugins", "you", "are", "required", "to", "ensure", "th...
fffcec2f23e410140d6c85210f429398a868e5ec
https://github.com/spiffyjr/spiffy-framework/blob/fffcec2f23e410140d6c85210f429398a868e5ec/src/Application.php#L75-L82
train
ethical-jobs/ethical-jobs-foundation-php
src/Utils/Timestamp.php
Timestamp.toMilliseconds
public static function toMilliseconds($value = null) { if (! $value) { return null; } if (! $value instanceof Carbon) { $value = Carbon::parse($value); // attempt to parse it } return (int) $value->timestamp * 1000; }
php
public static function toMilliseconds($value = null) { if (! $value) { return null; } if (! $value instanceof Carbon) { $value = Carbon::parse($value); // attempt to parse it } return (int) $value->timestamp * 1000; }
[ "public", "static", "function", "toMilliseconds", "(", "$", "value", "=", "null", ")", "{", "if", "(", "!", "$", "value", ")", "{", "return", "null", ";", "}", "if", "(", "!", "$", "value", "instanceof", "Carbon", ")", "{", "$", "value", "=", "Carb...
Converts carbon instance to milliseconds @param PHP unix timestamp (seconds) $timestamp
[ "Converts", "carbon", "instance", "to", "milliseconds" ]
35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8
https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Utils/Timestamp.php#L20-L31
train
ethical-jobs/ethical-jobs-foundation-php
src/Utils/Timestamp.php
Timestamp.fromMilliseconds
public static function fromMilliseconds($timestamp = null) { if (! $timestamp) { return null; } return Carbon::createFromTimestamp(self::toSeconds($timestamp)); }
php
public static function fromMilliseconds($timestamp = null) { if (! $timestamp) { return null; } return Carbon::createFromTimestamp(self::toSeconds($timestamp)); }
[ "public", "static", "function", "fromMilliseconds", "(", "$", "timestamp", "=", "null", ")", "{", "if", "(", "!", "$", "timestamp", ")", "{", "return", "null", ";", "}", "return", "Carbon", "::", "createFromTimestamp", "(", "self", "::", "toSeconds", "(", ...
Converts timestamp to carbon instance @param Carbon\Carbon $timestamp
[ "Converts", "timestamp", "to", "carbon", "instance" ]
35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8
https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Utils/Timestamp.php#L38-L45
train