id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
234,700
phpmath/bignumber
src/BigNumber.php
BigNumber.pow
public function pow($value) { if (!is_int($value) && !ctype_digit($value)) { throw new InvalidArgumentException(sprintf( 'Invalid exponent "%s" provided. Only integers are allowed.', $value )); } $newValue = bcpow($this->getValue(), $value, $this->getScale()); return $this->assignValue($newValue); }
php
public function pow($value) { if (!is_int($value) && !ctype_digit($value)) { throw new InvalidArgumentException(sprintf( 'Invalid exponent "%s" provided. Only integers are allowed.', $value )); } $newValue = bcpow($this->getValue(), $value, $this->getScale()); return $this->assignValue($newValue); }
[ "public", "function", "pow", "(", "$", "value", ")", "{", "if", "(", "!", "is_int", "(", "$", "value", ")", "&&", "!", "ctype_digit", "(", "$", "value", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid exponent \"%s\" provided. Only integers are allowed.'", ",", "$", "value", ")", ")", ";", "}", "$", "newValue", "=", "bcpow", "(", "$", "this", "->", "getValue", "(", ")", ",", "$", "value", ",", "$", "this", "->", "getScale", "(", ")", ")", ";", "return", "$", "this", "->", "assignValue", "(", "$", "newValue", ")", ";", "}" ]
Performs a power operation with the given number. @param int|string $value The value to perform a power operation with. Should be an integer (or an int-string). @return BigNumber
[ "Performs", "a", "power", "operation", "with", "the", "given", "number", "." ]
9d8343a535a66e1e61362abf71ca26133222fe9a
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L207-L219
234,701
phpmath/bignumber
src/BigNumber.php
BigNumber.sqrt
public function sqrt() { $newValue = bcsqrt($this->getValue(), $this->getScale()); return $this->assignValue($newValue); }
php
public function sqrt() { $newValue = bcsqrt($this->getValue(), $this->getScale()); return $this->assignValue($newValue); }
[ "public", "function", "sqrt", "(", ")", "{", "$", "newValue", "=", "bcsqrt", "(", "$", "this", "->", "getValue", "(", ")", ",", "$", "this", "->", "getScale", "(", ")", ")", ";", "return", "$", "this", "->", "assignValue", "(", "$", "newValue", ")", ";", "}" ]
Performs a square root operation with the given number. @return BigNumber
[ "Performs", "a", "square", "root", "operation", "with", "the", "given", "number", "." ]
9d8343a535a66e1e61362abf71ca26133222fe9a
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L226-L231
234,702
phpmath/bignumber
src/BigNumber.php
BigNumber.subtract
public function subtract($value) { if (!$value instanceof self) { $value = new self($value, $this->getScale(), false); } $newValue = bcsub($this->getValue(), $value->getValue(), $this->getScale()); return $this->assignValue($newValue); }
php
public function subtract($value) { if (!$value instanceof self) { $value = new self($value, $this->getScale(), false); } $newValue = bcsub($this->getValue(), $value->getValue(), $this->getScale()); return $this->assignValue($newValue); }
[ "public", "function", "subtract", "(", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "self", ")", "{", "$", "value", "=", "new", "self", "(", "$", "value", ",", "$", "this", "->", "getScale", "(", ")", ",", "false", ")", ";", "}", "$", "newValue", "=", "bcsub", "(", "$", "this", "->", "getValue", "(", ")", ",", "$", "value", "->", "getValue", "(", ")", ",", "$", "this", "->", "getScale", "(", ")", ")", ";", "return", "$", "this", "->", "assignValue", "(", "$", "newValue", ")", ";", "}" ]
Subtracts the given value from this value. @param float|int|string|BigNumber $value The value to subtract. @return BigNumber
[ "Subtracts", "the", "given", "value", "from", "this", "value", "." ]
9d8343a535a66e1e61362abf71ca26133222fe9a
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L239-L248
234,703
phpmath/bignumber
src/BigNumber.php
BigNumber.assignValue
private function assignValue($value) { if ($this->isMutable()) { $result = $this->internalSetValue($value); } else { $result = new BigNumber($value, $this->getScale(), false); } return $result; }
php
private function assignValue($value) { if ($this->isMutable()) { $result = $this->internalSetValue($value); } else { $result = new BigNumber($value, $this->getScale(), false); } return $result; }
[ "private", "function", "assignValue", "(", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isMutable", "(", ")", ")", "{", "$", "result", "=", "$", "this", "->", "internalSetValue", "(", "$", "value", ")", ";", "}", "else", "{", "$", "result", "=", "new", "BigNumber", "(", "$", "value", ",", "$", "this", "->", "getScale", "(", ")", ",", "false", ")", ";", "}", "return", "$", "result", ";", "}" ]
A helper method to assign the given value. @param int|string|BigNumber $value The value to assign. @return BigNumber
[ "A", "helper", "method", "to", "assign", "the", "given", "value", "." ]
9d8343a535a66e1e61362abf71ca26133222fe9a
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L286-L295
234,704
phpmath/bignumber
src/BigNumber.php
BigNumber.internalSetValue
private function internalSetValue($value) { if (is_float($value)) { $valueToSet = Utils::convertExponentialToString($value); } else { $valueToSet = (string)$value; } if (!is_numeric($valueToSet)) { throw new InvalidArgumentException('Invalid number provided: ' . $valueToSet); } // We use a slick trick to make sure the scale is respected. $this->value = bcadd(0, $valueToSet, $this->getScale()); return $this; }
php
private function internalSetValue($value) { if (is_float($value)) { $valueToSet = Utils::convertExponentialToString($value); } else { $valueToSet = (string)$value; } if (!is_numeric($valueToSet)) { throw new InvalidArgumentException('Invalid number provided: ' . $valueToSet); } // We use a slick trick to make sure the scale is respected. $this->value = bcadd(0, $valueToSet, $this->getScale()); return $this; }
[ "private", "function", "internalSetValue", "(", "$", "value", ")", "{", "if", "(", "is_float", "(", "$", "value", ")", ")", "{", "$", "valueToSet", "=", "Utils", "::", "convertExponentialToString", "(", "$", "value", ")", ";", "}", "else", "{", "$", "valueToSet", "=", "(", "string", ")", "$", "value", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "valueToSet", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid number provided: '", ".", "$", "valueToSet", ")", ";", "}", "// We use a slick trick to make sure the scale is respected.", "$", "this", "->", "value", "=", "bcadd", "(", "0", ",", "$", "valueToSet", ",", "$", "this", "->", "getScale", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
A helper method to set the value on this class. @param int|string|BigNumber $value The value to assign. @return BigNumber
[ "A", "helper", "method", "to", "set", "the", "value", "on", "this", "class", "." ]
9d8343a535a66e1e61362abf71ca26133222fe9a
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L303-L319
234,705
oxygen-cms/core
src/Form/FieldMetadata.php
FieldMetadata.getType
public function getType() { if($this->typeInstance !== null) { return $this->typeInstance; } if(isset(static::$types[$this->type])) { $this->typeInstance = static::$types[$this->type]; return static::$types[$this->type]; } else { if(static::$defaultType !== null) { $this->typeInstance = static::$defaultType; return static::$defaultType; } else { throw new Exception('No `FieldType` Object Set For Field Type "' . $this->type . '" And No Default Set'); } } }
php
public function getType() { if($this->typeInstance !== null) { return $this->typeInstance; } if(isset(static::$types[$this->type])) { $this->typeInstance = static::$types[$this->type]; return static::$types[$this->type]; } else { if(static::$defaultType !== null) { $this->typeInstance = static::$defaultType; return static::$defaultType; } else { throw new Exception('No `FieldType` Object Set For Field Type "' . $this->type . '" And No Default Set'); } } }
[ "public", "function", "getType", "(", ")", "{", "if", "(", "$", "this", "->", "typeInstance", "!==", "null", ")", "{", "return", "$", "this", "->", "typeInstance", ";", "}", "if", "(", "isset", "(", "static", "::", "$", "types", "[", "$", "this", "->", "type", "]", ")", ")", "{", "$", "this", "->", "typeInstance", "=", "static", "::", "$", "types", "[", "$", "this", "->", "type", "]", ";", "return", "static", "::", "$", "types", "[", "$", "this", "->", "type", "]", ";", "}", "else", "{", "if", "(", "static", "::", "$", "defaultType", "!==", "null", ")", "{", "$", "this", "->", "typeInstance", "=", "static", "::", "$", "defaultType", ";", "return", "static", "::", "$", "defaultType", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'No `FieldType` Object Set For Field Type \"'", ".", "$", "this", "->", "type", ".", "'\" And No Default Set'", ")", ";", "}", "}", "}" ]
Returns the type. @return FieldType @throws Exception if the type doesn't exist
[ "Returns", "the", "type", "." ]
8f8349c669771d9a7a719a7b120821e06cb5a20b
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Form/FieldMetadata.php#L144-L162
234,706
oxygen-cms/core
src/Console/BlueprintDetailCommand.php
BlueprintDetailCommand.getActionInformation
protected function getActionInformation(Action $action) { return [ $action->getPattern(), $action->getName(), $action->getMethod(), $action->group->getName() . ', ' . $action->group->getPattern(), Formatter::shortArray($action->getMiddleware()), $action->getUses(), Formatter::boolean($action->register), Formatter::boolean($action->useSmoothState) ]; }
php
protected function getActionInformation(Action $action) { return [ $action->getPattern(), $action->getName(), $action->getMethod(), $action->group->getName() . ', ' . $action->group->getPattern(), Formatter::shortArray($action->getMiddleware()), $action->getUses(), Formatter::boolean($action->register), Formatter::boolean($action->useSmoothState) ]; }
[ "protected", "function", "getActionInformation", "(", "Action", "$", "action", ")", "{", "return", "[", "$", "action", "->", "getPattern", "(", ")", ",", "$", "action", "->", "getName", "(", ")", ",", "$", "action", "->", "getMethod", "(", ")", ",", "$", "action", "->", "group", "->", "getName", "(", ")", ".", "', '", ".", "$", "action", "->", "group", "->", "getPattern", "(", ")", ",", "Formatter", "::", "shortArray", "(", "$", "action", "->", "getMiddleware", "(", ")", ")", ",", "$", "action", "->", "getUses", "(", ")", ",", "Formatter", "::", "boolean", "(", "$", "action", "->", "register", ")", ",", "Formatter", "::", "boolean", "(", "$", "action", "->", "useSmoothState", ")", "]", ";", "}" ]
Get information about an Action. @param Action $action @return array
[ "Get", "information", "about", "an", "Action", "." ]
8f8349c669771d9a7a719a7b120821e06cb5a20b
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Console/BlueprintDetailCommand.php#L101-L112
234,707
jonnnnyw/craft-awss3assets
src/JonnyW/AWSS3Assets/Validation/RegionValidator.php
RegionValidator.validateAttribute
protected function validateAttribute($object, $attribute) { $value = $object->$attribute; if ($value) { if (!preg_match('/^(us|sa|eu|ap)-(north|south|central)?(east|west)?-[1-9]$/', $value)) { $this->addError($object, $attribute, 'Please enter a valid AWS region e.g us-east-1.'); } } }
php
protected function validateAttribute($object, $attribute) { $value = $object->$attribute; if ($value) { if (!preg_match('/^(us|sa|eu|ap)-(north|south|central)?(east|west)?-[1-9]$/', $value)) { $this->addError($object, $attribute, 'Please enter a valid AWS region e.g us-east-1.'); } } }
[ "protected", "function", "validateAttribute", "(", "$", "object", ",", "$", "attribute", ")", "{", "$", "value", "=", "$", "object", "->", "$", "attribute", ";", "if", "(", "$", "value", ")", "{", "if", "(", "!", "preg_match", "(", "'/^(us|sa|eu|ap)-(north|south|central)?(east|west)?-[1-9]$/'", ",", "$", "value", ")", ")", "{", "$", "this", "->", "addError", "(", "$", "object", ",", "$", "attribute", ",", "'Please enter a valid AWS region e.g us-east-1.'", ")", ";", "}", "}", "}" ]
Validate AWS region. @access protected @param \CModel $object @param string $attribute @return void
[ "Validate", "AWS", "region", "." ]
6bc146a8f3496f148c28d431cd8a9e7dc8199a9d
https://github.com/jonnnnyw/craft-awss3assets/blob/6bc146a8f3496f148c28d431cd8a9e7dc8199a9d/src/JonnyW/AWSS3Assets/Validation/RegionValidator.php#L28-L38
234,708
fingo/laravel-session-fallback
src/SessionFallback.php
SessionFallback.validateCacheHandler
public function validateCacheHandler($driver, $handler) { $store = $handler->getCache()->getStore(); return static::$expectedStores[$driver] !== get_class($store); }
php
public function validateCacheHandler($driver, $handler) { $store = $handler->getCache()->getStore(); return static::$expectedStores[$driver] !== get_class($store); }
[ "public", "function", "validateCacheHandler", "(", "$", "driver", ",", "$", "handler", ")", "{", "$", "store", "=", "$", "handler", "->", "getCache", "(", ")", "->", "getStore", "(", ")", ";", "return", "static", "::", "$", "expectedStores", "[", "$", "driver", "]", "!==", "get_class", "(", "$", "store", ")", ";", "}" ]
Check if session has right store @param $driver @param $handler @return bool
[ "Check", "if", "session", "has", "right", "store" ]
0fb4f9adf33137ca1c1ceee3733fe0f700f598dd
https://github.com/fingo/laravel-session-fallback/blob/0fb4f9adf33137ca1c1ceee3733fe0f700f598dd/src/SessionFallback.php#L114-L118
234,709
accompli/accompli
src/DependencyInjection/ConfigurationServiceRegistrationCompilerPass.php
ConfigurationServiceRegistrationCompilerPass.process
public function process(ContainerBuilder $container) { $configuration = $container->get('configuration', ContainerInterface::NULL_ON_INVALID_REFERENCE); if ($configuration instanceof ConfigurationInterface) { $this->registerService($container, 'deployment_strategy', $configuration->getDeploymentStrategyClass()); $connectionManager = $container->get('connection_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE); if ($connectionManager instanceof ConnectionManagerInterface) { foreach ($configuration->getDeploymentConnectionClasses() as $connectionType => $connectionAdapterClass) { $connectionManager->registerConnectionAdapter($connectionType, $connectionAdapterClass); } } } }
php
public function process(ContainerBuilder $container) { $configuration = $container->get('configuration', ContainerInterface::NULL_ON_INVALID_REFERENCE); if ($configuration instanceof ConfigurationInterface) { $this->registerService($container, 'deployment_strategy', $configuration->getDeploymentStrategyClass()); $connectionManager = $container->get('connection_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE); if ($connectionManager instanceof ConnectionManagerInterface) { foreach ($configuration->getDeploymentConnectionClasses() as $connectionType => $connectionAdapterClass) { $connectionManager->registerConnectionAdapter($connectionType, $connectionAdapterClass); } } } }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "configuration", "=", "$", "container", "->", "get", "(", "'configuration'", ",", "ContainerInterface", "::", "NULL_ON_INVALID_REFERENCE", ")", ";", "if", "(", "$", "configuration", "instanceof", "ConfigurationInterface", ")", "{", "$", "this", "->", "registerService", "(", "$", "container", ",", "'deployment_strategy'", ",", "$", "configuration", "->", "getDeploymentStrategyClass", "(", ")", ")", ";", "$", "connectionManager", "=", "$", "container", "->", "get", "(", "'connection_manager'", ",", "ContainerInterface", "::", "NULL_ON_INVALID_REFERENCE", ")", ";", "if", "(", "$", "connectionManager", "instanceof", "ConnectionManagerInterface", ")", "{", "foreach", "(", "$", "configuration", "->", "getDeploymentConnectionClasses", "(", ")", "as", "$", "connectionType", "=>", "$", "connectionAdapterClass", ")", "{", "$", "connectionManager", "->", "registerConnectionAdapter", "(", "$", "connectionType", ",", "$", "connectionAdapterClass", ")", ";", "}", "}", "}", "}" ]
Adds deployment classes, defined in the configuration service, as services. @param ContainerBuilder $container
[ "Adds", "deployment", "classes", "defined", "in", "the", "configuration", "service", "as", "services", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/DependencyInjection/ConfigurationServiceRegistrationCompilerPass.php#L23-L36
234,710
accompli/accompli
src/DependencyInjection/ConfigurationServiceRegistrationCompilerPass.php
ConfigurationServiceRegistrationCompilerPass.registerService
private function registerService(ContainerBuilder $container, $serviceId, $serviceClass) { if (class_exists($serviceClass)) { $container->register($serviceId, $serviceClass); } }
php
private function registerService(ContainerBuilder $container, $serviceId, $serviceClass) { if (class_exists($serviceClass)) { $container->register($serviceId, $serviceClass); } }
[ "private", "function", "registerService", "(", "ContainerBuilder", "$", "container", ",", "$", "serviceId", ",", "$", "serviceClass", ")", "{", "if", "(", "class_exists", "(", "$", "serviceClass", ")", ")", "{", "$", "container", "->", "register", "(", "$", "serviceId", ",", "$", "serviceClass", ")", ";", "}", "}" ]
Registers a service with the service container when the class exists. @param ContainerBuilder $container @param string $serviceId @param string $serviceClass
[ "Registers", "a", "service", "with", "the", "service", "container", "when", "the", "class", "exists", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/DependencyInjection/ConfigurationServiceRegistrationCompilerPass.php#L45-L50
234,711
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Catalog/Lists/Standard.php
Standard.rebuildIndex
protected function rebuildIndex( array $prodIds ) { $context = $this->getContext(); $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); $search = $productManager->createSearch(); $search->setConditions( $search->compare( '==', 'product.id', $prodIds ) ); $search->setSlice( 0, count( $prodIds ) ); $indexManager = \Aimeos\MShop\Factory::createManager( $context, 'index' ); $indexManager->rebuildIndex( $productManager->searchItems( $search ) ); }
php
protected function rebuildIndex( array $prodIds ) { $context = $this->getContext(); $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); $search = $productManager->createSearch(); $search->setConditions( $search->compare( '==', 'product.id', $prodIds ) ); $search->setSlice( 0, count( $prodIds ) ); $indexManager = \Aimeos\MShop\Factory::createManager( $context, 'index' ); $indexManager->rebuildIndex( $productManager->searchItems( $search ) ); }
[ "protected", "function", "rebuildIndex", "(", "array", "$", "prodIds", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "productManager", "=", "\\", "Aimeos", "\\", "MShop", "\\", "Factory", "::", "createManager", "(", "$", "context", ",", "'product'", ")", ";", "$", "search", "=", "$", "productManager", "->", "createSearch", "(", ")", ";", "$", "search", "->", "setConditions", "(", "$", "search", "->", "compare", "(", "'=='", ",", "'product.id'", ",", "$", "prodIds", ")", ")", ";", "$", "search", "->", "setSlice", "(", "0", ",", "count", "(", "$", "prodIds", ")", ")", ";", "$", "indexManager", "=", "\\", "Aimeos", "\\", "MShop", "\\", "Factory", "::", "createManager", "(", "$", "context", ",", "'index'", ")", ";", "$", "indexManager", "->", "rebuildIndex", "(", "$", "productManager", "->", "searchItems", "(", "$", "search", ")", ")", ";", "}" ]
Rebuild the index for the given product IDs @param array $prodIds List of product IDs
[ "Rebuild", "the", "index", "for", "the", "given", "product", "IDs" ]
594ee7cec90fd63a4773c05c93f353e66d9b3408
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Catalog/Lists/Standard.php#L205-L216
234,712
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Coupon/Code/Standard.php
Standard.uploadFile
public function uploadFile( \stdClass $params ) { $this->checkParams( $params, array( 'site', 'parentid' ) ); $this->setLocale( $params->site ); if( ( $fileinfo = reset( $_FILES ) ) === false ) { throw new \Aimeos\Controller\ExtJS\Exception( 'No file was uploaded' ); } $config = $this->getContext()->getConfig(); /** controller/extjs/coupon/code/standard/uploaddir * Upload directory for text files that should be imported * * The upload directory must be an absolute path. Avoid a trailing slash * at the end of the upload directory string! * * @param string Absolute path including a leading slash * @since 2014.09 * @category Developer */ $dir = $config->get( 'controller/extjs/coupon/code/standard/uploaddir', 'uploads' ); /** controller/extjs/coupon/code/standard/enablecheck * Enables checking uploaded files if they are valid and not part of an attack * * This configuration option is for unit testing only! Please don't disable * the checks for uploaded files in production environments as this * would give attackers the possibility to infiltrate your installation! * * @param boolean True to enable, false to disable * @since 2014.09 * @category Developer */ if( $config->get( 'controller/extjs/coupon/code/standard/enablecheck', true ) ) { $this->checkFileUpload( $fileinfo['tmp_name'], $fileinfo['error'] ); } $fileext = pathinfo( $fileinfo['name'], PATHINFO_EXTENSION ); $dest = $dir . DIRECTORY_SEPARATOR . md5( $fileinfo['name'] . time() . getmypid() ) . '.' . $fileext; if( rename( $fileinfo['tmp_name'], $dest ) !== true ) { $msg = sprintf( 'Uploaded file could not be moved to upload directory "%1$s"', $dir ); throw new \Aimeos\Controller\ExtJS\Exception( $msg ); } /** controller/extjs/coupon/code/standard/fileperms * File permissions used when storing uploaded files * * The representation of the permissions is in octal notation (using 0-7) * with a leading zero. The first number after the leading zero are the * permissions for the web server creating the directory, the second is * for the primary group of the web server and the last number represents * the permissions for everyone else. * * You should use 0660 or 0600 for the permissions as the web server needs * to manage the files. The group permissions are important if you plan * to upload files directly via FTP or by other means because then the * web server needs to be able to read and manage those files. In this * case use 0660 as permissions, otherwise you can limit them to 0600. * * A more detailed description of the meaning of the Unix file permission * bits can be found in the Wikipedia article about * {@link https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation file system permissions} * * @param integer Octal Unix permission representation * @since 2014.09 * @category Developer */ $perms = $config->get( 'controller/extjs/coupon/code/standard/fileperms', 0660 ); if( chmod( $dest, $perms ) !== true ) { $msg = sprintf( 'Could not set permissions "%1$s" for file "%2$s"', $perms, $dest ); throw new \Aimeos\Controller\ExtJS\Exception( $msg ); } $result = (object) array( 'site' => $params->site, 'items' => array( (object) array( 'job.label' => 'Coupon code import: ' . $fileinfo['name'], 'job.method' => 'Coupon_Code.importFile', 'job.parameter' => array( 'site' => $params->site, 'parentid' => $params->parentid, 'items' => $dest, ), 'job.status' => 1, ), ), ); $jobController = \Aimeos\Controller\ExtJS\Admin\Job\Factory::createController( $this->getContext() ); $jobController->saveItems( $result ); return array( 'items' => $dest, 'success' => true, ); }
php
public function uploadFile( \stdClass $params ) { $this->checkParams( $params, array( 'site', 'parentid' ) ); $this->setLocale( $params->site ); if( ( $fileinfo = reset( $_FILES ) ) === false ) { throw new \Aimeos\Controller\ExtJS\Exception( 'No file was uploaded' ); } $config = $this->getContext()->getConfig(); /** controller/extjs/coupon/code/standard/uploaddir * Upload directory for text files that should be imported * * The upload directory must be an absolute path. Avoid a trailing slash * at the end of the upload directory string! * * @param string Absolute path including a leading slash * @since 2014.09 * @category Developer */ $dir = $config->get( 'controller/extjs/coupon/code/standard/uploaddir', 'uploads' ); /** controller/extjs/coupon/code/standard/enablecheck * Enables checking uploaded files if they are valid and not part of an attack * * This configuration option is for unit testing only! Please don't disable * the checks for uploaded files in production environments as this * would give attackers the possibility to infiltrate your installation! * * @param boolean True to enable, false to disable * @since 2014.09 * @category Developer */ if( $config->get( 'controller/extjs/coupon/code/standard/enablecheck', true ) ) { $this->checkFileUpload( $fileinfo['tmp_name'], $fileinfo['error'] ); } $fileext = pathinfo( $fileinfo['name'], PATHINFO_EXTENSION ); $dest = $dir . DIRECTORY_SEPARATOR . md5( $fileinfo['name'] . time() . getmypid() ) . '.' . $fileext; if( rename( $fileinfo['tmp_name'], $dest ) !== true ) { $msg = sprintf( 'Uploaded file could not be moved to upload directory "%1$s"', $dir ); throw new \Aimeos\Controller\ExtJS\Exception( $msg ); } /** controller/extjs/coupon/code/standard/fileperms * File permissions used when storing uploaded files * * The representation of the permissions is in octal notation (using 0-7) * with a leading zero. The first number after the leading zero are the * permissions for the web server creating the directory, the second is * for the primary group of the web server and the last number represents * the permissions for everyone else. * * You should use 0660 or 0600 for the permissions as the web server needs * to manage the files. The group permissions are important if you plan * to upload files directly via FTP or by other means because then the * web server needs to be able to read and manage those files. In this * case use 0660 as permissions, otherwise you can limit them to 0600. * * A more detailed description of the meaning of the Unix file permission * bits can be found in the Wikipedia article about * {@link https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation file system permissions} * * @param integer Octal Unix permission representation * @since 2014.09 * @category Developer */ $perms = $config->get( 'controller/extjs/coupon/code/standard/fileperms', 0660 ); if( chmod( $dest, $perms ) !== true ) { $msg = sprintf( 'Could not set permissions "%1$s" for file "%2$s"', $perms, $dest ); throw new \Aimeos\Controller\ExtJS\Exception( $msg ); } $result = (object) array( 'site' => $params->site, 'items' => array( (object) array( 'job.label' => 'Coupon code import: ' . $fileinfo['name'], 'job.method' => 'Coupon_Code.importFile', 'job.parameter' => array( 'site' => $params->site, 'parentid' => $params->parentid, 'items' => $dest, ), 'job.status' => 1, ), ), ); $jobController = \Aimeos\Controller\ExtJS\Admin\Job\Factory::createController( $this->getContext() ); $jobController->saveItems( $result ); return array( 'items' => $dest, 'success' => true, ); }
[ "public", "function", "uploadFile", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'site'", ",", "'parentid'", ")", ")", ";", "$", "this", "->", "setLocale", "(", "$", "params", "->", "site", ")", ";", "if", "(", "(", "$", "fileinfo", "=", "reset", "(", "$", "_FILES", ")", ")", "===", "false", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "ExtJS", "\\", "Exception", "(", "'No file was uploaded'", ")", ";", "}", "$", "config", "=", "$", "this", "->", "getContext", "(", ")", "->", "getConfig", "(", ")", ";", "/** controller/extjs/coupon/code/standard/uploaddir\n\t\t * Upload directory for text files that should be imported\n\t\t *\n\t\t * The upload directory must be an absolute path. Avoid a trailing slash\n\t\t * at the end of the upload directory string!\n\t\t *\n\t\t * @param string Absolute path including a leading slash\n\t\t * @since 2014.09\n\t\t * @category Developer\n\t\t */", "$", "dir", "=", "$", "config", "->", "get", "(", "'controller/extjs/coupon/code/standard/uploaddir'", ",", "'uploads'", ")", ";", "/** controller/extjs/coupon/code/standard/enablecheck\n\t\t * Enables checking uploaded files if they are valid and not part of an attack\n\t\t *\n\t\t * This configuration option is for unit testing only! Please don't disable\n\t\t * the checks for uploaded files in production environments as this\n\t\t * would give attackers the possibility to infiltrate your installation!\n\t\t *\n\t\t * @param boolean True to enable, false to disable\n\t\t * @since 2014.09\n\t\t * @category Developer\n\t\t */", "if", "(", "$", "config", "->", "get", "(", "'controller/extjs/coupon/code/standard/enablecheck'", ",", "true", ")", ")", "{", "$", "this", "->", "checkFileUpload", "(", "$", "fileinfo", "[", "'tmp_name'", "]", ",", "$", "fileinfo", "[", "'error'", "]", ")", ";", "}", "$", "fileext", "=", "pathinfo", "(", "$", "fileinfo", "[", "'name'", "]", ",", "PATHINFO_EXTENSION", ")", ";", "$", "dest", "=", "$", "dir", ".", "DIRECTORY_SEPARATOR", ".", "md5", "(", "$", "fileinfo", "[", "'name'", "]", ".", "time", "(", ")", ".", "getmypid", "(", ")", ")", ".", "'.'", ".", "$", "fileext", ";", "if", "(", "rename", "(", "$", "fileinfo", "[", "'tmp_name'", "]", ",", "$", "dest", ")", "!==", "true", ")", "{", "$", "msg", "=", "sprintf", "(", "'Uploaded file could not be moved to upload directory \"%1$s\"'", ",", "$", "dir", ")", ";", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "ExtJS", "\\", "Exception", "(", "$", "msg", ")", ";", "}", "/** controller/extjs/coupon/code/standard/fileperms\n\t\t * File permissions used when storing uploaded files\n\t\t *\n\t\t * The representation of the permissions is in octal notation (using 0-7)\n\t\t * with a leading zero. The first number after the leading zero are the\n\t\t * permissions for the web server creating the directory, the second is\n\t\t * for the primary group of the web server and the last number represents\n\t\t * the permissions for everyone else.\n\t\t *\n\t\t * You should use 0660 or 0600 for the permissions as the web server needs\n\t\t * to manage the files. The group permissions are important if you plan\n\t\t * to upload files directly via FTP or by other means because then the\n\t\t * web server needs to be able to read and manage those files. In this\n\t\t * case use 0660 as permissions, otherwise you can limit them to 0600.\n\t\t *\n\t\t * A more detailed description of the meaning of the Unix file permission\n\t\t * bits can be found in the Wikipedia article about\n\t\t * {@link https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation file system permissions}\n\t\t *\n\t\t * @param integer Octal Unix permission representation\n\t\t * @since 2014.09\n\t\t * @category Developer\n\t\t */", "$", "perms", "=", "$", "config", "->", "get", "(", "'controller/extjs/coupon/code/standard/fileperms'", ",", "0660", ")", ";", "if", "(", "chmod", "(", "$", "dest", ",", "$", "perms", ")", "!==", "true", ")", "{", "$", "msg", "=", "sprintf", "(", "'Could not set permissions \"%1$s\" for file \"%2$s\"'", ",", "$", "perms", ",", "$", "dest", ")", ";", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "ExtJS", "\\", "Exception", "(", "$", "msg", ")", ";", "}", "$", "result", "=", "(", "object", ")", "array", "(", "'site'", "=>", "$", "params", "->", "site", ",", "'items'", "=>", "array", "(", "(", "object", ")", "array", "(", "'job.label'", "=>", "'Coupon code import: '", ".", "$", "fileinfo", "[", "'name'", "]", ",", "'job.method'", "=>", "'Coupon_Code.importFile'", ",", "'job.parameter'", "=>", "array", "(", "'site'", "=>", "$", "params", "->", "site", ",", "'parentid'", "=>", "$", "params", "->", "parentid", ",", "'items'", "=>", "$", "dest", ",", ")", ",", "'job.status'", "=>", "1", ",", ")", ",", ")", ",", ")", ";", "$", "jobController", "=", "\\", "Aimeos", "\\", "Controller", "\\", "ExtJS", "\\", "Admin", "\\", "Job", "\\", "Factory", "::", "createController", "(", "$", "this", "->", "getContext", "(", ")", ")", ";", "$", "jobController", "->", "saveItems", "(", "$", "result", ")", ";", "return", "array", "(", "'items'", "=>", "$", "dest", ",", "'success'", "=>", "true", ",", ")", ";", "}" ]
Uploads a file with coupon codes and meta information. @param \stdClass $params Object containing the properties
[ "Uploads", "a", "file", "with", "coupon", "codes", "and", "meta", "information", "." ]
594ee7cec90fd63a4773c05c93f353e66d9b3408
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Coupon/Code/Standard.php#L44-L144
234,713
jonnnnyw/craft-awss3assets
AWSS3AssetsPlugin.php
AWSS3AssetsPlugin.onBeforeInstall
public function onBeforeInstall() { if (!class_exists('\JonnyW\AWSS3Assets\S3Bucket')) { $autoload = realpath(dirname(__FILE__)) . '/../../../vendor/autoload.php'; throw new CraftException( Craft::t('AWSS3AssetsPlugin could not locate an autoload file in {path}.', array('path' => $autoload)) ); } }
php
public function onBeforeInstall() { if (!class_exists('\JonnyW\AWSS3Assets\S3Bucket')) { $autoload = realpath(dirname(__FILE__)) . '/../../../vendor/autoload.php'; throw new CraftException( Craft::t('AWSS3AssetsPlugin could not locate an autoload file in {path}.', array('path' => $autoload)) ); } }
[ "public", "function", "onBeforeInstall", "(", ")", "{", "if", "(", "!", "class_exists", "(", "'\\JonnyW\\AWSS3Assets\\S3Bucket'", ")", ")", "{", "$", "autoload", "=", "realpath", "(", "dirname", "(", "__FILE__", ")", ")", ".", "'/../../../vendor/autoload.php'", ";", "throw", "new", "CraftException", "(", "Craft", "::", "t", "(", "'AWSS3AssetsPlugin could not locate an autoload file in {path}.'", ",", "array", "(", "'path'", "=>", "$", "autoload", ")", ")", ")", ";", "}", "}" ]
On before install @access public @return void @throws \Craft\CraftException
[ "On", "before", "install" ]
6bc146a8f3496f148c28d431cd8a9e7dc8199a9d
https://github.com/jonnnnyw/craft-awss3assets/blob/6bc146a8f3496f148c28d431cd8a9e7dc8199a9d/AWSS3AssetsPlugin.php#L111-L121
234,714
jonnnnyw/craft-awss3assets
AWSS3AssetsPlugin.php
AWSS3AssetsPlugin.init
public function init() { craft()->on('assets.onSaveAsset', function (Event $event) { $this->copyAsset($event->params['asset']); }); craft()->on('assets.onReplaceFile', function (Event $event) { $this->copyAsset($event->params['asset']); }); craft()->on('assets.onBeforeDeleteAsset', function (Event $event) { $this->deleteAsset($event->params['asset']); }); }
php
public function init() { craft()->on('assets.onSaveAsset', function (Event $event) { $this->copyAsset($event->params['asset']); }); craft()->on('assets.onReplaceFile', function (Event $event) { $this->copyAsset($event->params['asset']); }); craft()->on('assets.onBeforeDeleteAsset', function (Event $event) { $this->deleteAsset($event->params['asset']); }); }
[ "public", "function", "init", "(", ")", "{", "craft", "(", ")", "->", "on", "(", "'assets.onSaveAsset'", ",", "function", "(", "Event", "$", "event", ")", "{", "$", "this", "->", "copyAsset", "(", "$", "event", "->", "params", "[", "'asset'", "]", ")", ";", "}", ")", ";", "craft", "(", ")", "->", "on", "(", "'assets.onReplaceFile'", ",", "function", "(", "Event", "$", "event", ")", "{", "$", "this", "->", "copyAsset", "(", "$", "event", "->", "params", "[", "'asset'", "]", ")", ";", "}", ")", ";", "craft", "(", ")", "->", "on", "(", "'assets.onBeforeDeleteAsset'", ",", "function", "(", "Event", "$", "event", ")", "{", "$", "this", "->", "deleteAsset", "(", "$", "event", "->", "params", "[", "'asset'", "]", ")", ";", "}", ")", ";", "}" ]
Initialize plugin. @access public @return void
[ "Initialize", "plugin", "." ]
6bc146a8f3496f148c28d431cd8a9e7dc8199a9d
https://github.com/jonnnnyw/craft-awss3assets/blob/6bc146a8f3496f148c28d431cd8a9e7dc8199a9d/AWSS3AssetsPlugin.php#L129-L142
234,715
jonnnnyw/craft-awss3assets
AWSS3AssetsPlugin.php
AWSS3AssetsPlugin.getS3Bucket
private function getS3Bucket() { $settings = $this->getSettings(); $bucket = S3Bucket::getInstance( $settings->bucketRegion, $settings->bucketName, $settings->awsKey, $settings->awsSecret ); return $bucket; }
php
private function getS3Bucket() { $settings = $this->getSettings(); $bucket = S3Bucket::getInstance( $settings->bucketRegion, $settings->bucketName, $settings->awsKey, $settings->awsSecret ); return $bucket; }
[ "private", "function", "getS3Bucket", "(", ")", "{", "$", "settings", "=", "$", "this", "->", "getSettings", "(", ")", ";", "$", "bucket", "=", "S3Bucket", "::", "getInstance", "(", "$", "settings", "->", "bucketRegion", ",", "$", "settings", "->", "bucketName", ",", "$", "settings", "->", "awsKey", ",", "$", "settings", "->", "awsSecret", ")", ";", "return", "$", "bucket", ";", "}" ]
Get S3 Bucket instance. @access private @return \JonnyW\AWSS3Assets\S3Bucket
[ "Get", "S3", "Bucket", "instance", "." ]
6bc146a8f3496f148c28d431cd8a9e7dc8199a9d
https://github.com/jonnnnyw/craft-awss3assets/blob/6bc146a8f3496f148c28d431cd8a9e7dc8199a9d/AWSS3AssetsPlugin.php#L175-L187
234,716
jonnnnyw/craft-awss3assets
AWSS3AssetsPlugin.php
AWSS3AssetsPlugin.copyAsset
public function copyAsset(AssetFileModel $asset) { $settings = $this->getSettings(); try { $this->getS3Bucket()->cp($this->getAssetPath($asset), trim($settings->bucketPath . '/' . $asset->filename, '/')); } catch (\Exception $e) { throw new CraftException($e->getMessage()); } }
php
public function copyAsset(AssetFileModel $asset) { $settings = $this->getSettings(); try { $this->getS3Bucket()->cp($this->getAssetPath($asset), trim($settings->bucketPath . '/' . $asset->filename, '/')); } catch (\Exception $e) { throw new CraftException($e->getMessage()); } }
[ "public", "function", "copyAsset", "(", "AssetFileModel", "$", "asset", ")", "{", "$", "settings", "=", "$", "this", "->", "getSettings", "(", ")", ";", "try", "{", "$", "this", "->", "getS3Bucket", "(", ")", "->", "cp", "(", "$", "this", "->", "getAssetPath", "(", "$", "asset", ")", ",", "trim", "(", "$", "settings", "->", "bucketPath", ".", "'/'", ".", "$", "asset", "->", "filename", ",", "'/'", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "CraftException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Copy asset to bucket. @access public @param \Craft\AssetFileModel $asset @return void @throws \Craft\Exception
[ "Copy", "asset", "to", "bucket", "." ]
6bc146a8f3496f148c28d431cd8a9e7dc8199a9d
https://github.com/jonnnnyw/craft-awss3assets/blob/6bc146a8f3496f148c28d431cd8a9e7dc8199a9d/AWSS3AssetsPlugin.php#L197-L206
234,717
jonnnnyw/craft-awss3assets
AWSS3AssetsPlugin.php
AWSS3AssetsPlugin.deleteAsset
public function deleteAsset(AssetFileModel $asset) { $settings = $this->getSettings(); try { $this->getS3Bucket()->rm(trim($settings->bucketPath . '/' . $asset->filename, '/')); } catch (\Exception $e) { throw new CraftException($e->getMessage()); } }
php
public function deleteAsset(AssetFileModel $asset) { $settings = $this->getSettings(); try { $this->getS3Bucket()->rm(trim($settings->bucketPath . '/' . $asset->filename, '/')); } catch (\Exception $e) { throw new CraftException($e->getMessage()); } }
[ "public", "function", "deleteAsset", "(", "AssetFileModel", "$", "asset", ")", "{", "$", "settings", "=", "$", "this", "->", "getSettings", "(", ")", ";", "try", "{", "$", "this", "->", "getS3Bucket", "(", ")", "->", "rm", "(", "trim", "(", "$", "settings", "->", "bucketPath", ".", "'/'", ".", "$", "asset", "->", "filename", ",", "'/'", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "CraftException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Delete asset from bucket. @access public @param \Craft\AssetFileModel $asset @return void @throws \Craft\Exception
[ "Delete", "asset", "from", "bucket", "." ]
6bc146a8f3496f148c28d431cd8a9e7dc8199a9d
https://github.com/jonnnnyw/craft-awss3assets/blob/6bc146a8f3496f148c28d431cd8a9e7dc8199a9d/AWSS3AssetsPlugin.php#L216-L225
234,718
accompli/accompli
src/Task/YamlConfigurationTask.php
YamlConfigurationTask.onInstallReleaseCreateOrUpdateConfiguration
public function onInstallReleaseCreateOrUpdateConfiguration(InstallReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher) { $release = $event->getRelease(); $this->gatherEnvironmentVariables($release); $connection = $this->ensureConnection($release->getWorkspace()->getHost()); $configurationFile = $release->getPath().$this->configurationFile; $configurationDistributionFile = $configurationFile.'.dist'; $context = array('action' => 'Creating', 'configurationFile' => $configurationFile, 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS); if ($connection->isFile($configurationFile)) { $context['action'] = 'Updating'; } $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, '{action} configuration file "{configurationFile}"...', $eventName, $this, $context)); $yamlConfiguration = $this->getYamlConfiguration($connection, $release->getWorkspace()->getHost()->getStage(), $configurationFile, $configurationDistributionFile); if ($connection->putContents($configurationFile, $yamlConfiguration)) { $context['event.task.action'] = TaskInterface::ACTION_COMPLETED; if ($context['action'] === 'Creating') { $context['action'] = 'Created'; } else { $context['action'] = 'Updated'; } $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, '{action} configuration file "{configurationFile}".', $eventName, $this, $context)); } else { $context['event.task.action'] = TaskInterface::ACTION_FAILED; $context['action'] = strtolower($context['action']); $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed {action} configuration file "{configurationFile}".', $eventName, $this, $context)); } }
php
public function onInstallReleaseCreateOrUpdateConfiguration(InstallReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher) { $release = $event->getRelease(); $this->gatherEnvironmentVariables($release); $connection = $this->ensureConnection($release->getWorkspace()->getHost()); $configurationFile = $release->getPath().$this->configurationFile; $configurationDistributionFile = $configurationFile.'.dist'; $context = array('action' => 'Creating', 'configurationFile' => $configurationFile, 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS); if ($connection->isFile($configurationFile)) { $context['action'] = 'Updating'; } $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, '{action} configuration file "{configurationFile}"...', $eventName, $this, $context)); $yamlConfiguration = $this->getYamlConfiguration($connection, $release->getWorkspace()->getHost()->getStage(), $configurationFile, $configurationDistributionFile); if ($connection->putContents($configurationFile, $yamlConfiguration)) { $context['event.task.action'] = TaskInterface::ACTION_COMPLETED; if ($context['action'] === 'Creating') { $context['action'] = 'Created'; } else { $context['action'] = 'Updated'; } $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, '{action} configuration file "{configurationFile}".', $eventName, $this, $context)); } else { $context['event.task.action'] = TaskInterface::ACTION_FAILED; $context['action'] = strtolower($context['action']); $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed {action} configuration file "{configurationFile}".', $eventName, $this, $context)); } }
[ "public", "function", "onInstallReleaseCreateOrUpdateConfiguration", "(", "InstallReleaseEvent", "$", "event", ",", "$", "eventName", ",", "EventDispatcherInterface", "$", "eventDispatcher", ")", "{", "$", "release", "=", "$", "event", "->", "getRelease", "(", ")", ";", "$", "this", "->", "gatherEnvironmentVariables", "(", "$", "release", ")", ";", "$", "connection", "=", "$", "this", "->", "ensureConnection", "(", "$", "release", "->", "getWorkspace", "(", ")", "->", "getHost", "(", ")", ")", ";", "$", "configurationFile", "=", "$", "release", "->", "getPath", "(", ")", ".", "$", "this", "->", "configurationFile", ";", "$", "configurationDistributionFile", "=", "$", "configurationFile", ".", "'.dist'", ";", "$", "context", "=", "array", "(", "'action'", "=>", "'Creating'", ",", "'configurationFile'", "=>", "$", "configurationFile", ",", "'event.task.action'", "=>", "TaskInterface", "::", "ACTION_IN_PROGRESS", ")", ";", "if", "(", "$", "connection", "->", "isFile", "(", "$", "configurationFile", ")", ")", "{", "$", "context", "[", "'action'", "]", "=", "'Updating'", ";", "}", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "NOTICE", ",", "'{action} configuration file \"{configurationFile}\"...'", ",", "$", "eventName", ",", "$", "this", ",", "$", "context", ")", ")", ";", "$", "yamlConfiguration", "=", "$", "this", "->", "getYamlConfiguration", "(", "$", "connection", ",", "$", "release", "->", "getWorkspace", "(", ")", "->", "getHost", "(", ")", "->", "getStage", "(", ")", ",", "$", "configurationFile", ",", "$", "configurationDistributionFile", ")", ";", "if", "(", "$", "connection", "->", "putContents", "(", "$", "configurationFile", ",", "$", "yamlConfiguration", ")", ")", "{", "$", "context", "[", "'event.task.action'", "]", "=", "TaskInterface", "::", "ACTION_COMPLETED", ";", "if", "(", "$", "context", "[", "'action'", "]", "===", "'Creating'", ")", "{", "$", "context", "[", "'action'", "]", "=", "'Created'", ";", "}", "else", "{", "$", "context", "[", "'action'", "]", "=", "'Updated'", ";", "}", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "NOTICE", ",", "'{action} configuration file \"{configurationFile}\".'", ",", "$", "eventName", ",", "$", "this", ",", "$", "context", ")", ")", ";", "}", "else", "{", "$", "context", "[", "'event.task.action'", "]", "=", "TaskInterface", "::", "ACTION_FAILED", ";", "$", "context", "[", "'action'", "]", "=", "strtolower", "(", "$", "context", "[", "'action'", "]", ")", ";", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "WARNING", ",", "'Failed {action} configuration file \"{configurationFile}\".'", ",", "$", "eventName", ",", "$", "this", ",", "$", "context", ")", ")", ";", "}", "}" ]
Saves a YAML configuration file to a path within the release. @param InstallReleaseEvent $event @param string $eventName @param EventDispatcherInterface $eventDispatcher
[ "Saves", "a", "YAML", "configuration", "file", "to", "a", "path", "within", "the", "release", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/YamlConfigurationTask.php#L91-L124
234,719
accompli/accompli
src/Task/YamlConfigurationTask.php
YamlConfigurationTask.gatherEnvironmentVariables
private function gatherEnvironmentVariables(Release $release) { $this->environmentVariables = array( '%stage%' => $release->getWorkspace()->getHost()->getStage(), '%version%' => $release->getVersion(), ); }
php
private function gatherEnvironmentVariables(Release $release) { $this->environmentVariables = array( '%stage%' => $release->getWorkspace()->getHost()->getStage(), '%version%' => $release->getVersion(), ); }
[ "private", "function", "gatherEnvironmentVariables", "(", "Release", "$", "release", ")", "{", "$", "this", "->", "environmentVariables", "=", "array", "(", "'%stage%'", "=>", "$", "release", "->", "getWorkspace", "(", ")", "->", "getHost", "(", ")", "->", "getStage", "(", ")", ",", "'%version%'", "=>", "$", "release", "->", "getVersion", "(", ")", ",", ")", ";", "}" ]
Gathers environment variables to use in the YAML configuration. @param Release $release
[ "Gathers", "environment", "variables", "to", "use", "in", "the", "YAML", "configuration", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/YamlConfigurationTask.php#L131-L137
234,720
accompli/accompli
src/Task/YamlConfigurationTask.php
YamlConfigurationTask.getYamlConfiguration
private function getYamlConfiguration(ConnectionAdapterInterface $connection, $stage, $configurationFile, $configurationDistributionFile) { $configuration = array(); if ($connection->isFile($configurationFile)) { $configuration = Yaml::parse($connection->getContents($configurationFile)); } $distributionConfiguration = array(); if ($connection->isFile($configurationDistributionFile)) { $distributionConfiguration = Yaml::parse($connection->getContents($configurationDistributionFile)); } $stageSpecificConfiguration = array(); if (isset($this->stageSpecificConfigurations[$stage])) { $stageSpecificConfiguration = $this->stageSpecificConfigurations[$stage]; } $configuration = array_replace_recursive($distributionConfiguration, $configuration, $this->configuration, $stageSpecificConfiguration); foreach ($this->generateValueForParameters as $generateValueForParameter) { $this->findKeyAndGenerateValue($configuration, explode('.', $generateValueForParameter)); } $configuration = $this->addEnvironmentVariables($configuration); return Yaml::dump($configuration); }
php
private function getYamlConfiguration(ConnectionAdapterInterface $connection, $stage, $configurationFile, $configurationDistributionFile) { $configuration = array(); if ($connection->isFile($configurationFile)) { $configuration = Yaml::parse($connection->getContents($configurationFile)); } $distributionConfiguration = array(); if ($connection->isFile($configurationDistributionFile)) { $distributionConfiguration = Yaml::parse($connection->getContents($configurationDistributionFile)); } $stageSpecificConfiguration = array(); if (isset($this->stageSpecificConfigurations[$stage])) { $stageSpecificConfiguration = $this->stageSpecificConfigurations[$stage]; } $configuration = array_replace_recursive($distributionConfiguration, $configuration, $this->configuration, $stageSpecificConfiguration); foreach ($this->generateValueForParameters as $generateValueForParameter) { $this->findKeyAndGenerateValue($configuration, explode('.', $generateValueForParameter)); } $configuration = $this->addEnvironmentVariables($configuration); return Yaml::dump($configuration); }
[ "private", "function", "getYamlConfiguration", "(", "ConnectionAdapterInterface", "$", "connection", ",", "$", "stage", ",", "$", "configurationFile", ",", "$", "configurationDistributionFile", ")", "{", "$", "configuration", "=", "array", "(", ")", ";", "if", "(", "$", "connection", "->", "isFile", "(", "$", "configurationFile", ")", ")", "{", "$", "configuration", "=", "Yaml", "::", "parse", "(", "$", "connection", "->", "getContents", "(", "$", "configurationFile", ")", ")", ";", "}", "$", "distributionConfiguration", "=", "array", "(", ")", ";", "if", "(", "$", "connection", "->", "isFile", "(", "$", "configurationDistributionFile", ")", ")", "{", "$", "distributionConfiguration", "=", "Yaml", "::", "parse", "(", "$", "connection", "->", "getContents", "(", "$", "configurationDistributionFile", ")", ")", ";", "}", "$", "stageSpecificConfiguration", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "stageSpecificConfigurations", "[", "$", "stage", "]", ")", ")", "{", "$", "stageSpecificConfiguration", "=", "$", "this", "->", "stageSpecificConfigurations", "[", "$", "stage", "]", ";", "}", "$", "configuration", "=", "array_replace_recursive", "(", "$", "distributionConfiguration", ",", "$", "configuration", ",", "$", "this", "->", "configuration", ",", "$", "stageSpecificConfiguration", ")", ";", "foreach", "(", "$", "this", "->", "generateValueForParameters", "as", "$", "generateValueForParameter", ")", "{", "$", "this", "->", "findKeyAndGenerateValue", "(", "$", "configuration", ",", "explode", "(", "'.'", ",", "$", "generateValueForParameter", ")", ")", ";", "}", "$", "configuration", "=", "$", "this", "->", "addEnvironmentVariables", "(", "$", "configuration", ")", ";", "return", "Yaml", "::", "dump", "(", "$", "configuration", ")", ";", "}" ]
Returns the generated YAML content based on the existing configuration file, distribution configuration file and the configuration configured with this task. @param ConnectionAdapterInterface $connection @param string $stage @param string $configurationFile @param string $configurationDistributionFile @return string
[ "Returns", "the", "generated", "YAML", "content", "based", "on", "the", "existing", "configuration", "file", "distribution", "configuration", "file", "and", "the", "configuration", "configured", "with", "this", "task", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/YamlConfigurationTask.php#L149-L173
234,721
accompli/accompli
src/Task/YamlConfigurationTask.php
YamlConfigurationTask.findKeyAndGenerateValue
private function findKeyAndGenerateValue(array &$configuration, array $parameterParts) { foreach ($configuration as $key => $value) { if ($key === current($parameterParts)) { if (is_array($value) && count($parameterParts) > 1) { array_shift($parameterParts); $this->findKeyAndGenerateValue($value, $parameterParts); $configuration[$key] = $value; } elseif (is_scalar($value)) { $configuration[$key] = sha1(uniqid()); } } } }
php
private function findKeyAndGenerateValue(array &$configuration, array $parameterParts) { foreach ($configuration as $key => $value) { if ($key === current($parameterParts)) { if (is_array($value) && count($parameterParts) > 1) { array_shift($parameterParts); $this->findKeyAndGenerateValue($value, $parameterParts); $configuration[$key] = $value; } elseif (is_scalar($value)) { $configuration[$key] = sha1(uniqid()); } } } }
[ "private", "function", "findKeyAndGenerateValue", "(", "array", "&", "$", "configuration", ",", "array", "$", "parameterParts", ")", "{", "foreach", "(", "$", "configuration", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "===", "current", "(", "$", "parameterParts", ")", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "count", "(", "$", "parameterParts", ")", ">", "1", ")", "{", "array_shift", "(", "$", "parameterParts", ")", ";", "$", "this", "->", "findKeyAndGenerateValue", "(", "$", "value", ",", "$", "parameterParts", ")", ";", "$", "configuration", "[", "$", "key", "]", "=", "$", "value", ";", "}", "elseif", "(", "is_scalar", "(", "$", "value", ")", ")", "{", "$", "configuration", "[", "$", "key", "]", "=", "sha1", "(", "uniqid", "(", ")", ")", ";", "}", "}", "}", "}" ]
Traverses through the configuration array to find the configuration key and generates a unique sha1 hash. @param array $configuration @param array $parameterParts
[ "Traverses", "through", "the", "configuration", "array", "to", "find", "the", "configuration", "key", "and", "generates", "a", "unique", "sha1", "hash", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/YamlConfigurationTask.php#L181-L195
234,722
accompli/accompli
src/Task/YamlConfigurationTask.php
YamlConfigurationTask.addEnvironmentVariables
private function addEnvironmentVariables($value) { if (is_array($value)) { $value = array_map(array($this, __METHOD__), $value); } elseif (is_string($value)) { $value = strtr($value, $this->environmentVariables); } return $value; }
php
private function addEnvironmentVariables($value) { if (is_array($value)) { $value = array_map(array($this, __METHOD__), $value); } elseif (is_string($value)) { $value = strtr($value, $this->environmentVariables); } return $value; }
[ "private", "function", "addEnvironmentVariables", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "array_map", "(", "array", "(", "$", "this", ",", "__METHOD__", ")", ",", "$", "value", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "strtr", "(", "$", "value", ",", "$", "this", "->", "environmentVariables", ")", ";", "}", "return", "$", "value", ";", "}" ]
Adds the environment variables. @param mixed $value @return mixed
[ "Adds", "the", "environment", "variables", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/YamlConfigurationTask.php#L204-L213
234,723
artkonekt/gears
src/UI/Tree.php
Tree.findNode
public function findNode(string $id, $searchChildren = false) { return $this->findByIdAmongChildren($id, $this->nodes(), $searchChildren); }
php
public function findNode(string $id, $searchChildren = false) { return $this->findByIdAmongChildren($id, $this->nodes(), $searchChildren); }
[ "public", "function", "findNode", "(", "string", "$", "id", ",", "$", "searchChildren", "=", "false", ")", "{", "return", "$", "this", "->", "findByIdAmongChildren", "(", "$", "id", ",", "$", "this", "->", "nodes", "(", ")", ",", "$", "searchChildren", ")", ";", "}" ]
Searches a node in the tree and returns it if it was found @param string $id @param bool $searchChildren @return Node|null
[ "Searches", "a", "node", "in", "the", "tree", "and", "returns", "it", "if", "it", "was", "found" ]
6c006a3e8e334d8100aab768a2a5e807bcac5695
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/UI/Tree.php#L50-L53
234,724
potsky/microsoft-translator-php-sdk
src/MicrosoftTranslator/Tools.php
Tools.getArrayDotValue
public static function getArrayDotValue( array $context , $name ) { $pieces = explode( '.' , $name ); foreach ( $pieces as $piece ) { if ( ! is_array( $context ) || ! array_key_exists( $piece , $context ) ) { return null; } $context = $context[ $piece ]; } return $context; }
php
public static function getArrayDotValue( array $context , $name ) { $pieces = explode( '.' , $name ); foreach ( $pieces as $piece ) { if ( ! is_array( $context ) || ! array_key_exists( $piece , $context ) ) { return null; } $context = $context[ $piece ]; } return $context; }
[ "public", "static", "function", "getArrayDotValue", "(", "array", "$", "context", ",", "$", "name", ")", "{", "$", "pieces", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "foreach", "(", "$", "pieces", "as", "$", "piece", ")", "{", "if", "(", "!", "is_array", "(", "$", "context", ")", "||", "!", "array_key_exists", "(", "$", "piece", ",", "$", "context", ")", ")", "{", "return", "null", ";", "}", "$", "context", "=", "$", "context", "[", "$", "piece", "]", ";", "}", "return", "$", "context", ";", "}" ]
Get a key in a multi-dimension array with array dot notation @param array $context the haystack @param string $name the array dot key notation needle @return mixed|null
[ "Get", "a", "key", "in", "a", "multi", "-", "dimension", "array", "with", "array", "dot", "notation" ]
102f2411be5abb0e57a73c475f8e9e185a9f4859
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Tools.php#L135-L148
234,725
beyerz/OpenGraphProtocolBundle
Libraries/OpenGraph.php
OpenGraph.prepareLibraryDefaults
public function prepareLibraryDefaults(){ $libraries = $this->container->getParameter('libraries'); //Initiate Library Classes and load defaults foreach($libraries as $library=>$defaults){ //load class $this->addLibraryClass($library,$defaults[self::FIELD_CLASS]); $this->setLibDefaults($library,$defaults[self::FIELD_DEFAULT_VALUES]); } }
php
public function prepareLibraryDefaults(){ $libraries = $this->container->getParameter('libraries'); //Initiate Library Classes and load defaults foreach($libraries as $library=>$defaults){ //load class $this->addLibraryClass($library,$defaults[self::FIELD_CLASS]); $this->setLibDefaults($library,$defaults[self::FIELD_DEFAULT_VALUES]); } }
[ "public", "function", "prepareLibraryDefaults", "(", ")", "{", "$", "libraries", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'libraries'", ")", ";", "//Initiate Library Classes and load defaults", "foreach", "(", "$", "libraries", "as", "$", "library", "=>", "$", "defaults", ")", "{", "//load class", "$", "this", "->", "addLibraryClass", "(", "$", "library", ",", "$", "defaults", "[", "self", "::", "FIELD_CLASS", "]", ")", ";", "$", "this", "->", "setLibDefaults", "(", "$", "library", ",", "$", "defaults", "[", "self", "::", "FIELD_DEFAULT_VALUES", "]", ")", ";", "}", "}" ]
Load the defined libraries and set the defaults on each of them
[ "Load", "the", "defined", "libraries", "and", "set", "the", "defaults", "on", "each", "of", "them" ]
6f058432895c29055e15ad044c5b7b3bbd3b098a
https://github.com/beyerz/OpenGraphProtocolBundle/blob/6f058432895c29055e15ad044c5b7b3bbd3b098a/Libraries/OpenGraph.php#L26-L34
234,726
makinacorpus/drupal-ucms
ucms_layout/src/EventDispatcher/NodeEventSubscriber.php
NodeEventSubscriber.onInsert
public function onInsert(NodeEvent $event) { $node = $event->getNode(); // When inserting a node, site_id is always the current site context. if ($event->isClone() && $node->site_id) { $exists = (bool)$this ->db ->query( "SELECT 1 FROM {ucms_site_node} WHERE nid = :nid AND site_id = :sid", [':nid' => $node->parent_nid, ':sid' => $node->site_id] ) ; if ($exists) { // On clone, the original node layout should be kept but owned // by the clone instead of the parent, IF AND ONLY IF the site // is the same; please note that the dereferencing happens in // 'ucms_site' module. $this ->db ->query( "UPDATE {ucms_layout} SET nid = :clone WHERE nid = :parent AND site_id = :site", [ ':clone' => $node->id(), ':parent' => $node->parent_nid, ':site' => $node->site_id, ] ) ; // The same way, if the original node was present in some site // layout, it must be replaced by the new one, IF AND ONLY IF // the site is the same switch ($this->db->driver()) { case 'mysql': $sql = " UPDATE {ucms_layout_data} d JOIN {ucms_layout} l ON l.id = d.layout_id SET d.nid = :clone WHERE d.nid = :parent AND l.site_id = :site "; break; default: $sql = " UPDATE {ucms_layout_data} AS d SET nid = :clone FROM {ucms_layout} l WHERE l.id = d.layout_id AND d.nid = :parent AND l.site_id = :site "; break; } $this->db->query($sql, [ ':clone' => $node->id(), ':parent' => $node->parent_nid, ':site' => $node->site_id, ]); } } }
php
public function onInsert(NodeEvent $event) { $node = $event->getNode(); // When inserting a node, site_id is always the current site context. if ($event->isClone() && $node->site_id) { $exists = (bool)$this ->db ->query( "SELECT 1 FROM {ucms_site_node} WHERE nid = :nid AND site_id = :sid", [':nid' => $node->parent_nid, ':sid' => $node->site_id] ) ; if ($exists) { // On clone, the original node layout should be kept but owned // by the clone instead of the parent, IF AND ONLY IF the site // is the same; please note that the dereferencing happens in // 'ucms_site' module. $this ->db ->query( "UPDATE {ucms_layout} SET nid = :clone WHERE nid = :parent AND site_id = :site", [ ':clone' => $node->id(), ':parent' => $node->parent_nid, ':site' => $node->site_id, ] ) ; // The same way, if the original node was present in some site // layout, it must be replaced by the new one, IF AND ONLY IF // the site is the same switch ($this->db->driver()) { case 'mysql': $sql = " UPDATE {ucms_layout_data} d JOIN {ucms_layout} l ON l.id = d.layout_id SET d.nid = :clone WHERE d.nid = :parent AND l.site_id = :site "; break; default: $sql = " UPDATE {ucms_layout_data} AS d SET nid = :clone FROM {ucms_layout} l WHERE l.id = d.layout_id AND d.nid = :parent AND l.site_id = :site "; break; } $this->db->query($sql, [ ':clone' => $node->id(), ':parent' => $node->parent_nid, ':site' => $node->site_id, ]); } } }
[ "public", "function", "onInsert", "(", "NodeEvent", "$", "event", ")", "{", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "// When inserting a node, site_id is always the current site context.", "if", "(", "$", "event", "->", "isClone", "(", ")", "&&", "$", "node", "->", "site_id", ")", "{", "$", "exists", "=", "(", "bool", ")", "$", "this", "->", "db", "->", "query", "(", "\"SELECT 1 FROM {ucms_site_node} WHERE nid = :nid AND site_id = :sid\"", ",", "[", "':nid'", "=>", "$", "node", "->", "parent_nid", ",", "':sid'", "=>", "$", "node", "->", "site_id", "]", ")", ";", "if", "(", "$", "exists", ")", "{", "// On clone, the original node layout should be kept but owned", "// by the clone instead of the parent, IF AND ONLY IF the site", "// is the same; please note that the dereferencing happens in", "// 'ucms_site' module.", "$", "this", "->", "db", "->", "query", "(", "\"UPDATE {ucms_layout} SET nid = :clone WHERE nid = :parent AND site_id = :site\"", ",", "[", "':clone'", "=>", "$", "node", "->", "id", "(", ")", ",", "':parent'", "=>", "$", "node", "->", "parent_nid", ",", "':site'", "=>", "$", "node", "->", "site_id", ",", "]", ")", ";", "// The same way, if the original node was present in some site", "// layout, it must be replaced by the new one, IF AND ONLY IF", "// the site is the same", "switch", "(", "$", "this", "->", "db", "->", "driver", "(", ")", ")", "{", "case", "'mysql'", ":", "$", "sql", "=", "\"\n UPDATE {ucms_layout_data} d\n JOIN {ucms_layout} l ON l.id = d.layout_id\n SET\n d.nid = :clone\n WHERE\n d.nid = :parent\n AND l.site_id = :site\n \"", ";", "break", ";", "default", ":", "$", "sql", "=", "\"\n UPDATE {ucms_layout_data} AS d\n SET\n nid = :clone\n FROM {ucms_layout} l\n WHERE\n l.id = d.layout_id\n AND d.nid = :parent\n AND l.site_id = :site\n \"", ";", "break", ";", "}", "$", "this", "->", "db", "->", "query", "(", "$", "sql", ",", "[", "':clone'", "=>", "$", "node", "->", "id", "(", ")", ",", "':parent'", "=>", "$", "node", "->", "parent_nid", ",", "':site'", "=>", "$", "node", "->", "site_id", ",", "]", ")", ";", "}", "}", "}" ]
When cloning a node within a site, we must replace all its parent references using the new new node identifier instead, in order to make it gracefully inherit from the right layouts.
[ "When", "cloning", "a", "node", "within", "a", "site", "we", "must", "replace", "all", "its", "parent", "references", "using", "the", "new", "new", "node", "identifier", "instead", "in", "order", "to", "make", "it", "gracefully", "inherit", "from", "the", "right", "layouts", "." ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/EventDispatcher/NodeEventSubscriber.php#L44-L115
234,727
despark/ignicms
src/Models/AdminModel.php
AdminModel.setAttribute
public function setAttribute($key, $value) { parent::setAttribute($key, $value); // TODO: Change the autogenerated stub if (isset($this->attributes[$key]) && is_string($this->attributes[$key]) && strlen($this->attributes[$key]) === 0) { $this->attributes[$key] = null; } return $this; }
php
public function setAttribute($key, $value) { parent::setAttribute($key, $value); // TODO: Change the autogenerated stub if (isset($this->attributes[$key]) && is_string($this->attributes[$key]) && strlen($this->attributes[$key]) === 0) { $this->attributes[$key] = null; } return $this; }
[ "public", "function", "setAttribute", "(", "$", "key", ",", "$", "value", ")", "{", "parent", "::", "setAttribute", "(", "$", "key", ",", "$", "value", ")", ";", "// TODO: Change the autogenerated stub", "if", "(", "isset", "(", "$", "this", "->", "attributes", "[", "$", "key", "]", ")", "&&", "is_string", "(", "$", "this", "->", "attributes", "[", "$", "key", "]", ")", "&&", "strlen", "(", "$", "this", "->", "attributes", "[", "$", "key", "]", ")", "===", "0", ")", "{", "$", "this", "->", "attributes", "[", "$", "key", "]", "=", "null", ";", "}", "return", "$", "this", ";", "}" ]
Override set attributes so we can check for empty strings. @todo We need a different way to achieve this @param string $key @param mixed $value @return $this
[ "Override", "set", "attributes", "so", "we", "can", "check", "for", "empty", "strings", "." ]
d55775a4656a7e99017d2ef3f8160599d600d2a7
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Models/AdminModel.php#L81-L90
234,728
despark/ignicms
src/Models/AdminModel.php
AdminModel.getDirty
public function getDirty() { $dirty = parent::getDirty(); if (! empty($this->files)) { // We just set the ID to the same value to trigger the update. $dirty[$this->getKeyName()] = $this->getKey(); } return $dirty; }
php
public function getDirty() { $dirty = parent::getDirty(); if (! empty($this->files)) { // We just set the ID to the same value to trigger the update. $dirty[$this->getKeyName()] = $this->getKey(); } return $dirty; }
[ "public", "function", "getDirty", "(", ")", "{", "$", "dirty", "=", "parent", "::", "getDirty", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "files", ")", ")", "{", "// We just set the ID to the same value to trigger the update.", "$", "dirty", "[", "$", "this", "->", "getKeyName", "(", ")", "]", "=", "$", "this", "->", "getKey", "(", ")", ";", "}", "return", "$", "dirty", ";", "}" ]
Override is dirty so we can trigger update if we have dirty images. @return array
[ "Override", "is", "dirty", "so", "we", "can", "trigger", "update", "if", "we", "have", "dirty", "images", "." ]
d55775a4656a7e99017d2ef3f8160599d600d2a7
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Models/AdminModel.php#L142-L151
234,729
makinacorpus/drupal-ucms
ucms_notification/src/EventDispatcher/NodeEventSubscriber.php
NodeEventSubscriber.ensureNodeSubscribers
private function ensureNodeSubscribers(NodeEvent $event) { $node = $event->getNode(); $followers = []; if ($userId = $node->getOwnerId()) { $followers[] = $userId; } if ($userId = $this->currentUser->id()) { $followers[] = $userId; } if ($this->siteManager && $node->site_id) { // Notify all webmasters for the site, useful for content modified by local contributors. $site = $this->siteManager->getStorage()->findOne($node->site_id); foreach ($this->siteManager->getAccess()->listWebmasters($site) as $webmaster) { $followers[] = $webmaster->getUserId(); } } $this->service->getNotificationService()->subscribe('node', $node->id(), $followers); }
php
private function ensureNodeSubscribers(NodeEvent $event) { $node = $event->getNode(); $followers = []; if ($userId = $node->getOwnerId()) { $followers[] = $userId; } if ($userId = $this->currentUser->id()) { $followers[] = $userId; } if ($this->siteManager && $node->site_id) { // Notify all webmasters for the site, useful for content modified by local contributors. $site = $this->siteManager->getStorage()->findOne($node->site_id); foreach ($this->siteManager->getAccess()->listWebmasters($site) as $webmaster) { $followers[] = $webmaster->getUserId(); } } $this->service->getNotificationService()->subscribe('node', $node->id(), $followers); }
[ "private", "function", "ensureNodeSubscribers", "(", "NodeEvent", "$", "event", ")", "{", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "followers", "=", "[", "]", ";", "if", "(", "$", "userId", "=", "$", "node", "->", "getOwnerId", "(", ")", ")", "{", "$", "followers", "[", "]", "=", "$", "userId", ";", "}", "if", "(", "$", "userId", "=", "$", "this", "->", "currentUser", "->", "id", "(", ")", ")", "{", "$", "followers", "[", "]", "=", "$", "userId", ";", "}", "if", "(", "$", "this", "->", "siteManager", "&&", "$", "node", "->", "site_id", ")", "{", "// Notify all webmasters for the site, useful for content modified by local contributors.", "$", "site", "=", "$", "this", "->", "siteManager", "->", "getStorage", "(", ")", "->", "findOne", "(", "$", "node", "->", "site_id", ")", ";", "foreach", "(", "$", "this", "->", "siteManager", "->", "getAccess", "(", ")", "->", "listWebmasters", "(", "$", "site", ")", "as", "$", "webmaster", ")", "{", "$", "followers", "[", "]", "=", "$", "webmaster", "->", "getUserId", "(", ")", ";", "}", "}", "$", "this", "->", "service", "->", "getNotificationService", "(", ")", "->", "subscribe", "(", "'node'", ",", "$", "node", "->", "id", "(", ")", ",", "$", "followers", ")", ";", "}" ]
From the given node, ensure subscribers @param NodeEvent $event
[ "From", "the", "given", "node", "ensure", "subscribers" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/EventDispatcher/NodeEventSubscriber.php#L77-L99
234,730
makinacorpus/drupal-ucms
ucms_notification/src/EventDispatcher/NodeEventSubscriber.php
NodeEventSubscriber.onInsert
public function onInsert(NodeEvent $event) { $node = $event->getNode(); $this->ensureNodeSubscribers($event); // Enfore node event to run, so that the automatic resource listener // will raise the correct notifications $newEvent = new ResourceEvent('node', $node->nid, $this->currentUser->id()); $this->dispatcher->dispatch('node:add', $newEvent); }
php
public function onInsert(NodeEvent $event) { $node = $event->getNode(); $this->ensureNodeSubscribers($event); // Enfore node event to run, so that the automatic resource listener // will raise the correct notifications $newEvent = new ResourceEvent('node', $node->nid, $this->currentUser->id()); $this->dispatcher->dispatch('node:add', $newEvent); }
[ "public", "function", "onInsert", "(", "NodeEvent", "$", "event", ")", "{", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "this", "->", "ensureNodeSubscribers", "(", "$", "event", ")", ";", "// Enfore node event to run, so that the automatic resource listener", "// will raise the correct notifications", "$", "newEvent", "=", "new", "ResourceEvent", "(", "'node'", ",", "$", "node", "->", "nid", ",", "$", "this", "->", "currentUser", "->", "id", "(", ")", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'node:add'", ",", "$", "newEvent", ")", ";", "}" ]
On node insert
[ "On", "node", "insert" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/EventDispatcher/NodeEventSubscriber.php#L104-L114
234,731
makinacorpus/drupal-ucms
ucms_notification/src/EventDispatcher/NodeEventSubscriber.php
NodeEventSubscriber.onUpdateRunNodeEvents
public function onUpdateRunNodeEvents(NodeEvent $event) { $node = $event->getNode(); $this->ensureNodeSubscribers($event); $newEvent = new ResourceEvent('node', $node->nid, $this->currentUser->id()); if ($node->is_flagged != $node->original->is_flagged) { if ($node->is_flagged) { $this->dispatcher->dispatch('node:flag', $newEvent); } } else if ($node->status != $node->original->status) { if ($node->status) { $this->dispatcher->dispatch('node:publish', $newEvent); } else { $this->dispatcher->dispatch('node:unpublish', $newEvent); } } else { $this->dispatcher->dispatch('node:edit', $newEvent); } }
php
public function onUpdateRunNodeEvents(NodeEvent $event) { $node = $event->getNode(); $this->ensureNodeSubscribers($event); $newEvent = new ResourceEvent('node', $node->nid, $this->currentUser->id()); if ($node->is_flagged != $node->original->is_flagged) { if ($node->is_flagged) { $this->dispatcher->dispatch('node:flag', $newEvent); } } else if ($node->status != $node->original->status) { if ($node->status) { $this->dispatcher->dispatch('node:publish', $newEvent); } else { $this->dispatcher->dispatch('node:unpublish', $newEvent); } } else { $this->dispatcher->dispatch('node:edit', $newEvent); } }
[ "public", "function", "onUpdateRunNodeEvents", "(", "NodeEvent", "$", "event", ")", "{", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "this", "->", "ensureNodeSubscribers", "(", "$", "event", ")", ";", "$", "newEvent", "=", "new", "ResourceEvent", "(", "'node'", ",", "$", "node", "->", "nid", ",", "$", "this", "->", "currentUser", "->", "id", "(", ")", ")", ";", "if", "(", "$", "node", "->", "is_flagged", "!=", "$", "node", "->", "original", "->", "is_flagged", ")", "{", "if", "(", "$", "node", "->", "is_flagged", ")", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'node:flag'", ",", "$", "newEvent", ")", ";", "}", "}", "else", "if", "(", "$", "node", "->", "status", "!=", "$", "node", "->", "original", "->", "status", ")", "{", "if", "(", "$", "node", "->", "status", ")", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'node:publish'", ",", "$", "newEvent", ")", ";", "}", "else", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'node:unpublish'", ",", "$", "newEvent", ")", ";", "}", "}", "else", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'node:edit'", ",", "$", "newEvent", ")", ";", "}", "}" ]
On node update raise node related notifications
[ "On", "node", "update", "raise", "node", "related", "notifications" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/EventDispatcher/NodeEventSubscriber.php#L119-L140
234,732
makinacorpus/drupal-ucms
ucms_notification/src/EventDispatcher/NodeEventSubscriber.php
NodeEventSubscriber.onUpdateRunLabelEvents
public function onUpdateRunLabelEvents(NodeEvent $event) { $node = $event->getNode(); if ($oldLabels = field_get_items('node', $node->original, 'labels')) { $oldLabels = array_column($oldLabels, 'tid'); } else { $oldLabels = []; } if ($currentLabels = field_get_items('node', $node, 'labels')) { if (is_array($currentLabels)) { $currentLabels = array_column($currentLabels, 'tid'); } else { $currentLabels = (array) $currentLabels; } } if ($currentLabels && ($newLabels = array_diff($currentLabels, $oldLabels))) { $newEvent = new ResourceEvent('node', $node->nid, $this->currentUser->id()); $newEvent->setArgument('new_labels', $newLabels); $this->dispatcher->dispatch('node:new_labels', $newEvent); } }
php
public function onUpdateRunLabelEvents(NodeEvent $event) { $node = $event->getNode(); if ($oldLabels = field_get_items('node', $node->original, 'labels')) { $oldLabels = array_column($oldLabels, 'tid'); } else { $oldLabels = []; } if ($currentLabels = field_get_items('node', $node, 'labels')) { if (is_array($currentLabels)) { $currentLabels = array_column($currentLabels, 'tid'); } else { $currentLabels = (array) $currentLabels; } } if ($currentLabels && ($newLabels = array_diff($currentLabels, $oldLabels))) { $newEvent = new ResourceEvent('node', $node->nid, $this->currentUser->id()); $newEvent->setArgument('new_labels', $newLabels); $this->dispatcher->dispatch('node:new_labels', $newEvent); } }
[ "public", "function", "onUpdateRunLabelEvents", "(", "NodeEvent", "$", "event", ")", "{", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "if", "(", "$", "oldLabels", "=", "field_get_items", "(", "'node'", ",", "$", "node", "->", "original", ",", "'labels'", ")", ")", "{", "$", "oldLabels", "=", "array_column", "(", "$", "oldLabels", ",", "'tid'", ")", ";", "}", "else", "{", "$", "oldLabels", "=", "[", "]", ";", "}", "if", "(", "$", "currentLabels", "=", "field_get_items", "(", "'node'", ",", "$", "node", ",", "'labels'", ")", ")", "{", "if", "(", "is_array", "(", "$", "currentLabels", ")", ")", "{", "$", "currentLabels", "=", "array_column", "(", "$", "currentLabels", ",", "'tid'", ")", ";", "}", "else", "{", "$", "currentLabels", "=", "(", "array", ")", "$", "currentLabels", ";", "}", "}", "if", "(", "$", "currentLabels", "&&", "(", "$", "newLabels", "=", "array_diff", "(", "$", "currentLabels", ",", "$", "oldLabels", ")", ")", ")", "{", "$", "newEvent", "=", "new", "ResourceEvent", "(", "'node'", ",", "$", "node", "->", "nid", ",", "$", "this", "->", "currentUser", "->", "id", "(", ")", ")", ";", "$", "newEvent", "->", "setArgument", "(", "'new_labels'", ",", "$", "newLabels", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'node:new_labels'", ",", "$", "newEvent", ")", ";", "}", "}" ]
On node update raise label related notifications
[ "On", "node", "update", "raise", "label", "related", "notifications" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/EventDispatcher/NodeEventSubscriber.php#L145-L169
234,733
makinacorpus/drupal-ucms
ucms_notification/src/EventDispatcher/NodeEventSubscriber.php
NodeEventSubscriber.onDelete
public function onDelete(NodeEvent $event) { $this->service->getNotificationService()->getBackend()->deleteChannel('node:' . $event->getEntityId()); }
php
public function onDelete(NodeEvent $event) { $this->service->getNotificationService()->getBackend()->deleteChannel('node:' . $event->getEntityId()); }
[ "public", "function", "onDelete", "(", "NodeEvent", "$", "event", ")", "{", "$", "this", "->", "service", "->", "getNotificationService", "(", ")", "->", "getBackend", "(", ")", "->", "deleteChannel", "(", "'node:'", ".", "$", "event", "->", "getEntityId", "(", ")", ")", ";", "}" ]
On node delete
[ "On", "node", "delete" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/EventDispatcher/NodeEventSubscriber.php#L174-L177
234,734
makinacorpus/drupal-ucms
ucms_composition/src/EventDispatcher/NodeEventSubscriber.php
NodeEventSubscriber.onSitePostInit
public function onSitePostInit(SiteEvent $event) { // @todo Ugly... The best would be to not use drupal_valid_token() require_once DRUPAL_ROOT . '/includes/common.inc'; $request = $this->requestStack->getCurrentRequest(); $pageContext = $this->contextManager->getPageContext(); $transContext = $this->contextManager->getSiteContext(); $site = $event->getSite(); $token = null; $matches = []; // Column is nullable, so this is possible if ($siteHomeNid = $site->getHomeNodeId()) { if (($token = $request->get(ContextManager::PARAM_SITE_TOKEN)) && drupal_valid_token($token)) { $transContext->setToken($token); } $transContext->setCurrentLayoutNodeId($siteHomeNid, $site->getId()); } // @todo $_GET['q']: cannot use Request::get() here since Drupal // alters the 'q' variable directly in the $_GET array if (preg_match('/^node\/([0-9]+)$/', $_GET['q'], $matches) === 1) { if (($token = $request->get(ContextManager::PARAM_PAGE_TOKEN)) && drupal_valid_token($token)) { $pageContext->setToken($token); } $pageContext->setCurrentLayoutNodeId((int)$matches[1], $site->getId()); } if (($token = $request->get(ContextManager::PARAM_AJAX_TOKEN)) && drupal_valid_token($token) && ($region = $request->get('region'))) { if ($this->contextManager->isPageContextRegion($region, $site->theme)) { $pageContext->setToken($token); } else if ($this->contextManager->isTransversalContextRegion($region, $site->theme)) { $transContext->setToken($token); } } }
php
public function onSitePostInit(SiteEvent $event) { // @todo Ugly... The best would be to not use drupal_valid_token() require_once DRUPAL_ROOT . '/includes/common.inc'; $request = $this->requestStack->getCurrentRequest(); $pageContext = $this->contextManager->getPageContext(); $transContext = $this->contextManager->getSiteContext(); $site = $event->getSite(); $token = null; $matches = []; // Column is nullable, so this is possible if ($siteHomeNid = $site->getHomeNodeId()) { if (($token = $request->get(ContextManager::PARAM_SITE_TOKEN)) && drupal_valid_token($token)) { $transContext->setToken($token); } $transContext->setCurrentLayoutNodeId($siteHomeNid, $site->getId()); } // @todo $_GET['q']: cannot use Request::get() here since Drupal // alters the 'q' variable directly in the $_GET array if (preg_match('/^node\/([0-9]+)$/', $_GET['q'], $matches) === 1) { if (($token = $request->get(ContextManager::PARAM_PAGE_TOKEN)) && drupal_valid_token($token)) { $pageContext->setToken($token); } $pageContext->setCurrentLayoutNodeId((int)$matches[1], $site->getId()); } if (($token = $request->get(ContextManager::PARAM_AJAX_TOKEN)) && drupal_valid_token($token) && ($region = $request->get('region'))) { if ($this->contextManager->isPageContextRegion($region, $site->theme)) { $pageContext->setToken($token); } else if ($this->contextManager->isTransversalContextRegion($region, $site->theme)) { $transContext->setToken($token); } } }
[ "public", "function", "onSitePostInit", "(", "SiteEvent", "$", "event", ")", "{", "// @todo Ugly... The best would be to not use drupal_valid_token()", "require_once", "DRUPAL_ROOT", ".", "'/includes/common.inc'", ";", "$", "request", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", ";", "$", "pageContext", "=", "$", "this", "->", "contextManager", "->", "getPageContext", "(", ")", ";", "$", "transContext", "=", "$", "this", "->", "contextManager", "->", "getSiteContext", "(", ")", ";", "$", "site", "=", "$", "event", "->", "getSite", "(", ")", ";", "$", "token", "=", "null", ";", "$", "matches", "=", "[", "]", ";", "// Column is nullable, so this is possible", "if", "(", "$", "siteHomeNid", "=", "$", "site", "->", "getHomeNodeId", "(", ")", ")", "{", "if", "(", "(", "$", "token", "=", "$", "request", "->", "get", "(", "ContextManager", "::", "PARAM_SITE_TOKEN", ")", ")", "&&", "drupal_valid_token", "(", "$", "token", ")", ")", "{", "$", "transContext", "->", "setToken", "(", "$", "token", ")", ";", "}", "$", "transContext", "->", "setCurrentLayoutNodeId", "(", "$", "siteHomeNid", ",", "$", "site", "->", "getId", "(", ")", ")", ";", "}", "// @todo $_GET['q']: cannot use Request::get() here since Drupal", "// alters the 'q' variable directly in the $_GET array", "if", "(", "preg_match", "(", "'/^node\\/([0-9]+)$/'", ",", "$", "_GET", "[", "'q'", "]", ",", "$", "matches", ")", "===", "1", ")", "{", "if", "(", "(", "$", "token", "=", "$", "request", "->", "get", "(", "ContextManager", "::", "PARAM_PAGE_TOKEN", ")", ")", "&&", "drupal_valid_token", "(", "$", "token", ")", ")", "{", "$", "pageContext", "->", "setToken", "(", "$", "token", ")", ";", "}", "$", "pageContext", "->", "setCurrentLayoutNodeId", "(", "(", "int", ")", "$", "matches", "[", "1", "]", ",", "$", "site", "->", "getId", "(", ")", ")", ";", "}", "if", "(", "(", "$", "token", "=", "$", "request", "->", "get", "(", "ContextManager", "::", "PARAM_AJAX_TOKEN", ")", ")", "&&", "drupal_valid_token", "(", "$", "token", ")", "&&", "(", "$", "region", "=", "$", "request", "->", "get", "(", "'region'", ")", ")", ")", "{", "if", "(", "$", "this", "->", "contextManager", "->", "isPageContextRegion", "(", "$", "region", ",", "$", "site", "->", "theme", ")", ")", "{", "$", "pageContext", "->", "setToken", "(", "$", "token", ")", ";", "}", "else", "if", "(", "$", "this", "->", "contextManager", "->", "isTransversalContextRegion", "(", "$", "region", ",", "$", "site", "->", "theme", ")", ")", "{", "$", "transContext", "->", "setToken", "(", "$", "token", ")", ";", "}", "}", "}" ]
Home page handling mostly.
[ "Home", "page", "handling", "mostly", "." ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_composition/src/EventDispatcher/NodeEventSubscriber.php#L141-L177
234,735
makinacorpus/drupal-ucms
ucms_composition/src/EventDispatcher/NodeEventSubscriber.php
NodeEventSubscriber.onSiteClone
public function onSiteClone(SiteCloneEvent $event) { $source = $event->getTemplateSite(); $target = $event->getSite(); // First copy node layouts $this ->database ->query( " INSERT INTO {layout} (site_id, nid, region) SELECT :target, usn.nid, ul.region FROM {layout} ul JOIN {ucms_site_node} usn ON ul.nid = usn.nid AND usn.site_id = :target WHERE ul.site_id = :source AND NOT EXISTS ( SELECT 1 FROM {layout} s_ul WHERE s_ul.nid = ul.nid AND s_ul.site_id = :target3 ) ", [ ':target' => $target->getId(), ':target2' => $target->getId(), ':source' => $source->getId(), ':target3' => $target->getId(), ] ) ; // Then duplicate layout data $this ->database ->query( " INSERT INTO {layout_data} (layout_id, item_type, item_id, style, position, options) SELECT target_ul.id, uld.item_type, uld.item_id, uld.style, uld.position, uld.options FROM {layout} source_ul JOIN {layout_data} uld ON source_ul.id = uld.layout_id AND source_ul.site_id = :source JOIN {node} n ON n.nid = uld.nid JOIN {layout} target_ul ON target_ul.nid = source_ul.nid AND target_ul.site_id = :target WHERE (n.status = 1 OR n.is_global = 0) ", [ ':source' => $source->getId(), ':target' => $target->getId(), ] ) ; }
php
public function onSiteClone(SiteCloneEvent $event) { $source = $event->getTemplateSite(); $target = $event->getSite(); // First copy node layouts $this ->database ->query( " INSERT INTO {layout} (site_id, nid, region) SELECT :target, usn.nid, ul.region FROM {layout} ul JOIN {ucms_site_node} usn ON ul.nid = usn.nid AND usn.site_id = :target WHERE ul.site_id = :source AND NOT EXISTS ( SELECT 1 FROM {layout} s_ul WHERE s_ul.nid = ul.nid AND s_ul.site_id = :target3 ) ", [ ':target' => $target->getId(), ':target2' => $target->getId(), ':source' => $source->getId(), ':target3' => $target->getId(), ] ) ; // Then duplicate layout data $this ->database ->query( " INSERT INTO {layout_data} (layout_id, item_type, item_id, style, position, options) SELECT target_ul.id, uld.item_type, uld.item_id, uld.style, uld.position, uld.options FROM {layout} source_ul JOIN {layout_data} uld ON source_ul.id = uld.layout_id AND source_ul.site_id = :source JOIN {node} n ON n.nid = uld.nid JOIN {layout} target_ul ON target_ul.nid = source_ul.nid AND target_ul.site_id = :target WHERE (n.status = 1 OR n.is_global = 0) ", [ ':source' => $source->getId(), ':target' => $target->getId(), ] ) ; }
[ "public", "function", "onSiteClone", "(", "SiteCloneEvent", "$", "event", ")", "{", "$", "source", "=", "$", "event", "->", "getTemplateSite", "(", ")", ";", "$", "target", "=", "$", "event", "->", "getSite", "(", ")", ";", "// First copy node layouts", "$", "this", "->", "database", "->", "query", "(", "\"\n INSERT INTO {layout} (site_id, nid, region)\n SELECT\n :target, usn.nid, ul.region\n FROM {layout} ul\n JOIN {ucms_site_node} usn ON\n ul.nid = usn.nid\n AND usn.site_id = :target\n WHERE\n ul.site_id = :source\n AND NOT EXISTS (\n SELECT 1\n FROM {layout} s_ul\n WHERE\n s_ul.nid = ul.nid\n AND s_ul.site_id = :target3\n )\n \"", ",", "[", "':target'", "=>", "$", "target", "->", "getId", "(", ")", ",", "':target2'", "=>", "$", "target", "->", "getId", "(", ")", ",", "':source'", "=>", "$", "source", "->", "getId", "(", ")", ",", "':target3'", "=>", "$", "target", "->", "getId", "(", ")", ",", "]", ")", ";", "// Then duplicate layout data", "$", "this", "->", "database", "->", "query", "(", "\"\n INSERT INTO {layout_data}\n (layout_id, item_type, item_id, style, position, options)\n SELECT\n target_ul.id,\n uld.item_type,\n uld.item_id,\n uld.style,\n uld.position,\n uld.options\n FROM {layout} source_ul\n JOIN {layout_data} uld ON\n source_ul.id = uld.layout_id\n AND source_ul.site_id = :source\n JOIN {node} n ON n.nid = uld.nid\n JOIN {layout} target_ul ON\n target_ul.nid = source_ul.nid\n AND target_ul.site_id = :target\n WHERE\n (n.status = 1 OR n.is_global = 0)\n \"", ",", "[", "':source'", "=>", "$", "source", "->", "getId", "(", ")", ",", "':target'", "=>", "$", "target", "->", "getId", "(", ")", ",", "]", ")", ";", "}" ]
When cloning a site, we need to clone all layouts as well.
[ "When", "cloning", "a", "site", "we", "need", "to", "clone", "all", "layouts", "as", "well", "." ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_composition/src/EventDispatcher/NodeEventSubscriber.php#L182-L249
234,736
makinacorpus/drupal-ucms
ucms_composition/src/EventDispatcher/NodeEventSubscriber.php
NodeEventSubscriber.onAttach
public function onAttach(SiteAttachEvent $event) { // On 08/09/2016, I stumbled upon this piece of code. Long story short: // when you reference a node in a site, it duplicates the original site // layout in the new site. // // While I could see some kind of use for this, I am not sure this is // really necessary. // // I am quite sure that the original wanted behavior was on node clone // and not on node reference: when you want to edit a node that's not // yours, on your site, the application propose that you may clone it on // the site instead of editing the original node, at this exact point in // time, you do need to duplicate layouts. // Do no run when in edit mode if ($this->context->hasToken()) { return; } $siteIdList = $event->getSiteIdList(); /* @var \Drupal\node\NodeInterface[] $nodeList */ $nodeList = $this->entityManager->getStorage('node')->loadMultiple($event->getNodeIdList()); $pageContext = $this->contextManager->getPageContext(); $storage = $pageContext->getStorage(); // @todo Find a better way foreach ($siteIdList as $siteId) { foreach ($nodeList as $node) { if (!$node->site_id) { continue; } // Ensure a layout does not already exists (for example when // cloning a node, the layout data already has been inserted // if the original was existing). $exists = (bool)$this ->db ->query( "SELECT 1 FROM {ucms_layout} WHERE nid = :nid AND site_id = :sid", [':nid' => $node->id(), ':sid' => $siteId] ) ->fetchField() ; if ($exists) { return; } $layout = $storage->findForNodeOnSite($node->id(), $node->site_id); if ($layout) { $clone = clone $layout; $clone->setId(null); $clone->setSiteId($siteId); foreach ($clone->getAllRegions() as $region) { $region->toggleUpdateStatus(true); } $storage->save($clone); } } } }
php
public function onAttach(SiteAttachEvent $event) { // On 08/09/2016, I stumbled upon this piece of code. Long story short: // when you reference a node in a site, it duplicates the original site // layout in the new site. // // While I could see some kind of use for this, I am not sure this is // really necessary. // // I am quite sure that the original wanted behavior was on node clone // and not on node reference: when you want to edit a node that's not // yours, on your site, the application propose that you may clone it on // the site instead of editing the original node, at this exact point in // time, you do need to duplicate layouts. // Do no run when in edit mode if ($this->context->hasToken()) { return; } $siteIdList = $event->getSiteIdList(); /* @var \Drupal\node\NodeInterface[] $nodeList */ $nodeList = $this->entityManager->getStorage('node')->loadMultiple($event->getNodeIdList()); $pageContext = $this->contextManager->getPageContext(); $storage = $pageContext->getStorage(); // @todo Find a better way foreach ($siteIdList as $siteId) { foreach ($nodeList as $node) { if (!$node->site_id) { continue; } // Ensure a layout does not already exists (for example when // cloning a node, the layout data already has been inserted // if the original was existing). $exists = (bool)$this ->db ->query( "SELECT 1 FROM {ucms_layout} WHERE nid = :nid AND site_id = :sid", [':nid' => $node->id(), ':sid' => $siteId] ) ->fetchField() ; if ($exists) { return; } $layout = $storage->findForNodeOnSite($node->id(), $node->site_id); if ($layout) { $clone = clone $layout; $clone->setId(null); $clone->setSiteId($siteId); foreach ($clone->getAllRegions() as $region) { $region->toggleUpdateStatus(true); } $storage->save($clone); } } } }
[ "public", "function", "onAttach", "(", "SiteAttachEvent", "$", "event", ")", "{", "// On 08/09/2016, I stumbled upon this piece of code. Long story short:", "// when you reference a node in a site, it duplicates the original site", "// layout in the new site.", "//", "// While I could see some kind of use for this, I am not sure this is", "// really necessary.", "//", "// I am quite sure that the original wanted behavior was on node clone", "// and not on node reference: when you want to edit a node that's not", "// yours, on your site, the application propose that you may clone it on", "// the site instead of editing the original node, at this exact point in", "// time, you do need to duplicate layouts.", "// Do no run when in edit mode", "if", "(", "$", "this", "->", "context", "->", "hasToken", "(", ")", ")", "{", "return", ";", "}", "$", "siteIdList", "=", "$", "event", "->", "getSiteIdList", "(", ")", ";", "/* @var \\Drupal\\node\\NodeInterface[] $nodeList */", "$", "nodeList", "=", "$", "this", "->", "entityManager", "->", "getStorage", "(", "'node'", ")", "->", "loadMultiple", "(", "$", "event", "->", "getNodeIdList", "(", ")", ")", ";", "$", "pageContext", "=", "$", "this", "->", "contextManager", "->", "getPageContext", "(", ")", ";", "$", "storage", "=", "$", "pageContext", "->", "getStorage", "(", ")", ";", "// @todo Find a better way", "foreach", "(", "$", "siteIdList", "as", "$", "siteId", ")", "{", "foreach", "(", "$", "nodeList", "as", "$", "node", ")", "{", "if", "(", "!", "$", "node", "->", "site_id", ")", "{", "continue", ";", "}", "// Ensure a layout does not already exists (for example when", "// cloning a node, the layout data already has been inserted", "// if the original was existing).", "$", "exists", "=", "(", "bool", ")", "$", "this", "->", "db", "->", "query", "(", "\"SELECT 1 FROM {ucms_layout} WHERE nid = :nid AND site_id = :sid\"", ",", "[", "':nid'", "=>", "$", "node", "->", "id", "(", ")", ",", "':sid'", "=>", "$", "siteId", "]", ")", "->", "fetchField", "(", ")", ";", "if", "(", "$", "exists", ")", "{", "return", ";", "}", "$", "layout", "=", "$", "storage", "->", "findForNodeOnSite", "(", "$", "node", "->", "id", "(", ")", ",", "$", "node", "->", "site_id", ")", ";", "if", "(", "$", "layout", ")", "{", "$", "clone", "=", "clone", "$", "layout", ";", "$", "clone", "->", "setId", "(", "null", ")", ";", "$", "clone", "->", "setSiteId", "(", "$", "siteId", ")", ";", "foreach", "(", "$", "clone", "->", "getAllRegions", "(", ")", "as", "$", "region", ")", "{", "$", "region", "->", "toggleUpdateStatus", "(", "true", ")", ";", "}", "$", "storage", "->", "save", "(", "$", "clone", ")", ";", "}", "}", "}", "}" ]
When referencing a node on site, we clone its original layout as well so the user gets an exact copy of the page.
[ "When", "referencing", "a", "node", "on", "site", "we", "clone", "its", "original", "layout", "as", "well", "so", "the", "user", "gets", "an", "exact", "copy", "of", "the", "page", "." ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_composition/src/EventDispatcher/NodeEventSubscriber.php#L255-L321
234,737
PHPixie/HTTP
src/PHPixie/HTTP/Responses/Response.php
Response.setStatus
public function setStatus($code, $reasonPhrase = null) { $this->statusCode = $code; $this->reasonPhrase = $reasonPhrase; }
php
public function setStatus($code, $reasonPhrase = null) { $this->statusCode = $code; $this->reasonPhrase = $reasonPhrase; }
[ "public", "function", "setStatus", "(", "$", "code", ",", "$", "reasonPhrase", "=", "null", ")", "{", "$", "this", "->", "statusCode", "=", "$", "code", ";", "$", "this", "->", "reasonPhrase", "=", "$", "reasonPhrase", ";", "}" ]
Set status code and phrase @param int $code @param string|null $reasonPhrase
[ "Set", "status", "code", "and", "phrase" ]
581c0df452fd07ca4ea0b3e24e8ddee8dddc2912
https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Responses/Response.php#L99-L103
234,738
PHPixie/HTTP
src/PHPixie/HTTP/Responses/Response.php
Response.asResponseMessage
public function asResponseMessage($context = null) { return $this->messages->response( '1.1', $this->mergeContextHeaders($context), $this->body, $this->statusCode, $this->reasonPhrase ); }
php
public function asResponseMessage($context = null) { return $this->messages->response( '1.1', $this->mergeContextHeaders($context), $this->body, $this->statusCode, $this->reasonPhrase ); }
[ "public", "function", "asResponseMessage", "(", "$", "context", "=", "null", ")", "{", "return", "$", "this", "->", "messages", "->", "response", "(", "'1.1'", ",", "$", "this", "->", "mergeContextHeaders", "(", "$", "context", ")", ",", "$", "this", "->", "body", ",", "$", "this", "->", "statusCode", ",", "$", "this", "->", "reasonPhrase", ")", ";", "}" ]
Get PSR-7 response representation @param Context|null $context HTTP context @return ResponseInterface
[ "Get", "PSR", "-", "7", "response", "representation" ]
581c0df452fd07ca4ea0b3e24e8ddee8dddc2912
https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Responses/Response.php#L110-L119
234,739
PHPixie/HTTP
src/PHPixie/HTTP/Responses/Response.php
Response.mergeContextHeaders
protected function mergeContextHeaders($context) { $headers = $this->headers->asArray(); if($context === null ) { return $headers; } $cookieUpdates = $context->cookies()->updates(); if(empty($cookieUpdates)) { return $headers; } $cookieHeaders = array(); foreach($cookieUpdates as $update) { $cookieHeaders[] = $update->asHeader(); } foreach($headers as $name => $value) { if(strtolower($name) === 'set-cookie') { foreach($cookieHeaders as $header) { $headers[$name][] = $header; } return $headers; } } $headers['Set-Cookie'] = $cookieHeaders; return $headers; }
php
protected function mergeContextHeaders($context) { $headers = $this->headers->asArray(); if($context === null ) { return $headers; } $cookieUpdates = $context->cookies()->updates(); if(empty($cookieUpdates)) { return $headers; } $cookieHeaders = array(); foreach($cookieUpdates as $update) { $cookieHeaders[] = $update->asHeader(); } foreach($headers as $name => $value) { if(strtolower($name) === 'set-cookie') { foreach($cookieHeaders as $header) { $headers[$name][] = $header; } return $headers; } } $headers['Set-Cookie'] = $cookieHeaders; return $headers; }
[ "protected", "function", "mergeContextHeaders", "(", "$", "context", ")", "{", "$", "headers", "=", "$", "this", "->", "headers", "->", "asArray", "(", ")", ";", "if", "(", "$", "context", "===", "null", ")", "{", "return", "$", "headers", ";", "}", "$", "cookieUpdates", "=", "$", "context", "->", "cookies", "(", ")", "->", "updates", "(", ")", ";", "if", "(", "empty", "(", "$", "cookieUpdates", ")", ")", "{", "return", "$", "headers", ";", "}", "$", "cookieHeaders", "=", "array", "(", ")", ";", "foreach", "(", "$", "cookieUpdates", "as", "$", "update", ")", "{", "$", "cookieHeaders", "[", "]", "=", "$", "update", "->", "asHeader", "(", ")", ";", "}", "foreach", "(", "$", "headers", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "strtolower", "(", "$", "name", ")", "===", "'set-cookie'", ")", "{", "foreach", "(", "$", "cookieHeaders", "as", "$", "header", ")", "{", "$", "headers", "[", "$", "name", "]", "[", "]", "=", "$", "header", ";", "}", "return", "$", "headers", ";", "}", "}", "$", "headers", "[", "'Set-Cookie'", "]", "=", "$", "cookieHeaders", ";", "return", "$", "headers", ";", "}" ]
Merge headers from HTTP context @param Context $context @return array
[ "Merge", "headers", "from", "HTTP", "context" ]
581c0df452fd07ca4ea0b3e24e8ddee8dddc2912
https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Responses/Response.php#L126-L155
234,740
browner12/validation
src/Validator.php
Validator.isValid
public function isValid(array $attributes, $rules = 'rules') { //validator $validator = $this->factory->make($attributes, static::${$rules}); //passes validation if (!$validator->fails()) { return true; } //set errors $this->errors = $validator->getMessageBag(); //return return false; }
php
public function isValid(array $attributes, $rules = 'rules') { //validator $validator = $this->factory->make($attributes, static::${$rules}); //passes validation if (!$validator->fails()) { return true; } //set errors $this->errors = $validator->getMessageBag(); //return return false; }
[ "public", "function", "isValid", "(", "array", "$", "attributes", ",", "$", "rules", "=", "'rules'", ")", "{", "//validator", "$", "validator", "=", "$", "this", "->", "factory", "->", "make", "(", "$", "attributes", ",", "static", "::", "$", "{", "$", "rules", "}", ")", ";", "//passes validation", "if", "(", "!", "$", "validator", "->", "fails", "(", ")", ")", "{", "return", "true", ";", "}", "//set errors", "$", "this", "->", "errors", "=", "$", "validator", "->", "getMessageBag", "(", ")", ";", "//return", "return", "false", ";", "}" ]
check if the input is valid @param array $attributes @param string $rules @return bool
[ "check", "if", "the", "input", "is", "valid" ]
539a8f1df76c719bf11aceffc9a2d9aaadab72b1
https://github.com/browner12/validation/blob/539a8f1df76c719bf11aceffc9a2d9aaadab72b1/src/Validator.php#L35-L50
234,741
makinacorpus/drupal-ucms
ucms_search/src/NodeIndexerChain.php
NodeIndexerChain.getIndexer
public function getIndexer($index) { if (!isset($this->chain[$index])) { throw new \InvalidArgumentException(sprintf("Indexer for index '%s' is not registered", $index)); } return $this->chain[$index]; }
php
public function getIndexer($index) { if (!isset($this->chain[$index])) { throw new \InvalidArgumentException(sprintf("Indexer for index '%s' is not registered", $index)); } return $this->chain[$index]; }
[ "public", "function", "getIndexer", "(", "$", "index", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "chain", "[", "$", "index", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"Indexer for index '%s' is not registered\"", ",", "$", "index", ")", ")", ";", "}", "return", "$", "this", "->", "chain", "[", "$", "index", "]", ";", "}" ]
Get a single indexer @param string $index @return NodeIndexerInterface
[ "Get", "a", "single", "indexer" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/NodeIndexerChain.php#L56-L63
234,742
PHPixie/HTTP
src/PHPixie/HTTP/Context/Cookies.php
Cookies.getRequired
public function getRequired($name) { if($this->exists($name)) { return $this->cookies[$name]; } throw new \PHPixie\HTTP\Exception("Cookie '$name' is not set"); }
php
public function getRequired($name) { if($this->exists($name)) { return $this->cookies[$name]; } throw new \PHPixie\HTTP\Exception("Cookie '$name' is not set"); }
[ "public", "function", "getRequired", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "exists", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "cookies", "[", "$", "name", "]", ";", "}", "throw", "new", "\\", "PHPixie", "\\", "HTTP", "\\", "Exception", "(", "\"Cookie '$name' is not set\"", ")", ";", "}" ]
Get cookie or throw an exception if it's missing @param string $name @return mixed @throws \PHPixie\HTTP\Exception
[ "Get", "cookie", "or", "throw", "an", "exception", "if", "it", "s", "missing" ]
581c0df452fd07ca4ea0b3e24e8ddee8dddc2912
https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Context/Cookies.php#L58-L65
234,743
stephweb/daw-php-orm
example/core/Routing/Router.php
Router.setUri
private function setUri() { if (Input::hasGet('uri')) { $this->uri = ltrim(Input::get('uri'), '/'); if (strpos(Request::getRequestUri(), '?uri=') !== false) { Response::redirect($this->uri, 301); } } }
php
private function setUri() { if (Input::hasGet('uri')) { $this->uri = ltrim(Input::get('uri'), '/'); if (strpos(Request::getRequestUri(), '?uri=') !== false) { Response::redirect($this->uri, 301); } } }
[ "private", "function", "setUri", "(", ")", "{", "if", "(", "Input", "::", "hasGet", "(", "'uri'", ")", ")", "{", "$", "this", "->", "uri", "=", "ltrim", "(", "Input", "::", "get", "(", "'uri'", ")", ",", "'/'", ")", ";", "if", "(", "strpos", "(", "Request", "::", "getRequestUri", "(", ")", ",", "'?uri='", ")", "!==", "false", ")", "{", "Response", "::", "redirect", "(", "$", "this", "->", "uri", ",", "301", ")", ";", "}", "}", "}" ]
Setter de l'URI
[ "Setter", "de", "l", "URI" ]
0c37e3baa1420cf9e3feff122016329de3764bcc
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/example/core/Routing/Router.php#L60-L69
234,744
stephweb/daw-php-orm
example/core/Routing/Router.php
Router.run
public function run() { foreach ($this->routes as $path => $action) { if ($this->uri == $path) { return $this->executeAction($action); } } return $this->executeError404(); }
php
public function run() { foreach ($this->routes as $path => $action) { if ($this->uri == $path) { return $this->executeAction($action); } } return $this->executeError404(); }
[ "public", "function", "run", "(", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "path", "=>", "$", "action", ")", "{", "if", "(", "$", "this", "->", "uri", "==", "$", "path", ")", "{", "return", "$", "this", "->", "executeAction", "(", "$", "action", ")", ";", "}", "}", "return", "$", "this", "->", "executeError404", "(", ")", ";", "}" ]
Executer le Routing @return mixed
[ "Executer", "le", "Routing" ]
0c37e3baa1420cf9e3feff122016329de3764bcc
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/example/core/Routing/Router.php#L87-L96
234,745
stephweb/daw-php-orm
example/core/Routing/Router.php
Router.executeAction
private function executeAction(string $action) { list($controller, $method) = explode('@', $action); $class = '\App\Controllers\\'.ucfirst($controller).'Controller'; if (!class_exists($class)) { throw new ExceptionHandler('Class "'.$class.'" not found.'); } $controllerInstantiate = new $class(); if (!method_exists($controllerInstantiate, $method)) { throw new ExceptionHandler('Method "'.$method.'" not found in '.$class.'.'); } return call_user_func_array([new $controllerInstantiate, $method], []); }
php
private function executeAction(string $action) { list($controller, $method) = explode('@', $action); $class = '\App\Controllers\\'.ucfirst($controller).'Controller'; if (!class_exists($class)) { throw new ExceptionHandler('Class "'.$class.'" not found.'); } $controllerInstantiate = new $class(); if (!method_exists($controllerInstantiate, $method)) { throw new ExceptionHandler('Method "'.$method.'" not found in '.$class.'.'); } return call_user_func_array([new $controllerInstantiate, $method], []); }
[ "private", "function", "executeAction", "(", "string", "$", "action", ")", "{", "list", "(", "$", "controller", ",", "$", "method", ")", "=", "explode", "(", "'@'", ",", "$", "action", ")", ";", "$", "class", "=", "'\\App\\Controllers\\\\'", ".", "ucfirst", "(", "$", "controller", ")", ".", "'Controller'", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "ExceptionHandler", "(", "'Class \"'", ".", "$", "class", ".", "'\" not found.'", ")", ";", "}", "$", "controllerInstantiate", "=", "new", "$", "class", "(", ")", ";", "if", "(", "!", "method_exists", "(", "$", "controllerInstantiate", ",", "$", "method", ")", ")", "{", "throw", "new", "ExceptionHandler", "(", "'Method \"'", ".", "$", "method", ".", "'\" not found in '", ".", "$", "class", ".", "'.'", ")", ";", "}", "return", "call_user_func_array", "(", "[", "new", "$", "controllerInstantiate", ",", "$", "method", "]", ",", "[", "]", ")", ";", "}" ]
Executer l'action @param string $action @return mixed
[ "Executer", "l", "action" ]
0c37e3baa1420cf9e3feff122016329de3764bcc
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/example/core/Routing/Router.php#L104-L121
234,746
makinacorpus/drupal-ucms
ucms_widget/src/Impl/MenuRoleWidget.php
MenuRoleWidget.findAllMenuWithRole
private function findAllMenuWithRole(Site $site, $role) { return $this->treeManager->getMenuStorage()->loadWithConditions([ 'site_id' => $site->getId(), 'role' => $role, ]); }
php
private function findAllMenuWithRole(Site $site, $role) { return $this->treeManager->getMenuStorage()->loadWithConditions([ 'site_id' => $site->getId(), 'role' => $role, ]); }
[ "private", "function", "findAllMenuWithRole", "(", "Site", "$", "site", ",", "$", "role", ")", "{", "return", "$", "this", "->", "treeManager", "->", "getMenuStorage", "(", ")", "->", "loadWithConditions", "(", "[", "'site_id'", "=>", "$", "site", "->", "getId", "(", ")", ",", "'role'", "=>", "$", "role", ",", "]", ")", ";", "}" ]
Find all the menus with the given role in the given site @param Site $site @param string $role @return Menu[]
[ "Find", "all", "the", "menus", "with", "the", "given", "role", "in", "the", "given", "site" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_widget/src/Impl/MenuRoleWidget.php#L48-L54
234,747
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Order/Base/Standard.php
Standard.saveItems
public function saveItems( \stdClass $params ) { $this->checkParams( $params, array( 'site', 'items' ) ); $ids = []; $manager = $this->getManager(); $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $entry ) { $langid = ( isset( $entry->{'order.base.languageid'} ) ? $entry->{'order.base.languageid'} : null ); $currencyid = ( isset( $entry->{'order.base.currencyid'} ) ? $entry->{'order.base.currencyid'} : null ); $this->setLocale( $params->site, $langid, $currencyid ); $item = $manager->createItem(); $item->fromArray( (array) $this->transformValues( $entry ) ); $item = $manager->saveItem( $item ); $ids[] = $item->getId(); } return $this->getItems( $ids, $this->getPrefix() ); }
php
public function saveItems( \stdClass $params ) { $this->checkParams( $params, array( 'site', 'items' ) ); $ids = []; $manager = $this->getManager(); $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $entry ) { $langid = ( isset( $entry->{'order.base.languageid'} ) ? $entry->{'order.base.languageid'} : null ); $currencyid = ( isset( $entry->{'order.base.currencyid'} ) ? $entry->{'order.base.currencyid'} : null ); $this->setLocale( $params->site, $langid, $currencyid ); $item = $manager->createItem(); $item->fromArray( (array) $this->transformValues( $entry ) ); $item = $manager->saveItem( $item ); $ids[] = $item->getId(); } return $this->getItems( $ids, $this->getPrefix() ); }
[ "public", "function", "saveItems", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'site'", ",", "'items'", ")", ")", ";", "$", "ids", "=", "[", "]", ";", "$", "manager", "=", "$", "this", "->", "getManager", "(", ")", ";", "$", "items", "=", "(", "!", "is_array", "(", "$", "params", "->", "items", ")", "?", "array", "(", "$", "params", "->", "items", ")", ":", "$", "params", "->", "items", ")", ";", "foreach", "(", "$", "items", "as", "$", "entry", ")", "{", "$", "langid", "=", "(", "isset", "(", "$", "entry", "->", "{", "'order.base.languageid'", "}", ")", "?", "$", "entry", "->", "{", "'order.base.languageid'", "}", ":", "null", ")", ";", "$", "currencyid", "=", "(", "isset", "(", "$", "entry", "->", "{", "'order.base.currencyid'", "}", ")", "?", "$", "entry", "->", "{", "'order.base.currencyid'", "}", ":", "null", ")", ";", "$", "this", "->", "setLocale", "(", "$", "params", "->", "site", ",", "$", "langid", ",", "$", "currencyid", ")", ";", "$", "item", "=", "$", "manager", "->", "createItem", "(", ")", ";", "$", "item", "->", "fromArray", "(", "(", "array", ")", "$", "this", "->", "transformValues", "(", "$", "entry", ")", ")", ";", "$", "item", "=", "$", "manager", "->", "saveItem", "(", "$", "item", ")", ";", "$", "ids", "[", "]", "=", "$", "item", "->", "getId", "(", ")", ";", "}", "return", "$", "this", "->", "getItems", "(", "$", "ids", ",", "$", "this", "->", "getPrefix", "(", ")", ")", ";", "}" ]
Creates a new order base item or updates an existing one or a list thereof. @param \stdClass $params Associative array containing the order base properties
[ "Creates", "a", "new", "order", "base", "item", "or", "updates", "an", "existing", "one", "or", "a", "list", "thereof", "." ]
594ee7cec90fd63a4773c05c93f353e66d9b3408
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Order/Base/Standard.php#L44-L66
234,748
edvler/yii2-accounting
tools/StaticEb.php
StaticEb.formatAccountside
public static function formatAccountside($value) { if ($value === StaticEb::$accountsideDebitSign) { return \Yii::t('common/staticeb', 'Debit'); } else if ($value === StaticEb::$accountsideCreditSign) { return \Yii::t('common/staticeb', 'Credit'); } else { throw new Exception(\Yii::t('common/staticeb', '{value} is not a accounside. Valid values: ' . StaticEb::$accountsideDebitSign . ',' . StaticEb::$accountsideCreditSign, [ 'value' => $value] )); } }
php
public static function formatAccountside($value) { if ($value === StaticEb::$accountsideDebitSign) { return \Yii::t('common/staticeb', 'Debit'); } else if ($value === StaticEb::$accountsideCreditSign) { return \Yii::t('common/staticeb', 'Credit'); } else { throw new Exception(\Yii::t('common/staticeb', '{value} is not a accounside. Valid values: ' . StaticEb::$accountsideDebitSign . ',' . StaticEb::$accountsideCreditSign, [ 'value' => $value] )); } }
[ "public", "static", "function", "formatAccountside", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "StaticEb", "::", "$", "accountsideDebitSign", ")", "{", "return", "\\", "Yii", "::", "t", "(", "'common/staticeb'", ",", "'Debit'", ")", ";", "}", "else", "if", "(", "$", "value", "===", "StaticEb", "::", "$", "accountsideCreditSign", ")", "{", "return", "\\", "Yii", "::", "t", "(", "'common/staticeb'", ",", "'Credit'", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "\\", "Yii", "::", "t", "(", "'common/staticeb'", ",", "'{value} is not a accounside. Valid values: '", ".", "StaticEb", "::", "$", "accountsideDebitSign", ".", "','", ".", "StaticEb", "::", "$", "accountsideCreditSign", ",", "[", "'value'", "=>", "$", "value", "]", ")", ")", ";", "}", "}" ]
Format credit or debit accountside @param string $value @return string formatted language string @throws Exception if sign other than C,D given
[ "Format", "credit", "or", "debit", "accountside" ]
26c5f8731b47a3e6e28da2a460ec2bf72c94422b
https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L54-L63
234,749
edvler/yii2-accounting
tools/StaticEb.php
StaticEb.getAccountSideSignFromLanguage
public static function getAccountSideSignFromLanguage($value) { switch (strtolower($value)) { case strtolower(StaticEb::$accountsideDebitSign): case strtolower(StaticEb::formatAccountside('D')): return 'D'; case strtolower(StaticEb::$accountsideCreditSign): case strtolower(StaticEb::formatAccountside('C')): return 'C'; default: throw new Exception(\Yii::t('common/staticeb', 'Cannot determine accoundside sign from value "{value}". Valid values: ' . StaticEb::$accountsideDebitSign . ', ' . StaticEb::formatAccountside('D') . ', ' . StaticEb::$accountsideCreditSign . ', ' . StaticEb::formatAccountside('C'), [ 'value' => $value] )); } }
php
public static function getAccountSideSignFromLanguage($value) { switch (strtolower($value)) { case strtolower(StaticEb::$accountsideDebitSign): case strtolower(StaticEb::formatAccountside('D')): return 'D'; case strtolower(StaticEb::$accountsideCreditSign): case strtolower(StaticEb::formatAccountside('C')): return 'C'; default: throw new Exception(\Yii::t('common/staticeb', 'Cannot determine accoundside sign from value "{value}". Valid values: ' . StaticEb::$accountsideDebitSign . ', ' . StaticEb::formatAccountside('D') . ', ' . StaticEb::$accountsideCreditSign . ', ' . StaticEb::formatAccountside('C'), [ 'value' => $value] )); } }
[ "public", "static", "function", "getAccountSideSignFromLanguage", "(", "$", "value", ")", "{", "switch", "(", "strtolower", "(", "$", "value", ")", ")", "{", "case", "strtolower", "(", "StaticEb", "::", "$", "accountsideDebitSign", ")", ":", "case", "strtolower", "(", "StaticEb", "::", "formatAccountside", "(", "'D'", ")", ")", ":", "return", "'D'", ";", "case", "strtolower", "(", "StaticEb", "::", "$", "accountsideCreditSign", ")", ":", "case", "strtolower", "(", "StaticEb", "::", "formatAccountside", "(", "'C'", ")", ")", ":", "return", "'C'", ";", "default", ":", "throw", "new", "Exception", "(", "\\", "Yii", "::", "t", "(", "'common/staticeb'", ",", "'Cannot determine accoundside sign from value \"{value}\". Valid values: '", ".", "StaticEb", "::", "$", "accountsideDebitSign", ".", "', '", ".", "StaticEb", "::", "formatAccountside", "(", "'D'", ")", ".", "', '", ".", "StaticEb", "::", "$", "accountsideCreditSign", ".", "', '", ".", "StaticEb", "::", "formatAccountside", "(", "'C'", ")", ",", "[", "'value'", "=>", "$", "value", "]", ")", ")", ";", "}", "}" ]
Get AccountsideSign from current language @param string $value @return string formatted language string @throws Exception if accountside sign could not be determined
[ "Get", "AccountsideSign", "from", "current", "language" ]
26c5f8731b47a3e6e28da2a460ec2bf72c94422b
https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L72-L86
234,750
edvler/yii2-accounting
tools/StaticEb.php
StaticEb.parseDate
public static function parseDate($sourceDate, $sourceFormat, $destinationFormat) { $myDateTime = \DateTime::createFromFormat($sourceFormat, $sourceDate); if ($myDateTime === false) { throw new Exception("Date " . $sourceDate . " cannot be parsed with format \"" . $sourceFormat . "\""); } return $myDateTime->format($destinationFormat); }
php
public static function parseDate($sourceDate, $sourceFormat, $destinationFormat) { $myDateTime = \DateTime::createFromFormat($sourceFormat, $sourceDate); if ($myDateTime === false) { throw new Exception("Date " . $sourceDate . " cannot be parsed with format \"" . $sourceFormat . "\""); } return $myDateTime->format($destinationFormat); }
[ "public", "static", "function", "parseDate", "(", "$", "sourceDate", ",", "$", "sourceFormat", ",", "$", "destinationFormat", ")", "{", "$", "myDateTime", "=", "\\", "DateTime", "::", "createFromFormat", "(", "$", "sourceFormat", ",", "$", "sourceDate", ")", ";", "if", "(", "$", "myDateTime", "===", "false", ")", "{", "throw", "new", "Exception", "(", "\"Date \"", ".", "$", "sourceDate", ".", "\" cannot be parsed with format \\\"\"", ".", "$", "sourceFormat", ".", "\"\\\"\"", ")", ";", "}", "return", "$", "myDateTime", "->", "format", "(", "$", "destinationFormat", ")", ";", "}" ]
Parse a date from a string @param string String to parse @param string Source format according to http://php.net/manual/de/datetime.createfromformat.php @param string Destination format according to http://php.net/manual/de/datetime.createfromformat.php @return string the formatted date
[ "Parse", "a", "date", "from", "a", "string" ]
26c5f8731b47a3e6e28da2a460ec2bf72c94422b
https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L115-L123
234,751
schnittstabil/csrf-tokenservice
src/TokenService.php
TokenService.generate
public function generate($nonce, $iat = null, $exp = null) { $generator = $this->generator; return $generator($nonce, $iat, $exp); }
php
public function generate($nonce, $iat = null, $exp = null) { $generator = $this->generator; return $generator($nonce, $iat, $exp); }
[ "public", "function", "generate", "(", "$", "nonce", ",", "$", "iat", "=", "null", ",", "$", "exp", "=", "null", ")", "{", "$", "generator", "=", "$", "this", "->", "generator", ";", "return", "$", "generator", "(", "$", "nonce", ",", "$", "iat", ",", "$", "exp", ")", ";", "}" ]
Generate a CSRF token. @param string $nonce Value used to associate a client session @param int $iat The time that the token was issued, defaults to `time()` @param int $exp The expiration time, defaults to `$iat + $this->ttl` @return string @throws \InvalidArgumentException For invalid $iat and $exp arguments
[ "Generate", "a", "CSRF", "token", "." ]
22aefee674137e661fe439d08414b6abc1fe0d25
https://github.com/schnittstabil/csrf-tokenservice/blob/22aefee674137e661fe439d08414b6abc1fe0d25/src/TokenService.php#L43-L48
234,752
schnittstabil/csrf-tokenservice
src/TokenService.php
TokenService.getConstraintViolations
public function getConstraintViolations($nonce, $token, $now = null, $leeway = 0) { $validator = $this->validator; return $validator($nonce, $token, $now, $leeway); }
php
public function getConstraintViolations($nonce, $token, $now = null, $leeway = 0) { $validator = $this->validator; return $validator($nonce, $token, $now, $leeway); }
[ "public", "function", "getConstraintViolations", "(", "$", "nonce", ",", "$", "token", ",", "$", "now", "=", "null", ",", "$", "leeway", "=", "0", ")", "{", "$", "validator", "=", "$", "this", "->", "validator", ";", "return", "$", "validator", "(", "$", "nonce", ",", "$", "token", ",", "$", "now", ",", "$", "leeway", ")", ";", "}" ]
Determine constraint violations of CSRF tokens. @param string $nonce Value used to associate a client session @param string $token The token to validate @param int $now The current time, defaults to `time()` @return InvalidArgumentException[] Constraint violations; if $token is valid, an empty array
[ "Determine", "constraint", "violations", "of", "CSRF", "tokens", "." ]
22aefee674137e661fe439d08414b6abc1fe0d25
https://github.com/schnittstabil/csrf-tokenservice/blob/22aefee674137e661fe439d08414b6abc1fe0d25/src/TokenService.php#L59-L64
234,753
schnittstabil/csrf-tokenservice
src/TokenService.php
TokenService.validate
public function validate($nonce, $token, $now = null, $leeway = 0) { return count($this->getConstraintViolations($nonce, $token, $now, $leeway)) === 0; }
php
public function validate($nonce, $token, $now = null, $leeway = 0) { return count($this->getConstraintViolations($nonce, $token, $now, $leeway)) === 0; }
[ "public", "function", "validate", "(", "$", "nonce", ",", "$", "token", ",", "$", "now", "=", "null", ",", "$", "leeway", "=", "0", ")", "{", "return", "count", "(", "$", "this", "->", "getConstraintViolations", "(", "$", "nonce", ",", "$", "token", ",", "$", "now", ",", "$", "leeway", ")", ")", "===", "0", ";", "}" ]
Validate a CSRF token. @param string $nonce Value used to associate a client session @param string $token The token to validate @param int $now The current time, defaults to `time()` @param int $leeway The leeway in seconds @return bool true iff $token is valid
[ "Validate", "a", "CSRF", "token", "." ]
22aefee674137e661fe439d08414b6abc1fe0d25
https://github.com/schnittstabil/csrf-tokenservice/blob/22aefee674137e661fe439d08414b6abc1fe0d25/src/TokenService.php#L76-L79
234,754
h4cc/StackLogger
src/Logger.php
Logger.log
private function log($msg, array $context = array()) { /** @var \Psr\Log\LoggerInterface $logger */ $logger = $this->container['logger']; $logger->log($this->container['log_level'], $msg, $context); }
php
private function log($msg, array $context = array()) { /** @var \Psr\Log\LoggerInterface $logger */ $logger = $this->container['logger']; $logger->log($this->container['log_level'], $msg, $context); }
[ "private", "function", "log", "(", "$", "msg", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "/** @var \\Psr\\Log\\LoggerInterface $logger */", "$", "logger", "=", "$", "this", "->", "container", "[", "'logger'", "]", ";", "$", "logger", "->", "log", "(", "$", "this", "->", "container", "[", "'log_level'", "]", ",", "$", "msg", ",", "$", "context", ")", ";", "}" ]
Logs a message and given context. @param $msg @param array $context
[ "Logs", "a", "message", "and", "given", "context", "." ]
1bdbb3e7d157aa9069ace90267c249f43dc02b77
https://github.com/h4cc/StackLogger/blob/1bdbb3e7d157aa9069ace90267c249f43dc02b77/src/Logger.php#L125-L130
234,755
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Media/Standard.php
Standard.uploadItem
public function uploadItem( \stdClass $params ) { $this->checkParams( $params, array( 'site', 'domain' ) ); $this->setLocale( $params->site ); $context = $this->getContext(); $manager = \Aimeos\MShop\Factory::createManager( $context, 'media' ); $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'media/type' ); $item = $manager->createItem(); $item->setTypeId( $typeManager->findItem( 'default', [], 'product' )->getId() ); $item->setDomain( 'product' ); $item->setStatus( 1 ); $file = $this->getUploadedFile(); \Aimeos\Controller\Common\Media\Factory::createController( $context )->add( $item, $file ); $item = $manager->saveItem( $item ); return (object) $item->toArray( true ); }
php
public function uploadItem( \stdClass $params ) { $this->checkParams( $params, array( 'site', 'domain' ) ); $this->setLocale( $params->site ); $context = $this->getContext(); $manager = \Aimeos\MShop\Factory::createManager( $context, 'media' ); $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'media/type' ); $item = $manager->createItem(); $item->setTypeId( $typeManager->findItem( 'default', [], 'product' )->getId() ); $item->setDomain( 'product' ); $item->setStatus( 1 ); $file = $this->getUploadedFile(); \Aimeos\Controller\Common\Media\Factory::createController( $context )->add( $item, $file ); $item = $manager->saveItem( $item ); return (object) $item->toArray( true ); }
[ "public", "function", "uploadItem", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'site'", ",", "'domain'", ")", ")", ";", "$", "this", "->", "setLocale", "(", "$", "params", "->", "site", ")", ";", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "manager", "=", "\\", "Aimeos", "\\", "MShop", "\\", "Factory", "::", "createManager", "(", "$", "context", ",", "'media'", ")", ";", "$", "typeManager", "=", "\\", "Aimeos", "\\", "MShop", "\\", "Factory", "::", "createManager", "(", "$", "context", ",", "'media/type'", ")", ";", "$", "item", "=", "$", "manager", "->", "createItem", "(", ")", ";", "$", "item", "->", "setTypeId", "(", "$", "typeManager", "->", "findItem", "(", "'default'", ",", "[", "]", ",", "'product'", ")", "->", "getId", "(", ")", ")", ";", "$", "item", "->", "setDomain", "(", "'product'", ")", ";", "$", "item", "->", "setStatus", "(", "1", ")", ";", "$", "file", "=", "$", "this", "->", "getUploadedFile", "(", ")", ";", "\\", "Aimeos", "\\", "Controller", "\\", "Common", "\\", "Media", "\\", "Factory", "::", "createController", "(", "$", "context", ")", "->", "add", "(", "$", "item", ",", "$", "file", ")", ";", "$", "item", "=", "$", "manager", "->", "saveItem", "(", "$", "item", ")", ";", "return", "(", "object", ")", "$", "item", "->", "toArray", "(", "true", ")", ";", "}" ]
Stores an uploaded file @param \stdClass $params Associative list of parameters @return \stdClass Object with success value @throws \Aimeos\Controller\ExtJS\Exception If an error occurs
[ "Stores", "an", "uploaded", "file" ]
594ee7cec90fd63a4773c05c93f353e66d9b3408
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Media/Standard.php#L110-L130
234,756
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Media/Standard.php
Standard.getUploadedFile
protected function getUploadedFile() { $files = $this->getContext()->getView()->request()->getUploadedFiles(); if( ( $file = reset( $files ) ) === false ) { throw new \Aimeos\Controller\ExtJS\Exception( 'No file was uploaded' ); } return $file; }
php
protected function getUploadedFile() { $files = $this->getContext()->getView()->request()->getUploadedFiles(); if( ( $file = reset( $files ) ) === false ) { throw new \Aimeos\Controller\ExtJS\Exception( 'No file was uploaded' ); } return $file; }
[ "protected", "function", "getUploadedFile", "(", ")", "{", "$", "files", "=", "$", "this", "->", "getContext", "(", ")", "->", "getView", "(", ")", "->", "request", "(", ")", "->", "getUploadedFiles", "(", ")", ";", "if", "(", "(", "$", "file", "=", "reset", "(", "$", "files", ")", ")", "===", "false", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "ExtJS", "\\", "Exception", "(", "'No file was uploaded'", ")", ";", "}", "return", "$", "file", ";", "}" ]
Returns the PHP file information of the uploaded file @return Psr\Http\Message\UploadedFileInterface Uploaded file @throws \Aimeos\Controller\ExtJS\Exception If no file upload is available
[ "Returns", "the", "PHP", "file", "information", "of", "the", "uploaded", "file" ]
594ee7cec90fd63a4773c05c93f353e66d9b3408
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Media/Standard.php#L215-L224
234,757
shopgate/cart-integration-sdk
src/models/catalog/Product.php
Shopgate_Model_Catalog_Product.addAttributeGroup
public function addAttributeGroup($attributeGroup) { $attributesGroups = $this->getAttributeGroups(); array_push($attributesGroups, $attributeGroup); $this->setAttributeGroups($attributesGroups); }
php
public function addAttributeGroup($attributeGroup) { $attributesGroups = $this->getAttributeGroups(); array_push($attributesGroups, $attributeGroup); $this->setAttributeGroups($attributesGroups); }
[ "public", "function", "addAttributeGroup", "(", "$", "attributeGroup", ")", "{", "$", "attributesGroups", "=", "$", "this", "->", "getAttributeGroups", "(", ")", ";", "array_push", "(", "$", "attributesGroups", ",", "$", "attributeGroup", ")", ";", "$", "this", "->", "setAttributeGroups", "(", "$", "attributesGroups", ")", ";", "}" ]
add attribute group @param Shopgate_Model_Catalog_AttributeGroup $attributeGroup
[ "add", "attribute", "group" ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L546-L551
234,758
shopgate/cart-integration-sdk
src/models/catalog/Product.php
Shopgate_Model_Catalog_Product.addAttribute
public function addAttribute($attribute) { $attributes = $this->getAttributes(); array_push($attributes, $attribute); $this->setAttributes($attributes); }
php
public function addAttribute($attribute) { $attributes = $this->getAttributes(); array_push($attributes, $attribute); $this->setAttributes($attributes); }
[ "public", "function", "addAttribute", "(", "$", "attribute", ")", "{", "$", "attributes", "=", "$", "this", "->", "getAttributes", "(", ")", ";", "array_push", "(", "$", "attributes", ",", "$", "attribute", ")", ";", "$", "this", "->", "setAttributes", "(", "$", "attributes", ")", ";", "}" ]
add attribute option @param Shopgate_Model_Catalog_Attribute $attribute
[ "add", "attribute", "option" ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L618-L623
234,759
accompli/accompli
src/Task/SSHAgentTask.php
SSHAgentTask.onPrepareWorkspaceInitializeSSHAgent
public function onPrepareWorkspaceInitializeSSHAgent(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher) { $this->host = $event->getHost(); $connection = $this->ensureConnection($this->host); $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Initializing SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS))); $result = $connection->executeCommand('eval $(ssh-agent)'); if ($result->isSuccessful()) { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Initialized SSH agent. {output}', $eventName, $this, array('output' => trim($result->getOutput()), 'event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true))); foreach ($this->keys as $key) { $this->addKeyToSSHAgent($event->getWorkspace(), $connection, $key, $eventName, $eventDispatcher); } } else { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed initializing SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true))); } }
php
public function onPrepareWorkspaceInitializeSSHAgent(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher) { $this->host = $event->getHost(); $connection = $this->ensureConnection($this->host); $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Initializing SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS))); $result = $connection->executeCommand('eval $(ssh-agent)'); if ($result->isSuccessful()) { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Initialized SSH agent. {output}', $eventName, $this, array('output' => trim($result->getOutput()), 'event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true))); foreach ($this->keys as $key) { $this->addKeyToSSHAgent($event->getWorkspace(), $connection, $key, $eventName, $eventDispatcher); } } else { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed initializing SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true))); } }
[ "public", "function", "onPrepareWorkspaceInitializeSSHAgent", "(", "WorkspaceEvent", "$", "event", ",", "$", "eventName", ",", "EventDispatcherInterface", "$", "eventDispatcher", ")", "{", "$", "this", "->", "host", "=", "$", "event", "->", "getHost", "(", ")", ";", "$", "connection", "=", "$", "this", "->", "ensureConnection", "(", "$", "this", "->", "host", ")", ";", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "NOTICE", ",", "'Initializing SSH agent...'", ",", "$", "eventName", ",", "$", "this", ",", "array", "(", "'event.task.action'", "=>", "TaskInterface", "::", "ACTION_IN_PROGRESS", ")", ")", ")", ";", "$", "result", "=", "$", "connection", "->", "executeCommand", "(", "'eval $(ssh-agent)'", ")", ";", "if", "(", "$", "result", "->", "isSuccessful", "(", ")", ")", "{", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "NOTICE", ",", "'Initialized SSH agent. {output}'", ",", "$", "eventName", ",", "$", "this", ",", "array", "(", "'output'", "=>", "trim", "(", "$", "result", "->", "getOutput", "(", ")", ")", ",", "'event.task.action'", "=>", "TaskInterface", "::", "ACTION_COMPLETED", ",", "'output.resetLine'", "=>", "true", ")", ")", ")", ";", "foreach", "(", "$", "this", "->", "keys", "as", "$", "key", ")", "{", "$", "this", "->", "addKeyToSSHAgent", "(", "$", "event", "->", "getWorkspace", "(", ")", ",", "$", "connection", ",", "$", "key", ",", "$", "eventName", ",", "$", "eventDispatcher", ")", ";", "}", "}", "else", "{", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "WARNING", ",", "'Failed initializing SSH agent.'", ",", "$", "eventName", ",", "$", "this", ",", "array", "(", "'event.task.action'", "=>", "TaskInterface", "::", "ACTION_FAILED", ",", "'output.resetLine'", "=>", "true", ")", ")", ")", ";", "}", "}" ]
Initializes the SSH agent and adds the configured keys. @param WorkspaceEvent $event @param string $eventName @param EventDispatcherInterface $eventDispatcher
[ "Initializes", "the", "SSH", "agent", "and", "adds", "the", "configured", "keys", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/SSHAgentTask.php#L71-L89
234,760
accompli/accompli
src/Task/SSHAgentTask.php
SSHAgentTask.onInstallReleaseCompleteOrFailedShutdownSSHAgent
public function onInstallReleaseCompleteOrFailedShutdownSSHAgent(Event $event, $eventName, EventDispatcherInterface $eventDispatcher) { if ($this->host instanceof Host) { $connection = $this->ensureConnection($this->host); $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Terminating SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS))); $result = $connection->executeCommand('eval $(ssh-agent -k)'); if ($result->isSuccessful()) { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Terminated SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true))); } else { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed terminating SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true))); } } }
php
public function onInstallReleaseCompleteOrFailedShutdownSSHAgent(Event $event, $eventName, EventDispatcherInterface $eventDispatcher) { if ($this->host instanceof Host) { $connection = $this->ensureConnection($this->host); $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Terminating SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS))); $result = $connection->executeCommand('eval $(ssh-agent -k)'); if ($result->isSuccessful()) { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Terminated SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true))); } else { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed terminating SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true))); } } }
[ "public", "function", "onInstallReleaseCompleteOrFailedShutdownSSHAgent", "(", "Event", "$", "event", ",", "$", "eventName", ",", "EventDispatcherInterface", "$", "eventDispatcher", ")", "{", "if", "(", "$", "this", "->", "host", "instanceof", "Host", ")", "{", "$", "connection", "=", "$", "this", "->", "ensureConnection", "(", "$", "this", "->", "host", ")", ";", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "NOTICE", ",", "'Terminating SSH agent...'", ",", "$", "eventName", ",", "$", "this", ",", "array", "(", "'event.task.action'", "=>", "TaskInterface", "::", "ACTION_IN_PROGRESS", ")", ")", ")", ";", "$", "result", "=", "$", "connection", "->", "executeCommand", "(", "'eval $(ssh-agent -k)'", ")", ";", "if", "(", "$", "result", "->", "isSuccessful", "(", ")", ")", "{", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "NOTICE", ",", "'Terminated SSH agent.'", ",", "$", "eventName", ",", "$", "this", ",", "array", "(", "'event.task.action'", "=>", "TaskInterface", "::", "ACTION_COMPLETED", ",", "'output.resetLine'", "=>", "true", ")", ")", ")", ";", "}", "else", "{", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "WARNING", ",", "'Failed terminating SSH agent.'", ",", "$", "eventName", ",", "$", "this", ",", "array", "(", "'event.task.action'", "=>", "TaskInterface", "::", "ACTION_FAILED", ",", "'output.resetLine'", "=>", "true", ")", ")", ")", ";", "}", "}", "}" ]
Terminates SSH agent after release installation is successful or has failed. @param Event $event @param string $eventName @param EventDispatcherInterface $eventDispatcher
[ "Terminates", "SSH", "agent", "after", "release", "installation", "is", "successful", "or", "has", "failed", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/SSHAgentTask.php#L98-L112
234,761
accompli/accompli
src/Task/SSHAgentTask.php
SSHAgentTask.addKeyToSSHAgent
private function addKeyToSSHAgent(Workspace $workspace, ConnectionAdapterInterface $connection, $key, $eventName, EventDispatcherInterface $eventDispatcher) { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Adding key to SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS))); $keyFile = $workspace->getHost()->getPath().'/tmp.key'; if ($connection->createFile($keyFile, 0700) && $connection->putContents($keyFile, $key)) { $result = $connection->executeCommand('ssh-add', array($keyFile)); if ($result->isSuccessful()) { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Added key to SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true))); } $connection->delete($keyFile); if ($result->isSuccessful()) { return; } } $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Failed adding key to SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true))); }
php
private function addKeyToSSHAgent(Workspace $workspace, ConnectionAdapterInterface $connection, $key, $eventName, EventDispatcherInterface $eventDispatcher) { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Adding key to SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS))); $keyFile = $workspace->getHost()->getPath().'/tmp.key'; if ($connection->createFile($keyFile, 0700) && $connection->putContents($keyFile, $key)) { $result = $connection->executeCommand('ssh-add', array($keyFile)); if ($result->isSuccessful()) { $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Added key to SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true))); } $connection->delete($keyFile); if ($result->isSuccessful()) { return; } } $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Failed adding key to SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true))); }
[ "private", "function", "addKeyToSSHAgent", "(", "Workspace", "$", "workspace", ",", "ConnectionAdapterInterface", "$", "connection", ",", "$", "key", ",", "$", "eventName", ",", "EventDispatcherInterface", "$", "eventDispatcher", ")", "{", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "INFO", ",", "'Adding key to SSH agent...'", ",", "$", "eventName", ",", "$", "this", ",", "array", "(", "'event.task.action'", "=>", "TaskInterface", "::", "ACTION_IN_PROGRESS", ")", ")", ")", ";", "$", "keyFile", "=", "$", "workspace", "->", "getHost", "(", ")", "->", "getPath", "(", ")", ".", "'/tmp.key'", ";", "if", "(", "$", "connection", "->", "createFile", "(", "$", "keyFile", ",", "0700", ")", "&&", "$", "connection", "->", "putContents", "(", "$", "keyFile", ",", "$", "key", ")", ")", "{", "$", "result", "=", "$", "connection", "->", "executeCommand", "(", "'ssh-add'", ",", "array", "(", "$", "keyFile", ")", ")", ";", "if", "(", "$", "result", "->", "isSuccessful", "(", ")", ")", "{", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "INFO", ",", "'Added key to SSH agent.'", ",", "$", "eventName", ",", "$", "this", ",", "array", "(", "'event.task.action'", "=>", "TaskInterface", "::", "ACTION_COMPLETED", ",", "'output.resetLine'", "=>", "true", ")", ")", ")", ";", "}", "$", "connection", "->", "delete", "(", "$", "keyFile", ")", ";", "if", "(", "$", "result", "->", "isSuccessful", "(", ")", ")", "{", "return", ";", "}", "}", "$", "eventDispatcher", "->", "dispatch", "(", "AccompliEvents", "::", "LOG", ",", "new", "LogEvent", "(", "LogLevel", "::", "INFO", ",", "'Failed adding key to SSH agent.'", ",", "$", "eventName", ",", "$", "this", ",", "array", "(", "'event.task.action'", "=>", "TaskInterface", "::", "ACTION_FAILED", ",", "'output.resetLine'", "=>", "true", ")", ")", ")", ";", "}" ]
Adds an SSH key to the initialized SSH agent. @param Workspace $workspace @param ConnectionAdapterInterface $connection @param string $key @param string $eventName @param EventDispatcherInterface $eventDispatcher
[ "Adds", "an", "SSH", "key", "to", "the", "initialized", "SSH", "agent", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/SSHAgentTask.php#L123-L142
234,762
runcmf/runbb
src/RunBB/Model/Userlist.php
Userlist.fetchUserCount
public function fetchUserCount($username, $show_group) { // Fetch user count $num_users = DB::forTable('users') ->tableAlias('u') ->whereGt('u.id', 1) ->whereNotEqual('u.group_id', ForumEnv::get('FEATHER_UNVERIFIED')); if ($username != '') { $num_users = $num_users->whereLike('u.username', str_replace('*', '%', $username)); } if ($show_group > -1) { $num_users = $num_users->where('u.group_id', $show_group); } $num_users = $num_users->count('id'); $num_users = Container::get('hooks')->fire('model.userlist.fetch_user_count', $num_users); return $num_users; }
php
public function fetchUserCount($username, $show_group) { // Fetch user count $num_users = DB::forTable('users') ->tableAlias('u') ->whereGt('u.id', 1) ->whereNotEqual('u.group_id', ForumEnv::get('FEATHER_UNVERIFIED')); if ($username != '') { $num_users = $num_users->whereLike('u.username', str_replace('*', '%', $username)); } if ($show_group > -1) { $num_users = $num_users->where('u.group_id', $show_group); } $num_users = $num_users->count('id'); $num_users = Container::get('hooks')->fire('model.userlist.fetch_user_count', $num_users); return $num_users; }
[ "public", "function", "fetchUserCount", "(", "$", "username", ",", "$", "show_group", ")", "{", "// Fetch user count", "$", "num_users", "=", "DB", "::", "forTable", "(", "'users'", ")", "->", "tableAlias", "(", "'u'", ")", "->", "whereGt", "(", "'u.id'", ",", "1", ")", "->", "whereNotEqual", "(", "'u.group_id'", ",", "ForumEnv", "::", "get", "(", "'FEATHER_UNVERIFIED'", ")", ")", ";", "if", "(", "$", "username", "!=", "''", ")", "{", "$", "num_users", "=", "$", "num_users", "->", "whereLike", "(", "'u.username'", ",", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "username", ")", ")", ";", "}", "if", "(", "$", "show_group", ">", "-", "1", ")", "{", "$", "num_users", "=", "$", "num_users", "->", "where", "(", "'u.group_id'", ",", "$", "show_group", ")", ";", "}", "$", "num_users", "=", "$", "num_users", "->", "count", "(", "'id'", ")", ";", "$", "num_users", "=", "Container", "::", "get", "(", "'hooks'", ")", "->", "fire", "(", "'model.userlist.fetch_user_count'", ",", "$", "num_users", ")", ";", "return", "$", "num_users", ";", "}" ]
Counts the number of user for a specific query
[ "Counts", "the", "number", "of", "user", "for", "a", "specific", "query" ]
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Userlist.php#L17-L37
234,763
runcmf/runbb
src/RunBB/Model/Userlist.php
Userlist.generateDropdownMenu
public function generateDropdownMenu($show_group) { $show_group = Container::get('hooks')->fire('model.userlist.generate_dropdown_menu_start', $show_group); $dropdown_menu = ''; $result['select'] = ['g_id', 'g_title']; $result = DB::forTable('groups') ->selectMany($result['select']) ->whereNotEqual('g_id', ForumEnv::get('FEATHER_GUEST')) ->orderByExpr('g_id'); $result = Container::get('hooks')->fireDB('model.userlist.generate_dropdown_menu_query', $result); $result = $result->findMany(); foreach ($result as $cur_group) { if ($cur_group['g_id'] == $show_group) { $dropdown_menu .= "\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '" selected="selected">' . Utils::escape($cur_group['g_title']) . '</option>' . "\n"; } else { $dropdown_menu .= "\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '">' . Utils::escape($cur_group['g_title']) . '</option>' . "\n"; } } $dropdown_menu = Container::get('hooks')->fire('model.userlist.generate_dropdown_menu', $dropdown_menu); return $dropdown_menu; }
php
public function generateDropdownMenu($show_group) { $show_group = Container::get('hooks')->fire('model.userlist.generate_dropdown_menu_start', $show_group); $dropdown_menu = ''; $result['select'] = ['g_id', 'g_title']; $result = DB::forTable('groups') ->selectMany($result['select']) ->whereNotEqual('g_id', ForumEnv::get('FEATHER_GUEST')) ->orderByExpr('g_id'); $result = Container::get('hooks')->fireDB('model.userlist.generate_dropdown_menu_query', $result); $result = $result->findMany(); foreach ($result as $cur_group) { if ($cur_group['g_id'] == $show_group) { $dropdown_menu .= "\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '" selected="selected">' . Utils::escape($cur_group['g_title']) . '</option>' . "\n"; } else { $dropdown_menu .= "\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '">' . Utils::escape($cur_group['g_title']) . '</option>' . "\n"; } } $dropdown_menu = Container::get('hooks')->fire('model.userlist.generate_dropdown_menu', $dropdown_menu); return $dropdown_menu; }
[ "public", "function", "generateDropdownMenu", "(", "$", "show_group", ")", "{", "$", "show_group", "=", "Container", "::", "get", "(", "'hooks'", ")", "->", "fire", "(", "'model.userlist.generate_dropdown_menu_start'", ",", "$", "show_group", ")", ";", "$", "dropdown_menu", "=", "''", ";", "$", "result", "[", "'select'", "]", "=", "[", "'g_id'", ",", "'g_title'", "]", ";", "$", "result", "=", "DB", "::", "forTable", "(", "'groups'", ")", "->", "selectMany", "(", "$", "result", "[", "'select'", "]", ")", "->", "whereNotEqual", "(", "'g_id'", ",", "ForumEnv", "::", "get", "(", "'FEATHER_GUEST'", ")", ")", "->", "orderByExpr", "(", "'g_id'", ")", ";", "$", "result", "=", "Container", "::", "get", "(", "'hooks'", ")", "->", "fireDB", "(", "'model.userlist.generate_dropdown_menu_query'", ",", "$", "result", ")", ";", "$", "result", "=", "$", "result", "->", "findMany", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "cur_group", ")", "{", "if", "(", "$", "cur_group", "[", "'g_id'", "]", "==", "$", "show_group", ")", "{", "$", "dropdown_menu", ".=", "\"\\t\\t\\t\\t\\t\\t\\t\"", ".", "'<option value=\"'", ".", "$", "cur_group", "[", "'g_id'", "]", ".", "'\" selected=\"selected\">'", ".", "Utils", "::", "escape", "(", "$", "cur_group", "[", "'g_title'", "]", ")", ".", "'</option>'", ".", "\"\\n\"", ";", "}", "else", "{", "$", "dropdown_menu", ".=", "\"\\t\\t\\t\\t\\t\\t\\t\"", ".", "'<option value=\"'", ".", "$", "cur_group", "[", "'g_id'", "]", ".", "'\">'", ".", "Utils", "::", "escape", "(", "$", "cur_group", "[", "'g_title'", "]", ")", ".", "'</option>'", ".", "\"\\n\"", ";", "}", "}", "$", "dropdown_menu", "=", "Container", "::", "get", "(", "'hooks'", ")", "->", "fire", "(", "'model.userlist.generate_dropdown_menu'", ",", "$", "dropdown_menu", ")", ";", "return", "$", "dropdown_menu", ";", "}" ]
Generates the dropdown menu containing groups
[ "Generates", "the", "dropdown", "menu", "containing", "groups" ]
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Userlist.php#L40-L68
234,764
runcmf/runbb
src/RunBB/Model/Userlist.php
Userlist.printUsers
public function printUsers($username, $start_from, $sort_by, $sort_dir, $show_group) { $userlist_data = []; $username = Container::get('hooks') ->fire('model.userlist.print_users_start', $username, $start_from, $sort_by, $sort_dir, $show_group); // Retrieve a list of user IDs, LIMIT is (really) expensive so we only fetch the // IDs here then later fetch the remaining data $result = DB::forTable('users') ->select('u.id') ->tableAlias('u') ->whereGt('u.id', 1) ->whereNotEqual('u.group_id', ForumEnv::get('FEATHER_UNVERIFIED')); if ($username != '') { $result = $result->whereLike('u.username', str_replace('*', '%', $username)); } if ($show_group > -1) { $result = $result->where('u.group_id', $show_group); } $result = $result->orderByExpr($sort_by . ' ' . $sort_dir) ->orderByAsc('u.id') ->limit(50) ->offset($start_from); $result = Container::get('hooks')->fireDB('model.userlist.print_users_query', $result); $result = $result->findMany(); if ($result) { $user_ids = []; foreach ($result as $cur_user_id) { $user_ids[] = $cur_user_id['id']; } // Grab the users $result['select'] = ['u.id', 'u.username', 'u.title', 'u.num_posts', 'u.registered', 'g.g_id', 'g.g_user_title']; $result = DB::forTable('users') ->tableAlias('u') ->selectMany($result['select']) ->leftOuterJoin(DB::prefix() . 'groups', ['g.g_id', '=', 'u.group_id'], 'g') ->whereIn('u.id', $user_ids) ->orderByExpr($sort_by . ' ' . $sort_dir) ->orderByAsc('u.id'); $result = Container::get('hooks')->fireDB('model.userlist.print_users_grab_query', $result); $result = $result->find_many(); foreach ($result as $user_data) { $userlist_data[] = $user_data; } } $userlist_data = Container::get('hooks')->fire('model.userlist.print_users', $userlist_data); return $userlist_data; }
php
public function printUsers($username, $start_from, $sort_by, $sort_dir, $show_group) { $userlist_data = []; $username = Container::get('hooks') ->fire('model.userlist.print_users_start', $username, $start_from, $sort_by, $sort_dir, $show_group); // Retrieve a list of user IDs, LIMIT is (really) expensive so we only fetch the // IDs here then later fetch the remaining data $result = DB::forTable('users') ->select('u.id') ->tableAlias('u') ->whereGt('u.id', 1) ->whereNotEqual('u.group_id', ForumEnv::get('FEATHER_UNVERIFIED')); if ($username != '') { $result = $result->whereLike('u.username', str_replace('*', '%', $username)); } if ($show_group > -1) { $result = $result->where('u.group_id', $show_group); } $result = $result->orderByExpr($sort_by . ' ' . $sort_dir) ->orderByAsc('u.id') ->limit(50) ->offset($start_from); $result = Container::get('hooks')->fireDB('model.userlist.print_users_query', $result); $result = $result->findMany(); if ($result) { $user_ids = []; foreach ($result as $cur_user_id) { $user_ids[] = $cur_user_id['id']; } // Grab the users $result['select'] = ['u.id', 'u.username', 'u.title', 'u.num_posts', 'u.registered', 'g.g_id', 'g.g_user_title']; $result = DB::forTable('users') ->tableAlias('u') ->selectMany($result['select']) ->leftOuterJoin(DB::prefix() . 'groups', ['g.g_id', '=', 'u.group_id'], 'g') ->whereIn('u.id', $user_ids) ->orderByExpr($sort_by . ' ' . $sort_dir) ->orderByAsc('u.id'); $result = Container::get('hooks')->fireDB('model.userlist.print_users_grab_query', $result); $result = $result->find_many(); foreach ($result as $user_data) { $userlist_data[] = $user_data; } } $userlist_data = Container::get('hooks')->fire('model.userlist.print_users', $userlist_data); return $userlist_data; }
[ "public", "function", "printUsers", "(", "$", "username", ",", "$", "start_from", ",", "$", "sort_by", ",", "$", "sort_dir", ",", "$", "show_group", ")", "{", "$", "userlist_data", "=", "[", "]", ";", "$", "username", "=", "Container", "::", "get", "(", "'hooks'", ")", "->", "fire", "(", "'model.userlist.print_users_start'", ",", "$", "username", ",", "$", "start_from", ",", "$", "sort_by", ",", "$", "sort_dir", ",", "$", "show_group", ")", ";", "// Retrieve a list of user IDs, LIMIT is (really) expensive so we only fetch the", "// IDs here then later fetch the remaining data", "$", "result", "=", "DB", "::", "forTable", "(", "'users'", ")", "->", "select", "(", "'u.id'", ")", "->", "tableAlias", "(", "'u'", ")", "->", "whereGt", "(", "'u.id'", ",", "1", ")", "->", "whereNotEqual", "(", "'u.group_id'", ",", "ForumEnv", "::", "get", "(", "'FEATHER_UNVERIFIED'", ")", ")", ";", "if", "(", "$", "username", "!=", "''", ")", "{", "$", "result", "=", "$", "result", "->", "whereLike", "(", "'u.username'", ",", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "username", ")", ")", ";", "}", "if", "(", "$", "show_group", ">", "-", "1", ")", "{", "$", "result", "=", "$", "result", "->", "where", "(", "'u.group_id'", ",", "$", "show_group", ")", ";", "}", "$", "result", "=", "$", "result", "->", "orderByExpr", "(", "$", "sort_by", ".", "' '", ".", "$", "sort_dir", ")", "->", "orderByAsc", "(", "'u.id'", ")", "->", "limit", "(", "50", ")", "->", "offset", "(", "$", "start_from", ")", ";", "$", "result", "=", "Container", "::", "get", "(", "'hooks'", ")", "->", "fireDB", "(", "'model.userlist.print_users_query'", ",", "$", "result", ")", ";", "$", "result", "=", "$", "result", "->", "findMany", "(", ")", ";", "if", "(", "$", "result", ")", "{", "$", "user_ids", "=", "[", "]", ";", "foreach", "(", "$", "result", "as", "$", "cur_user_id", ")", "{", "$", "user_ids", "[", "]", "=", "$", "cur_user_id", "[", "'id'", "]", ";", "}", "// Grab the users", "$", "result", "[", "'select'", "]", "=", "[", "'u.id'", ",", "'u.username'", ",", "'u.title'", ",", "'u.num_posts'", ",", "'u.registered'", ",", "'g.g_id'", ",", "'g.g_user_title'", "]", ";", "$", "result", "=", "DB", "::", "forTable", "(", "'users'", ")", "->", "tableAlias", "(", "'u'", ")", "->", "selectMany", "(", "$", "result", "[", "'select'", "]", ")", "->", "leftOuterJoin", "(", "DB", "::", "prefix", "(", ")", ".", "'groups'", ",", "[", "'g.g_id'", ",", "'='", ",", "'u.group_id'", "]", ",", "'g'", ")", "->", "whereIn", "(", "'u.id'", ",", "$", "user_ids", ")", "->", "orderByExpr", "(", "$", "sort_by", ".", "' '", ".", "$", "sort_dir", ")", "->", "orderByAsc", "(", "'u.id'", ")", ";", "$", "result", "=", "Container", "::", "get", "(", "'hooks'", ")", "->", "fireDB", "(", "'model.userlist.print_users_grab_query'", ",", "$", "result", ")", ";", "$", "result", "=", "$", "result", "->", "find_many", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "user_data", ")", "{", "$", "userlist_data", "[", "]", "=", "$", "user_data", ";", "}", "}", "$", "userlist_data", "=", "Container", "::", "get", "(", "'hooks'", ")", "->", "fire", "(", "'model.userlist.print_users'", ",", "$", "userlist_data", ")", ";", "return", "$", "userlist_data", ";", "}" ]
Prints the users
[ "Prints", "the", "users" ]
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Userlist.php#L71-L129
234,765
makinacorpus/drupal-ucms
ucms_contrib/src/Form/NodeDuplicate.php
NodeDuplicate.submitForm
public function submitForm(array &$form, FormStateInterface $form_state) { $node = $form_state->getTemporaryValue('node'); $action = $form_state->getValue('action'); $siteId = $form_state->getValue('site'); $options = []; if (isset($_GET['destination'])) { $options['query']['destination'] = $_GET['destination']; unset($_GET['destination']); } switch ($action) { case 'duplicate': list($path, $options) = $this->siteManager->getUrlGenerator()->getRouteAndParams($siteId, 'node/' . $node->id(). '/clone', $options); drupal_set_message($this->t("You can now edit this node on this site, it will be automatically duplicated.")); break; default: $path = 'node/' . $node->id() . '/edit'; drupal_set_message($this->t("You are now editing the global content for all sites.")); break; } $form_state->setRedirect($path, $options); }
php
public function submitForm(array &$form, FormStateInterface $form_state) { $node = $form_state->getTemporaryValue('node'); $action = $form_state->getValue('action'); $siteId = $form_state->getValue('site'); $options = []; if (isset($_GET['destination'])) { $options['query']['destination'] = $_GET['destination']; unset($_GET['destination']); } switch ($action) { case 'duplicate': list($path, $options) = $this->siteManager->getUrlGenerator()->getRouteAndParams($siteId, 'node/' . $node->id(). '/clone', $options); drupal_set_message($this->t("You can now edit this node on this site, it will be automatically duplicated.")); break; default: $path = 'node/' . $node->id() . '/edit'; drupal_set_message($this->t("You are now editing the global content for all sites.")); break; } $form_state->setRedirect($path, $options); }
[ "public", "function", "submitForm", "(", "array", "&", "$", "form", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "node", "=", "$", "form_state", "->", "getTemporaryValue", "(", "'node'", ")", ";", "$", "action", "=", "$", "form_state", "->", "getValue", "(", "'action'", ")", ";", "$", "siteId", "=", "$", "form_state", "->", "getValue", "(", "'site'", ")", ";", "$", "options", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "_GET", "[", "'destination'", "]", ")", ")", "{", "$", "options", "[", "'query'", "]", "[", "'destination'", "]", "=", "$", "_GET", "[", "'destination'", "]", ";", "unset", "(", "$", "_GET", "[", "'destination'", "]", ")", ";", "}", "switch", "(", "$", "action", ")", "{", "case", "'duplicate'", ":", "list", "(", "$", "path", ",", "$", "options", ")", "=", "$", "this", "->", "siteManager", "->", "getUrlGenerator", "(", ")", "->", "getRouteAndParams", "(", "$", "siteId", ",", "'node/'", ".", "$", "node", "->", "id", "(", ")", ".", "'/clone'", ",", "$", "options", ")", ";", "drupal_set_message", "(", "$", "this", "->", "t", "(", "\"You can now edit this node on this site, it will be automatically duplicated.\"", ")", ")", ";", "break", ";", "default", ":", "$", "path", "=", "'node/'", ".", "$", "node", "->", "id", "(", ")", ".", "'/edit'", ";", "drupal_set_message", "(", "$", "this", "->", "t", "(", "\"You are now editing the global content for all sites.\"", ")", ")", ";", "break", ";", "}", "$", "form_state", "->", "setRedirect", "(", "$", "path", ",", "$", "options", ")", ";", "}" ]
Duplicate in context submit.
[ "Duplicate", "in", "context", "submit", "." ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_contrib/src/Form/NodeDuplicate.php#L158-L184
234,766
runcmf/runbb
src/RunBB/Core/Lister.php
Lister.getPlugins
public static function getPlugins(array $list = []) { $plugins = []; if (!empty($list)) { foreach ($list as $plug) { if (class_exists($plug['class'])) { $plugins[] = json_decode($plug['class']::getInfo()); } } } return $plugins; }
php
public static function getPlugins(array $list = []) { $plugins = []; if (!empty($list)) { foreach ($list as $plug) { if (class_exists($plug['class'])) { $plugins[] = json_decode($plug['class']::getInfo()); } } } return $plugins; }
[ "public", "static", "function", "getPlugins", "(", "array", "$", "list", "=", "[", "]", ")", "{", "$", "plugins", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "list", ")", ")", "{", "foreach", "(", "$", "list", "as", "$", "plug", ")", "{", "if", "(", "class_exists", "(", "$", "plug", "[", "'class'", "]", ")", ")", "{", "$", "plugins", "[", "]", "=", "json_decode", "(", "$", "plug", "[", "'class'", "]", "::", "getInfo", "(", ")", ")", ";", "}", "}", "}", "return", "$", "plugins", ";", "}" ]
Get all valid plugin files. @param array $list @return array
[ "Get", "all", "valid", "plugin", "files", "." ]
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Lister.php#L19-L32
234,767
runcmf/runbb
src/RunBB/Core/Lister.php
Lister.getOfficialPlugins
public static function getOfficialPlugins() { $plugins = []; // Get the official list from the website $content = json_decode(AdminUtils::getContent('http://featherbb.org/plugins.json')); // If internet is available if (!is_null($content)) { foreach ($content as $plugin) { // Get information from each repo // TODO: cache $plugins[] = json_decode( AdminUtils::getContent( 'https://raw.githubusercontent.com/featherbb/'.$plugin.'/master/featherbb.json' ) ); } } return $plugins; }
php
public static function getOfficialPlugins() { $plugins = []; // Get the official list from the website $content = json_decode(AdminUtils::getContent('http://featherbb.org/plugins.json')); // If internet is available if (!is_null($content)) { foreach ($content as $plugin) { // Get information from each repo // TODO: cache $plugins[] = json_decode( AdminUtils::getContent( 'https://raw.githubusercontent.com/featherbb/'.$plugin.'/master/featherbb.json' ) ); } } return $plugins; }
[ "public", "static", "function", "getOfficialPlugins", "(", ")", "{", "$", "plugins", "=", "[", "]", ";", "// Get the official list from the website", "$", "content", "=", "json_decode", "(", "AdminUtils", "::", "getContent", "(", "'http://featherbb.org/plugins.json'", ")", ")", ";", "// If internet is available", "if", "(", "!", "is_null", "(", "$", "content", ")", ")", "{", "foreach", "(", "$", "content", "as", "$", "plugin", ")", "{", "// Get information from each repo", "// TODO: cache", "$", "plugins", "[", "]", "=", "json_decode", "(", "AdminUtils", "::", "getContent", "(", "'https://raw.githubusercontent.com/featherbb/'", ".", "$", "plugin", ".", "'/master/featherbb.json'", ")", ")", ";", "}", "}", "return", "$", "plugins", ";", "}" ]
Get all official plugins using GitHub API
[ "Get", "all", "official", "plugins", "using", "GitHub", "API" ]
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Lister.php#L37-L58
234,768
runcmf/runbb
src/RunBB/Core/Lister.php
Lister.getStyles
public static function getStyles() { $styles = []; $iterator = new \DirectoryIterator(ForumEnv::get('WEB_ROOT').'themes/'); foreach ($iterator as $child) { if (!$child->isDot() && $child->isDir() && file_exists($child->getPathname().DIRECTORY_SEPARATOR.'style.css')) { // If the theme is well formed, add it to the list $styles[] = $child->getFileName(); } } natcasesort($styles); return $styles; }
php
public static function getStyles() { $styles = []; $iterator = new \DirectoryIterator(ForumEnv::get('WEB_ROOT').'themes/'); foreach ($iterator as $child) { if (!$child->isDot() && $child->isDir() && file_exists($child->getPathname().DIRECTORY_SEPARATOR.'style.css')) { // If the theme is well formed, add it to the list $styles[] = $child->getFileName(); } } natcasesort($styles); return $styles; }
[ "public", "static", "function", "getStyles", "(", ")", "{", "$", "styles", "=", "[", "]", ";", "$", "iterator", "=", "new", "\\", "DirectoryIterator", "(", "ForumEnv", "::", "get", "(", "'WEB_ROOT'", ")", ".", "'themes/'", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "child", ")", "{", "if", "(", "!", "$", "child", "->", "isDot", "(", ")", "&&", "$", "child", "->", "isDir", "(", ")", "&&", "file_exists", "(", "$", "child", "->", "getPathname", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "'style.css'", ")", ")", "{", "// If the theme is well formed, add it to the list", "$", "styles", "[", "]", "=", "$", "child", "->", "getFileName", "(", ")", ";", "}", "}", "natcasesort", "(", "$", "styles", ")", ";", "return", "$", "styles", ";", "}" ]
Get available styles
[ "Get", "available", "styles" ]
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Lister.php#L63-L78
234,769
anlutro/laravel-validation
examples/ProjectValidator.php
ProjectValidator.prepareRules
protected function prepareRules(array $rules, array $attributes) { // start and deadline are both optional, but if they're both set, we // want to validate that the deadline is after the start. if (!empty($attributes['start']) && !empty($attributes['deadline'])) { // because we're validating that start and deadline are valid date/ // time strings, we can use the "after" validation rule. $rules['deadline'][] = 'after:' . $attributes['start']; } // always return the modified rules! return $rules; }
php
protected function prepareRules(array $rules, array $attributes) { // start and deadline are both optional, but if they're both set, we // want to validate that the deadline is after the start. if (!empty($attributes['start']) && !empty($attributes['deadline'])) { // because we're validating that start and deadline are valid date/ // time strings, we can use the "after" validation rule. $rules['deadline'][] = 'after:' . $attributes['start']; } // always return the modified rules! return $rules; }
[ "protected", "function", "prepareRules", "(", "array", "$", "rules", ",", "array", "$", "attributes", ")", "{", "// start and deadline are both optional, but if they're both set, we", "// want to validate that the deadline is after the start.", "if", "(", "!", "empty", "(", "$", "attributes", "[", "'start'", "]", ")", "&&", "!", "empty", "(", "$", "attributes", "[", "'deadline'", "]", ")", ")", "{", "// because we're validating that start and deadline are valid date/", "// time strings, we can use the \"after\" validation rule.", "$", "rules", "[", "'deadline'", "]", "[", "]", "=", "'after:'", ".", "$", "attributes", "[", "'start'", "]", ";", "}", "// always return the modified rules!", "return", "$", "rules", ";", "}" ]
Prepare the rules before passing them to the validator.
[ "Prepare", "the", "rules", "before", "passing", "them", "to", "the", "validator", "." ]
fb653cf29f230bf53beda4b35a4e1042d52faaeb
https://github.com/anlutro/laravel-validation/blob/fb653cf29f230bf53beda4b35a4e1042d52faaeb/examples/ProjectValidator.php#L47-L59
234,770
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Supplier/Lists/Factory.php
Factory.createController
public static function createController( \Aimeos\MShop\Context\Item\Iface $context, $name = null ) { /** controller/extjs/supplier/lists/name * Class name of the used ExtJS supplier list controller implementation * * Each default ExtJS controller can be replace by an alternative imlementation. * To use this implementation, you have to set the last part of the class * name as configuration value so the client factory knows which class it * has to instantiate. * * For example, if the name of the default class is * * \Aimeos\Controller\ExtJS\Supplier\Lists\Standard * * and you want to replace it with your own version named * * \Aimeos\Controller\ExtJS\Supplier\Lists\Mylist * * then you have to set the this configuration option: * * controller/extjs/supplier/lists/name = Mylist * * The value is the last part of your own class name and it's case sensitive, * so take care that the configuration value is exactly named like the last * part of the class name. * * The allowed characters of the class name are A-Z, a-z and 0-9. No other * characters are possible! You should always start the last part of the class * name with an upper case character and continue only with lower case characters * or numbers. Avoid chamel case names like "MyList"! * * @param string Last part of the class name * @since 2015.08 * @category Developer */ if( $name === null ) { $name = $context->getConfig()->get( 'controller/extjs/supplier/lists/name', 'Standard' ); } if( ctype_alnum( $name ) === false ) { $classname = is_string( $name ) ? '\\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\' . $name : '<not a string>'; throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); } $iface = '\\Aimeos\\Controller\\ExtJS\\Common\\Iface'; $classname = '\\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\' . $name; $controller = self::createControllerBase( $context, $classname, $iface ); /** controller/extjs/supplier/lists/decorators/excludes * Excludes decorators added by the "common" option from the supplier list ExtJS controllers * * Decorators extend the functionality of a class by adding new aspects * (e.g. log what is currently done), executing the methods of the underlying * class only in certain conditions (e.g. only for logged in users) or * modify what is returned to the caller. * * This option allows you to remove a decorator added via * "controller/extjs/common/decorators/default" before they are wrapped * around the ExtJS controller. * * controller/extjs/supplier/lists/decorators/excludes = array( 'decorator1' ) * * This would remove the decorator named "decorator1" from the list of * common decorators ("\Aimeos\Controller\ExtJS\Common\Decorator\*") added via * "controller/extjs/common/decorators/default" for the admin ExtJS controller. * * @param array List of decorator names * @since 2015.09 * @category Developer * @see controller/extjs/common/decorators/default * @see controller/extjs/supplier/lists/decorators/global * @see controller/extjs/supplier/lists/decorators/local */ /** controller/extjs/supplier/lists/decorators/global * Adds a list of globally available decorators only to the supplier list ExtJS controllers * * Decorators extend the functionality of a class by adding new aspects * (e.g. log what is currently done), executing the methods of the underlying * class only in certain conditions (e.g. only for logged in users) or * modify what is returned to the caller. * * This option allows you to wrap global decorators * ("\Aimeos\Controller\ExtJS\Common\Decorator\*") around the ExtJS controller. * * controller/extjs/supplier/lists/decorators/global = array( 'decorator1' ) * * This would add the decorator named "decorator1" defined by * "\Aimeos\Controller\ExtJS\Common\Decorator\Decorator1" only to the ExtJS controller. * * @param array List of decorator names * @since 2015.09 * @category Developer * @see controller/extjs/common/decorators/default * @see controller/extjs/supplier/lists/decorators/excludes * @see controller/extjs/supplier/lists/decorators/local */ /** controller/extjs/supplier/lists/decorators/local * Adds a list of local decorators only to the supplier list ExtJS controllers * * Decorators extend the functionality of a class by adding new aspects * (e.g. log what is currently done), executing the methods of the underlying * class only in certain conditions (e.g. only for logged in users) or * modify what is returned to the caller. * * This option allows you to wrap local decorators * ("\Aimeos\Controller\ExtJS\Supplier\Lists\Decorator\*") around the ExtJS controller. * * controller/extjs/supplier/lists/decorators/local = array( 'decorator2' ) * * This would add the decorator named "decorator2" defined by * "\Aimeos\Controller\ExtJS\Supplier\Lists\Decorator\Decorator2" only to the ExtJS * controller. * * @param array List of decorator names * @since 2015.09 * @category Developer * @see controller/extjs/common/decorators/default * @see controller/extjs/supplier/lists/decorators/excludes * @see controller/extjs/supplier/lists/decorators/global */ return self::addControllerDecorators( $context, $controller, 'supplier/lists' ); }
php
public static function createController( \Aimeos\MShop\Context\Item\Iface $context, $name = null ) { /** controller/extjs/supplier/lists/name * Class name of the used ExtJS supplier list controller implementation * * Each default ExtJS controller can be replace by an alternative imlementation. * To use this implementation, you have to set the last part of the class * name as configuration value so the client factory knows which class it * has to instantiate. * * For example, if the name of the default class is * * \Aimeos\Controller\ExtJS\Supplier\Lists\Standard * * and you want to replace it with your own version named * * \Aimeos\Controller\ExtJS\Supplier\Lists\Mylist * * then you have to set the this configuration option: * * controller/extjs/supplier/lists/name = Mylist * * The value is the last part of your own class name and it's case sensitive, * so take care that the configuration value is exactly named like the last * part of the class name. * * The allowed characters of the class name are A-Z, a-z and 0-9. No other * characters are possible! You should always start the last part of the class * name with an upper case character and continue only with lower case characters * or numbers. Avoid chamel case names like "MyList"! * * @param string Last part of the class name * @since 2015.08 * @category Developer */ if( $name === null ) { $name = $context->getConfig()->get( 'controller/extjs/supplier/lists/name', 'Standard' ); } if( ctype_alnum( $name ) === false ) { $classname = is_string( $name ) ? '\\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\' . $name : '<not a string>'; throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); } $iface = '\\Aimeos\\Controller\\ExtJS\\Common\\Iface'; $classname = '\\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\' . $name; $controller = self::createControllerBase( $context, $classname, $iface ); /** controller/extjs/supplier/lists/decorators/excludes * Excludes decorators added by the "common" option from the supplier list ExtJS controllers * * Decorators extend the functionality of a class by adding new aspects * (e.g. log what is currently done), executing the methods of the underlying * class only in certain conditions (e.g. only for logged in users) or * modify what is returned to the caller. * * This option allows you to remove a decorator added via * "controller/extjs/common/decorators/default" before they are wrapped * around the ExtJS controller. * * controller/extjs/supplier/lists/decorators/excludes = array( 'decorator1' ) * * This would remove the decorator named "decorator1" from the list of * common decorators ("\Aimeos\Controller\ExtJS\Common\Decorator\*") added via * "controller/extjs/common/decorators/default" for the admin ExtJS controller. * * @param array List of decorator names * @since 2015.09 * @category Developer * @see controller/extjs/common/decorators/default * @see controller/extjs/supplier/lists/decorators/global * @see controller/extjs/supplier/lists/decorators/local */ /** controller/extjs/supplier/lists/decorators/global * Adds a list of globally available decorators only to the supplier list ExtJS controllers * * Decorators extend the functionality of a class by adding new aspects * (e.g. log what is currently done), executing the methods of the underlying * class only in certain conditions (e.g. only for logged in users) or * modify what is returned to the caller. * * This option allows you to wrap global decorators * ("\Aimeos\Controller\ExtJS\Common\Decorator\*") around the ExtJS controller. * * controller/extjs/supplier/lists/decorators/global = array( 'decorator1' ) * * This would add the decorator named "decorator1" defined by * "\Aimeos\Controller\ExtJS\Common\Decorator\Decorator1" only to the ExtJS controller. * * @param array List of decorator names * @since 2015.09 * @category Developer * @see controller/extjs/common/decorators/default * @see controller/extjs/supplier/lists/decorators/excludes * @see controller/extjs/supplier/lists/decorators/local */ /** controller/extjs/supplier/lists/decorators/local * Adds a list of local decorators only to the supplier list ExtJS controllers * * Decorators extend the functionality of a class by adding new aspects * (e.g. log what is currently done), executing the methods of the underlying * class only in certain conditions (e.g. only for logged in users) or * modify what is returned to the caller. * * This option allows you to wrap local decorators * ("\Aimeos\Controller\ExtJS\Supplier\Lists\Decorator\*") around the ExtJS controller. * * controller/extjs/supplier/lists/decorators/local = array( 'decorator2' ) * * This would add the decorator named "decorator2" defined by * "\Aimeos\Controller\ExtJS\Supplier\Lists\Decorator\Decorator2" only to the ExtJS * controller. * * @param array List of decorator names * @since 2015.09 * @category Developer * @see controller/extjs/common/decorators/default * @see controller/extjs/supplier/lists/decorators/excludes * @see controller/extjs/supplier/lists/decorators/global */ return self::addControllerDecorators( $context, $controller, 'supplier/lists' ); }
[ "public", "static", "function", "createController", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Context", "\\", "Item", "\\", "Iface", "$", "context", ",", "$", "name", "=", "null", ")", "{", "/** controller/extjs/supplier/lists/name\n\t\t * Class name of the used ExtJS supplier list controller implementation\n\t\t *\n\t\t * Each default ExtJS controller can be replace by an alternative imlementation.\n\t\t * To use this implementation, you have to set the last part of the class\n\t\t * name as configuration value so the client factory knows which class it\n\t\t * has to instantiate.\n\t\t *\n\t\t * For example, if the name of the default class is\n\t\t *\n\t\t * \\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\Standard\n\t\t *\n\t\t * and you want to replace it with your own version named\n\t\t *\n\t\t * \\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\Mylist\n\t\t *\n\t\t * then you have to set the this configuration option:\n\t\t *\n\t\t * controller/extjs/supplier/lists/name = Mylist\n\t\t *\n\t\t * The value is the last part of your own class name and it's case sensitive,\n\t\t * so take care that the configuration value is exactly named like the last\n\t\t * part of the class name.\n\t\t *\n\t\t * The allowed characters of the class name are A-Z, a-z and 0-9. No other\n\t\t * characters are possible! You should always start the last part of the class\n\t\t * name with an upper case character and continue only with lower case characters\n\t\t * or numbers. Avoid chamel case names like \"MyList\"!\n\t\t *\n\t\t * @param string Last part of the class name\n\t\t * @since 2015.08\n\t\t * @category Developer\n\t\t */", "if", "(", "$", "name", "===", "null", ")", "{", "$", "name", "=", "$", "context", "->", "getConfig", "(", ")", "->", "get", "(", "'controller/extjs/supplier/lists/name'", ",", "'Standard'", ")", ";", "}", "if", "(", "ctype_alnum", "(", "$", "name", ")", "===", "false", ")", "{", "$", "classname", "=", "is_string", "(", "$", "name", ")", "?", "'\\\\Aimeos\\\\Controller\\\\ExtJS\\\\Supplier\\\\Lists\\\\'", ".", "$", "name", ":", "'<not a string>'", ";", "throw", "new", "\\", "Aimeos", "\\", "Controller", "\\", "ExtJS", "\\", "Exception", "(", "sprintf", "(", "'Invalid class name \"%1$s\"'", ",", "$", "classname", ")", ")", ";", "}", "$", "iface", "=", "'\\\\Aimeos\\\\Controller\\\\ExtJS\\\\Common\\\\Iface'", ";", "$", "classname", "=", "'\\\\Aimeos\\\\Controller\\\\ExtJS\\\\Supplier\\\\Lists\\\\'", ".", "$", "name", ";", "$", "controller", "=", "self", "::", "createControllerBase", "(", "$", "context", ",", "$", "classname", ",", "$", "iface", ")", ";", "/** controller/extjs/supplier/lists/decorators/excludes\n\t\t * Excludes decorators added by the \"common\" option from the supplier list ExtJS controllers\n\t\t *\n\t\t * Decorators extend the functionality of a class by adding new aspects\n\t\t * (e.g. log what is currently done), executing the methods of the underlying\n\t\t * class only in certain conditions (e.g. only for logged in users) or\n\t\t * modify what is returned to the caller.\n\t\t *\n\t\t * This option allows you to remove a decorator added via\n\t\t * \"controller/extjs/common/decorators/default\" before they are wrapped\n\t\t * around the ExtJS controller.\n\t\t *\n\t\t * controller/extjs/supplier/lists/decorators/excludes = array( 'decorator1' )\n\t\t *\n\t\t * This would remove the decorator named \"decorator1\" from the list of\n\t\t * common decorators (\"\\Aimeos\\Controller\\ExtJS\\Common\\Decorator\\*\") added via\n\t\t * \"controller/extjs/common/decorators/default\" for the admin ExtJS controller.\n\t\t *\n\t\t * @param array List of decorator names\n\t\t * @since 2015.09\n\t\t * @category Developer\n\t\t * @see controller/extjs/common/decorators/default\n\t\t * @see controller/extjs/supplier/lists/decorators/global\n\t\t * @see controller/extjs/supplier/lists/decorators/local\n\t\t */", "/** controller/extjs/supplier/lists/decorators/global\n\t\t * Adds a list of globally available decorators only to the supplier list ExtJS controllers\n\t\t *\n\t\t * Decorators extend the functionality of a class by adding new aspects\n\t\t * (e.g. log what is currently done), executing the methods of the underlying\n\t\t * class only in certain conditions (e.g. only for logged in users) or\n\t\t * modify what is returned to the caller.\n\t\t *\n\t\t * This option allows you to wrap global decorators\n\t\t * (\"\\Aimeos\\Controller\\ExtJS\\Common\\Decorator\\*\") around the ExtJS controller.\n\t\t *\n\t\t * controller/extjs/supplier/lists/decorators/global = array( 'decorator1' )\n\t\t *\n\t\t * This would add the decorator named \"decorator1\" defined by\n\t\t * \"\\Aimeos\\Controller\\ExtJS\\Common\\Decorator\\Decorator1\" only to the ExtJS controller.\n\t\t *\n\t\t * @param array List of decorator names\n\t\t * @since 2015.09\n\t\t * @category Developer\n\t\t * @see controller/extjs/common/decorators/default\n\t\t * @see controller/extjs/supplier/lists/decorators/excludes\n\t\t * @see controller/extjs/supplier/lists/decorators/local\n\t\t */", "/** controller/extjs/supplier/lists/decorators/local\n\t\t * Adds a list of local decorators only to the supplier list ExtJS controllers\n\t\t *\n\t\t * Decorators extend the functionality of a class by adding new aspects\n\t\t * (e.g. log what is currently done), executing the methods of the underlying\n\t\t * class only in certain conditions (e.g. only for logged in users) or\n\t\t * modify what is returned to the caller.\n\t\t *\n\t\t * This option allows you to wrap local decorators\n\t\t * (\"\\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\Decorator\\*\") around the ExtJS controller.\n\t\t *\n\t\t * controller/extjs/supplier/lists/decorators/local = array( 'decorator2' )\n\t\t *\n\t\t * This would add the decorator named \"decorator2\" defined by\n\t\t * \"\\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\Decorator\\Decorator2\" only to the ExtJS\n\t\t * controller.\n\t\t *\n\t\t * @param array List of decorator names\n\t\t * @since 2015.09\n\t\t * @category Developer\n\t\t * @see controller/extjs/common/decorators/default\n\t\t * @see controller/extjs/supplier/lists/decorators/excludes\n\t\t * @see controller/extjs/supplier/lists/decorators/global\n\t\t */", "return", "self", "::", "addControllerDecorators", "(", "$", "context", ",", "$", "controller", ",", "'supplier/lists'", ")", ";", "}" ]
Creates a new supplier lists controller object. @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects @param string|null $name Name of the controller implementaton (default: "Standard") @return \Aimeos\Controller\ExtJS\Iface Controller object
[ "Creates", "a", "new", "supplier", "lists", "controller", "object", "." ]
594ee7cec90fd63a4773c05c93f353e66d9b3408
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Supplier/Lists/Factory.php#L31-L156
234,771
shopgate/cart-integration-sdk
src/helper/redirect/JsScriptBuilder.php
Shopgate_Helper_Redirect_JsScriptBuilder.setSiteParameters
public function setSiteParameters($params) { foreach ($params as $key => $param) { $this->setSiteParameter($key, $param); } return $this; }
php
public function setSiteParameters($params) { foreach ($params as $key => $param) { $this->setSiteParameter($key, $param); } return $this; }
[ "public", "function", "setSiteParameters", "(", "$", "params", ")", "{", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "param", ")", "{", "$", "this", "->", "setSiteParameter", "(", "$", "key", ",", "$", "param", ")", ";", "}", "return", "$", "this", ";", "}" ]
Helps set all parameters at once @param array $params - array(key => value) @return Shopgate_Helper_Redirect_JsScriptBuilder
[ "Helps", "set", "all", "parameters", "at", "once" ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/redirect/JsScriptBuilder.php#L144-L151
234,772
accompli/accompli
src/Report/AbstractReport.php
AbstractReport.generate
public function generate(ConsoleLoggerInterface $logger) { $logLevel = LogLevel::NOTICE; $style = TitleBlock::STYLE_SUCCESS; if ($this->eventDataCollector->hasCountedFailedEvents()) { $logLevel = LogLevel::ERROR; $style = TitleBlock::STYLE_FAILURE; } elseif ($this->eventDataCollector->hasCountedLogLevel(LogLevel::EMERGENCY) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::ALERT) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::CRITICAL) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::ERROR) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::WARNING)) { $logLevel = LogLevel::WARNING; $style = TitleBlock::STYLE_ERRORED_SUCCESS; } $output = $logger->getOutput($logLevel); $titleBlock = new TitleBlock($output, $this->messages[$style], $style); $titleBlock->render(); $dataCollectorsData = array(); foreach ($this->dataCollectors as $dataCollector) { $data = $dataCollector->getData($logger->getVerbosity()); foreach ($data as $label => $value) { $dataCollectorsData[] = array($label, $value); } } $table = new Table($output); $table->setRows($dataCollectorsData); $table->setStyle('symfony-style-guide'); $table->render(); $output->writeln(''); }
php
public function generate(ConsoleLoggerInterface $logger) { $logLevel = LogLevel::NOTICE; $style = TitleBlock::STYLE_SUCCESS; if ($this->eventDataCollector->hasCountedFailedEvents()) { $logLevel = LogLevel::ERROR; $style = TitleBlock::STYLE_FAILURE; } elseif ($this->eventDataCollector->hasCountedLogLevel(LogLevel::EMERGENCY) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::ALERT) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::CRITICAL) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::ERROR) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::WARNING)) { $logLevel = LogLevel::WARNING; $style = TitleBlock::STYLE_ERRORED_SUCCESS; } $output = $logger->getOutput($logLevel); $titleBlock = new TitleBlock($output, $this->messages[$style], $style); $titleBlock->render(); $dataCollectorsData = array(); foreach ($this->dataCollectors as $dataCollector) { $data = $dataCollector->getData($logger->getVerbosity()); foreach ($data as $label => $value) { $dataCollectorsData[] = array($label, $value); } } $table = new Table($output); $table->setRows($dataCollectorsData); $table->setStyle('symfony-style-guide'); $table->render(); $output->writeln(''); }
[ "public", "function", "generate", "(", "ConsoleLoggerInterface", "$", "logger", ")", "{", "$", "logLevel", "=", "LogLevel", "::", "NOTICE", ";", "$", "style", "=", "TitleBlock", "::", "STYLE_SUCCESS", ";", "if", "(", "$", "this", "->", "eventDataCollector", "->", "hasCountedFailedEvents", "(", ")", ")", "{", "$", "logLevel", "=", "LogLevel", "::", "ERROR", ";", "$", "style", "=", "TitleBlock", "::", "STYLE_FAILURE", ";", "}", "elseif", "(", "$", "this", "->", "eventDataCollector", "->", "hasCountedLogLevel", "(", "LogLevel", "::", "EMERGENCY", ")", "||", "$", "this", "->", "eventDataCollector", "->", "hasCountedLogLevel", "(", "LogLevel", "::", "ALERT", ")", "||", "$", "this", "->", "eventDataCollector", "->", "hasCountedLogLevel", "(", "LogLevel", "::", "CRITICAL", ")", "||", "$", "this", "->", "eventDataCollector", "->", "hasCountedLogLevel", "(", "LogLevel", "::", "ERROR", ")", "||", "$", "this", "->", "eventDataCollector", "->", "hasCountedLogLevel", "(", "LogLevel", "::", "WARNING", ")", ")", "{", "$", "logLevel", "=", "LogLevel", "::", "WARNING", ";", "$", "style", "=", "TitleBlock", "::", "STYLE_ERRORED_SUCCESS", ";", "}", "$", "output", "=", "$", "logger", "->", "getOutput", "(", "$", "logLevel", ")", ";", "$", "titleBlock", "=", "new", "TitleBlock", "(", "$", "output", ",", "$", "this", "->", "messages", "[", "$", "style", "]", ",", "$", "style", ")", ";", "$", "titleBlock", "->", "render", "(", ")", ";", "$", "dataCollectorsData", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "dataCollectors", "as", "$", "dataCollector", ")", "{", "$", "data", "=", "$", "dataCollector", "->", "getData", "(", "$", "logger", "->", "getVerbosity", "(", ")", ")", ";", "foreach", "(", "$", "data", "as", "$", "label", "=>", "$", "value", ")", "{", "$", "dataCollectorsData", "[", "]", "=", "array", "(", "$", "label", ",", "$", "value", ")", ";", "}", "}", "$", "table", "=", "new", "Table", "(", "$", "output", ")", ";", "$", "table", "->", "setRows", "(", "$", "dataCollectorsData", ")", ";", "$", "table", "->", "setStyle", "(", "'symfony-style-guide'", ")", ";", "$", "table", "->", "render", "(", ")", ";", "$", "output", "->", "writeln", "(", "''", ")", ";", "}" ]
Generates the output for the report. @param ConsoleLoggerInterface $logger
[ "Generates", "the", "output", "for", "the", "report", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Report/AbstractReport.php#L61-L92
234,773
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasCacheLookup.php
AliasCacheLookup.write
public function write() { if ($this->isModified && $this->cacheKey) { $this->cache->set($this->cacheKey, $this->queried); $this->isModified = false; } }
php
public function write() { if ($this->isModified && $this->cacheKey) { $this->cache->set($this->cacheKey, $this->queried); $this->isModified = false; } }
[ "public", "function", "write", "(", ")", "{", "if", "(", "$", "this", "->", "isModified", "&&", "$", "this", "->", "cacheKey", ")", "{", "$", "this", "->", "cache", "->", "set", "(", "$", "this", "->", "cacheKey", ",", "$", "this", "->", "queried", ")", ";", "$", "this", "->", "isModified", "=", "false", ";", "}", "}" ]
Write current cache This will be called by a terminate event
[ "Write", "current", "cache" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasCacheLookup.php#L93-L99
234,774
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasCacheLookup.php
AliasCacheLookup.fetchAlias
private function fetchAlias($nodeId, $siteId) { // We have no source loaded yet, attempt to find it properly and // populate the cache, even if there's nothing to load $alias = $this->aliasManager->getPathAlias($nodeId, $siteId); $this->isModified = true; if ($alias) { $this->loaded[$nodeId][$siteId] = $alias; } return $alias; }
php
private function fetchAlias($nodeId, $siteId) { // We have no source loaded yet, attempt to find it properly and // populate the cache, even if there's nothing to load $alias = $this->aliasManager->getPathAlias($nodeId, $siteId); $this->isModified = true; if ($alias) { $this->loaded[$nodeId][$siteId] = $alias; } return $alias; }
[ "private", "function", "fetchAlias", "(", "$", "nodeId", ",", "$", "siteId", ")", "{", "// We have no source loaded yet, attempt to find it properly and", "// populate the cache, even if there's nothing to load", "$", "alias", "=", "$", "this", "->", "aliasManager", "->", "getPathAlias", "(", "$", "nodeId", ",", "$", "siteId", ")", ";", "$", "this", "->", "isModified", "=", "true", ";", "if", "(", "$", "alias", ")", "{", "$", "this", "->", "loaded", "[", "$", "nodeId", "]", "[", "$", "siteId", "]", "=", "$", "alias", ";", "}", "return", "$", "alias", ";", "}" ]
Fetch alias for node using the manager, and store it into cache @param int $nodeId @param int $siteId @return string
[ "Fetch", "alias", "for", "node", "using", "the", "manager", "and", "store", "it", "into", "cache" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasCacheLookup.php#L109-L122
234,775
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasCacheLookup.php
AliasCacheLookup.lookup
public function lookup($nodeId, $siteId) { if (!$this->isLoaded) { $this->load(); $this->isLoaded = true; } // Build the array we will store at the end of the query if we have // anything changed during the request if ($this->queriedCount < self::MAX_CACHE_SIZE) { $this->queried[$nodeId][$siteId] = true; } $this->queriedCount++; if (!isset($this->loaded[$nodeId][$siteId])) { // We already have cached this path in the past, or it was not in // original cache source array, or it is non existing anymore or // outdated, our cache is broken, we need to lookup and update return $this->fetchAlias($nodeId, $siteId) ?? 'node/' . $nodeId; } // Best case scenario, it exists! return $this->loaded[$nodeId][$siteId]; }
php
public function lookup($nodeId, $siteId) { if (!$this->isLoaded) { $this->load(); $this->isLoaded = true; } // Build the array we will store at the end of the query if we have // anything changed during the request if ($this->queriedCount < self::MAX_CACHE_SIZE) { $this->queried[$nodeId][$siteId] = true; } $this->queriedCount++; if (!isset($this->loaded[$nodeId][$siteId])) { // We already have cached this path in the past, or it was not in // original cache source array, or it is non existing anymore or // outdated, our cache is broken, we need to lookup and update return $this->fetchAlias($nodeId, $siteId) ?? 'node/' . $nodeId; } // Best case scenario, it exists! return $this->loaded[$nodeId][$siteId]; }
[ "public", "function", "lookup", "(", "$", "nodeId", ",", "$", "siteId", ")", "{", "if", "(", "!", "$", "this", "->", "isLoaded", ")", "{", "$", "this", "->", "load", "(", ")", ";", "$", "this", "->", "isLoaded", "=", "true", ";", "}", "// Build the array we will store at the end of the query if we have", "// anything changed during the request", "if", "(", "$", "this", "->", "queriedCount", "<", "self", "::", "MAX_CACHE_SIZE", ")", "{", "$", "this", "->", "queried", "[", "$", "nodeId", "]", "[", "$", "siteId", "]", "=", "true", ";", "}", "$", "this", "->", "queriedCount", "++", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "loaded", "[", "$", "nodeId", "]", "[", "$", "siteId", "]", ")", ")", "{", "// We already have cached this path in the past, or it was not in", "// original cache source array, or it is non existing anymore or", "// outdated, our cache is broken, we need to lookup and update", "return", "$", "this", "->", "fetchAlias", "(", "$", "nodeId", ",", "$", "siteId", ")", "??", "'node/'", ".", "$", "nodeId", ";", "}", "// Best case scenario, it exists!", "return", "$", "this", "->", "loaded", "[", "$", "nodeId", "]", "[", "$", "siteId", "]", ";", "}" ]
Lookup for given source @param int $source @param int $siteId @return string
[ "Lookup", "for", "given", "source" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasCacheLookup.php#L132-L155
234,776
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasCacheLookup.php
AliasCacheLookup.refresh
public function refresh($siteId = null) { // @sorry for this, but Drupal 8 does not handle prefixes // and we don't have a fallback for tags yet in sf_dic if ($siteId) { cache_clear_all('alias#master#', 'cache', true); cache_clear_all('alias#' . $siteId . '#', 'cache', true); } else { cache_clear_all('alias#', 'cache', true); } }
php
public function refresh($siteId = null) { // @sorry for this, but Drupal 8 does not handle prefixes // and we don't have a fallback for tags yet in sf_dic if ($siteId) { cache_clear_all('alias#master#', 'cache', true); cache_clear_all('alias#' . $siteId . '#', 'cache', true); } else { cache_clear_all('alias#', 'cache', true); } }
[ "public", "function", "refresh", "(", "$", "siteId", "=", "null", ")", "{", "// @sorry for this, but Drupal 8 does not handle prefixes", "// and we don't have a fallback for tags yet in sf_dic", "if", "(", "$", "siteId", ")", "{", "cache_clear_all", "(", "'alias#master#'", ",", "'cache'", ",", "true", ")", ";", "cache_clear_all", "(", "'alias#'", ".", "$", "siteId", ".", "'#'", ",", "'cache'", ",", "true", ")", ";", "}", "else", "{", "cache_clear_all", "(", "'alias#'", ",", "'cache'", ",", "true", ")", ";", "}", "}" ]
Clear caches for site This will always refresh cache for master as well. @param int $siteId If set, refresh only for this site, delete all otherwise
[ "Clear", "caches", "for", "site" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasCacheLookup.php#L217-L227
234,777
makinacorpus/drupal-ucms
ucms_layout/src/Context.php
Context.commit
public function commit() { // Throws a nice exception if no token $this->getToken(); if (!$this->layout instanceof Layout) { throw new \LogicException("No contextual instance is set, cannot commit"); } // This gets the temporary storage until now $this->getStorage()->delete($this->layout->getId()); // Loaded instance is supposed to be the false one $this->storage->save($this->layout); $this->setToken(null); return $this; }
php
public function commit() { // Throws a nice exception if no token $this->getToken(); if (!$this->layout instanceof Layout) { throw new \LogicException("No contextual instance is set, cannot commit"); } // This gets the temporary storage until now $this->getStorage()->delete($this->layout->getId()); // Loaded instance is supposed to be the false one $this->storage->save($this->layout); $this->setToken(null); return $this; }
[ "public", "function", "commit", "(", ")", "{", "// Throws a nice exception if no token", "$", "this", "->", "getToken", "(", ")", ";", "if", "(", "!", "$", "this", "->", "layout", "instanceof", "Layout", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"No contextual instance is set, cannot commit\"", ")", ";", "}", "// This gets the temporary storage until now", "$", "this", "->", "getStorage", "(", ")", "->", "delete", "(", "$", "this", "->", "layout", "->", "getId", "(", ")", ")", ";", "// Loaded instance is supposed to be the false one", "$", "this", "->", "storage", "->", "save", "(", "$", "this", "->", "layout", ")", ";", "$", "this", "->", "setToken", "(", "null", ")", ";", "return", "$", "this", ";", "}" ]
Commit session changes and restore storage @return Context
[ "Commit", "session", "changes", "and", "restore", "storage" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Context.php#L56-L73
234,778
makinacorpus/drupal-ucms
ucms_layout/src/Context.php
Context.rollback
public function rollback() { // Throws a nice exception if no token $this->getToken(); if (!$this->layout instanceof Layout) { throw new \LogicException("No contextual instance is set, cannot commit"); } // Loaded instance is supposed to be the false one // This gets the temporary storage until now $this->getStorage()->delete($this->layout->getId()); $this->setToken(null); // Reload the real layout $this->layout = $this->storage->load($this->layout->getId()); return $this; }
php
public function rollback() { // Throws a nice exception if no token $this->getToken(); if (!$this->layout instanceof Layout) { throw new \LogicException("No contextual instance is set, cannot commit"); } // Loaded instance is supposed to be the false one // This gets the temporary storage until now $this->getStorage()->delete($this->layout->getId()); $this->setToken(null); // Reload the real layout $this->layout = $this->storage->load($this->layout->getId()); return $this; }
[ "public", "function", "rollback", "(", ")", "{", "// Throws a nice exception if no token", "$", "this", "->", "getToken", "(", ")", ";", "if", "(", "!", "$", "this", "->", "layout", "instanceof", "Layout", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"No contextual instance is set, cannot commit\"", ")", ";", "}", "// Loaded instance is supposed to be the false one", "// This gets the temporary storage until now", "$", "this", "->", "getStorage", "(", ")", "->", "delete", "(", "$", "this", "->", "layout", "->", "getId", "(", ")", ")", ";", "$", "this", "->", "setToken", "(", "null", ")", ";", "// Reload the real layout", "$", "this", "->", "layout", "=", "$", "this", "->", "storage", "->", "load", "(", "$", "this", "->", "layout", "->", "getId", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Rollback session changes and restore storage @return Context
[ "Rollback", "session", "changes", "and", "restore", "storage" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Context.php#L80-L99
234,779
makinacorpus/drupal-ucms
ucms_layout/src/Context.php
Context.getCurrentLayout
public function getCurrentLayout() { if (!$this->layout && $this->layoutNodeId) { $this->layout = $this->getStorage()->findForNodeOnSite($this->layoutNodeId, $this->layoutSiteId, true); } return $this->layout; }
php
public function getCurrentLayout() { if (!$this->layout && $this->layoutNodeId) { $this->layout = $this->getStorage()->findForNodeOnSite($this->layoutNodeId, $this->layoutSiteId, true); } return $this->layout; }
[ "public", "function", "getCurrentLayout", "(", ")", "{", "if", "(", "!", "$", "this", "->", "layout", "&&", "$", "this", "->", "layoutNodeId", ")", "{", "$", "this", "->", "layout", "=", "$", "this", "->", "getStorage", "(", ")", "->", "findForNodeOnSite", "(", "$", "this", "->", "layoutNodeId", ",", "$", "this", "->", "layoutSiteId", ",", "true", ")", ";", "}", "return", "$", "this", "->", "layout", ";", "}" ]
Get current layout
[ "Get", "current", "layout" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Context.php#L118-L125
234,780
makinacorpus/drupal-ucms
ucms_layout/src/Context.php
Context.setCurrentLayoutNodeId
public function setCurrentLayoutNodeId($nid, $siteId) { if ($this->layoutNodeId) { throw new \LogicException("You can't change the current layout node ID."); } $this->layoutNodeId = $nid; $this->layoutSiteId = $siteId; }
php
public function setCurrentLayoutNodeId($nid, $siteId) { if ($this->layoutNodeId) { throw new \LogicException("You can't change the current layout node ID."); } $this->layoutNodeId = $nid; $this->layoutSiteId = $siteId; }
[ "public", "function", "setCurrentLayoutNodeId", "(", "$", "nid", ",", "$", "siteId", ")", "{", "if", "(", "$", "this", "->", "layoutNodeId", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"You can't change the current layout node ID.\"", ")", ";", "}", "$", "this", "->", "layoutNodeId", "=", "$", "nid", ";", "$", "this", "->", "layoutSiteId", "=", "$", "siteId", ";", "}" ]
Set current layout node ID @param int $nid @param int $siteId
[ "Set", "current", "layout", "node", "ID" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Context.php#L133-L141
234,781
makinacorpus/drupal-ucms
ucms_layout/src/Context.php
Context.getStorage
public function getStorage() { if ($this->hasToken()) { return $this->temporaryStorage->setToken($this->getToken()); } return $this->storage; }
php
public function getStorage() { if ($this->hasToken()) { return $this->temporaryStorage->setToken($this->getToken()); } return $this->storage; }
[ "public", "function", "getStorage", "(", ")", "{", "if", "(", "$", "this", "->", "hasToken", "(", ")", ")", "{", "return", "$", "this", "->", "temporaryStorage", "->", "setToken", "(", "$", "this", "->", "getToken", "(", ")", ")", ";", "}", "return", "$", "this", "->", "storage", ";", "}" ]
Get real life storage @return StorageInterface
[ "Get", "real", "life", "storage" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Context.php#L158-L165
234,782
huang-yi/swoole-watcher
src/Watcher.php
Watcher.watch
public function watch() { foreach ($this->directories as $directory) { if (is_dir($directory)) { $this->watchAllDirectories($directory); } } }
php
public function watch() { foreach ($this->directories as $directory) { if (is_dir($directory)) { $this->watchAllDirectories($directory); } } }
[ "public", "function", "watch", "(", ")", "{", "foreach", "(", "$", "this", "->", "directories", "as", "$", "directory", ")", "{", "if", "(", "is_dir", "(", "$", "directory", ")", ")", "{", "$", "this", "->", "watchAllDirectories", "(", "$", "directory", ")", ";", "}", "}", "}" ]
Run watcher.
[ "Run", "watcher", "." ]
44ca253453c5f04d7300553bddb736706fbc957a
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L90-L97
234,783
huang-yi/swoole-watcher
src/Watcher.php
Watcher.stop
public function stop() { swoole_event_del($this->inotify); swoole_event_exit(); fclose($this->inotify); $this->watchedDirectories = []; }
php
public function stop() { swoole_event_del($this->inotify); swoole_event_exit(); fclose($this->inotify); $this->watchedDirectories = []; }
[ "public", "function", "stop", "(", ")", "{", "swoole_event_del", "(", "$", "this", "->", "inotify", ")", ";", "swoole_event_exit", "(", ")", ";", "fclose", "(", "$", "this", "->", "inotify", ")", ";", "$", "this", "->", "watchedDirectories", "=", "[", "]", ";", "}" ]
Stop watcher.
[ "Stop", "watcher", "." ]
44ca253453c5f04d7300553bddb736706fbc957a
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L112-L120
234,784
huang-yi/swoole-watcher
src/Watcher.php
Watcher.watchHandler
public function watchHandler() { if (! $events = inotify_read($this->inotify)) { return; } foreach ($events as $event) { if (! empty($event['name']) && ! $this->inWatchedSuffixes($event['name'])) { continue; } if (! $this->handle($event)) { break; } } }
php
public function watchHandler() { if (! $events = inotify_read($this->inotify)) { return; } foreach ($events as $event) { if (! empty($event['name']) && ! $this->inWatchedSuffixes($event['name'])) { continue; } if (! $this->handle($event)) { break; } } }
[ "public", "function", "watchHandler", "(", ")", "{", "if", "(", "!", "$", "events", "=", "inotify_read", "(", "$", "this", "->", "inotify", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "events", "as", "$", "event", ")", "{", "if", "(", "!", "empty", "(", "$", "event", "[", "'name'", "]", ")", "&&", "!", "$", "this", "->", "inWatchedSuffixes", "(", "$", "event", "[", "'name'", "]", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "$", "this", "->", "handle", "(", "$", "event", ")", ")", "{", "break", ";", "}", "}", "}" ]
Watch handler.
[ "Watch", "handler", "." ]
44ca253453c5f04d7300553bddb736706fbc957a
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L135-L150
234,785
huang-yi/swoole-watcher
src/Watcher.php
Watcher.watchAllDirectories
protected function watchAllDirectories($directory) { $directory = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if (! $this->watchDirectory($directory)) { return false; } $names = scandir($directory); foreach ($names as $name) { if (in_array($name, ['.', '..'], true)) { continue; } $subdirectory = $directory . $name; if (is_dir($subdirectory)) { $this->watchAllDirectories($subdirectory); } } return true; }
php
protected function watchAllDirectories($directory) { $directory = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if (! $this->watchDirectory($directory)) { return false; } $names = scandir($directory); foreach ($names as $name) { if (in_array($name, ['.', '..'], true)) { continue; } $subdirectory = $directory . $name; if (is_dir($subdirectory)) { $this->watchAllDirectories($subdirectory); } } return true; }
[ "protected", "function", "watchAllDirectories", "(", "$", "directory", ")", "{", "$", "directory", "=", "rtrim", "(", "$", "directory", ",", "DIRECTORY_SEPARATOR", ")", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "$", "this", "->", "watchDirectory", "(", "$", "directory", ")", ")", "{", "return", "false", ";", "}", "$", "names", "=", "scandir", "(", "$", "directory", ")", ";", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "if", "(", "in_array", "(", "$", "name", ",", "[", "'.'", ",", "'..'", "]", ",", "true", ")", ")", "{", "continue", ";", "}", "$", "subdirectory", "=", "$", "directory", ".", "$", "name", ";", "if", "(", "is_dir", "(", "$", "subdirectory", ")", ")", "{", "$", "this", "->", "watchAllDirectories", "(", "$", "subdirectory", ")", ";", "}", "}", "return", "true", ";", "}" ]
Watch the directory and all subdirectories under the directory. @param string $directory @return bool
[ "Watch", "the", "directory", "and", "all", "subdirectories", "under", "the", "directory", "." ]
44ca253453c5f04d7300553bddb736706fbc957a
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L158-L181
234,786
huang-yi/swoole-watcher
src/Watcher.php
Watcher.watchDirectory
protected function watchDirectory($directory) { if ($this->isExcluded($directory)) { return false; } if (! $this->isWatched($directory)) { $wd = inotify_add_watch($this->inotify, $directory, $this->getMaskValue()); $this->watchedDirectories[$wd] = $directory; } return true; }
php
protected function watchDirectory($directory) { if ($this->isExcluded($directory)) { return false; } if (! $this->isWatched($directory)) { $wd = inotify_add_watch($this->inotify, $directory, $this->getMaskValue()); $this->watchedDirectories[$wd] = $directory; } return true; }
[ "protected", "function", "watchDirectory", "(", "$", "directory", ")", "{", "if", "(", "$", "this", "->", "isExcluded", "(", "$", "directory", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "isWatched", "(", "$", "directory", ")", ")", "{", "$", "wd", "=", "inotify_add_watch", "(", "$", "this", "->", "inotify", ",", "$", "directory", ",", "$", "this", "->", "getMaskValue", "(", ")", ")", ";", "$", "this", "->", "watchedDirectories", "[", "$", "wd", "]", "=", "$", "directory", ";", "}", "return", "true", ";", "}" ]
Watch directory. @param string $directory @return bool
[ "Watch", "directory", "." ]
44ca253453c5f04d7300553bddb736706fbc957a
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L189-L201
234,787
huang-yi/swoole-watcher
src/Watcher.php
Watcher.inWatchedSuffixes
protected function inWatchedSuffixes($file) { foreach ($this->suffixes as $suffix) { $start = strlen($suffix); if (substr($file, -$start, $start) === $suffix) { return true; } } return false; }
php
protected function inWatchedSuffixes($file) { foreach ($this->suffixes as $suffix) { $start = strlen($suffix); if (substr($file, -$start, $start) === $suffix) { return true; } } return false; }
[ "protected", "function", "inWatchedSuffixes", "(", "$", "file", ")", "{", "foreach", "(", "$", "this", "->", "suffixes", "as", "$", "suffix", ")", "{", "$", "start", "=", "strlen", "(", "$", "suffix", ")", ";", "if", "(", "substr", "(", "$", "file", ",", "-", "$", "start", ",", "$", "start", ")", "===", "$", "suffix", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Determine if the file type should be watched. @param string $file @return bool
[ "Determine", "if", "the", "file", "type", "should", "be", "watched", "." ]
44ca253453c5f04d7300553bddb736706fbc957a
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L231-L242
234,788
huang-yi/swoole-watcher
src/Watcher.php
Watcher.setMasks
public function setMasks($masks) { $this->masks = (array) $masks; $this->maskValue = array_reduce($this->masks, function ($maskValue, $mask) { return $maskValue | $mask; }); return $this; }
php
public function setMasks($masks) { $this->masks = (array) $masks; $this->maskValue = array_reduce($this->masks, function ($maskValue, $mask) { return $maskValue | $mask; }); return $this; }
[ "public", "function", "setMasks", "(", "$", "masks", ")", "{", "$", "this", "->", "masks", "=", "(", "array", ")", "$", "masks", ";", "$", "this", "->", "maskValue", "=", "array_reduce", "(", "$", "this", "->", "masks", ",", "function", "(", "$", "maskValue", ",", "$", "mask", ")", "{", "return", "$", "maskValue", "|", "$", "mask", ";", "}", ")", ";", "return", "$", "this", ";", "}" ]
Set the watched masks. @param array $masks @return $this
[ "Set", "the", "watched", "masks", "." ]
44ca253453c5f04d7300553bddb736706fbc957a
https://github.com/huang-yi/swoole-watcher/blob/44ca253453c5f04d7300553bddb736706fbc957a/src/Watcher.php#L365-L373
234,789
shopgate/cart-integration-sdk
src/core.php
ShopgateLibraryException.getMessageFor
public static function getMessageFor($code) { if (isset(self::$errorMessages[$code])) { $message = self::$errorMessages[$code]; } else { $message = 'Unknown error code: "' . $code . '"'; } return $message; }
php
public static function getMessageFor($code) { if (isset(self::$errorMessages[$code])) { $message = self::$errorMessages[$code]; } else { $message = 'Unknown error code: "' . $code . '"'; } return $message; }
[ "public", "static", "function", "getMessageFor", "(", "$", "code", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "errorMessages", "[", "$", "code", "]", ")", ")", "{", "$", "message", "=", "self", "::", "$", "errorMessages", "[", "$", "code", "]", ";", "}", "else", "{", "$", "message", "=", "'Unknown error code: \"'", ".", "$", "code", ".", "'\"'", ";", "}", "return", "$", "message", ";", "}" ]
Gets the error message for an error code. @param int $code One of the constants in this class. @return string
[ "Gets", "the", "error", "message", "for", "an", "error", "code", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L425-L434
234,790
shopgate/cart-integration-sdk
src/core.php
ShopgateLibraryException.buildLogMessageFor
public static function buildLogMessageFor($code, $additionalInformation) { $e = new ShopgateLibraryException($code, $additionalInformation, false, false); return $e->buildLogMessage(); }
php
public static function buildLogMessageFor($code, $additionalInformation) { $e = new ShopgateLibraryException($code, $additionalInformation, false, false); return $e->buildLogMessage(); }
[ "public", "static", "function", "buildLogMessageFor", "(", "$", "code", ",", "$", "additionalInformation", ")", "{", "$", "e", "=", "new", "ShopgateLibraryException", "(", "$", "code", ",", "$", "additionalInformation", ",", "false", ",", "false", ")", ";", "return", "$", "e", "->", "buildLogMessage", "(", ")", ";", "}" ]
Builds the message that would be logged if a ShopgateLibraryException was thrown with the same parameters and returns it. This is a convenience method for cases where logging is desired but the script should not abort. By using this function an empty try-catch-statement can be avoided. Just pass the returned string to ShopgateLogger::log(). @param int $code One of the constants defined in ShopgateLibraryException. @param string $additionalInformation More detailed information on what exactly went wrong. @return string @deprecated
[ "Builds", "the", "message", "that", "would", "be", "logged", "if", "a", "ShopgateLibraryException", "was", "thrown", "with", "the", "same", "parameters", "and", "returns", "it", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L449-L454
234,791
shopgate/cart-integration-sdk
src/core.php
ShopgateLibraryException.buildLogMessage
protected function buildLogMessage($appendAdditionalInformation = true) { $logMessage = $this->getMessage(); if ($appendAdditionalInformation && !empty($this->additionalInformation)) { $logMessage .= ': ' . $this->additionalInformation; } $logMessage .= "\n"; // Add tracing information to the message $previous = $this->getPreviousException(); $trace = $previous ? $previous->getTraceAsString() : $this->getTraceAsString(); $line = $previous ? $previous->getLine() : $this->getLine(); $file = $previous ? $previous->getFile() : $this->getFile(); $class = $previous ? get_class($previous) : get_class($this); $traceLines = explode("\n", $trace); array_unshift($traceLines, "## $file($line): throw $class"); $i = 0; foreach ($traceLines as $traceLine) { $i++; if ($i > 20) { $logMessage .= "\t(...)"; break; } $logMessage .= "\t$traceLine\n"; } return $logMessage; }
php
protected function buildLogMessage($appendAdditionalInformation = true) { $logMessage = $this->getMessage(); if ($appendAdditionalInformation && !empty($this->additionalInformation)) { $logMessage .= ': ' . $this->additionalInformation; } $logMessage .= "\n"; // Add tracing information to the message $previous = $this->getPreviousException(); $trace = $previous ? $previous->getTraceAsString() : $this->getTraceAsString(); $line = $previous ? $previous->getLine() : $this->getLine(); $file = $previous ? $previous->getFile() : $this->getFile(); $class = $previous ? get_class($previous) : get_class($this); $traceLines = explode("\n", $trace); array_unshift($traceLines, "## $file($line): throw $class"); $i = 0; foreach ($traceLines as $traceLine) { $i++; if ($i > 20) { $logMessage .= "\t(...)"; break; } $logMessage .= "\t$traceLine\n"; } return $logMessage; }
[ "protected", "function", "buildLogMessage", "(", "$", "appendAdditionalInformation", "=", "true", ")", "{", "$", "logMessage", "=", "$", "this", "->", "getMessage", "(", ")", ";", "if", "(", "$", "appendAdditionalInformation", "&&", "!", "empty", "(", "$", "this", "->", "additionalInformation", ")", ")", "{", "$", "logMessage", ".=", "': '", ".", "$", "this", "->", "additionalInformation", ";", "}", "$", "logMessage", ".=", "\"\\n\"", ";", "// Add tracing information to the message", "$", "previous", "=", "$", "this", "->", "getPreviousException", "(", ")", ";", "$", "trace", "=", "$", "previous", "?", "$", "previous", "->", "getTraceAsString", "(", ")", ":", "$", "this", "->", "getTraceAsString", "(", ")", ";", "$", "line", "=", "$", "previous", "?", "$", "previous", "->", "getLine", "(", ")", ":", "$", "this", "->", "getLine", "(", ")", ";", "$", "file", "=", "$", "previous", "?", "$", "previous", "->", "getFile", "(", ")", ":", "$", "this", "->", "getFile", "(", ")", ";", "$", "class", "=", "$", "previous", "?", "get_class", "(", "$", "previous", ")", ":", "get_class", "(", "$", "this", ")", ";", "$", "traceLines", "=", "explode", "(", "\"\\n\"", ",", "$", "trace", ")", ";", "array_unshift", "(", "$", "traceLines", ",", "\"## $file($line): throw $class\"", ")", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "traceLines", "as", "$", "traceLine", ")", "{", "$", "i", "++", ";", "if", "(", "$", "i", ">", "20", ")", "{", "$", "logMessage", ".=", "\"\\t(...)\"", ";", "break", ";", "}", "$", "logMessage", ".=", "\"\\t$traceLine\\n\"", ";", "}", "return", "$", "logMessage", ";", "}" ]
Builds the message that will be logged to the error log. @param bool $appendAdditionalInformation @return string
[ "Builds", "the", "message", "that", "will", "be", "logged", "to", "the", "error", "log", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L463-L502
234,792
shopgate/cart-integration-sdk
src/core.php
ShopgateBuilder.buildMerchantApi
public function buildMerchantApi() { $merchantApi = null; switch ($smaAuthServiceClassName = $this->config->getSmaAuthServiceClassName()) { case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_SHOPGATE: $smaAuthService = new ShopgateAuthenticationServiceShopgate( $this->config->getCustomerNumber(), $this->config->getApikey() ); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi( $smaAuthService, $this->config->getShopNumber(), $this->config->getApiUrl() ); break; case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_OAUTH: $smaAuthService = new ShopgateAuthenticationServiceOAuth($this->config->getOauthAccessToken()); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi($smaAuthService, null, $this->config->getApiUrl()); break; default: // undefined auth service trigger_error( 'Invalid SMA-Auth-Service defined - this should not happen with valid plugin code', E_USER_ERROR ); break; } return $merchantApi; }
php
public function buildMerchantApi() { $merchantApi = null; switch ($smaAuthServiceClassName = $this->config->getSmaAuthServiceClassName()) { case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_SHOPGATE: $smaAuthService = new ShopgateAuthenticationServiceShopgate( $this->config->getCustomerNumber(), $this->config->getApikey() ); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi( $smaAuthService, $this->config->getShopNumber(), $this->config->getApiUrl() ); break; case ShopgateConfigInterface::SHOPGATE_AUTH_SERVICE_CLASS_NAME_OAUTH: $smaAuthService = new ShopgateAuthenticationServiceOAuth($this->config->getOauthAccessToken()); $smaAuthService->setup($this->config); $merchantApi = new ShopgateMerchantApi($smaAuthService, null, $this->config->getApiUrl()); break; default: // undefined auth service trigger_error( 'Invalid SMA-Auth-Service defined - this should not happen with valid plugin code', E_USER_ERROR ); break; } return $merchantApi; }
[ "public", "function", "buildMerchantApi", "(", ")", "{", "$", "merchantApi", "=", "null", ";", "switch", "(", "$", "smaAuthServiceClassName", "=", "$", "this", "->", "config", "->", "getSmaAuthServiceClassName", "(", ")", ")", "{", "case", "ShopgateConfigInterface", "::", "SHOPGATE_AUTH_SERVICE_CLASS_NAME_SHOPGATE", ":", "$", "smaAuthService", "=", "new", "ShopgateAuthenticationServiceShopgate", "(", "$", "this", "->", "config", "->", "getCustomerNumber", "(", ")", ",", "$", "this", "->", "config", "->", "getApikey", "(", ")", ")", ";", "$", "smaAuthService", "->", "setup", "(", "$", "this", "->", "config", ")", ";", "$", "merchantApi", "=", "new", "ShopgateMerchantApi", "(", "$", "smaAuthService", ",", "$", "this", "->", "config", "->", "getShopNumber", "(", ")", ",", "$", "this", "->", "config", "->", "getApiUrl", "(", ")", ")", ";", "break", ";", "case", "ShopgateConfigInterface", "::", "SHOPGATE_AUTH_SERVICE_CLASS_NAME_OAUTH", ":", "$", "smaAuthService", "=", "new", "ShopgateAuthenticationServiceOAuth", "(", "$", "this", "->", "config", "->", "getOauthAccessToken", "(", ")", ")", ";", "$", "smaAuthService", "->", "setup", "(", "$", "this", "->", "config", ")", ";", "$", "merchantApi", "=", "new", "ShopgateMerchantApi", "(", "$", "smaAuthService", ",", "null", ",", "$", "this", "->", "config", "->", "getApiUrl", "(", ")", ")", ";", "break", ";", "default", ":", "// undefined auth service", "trigger_error", "(", "'Invalid SMA-Auth-Service defined - this should not happen with valid plugin code'", ",", "E_USER_ERROR", ")", ";", "break", ";", "}", "return", "$", "merchantApi", ";", "}" ]
Builds the Shopgate Cart Integration SDK object graph for ShopgateMerchantApi and returns the instance. @return ShopgateMerchantApi
[ "Builds", "the", "Shopgate", "Cart", "Integration", "SDK", "object", "graph", "for", "ShopgateMerchantApi", "and", "returns", "the", "instance", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L878-L908
234,793
shopgate/cart-integration-sdk
src/core.php
ShopgateBuilder.buildJsRedirect
public function buildJsRedirect(array $get, array $cookie) { $settingsManager = new Shopgate_Helper_Redirect_SettingsManager($this->config, $get, $cookie); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $tagsGenerator = new Shopgate_Helper_Redirect_TagsGenerator( $linkBuilder, $templateParser ); $jsBuilder = new Shopgate_Helper_Redirect_JsScriptBuilder( $tagsGenerator, $settingsManager, $templateParser, dirname(__FILE__) . '/../assets/js_header.html', $this->config->getShopNumber() ); $jsType = new Shopgate_Helper_Redirect_Type_Js($jsBuilder); return $jsType; }
php
public function buildJsRedirect(array $get, array $cookie) { $settingsManager = new Shopgate_Helper_Redirect_SettingsManager($this->config, $get, $cookie); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $tagsGenerator = new Shopgate_Helper_Redirect_TagsGenerator( $linkBuilder, $templateParser ); $jsBuilder = new Shopgate_Helper_Redirect_JsScriptBuilder( $tagsGenerator, $settingsManager, $templateParser, dirname(__FILE__) . '/../assets/js_header.html', $this->config->getShopNumber() ); $jsType = new Shopgate_Helper_Redirect_Type_Js($jsBuilder); return $jsType; }
[ "public", "function", "buildJsRedirect", "(", "array", "$", "get", ",", "array", "$", "cookie", ")", "{", "$", "settingsManager", "=", "new", "Shopgate_Helper_Redirect_SettingsManager", "(", "$", "this", "->", "config", ",", "$", "get", ",", "$", "cookie", ")", ";", "$", "templateParser", "=", "new", "Shopgate_Helper_Redirect_TemplateParser", "(", ")", ";", "$", "linkBuilder", "=", "new", "Shopgate_Helper_Redirect_LinkBuilder", "(", "$", "settingsManager", ",", "$", "templateParser", ")", ";", "$", "tagsGenerator", "=", "new", "Shopgate_Helper_Redirect_TagsGenerator", "(", "$", "linkBuilder", ",", "$", "templateParser", ")", ";", "$", "jsBuilder", "=", "new", "Shopgate_Helper_Redirect_JsScriptBuilder", "(", "$", "tagsGenerator", ",", "$", "settingsManager", ",", "$", "templateParser", ",", "dirname", "(", "__FILE__", ")", ".", "'/../assets/js_header.html'", ",", "$", "this", "->", "config", "->", "getShopNumber", "(", ")", ")", ";", "$", "jsType", "=", "new", "Shopgate_Helper_Redirect_Type_Js", "(", "$", "jsBuilder", ")", ";", "return", "$", "jsType", ";", "}" ]
Generates JavaScript code to redirect the current page Shopgate mobile site @param array $get @param array $cookie @return Shopgate_Helper_Redirect_Type_Js
[ "Generates", "JavaScript", "code", "to", "redirect", "the", "current", "page", "Shopgate", "mobile", "site" ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1005-L1030
234,794
shopgate/cart-integration-sdk
src/core.php
ShopgateBuilder.buildHttpRedirect
public function buildHttpRedirect($userAgent, array $get, array $cookie) { $settingsManager = new Shopgate_Helper_Redirect_SettingsManager($this->config, $get, $cookie); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $redirector = new Shopgate_Helper_Redirect_Redirector( $settingsManager, new Shopgate_Helper_Redirect_KeywordsManager( $this->buildMerchantApi(), $this->config->getRedirectKeywordCachePath(), $this->config->getRedirectSkipKeywordCachePath() ), $linkBuilder, $userAgent ); return new Shopgate_Helper_Redirect_Type_Http($redirector); }
php
public function buildHttpRedirect($userAgent, array $get, array $cookie) { $settingsManager = new Shopgate_Helper_Redirect_SettingsManager($this->config, $get, $cookie); $templateParser = new Shopgate_Helper_Redirect_TemplateParser(); $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder( $settingsManager, $templateParser ); $redirector = new Shopgate_Helper_Redirect_Redirector( $settingsManager, new Shopgate_Helper_Redirect_KeywordsManager( $this->buildMerchantApi(), $this->config->getRedirectKeywordCachePath(), $this->config->getRedirectSkipKeywordCachePath() ), $linkBuilder, $userAgent ); return new Shopgate_Helper_Redirect_Type_Http($redirector); }
[ "public", "function", "buildHttpRedirect", "(", "$", "userAgent", ",", "array", "$", "get", ",", "array", "$", "cookie", ")", "{", "$", "settingsManager", "=", "new", "Shopgate_Helper_Redirect_SettingsManager", "(", "$", "this", "->", "config", ",", "$", "get", ",", "$", "cookie", ")", ";", "$", "templateParser", "=", "new", "Shopgate_Helper_Redirect_TemplateParser", "(", ")", ";", "$", "linkBuilder", "=", "new", "Shopgate_Helper_Redirect_LinkBuilder", "(", "$", "settingsManager", ",", "$", "templateParser", ")", ";", "$", "redirector", "=", "new", "Shopgate_Helper_Redirect_Redirector", "(", "$", "settingsManager", ",", "new", "Shopgate_Helper_Redirect_KeywordsManager", "(", "$", "this", "->", "buildMerchantApi", "(", ")", ",", "$", "this", "->", "config", "->", "getRedirectKeywordCachePath", "(", ")", ",", "$", "this", "->", "config", "->", "getRedirectSkipKeywordCachePath", "(", ")", ")", ",", "$", "linkBuilder", ",", "$", "userAgent", ")", ";", "return", "new", "Shopgate_Helper_Redirect_Type_Http", "(", "$", "redirector", ")", ";", "}" ]
Attempts to redirect via an HTTP header call before the page is loaded @param string $userAgent - browser agent string @param array $get @param array $cookie @return Shopgate_Helper_Redirect_Type_Http
[ "Attempts", "to", "redirect", "via", "an", "HTTP", "header", "call", "before", "the", "page", "is", "loaded" ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1042-L1064
234,795
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.getHelper
protected function getHelper($helperName) { if (array_key_exists($helperName, $this->helperClassInstances)) { $helperClassName = "Shopgate_Helper_" . $helperName; if (!isset($this->helperClassInstances[$helperClassName])) { $this->helperClassInstances[$helperClassName] = new $helperClassName(); } return $this->helperClassInstances[$helperClassName]; } throw new ShopgateLibraryException( "Helper function {$helperName} not found", ShopgateLibraryException::SHOPGATE_HELPER_FUNCTION_NOT_FOUND_EXCEPTION ); }
php
protected function getHelper($helperName) { if (array_key_exists($helperName, $this->helperClassInstances)) { $helperClassName = "Shopgate_Helper_" . $helperName; if (!isset($this->helperClassInstances[$helperClassName])) { $this->helperClassInstances[$helperClassName] = new $helperClassName(); } return $this->helperClassInstances[$helperClassName]; } throw new ShopgateLibraryException( "Helper function {$helperName} not found", ShopgateLibraryException::SHOPGATE_HELPER_FUNCTION_NOT_FOUND_EXCEPTION ); }
[ "protected", "function", "getHelper", "(", "$", "helperName", ")", "{", "if", "(", "array_key_exists", "(", "$", "helperName", ",", "$", "this", "->", "helperClassInstances", ")", ")", "{", "$", "helperClassName", "=", "\"Shopgate_Helper_\"", ".", "$", "helperName", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "helperClassInstances", "[", "$", "helperClassName", "]", ")", ")", "{", "$", "this", "->", "helperClassInstances", "[", "$", "helperClassName", "]", "=", "new", "$", "helperClassName", "(", ")", ";", "}", "return", "$", "this", "->", "helperClassInstances", "[", "$", "helperClassName", "]", ";", "}", "throw", "new", "ShopgateLibraryException", "(", "\"Helper function {$helperName} not found\"", ",", "ShopgateLibraryException", "::", "SHOPGATE_HELPER_FUNCTION_NOT_FOUND_EXCEPTION", ")", ";", "}" ]
get a instance of an Shopgate helper class depending on the committed name @param $helperName string defined by constants in this class(ShopgateObject) @return Shopgate_Helper_DataStructure|Shopgate_Helper_Pricing|Shopgate_Helper_String returns the requested helper instance @throws ShopgateLibraryException
[ "get", "a", "instance", "of", "an", "Shopgate", "helper", "class", "depending", "on", "the", "committed", "name" ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1152-L1166
234,796
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.log
public function log($msg, $type = ShopgateLogger::LOGTYPE_ERROR) { return ShopgateLogger::getInstance()->log($msg, $type); }
php
public function log($msg, $type = ShopgateLogger::LOGTYPE_ERROR) { return ShopgateLogger::getInstance()->log($msg, $type); }
[ "public", "function", "log", "(", "$", "msg", ",", "$", "type", "=", "ShopgateLogger", "::", "LOGTYPE_ERROR", ")", "{", "return", "ShopgateLogger", "::", "getInstance", "(", ")", "->", "log", "(", "$", "msg", ",", "$", "type", ")", ";", "}" ]
Convenience method for logging to the ShopgateLogger. @param string $msg The error message. @param string $type The log type, that would be one of the ShopgateLogger::LOGTYPE_* constants. @return bool True on success, false on error.
[ "Convenience", "method", "for", "logging", "to", "the", "ShopgateLogger", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1176-L1179
234,797
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.camelize
public function camelize($str, $capitalizeFirst = false) { $hash = md5($str . $capitalizeFirst); if (empty($this->camelizeCache[$hash])) { $str = strtolower($str); if ($capitalizeFirst) { $str[0] = strtoupper($str[0]); } $this->camelizeCache[$hash] = preg_replace_callback('/_([a-z0-9])/', array($this, 'camelizeHelper'), $str); } return $this->camelizeCache[$hash]; }
php
public function camelize($str, $capitalizeFirst = false) { $hash = md5($str . $capitalizeFirst); if (empty($this->camelizeCache[$hash])) { $str = strtolower($str); if ($capitalizeFirst) { $str[0] = strtoupper($str[0]); } $this->camelizeCache[$hash] = preg_replace_callback('/_([a-z0-9])/', array($this, 'camelizeHelper'), $str); } return $this->camelizeCache[$hash]; }
[ "public", "function", "camelize", "(", "$", "str", ",", "$", "capitalizeFirst", "=", "false", ")", "{", "$", "hash", "=", "md5", "(", "$", "str", ".", "$", "capitalizeFirst", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "camelizeCache", "[", "$", "hash", "]", ")", ")", "{", "$", "str", "=", "strtolower", "(", "$", "str", ")", ";", "if", "(", "$", "capitalizeFirst", ")", "{", "$", "str", "[", "0", "]", "=", "strtoupper", "(", "$", "str", "[", "0", "]", ")", ";", "}", "$", "this", "->", "camelizeCache", "[", "$", "hash", "]", "=", "preg_replace_callback", "(", "'/_([a-z0-9])/'", ",", "array", "(", "$", "this", ",", "'camelizeHelper'", ")", ",", "$", "str", ")", ";", "}", "return", "$", "this", "->", "camelizeCache", "[", "$", "hash", "]", ";", "}" ]
Converts a an underscored string to a camelized one. e.g.:<br /> $this->camelize("get_categories_csv") returns "getCategoriesCsv"<br /> $this->camelize("shopgate_library", true) returns "ShopgateLibrary"<br /> @param string $str The underscored string. @param bool $capitalizeFirst Set true to capitalize the first letter (e.g. for class names). Default: false. @return string The camelized string.
[ "Converts", "a", "an", "underscored", "string", "to", "a", "camelized", "one", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1193-L1206
234,798
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.stringToUtf8
public function stringToUtf8($string, $sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { $conditions = is_string($sourceEncoding) && ($sourceEncoding == SHOPGATE_LIBRARY_ENCODING) && !$force; return ($conditions) ? $string : $this->convertEncoding($string, SHOPGATE_LIBRARY_ENCODING, $sourceEncoding, $useIconv); }
php
public function stringToUtf8($string, $sourceEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { $conditions = is_string($sourceEncoding) && ($sourceEncoding == SHOPGATE_LIBRARY_ENCODING) && !$force; return ($conditions) ? $string : $this->convertEncoding($string, SHOPGATE_LIBRARY_ENCODING, $sourceEncoding, $useIconv); }
[ "public", "function", "stringToUtf8", "(", "$", "string", ",", "$", "sourceEncoding", "=", "'ISO-8859-15'", ",", "$", "force", "=", "false", ",", "$", "useIconv", "=", "false", ")", "{", "$", "conditions", "=", "is_string", "(", "$", "sourceEncoding", ")", "&&", "(", "$", "sourceEncoding", "==", "SHOPGATE_LIBRARY_ENCODING", ")", "&&", "!", "$", "force", ";", "return", "(", "$", "conditions", ")", "?", "$", "string", ":", "$", "this", "->", "convertEncoding", "(", "$", "string", ",", "SHOPGATE_LIBRARY_ENCODING", ",", "$", "sourceEncoding", ",", "$", "useIconv", ")", ";", "}" ]
Encodes a string from a given encoding to UTF-8. @param string $string The string to encode. @param string|string[] $sourceEncoding The (possible) encoding(s) of $string. @param bool $force Set this true to enforce encoding even if the source encoding is already UTF-8. @param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is present. @return string The UTF-8 encoded string.
[ "Encodes", "a", "string", "from", "a", "given", "encoding", "to", "UTF", "-", "8", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1266-L1276
234,799
shopgate/cart-integration-sdk
src/core.php
ShopgateObject.stringFromUtf8
public function stringFromUtf8($string, $destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { return ($destinationEncoding == SHOPGATE_LIBRARY_ENCODING) && !$force ? $string : $this->convertEncoding($string, $destinationEncoding, SHOPGATE_LIBRARY_ENCODING, $useIconv); }
php
public function stringFromUtf8($string, $destinationEncoding = 'ISO-8859-15', $force = false, $useIconv = false) { return ($destinationEncoding == SHOPGATE_LIBRARY_ENCODING) && !$force ? $string : $this->convertEncoding($string, $destinationEncoding, SHOPGATE_LIBRARY_ENCODING, $useIconv); }
[ "public", "function", "stringFromUtf8", "(", "$", "string", ",", "$", "destinationEncoding", "=", "'ISO-8859-15'", ",", "$", "force", "=", "false", ",", "$", "useIconv", "=", "false", ")", "{", "return", "(", "$", "destinationEncoding", "==", "SHOPGATE_LIBRARY_ENCODING", ")", "&&", "!", "$", "force", "?", "$", "string", ":", "$", "this", "->", "convertEncoding", "(", "$", "string", ",", "$", "destinationEncoding", ",", "SHOPGATE_LIBRARY_ENCODING", ",", "$", "useIconv", ")", ";", "}" ]
Decodes a string from UTF-8 to a given encoding. @param string $string The string to decode. @param string $destinationEncoding The desired encoding of the return value. @param bool $force Set this true to enforce encoding even if the destination encoding is set to UTF-8. @param bool $useIconv True to use iconv instead of mb_convert_encoding even if the mb library is present. @return string The UTF-8 decoded string.
[ "Decodes", "a", "string", "from", "UTF", "-", "8", "to", "a", "given", "encoding", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/core.php#L1290-L1295