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
224,500
doctrine/oxm
lib/Doctrine/OXM/Tools/XmlEntityGenerator.php
XmlEntityGenerator.writeXmlEntityClass
public function writeXmlEntityClass(ClassMetadataInfo $metadata, $outputDirectory) { $path = $outputDirectory . '/' . str_replace('\\', DIRECTORY_SEPARATOR, $metadata->name) . $this->extension; $dir = dirname($path); if ( ! is_dir($dir)) { mkdir($dir, 0777, true); } $this->isNew = !file_exists($path) || (file_exists($path) && $this->regenerateXmlEntityIfExists); if ( ! $this->isNew) { $this->parseTokensInXmlEntityFile($path); } if ($this->backupExisting && file_exists($path)) { $backupPath = dirname($path) . DIRECTORY_SEPARATOR . "~" . basename($path); if (!copy($path, $backupPath)) { throw new \RuntimeException("Attempt to backup overwritten xml-entity file but copy operation failed."); } } // If xml-entity doesn't exist or we're re-generating the xml-entities entirely if ($this->isNew) { file_put_contents($path, $this->generateXmlEntityClass($metadata)); // If xml-entity exists and we're allowed to update the xml-entity class } else if ( ! $this->isNew && $this->updateXmlEntityIfExists) { file_put_contents($path, $this->generateUpdatedXmlEntityClass($metadata, $path)); } }
php
public function writeXmlEntityClass(ClassMetadataInfo $metadata, $outputDirectory) { $path = $outputDirectory . '/' . str_replace('\\', DIRECTORY_SEPARATOR, $metadata->name) . $this->extension; $dir = dirname($path); if ( ! is_dir($dir)) { mkdir($dir, 0777, true); } $this->isNew = !file_exists($path) || (file_exists($path) && $this->regenerateXmlEntityIfExists); if ( ! $this->isNew) { $this->parseTokensInXmlEntityFile($path); } if ($this->backupExisting && file_exists($path)) { $backupPath = dirname($path) . DIRECTORY_SEPARATOR . "~" . basename($path); if (!copy($path, $backupPath)) { throw new \RuntimeException("Attempt to backup overwritten xml-entity file but copy operation failed."); } } // If xml-entity doesn't exist or we're re-generating the xml-entities entirely if ($this->isNew) { file_put_contents($path, $this->generateXmlEntityClass($metadata)); // If xml-entity exists and we're allowed to update the xml-entity class } else if ( ! $this->isNew && $this->updateXmlEntityIfExists) { file_put_contents($path, $this->generateUpdatedXmlEntityClass($metadata, $path)); } }
[ "public", "function", "writeXmlEntityClass", "(", "ClassMetadataInfo", "$", "metadata", ",", "$", "outputDirectory", ")", "{", "$", "path", "=", "$", "outputDirectory", ".", "'/'", ".", "str_replace", "(", "'\\\\'", ",", "DIRECTORY_SEPARATOR", ",", "$", "metadata", "->", "name", ")", ".", "$", "this", "->", "extension", ";", "$", "dir", "=", "dirname", "(", "$", "path", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0777", ",", "true", ")", ";", "}", "$", "this", "->", "isNew", "=", "!", "file_exists", "(", "$", "path", ")", "||", "(", "file_exists", "(", "$", "path", ")", "&&", "$", "this", "->", "regenerateXmlEntityIfExists", ")", ";", "if", "(", "!", "$", "this", "->", "isNew", ")", "{", "$", "this", "->", "parseTokensInXmlEntityFile", "(", "$", "path", ")", ";", "}", "if", "(", "$", "this", "->", "backupExisting", "&&", "file_exists", "(", "$", "path", ")", ")", "{", "$", "backupPath", "=", "dirname", "(", "$", "path", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"~\"", ".", "basename", "(", "$", "path", ")", ";", "if", "(", "!", "copy", "(", "$", "path", ",", "$", "backupPath", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Attempt to backup overwritten xml-entity file but copy operation failed.\"", ")", ";", "}", "}", "// If xml-entity doesn't exist or we're re-generating the xml-entities entirely", "if", "(", "$", "this", "->", "isNew", ")", "{", "file_put_contents", "(", "$", "path", ",", "$", "this", "->", "generateXmlEntityClass", "(", "$", "metadata", ")", ")", ";", "// If xml-entity exists and we're allowed to update the xml-entity class", "}", "else", "if", "(", "!", "$", "this", "->", "isNew", "&&", "$", "this", "->", "updateXmlEntityIfExists", ")", "{", "file_put_contents", "(", "$", "path", ",", "$", "this", "->", "generateUpdatedXmlEntityClass", "(", "$", "metadata", ",", "$", "path", ")", ")", ";", "}", "}" ]
Generated and write xml-entity class to disk for the given ClassMetadataInfo instance @param ClassMetadataInfo $metadata @param string $outputDirectory @return void
[ "Generated", "and", "write", "xml", "-", "entity", "class", "to", "disk", "for", "the", "given", "ClassMetadataInfo", "instance" ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Tools/XmlEntityGenerator.php#L161-L189
224,501
doctrine/oxm
lib/Doctrine/OXM/Tools/XmlEntityGenerator.php
XmlEntityGenerator.generateXmlEntityClass
public function generateXmlEntityClass(ClassMetadataInfo $metadata) { $placeHolders = array( '<namespace>', '<imports>', '<xmlEntityAnnotation>', '<xmlEntityClassName>', '<xmlEntityBody>' ); $replacements = array( $this->generateXmlEntityNamespace($metadata), $this->generateXmlEntityImports($metadata), $this->generateXmlEntityDocBlock($metadata), $this->generateXmlEntityClassName($metadata), $this->generateXmlEntityBody($metadata) ); $code = str_replace($placeHolders, $replacements, self::$classTemplate); return str_replace('<spaces>', $this->spaces, $code); }
php
public function generateXmlEntityClass(ClassMetadataInfo $metadata) { $placeHolders = array( '<namespace>', '<imports>', '<xmlEntityAnnotation>', '<xmlEntityClassName>', '<xmlEntityBody>' ); $replacements = array( $this->generateXmlEntityNamespace($metadata), $this->generateXmlEntityImports($metadata), $this->generateXmlEntityDocBlock($metadata), $this->generateXmlEntityClassName($metadata), $this->generateXmlEntityBody($metadata) ); $code = str_replace($placeHolders, $replacements, self::$classTemplate); return str_replace('<spaces>', $this->spaces, $code); }
[ "public", "function", "generateXmlEntityClass", "(", "ClassMetadataInfo", "$", "metadata", ")", "{", "$", "placeHolders", "=", "array", "(", "'<namespace>'", ",", "'<imports>'", ",", "'<xmlEntityAnnotation>'", ",", "'<xmlEntityClassName>'", ",", "'<xmlEntityBody>'", ")", ";", "$", "replacements", "=", "array", "(", "$", "this", "->", "generateXmlEntityNamespace", "(", "$", "metadata", ")", ",", "$", "this", "->", "generateXmlEntityImports", "(", "$", "metadata", ")", ",", "$", "this", "->", "generateXmlEntityDocBlock", "(", "$", "metadata", ")", ",", "$", "this", "->", "generateXmlEntityClassName", "(", "$", "metadata", ")", ",", "$", "this", "->", "generateXmlEntityBody", "(", "$", "metadata", ")", ")", ";", "$", "code", "=", "str_replace", "(", "$", "placeHolders", ",", "$", "replacements", ",", "self", "::", "$", "classTemplate", ")", ";", "return", "str_replace", "(", "'<spaces>'", ",", "$", "this", "->", "spaces", ",", "$", "code", ")", ";", "}" ]
Generate a PHP5 Doctrine 2 xml-entity class from the given ClassMetadataInfo instance @param ClassMetadataInfo $metadata @return string $code
[ "Generate", "a", "PHP5", "Doctrine", "2", "xml", "-", "entity", "class", "from", "the", "given", "ClassMetadataInfo", "instance" ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Tools/XmlEntityGenerator.php#L197-L217
224,502
doctrine/oxm
lib/Doctrine/OXM/Tools/XmlEntityGenerator.php
XmlEntityGenerator.generateUpdatedXmlEntityClass
public function generateUpdatedXmlEntityClass(ClassMetadataInfo $metadata, $path) { $currentCode = file_get_contents($path); $body = $this->generateXmlEntityBody($metadata); $body = str_replace('<spaces>', $this->spaces, $body); $last = strrpos($currentCode, '}'); return substr($currentCode, 0, $last) . $body . (strlen($body) > 0 ? "\n" : ''). "}"; }
php
public function generateUpdatedXmlEntityClass(ClassMetadataInfo $metadata, $path) { $currentCode = file_get_contents($path); $body = $this->generateXmlEntityBody($metadata); $body = str_replace('<spaces>', $this->spaces, $body); $last = strrpos($currentCode, '}'); return substr($currentCode, 0, $last) . $body . (strlen($body) > 0 ? "\n" : ''). "}"; }
[ "public", "function", "generateUpdatedXmlEntityClass", "(", "ClassMetadataInfo", "$", "metadata", ",", "$", "path", ")", "{", "$", "currentCode", "=", "file_get_contents", "(", "$", "path", ")", ";", "$", "body", "=", "$", "this", "->", "generateXmlEntityBody", "(", "$", "metadata", ")", ";", "$", "body", "=", "str_replace", "(", "'<spaces>'", ",", "$", "this", "->", "spaces", ",", "$", "body", ")", ";", "$", "last", "=", "strrpos", "(", "$", "currentCode", ",", "'}'", ")", ";", "return", "substr", "(", "$", "currentCode", ",", "0", ",", "$", "last", ")", ".", "$", "body", ".", "(", "strlen", "(", "$", "body", ")", ">", "0", "?", "\"\\n\"", ":", "''", ")", ".", "\"}\"", ";", "}" ]
Generate the updated code for the given ClassMetadataInfo and xml-entity at path @param ClassMetadataInfo $metadata @param string $path @return string $code;
[ "Generate", "the", "updated", "code", "for", "the", "given", "ClassMetadataInfo", "and", "xml", "-", "entity", "at", "path" ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Tools/XmlEntityGenerator.php#L226-L235
224,503
doctrine/oxm
lib/Doctrine/OXM/Mapping/Driver/AbstractFileDriver.php
AbstractFileDriver.getElement
public function getElement($className) { if ($file = $this->findMappingFile($className)) { $result = $this->loadMappingFile($file); return $result[$className]; } return false; }
php
public function getElement($className) { if ($file = $this->findMappingFile($className)) { $result = $this->loadMappingFile($file); return $result[$className]; } return false; }
[ "public", "function", "getElement", "(", "$", "className", ")", "{", "if", "(", "$", "file", "=", "$", "this", "->", "findMappingFile", "(", "$", "className", ")", ")", "{", "$", "result", "=", "$", "this", "->", "loadMappingFile", "(", "$", "file", ")", ";", "return", "$", "result", "[", "$", "className", "]", ";", "}", "return", "false", ";", "}" ]
Get the element of schema meta data for the class from the mapping file. This will lazily load the mapping file if it is not loaded yet @return array $element The element of schema meta data
[ "Get", "the", "element", "of", "schema", "meta", "data", "for", "the", "class", "from", "the", "mapping", "file", ".", "This", "will", "lazily", "load", "the", "mapping", "file", "if", "it", "is", "not", "loaded", "yet" ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Mapping/Driver/AbstractFileDriver.php#L108-L115
224,504
doctrine/oxm
lib/Doctrine/OXM/Mapping/Driver/AbstractFileDriver.php
AbstractFileDriver.isTransient
public function isTransient($className) { $fileName = str_replace('\\', '.', $className) . $this->fileExtension; // Check whether file exists foreach ((array) $this->paths as $path) { if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { return false; } } return true; }
php
public function isTransient($className) { $fileName = str_replace('\\', '.', $className) . $this->fileExtension; // Check whether file exists foreach ((array) $this->paths as $path) { if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { return false; } } return true; }
[ "public", "function", "isTransient", "(", "$", "className", ")", "{", "$", "fileName", "=", "str_replace", "(", "'\\\\'", ",", "'.'", ",", "$", "className", ")", ".", "$", "this", "->", "fileExtension", ";", "// Check whether file exists", "foreach", "(", "(", "array", ")", "$", "this", "->", "paths", "as", "$", "path", ")", "{", "if", "(", "file_exists", "(", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "fileName", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Whether the class with the specified name should have its metadata loaded. This is only the case if it is either mapped as an Entity or a MappedSuperclass. @param string $className @return boolean
[ "Whether", "the", "class", "with", "the", "specified", "name", "should", "have", "its", "metadata", "loaded", ".", "This", "is", "only", "the", "case", "if", "it", "is", "either", "mapped", "as", "an", "Entity", "or", "a", "MappedSuperclass", "." ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Mapping/Driver/AbstractFileDriver.php#L125-L137
224,505
doctrine/oxm
lib/Doctrine/OXM/Mapping/Driver/AbstractFileDriver.php
AbstractFileDriver.findMappingFile
protected function findMappingFile($className) { $fileName = str_replace('\\', '.', $className) . $this->fileExtension; // Check whether file exists foreach ((array) $this->paths as $path) { if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { return $path . DIRECTORY_SEPARATOR . $fileName; } } return false; //throw MappingException::mappingFileNotFound($className, $fileName); }
php
protected function findMappingFile($className) { $fileName = str_replace('\\', '.', $className) . $this->fileExtension; // Check whether file exists foreach ((array) $this->paths as $path) { if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { return $path . DIRECTORY_SEPARATOR . $fileName; } } return false; //throw MappingException::mappingFileNotFound($className, $fileName); }
[ "protected", "function", "findMappingFile", "(", "$", "className", ")", "{", "$", "fileName", "=", "str_replace", "(", "'\\\\'", ",", "'.'", ",", "$", "className", ")", ".", "$", "this", "->", "fileExtension", ";", "// Check whether file exists", "foreach", "(", "(", "array", ")", "$", "this", "->", "paths", "as", "$", "path", ")", "{", "if", "(", "file_exists", "(", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "fileName", ")", ")", "{", "return", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "fileName", ";", "}", "}", "return", "false", ";", "//throw MappingException::mappingFileNotFound($className, $fileName);", "}" ]
Finds the mapping file for the class with the given name by searching through the configured paths. @param $className @return string The (absolute) file name. @throws MappingException
[ "Finds", "the", "mapping", "file", "for", "the", "class", "with", "the", "given", "name", "by", "searching", "through", "the", "configured", "paths", "." ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Mapping/Driver/AbstractFileDriver.php#L183-L196
224,506
nealio82/avro-php
src/Avro/DataIO/DataIOWriter.php
DataIOWriter.write_block
private function write_block() { if ($this->block_count > 0) { $this->encoder->write_long($this->block_count); $to_write = strval($this->buffer); $this->encoder->write_long(strlen($to_write)); if (DataIO::is_valid_codec( $this->metadata[DataIO::METADATA_CODEC_ATTR]) ) $this->write($to_write); else throw new DataIOException( sprintf('codec %s is not supported', $this->metadata[DataIO::METADATA_CODEC_ATTR])); $this->write($this->sync_marker); $this->buffer->truncate(); $this->block_count = 0; } }
php
private function write_block() { if ($this->block_count > 0) { $this->encoder->write_long($this->block_count); $to_write = strval($this->buffer); $this->encoder->write_long(strlen($to_write)); if (DataIO::is_valid_codec( $this->metadata[DataIO::METADATA_CODEC_ATTR]) ) $this->write($to_write); else throw new DataIOException( sprintf('codec %s is not supported', $this->metadata[DataIO::METADATA_CODEC_ATTR])); $this->write($this->sync_marker); $this->buffer->truncate(); $this->block_count = 0; } }
[ "private", "function", "write_block", "(", ")", "{", "if", "(", "$", "this", "->", "block_count", ">", "0", ")", "{", "$", "this", "->", "encoder", "->", "write_long", "(", "$", "this", "->", "block_count", ")", ";", "$", "to_write", "=", "strval", "(", "$", "this", "->", "buffer", ")", ";", "$", "this", "->", "encoder", "->", "write_long", "(", "strlen", "(", "$", "to_write", ")", ")", ";", "if", "(", "DataIO", "::", "is_valid_codec", "(", "$", "this", "->", "metadata", "[", "DataIO", "::", "METADATA_CODEC_ATTR", "]", ")", ")", "$", "this", "->", "write", "(", "$", "to_write", ")", ";", "else", "throw", "new", "DataIOException", "(", "sprintf", "(", "'codec %s is not supported'", ",", "$", "this", "->", "metadata", "[", "DataIO", "::", "METADATA_CODEC_ATTR", "]", ")", ")", ";", "$", "this", "->", "write", "(", "$", "this", "->", "sync_marker", ")", ";", "$", "this", "->", "buffer", "->", "truncate", "(", ")", ";", "$", "this", "->", "block_count", "=", "0", ";", "}", "}" ]
Writes a block of data to the IO object container. @throws DataIOException if the codec provided by the encoder is not supported @internal Should the codec check happen in the constructor? Why wait until we're writing data?
[ "Writes", "a", "block", "of", "data", "to", "the", "IO", "object", "container", "." ]
bf99a4155cb6c2df4a153b2b190389a48c1b79f7
https://github.com/nealio82/avro-php/blob/bf99a4155cb6c2df4a153b2b190389a48c1b79f7/src/Avro/DataIO/DataIOWriter.php#L145-L165
224,507
nealio82/avro-php
src/Avro/DataIO/DataIOWriter.php
DataIOWriter.write_header
private function write_header() { $this->write(DataIO::magic()); $this->datum_writer->write_data(DataIO::metadata_schema(), $this->metadata, $this->encoder); $this->write($this->sync_marker); }
php
private function write_header() { $this->write(DataIO::magic()); $this->datum_writer->write_data(DataIO::metadata_schema(), $this->metadata, $this->encoder); $this->write($this->sync_marker); }
[ "private", "function", "write_header", "(", ")", "{", "$", "this", "->", "write", "(", "DataIO", "::", "magic", "(", ")", ")", ";", "$", "this", "->", "datum_writer", "->", "write_data", "(", "DataIO", "::", "metadata_schema", "(", ")", ",", "$", "this", "->", "metadata", ",", "$", "this", "->", "encoder", ")", ";", "$", "this", "->", "write", "(", "$", "this", "->", "sync_marker", ")", ";", "}" ]
Writes the header of the IO object container
[ "Writes", "the", "header", "of", "the", "IO", "object", "container" ]
bf99a4155cb6c2df4a153b2b190389a48c1b79f7
https://github.com/nealio82/avro-php/blob/bf99a4155cb6c2df4a153b2b190389a48c1b79f7/src/Avro/DataIO/DataIOWriter.php#L170-L176
224,508
someline/rest-api-client
src/Someline/Rest/RestClient.php
RestClient.setUp
public function setUp() { $base_uri = $this->getServiceConfig('base_uri'); $guzzle_client_config = $this->getConfig('guzzle_client_config', []); if (!ends_with($base_uri, '/')) { $base_uri .= '/'; } $this->printLine("REST CLIENT BASE URI: " . $base_uri); $this->client = new Client(array_merge($guzzle_client_config, [ 'base_uri' => $base_uri, 'exceptions' => false, ])); }
php
public function setUp() { $base_uri = $this->getServiceConfig('base_uri'); $guzzle_client_config = $this->getConfig('guzzle_client_config', []); if (!ends_with($base_uri, '/')) { $base_uri .= '/'; } $this->printLine("REST CLIENT BASE URI: " . $base_uri); $this->client = new Client(array_merge($guzzle_client_config, [ 'base_uri' => $base_uri, 'exceptions' => false, ])); }
[ "public", "function", "setUp", "(", ")", "{", "$", "base_uri", "=", "$", "this", "->", "getServiceConfig", "(", "'base_uri'", ")", ";", "$", "guzzle_client_config", "=", "$", "this", "->", "getConfig", "(", "'guzzle_client_config'", ",", "[", "]", ")", ";", "if", "(", "!", "ends_with", "(", "$", "base_uri", ",", "'/'", ")", ")", "{", "$", "base_uri", ".=", "'/'", ";", "}", "$", "this", "->", "printLine", "(", "\"REST CLIENT BASE URI: \"", ".", "$", "base_uri", ")", ";", "$", "this", "->", "client", "=", "new", "Client", "(", "array_merge", "(", "$", "guzzle_client_config", ",", "[", "'base_uri'", "=>", "$", "base_uri", ",", "'exceptions'", "=>", "false", ",", "]", ")", ")", ";", "}" ]
Set Up Client
[ "Set", "Up", "Client" ]
b9ffd265a6ff086941d90a8d899c72a28e5a207e
https://github.com/someline/rest-api-client/blob/b9ffd265a6ff086941d90a8d899c72a28e5a207e/src/Someline/Rest/RestClient.php#L194-L206
224,509
someline/rest-api-client
src/Someline/Rest/RestClient.php
RestClient.useOAuthTokenFromCache
private function useOAuthTokenFromCache() { if (!$this->use_cache_token) { return; } $this->oauth_tokens = \Cache::get($this->getOauthTokensCacheKey(), []); if (!empty($this->oauth_tokens)) { $this->printLine("Using OAuth Tokens from cache:"); $this->printArray($this->oauth_tokens); } }
php
private function useOAuthTokenFromCache() { if (!$this->use_cache_token) { return; } $this->oauth_tokens = \Cache::get($this->getOauthTokensCacheKey(), []); if (!empty($this->oauth_tokens)) { $this->printLine("Using OAuth Tokens from cache:"); $this->printArray($this->oauth_tokens); } }
[ "private", "function", "useOAuthTokenFromCache", "(", ")", "{", "if", "(", "!", "$", "this", "->", "use_cache_token", ")", "{", "return", ";", "}", "$", "this", "->", "oauth_tokens", "=", "\\", "Cache", "::", "get", "(", "$", "this", "->", "getOauthTokensCacheKey", "(", ")", ",", "[", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "oauth_tokens", ")", ")", "{", "$", "this", "->", "printLine", "(", "\"Using OAuth Tokens from cache:\"", ")", ";", "$", "this", "->", "printArray", "(", "$", "this", "->", "oauth_tokens", ")", ";", "}", "}" ]
Use OAuth Tokens from Cache
[ "Use", "OAuth", "Tokens", "from", "Cache" ]
b9ffd265a6ff086941d90a8d899c72a28e5a207e
https://github.com/someline/rest-api-client/blob/b9ffd265a6ff086941d90a8d899c72a28e5a207e/src/Someline/Rest/RestClient.php#L318-L329
224,510
bramstroker/zf2-fullpage-cache
src/Service/CacheService.php
CacheService.load
public function load(MvcEvent $mvcEvent) { $id = $this->getIdGenerator()->generate(); if (!$this->getCacheStorage()->hasItem($id)) { return null; }; $event = $this->createCacheEvent(CacheEvent::EVENT_LOAD, $mvcEvent, $id); $results = $this->getEventManager()->triggerEventUntil(function ($result) { return ($result === false); }, $event); if ($results->stopped()) { return null; } return $this->getCacheStorage()->getItem($id); }
php
public function load(MvcEvent $mvcEvent) { $id = $this->getIdGenerator()->generate(); if (!$this->getCacheStorage()->hasItem($id)) { return null; }; $event = $this->createCacheEvent(CacheEvent::EVENT_LOAD, $mvcEvent, $id); $results = $this->getEventManager()->triggerEventUntil(function ($result) { return ($result === false); }, $event); if ($results->stopped()) { return null; } return $this->getCacheStorage()->getItem($id); }
[ "public", "function", "load", "(", "MvcEvent", "$", "mvcEvent", ")", "{", "$", "id", "=", "$", "this", "->", "getIdGenerator", "(", ")", "->", "generate", "(", ")", ";", "if", "(", "!", "$", "this", "->", "getCacheStorage", "(", ")", "->", "hasItem", "(", "$", "id", ")", ")", "{", "return", "null", ";", "}", ";", "$", "event", "=", "$", "this", "->", "createCacheEvent", "(", "CacheEvent", "::", "EVENT_LOAD", ",", "$", "mvcEvent", ",", "$", "id", ")", ";", "$", "results", "=", "$", "this", "->", "getEventManager", "(", ")", "->", "triggerEventUntil", "(", "function", "(", "$", "result", ")", "{", "return", "(", "$", "result", "===", "false", ")", ";", "}", ",", "$", "event", ")", ";", "if", "(", "$", "results", "->", "stopped", "(", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "getCacheStorage", "(", ")", "->", "getItem", "(", "$", "id", ")", ";", "}" ]
Check if a page is saved in the cache and return contents. Return null when no item is found. @param MvcEvent $mvcEvent @return mixed|null
[ "Check", "if", "a", "page", "is", "saved", "in", "the", "cache", "and", "return", "contents", ".", "Return", "null", "when", "no", "item", "is", "found", "." ]
ae2cf413e445163a6725afbca597d6fb98c38f0d
https://github.com/bramstroker/zf2-fullpage-cache/blob/ae2cf413e445163a6725afbca597d6fb98c38f0d/src/Service/CacheService.php#L68-L86
224,511
bramstroker/zf2-fullpage-cache
src/Service/CacheService.php
CacheService.save
public function save(MvcEvent $mvcEvent) { if (!$this->shouldCacheRequest($mvcEvent)) { return; } $id = $this->getIdGenerator()->generate(); $item = ($this->getOptions()->getCacheResponse() === true) ? serialize($mvcEvent->getResponse()) : $mvcEvent->getResponse()->getContent(); $this->getCacheStorage()->setItem($id, $item); $cacheEvent = $this->createCacheEvent(CacheEvent::EVENT_SAVE, $mvcEvent, $id); $this->getEventManager()->triggerEvent($cacheEvent); $cacheStorage = $this->getCacheStorage(); if ($cacheStorage instanceof TaggableInterface) { $tags = array_unique(array_merge($this->getTags($mvcEvent), $cacheEvent->getTags())); $cacheStorage->setTags($id, $this->prefixTags($tags)); } }
php
public function save(MvcEvent $mvcEvent) { if (!$this->shouldCacheRequest($mvcEvent)) { return; } $id = $this->getIdGenerator()->generate(); $item = ($this->getOptions()->getCacheResponse() === true) ? serialize($mvcEvent->getResponse()) : $mvcEvent->getResponse()->getContent(); $this->getCacheStorage()->setItem($id, $item); $cacheEvent = $this->createCacheEvent(CacheEvent::EVENT_SAVE, $mvcEvent, $id); $this->getEventManager()->triggerEvent($cacheEvent); $cacheStorage = $this->getCacheStorage(); if ($cacheStorage instanceof TaggableInterface) { $tags = array_unique(array_merge($this->getTags($mvcEvent), $cacheEvent->getTags())); $cacheStorage->setTags($id, $this->prefixTags($tags)); } }
[ "public", "function", "save", "(", "MvcEvent", "$", "mvcEvent", ")", "{", "if", "(", "!", "$", "this", "->", "shouldCacheRequest", "(", "$", "mvcEvent", ")", ")", "{", "return", ";", "}", "$", "id", "=", "$", "this", "->", "getIdGenerator", "(", ")", "->", "generate", "(", ")", ";", "$", "item", "=", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getCacheResponse", "(", ")", "===", "true", ")", "?", "serialize", "(", "$", "mvcEvent", "->", "getResponse", "(", ")", ")", ":", "$", "mvcEvent", "->", "getResponse", "(", ")", "->", "getContent", "(", ")", ";", "$", "this", "->", "getCacheStorage", "(", ")", "->", "setItem", "(", "$", "id", ",", "$", "item", ")", ";", "$", "cacheEvent", "=", "$", "this", "->", "createCacheEvent", "(", "CacheEvent", "::", "EVENT_SAVE", ",", "$", "mvcEvent", ",", "$", "id", ")", ";", "$", "this", "->", "getEventManager", "(", ")", "->", "triggerEvent", "(", "$", "cacheEvent", ")", ";", "$", "cacheStorage", "=", "$", "this", "->", "getCacheStorage", "(", ")", ";", "if", "(", "$", "cacheStorage", "instanceof", "TaggableInterface", ")", "{", "$", "tags", "=", "array_unique", "(", "array_merge", "(", "$", "this", "->", "getTags", "(", "$", "mvcEvent", ")", ",", "$", "cacheEvent", "->", "getTags", "(", ")", ")", ")", ";", "$", "cacheStorage", "->", "setTags", "(", "$", "id", ",", "$", "this", "->", "prefixTags", "(", "$", "tags", ")", ")", ";", "}", "}" ]
Save the page contents to the cache storage. @param MvcEvent $mvcEvent
[ "Save", "the", "page", "contents", "to", "the", "cache", "storage", "." ]
ae2cf413e445163a6725afbca597d6fb98c38f0d
https://github.com/bramstroker/zf2-fullpage-cache/blob/ae2cf413e445163a6725afbca597d6fb98c38f0d/src/Service/CacheService.php#L93-L113
224,512
bramstroker/zf2-fullpage-cache
src/Service/CacheService.php
CacheService.shouldCacheRequest
protected function shouldCacheRequest(MvcEvent $mvcEvent) { $event = $this->createCacheEvent(CacheEvent::EVENT_SHOULDCACHE, $mvcEvent); $results = $this->getEventManager()->triggerEventUntil(function ($result) { return $result; }, $event); if ($results->stopped()) { return $results->last(); } return false; }
php
protected function shouldCacheRequest(MvcEvent $mvcEvent) { $event = $this->createCacheEvent(CacheEvent::EVENT_SHOULDCACHE, $mvcEvent); $results = $this->getEventManager()->triggerEventUntil(function ($result) { return $result; }, $event); if ($results->stopped()) { return $results->last(); } return false; }
[ "protected", "function", "shouldCacheRequest", "(", "MvcEvent", "$", "mvcEvent", ")", "{", "$", "event", "=", "$", "this", "->", "createCacheEvent", "(", "CacheEvent", "::", "EVENT_SHOULDCACHE", ",", "$", "mvcEvent", ")", ";", "$", "results", "=", "$", "this", "->", "getEventManager", "(", ")", "->", "triggerEventUntil", "(", "function", "(", "$", "result", ")", "{", "return", "$", "result", ";", "}", ",", "$", "event", ")", ";", "if", "(", "$", "results", "->", "stopped", "(", ")", ")", "{", "return", "$", "results", "->", "last", "(", ")", ";", "}", "return", "false", ";", "}" ]
Determine if we should cache the current request @param MvcEvent $mvcEvent @return bool
[ "Determine", "if", "we", "should", "cache", "the", "current", "request" ]
ae2cf413e445163a6725afbca597d6fb98c38f0d
https://github.com/bramstroker/zf2-fullpage-cache/blob/ae2cf413e445163a6725afbca597d6fb98c38f0d/src/Service/CacheService.php#L121-L134
224,513
bramstroker/zf2-fullpage-cache
src/Service/CacheService.php
CacheService.getTags
public function getTags(MvcEvent $event) { $routeName = $event->getRouteMatch()->getMatchedRouteName(); $tags = [ 'route_' . $routeName ]; foreach ($event->getRouteMatch()->getParams() as $key => $value) { if ($key == 'controller') { $tags[] = 'controller_' . $value; } else { $tags[] = 'param_' . $key . '_' . $value; } } return $tags; }
php
public function getTags(MvcEvent $event) { $routeName = $event->getRouteMatch()->getMatchedRouteName(); $tags = [ 'route_' . $routeName ]; foreach ($event->getRouteMatch()->getParams() as $key => $value) { if ($key == 'controller') { $tags[] = 'controller_' . $value; } else { $tags[] = 'param_' . $key . '_' . $value; } } return $tags; }
[ "public", "function", "getTags", "(", "MvcEvent", "$", "event", ")", "{", "$", "routeName", "=", "$", "event", "->", "getRouteMatch", "(", ")", "->", "getMatchedRouteName", "(", ")", ";", "$", "tags", "=", "[", "'route_'", ".", "$", "routeName", "]", ";", "foreach", "(", "$", "event", "->", "getRouteMatch", "(", ")", "->", "getParams", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "==", "'controller'", ")", "{", "$", "tags", "[", "]", "=", "'controller_'", ".", "$", "value", ";", "}", "else", "{", "$", "tags", "[", "]", "=", "'param_'", ".", "$", "key", ".", "'_'", ".", "$", "value", ";", "}", "}", "return", "$", "tags", ";", "}" ]
Cache tags to use for this page @param MvcEvent $event @return array
[ "Cache", "tags", "to", "use", "for", "this", "page" ]
ae2cf413e445163a6725afbca597d6fb98c38f0d
https://github.com/bramstroker/zf2-fullpage-cache/blob/ae2cf413e445163a6725afbca597d6fb98c38f0d/src/Service/CacheService.php#L159-L174
224,514
doctrine/oxm
lib/Doctrine/OXM/XmlEntityRepository.php
XmlEntityRepository.find
public function find($id, $lockMode = LockMode::NONE, $lockVersion = null) { // Check identity map first if ($entity = $this->xem->getUnitOfWork()->tryGetById($id, $this->class->rootXmlEntityName)) { if ($lockMode != LockMode::NONE) { $this->xem->lock($entity, $lockMode, $lockVersion); } return $entity; // Hit! } if ($lockMode == LockMode::NONE) { return $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id); } else if ($lockMode == LockMode::OPTIMISTIC) { if (!$this->class->isVersioned) { throw OptimisticLockException::notVersioned($this->entityName); } $entity = $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id); $this->xem->getUnitOfWork()->lock($entity, $lockMode, $lockVersion); return $entity; } else { if (!$this->xem->getConnection()->isTransactionActive()) { throw TransactionRequiredException::transactionRequired(); } return $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id, null, null, array(), $lockMode); } }
php
public function find($id, $lockMode = LockMode::NONE, $lockVersion = null) { // Check identity map first if ($entity = $this->xem->getUnitOfWork()->tryGetById($id, $this->class->rootXmlEntityName)) { if ($lockMode != LockMode::NONE) { $this->xem->lock($entity, $lockMode, $lockVersion); } return $entity; // Hit! } if ($lockMode == LockMode::NONE) { return $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id); } else if ($lockMode == LockMode::OPTIMISTIC) { if (!$this->class->isVersioned) { throw OptimisticLockException::notVersioned($this->entityName); } $entity = $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id); $this->xem->getUnitOfWork()->lock($entity, $lockMode, $lockVersion); return $entity; } else { if (!$this->xem->getConnection()->isTransactionActive()) { throw TransactionRequiredException::transactionRequired(); } return $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id, null, null, array(), $lockMode); } }
[ "public", "function", "find", "(", "$", "id", ",", "$", "lockMode", "=", "LockMode", "::", "NONE", ",", "$", "lockVersion", "=", "null", ")", "{", "// Check identity map first", "if", "(", "$", "entity", "=", "$", "this", "->", "xem", "->", "getUnitOfWork", "(", ")", "->", "tryGetById", "(", "$", "id", ",", "$", "this", "->", "class", "->", "rootXmlEntityName", ")", ")", "{", "if", "(", "$", "lockMode", "!=", "LockMode", "::", "NONE", ")", "{", "$", "this", "->", "xem", "->", "lock", "(", "$", "entity", ",", "$", "lockMode", ",", "$", "lockVersion", ")", ";", "}", "return", "$", "entity", ";", "// Hit!", "}", "if", "(", "$", "lockMode", "==", "LockMode", "::", "NONE", ")", "{", "return", "$", "this", "->", "xem", "->", "getUnitOfWork", "(", ")", "->", "getXmlEntityPersister", "(", "$", "this", "->", "entityName", ")", "->", "load", "(", "$", "id", ")", ";", "}", "else", "if", "(", "$", "lockMode", "==", "LockMode", "::", "OPTIMISTIC", ")", "{", "if", "(", "!", "$", "this", "->", "class", "->", "isVersioned", ")", "{", "throw", "OptimisticLockException", "::", "notVersioned", "(", "$", "this", "->", "entityName", ")", ";", "}", "$", "entity", "=", "$", "this", "->", "xem", "->", "getUnitOfWork", "(", ")", "->", "getXmlEntityPersister", "(", "$", "this", "->", "entityName", ")", "->", "load", "(", "$", "id", ")", ";", "$", "this", "->", "xem", "->", "getUnitOfWork", "(", ")", "->", "lock", "(", "$", "entity", ",", "$", "lockMode", ",", "$", "lockVersion", ")", ";", "return", "$", "entity", ";", "}", "else", "{", "if", "(", "!", "$", "this", "->", "xem", "->", "getConnection", "(", ")", "->", "isTransactionActive", "(", ")", ")", "{", "throw", "TransactionRequiredException", "::", "transactionRequired", "(", ")", ";", "}", "return", "$", "this", "->", "xem", "->", "getUnitOfWork", "(", ")", "->", "getXmlEntityPersister", "(", "$", "this", "->", "entityName", ")", "->", "load", "(", "$", "id", ",", "null", ",", "null", ",", "array", "(", ")", ",", "$", "lockMode", ")", ";", "}", "}" ]
Finds an entity by its identifier. @param $id The identifier. @param int $lockMode @param int $lockVersion @return object The entity.
[ "Finds", "an", "entity", "by", "its", "identifier", "." ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/XmlEntityRepository.php#L103-L132
224,515
doctrine/oxm
lib/Doctrine/OXM/Mapping/Driver/PHPDriver.php
PHPDriver.loadMetadataForClass
public function loadMetadataForClass($className, ClassMetadataInfo $metadata) { $this->metadata = $metadata; $this->loadMappingFile($this->findMappingFile($className)); }
php
public function loadMetadataForClass($className, ClassMetadataInfo $metadata) { $this->metadata = $metadata; $this->loadMappingFile($this->findMappingFile($className)); }
[ "public", "function", "loadMetadataForClass", "(", "$", "className", ",", "ClassMetadataInfo", "$", "metadata", ")", "{", "$", "this", "->", "metadata", "=", "$", "metadata", ";", "$", "this", "->", "loadMappingFile", "(", "$", "this", "->", "findMappingFile", "(", "$", "className", ")", ")", ";", "}" ]
Loads the mapping for the specified class into the provided container. @param string $className @param Mapping $mapping
[ "Loads", "the", "mapping", "for", "the", "specified", "class", "into", "the", "provided", "container", "." ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Mapping/Driver/PHPDriver.php#L44-L48
224,516
boboldehampsink/tagmanager
controllers/TagManagerController.php
TagManagerController.actionEditTag
public function actionEditTag(array $variables = array()) { if (!empty($variables['groupHandle'])) { $variables['group'] = craft()->tags->getTagGroupByHandle($variables['groupHandle']); } elseif (!empty($variables['groupId'])) { $variables['group'] = craft()->tags->getTagGroupById($variables['groupId']); } if (empty($variables['group'])) { throw new HttpException(404); } // Now let's set up the actual tag if (empty($variables['tag'])) { if (!empty($variables['tagId'])) { $variables['tag'] = craft()->tags->getTagById($variables['tagId'], craft()->locale->id); if (!$variables['tag']) { throw new HttpException(404); } } else { $variables['tag'] = new TagModel(); $variables['tag']->groupId = $variables['group']->id; } } // Tabs $variables['tabs'] = array(); foreach ($variables['group']->getFieldLayout()->getTabs() as $index => $tab) { // Do any of the fields on this tab have errors? $hasErrors = false; if ($variables['tag']->hasErrors()) { foreach ($tab->getFields() as $field) { if ($variables['tag']->getErrors($field->getField()->handle)) { $hasErrors = true; break; } } } $variables['tabs'][] = array( 'label' => $tab->name, 'url' => '#tab'.($index + 1), 'class' => ($hasErrors ? 'error' : null), ); } if (!$variables['tag']->id) { $variables['title'] = Craft::t('Create a new tag'); } else { $variables['title'] = $variables['tag']->title; } // Breadcrumbs $variables['crumbs'] = array( array('label' => Craft::t('Tag Manager'), 'url' => UrlHelper::getUrl('tagmanager')), array('label' => $variables['group']->name, 'url' => UrlHelper::getUrl('tagmanager')), ); // Set the "Continue Editing" URL $variables['continueEditingUrl'] = 'tagmanager/'.$variables['group']->handle.'/{id}'; // Render the template! $this->renderTemplate('tagmanager/_edit', $variables); }
php
public function actionEditTag(array $variables = array()) { if (!empty($variables['groupHandle'])) { $variables['group'] = craft()->tags->getTagGroupByHandle($variables['groupHandle']); } elseif (!empty($variables['groupId'])) { $variables['group'] = craft()->tags->getTagGroupById($variables['groupId']); } if (empty($variables['group'])) { throw new HttpException(404); } // Now let's set up the actual tag if (empty($variables['tag'])) { if (!empty($variables['tagId'])) { $variables['tag'] = craft()->tags->getTagById($variables['tagId'], craft()->locale->id); if (!$variables['tag']) { throw new HttpException(404); } } else { $variables['tag'] = new TagModel(); $variables['tag']->groupId = $variables['group']->id; } } // Tabs $variables['tabs'] = array(); foreach ($variables['group']->getFieldLayout()->getTabs() as $index => $tab) { // Do any of the fields on this tab have errors? $hasErrors = false; if ($variables['tag']->hasErrors()) { foreach ($tab->getFields() as $field) { if ($variables['tag']->getErrors($field->getField()->handle)) { $hasErrors = true; break; } } } $variables['tabs'][] = array( 'label' => $tab->name, 'url' => '#tab'.($index + 1), 'class' => ($hasErrors ? 'error' : null), ); } if (!$variables['tag']->id) { $variables['title'] = Craft::t('Create a new tag'); } else { $variables['title'] = $variables['tag']->title; } // Breadcrumbs $variables['crumbs'] = array( array('label' => Craft::t('Tag Manager'), 'url' => UrlHelper::getUrl('tagmanager')), array('label' => $variables['group']->name, 'url' => UrlHelper::getUrl('tagmanager')), ); // Set the "Continue Editing" URL $variables['continueEditingUrl'] = 'tagmanager/'.$variables['group']->handle.'/{id}'; // Render the template! $this->renderTemplate('tagmanager/_edit', $variables); }
[ "public", "function", "actionEditTag", "(", "array", "$", "variables", "=", "array", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "variables", "[", "'groupHandle'", "]", ")", ")", "{", "$", "variables", "[", "'group'", "]", "=", "craft", "(", ")", "->", "tags", "->", "getTagGroupByHandle", "(", "$", "variables", "[", "'groupHandle'", "]", ")", ";", "}", "elseif", "(", "!", "empty", "(", "$", "variables", "[", "'groupId'", "]", ")", ")", "{", "$", "variables", "[", "'group'", "]", "=", "craft", "(", ")", "->", "tags", "->", "getTagGroupById", "(", "$", "variables", "[", "'groupId'", "]", ")", ";", "}", "if", "(", "empty", "(", "$", "variables", "[", "'group'", "]", ")", ")", "{", "throw", "new", "HttpException", "(", "404", ")", ";", "}", "// Now let's set up the actual tag", "if", "(", "empty", "(", "$", "variables", "[", "'tag'", "]", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "variables", "[", "'tagId'", "]", ")", ")", "{", "$", "variables", "[", "'tag'", "]", "=", "craft", "(", ")", "->", "tags", "->", "getTagById", "(", "$", "variables", "[", "'tagId'", "]", ",", "craft", "(", ")", "->", "locale", "->", "id", ")", ";", "if", "(", "!", "$", "variables", "[", "'tag'", "]", ")", "{", "throw", "new", "HttpException", "(", "404", ")", ";", "}", "}", "else", "{", "$", "variables", "[", "'tag'", "]", "=", "new", "TagModel", "(", ")", ";", "$", "variables", "[", "'tag'", "]", "->", "groupId", "=", "$", "variables", "[", "'group'", "]", "->", "id", ";", "}", "}", "// Tabs", "$", "variables", "[", "'tabs'", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "variables", "[", "'group'", "]", "->", "getFieldLayout", "(", ")", "->", "getTabs", "(", ")", "as", "$", "index", "=>", "$", "tab", ")", "{", "// Do any of the fields on this tab have errors?", "$", "hasErrors", "=", "false", ";", "if", "(", "$", "variables", "[", "'tag'", "]", "->", "hasErrors", "(", ")", ")", "{", "foreach", "(", "$", "tab", "->", "getFields", "(", ")", "as", "$", "field", ")", "{", "if", "(", "$", "variables", "[", "'tag'", "]", "->", "getErrors", "(", "$", "field", "->", "getField", "(", ")", "->", "handle", ")", ")", "{", "$", "hasErrors", "=", "true", ";", "break", ";", "}", "}", "}", "$", "variables", "[", "'tabs'", "]", "[", "]", "=", "array", "(", "'label'", "=>", "$", "tab", "->", "name", ",", "'url'", "=>", "'#tab'", ".", "(", "$", "index", "+", "1", ")", ",", "'class'", "=>", "(", "$", "hasErrors", "?", "'error'", ":", "null", ")", ",", ")", ";", "}", "if", "(", "!", "$", "variables", "[", "'tag'", "]", "->", "id", ")", "{", "$", "variables", "[", "'title'", "]", "=", "Craft", "::", "t", "(", "'Create a new tag'", ")", ";", "}", "else", "{", "$", "variables", "[", "'title'", "]", "=", "$", "variables", "[", "'tag'", "]", "->", "title", ";", "}", "// Breadcrumbs", "$", "variables", "[", "'crumbs'", "]", "=", "array", "(", "array", "(", "'label'", "=>", "Craft", "::", "t", "(", "'Tag Manager'", ")", ",", "'url'", "=>", "UrlHelper", "::", "getUrl", "(", "'tagmanager'", ")", ")", ",", "array", "(", "'label'", "=>", "$", "variables", "[", "'group'", "]", "->", "name", ",", "'url'", "=>", "UrlHelper", "::", "getUrl", "(", "'tagmanager'", ")", ")", ",", ")", ";", "// Set the \"Continue Editing\" URL", "$", "variables", "[", "'continueEditingUrl'", "]", "=", "'tagmanager/'", ".", "$", "variables", "[", "'group'", "]", "->", "handle", ".", "'/{id}'", ";", "// Render the template!", "$", "this", "->", "renderTemplate", "(", "'tagmanager/_edit'", ",", "$", "variables", ")", ";", "}" ]
Edit a tag. @param array $variables @throws HttpException
[ "Edit", "a", "tag", "." ]
99d28c6424e92542142fad766a471bbe7d43e9fa
https://github.com/boboldehampsink/tagmanager/blob/99d28c6424e92542142fad766a471bbe7d43e9fa/controllers/TagManagerController.php#L35-L90
224,517
descubraomundo/omnipay-pagarme
src/Message/Response.php
Response.getCustomerReference
public function getCustomerReference() { if (isset($this->data['object']) && 'customer' === $this->data['object']) { return $this->data['id']; } if (isset($this->data['object']) && 'transaction' === $this->data['object']) { if (! empty($this->data['customer'])) { return $this->data['customer']['id']; } } if (isset($this->data['object']) && 'card' === $this->data['object']) { if (! empty($this->data['customer'])) { return $this->data['customer']['id']; } } return null; }
php
public function getCustomerReference() { if (isset($this->data['object']) && 'customer' === $this->data['object']) { return $this->data['id']; } if (isset($this->data['object']) && 'transaction' === $this->data['object']) { if (! empty($this->data['customer'])) { return $this->data['customer']['id']; } } if (isset($this->data['object']) && 'card' === $this->data['object']) { if (! empty($this->data['customer'])) { return $this->data['customer']['id']; } } return null; }
[ "public", "function", "getCustomerReference", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "'object'", "]", ")", "&&", "'customer'", "===", "$", "this", "->", "data", "[", "'object'", "]", ")", "{", "return", "$", "this", "->", "data", "[", "'id'", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "'object'", "]", ")", "&&", "'transaction'", "===", "$", "this", "->", "data", "[", "'object'", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "data", "[", "'customer'", "]", ")", ")", "{", "return", "$", "this", "->", "data", "[", "'customer'", "]", "[", "'id'", "]", ";", "}", "}", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "'object'", "]", ")", "&&", "'card'", "===", "$", "this", "->", "data", "[", "'object'", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "data", "[", "'customer'", "]", ")", ")", "{", "return", "$", "this", "->", "data", "[", "'customer'", "]", "[", "'id'", "]", ";", "}", "}", "return", "null", ";", "}" ]
Get a customer reference, for createCustomer requests. @return string|null
[ "Get", "a", "customer", "reference", "for", "createCustomer", "requests", "." ]
99e92dffd1640bdaf736560e26ec244326a3dd4a
https://github.com/descubraomundo/omnipay-pagarme/blob/99e92dffd1640bdaf736560e26ec244326a3dd4a/src/Message/Response.php#L66-L83
224,518
descubraomundo/omnipay-pagarme
src/Message/Response.php
Response.getBoleto
public function getBoleto() { if (isset($this->data['object']) && 'transaction' === $this->data['object']) { if ( $this->data['boleto_url'] ) { $data = array( 'boleto_url' => $this->data['boleto_url'], 'boleto_barcode' => $this->data['boleto_barcode'], 'boleto_expiration_date' => $this->data['boleto_expiration_date'], ); return $data; } else { return null; } } return null; }
php
public function getBoleto() { if (isset($this->data['object']) && 'transaction' === $this->data['object']) { if ( $this->data['boleto_url'] ) { $data = array( 'boleto_url' => $this->data['boleto_url'], 'boleto_barcode' => $this->data['boleto_barcode'], 'boleto_expiration_date' => $this->data['boleto_expiration_date'], ); return $data; } else { return null; } } return null; }
[ "public", "function", "getBoleto", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "'object'", "]", ")", "&&", "'transaction'", "===", "$", "this", "->", "data", "[", "'object'", "]", ")", "{", "if", "(", "$", "this", "->", "data", "[", "'boleto_url'", "]", ")", "{", "$", "data", "=", "array", "(", "'boleto_url'", "=>", "$", "this", "->", "data", "[", "'boleto_url'", "]", ",", "'boleto_barcode'", "=>", "$", "this", "->", "data", "[", "'boleto_barcode'", "]", ",", "'boleto_expiration_date'", "=>", "$", "this", "->", "data", "[", "'boleto_expiration_date'", "]", ",", ")", ";", "return", "$", "data", ";", "}", "else", "{", "return", "null", ";", "}", "}", "return", "null", ";", "}" ]
Get the boleto_url, boleto_barcode and boleto_expiration_date in the transaction object. @return array|null the boleto_url, boleto_barcode and boleto_expiration_date
[ "Get", "the", "boleto_url", "boleto_barcode", "and", "boleto_expiration_date", "in", "the", "transaction", "object", "." ]
99e92dffd1640bdaf736560e26ec244326a3dd4a
https://github.com/descubraomundo/omnipay-pagarme/blob/99e92dffd1640bdaf736560e26ec244326a3dd4a/src/Message/Response.php#L111-L127
224,519
bramstroker/zf2-fullpage-cache
src/Listener/CacheListener.php
CacheListener.onRoute
public function onRoute(MvcEvent $e) { if (!$e->getRequest() instanceof HttpRequest || !$e->getResponse() instanceof HttpResponse) { return null; } /** @var HttpResponse $response */ $response = $e->getResponse(); $data = $this->getCacheService()->load($e); if ($data !== null) { $this->loadedFromCache = true; if ($this->getOptions()->getCacheResponse() === true) { $response = unserialize($data); } else { $response = $e->getResponse(); $response->setContent($data); } $this->addDebugResponseHeader($response, 'Hit'); return $response; } $this->addDebugResponseHeader($response, 'Miss'); }
php
public function onRoute(MvcEvent $e) { if (!$e->getRequest() instanceof HttpRequest || !$e->getResponse() instanceof HttpResponse) { return null; } /** @var HttpResponse $response */ $response = $e->getResponse(); $data = $this->getCacheService()->load($e); if ($data !== null) { $this->loadedFromCache = true; if ($this->getOptions()->getCacheResponse() === true) { $response = unserialize($data); } else { $response = $e->getResponse(); $response->setContent($data); } $this->addDebugResponseHeader($response, 'Hit'); return $response; } $this->addDebugResponseHeader($response, 'Miss'); }
[ "public", "function", "onRoute", "(", "MvcEvent", "$", "e", ")", "{", "if", "(", "!", "$", "e", "->", "getRequest", "(", ")", "instanceof", "HttpRequest", "||", "!", "$", "e", "->", "getResponse", "(", ")", "instanceof", "HttpResponse", ")", "{", "return", "null", ";", "}", "/** @var HttpResponse $response */", "$", "response", "=", "$", "e", "->", "getResponse", "(", ")", ";", "$", "data", "=", "$", "this", "->", "getCacheService", "(", ")", "->", "load", "(", "$", "e", ")", ";", "if", "(", "$", "data", "!==", "null", ")", "{", "$", "this", "->", "loadedFromCache", "=", "true", ";", "if", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getCacheResponse", "(", ")", "===", "true", ")", "{", "$", "response", "=", "unserialize", "(", "$", "data", ")", ";", "}", "else", "{", "$", "response", "=", "$", "e", "->", "getResponse", "(", ")", ";", "$", "response", "->", "setContent", "(", "$", "data", ")", ";", "}", "$", "this", "->", "addDebugResponseHeader", "(", "$", "response", ",", "'Hit'", ")", ";", "return", "$", "response", ";", "}", "$", "this", "->", "addDebugResponseHeader", "(", "$", "response", ",", "'Miss'", ")", ";", "}" ]
Load the page contents from the cache and set the response. @param MvcEvent $e @return HttpResponse
[ "Load", "the", "page", "contents", "from", "the", "cache", "and", "set", "the", "response", "." ]
ae2cf413e445163a6725afbca597d6fb98c38f0d
https://github.com/bramstroker/zf2-fullpage-cache/blob/ae2cf413e445163a6725afbca597d6fb98c38f0d/src/Listener/CacheListener.php#L67-L94
224,520
bramstroker/zf2-fullpage-cache
src/Listener/CacheListener.php
CacheListener.onFinish
public function onFinish(MvcEvent $e) { if (!$e->getRequest() instanceof HttpRequest || $this->loadedFromCache) { return; } $this->getCacheService()->save($e); }
php
public function onFinish(MvcEvent $e) { if (!$e->getRequest() instanceof HttpRequest || $this->loadedFromCache) { return; } $this->getCacheService()->save($e); }
[ "public", "function", "onFinish", "(", "MvcEvent", "$", "e", ")", "{", "if", "(", "!", "$", "e", "->", "getRequest", "(", ")", "instanceof", "HttpRequest", "||", "$", "this", "->", "loadedFromCache", ")", "{", "return", ";", "}", "$", "this", "->", "getCacheService", "(", ")", "->", "save", "(", "$", "e", ")", ";", "}" ]
Save page contents to the cache @param MvcEvent $e @return void
[ "Save", "page", "contents", "to", "the", "cache" ]
ae2cf413e445163a6725afbca597d6fb98c38f0d
https://github.com/bramstroker/zf2-fullpage-cache/blob/ae2cf413e445163a6725afbca597d6fb98c38f0d/src/Listener/CacheListener.php#L113-L120
224,521
descubraomundo/omnipay-pagarme
src/Message/AuthorizeRequest.php
AuthorizeRequest.getBoletoExpirationDate
public function getBoletoExpirationDate($format = 'Y-m-d\TH:i:s') { $value = $this->getParameter('boleto_expiration_date'); return $value ? $value->format($format) : null; }
php
public function getBoletoExpirationDate($format = 'Y-m-d\TH:i:s') { $value = $this->getParameter('boleto_expiration_date'); return $value ? $value->format($format) : null; }
[ "public", "function", "getBoletoExpirationDate", "(", "$", "format", "=", "'Y-m-d\\TH:i:s'", ")", "{", "$", "value", "=", "$", "this", "->", "getParameter", "(", "'boleto_expiration_date'", ")", ";", "return", "$", "value", "?", "$", "value", "->", "format", "(", "$", "format", ")", ":", "null", ";", "}" ]
Get the boleto expiration date @return string boleto expiration date
[ "Get", "the", "boleto", "expiration", "date" ]
99e92dffd1640bdaf736560e26ec244326a3dd4a
https://github.com/descubraomundo/omnipay-pagarme/blob/99e92dffd1640bdaf736560e26ec244326a3dd4a/src/Message/AuthorizeRequest.php#L172-L177
224,522
descubraomundo/omnipay-pagarme
src/Message/AuthorizeRequest.php
AuthorizeRequest.setBoletoExpirationDate
public function setBoletoExpirationDate($value) { if ($value) { $value = new \DateTime($value, new \DateTimeZone('UTC')); $value = new \DateTime($value->format('Y-m-d\T03:00:00'), new \DateTimeZone('UTC')); } else { $value = null; } return $this->setParameter('boleto_expiration_date', $value); }
php
public function setBoletoExpirationDate($value) { if ($value) { $value = new \DateTime($value, new \DateTimeZone('UTC')); $value = new \DateTime($value->format('Y-m-d\T03:00:00'), new \DateTimeZone('UTC')); } else { $value = null; } return $this->setParameter('boleto_expiration_date', $value); }
[ "public", "function", "setBoletoExpirationDate", "(", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "$", "value", "=", "new", "\\", "DateTime", "(", "$", "value", ",", "new", "\\", "DateTimeZone", "(", "'UTC'", ")", ")", ";", "$", "value", "=", "new", "\\", "DateTime", "(", "$", "value", "->", "format", "(", "'Y-m-d\\T03:00:00'", ")", ",", "new", "\\", "DateTimeZone", "(", "'UTC'", ")", ")", ";", "}", "else", "{", "$", "value", "=", "null", ";", "}", "return", "$", "this", "->", "setParameter", "(", "'boleto_expiration_date'", ",", "$", "value", ")", ";", "}" ]
Set the boleto expiration date @param string $value defaults to atual date + 7 days @return AuthorizeRequest provides a fluent interface
[ "Set", "the", "boleto", "expiration", "date" ]
99e92dffd1640bdaf736560e26ec244326a3dd4a
https://github.com/descubraomundo/omnipay-pagarme/blob/99e92dffd1640bdaf736560e26ec244326a3dd4a/src/Message/AuthorizeRequest.php#L185-L195
224,523
smoqadam/php-telegram-bot
src/Smoqadam/Telegram.php
Telegram.process
public function process($payload) { $result = $this->convertToObject($payload, true); return $this->processPayload($result); }
php
public function process($payload) { $result = $this->convertToObject($payload, true); return $this->processPayload($result); }
[ "public", "function", "process", "(", "$", "payload", ")", "{", "$", "result", "=", "$", "this", "->", "convertToObject", "(", "$", "payload", ",", "true", ")", ";", "return", "$", "this", "->", "processPayload", "(", "$", "result", ")", ";", "}" ]
this method used for setWebhook sended payload
[ "this", "method", "used", "for", "setWebhook", "sended", "payload" ]
dacd8f8bc0f6709bdd10473dbe130d3788b60f08
https://github.com/smoqadam/php-telegram-bot/blob/dacd8f8bc0f6709bdd10473dbe130d3788b60f08/src/Smoqadam/Telegram.php#L157-L161
224,524
smoqadam/php-telegram-bot
src/Smoqadam/Telegram.php
Telegram.getArgs
private function getArgs(&$pattern, $payload) { $args = null; // if command has argument if (preg_match('/<<.*>>/', $pattern, $matches)) { $args_pattern = $matches[0]; //remove << and >> from patterns $tmp_args_pattern = str_replace(['<<', '>>'], ['(', ')'], $pattern); //if args set if (preg_match('/' . $tmp_args_pattern . '/i', $payload, $matches)) { //remove first element array_shift($matches); if (isset($matches[0])) { //set args $args = array_shift($matches); //remove args pattern from main pattern $pattern = str_replace($args_pattern, '', $pattern); } } } return $args; }
php
private function getArgs(&$pattern, $payload) { $args = null; // if command has argument if (preg_match('/<<.*>>/', $pattern, $matches)) { $args_pattern = $matches[0]; //remove << and >> from patterns $tmp_args_pattern = str_replace(['<<', '>>'], ['(', ')'], $pattern); //if args set if (preg_match('/' . $tmp_args_pattern . '/i', $payload, $matches)) { //remove first element array_shift($matches); if (isset($matches[0])) { //set args $args = array_shift($matches); //remove args pattern from main pattern $pattern = str_replace($args_pattern, '', $pattern); } } } return $args; }
[ "private", "function", "getArgs", "(", "&", "$", "pattern", ",", "$", "payload", ")", "{", "$", "args", "=", "null", ";", "// if command has argument", "if", "(", "preg_match", "(", "'/<<.*>>/'", ",", "$", "pattern", ",", "$", "matches", ")", ")", "{", "$", "args_pattern", "=", "$", "matches", "[", "0", "]", ";", "//remove << and >> from patterns", "$", "tmp_args_pattern", "=", "str_replace", "(", "[", "'<<'", ",", "'>>'", "]", ",", "[", "'('", ",", "')'", "]", ",", "$", "pattern", ")", ";", "//if args set", "if", "(", "preg_match", "(", "'/'", ".", "$", "tmp_args_pattern", ".", "'/i'", ",", "$", "payload", ",", "$", "matches", ")", ")", "{", "//remove first element", "array_shift", "(", "$", "matches", ")", ";", "if", "(", "isset", "(", "$", "matches", "[", "0", "]", ")", ")", "{", "//set args", "$", "args", "=", "array_shift", "(", "$", "matches", ")", ";", "//remove args pattern from main pattern", "$", "pattern", "=", "str_replace", "(", "$", "args_pattern", ",", "''", ",", "$", "pattern", ")", ";", "}", "}", "}", "return", "$", "args", ";", "}" ]
get arguments part in regex @param $pattern @param $payload @return mixed|null
[ "get", "arguments", "part", "in", "regex" ]
dacd8f8bc0f6709bdd10473dbe130d3788b60f08
https://github.com/smoqadam/php-telegram-bot/blob/dacd8f8bc0f6709bdd10473dbe130d3788b60f08/src/Smoqadam/Telegram.php#L214-L237
224,525
smoqadam/php-telegram-bot
src/Smoqadam/Telegram.php
Telegram.exec
private function exec($command, $params = []) { if (in_array($command, $this->available_commands)) { // convert json to array then get the last messages info $output = json_decode($this->curl_get_contents($this->api . '/' . $command, $params), true); return $this->convertToObject($output); } else { echo 'command not found'; } }
php
private function exec($command, $params = []) { if (in_array($command, $this->available_commands)) { // convert json to array then get the last messages info $output = json_decode($this->curl_get_contents($this->api . '/' . $command, $params), true); return $this->convertToObject($output); } else { echo 'command not found'; } }
[ "private", "function", "exec", "(", "$", "command", ",", "$", "params", "=", "[", "]", ")", "{", "if", "(", "in_array", "(", "$", "command", ",", "$", "this", "->", "available_commands", ")", ")", "{", "// convert json to array then get the last messages info", "$", "output", "=", "json_decode", "(", "$", "this", "->", "curl_get_contents", "(", "$", "this", "->", "api", ".", "'/'", ".", "$", "command", ",", "$", "params", ")", ",", "true", ")", ";", "return", "$", "this", "->", "convertToObject", "(", "$", "output", ")", ";", "}", "else", "{", "echo", "'command not found'", ";", "}", "}" ]
execute telegram api commands @param $command @param array $params
[ "execute", "telegram", "api", "commands" ]
dacd8f8bc0f6709bdd10473dbe130d3788b60f08
https://github.com/smoqadam/php-telegram-bot/blob/dacd8f8bc0f6709bdd10473dbe130d3788b60f08/src/Smoqadam/Telegram.php#L244-L253
224,526
smoqadam/php-telegram-bot
src/Smoqadam/Telegram.php
Telegram.getChatId
public function getChatId($chat_id = null) { try { if ($chat_id) return $chat_id; if( isset($this->result->message) ) { return $this->result->message->chat->id; } elseif ( isset($this->result->inline_query) ) { return $this->result->inline_query->from->id; } else { throw new \Exception("Error Processing Request", 1); } } catch (\Exception $e) { error_log($e->getMessage()); } }
php
public function getChatId($chat_id = null) { try { if ($chat_id) return $chat_id; if( isset($this->result->message) ) { return $this->result->message->chat->id; } elseif ( isset($this->result->inline_query) ) { return $this->result->inline_query->from->id; } else { throw new \Exception("Error Processing Request", 1); } } catch (\Exception $e) { error_log($e->getMessage()); } }
[ "public", "function", "getChatId", "(", "$", "chat_id", "=", "null", ")", "{", "try", "{", "if", "(", "$", "chat_id", ")", "return", "$", "chat_id", ";", "if", "(", "isset", "(", "$", "this", "->", "result", "->", "message", ")", ")", "{", "return", "$", "this", "->", "result", "->", "message", "->", "chat", "->", "id", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "result", "->", "inline_query", ")", ")", "{", "return", "$", "this", "->", "result", "->", "inline_query", "->", "from", "->", "id", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "\"Error Processing Request\"", ",", "1", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "error_log", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Get current chat id @param null $chat_id @return int
[ "Get", "current", "chat", "id" ]
dacd8f8bc0f6709bdd10473dbe130d3788b60f08
https://github.com/smoqadam/php-telegram-bot/blob/dacd8f8bc0f6709bdd10473dbe130d3788b60f08/src/Smoqadam/Telegram.php#L302-L317
224,527
RichWeber/yii2-google-translate-api
Translation.php
Translation.translate
public function translate($source, $target, $text) { return $this->getResponse($this->getRequest('', $text, $source, $target)); }
php
public function translate($source, $target, $text) { return $this->getResponse($this->getRequest('', $text, $source, $target)); }
[ "public", "function", "translate", "(", "$", "source", ",", "$", "target", ",", "$", "text", ")", "{", "return", "$", "this", "->", "getResponse", "(", "$", "this", "->", "getRequest", "(", "''", ",", "$", "text", ",", "$", "source", ",", "$", "target", ")", ")", ";", "}" ]
You can translate text from one language to another language @param string $source Source language @param string $target Target language @param string $text Source text string @return array
[ "You", "can", "translate", "text", "from", "one", "language", "to", "another", "language" ]
8c7e47bd8c3309f6dcb4869141e2c30a3a231537
https://github.com/RichWeber/yii2-google-translate-api/blob/8c7e47bd8c3309f6dcb4869141e2c30a3a231537/Translation.php#L41-L44
224,528
RichWeber/yii2-google-translate-api
Translation.php
Translation.getRequest
protected function getRequest($method, $text = '', $source = '', $target = '') { $request = self::API_URL . '/' . $method . '?' . http_build_query( [ 'key' => $this->key, 'source' => $source, 'target' => $target, 'q' => Html::encode($text), ] ); return $request; }
php
protected function getRequest($method, $text = '', $source = '', $target = '') { $request = self::API_URL . '/' . $method . '?' . http_build_query( [ 'key' => $this->key, 'source' => $source, 'target' => $target, 'q' => Html::encode($text), ] ); return $request; }
[ "protected", "function", "getRequest", "(", "$", "method", ",", "$", "text", "=", "''", ",", "$", "source", "=", "''", ",", "$", "target", "=", "''", ")", "{", "$", "request", "=", "self", "::", "API_URL", ".", "'/'", ".", "$", "method", ".", "'?'", ".", "http_build_query", "(", "[", "'key'", "=>", "$", "this", "->", "key", ",", "'source'", "=>", "$", "source", ",", "'target'", "=>", "$", "target", ",", "'q'", "=>", "Html", "::", "encode", "(", "$", "text", ")", ",", "]", ")", ";", "return", "$", "request", ";", "}" ]
Forming query parameters @param string $method API method @param string $text Source text string @param string $source Source language @param string $target Target language @return array Data properties
[ "Forming", "query", "parameters" ]
8c7e47bd8c3309f6dcb4869141e2c30a3a231537
https://github.com/RichWeber/yii2-google-translate-api/blob/8c7e47bd8c3309f6dcb4869141e2c30a3a231537/Translation.php#L73-L85
224,529
doctrine/oxm
lib/Doctrine/OXM/Proxy/ProxyFactory.php
ProxyFactory.getProxy
public function getProxy($className, $identifier) { $proxyClassName = str_replace('\\', '', $className) . 'Proxy'; $fqn = $this->proxyNamespace . '\\' . $proxyClassName; if (! class_exists($fqn, false)) { $fileName = $this->proxyDir . DIRECTORY_SEPARATOR . $proxyClassName . '.php'; if ($this->autoGenerate) { $this->generateProxyClass($this->xem->getClassMetadata($className), $proxyClassName, $fileName, self::$proxyClassTemplate); } require $fileName; } if ( ! $this->xem->getMetadataFactory()->hasMetadataFor($fqn)) { $this->xem->getMetadataFactory()->setMetadataFor($fqn, $this->xem->getClassMetadata($className)); } $documentPersister = $this->xem->getUnitOfWork()->getXmlEntityPersister($className); return new $fqn($documentPersister, $identifier); }
php
public function getProxy($className, $identifier) { $proxyClassName = str_replace('\\', '', $className) . 'Proxy'; $fqn = $this->proxyNamespace . '\\' . $proxyClassName; if (! class_exists($fqn, false)) { $fileName = $this->proxyDir . DIRECTORY_SEPARATOR . $proxyClassName . '.php'; if ($this->autoGenerate) { $this->generateProxyClass($this->xem->getClassMetadata($className), $proxyClassName, $fileName, self::$proxyClassTemplate); } require $fileName; } if ( ! $this->xem->getMetadataFactory()->hasMetadataFor($fqn)) { $this->xem->getMetadataFactory()->setMetadataFor($fqn, $this->xem->getClassMetadata($className)); } $documentPersister = $this->xem->getUnitOfWork()->getXmlEntityPersister($className); return new $fqn($documentPersister, $identifier); }
[ "public", "function", "getProxy", "(", "$", "className", ",", "$", "identifier", ")", "{", "$", "proxyClassName", "=", "str_replace", "(", "'\\\\'", ",", "''", ",", "$", "className", ")", ".", "'Proxy'", ";", "$", "fqn", "=", "$", "this", "->", "proxyNamespace", ".", "'\\\\'", ".", "$", "proxyClassName", ";", "if", "(", "!", "class_exists", "(", "$", "fqn", ",", "false", ")", ")", "{", "$", "fileName", "=", "$", "this", "->", "proxyDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "proxyClassName", ".", "'.php'", ";", "if", "(", "$", "this", "->", "autoGenerate", ")", "{", "$", "this", "->", "generateProxyClass", "(", "$", "this", "->", "xem", "->", "getClassMetadata", "(", "$", "className", ")", ",", "$", "proxyClassName", ",", "$", "fileName", ",", "self", "::", "$", "proxyClassTemplate", ")", ";", "}", "require", "$", "fileName", ";", "}", "if", "(", "!", "$", "this", "->", "xem", "->", "getMetadataFactory", "(", ")", "->", "hasMetadataFor", "(", "$", "fqn", ")", ")", "{", "$", "this", "->", "xem", "->", "getMetadataFactory", "(", ")", "->", "setMetadataFor", "(", "$", "fqn", ",", "$", "this", "->", "xem", "->", "getClassMetadata", "(", "$", "className", ")", ")", ";", "}", "$", "documentPersister", "=", "$", "this", "->", "xem", "->", "getUnitOfWork", "(", ")", "->", "getXmlEntityPersister", "(", "$", "className", ")", ";", "return", "new", "$", "fqn", "(", "$", "documentPersister", ",", "$", "identifier", ")", ";", "}" ]
Gets a reference proxy instance for the xml-entity of the given type and identified by the given identifier. @param string $className @param mixed $identifier @return object
[ "Gets", "a", "reference", "proxy", "instance", "for", "the", "xml", "-", "entity", "of", "the", "given", "type", "and", "identified", "by", "the", "given", "identifier", "." ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Proxy/ProxyFactory.php#L75-L95
224,530
descubraomundo/omnipay-pagarme
src/Message/AbstractRequest.php
AbstractRequest.getCustomerData
protected function getCustomerData() { $card = $this->getCard(); $data = array(); $data['customer']['name'] = $card->getName(); $data['customer']['email'] = $card->getEmail(); $data['customer']['sex'] = $card->getGender(); $data['customer']['born_at'] = $card->getBirthday('m-d-Y'); $data['customer']['document_number'] = $card->getHolderDocumentNumber(); $arrayAddress = $this->extractAddress($card->getAddress1()); if ( ! empty($arrayAddress['street']) ) { $data['customer']['address'] = $arrayAddress; $data['customer']['address']['zipcode'] = $card->getPostcode(); if ( $card->getAddress2() ) { $data['customer']['address']['neighborhood'] = $card->getAddress2(); } $data['customer']['address']['city'] = $card->getCity(); $data['customer']['address']['state'] = $card->getState(); $data['customer']['address']['country'] = $card->getCountry(); } $arrayPhone = $this->extractDddPhone($card->getPhone()); if ( ! empty($arrayPhone['ddd']) ) { $data['customer']['phone'] = $arrayPhone; } return $data; }
php
protected function getCustomerData() { $card = $this->getCard(); $data = array(); $data['customer']['name'] = $card->getName(); $data['customer']['email'] = $card->getEmail(); $data['customer']['sex'] = $card->getGender(); $data['customer']['born_at'] = $card->getBirthday('m-d-Y'); $data['customer']['document_number'] = $card->getHolderDocumentNumber(); $arrayAddress = $this->extractAddress($card->getAddress1()); if ( ! empty($arrayAddress['street']) ) { $data['customer']['address'] = $arrayAddress; $data['customer']['address']['zipcode'] = $card->getPostcode(); if ( $card->getAddress2() ) { $data['customer']['address']['neighborhood'] = $card->getAddress2(); } $data['customer']['address']['city'] = $card->getCity(); $data['customer']['address']['state'] = $card->getState(); $data['customer']['address']['country'] = $card->getCountry(); } $arrayPhone = $this->extractDddPhone($card->getPhone()); if ( ! empty($arrayPhone['ddd']) ) { $data['customer']['phone'] = $arrayPhone; } return $data; }
[ "protected", "function", "getCustomerData", "(", ")", "{", "$", "card", "=", "$", "this", "->", "getCard", "(", ")", ";", "$", "data", "=", "array", "(", ")", ";", "$", "data", "[", "'customer'", "]", "[", "'name'", "]", "=", "$", "card", "->", "getName", "(", ")", ";", "$", "data", "[", "'customer'", "]", "[", "'email'", "]", "=", "$", "card", "->", "getEmail", "(", ")", ";", "$", "data", "[", "'customer'", "]", "[", "'sex'", "]", "=", "$", "card", "->", "getGender", "(", ")", ";", "$", "data", "[", "'customer'", "]", "[", "'born_at'", "]", "=", "$", "card", "->", "getBirthday", "(", "'m-d-Y'", ")", ";", "$", "data", "[", "'customer'", "]", "[", "'document_number'", "]", "=", "$", "card", "->", "getHolderDocumentNumber", "(", ")", ";", "$", "arrayAddress", "=", "$", "this", "->", "extractAddress", "(", "$", "card", "->", "getAddress1", "(", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "arrayAddress", "[", "'street'", "]", ")", ")", "{", "$", "data", "[", "'customer'", "]", "[", "'address'", "]", "=", "$", "arrayAddress", ";", "$", "data", "[", "'customer'", "]", "[", "'address'", "]", "[", "'zipcode'", "]", "=", "$", "card", "->", "getPostcode", "(", ")", ";", "if", "(", "$", "card", "->", "getAddress2", "(", ")", ")", "{", "$", "data", "[", "'customer'", "]", "[", "'address'", "]", "[", "'neighborhood'", "]", "=", "$", "card", "->", "getAddress2", "(", ")", ";", "}", "$", "data", "[", "'customer'", "]", "[", "'address'", "]", "[", "'city'", "]", "=", "$", "card", "->", "getCity", "(", ")", ";", "$", "data", "[", "'customer'", "]", "[", "'address'", "]", "[", "'state'", "]", "=", "$", "card", "->", "getState", "(", ")", ";", "$", "data", "[", "'customer'", "]", "[", "'address'", "]", "[", "'country'", "]", "=", "$", "card", "->", "getCountry", "(", ")", ";", "}", "$", "arrayPhone", "=", "$", "this", "->", "extractDddPhone", "(", "$", "card", "->", "getPhone", "(", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "arrayPhone", "[", "'ddd'", "]", ")", ")", "{", "$", "data", "[", "'customer'", "]", "[", "'phone'", "]", "=", "$", "arrayPhone", ";", "}", "return", "$", "data", ";", "}" ]
Get the Customer data. Because the pagarme gateway uses a common format for passing customer data to the API, this function can be called to get the data from the card object in the format that the API requires. @return array customer data
[ "Get", "the", "Customer", "data", "." ]
99e92dffd1640bdaf736560e26ec244326a3dd4a
https://github.com/descubraomundo/omnipay-pagarme/blob/99e92dffd1640bdaf736560e26ec244326a3dd4a/src/Message/AbstractRequest.php#L261-L291
224,531
bramstroker/zf2-fullpage-cache
src/Controller/CacheController.php
CacheController.clearAction
public function clearAction() { $tags = $this->params('tags', null); if (null === $tags) { $this->console->writeLine('You should provide tags'); return; } $tags = explode(',', $tags); $result = false; try { $result = $this->getCacheService()->clearByTags($tags); } catch (UnsupportedAdapterException $exception) { $this->console->writeLine($exception->getMessage()); } $this->console->writeLine( sprintf( 'Cache invalidation %s', $result ? 'succeeded' : 'failed' ) ); }
php
public function clearAction() { $tags = $this->params('tags', null); if (null === $tags) { $this->console->writeLine('You should provide tags'); return; } $tags = explode(',', $tags); $result = false; try { $result = $this->getCacheService()->clearByTags($tags); } catch (UnsupportedAdapterException $exception) { $this->console->writeLine($exception->getMessage()); } $this->console->writeLine( sprintf( 'Cache invalidation %s', $result ? 'succeeded' : 'failed' ) ); }
[ "public", "function", "clearAction", "(", ")", "{", "$", "tags", "=", "$", "this", "->", "params", "(", "'tags'", ",", "null", ")", ";", "if", "(", "null", "===", "$", "tags", ")", "{", "$", "this", "->", "console", "->", "writeLine", "(", "'You should provide tags'", ")", ";", "return", ";", "}", "$", "tags", "=", "explode", "(", "','", ",", "$", "tags", ")", ";", "$", "result", "=", "false", ";", "try", "{", "$", "result", "=", "$", "this", "->", "getCacheService", "(", ")", "->", "clearByTags", "(", "$", "tags", ")", ";", "}", "catch", "(", "UnsupportedAdapterException", "$", "exception", ")", "{", "$", "this", "->", "console", "->", "writeLine", "(", "$", "exception", "->", "getMessage", "(", ")", ")", ";", "}", "$", "this", "->", "console", "->", "writeLine", "(", "sprintf", "(", "'Cache invalidation %s'", ",", "$", "result", "?", "'succeeded'", ":", "'failed'", ")", ")", ";", "}" ]
Clear items from the cache @return string
[ "Clear", "items", "from", "the", "cache" ]
ae2cf413e445163a6725afbca597d6fb98c38f0d
https://github.com/bramstroker/zf2-fullpage-cache/blob/ae2cf413e445163a6725afbca597d6fb98c38f0d/src/Controller/CacheController.php#L36-L58
224,532
doctrine/oxm
lib/Doctrine/OXM/Types/Type.php
Type.getType
public static function getType($name) { if ( ! isset(self::$_typeObjects[$name])) { if ( ! isset(self::$_typesMap[$name])) { throw OXMException::unknownType($name); } self::$_typeObjects[$name] = new self::$_typesMap[$name](); } return self::$_typeObjects[$name]; }
php
public static function getType($name) { if ( ! isset(self::$_typeObjects[$name])) { if ( ! isset(self::$_typesMap[$name])) { throw OXMException::unknownType($name); } self::$_typeObjects[$name] = new self::$_typesMap[$name](); } return self::$_typeObjects[$name]; }
[ "public", "static", "function", "getType", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "_typeObjects", "[", "$", "name", "]", ")", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "_typesMap", "[", "$", "name", "]", ")", ")", "{", "throw", "OXMException", "::", "unknownType", "(", "$", "name", ")", ";", "}", "self", "::", "$", "_typeObjects", "[", "$", "name", "]", "=", "new", "self", "::", "$", "_typesMap", "[", "$", "name", "]", "(", ")", ";", "}", "return", "self", "::", "$", "_typeObjects", "[", "$", "name", "]", ";", "}" ]
Factory method to create type instances. Type instances are implemented as flyweights. @static @throws OXMException @param string $name The name of the type (as returned by getName()). @return \Doctrine\OXM\Types\Type
[ "Factory", "method", "to", "create", "type", "instances", ".", "Type", "instances", "are", "implemented", "as", "flyweights", "." ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Types/Type.php#L112-L122
224,533
doctrine/oxm
lib/Doctrine/OXM/Tools/Console/ConsoleRunner.php
ConsoleRunner.run
static public function run(HelperSet $helperSet) { $cli = new Application('Doctrine OXM Command Line Interface', \Doctrine\OXM\Version::VERSION); $cli->setCatchExceptions(true); $cli->setHelperSet($helperSet); self::addCommands($cli); $cli->run(); }
php
static public function run(HelperSet $helperSet) { $cli = new Application('Doctrine OXM Command Line Interface', \Doctrine\OXM\Version::VERSION); $cli->setCatchExceptions(true); $cli->setHelperSet($helperSet); self::addCommands($cli); $cli->run(); }
[ "static", "public", "function", "run", "(", "HelperSet", "$", "helperSet", ")", "{", "$", "cli", "=", "new", "Application", "(", "'Doctrine OXM Command Line Interface'", ",", "\\", "Doctrine", "\\", "OXM", "\\", "Version", "::", "VERSION", ")", ";", "$", "cli", "->", "setCatchExceptions", "(", "true", ")", ";", "$", "cli", "->", "setHelperSet", "(", "$", "helperSet", ")", ";", "self", "::", "addCommands", "(", "$", "cli", ")", ";", "$", "cli", "->", "run", "(", ")", ";", "}" ]
Run console with the given helperset. @param \Symfony\Component\Console\Helper\HelperSet $helperSet @return void
[ "Run", "console", "with", "the", "given", "helperset", "." ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Tools/Console/ConsoleRunner.php#L42-L49
224,534
doctrine/oxm
lib/Doctrine/OXM/Mapping/ClassMetadata.php
ClassMetadata.getFieldValue
public function getFieldValue($entity, $fieldName) { if ($this->fieldMappings[$fieldName]['direct']) { return $this->reflFields[$fieldName]->getValue($entity); } else { if (!array_key_exists('getMethod', $this->fieldMappings[$fieldName])) { $this->fieldMappings[$fieldName]['getMethod'] = $this->inferGetter($fieldName); } $getter = $this->fieldMappings[$fieldName]['getMethod']; if ($this->reflClass->hasMethod($getter)) { return call_user_func(array($entity, $getter)); } else { throw MappingException::fieldGetMethodDoesNotExist($this->name, $fieldName, $getter); } } }
php
public function getFieldValue($entity, $fieldName) { if ($this->fieldMappings[$fieldName]['direct']) { return $this->reflFields[$fieldName]->getValue($entity); } else { if (!array_key_exists('getMethod', $this->fieldMappings[$fieldName])) { $this->fieldMappings[$fieldName]['getMethod'] = $this->inferGetter($fieldName); } $getter = $this->fieldMappings[$fieldName]['getMethod']; if ($this->reflClass->hasMethod($getter)) { return call_user_func(array($entity, $getter)); } else { throw MappingException::fieldGetMethodDoesNotExist($this->name, $fieldName, $getter); } } }
[ "public", "function", "getFieldValue", "(", "$", "entity", ",", "$", "fieldName", ")", "{", "if", "(", "$", "this", "->", "fieldMappings", "[", "$", "fieldName", "]", "[", "'direct'", "]", ")", "{", "return", "$", "this", "->", "reflFields", "[", "$", "fieldName", "]", "->", "getValue", "(", "$", "entity", ")", ";", "}", "else", "{", "if", "(", "!", "array_key_exists", "(", "'getMethod'", ",", "$", "this", "->", "fieldMappings", "[", "$", "fieldName", "]", ")", ")", "{", "$", "this", "->", "fieldMappings", "[", "$", "fieldName", "]", "[", "'getMethod'", "]", "=", "$", "this", "->", "inferGetter", "(", "$", "fieldName", ")", ";", "}", "$", "getter", "=", "$", "this", "->", "fieldMappings", "[", "$", "fieldName", "]", "[", "'getMethod'", "]", ";", "if", "(", "$", "this", "->", "reflClass", "->", "hasMethod", "(", "$", "getter", ")", ")", "{", "return", "call_user_func", "(", "array", "(", "$", "entity", ",", "$", "getter", ")", ")", ";", "}", "else", "{", "throw", "MappingException", "::", "fieldGetMethodDoesNotExist", "(", "$", "this", "->", "name", ",", "$", "fieldName", ",", "$", "getter", ")", ";", "}", "}", "}" ]
Gets the specified field's value off the given entity. @param object $entity @param string $fieldName
[ "Gets", "the", "specified", "field", "s", "value", "off", "the", "given", "entity", "." ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Mapping/ClassMetadata.php#L152-L168
224,535
doctrine/oxm
lib/Doctrine/OXM/Persisters/RootXmlEntityPersister.php
RootXmlEntityPersister.update
public function update($xmlEntity) { $identifier = $this->metadata->getIdentifierValue($xmlEntity); $xml = $this->marshaller->marshalToString($xmlEntity); return $this->storage->update($this->metadata, $identifier, $xml); }
php
public function update($xmlEntity) { $identifier = $this->metadata->getIdentifierValue($xmlEntity); $xml = $this->marshaller->marshalToString($xmlEntity); return $this->storage->update($this->metadata, $identifier, $xml); }
[ "public", "function", "update", "(", "$", "xmlEntity", ")", "{", "$", "identifier", "=", "$", "this", "->", "metadata", "->", "getIdentifierValue", "(", "$", "xmlEntity", ")", ";", "$", "xml", "=", "$", "this", "->", "marshaller", "->", "marshalToString", "(", "$", "xmlEntity", ")", ";", "return", "$", "this", "->", "storage", "->", "update", "(", "$", "this", "->", "metadata", ",", "$", "identifier", ",", "$", "xml", ")", ";", "}" ]
Updates this xml entity in the storage system @param $xmlEntity @return bool|int
[ "Updates", "this", "xml", "entity", "in", "the", "storage", "system" ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Persisters/RootXmlEntityPersister.php#L81-L88
224,536
doctrine/oxm
lib/Doctrine/OXM/Mapping/ClassMetadataFactory.php
ClassMetadataFactory.getParentClasses
protected function getParentClasses($name) { // Collect parent classes, ignoring transient (not-mapped) classes. $parentClasses = array(); foreach (array_reverse(class_parents($name)) as $parentClass) { if (!$this->driver->isTransient($parentClass)) { $parentClasses[] = $parentClass; } } return $parentClasses; }
php
protected function getParentClasses($name) { // Collect parent classes, ignoring transient (not-mapped) classes. $parentClasses = array(); foreach (array_reverse(class_parents($name)) as $parentClass) { if (!$this->driver->isTransient($parentClass)) { $parentClasses[] = $parentClass; } } return $parentClasses; }
[ "protected", "function", "getParentClasses", "(", "$", "name", ")", "{", "// Collect parent classes, ignoring transient (not-mapped) classes.", "$", "parentClasses", "=", "array", "(", ")", ";", "foreach", "(", "array_reverse", "(", "class_parents", "(", "$", "name", ")", ")", "as", "$", "parentClass", ")", "{", "if", "(", "!", "$", "this", "->", "driver", "->", "isTransient", "(", "$", "parentClass", ")", ")", "{", "$", "parentClasses", "[", "]", "=", "$", "parentClass", ";", "}", "}", "return", "$", "parentClasses", ";", "}" ]
Get array of parent classes for the given entity class @param string $name @return array $parentClasses
[ "Get", "array", "of", "parent", "classes", "for", "the", "given", "entity", "class" ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Mapping/ClassMetadataFactory.php#L256-L266
224,537
doctrine/oxm
lib/Doctrine/OXM/Mapping/ClassMetadataFactory.php
ClassMetadataFactory.completeMappingTypeValidation
private function completeMappingTypeValidation($className, ClassMetadataInfo $class) { foreach ($class->fieldMappings as $fieldName => $mapping) { if (Type::hasType($mapping['type'])) { continue; } // Support type as a mapped class? if (!$this->hasMetadataFor($mapping['type']) && !$this->getMetadataFor($mapping['type'])) { throw MappingException::fieldTypeNotFound($className, $fieldName, $mapping['type']); } // Mapped classes must have binding node type XML_ELEMENT if ($mapping['node'] !== ClassMetadataInfo::XML_ELEMENT) { throw MappingException::customTypeWithoutNodeElement($className, $fieldName); } } }
php
private function completeMappingTypeValidation($className, ClassMetadataInfo $class) { foreach ($class->fieldMappings as $fieldName => $mapping) { if (Type::hasType($mapping['type'])) { continue; } // Support type as a mapped class? if (!$this->hasMetadataFor($mapping['type']) && !$this->getMetadataFor($mapping['type'])) { throw MappingException::fieldTypeNotFound($className, $fieldName, $mapping['type']); } // Mapped classes must have binding node type XML_ELEMENT if ($mapping['node'] !== ClassMetadataInfo::XML_ELEMENT) { throw MappingException::customTypeWithoutNodeElement($className, $fieldName); } } }
[ "private", "function", "completeMappingTypeValidation", "(", "$", "className", ",", "ClassMetadataInfo", "$", "class", ")", "{", "foreach", "(", "$", "class", "->", "fieldMappings", "as", "$", "fieldName", "=>", "$", "mapping", ")", "{", "if", "(", "Type", "::", "hasType", "(", "$", "mapping", "[", "'type'", "]", ")", ")", "{", "continue", ";", "}", "// Support type as a mapped class?", "if", "(", "!", "$", "this", "->", "hasMetadataFor", "(", "$", "mapping", "[", "'type'", "]", ")", "&&", "!", "$", "this", "->", "getMetadataFor", "(", "$", "mapping", "[", "'type'", "]", ")", ")", "{", "throw", "MappingException", "::", "fieldTypeNotFound", "(", "$", "className", ",", "$", "fieldName", ",", "$", "mapping", "[", "'type'", "]", ")", ";", "}", "// Mapped classes must have binding node type XML_ELEMENT", "if", "(", "$", "mapping", "[", "'node'", "]", "!==", "ClassMetadataInfo", "::", "XML_ELEMENT", ")", "{", "throw", "MappingException", "::", "customTypeWithoutNodeElement", "(", "$", "className", ",", "$", "fieldName", ")", ";", "}", "}", "}" ]
Complete and validate type mappings @param string $className @param ClassMetadataInfo $class
[ "Complete", "and", "validate", "type", "mappings" ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Mapping/ClassMetadataFactory.php#L366-L383
224,538
doctrine/oxm
lib/Doctrine/OXM/Mapping/ClassMetadataFactory.php
ClassMetadataFactory.completeIdGeneratorMapping
private function completeIdGeneratorMapping(ClassMetadataInfo $class) { $idGenType = $class->generatorType; if ($idGenType == ClassMetadata::GENERATOR_TYPE_AUTO) { $class->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); } // Create & assign an appropriate ID generator instance switch ($class->generatorType) { case ClassMetadataInfo::GENERATOR_TYPE_INCREMENT: throw new OXMException("Increment generator type not implemented yet"); break; case ClassMetadataInfo::GENERATOR_TYPE_NONE: $class->setIdGenerator(new \Doctrine\OXM\Id\AssignedGenerator()); break; case ClassMetadataInfo::GENERATOR_TYPE_UUID: $class->setIdGenerator(new \Doctrine\OXM\Id\UuidGenerator()); break; default: throw new OXMException("Unknown generator type: " . $class->generatorType); } }
php
private function completeIdGeneratorMapping(ClassMetadataInfo $class) { $idGenType = $class->generatorType; if ($idGenType == ClassMetadata::GENERATOR_TYPE_AUTO) { $class->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); } // Create & assign an appropriate ID generator instance switch ($class->generatorType) { case ClassMetadataInfo::GENERATOR_TYPE_INCREMENT: throw new OXMException("Increment generator type not implemented yet"); break; case ClassMetadataInfo::GENERATOR_TYPE_NONE: $class->setIdGenerator(new \Doctrine\OXM\Id\AssignedGenerator()); break; case ClassMetadataInfo::GENERATOR_TYPE_UUID: $class->setIdGenerator(new \Doctrine\OXM\Id\UuidGenerator()); break; default: throw new OXMException("Unknown generator type: " . $class->generatorType); } }
[ "private", "function", "completeIdGeneratorMapping", "(", "ClassMetadataInfo", "$", "class", ")", "{", "$", "idGenType", "=", "$", "class", "->", "generatorType", ";", "if", "(", "$", "idGenType", "==", "ClassMetadata", "::", "GENERATOR_TYPE_AUTO", ")", "{", "$", "class", "->", "setIdGeneratorType", "(", "ClassMetadataInfo", "::", "GENERATOR_TYPE_NONE", ")", ";", "}", "// Create & assign an appropriate ID generator instance", "switch", "(", "$", "class", "->", "generatorType", ")", "{", "case", "ClassMetadataInfo", "::", "GENERATOR_TYPE_INCREMENT", ":", "throw", "new", "OXMException", "(", "\"Increment generator type not implemented yet\"", ")", ";", "break", ";", "case", "ClassMetadataInfo", "::", "GENERATOR_TYPE_NONE", ":", "$", "class", "->", "setIdGenerator", "(", "new", "\\", "Doctrine", "\\", "OXM", "\\", "Id", "\\", "AssignedGenerator", "(", ")", ")", ";", "break", ";", "case", "ClassMetadataInfo", "::", "GENERATOR_TYPE_UUID", ":", "$", "class", "->", "setIdGenerator", "(", "new", "\\", "Doctrine", "\\", "OXM", "\\", "Id", "\\", "UuidGenerator", "(", ")", ")", ";", "break", ";", "default", ":", "throw", "new", "OXMException", "(", "\"Unknown generator type: \"", ".", "$", "class", "->", "generatorType", ")", ";", "}", "}" ]
Completes the ID generator mapping. If "auto" is specified we choose the generator most appropriate. @param Doctrine\OXM\Mapping\ClassMetadataInfo $class
[ "Completes", "the", "ID", "generator", "mapping", ".", "If", "auto", "is", "specified", "we", "choose", "the", "generator", "most", "appropriate", "." ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Mapping/ClassMetadataFactory.php#L413-L434
224,539
doctrine/oxm
lib/Doctrine/OXM/Storage/FileSystemStorage.php
FileSystemStorage.insert
public function insert(ClassMetadataInfo $classMetadata, $id, $xmlContent) { $this->prepareStoragePathForClass($this->resolveClassName($classMetadata)); $filePath = $this->getFilename($classMetadata, $id); $result = file_put_contents($filePath, $xmlContent); if (false === $result) { // @codeCoverageIgnoreStart throw new StorageException("Entity '$id' could not be saved to the filesystem at '$filePath'"); // @codeCoverageIgnoreEnd } return $result > 0; }
php
public function insert(ClassMetadataInfo $classMetadata, $id, $xmlContent) { $this->prepareStoragePathForClass($this->resolveClassName($classMetadata)); $filePath = $this->getFilename($classMetadata, $id); $result = file_put_contents($filePath, $xmlContent); if (false === $result) { // @codeCoverageIgnoreStart throw new StorageException("Entity '$id' could not be saved to the filesystem at '$filePath'"); // @codeCoverageIgnoreEnd } return $result > 0; }
[ "public", "function", "insert", "(", "ClassMetadataInfo", "$", "classMetadata", ",", "$", "id", ",", "$", "xmlContent", ")", "{", "$", "this", "->", "prepareStoragePathForClass", "(", "$", "this", "->", "resolveClassName", "(", "$", "classMetadata", ")", ")", ";", "$", "filePath", "=", "$", "this", "->", "getFilename", "(", "$", "classMetadata", ",", "$", "id", ")", ";", "$", "result", "=", "file_put_contents", "(", "$", "filePath", ",", "$", "xmlContent", ")", ";", "if", "(", "false", "===", "$", "result", ")", "{", "// @codeCoverageIgnoreStart", "throw", "new", "StorageException", "(", "\"Entity '$id' could not be saved to the filesystem at '$filePath'\"", ")", ";", "// @codeCoverageIgnoreEnd", "}", "return", "$", "result", ">", "0", ";", "}" ]
Insert the XML into the filesystem with a specific identifier @throws StorageException @param \Doctrine\OXM\Mapping\ClassMetadataInfo $classMetadata @param string $id @param string $xmlContent @return boolean
[ "Insert", "the", "XML", "into", "the", "filesystem", "with", "a", "specific", "identifier" ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Storage/FileSystemStorage.php#L100-L114
224,540
doctrine/oxm
lib/Doctrine/OXM/Storage/FileSystemStorage.php
FileSystemStorage.prepareStoragePathForClass
private function prepareStoragePathForClass($className) { $filePath = $this->buildStoragePath($className); if (!file_exists($filePath)) { mkdir($filePath, $this->fileModeBits, true); } return $filePath; }
php
private function prepareStoragePathForClass($className) { $filePath = $this->buildStoragePath($className); if (!file_exists($filePath)) { mkdir($filePath, $this->fileModeBits, true); } return $filePath; }
[ "private", "function", "prepareStoragePathForClass", "(", "$", "className", ")", "{", "$", "filePath", "=", "$", "this", "->", "buildStoragePath", "(", "$", "className", ")", ";", "if", "(", "!", "file_exists", "(", "$", "filePath", ")", ")", "{", "mkdir", "(", "$", "filePath", ",", "$", "this", "->", "fileModeBits", ",", "true", ")", ";", "}", "return", "$", "filePath", ";", "}" ]
Build the realpath to save the xml in a specific folder @param string $className @return string
[ "Build", "the", "realpath", "to", "save", "the", "xml", "in", "a", "specific", "folder" ]
dec0f71d8219975165ba52cad6f0d538d8d2ffee
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Storage/FileSystemStorage.php#L177-L184
224,541
joomla-framework/github-api
src/Package/Activity/Starring.php
Starring.getRepositories
public function getRepositories($user = '', $sort = 'created', $direction = 'desc') { $allowedSort = array('created', 'updated'); $allowedDir = array('asc', 'desc'); if (!\in_array($sort, $allowedSort)) { throw new \InvalidArgumentException( sprintf( 'The sorting value is invalid. Allowed values are: %s', implode(', ', $allowedSort) ) ); } if (!\in_array($direction, $allowedDir)) { throw new \InvalidArgumentException( sprintf( 'The direction value is invalid. Allowed values are: %s', implode(', ', $allowedDir) ) ); } // Build the request path. $path = ($user) ? '/users' . $user . '/starred' : '/user/starred'; $uri = new Uri($this->fetchUrl($path)); $uri->setVar('sort', $sort); $uri->setVar('direction', $direction); // Send the request. return $this->processResponse($this->client->get($uri)); }
php
public function getRepositories($user = '', $sort = 'created', $direction = 'desc') { $allowedSort = array('created', 'updated'); $allowedDir = array('asc', 'desc'); if (!\in_array($sort, $allowedSort)) { throw new \InvalidArgumentException( sprintf( 'The sorting value is invalid. Allowed values are: %s', implode(', ', $allowedSort) ) ); } if (!\in_array($direction, $allowedDir)) { throw new \InvalidArgumentException( sprintf( 'The direction value is invalid. Allowed values are: %s', implode(', ', $allowedDir) ) ); } // Build the request path. $path = ($user) ? '/users' . $user . '/starred' : '/user/starred'; $uri = new Uri($this->fetchUrl($path)); $uri->setVar('sort', $sort); $uri->setVar('direction', $direction); // Send the request. return $this->processResponse($this->client->get($uri)); }
[ "public", "function", "getRepositories", "(", "$", "user", "=", "''", ",", "$", "sort", "=", "'created'", ",", "$", "direction", "=", "'desc'", ")", "{", "$", "allowedSort", "=", "array", "(", "'created'", ",", "'updated'", ")", ";", "$", "allowedDir", "=", "array", "(", "'asc'", ",", "'desc'", ")", ";", "if", "(", "!", "\\", "in_array", "(", "$", "sort", ",", "$", "allowedSort", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The sorting value is invalid. Allowed values are: %s'", ",", "implode", "(", "', '", ",", "$", "allowedSort", ")", ")", ")", ";", "}", "if", "(", "!", "\\", "in_array", "(", "$", "direction", ",", "$", "allowedDir", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The direction value is invalid. Allowed values are: %s'", ",", "implode", "(", "', '", ",", "$", "allowedDir", ")", ")", ")", ";", "}", "// Build the request path.", "$", "path", "=", "(", "$", "user", ")", "?", "'/users'", ".", "$", "user", ".", "'/starred'", ":", "'/user/starred'", ";", "$", "uri", "=", "new", "Uri", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ")", ";", "$", "uri", "->", "setVar", "(", "'sort'", ",", "$", "sort", ")", ";", "$", "uri", "->", "setVar", "(", "'direction'", ",", "$", "direction", ")", ";", "// Send the request.", "return", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "get", "(", "$", "uri", ")", ")", ";", "}" ]
List repositories being starred. List repositories being starred by a user. @param string $user User name. @param string $sort One of `created` (when the repository was starred) or `updated` (when it was last pushed to). @param string $direction One of `asc` (ascending) or `desc` (descending). @return object @since 1.0 @throws \InvalidArgumentException
[ "List", "repositories", "being", "starred", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Activity/Starring.php#L57-L93
224,542
burnbright/silverstripe-importexport
code/CSVFieldMapper.php
CSVFieldMapper.getMapHeadings
public function getMapHeadings() { if (!$this->headings && !$this->mappablecols) { return; } $out = new Arraylist(); foreach ($this->headings as $heading) { $dropdown = $this->createHeadingDropdown($heading); if (is_array($this->mappingvalues) && isset($this->mappingvalues[$heading]) ) { $dropdown->setValue($this->mappingvalues[$heading]); } $out->push(new ArrayData(array( "Heading" => $heading, "Dropdown" => $dropdown ))); } return $out; }
php
public function getMapHeadings() { if (!$this->headings && !$this->mappablecols) { return; } $out = new Arraylist(); foreach ($this->headings as $heading) { $dropdown = $this->createHeadingDropdown($heading); if (is_array($this->mappingvalues) && isset($this->mappingvalues[$heading]) ) { $dropdown->setValue($this->mappingvalues[$heading]); } $out->push(new ArrayData(array( "Heading" => $heading, "Dropdown" => $dropdown ))); } return $out; }
[ "public", "function", "getMapHeadings", "(", ")", "{", "if", "(", "!", "$", "this", "->", "headings", "&&", "!", "$", "this", "->", "mappablecols", ")", "{", "return", ";", "}", "$", "out", "=", "new", "Arraylist", "(", ")", ";", "foreach", "(", "$", "this", "->", "headings", "as", "$", "heading", ")", "{", "$", "dropdown", "=", "$", "this", "->", "createHeadingDropdown", "(", "$", "heading", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "mappingvalues", ")", "&&", "isset", "(", "$", "this", "->", "mappingvalues", "[", "$", "heading", "]", ")", ")", "{", "$", "dropdown", "->", "setValue", "(", "$", "this", "->", "mappingvalues", "[", "$", "heading", "]", ")", ";", "}", "$", "out", "->", "push", "(", "new", "ArrayData", "(", "array", "(", "\"Heading\"", "=>", "$", "heading", ",", "\"Dropdown\"", "=>", "$", "dropdown", ")", ")", ")", ";", "}", "return", "$", "out", ";", "}" ]
Provide heading dropdowns for creating mappings @return ArrayList
[ "Provide", "heading", "dropdowns", "for", "creating", "mappings" ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/CSVFieldMapper.php#L34-L54
224,543
JeroenBoersma/php-normalize
src/Manager.php
Manager.get
public function get(string $identifier = '') : Normalize { if (!$this->exists($identifier)) { throw new NotFound("No instance found with the name '{$identifier}'"); } return $this->instances[$identifier]; }
php
public function get(string $identifier = '') : Normalize { if (!$this->exists($identifier)) { throw new NotFound("No instance found with the name '{$identifier}'"); } return $this->instances[$identifier]; }
[ "public", "function", "get", "(", "string", "$", "identifier", "=", "''", ")", ":", "Normalize", "{", "if", "(", "!", "$", "this", "->", "exists", "(", "$", "identifier", ")", ")", "{", "throw", "new", "NotFound", "(", "\"No instance found with the name '{$identifier}'\"", ")", ";", "}", "return", "$", "this", "->", "instances", "[", "$", "identifier", "]", ";", "}" ]
Get existing normalize instance @param string $identifier @return Normalize @throws NotFound
[ "Get", "existing", "normalize", "instance" ]
254fdcc50bfd8cbf3eba8dae93439c07e28e0396
https://github.com/JeroenBoersma/php-normalize/blob/254fdcc50bfd8cbf3eba8dae93439c07e28e0396/src/Manager.php#L54-L61
224,544
JeroenBoersma/php-normalize
src/Manager.php
Manager.createAndAdd
public function createAndAdd(array $rules = [], string $identifier = '', string $chain = null) : Manager { return $this->add($this->create($rules), $identifier, $chain); }
php
public function createAndAdd(array $rules = [], string $identifier = '', string $chain = null) : Manager { return $this->add($this->create($rules), $identifier, $chain); }
[ "public", "function", "createAndAdd", "(", "array", "$", "rules", "=", "[", "]", ",", "string", "$", "identifier", "=", "''", ",", "string", "$", "chain", "=", "null", ")", ":", "Manager", "{", "return", "$", "this", "->", "add", "(", "$", "this", "->", "create", "(", "$", "rules", ")", ",", "$", "identifier", ",", "$", "chain", ")", ";", "}" ]
Create and add Normalize object @param array $rules @param string $identifier @param string $chain @return Manager
[ "Create", "and", "add", "Normalize", "object" ]
254fdcc50bfd8cbf3eba8dae93439c07e28e0396
https://github.com/JeroenBoersma/php-normalize/blob/254fdcc50bfd8cbf3eba8dae93439c07e28e0396/src/Manager.php#L104-L107
224,545
neos/setup
Classes/ViewHelpers/Widget/Controller/DatabaseSelectorController.php
DatabaseSelectorController.databaseSupportsUtf8Mb4
protected function databaseSupportsUtf8Mb4(string $databaseVersion): bool { if (strpos($databaseVersion, '-MariaDB') !== false && version_compare($databaseVersion, self::MINIMUM_MARIA_DB_VERSION) === -1 ) { return false; } if (preg_match('([a-zA-Z])', $databaseVersion) === 0 && version_compare($databaseVersion, self::MINIMUM_MYSQL_VERSION) === -1 ) { return false; } return true; }
php
protected function databaseSupportsUtf8Mb4(string $databaseVersion): bool { if (strpos($databaseVersion, '-MariaDB') !== false && version_compare($databaseVersion, self::MINIMUM_MARIA_DB_VERSION) === -1 ) { return false; } if (preg_match('([a-zA-Z])', $databaseVersion) === 0 && version_compare($databaseVersion, self::MINIMUM_MYSQL_VERSION) === -1 ) { return false; } return true; }
[ "protected", "function", "databaseSupportsUtf8Mb4", "(", "string", "$", "databaseVersion", ")", ":", "bool", "{", "if", "(", "strpos", "(", "$", "databaseVersion", ",", "'-MariaDB'", ")", "!==", "false", "&&", "version_compare", "(", "$", "databaseVersion", ",", "self", "::", "MINIMUM_MARIA_DB_VERSION", ")", "===", "-", "1", ")", "{", "return", "false", ";", "}", "if", "(", "preg_match", "(", "'([a-zA-Z])'", ",", "$", "databaseVersion", ")", "===", "0", "&&", "version_compare", "(", "$", "databaseVersion", ",", "self", "::", "MINIMUM_MYSQL_VERSION", ")", "===", "-", "1", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if MySQL based database supports utf8mb4 character set. @param string $databaseVersion @return bool
[ "Check", "if", "MySQL", "based", "database", "supports", "utf8mb4", "character", "set", "." ]
7b5437efe8113e997007be6896628aa9f5c39d2f
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/ViewHelpers/Widget/Controller/DatabaseSelectorController.php#L189-L204
224,546
joomla-framework/github-api
src/Package/Orgs/Teams.php
Teams.create
public function create($org, $name, array $repoNames = array(), $permission = '') { // Build the request path. $path = '/orgs/' . $org . '/teams'; $data = array( 'name' => $name, ); if ($repoNames) { $data['repo_names'] = $repoNames; } if ($permission) { if (\in_array($permission, array('pull', 'push', 'admin')) == false) { throw new \UnexpectedValueException('Permissions must be either "pull", "push", or "admin".'); } $data['permission'] = $permission; } return $this->processResponse( $this->client->post($this->fetchUrl($path), $data), 201 ); }
php
public function create($org, $name, array $repoNames = array(), $permission = '') { // Build the request path. $path = '/orgs/' . $org . '/teams'; $data = array( 'name' => $name, ); if ($repoNames) { $data['repo_names'] = $repoNames; } if ($permission) { if (\in_array($permission, array('pull', 'push', 'admin')) == false) { throw new \UnexpectedValueException('Permissions must be either "pull", "push", or "admin".'); } $data['permission'] = $permission; } return $this->processResponse( $this->client->post($this->fetchUrl($path), $data), 201 ); }
[ "public", "function", "create", "(", "$", "org", ",", "$", "name", ",", "array", "$", "repoNames", "=", "array", "(", ")", ",", "$", "permission", "=", "''", ")", "{", "// Build the request path.", "$", "path", "=", "'/orgs/'", ".", "$", "org", ".", "'/teams'", ";", "$", "data", "=", "array", "(", "'name'", "=>", "$", "name", ",", ")", ";", "if", "(", "$", "repoNames", ")", "{", "$", "data", "[", "'repo_names'", "]", "=", "$", "repoNames", ";", "}", "if", "(", "$", "permission", ")", "{", "if", "(", "\\", "in_array", "(", "$", "permission", ",", "array", "(", "'pull'", ",", "'push'", ",", "'admin'", ")", ")", "==", "false", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Permissions must be either \"pull\", \"push\", or \"admin\".'", ")", ";", "}", "$", "data", "[", "'permission'", "]", "=", "$", "permission", ";", "}", "return", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "post", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ",", "$", "data", ")", ",", "201", ")", ";", "}" ]
Create team. In order to create a team, the authenticated user must be an owner of the organization. @param string $org The name of the organization. @param string $name The name of the team. @param array $repoNames Repository names. @param string $permission The permission. (Deprecated) pull - team members can pull, but not push to or administer these repositories. Default push - team members can pull and push, but not administer these repositories. admin - team members can pull, push and administer these repositories. @return object @since 1.0 @throws \UnexpectedValueException
[ "Create", "team", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Orgs/Teams.php#L81-L109
224,547
joomla-framework/github-api
src/Package/Orgs/Teams.php
Teams.edit
public function edit($id, $name, $permission = '') { // Build the request path. $path = '/teams/' . (int) $id; $data = array( 'name' => $name, ); if ($permission) { if (\in_array($permission, array('pull', 'push', 'admin')) == false) { throw new \UnexpectedValueException('Permissions must be either "pull", "push", or "admin".'); } $data['permission'] = $permission; } return $this->processResponse( $this->client->patch($this->fetchUrl($path), $data) ); }
php
public function edit($id, $name, $permission = '') { // Build the request path. $path = '/teams/' . (int) $id; $data = array( 'name' => $name, ); if ($permission) { if (\in_array($permission, array('pull', 'push', 'admin')) == false) { throw new \UnexpectedValueException('Permissions must be either "pull", "push", or "admin".'); } $data['permission'] = $permission; } return $this->processResponse( $this->client->patch($this->fetchUrl($path), $data) ); }
[ "public", "function", "edit", "(", "$", "id", ",", "$", "name", ",", "$", "permission", "=", "''", ")", "{", "// Build the request path.", "$", "path", "=", "'/teams/'", ".", "(", "int", ")", "$", "id", ";", "$", "data", "=", "array", "(", "'name'", "=>", "$", "name", ",", ")", ";", "if", "(", "$", "permission", ")", "{", "if", "(", "\\", "in_array", "(", "$", "permission", ",", "array", "(", "'pull'", ",", "'push'", ",", "'admin'", ")", ")", "==", "false", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Permissions must be either \"pull\", \"push\", or \"admin\".'", ")", ";", "}", "$", "data", "[", "'permission'", "]", "=", "$", "permission", ";", "}", "return", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "patch", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ",", "$", "data", ")", ")", ";", "}" ]
Edit team. In order to edit a team, the authenticated user must be an owner of the org that the team is associated with. @param integer $id The team id. @param string $name The name of the team. @param string $permission The permission. (Deprecated) pull - team members can pull, but not push to or administer these repositories. Default push - team members can pull and push, but not administer these repositories. admin - team members can pull, push and administer these repositories. @return object @since 1.0 @throws \UnexpectedValueException
[ "Edit", "team", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Orgs/Teams.php#L128-L150
224,548
flipboxfactory/craft-rest
src/JsonParser.php
JsonParser.filterNullValuesFromArray
public function filterNullValuesFromArray(array $arr): array { foreach ($arr as $key => $value) { if ($value === null) { unset($arr[$key]); } if (is_array($value)) { $arr[$key] = $this->filterNullValuesFromArray($value); } } return $arr; }
php
public function filterNullValuesFromArray(array $arr): array { foreach ($arr as $key => $value) { if ($value === null) { unset($arr[$key]); } if (is_array($value)) { $arr[$key] = $this->filterNullValuesFromArray($value); } } return $arr; }
[ "public", "function", "filterNullValuesFromArray", "(", "array", "$", "arr", ")", ":", "array", "{", "foreach", "(", "$", "arr", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "unset", "(", "$", "arr", "[", "$", "key", "]", ")", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "arr", "[", "$", "key", "]", "=", "$", "this", "->", "filterNullValuesFromArray", "(", "$", "value", ")", ";", "}", "}", "return", "$", "arr", ";", "}" ]
Filters null values from an array. @param array $arr @return array
[ "Filters", "null", "values", "from", "an", "array", "." ]
bb9d0e2e0fbde85edab1cc1ac9d1a033888c4f63
https://github.com/flipboxfactory/craft-rest/blob/bb9d0e2e0fbde85edab1cc1ac9d1a033888c4f63/src/JsonParser.php#L32-L44
224,549
phootwork/collection
src/CollectionUtils.php
CollectionUtils.toArrayRecursive
public static function toArrayRecursive($collection) { $arr = $collection; if (is_object($collection) && method_exists($collection, 'toArray')) { $arr = $collection->toArray(); } return array_map(function ($v) { if (is_object($v) && method_exists($v, 'toArray')) { return static::toArrayRecursive($v); } return $v; }, $arr); }
php
public static function toArrayRecursive($collection) { $arr = $collection; if (is_object($collection) && method_exists($collection, 'toArray')) { $arr = $collection->toArray(); } return array_map(function ($v) { if (is_object($v) && method_exists($v, 'toArray')) { return static::toArrayRecursive($v); } return $v; }, $arr); }
[ "public", "static", "function", "toArrayRecursive", "(", "$", "collection", ")", "{", "$", "arr", "=", "$", "collection", ";", "if", "(", "is_object", "(", "$", "collection", ")", "&&", "method_exists", "(", "$", "collection", ",", "'toArray'", ")", ")", "{", "$", "arr", "=", "$", "collection", "->", "toArray", "(", ")", ";", "}", "return", "array_map", "(", "function", "(", "$", "v", ")", "{", "if", "(", "is_object", "(", "$", "v", ")", "&&", "method_exists", "(", "$", "v", ",", "'toArray'", ")", ")", "{", "return", "static", "::", "toArrayRecursive", "(", "$", "v", ")", ";", "}", "return", "$", "v", ";", "}", ",", "$", "arr", ")", ";", "}" ]
Recursively exports a collection to an array @param mixed $collection @return array
[ "Recursively", "exports", "a", "collection", "to", "an", "array" ]
e745fe3735a6f2099015d11ea7b917634ebf76f3
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/CollectionUtils.php#L88-L100
224,550
netz98/n98-deployer
src/Deployer/Task/DeployTasks.php
DeployTasks.initStableRelease
protected static function initStableRelease() { $releasePathStable = ''; $path = \Deployer\get('deploy_path'); $hasStableRelease = \Deployer\test("[ -d $path/current/ ]"); if ($hasStableRelease) { // make shure we do not have an array at this point TODO: Check why this workaround is necessary $readlinkBin = \Deployer\get('readlink_bin'); if (is_array($readlinkBin)) { $readlinkBin = current($readlinkBin); } if (PHP_OS === 'Darwin') { $releasePathStable = (string)\Deployer\run("$readlinkBin -n $path/current"); } else { $releasePathStable = (string)\Deployer\run("$readlinkBin -f $path/current/"); } \Deployer\set('release_path_stable', $releasePathStable); } if (\Deployer\isVerbose()) { \Deployer\writeln("release_path_stable = '{$releasePathStable}'"); } }
php
protected static function initStableRelease() { $releasePathStable = ''; $path = \Deployer\get('deploy_path'); $hasStableRelease = \Deployer\test("[ -d $path/current/ ]"); if ($hasStableRelease) { // make shure we do not have an array at this point TODO: Check why this workaround is necessary $readlinkBin = \Deployer\get('readlink_bin'); if (is_array($readlinkBin)) { $readlinkBin = current($readlinkBin); } if (PHP_OS === 'Darwin') { $releasePathStable = (string)\Deployer\run("$readlinkBin -n $path/current"); } else { $releasePathStable = (string)\Deployer\run("$readlinkBin -f $path/current/"); } \Deployer\set('release_path_stable', $releasePathStable); } if (\Deployer\isVerbose()) { \Deployer\writeln("release_path_stable = '{$releasePathStable}'"); } }
[ "protected", "static", "function", "initStableRelease", "(", ")", "{", "$", "releasePathStable", "=", "''", ";", "$", "path", "=", "\\", "Deployer", "\\", "get", "(", "'deploy_path'", ")", ";", "$", "hasStableRelease", "=", "\\", "Deployer", "\\", "test", "(", "\"[ -d $path/current/ ]\"", ")", ";", "if", "(", "$", "hasStableRelease", ")", "{", "// make shure we do not have an array at this point TODO: Check why this workaround is necessary", "$", "readlinkBin", "=", "\\", "Deployer", "\\", "get", "(", "'readlink_bin'", ")", ";", "if", "(", "is_array", "(", "$", "readlinkBin", ")", ")", "{", "$", "readlinkBin", "=", "current", "(", "$", "readlinkBin", ")", ";", "}", "if", "(", "PHP_OS", "===", "'Darwin'", ")", "{", "$", "releasePathStable", "=", "(", "string", ")", "\\", "Deployer", "\\", "run", "(", "\"$readlinkBin -n $path/current\"", ")", ";", "}", "else", "{", "$", "releasePathStable", "=", "(", "string", ")", "\\", "Deployer", "\\", "run", "(", "\"$readlinkBin -f $path/current/\"", ")", ";", "}", "\\", "Deployer", "\\", "set", "(", "'release_path_stable'", ",", "$", "releasePathStable", ")", ";", "}", "if", "(", "\\", "Deployer", "\\", "isVerbose", "(", ")", ")", "{", "\\", "Deployer", "\\", "writeln", "(", "\"release_path_stable = '{$releasePathStable}'\"", ")", ";", "}", "}" ]
Detect the path to current release before actual deployment starts This is done so we have it later on during rollback and maybe other actions
[ "Detect", "the", "path", "to", "current", "release", "before", "actual", "deployment", "starts" ]
cf7b7c790f45c41ed338b8a33b498eeaaaa765e9
https://github.com/netz98/n98-deployer/blob/cf7b7c790f45c41ed338b8a33b498eeaaaa765e9/src/Deployer/Task/DeployTasks.php#L121-L144
224,551
netz98/n98-deployer
src/Deployer/Task/DeployTasks.php
DeployTasks.initReleaseName
protected static function initReleaseName() { // Ensure the release-name is unique otherwise there are weird consequences in deployer // them being dep/releases with wrong versions, deployments to same release, … $release = \Deployer\get('release_name'); $isVersion = version_compare($release, '0.0.1', '>='); if ($isVersion === true) { $releaseName = self::getUniqueReleaseName($release); } else { $releaseClean = self::cleanString($release); $doUseTimestamp = (bool)\Deployer\get('release_name_usetimestamp'); if($doUseTimestamp) { $releaseName = $releaseClean . '-' . date('YmdHis'); } else { $releaseName = self::getUniqueReleaseName($releaseClean . '-branch'); } } \Deployer\set('release_name', $releaseName); \Deployer\writeln("Deploying $releaseName to releases/$releaseName"); }
php
protected static function initReleaseName() { // Ensure the release-name is unique otherwise there are weird consequences in deployer // them being dep/releases with wrong versions, deployments to same release, … $release = \Deployer\get('release_name'); $isVersion = version_compare($release, '0.0.1', '>='); if ($isVersion === true) { $releaseName = self::getUniqueReleaseName($release); } else { $releaseClean = self::cleanString($release); $doUseTimestamp = (bool)\Deployer\get('release_name_usetimestamp'); if($doUseTimestamp) { $releaseName = $releaseClean . '-' . date('YmdHis'); } else { $releaseName = self::getUniqueReleaseName($releaseClean . '-branch'); } } \Deployer\set('release_name', $releaseName); \Deployer\writeln("Deploying $releaseName to releases/$releaseName"); }
[ "protected", "static", "function", "initReleaseName", "(", ")", "{", "// Ensure the release-name is unique otherwise there are weird consequences in deployer", "// them being dep/releases with wrong versions, deployments to same release, …", "$", "release", "=", "\\", "Deployer", "\\", "get", "(", "'release_name'", ")", ";", "$", "isVersion", "=", "version_compare", "(", "$", "release", ",", "'0.0.1'", ",", "'>='", ")", ";", "if", "(", "$", "isVersion", "===", "true", ")", "{", "$", "releaseName", "=", "self", "::", "getUniqueReleaseName", "(", "$", "release", ")", ";", "}", "else", "{", "$", "releaseClean", "=", "self", "::", "cleanString", "(", "$", "release", ")", ";", "$", "doUseTimestamp", "=", "(", "bool", ")", "\\", "Deployer", "\\", "get", "(", "'release_name_usetimestamp'", ")", ";", "if", "(", "$", "doUseTimestamp", ")", "{", "$", "releaseName", "=", "$", "releaseClean", ".", "'-'", ".", "date", "(", "'YmdHis'", ")", ";", "}", "else", "{", "$", "releaseName", "=", "self", "::", "getUniqueReleaseName", "(", "$", "releaseClean", ".", "'-branch'", ")", ";", "}", "}", "\\", "Deployer", "\\", "set", "(", "'release_name'", ",", "$", "releaseName", ")", ";", "\\", "Deployer", "\\", "writeln", "(", "\"Deploying $releaseName to releases/$releaseName\"", ")", ";", "}" ]
Initialize a unique release-name checking if the release-name already exists and then postfixing it this is part of the overwrite of Deployer's own release_name logic
[ "Initialize", "a", "unique", "release", "-", "name", "checking", "if", "the", "release", "-", "name", "already", "exists", "and", "then", "postfixing", "it" ]
cf7b7c790f45c41ed338b8a33b498eeaaaa765e9
https://github.com/netz98/n98-deployer/blob/cf7b7c790f45c41ed338b8a33b498eeaaaa765e9/src/Deployer/Task/DeployTasks.php#L151-L173
224,552
netz98/n98-deployer
src/Deployer/Task/DeployTasks.php
DeployTasks.getUniqueReleaseName
protected static function getUniqueReleaseName($release) { // Prevent duplicate release names $i = 0; $releaseName = $release; $cmdTemplate = '[ -d {{deploy_path}}/releases/%s ]'; $cmd = sprintf($cmdTemplate, $releaseName); while (\Deployer\test($cmd)) { $releaseName = $release . '-' . ++$i; $cmd = sprintf($cmdTemplate, $releaseName); } return $releaseName; }
php
protected static function getUniqueReleaseName($release) { // Prevent duplicate release names $i = 0; $releaseName = $release; $cmdTemplate = '[ -d {{deploy_path}}/releases/%s ]'; $cmd = sprintf($cmdTemplate, $releaseName); while (\Deployer\test($cmd)) { $releaseName = $release . '-' . ++$i; $cmd = sprintf($cmdTemplate, $releaseName); } return $releaseName; }
[ "protected", "static", "function", "getUniqueReleaseName", "(", "$", "release", ")", "{", "// Prevent duplicate release names", "$", "i", "=", "0", ";", "$", "releaseName", "=", "$", "release", ";", "$", "cmdTemplate", "=", "'[ -d {{deploy_path}}/releases/%s ]'", ";", "$", "cmd", "=", "sprintf", "(", "$", "cmdTemplate", ",", "$", "releaseName", ")", ";", "while", "(", "\\", "Deployer", "\\", "test", "(", "$", "cmd", ")", ")", "{", "$", "releaseName", "=", "$", "release", ".", "'-'", ".", "++", "$", "i", ";", "$", "cmd", "=", "sprintf", "(", "$", "cmdTemplate", ",", "$", "releaseName", ")", ";", "}", "return", "$", "releaseName", ";", "}" ]
Determines a unique release-name @param string $release @return string
[ "Determines", "a", "unique", "release", "-", "name" ]
cf7b7c790f45c41ed338b8a33b498eeaaaa765e9
https://github.com/netz98/n98-deployer/blob/cf7b7c790f45c41ed338b8a33b498eeaaaa765e9/src/Deployer/Task/DeployTasks.php#L182-L195
224,553
sijad/flarum-ext-pages
src/Page.php
Page.getContentHtmlAttribute
public function getContentHtmlAttribute() { if ($this->is_html) { return $this->content; } return static::$formatter->render($this->attributes['content'], $this); }
php
public function getContentHtmlAttribute() { if ($this->is_html) { return $this->content; } return static::$formatter->render($this->attributes['content'], $this); }
[ "public", "function", "getContentHtmlAttribute", "(", ")", "{", "if", "(", "$", "this", "->", "is_html", ")", "{", "return", "$", "this", "->", "content", ";", "}", "return", "static", "::", "$", "formatter", "->", "render", "(", "$", "this", "->", "attributes", "[", "'content'", "]", ",", "$", "this", ")", ";", "}" ]
Get the content rendered as HTML. @return string
[ "Get", "the", "content", "rendered", "as", "HTML", "." ]
d318664af7f8485ddbcf405a329a99880d036b78
https://github.com/sijad/flarum-ext-pages/blob/d318664af7f8485ddbcf405a329a99880d036b78/src/Page.php#L96-L102
224,554
joomla-framework/github-api
src/Package/Repositories/Deployments.php
Deployments.getList
public function getList($owner, $repo, $sha = '', $ref = '', $task = '', $environment = '', $page = 0, $limit = 0) { // Build the request path. $path = "/repos/$owner/$repo/deployments"; $uri = new Uri($this->fetchUrl($path, $page, $limit)); if ($sha) { $uri->setVar('sha', $sha); } if ($ref) { $uri->setVar('ref', $ref); } if ($task) { $uri->setVar('task', $task); } if ($environment) { $uri->setVar('environment', $environment); } return $this->processResponse($this->client->get($uri)); }
php
public function getList($owner, $repo, $sha = '', $ref = '', $task = '', $environment = '', $page = 0, $limit = 0) { // Build the request path. $path = "/repos/$owner/$repo/deployments"; $uri = new Uri($this->fetchUrl($path, $page, $limit)); if ($sha) { $uri->setVar('sha', $sha); } if ($ref) { $uri->setVar('ref', $ref); } if ($task) { $uri->setVar('task', $task); } if ($environment) { $uri->setVar('environment', $environment); } return $this->processResponse($this->client->get($uri)); }
[ "public", "function", "getList", "(", "$", "owner", ",", "$", "repo", ",", "$", "sha", "=", "''", ",", "$", "ref", "=", "''", ",", "$", "task", "=", "''", ",", "$", "environment", "=", "''", ",", "$", "page", "=", "0", ",", "$", "limit", "=", "0", ")", "{", "// Build the request path.", "$", "path", "=", "\"/repos/$owner/$repo/deployments\"", ";", "$", "uri", "=", "new", "Uri", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ",", "$", "page", ",", "$", "limit", ")", ")", ";", "if", "(", "$", "sha", ")", "{", "$", "uri", "->", "setVar", "(", "'sha'", ",", "$", "sha", ")", ";", "}", "if", "(", "$", "ref", ")", "{", "$", "uri", "->", "setVar", "(", "'ref'", ",", "$", "ref", ")", ";", "}", "if", "(", "$", "task", ")", "{", "$", "uri", "->", "setVar", "(", "'task'", ",", "$", "task", ")", ";", "}", "if", "(", "$", "environment", ")", "{", "$", "uri", "->", "setVar", "(", "'environment'", ",", "$", "environment", ")", ";", "}", "return", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "get", "(", "$", "uri", ")", ")", ";", "}" ]
List Deployments. @param string $owner The name of the owner of the GitHub repository. @param string $repo The name of the GitHub repository. @param string $sha The SHA that was recorded at creation time. @param string $ref The name of the ref. This can be a branch, tag, or SHA. @param string $task The name of the task for the deployment. @param string $environment The name of the environment that was deployed to. @param integer $page The page number from which to get items. @param integer $limit The number of items on a page. @return object @since 1.4.0
[ "List", "Deployments", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Deployments.php#L39-L67
224,555
joomla-framework/github-api
src/Package/Repositories/Deployments.php
Deployments.create
public function create($owner, $repo, $ref, $task = '', $autoMerge = true, $requiredContexts = null, $payload = '', $environment = '', $description = '' ) { // Build the request path. $path = "/repos/$owner/$repo/deployments"; $data = array( 'ref' => $ref, 'auto_merge' => $autoMerge, ); if ($task) { $data['task'] = $task; } if (\is_array($requiredContexts)) { $data['required_contexts'] = $requiredContexts; } if ($payload) { $data['payload'] = $payload; } if ($environment) { $data['environment'] = $environment; } if ($description) { $data['description'] = $description; } $response = $this->client->post($this->fetchUrl($path), json_encode($data)); switch ($response->code) { case 201 : // The deployment was successful return json_decode($response->body); case 409 : // There was a merge conflict or a status check failed. $body = json_decode($response->body); $message = isset($body->message) ? $body->message : 'Invalid response received from GitHub.'; throw new \RuntimeException($message, $response->code); default : throw new \UnexpectedValueException('Unexpected response code: ' . $response->code); } }
php
public function create($owner, $repo, $ref, $task = '', $autoMerge = true, $requiredContexts = null, $payload = '', $environment = '', $description = '' ) { // Build the request path. $path = "/repos/$owner/$repo/deployments"; $data = array( 'ref' => $ref, 'auto_merge' => $autoMerge, ); if ($task) { $data['task'] = $task; } if (\is_array($requiredContexts)) { $data['required_contexts'] = $requiredContexts; } if ($payload) { $data['payload'] = $payload; } if ($environment) { $data['environment'] = $environment; } if ($description) { $data['description'] = $description; } $response = $this->client->post($this->fetchUrl($path), json_encode($data)); switch ($response->code) { case 201 : // The deployment was successful return json_decode($response->body); case 409 : // There was a merge conflict or a status check failed. $body = json_decode($response->body); $message = isset($body->message) ? $body->message : 'Invalid response received from GitHub.'; throw new \RuntimeException($message, $response->code); default : throw new \UnexpectedValueException('Unexpected response code: ' . $response->code); } }
[ "public", "function", "create", "(", "$", "owner", ",", "$", "repo", ",", "$", "ref", ",", "$", "task", "=", "''", ",", "$", "autoMerge", "=", "true", ",", "$", "requiredContexts", "=", "null", ",", "$", "payload", "=", "''", ",", "$", "environment", "=", "''", ",", "$", "description", "=", "''", ")", "{", "// Build the request path.", "$", "path", "=", "\"/repos/$owner/$repo/deployments\"", ";", "$", "data", "=", "array", "(", "'ref'", "=>", "$", "ref", ",", "'auto_merge'", "=>", "$", "autoMerge", ",", ")", ";", "if", "(", "$", "task", ")", "{", "$", "data", "[", "'task'", "]", "=", "$", "task", ";", "}", "if", "(", "\\", "is_array", "(", "$", "requiredContexts", ")", ")", "{", "$", "data", "[", "'required_contexts'", "]", "=", "$", "requiredContexts", ";", "}", "if", "(", "$", "payload", ")", "{", "$", "data", "[", "'payload'", "]", "=", "$", "payload", ";", "}", "if", "(", "$", "environment", ")", "{", "$", "data", "[", "'environment'", "]", "=", "$", "environment", ";", "}", "if", "(", "$", "description", ")", "{", "$", "data", "[", "'description'", "]", "=", "$", "description", ";", "}", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ",", "json_encode", "(", "$", "data", ")", ")", ";", "switch", "(", "$", "response", "->", "code", ")", "{", "case", "201", ":", "// The deployment was successful", "return", "json_decode", "(", "$", "response", "->", "body", ")", ";", "case", "409", ":", "// There was a merge conflict or a status check failed.", "$", "body", "=", "json_decode", "(", "$", "response", "->", "body", ")", ";", "$", "message", "=", "isset", "(", "$", "body", "->", "message", ")", "?", "$", "body", "->", "message", ":", "'Invalid response received from GitHub.'", ";", "throw", "new", "\\", "RuntimeException", "(", "$", "message", ",", "$", "response", "->", "code", ")", ";", "default", ":", "throw", "new", "\\", "UnexpectedValueException", "(", "'Unexpected response code: '", ".", "$", "response", "->", "code", ")", ";", "}", "}" ]
Create a Deployment. @param string $owner The name of the owner of the GitHub repository. @param string $repo The name of the GitHub repository. @param string $ref The ref to deploy. This can be a branch, tag, or SHA. @param string $task Optional parameter to specify a task to execute. @param boolean $autoMerge Optional parameter to merge the default branch into the requested ref if behind the default branch. @param array|null $requiredContexts Optional array of status contexts verified against commit status checks. If this parameter is omitted from the parameters then all unique contexts will be verified before a deployment is created. To bypass checking entirely pass an empty array. Defaults to all unique contexts. @param string $payload Optional JSON payload with extra information about the deployment. @param string $environment Optional name for the target deployment environment. @param string $description Optional short description. @return object @since 1.4.0 @throws \RuntimeException
[ "Create", "a", "Deployment", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Deployments.php#L89-L144
224,556
joomla-framework/github-api
src/Package/Repositories/Deployments.php
Deployments.getDeploymentStatuses
public function getDeploymentStatuses($owner, $repo, $id, $page = 0, $limit = 0) { // Build the request path. $path = "/repos/$owner/$repo/deployments/" . (int) $id . '/statuses'; return $this->processResponse( $this->client->get($this->fetchUrl($path, $page, $limit)) ); }
php
public function getDeploymentStatuses($owner, $repo, $id, $page = 0, $limit = 0) { // Build the request path. $path = "/repos/$owner/$repo/deployments/" . (int) $id . '/statuses'; return $this->processResponse( $this->client->get($this->fetchUrl($path, $page, $limit)) ); }
[ "public", "function", "getDeploymentStatuses", "(", "$", "owner", ",", "$", "repo", ",", "$", "id", ",", "$", "page", "=", "0", ",", "$", "limit", "=", "0", ")", "{", "// Build the request path.", "$", "path", "=", "\"/repos/$owner/$repo/deployments/\"", ".", "(", "int", ")", "$", "id", ".", "'/statuses'", ";", "return", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ",", "$", "page", ",", "$", "limit", ")", ")", ")", ";", "}" ]
List Deployment Statuses. @param string $owner The name of the owner of the GitHub repository. @param string $repo The name of the GitHub repository. @param integer $id The Deployment ID to list the statuses from. @param integer $page The page number from which to get items. @param integer $limit The number of items on a page. @return object @since 1.4.0
[ "List", "Deployment", "Statuses", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Deployments.php#L159-L167
224,557
joomla-framework/github-api
src/Package/Repositories/Deployments.php
Deployments.createStatus
public function createStatus($owner, $repo, $id, $state, $targetUrl = '', $description = '') { $allowedStates = array('pending', 'success', 'error', 'failure'); // Build the request path. $path = "/repos/$owner/$repo/deployments/" . (int) $id . '/statuses'; if (!\in_array($state, $allowedStates)) { throw new \InvalidArgumentException(sprintf('The deployment state must be: %s', implode(', ', $allowedStates))); } $data = array( 'state' => $state, ); if ($targetUrl) { $data['target_url'] = $targetUrl; } if ($description) { $data['description'] = $description; } return $this->processResponse( $this->client->post($this->fetchUrl($path), json_encode($data)), 201 ); }
php
public function createStatus($owner, $repo, $id, $state, $targetUrl = '', $description = '') { $allowedStates = array('pending', 'success', 'error', 'failure'); // Build the request path. $path = "/repos/$owner/$repo/deployments/" . (int) $id . '/statuses'; if (!\in_array($state, $allowedStates)) { throw new \InvalidArgumentException(sprintf('The deployment state must be: %s', implode(', ', $allowedStates))); } $data = array( 'state' => $state, ); if ($targetUrl) { $data['target_url'] = $targetUrl; } if ($description) { $data['description'] = $description; } return $this->processResponse( $this->client->post($this->fetchUrl($path), json_encode($data)), 201 ); }
[ "public", "function", "createStatus", "(", "$", "owner", ",", "$", "repo", ",", "$", "id", ",", "$", "state", ",", "$", "targetUrl", "=", "''", ",", "$", "description", "=", "''", ")", "{", "$", "allowedStates", "=", "array", "(", "'pending'", ",", "'success'", ",", "'error'", ",", "'failure'", ")", ";", "// Build the request path.", "$", "path", "=", "\"/repos/$owner/$repo/deployments/\"", ".", "(", "int", ")", "$", "id", ".", "'/statuses'", ";", "if", "(", "!", "\\", "in_array", "(", "$", "state", ",", "$", "allowedStates", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The deployment state must be: %s'", ",", "implode", "(", "', '", ",", "$", "allowedStates", ")", ")", ")", ";", "}", "$", "data", "=", "array", "(", "'state'", "=>", "$", "state", ",", ")", ";", "if", "(", "$", "targetUrl", ")", "{", "$", "data", "[", "'target_url'", "]", "=", "$", "targetUrl", ";", "}", "if", "(", "$", "description", ")", "{", "$", "data", "[", "'description'", "]", "=", "$", "description", ";", "}", "return", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "post", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ",", "json_encode", "(", "$", "data", ")", ")", ",", "201", ")", ";", "}" ]
Create a Deployment Status. @param string $owner The name of the owner of the GitHub repository. @param string $repo The name of the GitHub repository. @param integer $id The Deployment ID to list the statuses from. @param string $state The state of the status. @param string $targetUrl The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. @param string $description A short description of the status. Maximum length of 140 characters. @return object @since 1.4.0 @throws \InvalidArgumentException
[ "Create", "a", "Deployment", "Status", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Deployments.php#L185-L215
224,558
acacha/users
src/Http/Controllers/APIFullUsersController.php
APIFullUsersController.executeDestroy
private function executeDestroy($ids){ $models = User::find($ids); User::destroy($ids); event(new UserRemoved($models->toJson())); return Response::json(['deleted' => true ]); }
php
private function executeDestroy($ids){ $models = User::find($ids); User::destroy($ids); event(new UserRemoved($models->toJson())); return Response::json(['deleted' => true ]); }
[ "private", "function", "executeDestroy", "(", "$", "ids", ")", "{", "$", "models", "=", "User", "::", "find", "(", "$", "ids", ")", ";", "User", "::", "destroy", "(", "$", "ids", ")", ";", "event", "(", "new", "UserRemoved", "(", "$", "models", "->", "toJson", "(", ")", ")", ")", ";", "return", "Response", "::", "json", "(", "[", "'deleted'", "=>", "true", "]", ")", ";", "}" ]
Execute destroy. @param $ids @return \Illuminate\Http\JsonResponse
[ "Execute", "destroy", "." ]
af74be23d225bc9a23ee049579abb1596ae683c0
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Http/Controllers/APIFullUsersController.php#L71-L80
224,559
kohkimakimoto/workerphp
src/Kohkimakimoto/Worker/Worker.php
Worker.start
public function start() { declare (ticks = 1); register_shutdown_function(array($this, "shutdown")); pcntl_signal(SIGTERM, array($this, "signalHandler")); pcntl_signal(SIGINT, array($this, "signalHandler")); $this->output->writeln("<info>Starting <comment>".$this->config->getName()."</comment>.</info>"); $this->dispatcher->dispatch(WorkerEvents::STARTED, new WorkerStartedEvent($this)); // A dummy timer to keep a process on a system. $this->eventLoop->addPeriodicTimer(10, function () {}); $this->output->writeln('<info>Successfully booted. Quit working with CONTROL-C.</info>'); // Start event loop. $this->eventLoop->run(); }
php
public function start() { declare (ticks = 1); register_shutdown_function(array($this, "shutdown")); pcntl_signal(SIGTERM, array($this, "signalHandler")); pcntl_signal(SIGINT, array($this, "signalHandler")); $this->output->writeln("<info>Starting <comment>".$this->config->getName()."</comment>.</info>"); $this->dispatcher->dispatch(WorkerEvents::STARTED, new WorkerStartedEvent($this)); // A dummy timer to keep a process on a system. $this->eventLoop->addPeriodicTimer(10, function () {}); $this->output->writeln('<info>Successfully booted. Quit working with CONTROL-C.</info>'); // Start event loop. $this->eventLoop->run(); }
[ "public", "function", "start", "(", ")", "{", "declare", "(", "ticks", "=", "1", ")", ";", "register_shutdown_function", "(", "array", "(", "$", "this", ",", "\"shutdown\"", ")", ")", ";", "pcntl_signal", "(", "SIGTERM", ",", "array", "(", "$", "this", ",", "\"signalHandler\"", ")", ")", ";", "pcntl_signal", "(", "SIGINT", ",", "array", "(", "$", "this", ",", "\"signalHandler\"", ")", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", "\"<info>Starting <comment>\"", ".", "$", "this", "->", "config", "->", "getName", "(", ")", ".", "\"</comment>.</info>\"", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "WorkerEvents", "::", "STARTED", ",", "new", "WorkerStartedEvent", "(", "$", "this", ")", ")", ";", "// A dummy timer to keep a process on a system.", "$", "this", "->", "eventLoop", "->", "addPeriodicTimer", "(", "10", ",", "function", "(", ")", "{", "}", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", "'<info>Successfully booted. Quit working with CONTROL-C.</info>'", ")", ";", "// Start event loop.", "$", "this", "->", "eventLoop", "->", "run", "(", ")", ";", "}" ]
Starts running worker. @return void
[ "Starts", "running", "worker", "." ]
fd9688d21b6e46b9a5ecb154374a980ca93dffbc
https://github.com/kohkimakimoto/workerphp/blob/fd9688d21b6e46b9a5ecb154374a980ca93dffbc/src/Kohkimakimoto/Worker/Worker.php#L76-L94
224,560
kohkimakimoto/workerphp
src/Kohkimakimoto/Worker/Worker.php
Worker.shutdown
public function shutdown() { if ($this->masterPid === posix_getpid() && !$this->finished) { // only master process. $this->dispatcher->dispatch(WorkerEvents::SHUTTING_DOWN, new WorkerShuttingDownEvent($this)); $this->output->writeln("<info>Shutdown <comment>".$this->config->getName()."</comment>.</info>"); $this->finished = true; } }
php
public function shutdown() { if ($this->masterPid === posix_getpid() && !$this->finished) { // only master process. $this->dispatcher->dispatch(WorkerEvents::SHUTTING_DOWN, new WorkerShuttingDownEvent($this)); $this->output->writeln("<info>Shutdown <comment>".$this->config->getName()."</comment>.</info>"); $this->finished = true; } }
[ "public", "function", "shutdown", "(", ")", "{", "if", "(", "$", "this", "->", "masterPid", "===", "posix_getpid", "(", ")", "&&", "!", "$", "this", "->", "finished", ")", "{", "// only master process.", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "WorkerEvents", "::", "SHUTTING_DOWN", ",", "new", "WorkerShuttingDownEvent", "(", "$", "this", ")", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", "\"<info>Shutdown <comment>\"", ".", "$", "this", "->", "config", "->", "getName", "(", ")", ".", "\"</comment>.</info>\"", ")", ";", "$", "this", "->", "finished", "=", "true", ";", "}", "}" ]
Shoutdown process. @return void
[ "Shoutdown", "process", "." ]
fd9688d21b6e46b9a5ecb154374a980ca93dffbc
https://github.com/kohkimakimoto/workerphp/blob/fd9688d21b6e46b9a5ecb154374a980ca93dffbc/src/Kohkimakimoto/Worker/Worker.php#L120-L128
224,561
burnbright/silverstripe-importexport
code/gridfield/GridFieldImporter_Request.php
GridFieldImporter_Request.upload
public function upload(SS_HTTPRequest $request) { $field = $this->getUploadField(); $uploadResponse = $field->upload($request); //decode response body. ugly hack ;o $body = Convert::json2array($uploadResponse->getBody()); $body = array_shift($body); //add extra data $body['import_url'] = Controller::join_links( $this->Link('preview'), $body['id'], // Also pull the back URL from the current request so we can persist this particular URL through the following pages. "?BackURL=" . $this->getBackURL($request) ); //don't return buttons at all unset($body['buttons']); //re-encode $response = new SS_HTTPResponse(Convert::raw2json(array($body))); return $response; }
php
public function upload(SS_HTTPRequest $request) { $field = $this->getUploadField(); $uploadResponse = $field->upload($request); //decode response body. ugly hack ;o $body = Convert::json2array($uploadResponse->getBody()); $body = array_shift($body); //add extra data $body['import_url'] = Controller::join_links( $this->Link('preview'), $body['id'], // Also pull the back URL from the current request so we can persist this particular URL through the following pages. "?BackURL=" . $this->getBackURL($request) ); //don't return buttons at all unset($body['buttons']); //re-encode $response = new SS_HTTPResponse(Convert::raw2json(array($body))); return $response; }
[ "public", "function", "upload", "(", "SS_HTTPRequest", "$", "request", ")", "{", "$", "field", "=", "$", "this", "->", "getUploadField", "(", ")", ";", "$", "uploadResponse", "=", "$", "field", "->", "upload", "(", "$", "request", ")", ";", "//decode response body. ugly hack ;o", "$", "body", "=", "Convert", "::", "json2array", "(", "$", "uploadResponse", "->", "getBody", "(", ")", ")", ";", "$", "body", "=", "array_shift", "(", "$", "body", ")", ";", "//add extra data", "$", "body", "[", "'import_url'", "]", "=", "Controller", "::", "join_links", "(", "$", "this", "->", "Link", "(", "'preview'", ")", ",", "$", "body", "[", "'id'", "]", ",", "// Also pull the back URL from the current request so we can persist this particular URL through the following pages.", "\"?BackURL=\"", ".", "$", "this", "->", "getBackURL", "(", "$", "request", ")", ")", ";", "//don't return buttons at all", "unset", "(", "$", "body", "[", "'buttons'", "]", ")", ";", "//re-encode", "$", "response", "=", "new", "SS_HTTPResponse", "(", "Convert", "::", "raw2json", "(", "array", "(", "$", "body", ")", ")", ")", ";", "return", "$", "response", ";", "}" ]
Upload the given file, and import or start preview. @param SS_HTTPRequest $request @return string
[ "Upload", "the", "given", "file", "and", "import", "or", "start", "preview", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter_Request.php#L81-L100
224,562
burnbright/silverstripe-importexport
code/gridfield/GridFieldImporter_Request.php
GridFieldImporter_Request.preview
public function preview(SS_HTTPRequest $request) { $file = File::get() ->byID($request->param('FileID')); if (!$file) { return "file not found"; } //TODO: validate file? $mapper = new CSVFieldMapper($file->getFullPath()); $mapper->setMappableCols($this->getMappableColumns()); //load previously stored values if ($cachedmapping = $this->getCachedMapping()) { $mapper->loadDataFrom($cachedmapping); } $form = $this->MapperForm(); $form->Fields()->unshift( new LiteralField('mapperfield', $mapper->forTemplate()) ); $form->Fields()->push(new HiddenField("BackURL", "BackURL", $this->getBackURL($request))); $form->setFormAction($this->Link('import').'/'.$file->ID); $content = ArrayData::create(array( 'File' => $file, 'MapperForm'=> $form ))->renderWith('GridFieldImporter_preview'); $controller = $this->getToplevelController(); return $controller->customise(array( 'Content' => $content )); }
php
public function preview(SS_HTTPRequest $request) { $file = File::get() ->byID($request->param('FileID')); if (!$file) { return "file not found"; } //TODO: validate file? $mapper = new CSVFieldMapper($file->getFullPath()); $mapper->setMappableCols($this->getMappableColumns()); //load previously stored values if ($cachedmapping = $this->getCachedMapping()) { $mapper->loadDataFrom($cachedmapping); } $form = $this->MapperForm(); $form->Fields()->unshift( new LiteralField('mapperfield', $mapper->forTemplate()) ); $form->Fields()->push(new HiddenField("BackURL", "BackURL", $this->getBackURL($request))); $form->setFormAction($this->Link('import').'/'.$file->ID); $content = ArrayData::create(array( 'File' => $file, 'MapperForm'=> $form ))->renderWith('GridFieldImporter_preview'); $controller = $this->getToplevelController(); return $controller->customise(array( 'Content' => $content )); }
[ "public", "function", "preview", "(", "SS_HTTPRequest", "$", "request", ")", "{", "$", "file", "=", "File", "::", "get", "(", ")", "->", "byID", "(", "$", "request", "->", "param", "(", "'FileID'", ")", ")", ";", "if", "(", "!", "$", "file", ")", "{", "return", "\"file not found\"", ";", "}", "//TODO: validate file?", "$", "mapper", "=", "new", "CSVFieldMapper", "(", "$", "file", "->", "getFullPath", "(", ")", ")", ";", "$", "mapper", "->", "setMappableCols", "(", "$", "this", "->", "getMappableColumns", "(", ")", ")", ";", "//load previously stored values", "if", "(", "$", "cachedmapping", "=", "$", "this", "->", "getCachedMapping", "(", ")", ")", "{", "$", "mapper", "->", "loadDataFrom", "(", "$", "cachedmapping", ")", ";", "}", "$", "form", "=", "$", "this", "->", "MapperForm", "(", ")", ";", "$", "form", "->", "Fields", "(", ")", "->", "unshift", "(", "new", "LiteralField", "(", "'mapperfield'", ",", "$", "mapper", "->", "forTemplate", "(", ")", ")", ")", ";", "$", "form", "->", "Fields", "(", ")", "->", "push", "(", "new", "HiddenField", "(", "\"BackURL\"", ",", "\"BackURL\"", ",", "$", "this", "->", "getBackURL", "(", "$", "request", ")", ")", ")", ";", "$", "form", "->", "setFormAction", "(", "$", "this", "->", "Link", "(", "'import'", ")", ".", "'/'", ".", "$", "file", "->", "ID", ")", ";", "$", "content", "=", "ArrayData", "::", "create", "(", "array", "(", "'File'", "=>", "$", "file", ",", "'MapperForm'", "=>", "$", "form", ")", ")", "->", "renderWith", "(", "'GridFieldImporter_preview'", ")", ";", "$", "controller", "=", "$", "this", "->", "getToplevelController", "(", ")", ";", "return", "$", "controller", "->", "customise", "(", "array", "(", "'Content'", "=>", "$", "content", ")", ")", ";", "}" ]
Action for getting preview interface. @param SS_HTTPRequest $request @return string
[ "Action", "for", "getting", "preview", "interface", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter_Request.php#L107-L137
224,563
burnbright/silverstripe-importexport
code/gridfield/GridFieldImporter_Request.php
GridFieldImporter_Request.MapperForm
public function MapperForm() { $fields = new FieldList( CheckboxField::create("HasHeader", "This data includes a header row.", true ) ); if ($this->component->getCanClearData()) { $fields->push( CheckboxField::create("ClearData", "Remove all existing records before import." ) ); } $actions = new FieldList( new FormAction("import", "Import CSV"), new FormAction("cancel", "Cancel") ); $form = new Form($this, __FUNCTION__, $fields, $actions); return $form; }
php
public function MapperForm() { $fields = new FieldList( CheckboxField::create("HasHeader", "This data includes a header row.", true ) ); if ($this->component->getCanClearData()) { $fields->push( CheckboxField::create("ClearData", "Remove all existing records before import." ) ); } $actions = new FieldList( new FormAction("import", "Import CSV"), new FormAction("cancel", "Cancel") ); $form = new Form($this, __FUNCTION__, $fields, $actions); return $form; }
[ "public", "function", "MapperForm", "(", ")", "{", "$", "fields", "=", "new", "FieldList", "(", "CheckboxField", "::", "create", "(", "\"HasHeader\"", ",", "\"This data includes a header row.\"", ",", "true", ")", ")", ";", "if", "(", "$", "this", "->", "component", "->", "getCanClearData", "(", ")", ")", "{", "$", "fields", "->", "push", "(", "CheckboxField", "::", "create", "(", "\"ClearData\"", ",", "\"Remove all existing records before import.\"", ")", ")", ";", "}", "$", "actions", "=", "new", "FieldList", "(", "new", "FormAction", "(", "\"import\"", ",", "\"Import CSV\"", ")", ",", "new", "FormAction", "(", "\"cancel\"", ",", "\"Cancel\"", ")", ")", ";", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "__FUNCTION__", ",", "$", "fields", ",", "$", "actions", ")", ";", "return", "$", "form", ";", "}" ]
The import form for creating mapping, and choosing options. @return Form
[ "The", "import", "form", "for", "creating", "mapping", "and", "choosing", "options", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter_Request.php#L144-L166
224,564
burnbright/silverstripe-importexport
code/gridfield/GridFieldImporter_Request.php
GridFieldImporter_Request.import
public function import(SS_HTTPRequest $request) { $hasheader = (bool)$request->postVar('HasHeader'); $cleardata = $this->component->getCanClearData() ? (bool)$request->postVar('ClearData') : false; if ($request->postVar('action_import')) { $file = File::get() ->byID($request->param('FileID')); if (!$file) { return "file not found"; } $colmap = Convert::raw2sql($request->postVar('mappings')); if ($colmap) { //save mapping to cache $this->cacheMapping($colmap); //do import $results = $this->importFile( $file->getFullPath(), $colmap, $hasheader, $cleardata ); $this->gridField->getForm() ->sessionMessage($results->getMessage(), 'good'); } } $controller = $this->getToplevelController(); $controller->redirectBack(); }
php
public function import(SS_HTTPRequest $request) { $hasheader = (bool)$request->postVar('HasHeader'); $cleardata = $this->component->getCanClearData() ? (bool)$request->postVar('ClearData') : false; if ($request->postVar('action_import')) { $file = File::get() ->byID($request->param('FileID')); if (!$file) { return "file not found"; } $colmap = Convert::raw2sql($request->postVar('mappings')); if ($colmap) { //save mapping to cache $this->cacheMapping($colmap); //do import $results = $this->importFile( $file->getFullPath(), $colmap, $hasheader, $cleardata ); $this->gridField->getForm() ->sessionMessage($results->getMessage(), 'good'); } } $controller = $this->getToplevelController(); $controller->redirectBack(); }
[ "public", "function", "import", "(", "SS_HTTPRequest", "$", "request", ")", "{", "$", "hasheader", "=", "(", "bool", ")", "$", "request", "->", "postVar", "(", "'HasHeader'", ")", ";", "$", "cleardata", "=", "$", "this", "->", "component", "->", "getCanClearData", "(", ")", "?", "(", "bool", ")", "$", "request", "->", "postVar", "(", "'ClearData'", ")", ":", "false", ";", "if", "(", "$", "request", "->", "postVar", "(", "'action_import'", ")", ")", "{", "$", "file", "=", "File", "::", "get", "(", ")", "->", "byID", "(", "$", "request", "->", "param", "(", "'FileID'", ")", ")", ";", "if", "(", "!", "$", "file", ")", "{", "return", "\"file not found\"", ";", "}", "$", "colmap", "=", "Convert", "::", "raw2sql", "(", "$", "request", "->", "postVar", "(", "'mappings'", ")", ")", ";", "if", "(", "$", "colmap", ")", "{", "//save mapping to cache", "$", "this", "->", "cacheMapping", "(", "$", "colmap", ")", ";", "//do import", "$", "results", "=", "$", "this", "->", "importFile", "(", "$", "file", "->", "getFullPath", "(", ")", ",", "$", "colmap", ",", "$", "hasheader", ",", "$", "cleardata", ")", ";", "$", "this", "->", "gridField", "->", "getForm", "(", ")", "->", "sessionMessage", "(", "$", "results", "->", "getMessage", "(", ")", ",", "'good'", ")", ";", "}", "}", "$", "controller", "=", "$", "this", "->", "getToplevelController", "(", ")", ";", "$", "controller", "->", "redirectBack", "(", ")", ";", "}" ]
Import the current file @param SS_HTTPRequest $request
[ "Import", "the", "current", "file" ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter_Request.php#L182-L211
224,565
burnbright/silverstripe-importexport
code/gridfield/GridFieldImporter_Request.php
GridFieldImporter_Request.importFile
public function importFile($filepath, $colmap = null, $hasheader = true, $cleardata = false) { $loader = $this->component->getLoader($this->gridField); $loader->deleteExistingRecords = $cleardata; //set or merge in given col map if (is_array($colmap)) { $loader->columnMap = $loader->columnMap ? array_merge($loader->columnMap, $colmap) : $colmap; } $loader->getSource() ->setFilePath($filepath) ->setHasHeader($hasheader); return $loader->load(); }
php
public function importFile($filepath, $colmap = null, $hasheader = true, $cleardata = false) { $loader = $this->component->getLoader($this->gridField); $loader->deleteExistingRecords = $cleardata; //set or merge in given col map if (is_array($colmap)) { $loader->columnMap = $loader->columnMap ? array_merge($loader->columnMap, $colmap) : $colmap; } $loader->getSource() ->setFilePath($filepath) ->setHasHeader($hasheader); return $loader->load(); }
[ "public", "function", "importFile", "(", "$", "filepath", ",", "$", "colmap", "=", "null", ",", "$", "hasheader", "=", "true", ",", "$", "cleardata", "=", "false", ")", "{", "$", "loader", "=", "$", "this", "->", "component", "->", "getLoader", "(", "$", "this", "->", "gridField", ")", ";", "$", "loader", "->", "deleteExistingRecords", "=", "$", "cleardata", ";", "//set or merge in given col map", "if", "(", "is_array", "(", "$", "colmap", ")", ")", "{", "$", "loader", "->", "columnMap", "=", "$", "loader", "->", "columnMap", "?", "array_merge", "(", "$", "loader", "->", "columnMap", ",", "$", "colmap", ")", ":", "$", "colmap", ";", "}", "$", "loader", "->", "getSource", "(", ")", "->", "setFilePath", "(", "$", "filepath", ")", "->", "setHasHeader", "(", "$", "hasheader", ")", ";", "return", "$", "loader", "->", "load", "(", ")", ";", "}" ]
Do the import using the configured importer. @param string $filepath @param array|null $colmap @return BulkLoader_Result
[ "Do", "the", "import", "using", "the", "configured", "importer", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter_Request.php#L219-L234
224,566
burnbright/silverstripe-importexport
code/gridfield/GridFieldImporter_Request.php
GridFieldImporter_Request.cacheMapping
protected function cacheMapping($mapping) { $mapping = array_filter($mapping); if ($mapping && !empty($mapping)) { $cache = SS_Cache::factory('gridfieldimporter'); $cache->save(serialize($mapping), $this->cacheKey()); } }
php
protected function cacheMapping($mapping) { $mapping = array_filter($mapping); if ($mapping && !empty($mapping)) { $cache = SS_Cache::factory('gridfieldimporter'); $cache->save(serialize($mapping), $this->cacheKey()); } }
[ "protected", "function", "cacheMapping", "(", "$", "mapping", ")", "{", "$", "mapping", "=", "array_filter", "(", "$", "mapping", ")", ";", "if", "(", "$", "mapping", "&&", "!", "empty", "(", "$", "mapping", ")", ")", "{", "$", "cache", "=", "SS_Cache", "::", "factory", "(", "'gridfieldimporter'", ")", ";", "$", "cache", "->", "save", "(", "serialize", "(", "$", "mapping", ")", ",", "$", "this", "->", "cacheKey", "(", ")", ")", ";", "}", "}" ]
Store the user defined mapping for future use.
[ "Store", "the", "user", "defined", "mapping", "for", "future", "use", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter_Request.php#L278-L285
224,567
burnbright/silverstripe-importexport
code/gridfield/GridFieldImporter_Request.php
GridFieldImporter_Request.getCachedMapping
protected function getCachedMapping() { $cache = SS_Cache::factory('gridfieldimporter'); if ($result = $cache->load($this->cacheKey())) { return unserialize($result); } }
php
protected function getCachedMapping() { $cache = SS_Cache::factory('gridfieldimporter'); if ($result = $cache->load($this->cacheKey())) { return unserialize($result); } }
[ "protected", "function", "getCachedMapping", "(", ")", "{", "$", "cache", "=", "SS_Cache", "::", "factory", "(", "'gridfieldimporter'", ")", ";", "if", "(", "$", "result", "=", "$", "cache", "->", "load", "(", "$", "this", "->", "cacheKey", "(", ")", ")", ")", "{", "return", "unserialize", "(", "$", "result", ")", ";", "}", "}" ]
Look for a previously stored user defined mapping.
[ "Look", "for", "a", "previously", "stored", "user", "defined", "mapping", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter_Request.php#L290-L296
224,568
burnbright/silverstripe-importexport
code/gridfield/GridFieldImporter_Request.php
GridFieldImporter_Request.getBackURL
protected function getBackURL(SS_HTTPRequest $request) { // Initialize a sane default (basically redirects to root admin URL). $controller = $this->getToplevelController(); $url = method_exists($this->requestHandler, "Link") ? $this->requestHandler->Link() : $controller->Link(); // Try to parse out a back URL using standard framework technique. if($request->requestVar('BackURL')) { $url = $request->requestVar('BackURL'); } else if($request->isAjax() && $request->getHeader('X-Backurl')) { $url = $request->getHeader('X-Backurl'); } else if($request->getHeader('Referer')) { $url = $request->getHeader('Referer'); } return $url; }
php
protected function getBackURL(SS_HTTPRequest $request) { // Initialize a sane default (basically redirects to root admin URL). $controller = $this->getToplevelController(); $url = method_exists($this->requestHandler, "Link") ? $this->requestHandler->Link() : $controller->Link(); // Try to parse out a back URL using standard framework technique. if($request->requestVar('BackURL')) { $url = $request->requestVar('BackURL'); } else if($request->isAjax() && $request->getHeader('X-Backurl')) { $url = $request->getHeader('X-Backurl'); } else if($request->getHeader('Referer')) { $url = $request->getHeader('Referer'); } return $url; }
[ "protected", "function", "getBackURL", "(", "SS_HTTPRequest", "$", "request", ")", "{", "// Initialize a sane default (basically redirects to root admin URL).", "$", "controller", "=", "$", "this", "->", "getToplevelController", "(", ")", ";", "$", "url", "=", "method_exists", "(", "$", "this", "->", "requestHandler", ",", "\"Link\"", ")", "?", "$", "this", "->", "requestHandler", "->", "Link", "(", ")", ":", "$", "controller", "->", "Link", "(", ")", ";", "// Try to parse out a back URL using standard framework technique.", "if", "(", "$", "request", "->", "requestVar", "(", "'BackURL'", ")", ")", "{", "$", "url", "=", "$", "request", "->", "requestVar", "(", "'BackURL'", ")", ";", "}", "else", "if", "(", "$", "request", "->", "isAjax", "(", ")", "&&", "$", "request", "->", "getHeader", "(", "'X-Backurl'", ")", ")", "{", "$", "url", "=", "$", "request", "->", "getHeader", "(", "'X-Backurl'", ")", ";", "}", "else", "if", "(", "$", "request", "->", "getHeader", "(", "'Referer'", ")", ")", "{", "$", "url", "=", "$", "request", "->", "getHeader", "(", "'Referer'", ")", ";", "}", "return", "$", "url", ";", "}" ]
Get's the previous URL that lead up to the current request. NOTE: Honestly, this should be built into SS_HTTPRequest, but we can't depend on that right now... so instead, this is being copied verbatim from Controller (in the framework). @param SS_HTTPRequest $request @return string
[ "Get", "s", "the", "previous", "URL", "that", "lead", "up", "to", "the", "current", "request", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/gridfield/GridFieldImporter_Request.php#L315-L332
224,569
burnbright/silverstripe-importexport
code/bulkloader/sources/CsvBulkLoaderSource.php
CsvBulkLoaderSource.getIterator
public function getIterator() { if (!file_exists($this->filepath)) { //TODO: throw exception instead? return null; } $header = $this->hasheader ? $this->getFirstRow() : null; $output = array(); $config = new LexerConfig(); $config->setDelimiter($this->delimiter); $config->setEnclosure($this->enclosure); $config->setIgnoreHeaderLine($this->hasheader); $interpreter = new Interpreter(); // Ignore row column count consistency $interpreter->unstrict(); $interpreter->addObserver(function (array $row) use (&$output, $header) { if ($header) { //create new row using headings as keys $newrow = array(); foreach ($header as $k => $heading) { if (isset($row[$k])) { $newrow[$heading] = $row[$k]; } } $row = $newrow; } $output[] = $row; }); $lexer = new Lexer($config); $lexer->parse($this->filepath, $interpreter); return new ArrayIterator($output); }
php
public function getIterator() { if (!file_exists($this->filepath)) { //TODO: throw exception instead? return null; } $header = $this->hasheader ? $this->getFirstRow() : null; $output = array(); $config = new LexerConfig(); $config->setDelimiter($this->delimiter); $config->setEnclosure($this->enclosure); $config->setIgnoreHeaderLine($this->hasheader); $interpreter = new Interpreter(); // Ignore row column count consistency $interpreter->unstrict(); $interpreter->addObserver(function (array $row) use (&$output, $header) { if ($header) { //create new row using headings as keys $newrow = array(); foreach ($header as $k => $heading) { if (isset($row[$k])) { $newrow[$heading] = $row[$k]; } } $row = $newrow; } $output[] = $row; }); $lexer = new Lexer($config); $lexer->parse($this->filepath, $interpreter); return new ArrayIterator($output); }
[ "public", "function", "getIterator", "(", ")", "{", "if", "(", "!", "file_exists", "(", "$", "this", "->", "filepath", ")", ")", "{", "//TODO: throw exception instead?", "return", "null", ";", "}", "$", "header", "=", "$", "this", "->", "hasheader", "?", "$", "this", "->", "getFirstRow", "(", ")", ":", "null", ";", "$", "output", "=", "array", "(", ")", ";", "$", "config", "=", "new", "LexerConfig", "(", ")", ";", "$", "config", "->", "setDelimiter", "(", "$", "this", "->", "delimiter", ")", ";", "$", "config", "->", "setEnclosure", "(", "$", "this", "->", "enclosure", ")", ";", "$", "config", "->", "setIgnoreHeaderLine", "(", "$", "this", "->", "hasheader", ")", ";", "$", "interpreter", "=", "new", "Interpreter", "(", ")", ";", "// Ignore row column count consistency", "$", "interpreter", "->", "unstrict", "(", ")", ";", "$", "interpreter", "->", "addObserver", "(", "function", "(", "array", "$", "row", ")", "use", "(", "&", "$", "output", ",", "$", "header", ")", "{", "if", "(", "$", "header", ")", "{", "//create new row using headings as keys", "$", "newrow", "=", "array", "(", ")", ";", "foreach", "(", "$", "header", "as", "$", "k", "=>", "$", "heading", ")", "{", "if", "(", "isset", "(", "$", "row", "[", "$", "k", "]", ")", ")", "{", "$", "newrow", "[", "$", "heading", "]", "=", "$", "row", "[", "$", "k", "]", ";", "}", "}", "$", "row", "=", "$", "newrow", ";", "}", "$", "output", "[", "]", "=", "$", "row", ";", "}", ")", ";", "$", "lexer", "=", "new", "Lexer", "(", "$", "config", ")", ";", "$", "lexer", "->", "parse", "(", "$", "this", "->", "filepath", ",", "$", "interpreter", ")", ";", "return", "new", "ArrayIterator", "(", "$", "output", ")", ";", "}" ]
Get a new CSVParser using defined settings. @return Iterator
[ "Get", "a", "new", "CSVParser", "using", "defined", "settings", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/bulkloader/sources/CsvBulkLoaderSource.php#L73-L108
224,570
acacha/users
src/Http/Controllers/UserProfileController.php
UserProfileController.index
public function index(User $user) { $data = []; if ($user->id) { //Requesting another user profile if ( $user->identifiableName() === Auth::user()->id || Auth::user()->can('see-other-users-profile')) { $data = $user->toArray(); } else { abort(403); } } return view('acacha_users::profile', $data); }
php
public function index(User $user) { $data = []; if ($user->id) { //Requesting another user profile if ( $user->identifiableName() === Auth::user()->id || Auth::user()->can('see-other-users-profile')) { $data = $user->toArray(); } else { abort(403); } } return view('acacha_users::profile', $data); }
[ "public", "function", "index", "(", "User", "$", "user", ")", "{", "$", "data", "=", "[", "]", ";", "if", "(", "$", "user", "->", "id", ")", "{", "//Requesting another user profile", "if", "(", "$", "user", "->", "identifiableName", "(", ")", "===", "Auth", "::", "user", "(", ")", "->", "id", "||", "Auth", "::", "user", "(", ")", "->", "can", "(", "'see-other-users-profile'", ")", ")", "{", "$", "data", "=", "$", "user", "->", "toArray", "(", ")", ";", "}", "else", "{", "abort", "(", "403", ")", ";", "}", "}", "return", "view", "(", "'acacha_users::profile'", ",", "$", "data", ")", ";", "}" ]
Show user profile. @param User $user @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
[ "Show", "user", "profile", "." ]
af74be23d225bc9a23ee049579abb1596ae683c0
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Http/Controllers/UserProfileController.php#L20-L32
224,571
acacha/users
src/Providers/UsersServiceProvider.php
UsersServiceProvider.registerGoogleServiceProvider
protected function registerGoogleServiceProvider() { $this->app->register(GoogleServiceProvider::class); $this->app->booting(function() { $loader = AliasLoader::getInstance(); $loader->alias('Google', Google::class); }); app()->extend(\PulkitJalan\Google\Client::class, function ($command, $app) { $config = $app['config']['google']; return new \PulkitJalan\Google\Client($config, config('users.google_apps_admin_user_email')); }); }
php
protected function registerGoogleServiceProvider() { $this->app->register(GoogleServiceProvider::class); $this->app->booting(function() { $loader = AliasLoader::getInstance(); $loader->alias('Google', Google::class); }); app()->extend(\PulkitJalan\Google\Client::class, function ($command, $app) { $config = $app['config']['google']; return new \PulkitJalan\Google\Client($config, config('users.google_apps_admin_user_email')); }); }
[ "protected", "function", "registerGoogleServiceProvider", "(", ")", "{", "$", "this", "->", "app", "->", "register", "(", "GoogleServiceProvider", "::", "class", ")", ";", "$", "this", "->", "app", "->", "booting", "(", "function", "(", ")", "{", "$", "loader", "=", "AliasLoader", "::", "getInstance", "(", ")", ";", "$", "loader", "->", "alias", "(", "'Google'", ",", "Google", "::", "class", ")", ";", "}", ")", ";", "app", "(", ")", "->", "extend", "(", "\\", "PulkitJalan", "\\", "Google", "\\", "Client", "::", "class", ",", "function", "(", "$", "command", ",", "$", "app", ")", "{", "$", "config", "=", "$", "app", "[", "'config'", "]", "[", "'google'", "]", ";", "return", "new", "\\", "PulkitJalan", "\\", "Google", "\\", "Client", "(", "$", "config", ",", "config", "(", "'users.google_apps_admin_user_email'", ")", ")", ";", "}", ")", ";", "}" ]
Register Google Service Provider.
[ "Register", "Google", "Service", "Provider", "." ]
af74be23d225bc9a23ee049579abb1596ae683c0
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Providers/UsersServiceProvider.php#L94-L107
224,572
acacha/users
src/Providers/UsersServiceProvider.php
UsersServiceProvider.defineRoutes
protected function defineRoutes() { if (!$this->app->routesAreCached()) { $router = app('router'); $this->defineWebRoutes($router); $this->defineApiRoutes($router); } }
php
protected function defineRoutes() { if (!$this->app->routesAreCached()) { $router = app('router'); $this->defineWebRoutes($router); $this->defineApiRoutes($router); } }
[ "protected", "function", "defineRoutes", "(", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "routesAreCached", "(", ")", ")", "{", "$", "router", "=", "app", "(", "'router'", ")", ";", "$", "this", "->", "defineWebRoutes", "(", "$", "router", ")", ";", "$", "this", "->", "defineApiRoutes", "(", "$", "router", ")", ";", "}", "}" ]
Define the AdminLTETemplate routes.
[ "Define", "the", "AdminLTETemplate", "routes", "." ]
af74be23d225bc9a23ee049579abb1596ae683c0
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Providers/UsersServiceProvider.php#L146-L153
224,573
framgia/laravel-skeleton
src/RunCommand.php
RunCommand.removeUserModel
protected function removeUserModel($directory) { $modelFile = $directory . '/app/User.php'; if (is_file($modelFile)) { @chmod($modelFile, 0777); @unlink($modelFile); } return $this; }
php
protected function removeUserModel($directory) { $modelFile = $directory . '/app/User.php'; if (is_file($modelFile)) { @chmod($modelFile, 0777); @unlink($modelFile); } return $this; }
[ "protected", "function", "removeUserModel", "(", "$", "directory", ")", "{", "$", "modelFile", "=", "$", "directory", ".", "'/app/User.php'", ";", "if", "(", "is_file", "(", "$", "modelFile", ")", ")", "{", "@", "chmod", "(", "$", "modelFile", ",", "0777", ")", ";", "@", "unlink", "(", "$", "modelFile", ")", ";", "}", "return", "$", "this", ";", "}" ]
Delete old model User.php @param $directory @return $this
[ "Delete", "old", "model", "User", ".", "php" ]
9439868a36c44b6df8b5a0b735094e4d6f86aa60
https://github.com/framgia/laravel-skeleton/blob/9439868a36c44b6df8b5a0b735094e4d6f86aa60/src/RunCommand.php#L121-L131
224,574
acacha/users
src/Http/Controllers/UserInvitationsController.php
UserInvitationsController.accept
public function accept(Request $request) { if (! $request->has('token')) abort(404); if (! $invitation = $this->validateToken($request->input('token'))) abort(404); return $this->showAcceptUserInvitationForm($invitation); }
php
public function accept(Request $request) { if (! $request->has('token')) abort(404); if (! $invitation = $this->validateToken($request->input('token'))) abort(404); return $this->showAcceptUserInvitationForm($invitation); }
[ "public", "function", "accept", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "request", "->", "has", "(", "'token'", ")", ")", "abort", "(", "404", ")", ";", "if", "(", "!", "$", "invitation", "=", "$", "this", "->", "validateToken", "(", "$", "request", "->", "input", "(", "'token'", ")", ")", ")", "abort", "(", "404", ")", ";", "return", "$", "this", "->", "showAcceptUserInvitationForm", "(", "$", "invitation", ")", ";", "}" ]
Accept user invitation. @param Request $request @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
[ "Accept", "user", "invitation", "." ]
af74be23d225bc9a23ee049579abb1596ae683c0
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Http/Controllers/UserInvitationsController.php#L110-L115
224,575
acacha/users
src/Http/Controllers/UserInvitationsController.php
UserInvitationsController.postAccept
public function postAccept(CreateUserWithTokenRequest $request) { if (! $request->has('token')) abort(403); if (! $invitation = $this->validateToken($request->input('token'))) abort(403); $user = User::create([ 'name' => $request->input('name'), 'email' => $request->input('email'), 'password' => bcrypt($request->input('password')), ]); event(new UserCreated($user)); $invitation = UserInvitation::where('token', $request->input('token'))->first(); $invitation->user()->associate($user); $invitation->accept(); return Response::json(['created' => true ]); }
php
public function postAccept(CreateUserWithTokenRequest $request) { if (! $request->has('token')) abort(403); if (! $invitation = $this->validateToken($request->input('token'))) abort(403); $user = User::create([ 'name' => $request->input('name'), 'email' => $request->input('email'), 'password' => bcrypt($request->input('password')), ]); event(new UserCreated($user)); $invitation = UserInvitation::where('token', $request->input('token'))->first(); $invitation->user()->associate($user); $invitation->accept(); return Response::json(['created' => true ]); }
[ "public", "function", "postAccept", "(", "CreateUserWithTokenRequest", "$", "request", ")", "{", "if", "(", "!", "$", "request", "->", "has", "(", "'token'", ")", ")", "abort", "(", "403", ")", ";", "if", "(", "!", "$", "invitation", "=", "$", "this", "->", "validateToken", "(", "$", "request", "->", "input", "(", "'token'", ")", ")", ")", "abort", "(", "403", ")", ";", "$", "user", "=", "User", "::", "create", "(", "[", "'name'", "=>", "$", "request", "->", "input", "(", "'name'", ")", ",", "'email'", "=>", "$", "request", "->", "input", "(", "'email'", ")", ",", "'password'", "=>", "bcrypt", "(", "$", "request", "->", "input", "(", "'password'", ")", ")", ",", "]", ")", ";", "event", "(", "new", "UserCreated", "(", "$", "user", ")", ")", ";", "$", "invitation", "=", "UserInvitation", "::", "where", "(", "'token'", ",", "$", "request", "->", "input", "(", "'token'", ")", ")", "->", "first", "(", ")", ";", "$", "invitation", "->", "user", "(", ")", "->", "associate", "(", "$", "user", ")", ";", "$", "invitation", "->", "accept", "(", ")", ";", "return", "Response", "::", "json", "(", "[", "'created'", "=>", "true", "]", ")", ";", "}" ]
Process accept user invitation form. @param CreateUserWithTokenRequest $request @return \Illuminate\Http\JsonResponse
[ "Process", "accept", "user", "invitation", "form", "." ]
af74be23d225bc9a23ee049579abb1596ae683c0
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Http/Controllers/UserInvitationsController.php#L123-L141
224,576
netz98/n98-deployer
src/Deployer/Task/MagentoTasks.php
MagentoTasks.updateMagentoConfig
public static function updateMagentoConfig() { $env = \Deployer\get('config_store_env'); if (empty($env)) { $env = \Deployer\input()->getArgument('stage'); } $dir = \Deployer\get('config_store_dir'); if (empty($dir)) { $dir = '{{release_path}}/config/store'; } \Deployer\cd('{{release_path_app}}'); \Deployer\run("php bin/magento config:data:import $dir $env"); }
php
public static function updateMagentoConfig() { $env = \Deployer\get('config_store_env'); if (empty($env)) { $env = \Deployer\input()->getArgument('stage'); } $dir = \Deployer\get('config_store_dir'); if (empty($dir)) { $dir = '{{release_path}}/config/store'; } \Deployer\cd('{{release_path_app}}'); \Deployer\run("php bin/magento config:data:import $dir $env"); }
[ "public", "static", "function", "updateMagentoConfig", "(", ")", "{", "$", "env", "=", "\\", "Deployer", "\\", "get", "(", "'config_store_env'", ")", ";", "if", "(", "empty", "(", "$", "env", ")", ")", "{", "$", "env", "=", "\\", "Deployer", "\\", "input", "(", ")", "->", "getArgument", "(", "'stage'", ")", ";", "}", "$", "dir", "=", "\\", "Deployer", "\\", "get", "(", "'config_store_dir'", ")", ";", "if", "(", "empty", "(", "$", "dir", ")", ")", "{", "$", "dir", "=", "'{{release_path}}/config/store'", ";", "}", "\\", "Deployer", "\\", "cd", "(", "'{{release_path_app}}'", ")", ";", "\\", "Deployer", "\\", "run", "(", "\"php bin/magento config:data:import $dir $env\"", ")", ";", "}" ]
Import the Magento Config using the config data files config: - config_store_env requirements: - config:data:import command through semaio/Magento2-ConfigImportExport - <git-repo>/config/store/<config_store_env> directory tree @throws \Symfony\Component\Console\Exception\InvalidArgumentException
[ "Import", "the", "Magento", "Config", "using", "the", "config", "data", "files" ]
cf7b7c790f45c41ed338b8a33b498eeaaaa765e9
https://github.com/netz98/n98-deployer/blob/cf7b7c790f45c41ed338b8a33b498eeaaaa765e9/src/Deployer/Task/MagentoTasks.php#L146-L160
224,577
phootwork/collection
src/ArrayList.php
ArrayList.add
public function add($element, $index = null) { if ($index === null) { $this->collection[$this->size()] = $element; } else { array_splice($this->collection, $index, 0, $element); } return $this; }
php
public function add($element, $index = null) { if ($index === null) { $this->collection[$this->size()] = $element; } else { array_splice($this->collection, $index, 0, $element); } return $this; }
[ "public", "function", "add", "(", "$", "element", ",", "$", "index", "=", "null", ")", "{", "if", "(", "$", "index", "===", "null", ")", "{", "$", "this", "->", "collection", "[", "$", "this", "->", "size", "(", ")", "]", "=", "$", "element", ";", "}", "else", "{", "array_splice", "(", "$", "this", "->", "collection", ",", "$", "index", ",", "0", ",", "$", "element", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds an element to that list @param mixed $element @param int $index @return $this
[ "Adds", "an", "element", "to", "that", "list" ]
e745fe3735a6f2099015d11ea7b917634ebf76f3
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/ArrayList.php#L29-L37
224,578
phootwork/collection
src/ArrayList.php
ArrayList.remove
public function remove($element) { $index = array_search($element, $this->collection, true); if ($index !== null) { unset($this->collection[$index]); } return $this; }
php
public function remove($element) { $index = array_search($element, $this->collection, true); if ($index !== null) { unset($this->collection[$index]); } return $this; }
[ "public", "function", "remove", "(", "$", "element", ")", "{", "$", "index", "=", "array_search", "(", "$", "element", ",", "$", "this", "->", "collection", ",", "true", ")", ";", "if", "(", "$", "index", "!==", "null", ")", "{", "unset", "(", "$", "this", "->", "collection", "[", "$", "index", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Removes an element from the list @param mixed $element @return $this
[ "Removes", "an", "element", "from", "the", "list" ]
e745fe3735a6f2099015d11ea7b917634ebf76f3
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/ArrayList.php#L81-L88
224,579
joomla-framework/github-api
src/Package/Activity/Feeds.php
Feeds.getFeeds
public function getFeeds() { // Build the request path. $path = '/feeds'; return $this->processResponse( $this->client->get($this->fetchUrl($path)) ); }
php
public function getFeeds() { // Build the request path. $path = '/feeds'; return $this->processResponse( $this->client->get($this->fetchUrl($path)) ); }
[ "public", "function", "getFeeds", "(", ")", "{", "// Build the request path.", "$", "path", "=", "'/feeds'", ";", "return", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ")", ")", ";", "}" ]
List Feeds. @return object @since 1.4.0
[ "List", "Feeds", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Activity/Feeds.php#L29-L37
224,580
joomla-framework/github-api
src/Package/Repositories/Releases.php
Releases.getByTag
public function getByTag($user, $repo, $tag) { // Build the request path. $path = "/repos/$user/$repo/releases/tags/$tag"; // Send the request. return $this->processResponse($this->client->get($this->fetchUrl($path))); }
php
public function getByTag($user, $repo, $tag) { // Build the request path. $path = "/repos/$user/$repo/releases/tags/$tag"; // Send the request. return $this->processResponse($this->client->get($this->fetchUrl($path))); }
[ "public", "function", "getByTag", "(", "$", "user", ",", "$", "repo", ",", "$", "tag", ")", "{", "// Build the request path.", "$", "path", "=", "\"/repos/$user/$repo/releases/tags/$tag\"", ";", "// Send the request.", "return", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ")", ")", ";", "}" ]
Get a release by tag name. @param string $user The name of the owner of the GitHub repository. @param string $repo The name of the GitHub repository. @param string $tag The name of the tag. @return object @since 1.4.0
[ "Get", "a", "release", "by", "tag", "name", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Releases.php#L198-L205
224,581
joomla-framework/github-api
src/Package/Repositories/Releases.php
Releases.getListAssets
public function getListAssets($user, $repo, $releaseId, $page = 0, $limit = 0) { // Build the request path. $path = '/repos/' . $user . '/' . $repo . '/releases/' . (int) $releaseId . '/assets'; // Send the request. return $this->processResponse($this->client->get($this->fetchUrl($path, $page, $limit))); }
php
public function getListAssets($user, $repo, $releaseId, $page = 0, $limit = 0) { // Build the request path. $path = '/repos/' . $user . '/' . $repo . '/releases/' . (int) $releaseId . '/assets'; // Send the request. return $this->processResponse($this->client->get($this->fetchUrl($path, $page, $limit))); }
[ "public", "function", "getListAssets", "(", "$", "user", ",", "$", "repo", ",", "$", "releaseId", ",", "$", "page", "=", "0", ",", "$", "limit", "=", "0", ")", "{", "// Build the request path.", "$", "path", "=", "'/repos/'", ".", "$", "user", ".", "'/'", ".", "$", "repo", ".", "'/releases/'", ".", "(", "int", ")", "$", "releaseId", ".", "'/assets'", ";", "// Send the request.", "return", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ",", "$", "page", ",", "$", "limit", ")", ")", ")", ";", "}" ]
List assets for a release. @param string $user The name of the owner of the GitHub repository. @param string $repo The name of the GitHub repository. @param integer $releaseId The release id. @param integer $page The page number from which to get items. @param integer $limit The number of items on a page. @return object @since 1.4.0
[ "List", "assets", "for", "a", "release", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Releases.php#L254-L261
224,582
joomla-framework/github-api
src/Package/Repositories/Releases.php
Releases.getAsset
public function getAsset($user, $repo, $assetId) { // Build the request path. $path = '/repos/' . $user . '/' . $repo . '/releases/assets/' . (int) $assetId; // Send the request. return $this->processResponse($this->client->get($this->fetchUrl($path))); }
php
public function getAsset($user, $repo, $assetId) { // Build the request path. $path = '/repos/' . $user . '/' . $repo . '/releases/assets/' . (int) $assetId; // Send the request. return $this->processResponse($this->client->get($this->fetchUrl($path))); }
[ "public", "function", "getAsset", "(", "$", "user", ",", "$", "repo", ",", "$", "assetId", ")", "{", "// Build the request path.", "$", "path", "=", "'/repos/'", ".", "$", "user", ".", "'/'", ".", "$", "repo", ".", "'/releases/assets/'", ".", "(", "int", ")", "$", "assetId", ";", "// Send the request.", "return", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ")", ")", ";", "}" ]
Get a single release asset. @param string $user The name of the owner of the GitHub repository. @param string $repo The name of the GitHub repository. @param integer $assetId The asset id. @return object @since 1.4.0
[ "Get", "a", "single", "release", "asset", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Releases.php#L274-L281
224,583
joomla-framework/github-api
src/Package/Repositories/Releases.php
Releases.editAsset
public function editAsset($user, $repo, $assetId, $name, $label = '') { // Build the request path. $path = '/repos/' . $user . '/' . $repo . '/releases/assets/' . (int) $assetId; $data = array( 'name' => $name, ); if ($label) { $data['label'] = $label; } // Send the request. return $this->processResponse($this->client->patch($this->fetchUrl($path), json_encode($data))); }
php
public function editAsset($user, $repo, $assetId, $name, $label = '') { // Build the request path. $path = '/repos/' . $user . '/' . $repo . '/releases/assets/' . (int) $assetId; $data = array( 'name' => $name, ); if ($label) { $data['label'] = $label; } // Send the request. return $this->processResponse($this->client->patch($this->fetchUrl($path), json_encode($data))); }
[ "public", "function", "editAsset", "(", "$", "user", ",", "$", "repo", ",", "$", "assetId", ",", "$", "name", ",", "$", "label", "=", "''", ")", "{", "// Build the request path.", "$", "path", "=", "'/repos/'", ".", "$", "user", ".", "'/'", ".", "$", "repo", ".", "'/releases/assets/'", ".", "(", "int", ")", "$", "assetId", ";", "$", "data", "=", "array", "(", "'name'", "=>", "$", "name", ",", ")", ";", "if", "(", "$", "label", ")", "{", "$", "data", "[", "'label'", "]", "=", "$", "label", ";", "}", "// Send the request.", "return", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "patch", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ",", "json_encode", "(", "$", "data", ")", ")", ")", ";", "}" ]
Edit a release asset. @param string $user The name of the owner of the GitHub repository. @param string $repo The name of the GitHub repository. @param integer $assetId The asset id. @param string $name The file name of the asset. @param string $label An alternate short description of the asset. Used in place of the filename. @return object @since 1.4.0
[ "Edit", "a", "release", "asset", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Releases.php#L296-L312
224,584
joomla-framework/github-api
src/Package/Repositories/Releases.php
Releases.deleteAsset
public function deleteAsset($user, $repo, $assetId) { // Build the request path. $path = '/repos/' . $user . '/' . $repo . '/releases/assets/' . (int) $assetId; // Send the request. $this->processResponse($this->client->delete($this->fetchUrl($path)), 204); return true; }
php
public function deleteAsset($user, $repo, $assetId) { // Build the request path. $path = '/repos/' . $user . '/' . $repo . '/releases/assets/' . (int) $assetId; // Send the request. $this->processResponse($this->client->delete($this->fetchUrl($path)), 204); return true; }
[ "public", "function", "deleteAsset", "(", "$", "user", ",", "$", "repo", ",", "$", "assetId", ")", "{", "// Build the request path.", "$", "path", "=", "'/repos/'", ".", "$", "user", ".", "'/'", ".", "$", "repo", ".", "'/releases/assets/'", ".", "(", "int", ")", "$", "assetId", ";", "// Send the request.", "$", "this", "->", "processResponse", "(", "$", "this", "->", "client", "->", "delete", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ")", ",", "204", ")", ";", "return", "true", ";", "}" ]
Delete a release asset. @param string $user The name of the owner of the GitHub repository. @param string $repo The name of the GitHub repository. @param integer $assetId The asset id. @return boolean @since 1.4.0
[ "Delete", "a", "release", "asset", "." ]
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Releases.php#L325-L334
224,585
neos/setup
Classes/Core/ConfigureRoutingComponent.php
ConfigureRoutingComponent.handle
public function handle(ComponentContext $componentContext) { $configurationSource = $this->objectManager->get(\Neos\Flow\Configuration\Source\YamlSource::class); $routesConfiguration = $configurationSource->load($this->packageManager->getPackage('Neos.Setup')->getConfigurationPath() . ConfigurationManager::CONFIGURATION_TYPE_ROUTES); $this->router->setRoutesConfiguration($routesConfiguration); $componentContext->setParameter(\Neos\Flow\Mvc\Routing\RoutingComponent::class, 'skipRouterInitialization', true); }
php
public function handle(ComponentContext $componentContext) { $configurationSource = $this->objectManager->get(\Neos\Flow\Configuration\Source\YamlSource::class); $routesConfiguration = $configurationSource->load($this->packageManager->getPackage('Neos.Setup')->getConfigurationPath() . ConfigurationManager::CONFIGURATION_TYPE_ROUTES); $this->router->setRoutesConfiguration($routesConfiguration); $componentContext->setParameter(\Neos\Flow\Mvc\Routing\RoutingComponent::class, 'skipRouterInitialization', true); }
[ "public", "function", "handle", "(", "ComponentContext", "$", "componentContext", ")", "{", "$", "configurationSource", "=", "$", "this", "->", "objectManager", "->", "get", "(", "\\", "Neos", "\\", "Flow", "\\", "Configuration", "\\", "Source", "\\", "YamlSource", "::", "class", ")", ";", "$", "routesConfiguration", "=", "$", "configurationSource", "->", "load", "(", "$", "this", "->", "packageManager", "->", "getPackage", "(", "'Neos.Setup'", ")", "->", "getConfigurationPath", "(", ")", ".", "ConfigurationManager", "::", "CONFIGURATION_TYPE_ROUTES", ")", ";", "$", "this", "->", "router", "->", "setRoutesConfiguration", "(", "$", "routesConfiguration", ")", ";", "$", "componentContext", "->", "setParameter", "(", "\\", "Neos", "\\", "Flow", "\\", "Mvc", "\\", "Routing", "\\", "RoutingComponent", "::", "class", ",", "'skipRouterInitialization'", ",", "true", ")", ";", "}" ]
Set the routes configuration for the Neos setup and configures the routing component to skip initialisation, which would overwrite the specific settings again. @param ComponentContext $componentContext @return void
[ "Set", "the", "routes", "configuration", "for", "the", "Neos", "setup", "and", "configures", "the", "routing", "component", "to", "skip", "initialisation", "which", "would", "overwrite", "the", "specific", "settings", "again", "." ]
7b5437efe8113e997007be6896628aa9f5c39d2f
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Core/ConfigureRoutingComponent.php#L71-L77
224,586
atorscho/membership
src/Membershipable.php
Membershipable.losePermissions
public function losePermissions($permissions): void { if (!is_array($permissions) && !$permissions instanceof Collection) { $permissions = func_get_args(); } foreach ($permissions as $permission) { $permission = $this->resolvePermission($permission); $this->permissions()->detach($permission); } }
php
public function losePermissions($permissions): void { if (!is_array($permissions) && !$permissions instanceof Collection) { $permissions = func_get_args(); } foreach ($permissions as $permission) { $permission = $this->resolvePermission($permission); $this->permissions()->detach($permission); } }
[ "public", "function", "losePermissions", "(", "$", "permissions", ")", ":", "void", "{", "if", "(", "!", "is_array", "(", "$", "permissions", ")", "&&", "!", "$", "permissions", "instanceof", "Collection", ")", "{", "$", "permissions", "=", "func_get_args", "(", ")", ";", "}", "foreach", "(", "$", "permissions", "as", "$", "permission", ")", "{", "$", "permission", "=", "$", "this", "->", "resolvePermission", "(", "$", "permission", ")", ";", "$", "this", "->", "permissions", "(", ")", "->", "detach", "(", "$", "permission", ")", ";", "}", "}" ]
Remove given permissions from the user. @param array|Permission|Collection|string $permissions
[ "Remove", "given", "permissions", "from", "the", "user", "." ]
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Membershipable.php#L78-L89
224,587
atorscho/membership
src/Membershipable.php
Membershipable.hasPermission
public function hasPermission(string $permission, ?Model $model = null, string $userForeignKey = 'user_id'): bool { // Check model's ownership if ($model && $model->{$userForeignKey} == $this->id) { return true; } // Check user's own permissions if ($this->permissions->pluck('code')->contains($permission)) { return true; } // Check user's groups permissions return $this->groups()->with('permissions')->get()->map->permissions->flatten() ->pluck('code') ->contains($permission); }
php
public function hasPermission(string $permission, ?Model $model = null, string $userForeignKey = 'user_id'): bool { // Check model's ownership if ($model && $model->{$userForeignKey} == $this->id) { return true; } // Check user's own permissions if ($this->permissions->pluck('code')->contains($permission)) { return true; } // Check user's groups permissions return $this->groups()->with('permissions')->get()->map->permissions->flatten() ->pluck('code') ->contains($permission); }
[ "public", "function", "hasPermission", "(", "string", "$", "permission", ",", "?", "Model", "$", "model", "=", "null", ",", "string", "$", "userForeignKey", "=", "'user_id'", ")", ":", "bool", "{", "// Check model's ownership", "if", "(", "$", "model", "&&", "$", "model", "->", "{", "$", "userForeignKey", "}", "==", "$", "this", "->", "id", ")", "{", "return", "true", ";", "}", "// Check user's own permissions", "if", "(", "$", "this", "->", "permissions", "->", "pluck", "(", "'code'", ")", "->", "contains", "(", "$", "permission", ")", ")", "{", "return", "true", ";", "}", "// Check user's groups permissions", "return", "$", "this", "->", "groups", "(", ")", "->", "with", "(", "'permissions'", ")", "->", "get", "(", ")", "->", "map", "->", "permissions", "->", "flatten", "(", ")", "->", "pluck", "(", "'code'", ")", "->", "contains", "(", "$", "permission", ")", ";", "}" ]
Check whether the user has given permission.
[ "Check", "whether", "the", "user", "has", "given", "permission", "." ]
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Membershipable.php#L94-L110
224,588
atorscho/membership
src/Membershipable.php
Membershipable.makeLeaderOf
public function makeLeaderOf($group): void { $group = $this->resolveGroup($group); $this->leadingGroups()->attach($group); }
php
public function makeLeaderOf($group): void { $group = $this->resolveGroup($group); $this->leadingGroups()->attach($group); }
[ "public", "function", "makeLeaderOf", "(", "$", "group", ")", ":", "void", "{", "$", "group", "=", "$", "this", "->", "resolveGroup", "(", "$", "group", ")", ";", "$", "this", "->", "leadingGroups", "(", ")", "->", "attach", "(", "$", "group", ")", ";", "}" ]
Make the user leader of a group. @param int|string|Group $group
[ "Make", "the", "user", "leader", "of", "a", "group", "." ]
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Membershipable.php#L117-L122
224,589
atorscho/membership
src/Membershipable.php
Membershipable.isLeaderOf
public function isLeaderOf($group): bool { $group = $this->resolveGroup($group); return $this->leadingGroups()->where('group_id', is_int($group) ? $group : $group->id)->exists(); }
php
public function isLeaderOf($group): bool { $group = $this->resolveGroup($group); return $this->leadingGroups()->where('group_id', is_int($group) ? $group : $group->id)->exists(); }
[ "public", "function", "isLeaderOf", "(", "$", "group", ")", ":", "bool", "{", "$", "group", "=", "$", "this", "->", "resolveGroup", "(", "$", "group", ")", ";", "return", "$", "this", "->", "leadingGroups", "(", ")", "->", "where", "(", "'group_id'", ",", "is_int", "(", "$", "group", ")", "?", "$", "group", ":", "$", "group", "->", "id", ")", "->", "exists", "(", ")", ";", "}" ]
Determine whether a given user is leader of the group. @param int|string|Group $group @return bool
[ "Determine", "whether", "a", "given", "user", "is", "leader", "of", "the", "group", "." ]
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Membershipable.php#L131-L136
224,590
atorscho/membership
src/Membershipable.php
Membershipable.getFormattedNameAttribute
public function getFormattedNameAttribute(): string { $nameField = \Config::get('membership.users.name_column'); if (!$this->primary_group_id) { return $this->{$nameField}; } return $this->primaryGroup->open_tag . $this->{$nameField} . $this->primaryGroup->close_tag; }
php
public function getFormattedNameAttribute(): string { $nameField = \Config::get('membership.users.name_column'); if (!$this->primary_group_id) { return $this->{$nameField}; } return $this->primaryGroup->open_tag . $this->{$nameField} . $this->primaryGroup->close_tag; }
[ "public", "function", "getFormattedNameAttribute", "(", ")", ":", "string", "{", "$", "nameField", "=", "\\", "Config", "::", "get", "(", "'membership.users.name_column'", ")", ";", "if", "(", "!", "$", "this", "->", "primary_group_id", ")", "{", "return", "$", "this", "->", "{", "$", "nameField", "}", ";", "}", "return", "$", "this", "->", "primaryGroup", "->", "open_tag", ".", "$", "this", "->", "{", "$", "nameField", "}", ".", "$", "this", "->", "primaryGroup", "->", "close_tag", ";", "}" ]
Get user's formatted name according to his primary group tags.
[ "Get", "user", "s", "formatted", "name", "according", "to", "his", "primary", "group", "tags", "." ]
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Membershipable.php#L141-L150
224,591
burnbright/silverstripe-importexport
code/bulkloader/BetterBulkLoader.php
BetterBulkLoader.processAll
protected function processAll($filepath, $preview = false) { if (!$this->source) { user_error("No source has been configured for the bulk loader", E_USER_WARNING ); } $results = new BetterBulkLoader_Result(); $iterator = $this->getSource()->getIterator(); foreach ($iterator as $record) { $this->processRecord($record, $this->columnMap, $results, $preview); } return $results; }
php
protected function processAll($filepath, $preview = false) { if (!$this->source) { user_error("No source has been configured for the bulk loader", E_USER_WARNING ); } $results = new BetterBulkLoader_Result(); $iterator = $this->getSource()->getIterator(); foreach ($iterator as $record) { $this->processRecord($record, $this->columnMap, $results, $preview); } return $results; }
[ "protected", "function", "processAll", "(", "$", "filepath", ",", "$", "preview", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "source", ")", "{", "user_error", "(", "\"No source has been configured for the bulk loader\"", ",", "E_USER_WARNING", ")", ";", "}", "$", "results", "=", "new", "BetterBulkLoader_Result", "(", ")", ";", "$", "iterator", "=", "$", "this", "->", "getSource", "(", ")", "->", "getIterator", "(", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "record", ")", "{", "$", "this", "->", "processRecord", "(", "$", "record", ",", "$", "this", "->", "columnMap", ",", "$", "results", ",", "$", "preview", ")", ";", "}", "return", "$", "results", ";", "}" ]
Import all records from the source. @param string $filepath @param boolean $preview @return BulkLoader_Result
[ "Import", "all", "records", "from", "the", "source", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/bulkloader/BetterBulkLoader.php#L153-L167
224,592
burnbright/silverstripe-importexport
code/bulkloader/BetterBulkLoader.php
BetterBulkLoader.processRecord
protected function processRecord($record, $columnMap, &$results, $preview = false) { if (!is_array($record) || empty($record) || !array_filter($record)) { $results->addSkipped("Empty/invalid record data."); return; } //map incoming record according to the standardisation mapping (columnMap) $record = $this->columnMapRecord($record); //skip if required data is not present if (!$this->hasRequiredData($record)) { $results->addSkipped("Required data is missing."); return; } $modelClass = $this->objectClass; $placeholder = new $modelClass(); //populate placeholder object with transformed data foreach ($this->mappableFields_cache as $field => $label) { //skip empty fields if (!isset($record[$field]) || empty($record[$field])) { continue; } $this->transformField($placeholder, $field, $record[$field]); } //find existing duplicate of placeholder data $obj = null; $existing = null; if (!$placeholder->ID && !empty($this->duplicateChecks)) { $data = $placeholder->getQueriedDatabaseFields(); //don't match on ID, ClassName or RecordClassName unset($data['ID'], $data['ClassName'], $data['RecordClassName']); $existing = $this->findExistingObject($data); } if ($existing) { $obj = $existing; $obj->update($data); } else { // new record if (!$this->addNewRecords) { $results->addSkipped('New record not added'); return; } $obj = $placeholder; } //callback access to every object if (is_callable($this->recordCallback)) { $callback = $this->recordCallback; $callback($obj, $record); } $changed = $existing && $obj->isChanged(); //try/catch for potential write() ValidationException try { // write obj record $obj->write(); //publish pages if ($this->publishPages && $obj instanceof SiteTree) { $obj->publish('Stage', 'Live'); } // save to results if ($existing) { if ($changed) { $results->addUpdated($obj); } else { $results->addSkipped("No data was changed."); } } else { $results->addCreated($obj); } } catch (ValidationException $e) { $results->addSkipped($e->getMessage()); } $objID = $obj->ID; // reduce memory usage $obj->destroy(); unset($existingObj); unset($obj); return $objID; }
php
protected function processRecord($record, $columnMap, &$results, $preview = false) { if (!is_array($record) || empty($record) || !array_filter($record)) { $results->addSkipped("Empty/invalid record data."); return; } //map incoming record according to the standardisation mapping (columnMap) $record = $this->columnMapRecord($record); //skip if required data is not present if (!$this->hasRequiredData($record)) { $results->addSkipped("Required data is missing."); return; } $modelClass = $this->objectClass; $placeholder = new $modelClass(); //populate placeholder object with transformed data foreach ($this->mappableFields_cache as $field => $label) { //skip empty fields if (!isset($record[$field]) || empty($record[$field])) { continue; } $this->transformField($placeholder, $field, $record[$field]); } //find existing duplicate of placeholder data $obj = null; $existing = null; if (!$placeholder->ID && !empty($this->duplicateChecks)) { $data = $placeholder->getQueriedDatabaseFields(); //don't match on ID, ClassName or RecordClassName unset($data['ID'], $data['ClassName'], $data['RecordClassName']); $existing = $this->findExistingObject($data); } if ($existing) { $obj = $existing; $obj->update($data); } else { // new record if (!$this->addNewRecords) { $results->addSkipped('New record not added'); return; } $obj = $placeholder; } //callback access to every object if (is_callable($this->recordCallback)) { $callback = $this->recordCallback; $callback($obj, $record); } $changed = $existing && $obj->isChanged(); //try/catch for potential write() ValidationException try { // write obj record $obj->write(); //publish pages if ($this->publishPages && $obj instanceof SiteTree) { $obj->publish('Stage', 'Live'); } // save to results if ($existing) { if ($changed) { $results->addUpdated($obj); } else { $results->addSkipped("No data was changed."); } } else { $results->addCreated($obj); } } catch (ValidationException $e) { $results->addSkipped($e->getMessage()); } $objID = $obj->ID; // reduce memory usage $obj->destroy(); unset($existingObj); unset($obj); return $objID; }
[ "protected", "function", "processRecord", "(", "$", "record", ",", "$", "columnMap", ",", "&", "$", "results", ",", "$", "preview", "=", "false", ")", "{", "if", "(", "!", "is_array", "(", "$", "record", ")", "||", "empty", "(", "$", "record", ")", "||", "!", "array_filter", "(", "$", "record", ")", ")", "{", "$", "results", "->", "addSkipped", "(", "\"Empty/invalid record data.\"", ")", ";", "return", ";", "}", "//map incoming record according to the standardisation mapping (columnMap)", "$", "record", "=", "$", "this", "->", "columnMapRecord", "(", "$", "record", ")", ";", "//skip if required data is not present", "if", "(", "!", "$", "this", "->", "hasRequiredData", "(", "$", "record", ")", ")", "{", "$", "results", "->", "addSkipped", "(", "\"Required data is missing.\"", ")", ";", "return", ";", "}", "$", "modelClass", "=", "$", "this", "->", "objectClass", ";", "$", "placeholder", "=", "new", "$", "modelClass", "(", ")", ";", "//populate placeholder object with transformed data", "foreach", "(", "$", "this", "->", "mappableFields_cache", "as", "$", "field", "=>", "$", "label", ")", "{", "//skip empty fields", "if", "(", "!", "isset", "(", "$", "record", "[", "$", "field", "]", ")", "||", "empty", "(", "$", "record", "[", "$", "field", "]", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "transformField", "(", "$", "placeholder", ",", "$", "field", ",", "$", "record", "[", "$", "field", "]", ")", ";", "}", "//find existing duplicate of placeholder data", "$", "obj", "=", "null", ";", "$", "existing", "=", "null", ";", "if", "(", "!", "$", "placeholder", "->", "ID", "&&", "!", "empty", "(", "$", "this", "->", "duplicateChecks", ")", ")", "{", "$", "data", "=", "$", "placeholder", "->", "getQueriedDatabaseFields", "(", ")", ";", "//don't match on ID, ClassName or RecordClassName", "unset", "(", "$", "data", "[", "'ID'", "]", ",", "$", "data", "[", "'ClassName'", "]", ",", "$", "data", "[", "'RecordClassName'", "]", ")", ";", "$", "existing", "=", "$", "this", "->", "findExistingObject", "(", "$", "data", ")", ";", "}", "if", "(", "$", "existing", ")", "{", "$", "obj", "=", "$", "existing", ";", "$", "obj", "->", "update", "(", "$", "data", ")", ";", "}", "else", "{", "// new record", "if", "(", "!", "$", "this", "->", "addNewRecords", ")", "{", "$", "results", "->", "addSkipped", "(", "'New record not added'", ")", ";", "return", ";", "}", "$", "obj", "=", "$", "placeholder", ";", "}", "//callback access to every object", "if", "(", "is_callable", "(", "$", "this", "->", "recordCallback", ")", ")", "{", "$", "callback", "=", "$", "this", "->", "recordCallback", ";", "$", "callback", "(", "$", "obj", ",", "$", "record", ")", ";", "}", "$", "changed", "=", "$", "existing", "&&", "$", "obj", "->", "isChanged", "(", ")", ";", "//try/catch for potential write() ValidationException", "try", "{", "// write obj record", "$", "obj", "->", "write", "(", ")", ";", "//publish pages", "if", "(", "$", "this", "->", "publishPages", "&&", "$", "obj", "instanceof", "SiteTree", ")", "{", "$", "obj", "->", "publish", "(", "'Stage'", ",", "'Live'", ")", ";", "}", "// save to results", "if", "(", "$", "existing", ")", "{", "if", "(", "$", "changed", ")", "{", "$", "results", "->", "addUpdated", "(", "$", "obj", ")", ";", "}", "else", "{", "$", "results", "->", "addSkipped", "(", "\"No data was changed.\"", ")", ";", "}", "}", "else", "{", "$", "results", "->", "addCreated", "(", "$", "obj", ")", ";", "}", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "$", "results", "->", "addSkipped", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "objID", "=", "$", "obj", "->", "ID", ";", "// reduce memory usage", "$", "obj", "->", "destroy", "(", ")", ";", "unset", "(", "$", "existingObj", ")", ";", "unset", "(", "$", "obj", ")", ";", "return", "$", "objID", ";", "}" ]
Import the given record
[ "Import", "the", "given", "record" ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/bulkloader/BetterBulkLoader.php#L172-L255
224,593
burnbright/silverstripe-importexport
code/bulkloader/BetterBulkLoader.php
BetterBulkLoader.columnMapRecord
protected function columnMapRecord($record) { $adjustedmap = $this->columnMap; $newrecord = array(); foreach ($record as $field => $value) { if (isset($adjustedmap[$field])) { $newrecord[$adjustedmap[$field]] = $value; } else { $newrecord[$field] = $value; } } return $newrecord; }
php
protected function columnMapRecord($record) { $adjustedmap = $this->columnMap; $newrecord = array(); foreach ($record as $field => $value) { if (isset($adjustedmap[$field])) { $newrecord[$adjustedmap[$field]] = $value; } else { $newrecord[$field] = $value; } } return $newrecord; }
[ "protected", "function", "columnMapRecord", "(", "$", "record", ")", "{", "$", "adjustedmap", "=", "$", "this", "->", "columnMap", ";", "$", "newrecord", "=", "array", "(", ")", ";", "foreach", "(", "$", "record", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "adjustedmap", "[", "$", "field", "]", ")", ")", "{", "$", "newrecord", "[", "$", "adjustedmap", "[", "$", "field", "]", "]", "=", "$", "value", ";", "}", "else", "{", "$", "newrecord", "[", "$", "field", "]", "=", "$", "value", ";", "}", "}", "return", "$", "newrecord", ";", "}" ]
Convert the record's keys to appropriate columnMap keys. @return array record
[ "Convert", "the", "record", "s", "keys", "to", "appropriate", "columnMap", "keys", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/bulkloader/BetterBulkLoader.php#L261-L274
224,594
burnbright/silverstripe-importexport
code/bulkloader/BetterBulkLoader.php
BetterBulkLoader.hasRequiredData
protected function hasRequiredData($mappedrecord) { if (!is_array($mappedrecord) || empty($mappedrecord) || !array_filter($mappedrecord)) { return false; } foreach ($this->transforms as $field => $t) { if ( is_array($t) && isset($t['required']) && $t['required'] === true && (!isset($mappedrecord[$field]) || empty($mappedrecord[$field])) ) { return false; } } return true; }
php
protected function hasRequiredData($mappedrecord) { if (!is_array($mappedrecord) || empty($mappedrecord) || !array_filter($mappedrecord)) { return false; } foreach ($this->transforms as $field => $t) { if ( is_array($t) && isset($t['required']) && $t['required'] === true && (!isset($mappedrecord[$field]) || empty($mappedrecord[$field])) ) { return false; } } return true; }
[ "protected", "function", "hasRequiredData", "(", "$", "mappedrecord", ")", "{", "if", "(", "!", "is_array", "(", "$", "mappedrecord", ")", "||", "empty", "(", "$", "mappedrecord", ")", "||", "!", "array_filter", "(", "$", "mappedrecord", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "transforms", "as", "$", "field", "=>", "$", "t", ")", "{", "if", "(", "is_array", "(", "$", "t", ")", "&&", "isset", "(", "$", "t", "[", "'required'", "]", ")", "&&", "$", "t", "[", "'required'", "]", "===", "true", "&&", "(", "!", "isset", "(", "$", "mappedrecord", "[", "$", "field", "]", ")", "||", "empty", "(", "$", "mappedrecord", "[", "$", "field", "]", ")", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Check if the given mapped record has the required data. @param array $mappedrecord @return boolean
[ "Check", "if", "the", "given", "mapped", "record", "has", "the", "required", "data", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/bulkloader/BetterBulkLoader.php#L281-L299
224,595
burnbright/silverstripe-importexport
code/bulkloader/BetterBulkLoader.php
BetterBulkLoader.isRelation
protected function isRelation($field) { //get relation name from dot notation if (strpos($field, '.') !== false) { list($field, $columnName) = explode('.', $field); } $has_ones = singleton($this->objectClass)->has_one(); //check if relation is present in has ones return isset($has_ones[$field]); }
php
protected function isRelation($field) { //get relation name from dot notation if (strpos($field, '.') !== false) { list($field, $columnName) = explode('.', $field); } $has_ones = singleton($this->objectClass)->has_one(); //check if relation is present in has ones return isset($has_ones[$field]); }
[ "protected", "function", "isRelation", "(", "$", "field", ")", "{", "//get relation name from dot notation", "if", "(", "strpos", "(", "$", "field", ",", "'.'", ")", "!==", "false", ")", "{", "list", "(", "$", "field", ",", "$", "columnName", ")", "=", "explode", "(", "'.'", ",", "$", "field", ")", ";", "}", "$", "has_ones", "=", "singleton", "(", "$", "this", "->", "objectClass", ")", "->", "has_one", "(", ")", ";", "//check if relation is present in has ones", "return", "isset", "(", "$", "has_ones", "[", "$", "field", "]", ")", ";", "}" ]
Detect if a given record field is a relation field. @param string $field @return boolean
[ "Detect", "if", "a", "given", "record", "field", "is", "a", "relation", "field", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/bulkloader/BetterBulkLoader.php#L409-L418
224,596
burnbright/silverstripe-importexport
code/bulkloader/BetterBulkLoader.php
BetterBulkLoader.getRelationName
protected function getRelationName($recordField) { $relationName = null; if (isset($this->relationCallbacks[$recordField])) { $relationName = $this->relationCallbacks[$recordField]['relationname']; } if (strpos($recordField, '.') !== false) { list($relationName, $columnName) = explode('.', $recordField); } return $relationName; }
php
protected function getRelationName($recordField) { $relationName = null; if (isset($this->relationCallbacks[$recordField])) { $relationName = $this->relationCallbacks[$recordField]['relationname']; } if (strpos($recordField, '.') !== false) { list($relationName, $columnName) = explode('.', $recordField); } return $relationName; }
[ "protected", "function", "getRelationName", "(", "$", "recordField", ")", "{", "$", "relationName", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "relationCallbacks", "[", "$", "recordField", "]", ")", ")", "{", "$", "relationName", "=", "$", "this", "->", "relationCallbacks", "[", "$", "recordField", "]", "[", "'relationname'", "]", ";", "}", "if", "(", "strpos", "(", "$", "recordField", ",", "'.'", ")", "!==", "false", ")", "{", "list", "(", "$", "relationName", ",", "$", "columnName", ")", "=", "explode", "(", "'.'", ",", "$", "recordField", ")", ";", "}", "return", "$", "relationName", ";", "}" ]
Given a record field name, find out if this is a relation name and return the name. @param string @return string
[ "Given", "a", "record", "field", "name", "find", "out", "if", "this", "is", "a", "relation", "name", "and", "return", "the", "name", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/bulkloader/BetterBulkLoader.php#L426-L437
224,597
burnbright/silverstripe-importexport
code/bulkloader/BetterBulkLoader.php
BetterBulkLoader.getMappableColumns
public function getMappableColumns() { if (!empty($this->mappableFields)) { return $this->mappableFields; } $scaffolded = $this->scaffoldMappableFields(); if (!empty($this->transforms)) { $transformables = array_keys($this->transforms); $transformables = array_combine($transformables, $transformables); $scaffolded = array_merge($transformables, $scaffolded); } natcasesort($scaffolded); return $scaffolded; }
php
public function getMappableColumns() { if (!empty($this->mappableFields)) { return $this->mappableFields; } $scaffolded = $this->scaffoldMappableFields(); if (!empty($this->transforms)) { $transformables = array_keys($this->transforms); $transformables = array_combine($transformables, $transformables); $scaffolded = array_merge($transformables, $scaffolded); } natcasesort($scaffolded); return $scaffolded; }
[ "public", "function", "getMappableColumns", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "mappableFields", ")", ")", "{", "return", "$", "this", "->", "mappableFields", ";", "}", "$", "scaffolded", "=", "$", "this", "->", "scaffoldMappableFields", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "transforms", ")", ")", "{", "$", "transformables", "=", "array_keys", "(", "$", "this", "->", "transforms", ")", ";", "$", "transformables", "=", "array_combine", "(", "$", "transformables", ",", "$", "transformables", ")", ";", "$", "scaffolded", "=", "array_merge", "(", "$", "transformables", ",", "$", "scaffolded", ")", ";", "}", "natcasesort", "(", "$", "scaffolded", ")", ";", "return", "$", "scaffolded", ";", "}" ]
Get the field-label mapping of fields that data can be mapped into. @return array
[ "Get", "the", "field", "-", "label", "mapping", "of", "fields", "that", "data", "can", "be", "mapped", "into", "." ]
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/bulkloader/BetterBulkLoader.php#L495-L509
224,598
rafasamp/sonus
src/Rafasamp/Sonus/Sonus.php
Sonus.getConverterVersion
public static function getConverterVersion() { // Run terminal command to retrieve version $command = self::getConverterPath().' -version'; $output = shell_exec($command); // PREG pattern to retrive version information $ouput = preg_match("/ffmpeg version (?P<major>[0-9]{0,3}).(?P<minor>[0-9]{0,3}).(?P<revision>[0-9]{0,3})/", $output, $parsed); // Verify output if ($output === false || $output == 0) { return false; } // Assign array with variables $version = array( 'major' => $parsed['major'], 'minor' => $parsed['minor'], 'rev' => $parsed['revision'] ); return $version; }
php
public static function getConverterVersion() { // Run terminal command to retrieve version $command = self::getConverterPath().' -version'; $output = shell_exec($command); // PREG pattern to retrive version information $ouput = preg_match("/ffmpeg version (?P<major>[0-9]{0,3}).(?P<minor>[0-9]{0,3}).(?P<revision>[0-9]{0,3})/", $output, $parsed); // Verify output if ($output === false || $output == 0) { return false; } // Assign array with variables $version = array( 'major' => $parsed['major'], 'minor' => $parsed['minor'], 'rev' => $parsed['revision'] ); return $version; }
[ "public", "static", "function", "getConverterVersion", "(", ")", "{", "// Run terminal command to retrieve version", "$", "command", "=", "self", "::", "getConverterPath", "(", ")", ".", "' -version'", ";", "$", "output", "=", "shell_exec", "(", "$", "command", ")", ";", "// PREG pattern to retrive version information", "$", "ouput", "=", "preg_match", "(", "\"/ffmpeg version (?P<major>[0-9]{0,3}).(?P<minor>[0-9]{0,3}).(?P<revision>[0-9]{0,3})/\"", ",", "$", "output", ",", "$", "parsed", ")", ";", "// Verify output", "if", "(", "$", "output", "===", "false", "||", "$", "output", "==", "0", ")", "{", "return", "false", ";", "}", "// Assign array with variables", "$", "version", "=", "array", "(", "'major'", "=>", "$", "parsed", "[", "'major'", "]", ",", "'minor'", "=>", "$", "parsed", "[", "'minor'", "]", ",", "'rev'", "=>", "$", "parsed", "[", "'revision'", "]", ")", ";", "return", "$", "version", ";", "}" ]
Returns installed ffmpeg version @return array
[ "Returns", "installed", "ffmpeg", "version" ]
bdf49840c5de4e72a7b767eec399d3338f1f9779
https://github.com/rafasamp/sonus/blob/bdf49840c5de4e72a7b767eec399d3338f1f9779/src/Rafasamp/Sonus/Sonus.php#L47-L70
224,599
rafasamp/sonus
src/Rafasamp/Sonus/Sonus.php
Sonus.getSupportedFormats
public static function getSupportedFormats() { // Run terminal command $command = self::getConverterPath().' -formats'; $output = shell_exec($command); // PREG pattern to retrive version information $output = preg_match_all("/(?P<mux>(D\s|\sE|DE))\s(?P<format>\S{3,11})\s/", $output, $parsed); // Verify output if ($output === false || $output == 0) { return false; } // Combine the format and mux information into an array $formats = array_combine($parsed['format'], $parsed['mux']); return $formats; }
php
public static function getSupportedFormats() { // Run terminal command $command = self::getConverterPath().' -formats'; $output = shell_exec($command); // PREG pattern to retrive version information $output = preg_match_all("/(?P<mux>(D\s|\sE|DE))\s(?P<format>\S{3,11})\s/", $output, $parsed); // Verify output if ($output === false || $output == 0) { return false; } // Combine the format and mux information into an array $formats = array_combine($parsed['format'], $parsed['mux']); return $formats; }
[ "public", "static", "function", "getSupportedFormats", "(", ")", "{", "// Run terminal command", "$", "command", "=", "self", "::", "getConverterPath", "(", ")", ".", "' -formats'", ";", "$", "output", "=", "shell_exec", "(", "$", "command", ")", ";", "// PREG pattern to retrive version information", "$", "output", "=", "preg_match_all", "(", "\"/(?P<mux>(D\\s|\\sE|DE))\\s(?P<format>\\S{3,11})\\s/\"", ",", "$", "output", ",", "$", "parsed", ")", ";", "// Verify output", "if", "(", "$", "output", "===", "false", "||", "$", "output", "==", "0", ")", "{", "return", "false", ";", "}", "// Combine the format and mux information into an array", "$", "formats", "=", "array_combine", "(", "$", "parsed", "[", "'format'", "]", ",", "$", "parsed", "[", "'mux'", "]", ")", ";", "return", "$", "formats", ";", "}" ]
Returns all formats ffmpeg supports @return array
[ "Returns", "all", "formats", "ffmpeg", "supports" ]
bdf49840c5de4e72a7b767eec399d3338f1f9779
https://github.com/rafasamp/sonus/blob/bdf49840c5de4e72a7b767eec399d3338f1f9779/src/Rafasamp/Sonus/Sonus.php#L76-L95