idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
7,400 | public function getLayout ( $ data = null ) { $ layout = null ; if ( is_array ( $ data ) && array_key_exists ( self :: LAYOUT_KEY , $ data ) ) { $ layout = $ data [ self :: LAYOUT_KEY ] ; unset ( $ data [ self :: LAYOUT_KEY ] ) ; } if ( $ this -> has ( self :: LAYOUT_KEY ) ) { $ layout = $ this -> get ( self :: LAYOUT_... | Returns the layout for this view . This will be either the layout data value the applications layout configuration value or layout . php . |
7,401 | public function query ( ) { for ( $ i = 0 ; $ i < $ this -> numservers ; $ i ++ ) { $ result = $ this -> querySingleServer ( $ this -> server [ $ i ] ) ; if ( $ this -> debug ) { echo "server: {$this->server[$i]}\n" ; echo "result: $result\n" ; } if ( $ result ) { return $ result ; } } return false ; } | Query each server . |
7,402 | public function input ( $ inputVars ) { foreach ( $ inputVars as $ key => $ val ) { if ( empty ( $ this -> allowed_fields [ $ key ] ) ) { echo "Invalid input $key - perhaps misspelled field?\n" ; return false ; } $ this -> queries [ $ key ] = urlencode ( $ this -> filter_field ( $ key , $ val ) ) ; } $ this -> queries ... | Validates and stores the inputVars in the queries array . |
7,403 | public function optimizeThumbnail ( JoinPointInterface $ joinPoint ) { $ thumbnail = $ joinPoint -> getProxy ( ) ; $ thumbnailResource = $ thumbnail -> getResource ( ) ; if ( ! $ thumbnailResource ) { return ; } $ streamMetaData = stream_get_meta_data ( $ thumbnailResource -> getStream ( ) ) ; $ pathAndFilename = $ str... | After a thumbnail has been refreshed the resource is optimized meaning the image is only optimized once when created . |
7,404 | protected function registerHttplugFactories ( ) { $ this -> app -> bind ( 'httplug.message_factory.default' , function ( $ app ) { return MessageFactoryDiscovery :: find ( ) ; } ) ; $ this -> app -> alias ( 'httplug.message_factory.default' , MessageFactory :: class ) ; $ this -> app -> alias ( 'httplug.message_factory... | Register php - http interfaces to container . |
7,405 | protected function registerHttplug ( ) { $ this -> app -> singleton ( 'httplug' , function ( $ app ) { return new HttplugManager ( $ app ) ; } ) ; $ this -> app -> alias ( 'httplug' , HttplugManager :: class ) ; $ this -> app -> singleton ( 'httplug.default' , function ( $ app ) { return $ app [ 'httplug' ] -> driver (... | Register httplug to container . |
7,406 | public function debugMode ( $ mode ) { if ( ! isset ( $ this -> debugMode [ $ mode ] ) ) { $ mode = 'production' ; } $ this -> mail -> SMTPDebug = $ this -> debugMode [ $ mode ] ; $ this -> mail -> Debugoutput = function ( $ str , $ mode ) { logger ( LogLevel :: DEBUG , $ str , [ 'debugMode' => $ mode ] ) ; } ; return ... | Set mailer debug mode |
7,407 | public function boot ( ) { $ path = __DIR__ . '/../resources/lang/en/exceptionmessages.php' ; $ this -> publishes ( [ $ path => resource_path ( "lang/vendor/{$this->namespace}/en/exceptionmessages.php" ) , ] ) ; $ this -> loadTranslationsFrom ( $ path , $ this -> namespace ) ; } | Registers resources for the package . |
7,408 | public function append ( $ operator , Criteria $ criteria ) { $ this -> children [ ] = new Node ( self :: TYPE_LEAF , $ operator , $ criteria ) ; $ this -> mostRecentCriteria = $ criteria ; return $ this ; } | Appends a leaf node to the children of this node . |
7,409 | public function connect ( ) { $ crotch = new Node ( self :: TYPE_CROTCH , self :: OPERATOR_BLANK , null ) ; $ crotch -> children = \ array_merge ( $ crotch -> children , $ this -> children ) ; $ crotch -> isNegatingWholeChildren = $ this -> isNegatingWholeChildren ; $ this -> isNegatingWholeChildren = false ; $ this ->... | Connects the children to a new parent tree . |
7,410 | protected function bindFulltextParametersToStatement ( \ SQLite3Stmt $ preparedStatement , $ fulltext ) { $ preparedStatement -> bindValue ( ':h1' , isset ( $ fulltext [ 'h1' ] ) ? $ fulltext [ 'h1' ] : '' ) ; $ preparedStatement -> bindValue ( ':h2' , isset ( $ fulltext [ 'h2' ] ) ? $ fulltext [ 'h2' ] : '' ) ; $ prep... | Binds fulltext parameters to a prepared statement as this happens in multiple places . |
7,411 | public function findOneByIdentifier ( $ identifier ) { $ statement = $ this -> connection -> prepare ( 'SELECT * FROM objects WHERE __identifier__ = :identifier LIMIT 1' ) ; $ statement -> bindValue ( ':identifier' , $ identifier ) ; return $ statement -> execute ( ) -> fetchArray ( SQLITE3_ASSOC ) ; } | Returns an index entry by identifier or NULL if it doesn t exist . |
7,412 | public function executeStatement ( $ statementQuery , array $ parameters ) { $ statement = $ this -> connection -> prepare ( $ statementQuery ) ; foreach ( $ parameters as $ parameterName => $ parameterValue ) { $ statement -> bindValue ( $ parameterName , $ parameterValue ) ; } $ result = $ statement -> execute ( ) ; ... | Execute a prepared statement . |
7,413 | public function stem ( $ token , $ lang ) { if ( \ strlen ( $ token ) <= 2 ) { return $ token ; } if ( $ lang !== 'en' ) { return $ token ; } if ( ! isset ( $ this -> cache [ $ lang ] [ $ token ] ) ) { $ result = $ token ; $ result = self :: step1ab ( $ result ) ; $ result = self :: step1c ( $ result ) ; $ result = sel... | Method to stem a token and return the root . |
7,414 | private static function replace ( & $ str , $ check , $ repl , $ m = null ) { $ len = 0 - \ strlen ( $ check ) ; if ( substr ( $ str , $ len ) == $ check ) { $ substr = substr ( $ str , 0 , $ len ) ; if ( $ m === null || self :: m ( $ substr ) > $ m ) { $ str = $ substr . $ repl ; } return true ; } return false ; } | Replaces the first string with the second at the end of the string . If third arg is given then the preceding string must match that m count at least . |
7,415 | public function directory ( $ path = null ) { if ( null === $ path ) { return $ this -> plates -> getDirectory ( ) ; } return $ this -> plates -> getDirectory ( ) . '/' . $ path ; } | Get view directory |
7,416 | public function getRecentTrades ( $ symbol = 'BNBBTC' , $ limit = 500 ) { $ data = [ 'symbol' => $ symbol , 'limit' => $ limit , ] ; $ b = $ this -> privateRequest ( 'v3/myTrades' , $ data ) ; return $ b ; } | Get trades for a specific account and symbol |
7,417 | public function trade ( $ symbol , $ quantity , $ side , $ type = 'MARKET' , $ price = false ) { $ data = [ 'symbol' => $ symbol , 'side' => $ side , 'type' => $ type , 'quantity' => $ quantity ] ; if ( $ price !== false ) { $ data [ 'price' ] = $ price ; } $ b = $ this -> privateRequest ( 'v3/order' , $ data , 'POST' ... | Base trade function |
7,418 | public function install_plugins ( ) { $ result = system ( WP_PHP_BINARY . ' ' . escapeshellarg ( dirname ( dirname ( __FILE__ ) ) . '/bin/install-plugins.php' ) . ' ' . escapeshellarg ( json_encode ( $ this -> plugins ) ) . ' ' . escapeshellarg ( $ this -> locate_wp_tests_config ( ) ) . ' ' . ( int ) is_multisite ( ) .... | Installs the plugins via a separate PHP process . |
7,419 | public function phpunit_compat ( ) { if ( class_exists ( 'PHPUnit\Runner\Version' ) ) { $ tests_dir = $ this -> get_wp_tests_dir ( ) ; if ( file_exists ( $ tests_dir . '/includes/phpunit6-compat.php' ) ) { require_once $ tests_dir . '/includes/phpunit6-compat.php' ; } else { require_once $ tests_dir . '/includes/phpuni... | Ensures compatibility with the current PHPUnit version . |
7,420 | public function get ( $ latitude = null , $ longitude = null , $ time = null ) { $ this -> guardAgainstEmptyArgument ( $ latitude , 'latitude' ) ; $ this -> guardAgainstEmptyArgument ( $ longitude , 'longitude' ) ; $ url = $ this -> getUrl ( $ latitude , $ longitude , $ time ) ; $ forecast = $ this -> getClient ( ) -> ... | Get the weather for the given latitude and longitude Optionally pass in a time for the query |
7,421 | public static function where ( $ field ) { $ root = new Node ( Node :: TYPE_CROTCH , Node :: OPERATOR_BLANK ) ; $ criteria = new Criteria ( $ field , $ root ) ; $ root -> append ( Node :: OPERATOR_BLANK , $ criteria ) ; return $ criteria ; } | Static factory method to create a new Criteria for the provided field . |
7,422 | public function is ( $ value ) { if ( $ value === null ) { return $ this -> isNull ( ) ; } if ( \ is_array ( $ value ) ) { return $ this -> in ( $ value ) ; } $ this -> predicates [ ] = $ this -> processValue ( $ value ) ; return $ this ; } | Creates new predicate without any wildcards for each entry . |
7,423 | public function withinBox ( $ startLatitude , $ startLongitude , $ endLatitude , $ endLongitude ) { $ this -> predicates [ ] = '[' . $ this -> processFloat ( $ startLatitude ) . ',' . $ this -> processFloat ( $ startLongitude ) . ' TO ' . $ this -> processFloat ( $ endLatitude ) . ',' . $ this -> processFloat ( $ endLo... | Creates new predicate for a RANGE spatial search . |
7,424 | public function nearCircle ( $ latitude , $ longitude , $ distance ) { $ this -> assertPositiveFloat ( $ distance ) ; $ this -> predicates [ ] = '{!bbox pt=' . $ this -> processFloat ( $ latitude ) . ',' . $ this -> processFloat ( $ longitude ) . ' sfield=' . $ this -> field . ' d=' . $ this -> processFloat ( $ distanc... | Creates new predicate for !bbox filter . |
7,425 | public function contains ( $ value ) { if ( \ is_array ( $ value ) ) { foreach ( $ value as $ item ) { $ this -> contains ( $ item ) ; } } else { $ this -> predicates [ ] = '*' . $ this -> processValue ( $ value ) . '*' ; } return $ this ; } | Crates new predicate with leading and trailing wildcards for each entry . |
7,426 | public function startsWith ( $ prefix ) { if ( \ is_array ( $ prefix ) ) { foreach ( $ prefix as $ item ) { $ this -> startsWith ( $ item ) ; } } else { $ this -> assertNotBlanks ( $ prefix ) ; $ this -> predicates [ ] = $ this -> processValue ( $ prefix ) . '*' ; } return $ this ; } | Crates new predicate with trailing wildcard for each entry . |
7,427 | public function endsWith ( $ postfix ) { if ( \ is_array ( $ postfix ) ) { foreach ( $ postfix as $ item ) { $ this -> endsWith ( $ item ) ; } } else { $ this -> assertNotBlanks ( $ postfix ) ; $ this -> predicates [ ] = '*' . $ this -> processValue ( $ postfix ) ; } return $ this ; } | Crates new predicate with leading wildcard for each entry . |
7,428 | public function fuzzy ( $ value , $ levenshteinDistance = null ) { if ( $ levenshteinDistance !== null && ( $ levenshteinDistance < 0 ) ) { throw new InvalidArgumentException ( 'Levenshtein Distance has to be 0 or above' ) ; } $ this -> predicates [ ] = $ this -> processValue ( $ value ) . '~' . ( $ levenshteinDistance... | Crates new predicate with trailing ~ optionally followed by levensteinDistance . |
7,429 | public function sloppy ( $ phrase , $ distance ) { if ( $ distance <= 0 ) { throw new InvalidArgumentException ( 'Slop distance has to be greater than 0.' ) ; } if ( \ strpos ( $ phrase , ' ' ) === false ) { throw new InvalidArgumentException ( 'Sloppy phrase must consist of multiple terms, separated with spaces.' ) ; ... | Crates new precidate with trailing ~ followed by distance . |
7,430 | public function boost ( $ value ) { if ( $ value < 0 ) { throw new InvalidArgumentException ( 'Boost must not be negative.' ) ; } $ this -> boost = $ this -> processFloat ( $ value ) ; return $ this ; } | Boost positive hit with given factor . eg . ^2 . 3 value . |
7,431 | private function traverse ( Node $ node ) { $ query = '' ; if ( $ node -> getOperator ( ) !== Node :: OPERATOR_BLANK ) { $ query .= ' ' . $ node -> getOperator ( ) . ' ' ; } if ( $ node -> getType ( ) === Node :: TYPE_CROTCH ) { $ addsParentheses = $ node -> isNegatingWholeChildren ( ) || ( $ node !== $ this -> root &&... | Parses and manages the current node tree of predicates . |
7,432 | public function sendRequest ( $ method , $ endPoint , $ data = '' ) { $ data = json_encode ( $ data ) ; $ headers = [ 'Authorization: Bearer ' . $ this -> ionicAPIToken , 'Content-Type: application/json' , 'Content-Length: ' . strlen ( $ data ) , ] ; $ curlHandler = curl_init ( ) ; curl_setopt ( $ curlHandler , CURLOPT... | Send requests to the Ionic Push API . |
7,433 | private function throwRequestException ( $ statusCode , $ response ) { if ( $ response && isset ( $ response -> error ) ) { $ type = $ response -> error -> type ; $ message = $ this -> getResponseErrorMessage ( $ response -> error ) ; $ link = $ response -> error -> link ; } elseif ( $ this -> isServerErrorResponse ( $... | Throw the RequestException error with error detail |
7,434 | private function getResponseErrorMessage ( $ error ) { $ message = $ error -> message ; if ( isset ( $ error -> details ) && is_array ( $ error -> details ) ) { foreach ( $ error -> details as $ detail ) { $ message .= implode ( ' - ' , $ detail -> errors ) . ' [' . $ detail -> error_type . ' in ' . $ detail -> paramet... | Generate a full message from response error request |
7,435 | private function toDatabaseFilePath ( $ filePath ) { if ( $ filePath === null ) { $ temporaryFile = sys_get_temp_dir ( ) . '/' . uniqid ( 'db-' , true ) . '.sqlite' ; register_shutdown_function ( array ( $ this , 'cleanUp' ) ) ; return $ temporaryFile ; } return $ filePath ; } | Returns a file path for the database file . |
7,436 | public static function findByCountryAndCode ( $ country , $ code ) { $ country = is_object ( $ country ) ? $ country -> id : $ country ; return ProvinceProxy :: byCountry ( $ country ) -> where ( 'code' , $ code ) -> take ( 1 ) -> get ( ) -> first ( ) ; } | Returns a single province object by country and code |
7,437 | private function executeUpdates ( ClassMetadata $ class , array $ options = array ( ) ) { $ className = $ class -> name ; $ persister = $ this -> getXmlEntityPersister ( $ className ) ; $ hasPreUpdateLifecycleCallbacks = isset ( $ class -> lifecycleCallbacks [ Events :: preUpdate ] ) ; $ hasPreUpdateListeners = $ this ... | Executes all xml entity updates for documents of the specified type . |
7,438 | private function doRefresh ( $ xmlEntity , array & $ visited ) { $ oid = spl_object_hash ( $ xmlEntity ) ; if ( isset ( $ visited [ $ oid ] ) ) { return ; } $ visited [ $ oid ] = $ xmlEntity ; $ class = $ this -> xem -> getClassMetadata ( get_class ( $ xmlEntity ) ) ; if ( $ this -> getXmlEntityState ( $ xmlEntity ) ==... | Executes a refresh operation on an xml - entity . |
7,439 | private function doDetach ( $ xmlEntity , array & $ visited ) { $ oid = spl_object_hash ( $ xmlEntity ) ; if ( isset ( $ visited [ $ oid ] ) ) { return ; } $ visited [ $ oid ] = $ xmlEntity ; switch ( $ this -> getXmlEntityState ( $ xmlEntity , self :: STATE_DETACHED ) ) { case self :: STATE_MANAGED : $ this -> removeF... | Executes a detach operation on the given xml - entity . |
7,440 | public function persist ( $ xmlEntity ) { $ class = $ this -> xem -> getClassMetadata ( get_class ( $ xmlEntity ) ) ; if ( $ class -> isMappedSuperclass ) { throw OXMException :: cannotPersistMappedSuperclass ( $ class -> name ) ; } if ( ! $ class -> isRoot ) { throw OXMException :: canOnlyPersistRootClasses ( $ class ... | Persists an xml entity as part of the current unit of work . |
7,441 | public function scheduleForDirtyCheck ( $ xmlEntity ) { $ rootClassName = $ this -> xem -> getClassMetadata ( get_class ( $ xmlEntity ) ) -> rootXmlEntityName ; $ this -> scheduledForDirtyCheck [ $ rootClassName ] [ spl_object_hash ( $ xmlEntity ) ] = $ xmlEntity ; } | Schedules a xml entity for dirty - checking at commit - time . |
7,442 | public function scheduleForInsert ( $ xmlEntity ) { $ oid = spl_object_hash ( $ xmlEntity ) ; if ( isset ( $ this -> entityUpdates [ $ oid ] ) ) { throw new \ InvalidArgumentException ( "Dirty xml entity can not be scheduled for insertion." ) ; } if ( isset ( $ this -> entityDeletions [ $ oid ] ) ) { throw new \ Invali... | Schedules an document for insertion into the database . If the document already has an identifier it will be added to the identity map . |
7,443 | public function getXmlEntityState ( $ xmlEntity , $ assume = null ) { $ oid = spl_object_hash ( $ xmlEntity ) ; if ( ! isset ( $ this -> entityStates [ $ oid ] ) ) { $ class = $ this -> xem -> getClassMetadata ( get_class ( $ xmlEntity ) ) ; if ( $ assume === null ) { $ id = $ class -> getIdentifierValue ( $ xmlEntity ... | Gets the state of an xml entity within the current unit of work . |
7,444 | function propertyChanged ( $ entity , $ propertyName , $ oldValue , $ newValue ) { $ oid = spl_object_hash ( $ entity ) ; $ class = $ this -> xem -> getClassMetadata ( get_class ( $ entity ) ) ; if ( ! isset ( $ class -> fieldMappings [ $ propertyName ] ) ) { return ; } $ this -> entityChangeSets [ $ oid ] [ $ property... | Notifies the listener of a property change . |
7,445 | protected function checkParams ( RouteMatch $ match , $ routeConfig ) { if ( ! isset ( $ routeConfig [ 'params' ] ) ) { return true ; } $ params = ( array ) $ routeConfig [ 'params' ] ; foreach ( $ params as $ name => $ value ) { $ param = $ match -> getParam ( $ name , null ) ; if ( null === $ param ) { continue ; } i... | Check if we should cache the request based on the params in the routematch |
7,446 | protected function checkHttpMethod ( MvcEvent $ event , $ routeConfig ) { $ request = $ event -> getRequest ( ) ; if ( ! $ request instanceof HttpRequest ) { return false ; } if ( isset ( $ routeConfig [ 'http_methods' ] ) ) { $ methods = ( array ) $ routeConfig [ 'http_methods' ] ; if ( ! in_array ( $ request -> getMe... | Check if we should cache the request based on http method requested |
7,447 | public function getReflectionClass ( ) { if ( ! $ this -> reflClass ) { $ this -> reflClass = new \ ReflectionClass ( $ this -> name ) ; } return $ this -> reflClass ; } | Gets the ReflectionClass instance of the mapped class . |
7,448 | public function getFieldXmlNode ( $ fieldName ) { return isset ( $ this -> fieldMappings [ $ fieldName ] ) ? $ this -> fieldMappings [ $ fieldName ] [ 'node' ] : null ; } | Gets the type of an xml name . |
7,449 | public function getFieldName ( $ xmlName ) { return isset ( $ this -> xmlFieldMap [ $ xmlName ] ) ? $ this -> xmlFieldMap [ $ xmlName ] : null ; } | Gets the field name for a xml name . If no field name can be found the xml name is returned . |
7,450 | public function avatar ( $ email ) { if ( filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { $ baseUrl = $ this -> useHttps ? $ this -> https ( $ this -> baseUrl ) : $ this -> baseUrl ; $ url = $ baseUrl . "avatar/" . $ this -> generateHash ( $ email ) ; } else { throw new InvalidArgumentException ( "The avatar filter ... | Get a Gravatar Avatar URL |
7,451 | public function https ( $ value ) { if ( strpos ( $ value , $ this -> baseUrl ) === false ) { throw new InvalidArgumentException ( "You can only convert existing Gravatar URLs to HTTPS" ) ; } else { return str_replace ( $ this -> baseUrl , $ this -> httpsUrl , $ value ) ; } } | Change a Gravatar URL to its Secure version |
7,452 | public function size ( $ value , $ px ) { if ( ! is_numeric ( $ px ) || $ px < 0 || $ px > 2048 ) { throw new InvalidArgumentException ( "You must pass the size filter a valid number between 0 and 2048" ) ; } else if ( strpos ( $ value , $ this -> baseUrl ) === false && strpos ( $ value , $ this -> httpsUrl ) === false... | Change the Size of a Gravatar URL |
7,453 | public function def ( $ value , $ default , $ force = false ) { if ( strpos ( $ value , $ this -> baseUrl ) === false && strpos ( $ value , $ this -> httpsUrl ) === false ) { throw new InvalidArgumentException ( "You can only a default to existing Gravatar URLs" ) ; } else if ( ! filter_var ( $ default , FILTER_VALIDAT... | Specify a default Image for when there is no matching Gravatar image . |
7,454 | public function rating ( $ value , $ rating ) { if ( strpos ( $ value , $ this -> baseUrl ) === false && strpos ( $ value , $ this -> httpsUrl ) === false ) { throw new InvalidArgumentException ( "You can only add a rating to an existing Gravatar URL" ) ; } else if ( ! in_array ( strtolower ( $ rating ) , $ this -> rat... | Specify the maximum rating for an avatar |
7,455 | private function query ( $ string , array $ addition ) { parse_str ( parse_url ( $ string , PHP_URL_QUERY ) , $ queryList ) ; foreach ( $ addition as $ key => $ value ) { $ queryList [ $ key ] = $ value ; } $ url = sprintf ( '%s://%s%s%s' , parse_url ( $ string , PHP_URL_SCHEME ) , parse_url ( $ string , PHP_URL_HOST )... | Generate the query string |
7,456 | public function getRepository ( $ entityName ) { $ entityName = ltrim ( $ entityName , '\\' ) ; if ( isset ( $ this -> repositories [ $ entityName ] ) ) { return $ this -> repositories [ $ entityName ] ; } $ metadata = $ this -> getClassMetadata ( $ entityName ) ; $ customRepositoryClassName = $ metadata -> customRepos... | Gets the repository for a class . |
7,457 | public function refresh ( $ entity ) { if ( ! is_object ( $ entity ) ) { throw new \ InvalidArgumentException ( gettype ( $ entity ) ) ; } $ this -> errorIfClosed ( ) ; $ this -> unitOfWork -> refresh ( $ entity ) ; } | Refreshes the persistent state of an entity from the filesystem overriding any local changes that have not yet been persisted . |
7,458 | public function persist ( $ entity ) { if ( ! is_object ( $ entity ) ) { throw new \ InvalidArgumentException ( gettype ( $ entity ) ) ; } $ this -> errorIfClosed ( ) ; $ this -> unitOfWork -> persist ( $ entity ) ; } | Tells the XmlEntityManager to make an instance managed and persistent . |
7,459 | public static function split ( $ name , NameOrder $ nameOrder = null ) { $ name = trim ( $ name ) ; $ parts = explode ( ' ' , $ name ) ; $ nameOrder = $ nameOrder ? : NameOrderProxy :: create ( ) ; switch ( count ( $ parts ) ) { case 1 : return [ 'firstname' => $ name ] ; break ; case 2 : if ( $ nameOrder -> isEastern ... | Parse and split a fullname into firstname & lastname . |
7,460 | public function generate ( XmlEntityManager $ xem , $ xmlEntity ) { if ( ! $ this -> salt ) { throw new \ Exception ( 'Guid Generator requires a salt to be provided.' ) ; } $ guid = $ this -> generateV4 ( ) ; return $ this -> generateV5 ( $ guid , $ this -> salt ) ; } | Generates a new GUID |
7,461 | public function generateV4 ( ) { return sprintf ( '%04x%04x%04x%04x%04x%04x%04x%04x' , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0x0fff ) | 0x4000 , mt_rand ( 0 , 0x3fff ) | 0x8000 , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) ) ; } | Generates a v4 GUID |
7,462 | public function generateV5 ( $ namespace , $ salt ) { if ( ! $ this -> isValid ( $ namespace ) ) { throw new \ Exception ( 'Provided $namespace is invalid: ' . $ namespace ) ; } $ nhex = str_replace ( array ( '-' , '{' , '}' ) , '' , $ namespace ) ; $ nstr = '' ; for ( $ i = 0 ; $ i < strlen ( $ nhex ) ; $ i += 2 ) { $... | Generates a v5 GUID |
7,463 | public function generate ( array $ metadatas , $ outputDirectory ) { foreach ( $ metadatas as $ metadata ) { $ this -> writeXmlEntityClass ( $ metadata , $ outputDirectory ) ; } } | Generate and write xml - entity classes for the given array of ClassMetadataInfo instances |
7,464 | 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... | Generated and write xml - entity class to disk for the given ClassMetadataInfo instance |
7,465 | public function generateXmlEntityClass ( ClassMetadataInfo $ metadata ) { $ placeHolders = array ( '<namespace>' , '<imports>' , '<xmlEntityAnnotation>' , '<xmlEntityClassName>' , '<xmlEntityBody>' ) ; $ replacements = array ( $ this -> generateXmlEntityNamespace ( $ metadata ) , $ this -> generateXmlEntityImports ( $ ... | Generate a PHP5 Doctrine 2 xml - entity class from the given ClassMetadataInfo instance |
7,466 | 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 ( ... | Generate the updated code for the given ClassMetadataInfo and xml - entity at path |
7,467 | 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 |
7,468 | public function isTransient ( $ className ) { $ fileName = str_replace ( '\\' , '.' , $ className ) . $ this -> fileExtension ; 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 . |
7,469 | protected function findMappingFile ( $ className ) { $ fileName = str_replace ( '\\' , '.' , $ className ) . $ this -> fileExtension ; foreach ( ( array ) $ this -> paths as $ path ) { if ( file_exists ( $ path . DIRECTORY_SEPARATOR . $ fileName ) ) { return $ path . DIRECTORY_SEPARATOR . $ fileName ; } } return false ... | Finds the mapping file for the class with the given name by searching through the configured paths . |
7,470 | 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 ] ) ... | Writes a block of data to the IO object container . |
7,471 | 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 |
7,472 | 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 Clie... | Set Up Client |
7,473 | 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 -> o... | Use OAuth Tokens from Cache |
7,474 | 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 ( ) -> trigger... | Check if a page is saved in the cache and return contents . Return null when no item is found . |
7,475 | public function save ( MvcEvent $ mvcEvent ) { if ( ! $ this -> shouldCacheRequest ( $ mvcEvent ) ) { return ; } $ id = $ this -> getIdGenerator ( ) -> generate ( ) ; $ item = ( $ this -> getOptions ( ) -> getCacheResponse ( ) === true ) ? serialize ( $ mvcEvent -> getResponse ( ) ) : $ mvcEvent -> getResponse ( ) -> g... | Save the page contents to the cache storage . |
7,476 | 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 $ re... | Determine if we should cache the current request |
7,477 | 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 { $ ta... | Cache tags to use for this page |
7,478 | public function find ( $ id , $ lockMode = LockMode :: NONE , $ lockVersion = null ) { if ( $ entity = $ this -> xem -> getUnitOfWork ( ) -> tryGetById ( $ id , $ this -> class -> rootXmlEntityName ) ) { if ( $ lockMode != LockMode :: NONE ) { $ this -> xem -> lock ( $ entity , $ lockMode , $ lockVersion ) ; } return $... | Finds an entity by its identifier . |
7,479 | 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 . |
7,480 | 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 -> ... | Edit a tag . |
7,481 | 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' ] ) ) { re... | Get a customer reference for createCustomer requests . |
7,482 | 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' =... | Get the boleto_url boleto_barcode and boleto_expiration_date in the transaction object . |
7,483 | public function onRoute ( MvcEvent $ e ) { if ( ! $ e -> getRequest ( ) instanceof HttpRequest || ! $ e -> getResponse ( ) instanceof HttpResponse ) { return null ; } $ response = $ e -> getResponse ( ) ; $ data = $ this -> getCacheService ( ) -> load ( $ e ) ; if ( $ data !== null ) { $ this -> loadedFromCache = true ... | Load the page contents from the cache and set the response . |
7,484 | public function onFinish ( MvcEvent $ e ) { if ( ! $ e -> getRequest ( ) instanceof HttpRequest || $ this -> loadedFromCache ) { return ; } $ this -> getCacheService ( ) -> save ( $ e ) ; } | Save page contents to the cache |
7,485 | 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 |
7,486 | 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_expiratio... | Set the boleto expiration date |
7,487 | public function process ( $ payload ) { $ result = $ this -> convertToObject ( $ payload , true ) ; return $ this -> processPayload ( $ result ) ; } | this method used for setWebhook sended payload |
7,488 | private function getArgs ( & $ pattern , $ payload ) { $ args = null ; if ( preg_match ( '/<<.*>>/' , $ pattern , $ matches ) ) { $ args_pattern = $ matches [ 0 ] ; $ tmp_args_pattern = str_replace ( [ '<<' , '>>' ] , [ '(' , ')' ] , $ pattern ) ; if ( preg_match ( '/' . $ tmp_args_pattern . '/i' , $ payload , $ matche... | get arguments part in regex |
7,489 | private function exec ( $ command , $ params = [ ] ) { if ( in_array ( $ command , $ this -> available_commands ) ) { $ 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 |
7,490 | 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 ne... | Get current chat id |
7,491 | public function translate ( $ source , $ target , $ text ) { return $ this -> getResponse ( $ this -> getRequest ( '' , $ text , $ source , $ target ) ) ; } | You can translate text from one language to another language |
7,492 | 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 |
7,493 | 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 (... | Gets a reference proxy instance for the xml - entity of the given type and identified by the given identifier . |
7,494 | 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 ... | Get the Customer data . |
7,495 | 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 ( U... | Clear items from the cache |
7,496 | 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 . |
7,497 | 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 . |
7,498 | 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 [ $ field... | Gets the specified field s value off the given entity . |
7,499 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.