idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
36,400 | public function getAll ( ) { if ( is_null ( $ this -> components ) ) { $ identifier = self :: COMPONENT_PREFIX ; $ filter = function ( Extension $ module ) use ( $ identifier ) { return strpos ( $ module -> getName ( ) , $ identifier ) === 0 ; } ; $ this -> components = array_filter ( $ this -> discovery -> scan ( 'mod... | Returns extension objects for all Lightning components . |
36,401 | public function getMainComponents ( ) { $ identifier = self :: COMPONENT_PREFIX ; $ filter = function ( Extension $ module ) use ( $ identifier ) { $ path = explode ( DIRECTORY_SEPARATOR , $ module -> getPath ( ) ) ; $ parent = $ path [ count ( $ path ) - 3 ] ; return strpos ( $ parent , $ identifier ) !== 0 ; } ; retu... | Returns extension objects for all main Lightning components . |
36,402 | protected function merge ( array $ merge , array $ config = [ ] ) { foreach ( $ merge as $ path ) { $ merge = file_get_contents ( $ path ) ; $ merge = str_replace ( '%paths.base%' , dirname ( $ path ) , $ merge ) ; $ merge = Yaml :: decode ( $ merge ) ; $ config = NestedArray :: mergeDeep ( $ config , $ merge ) ; } ret... | Merges partials into the aggregated Behat configuration . |
36,403 | protected function readConfig ( ) { $ this -> configPath = $ this -> ensurePath ( $ this -> configPath ) ; $ config = file_get_contents ( $ this -> configPath ) ; return Yaml :: decode ( $ config ) ; } | Parses the aggregated Behat configuration . |
36,404 | protected function writeConfig ( array $ config , array $ merge = [ ] ) { if ( $ merge ) { $ config = $ this -> merge ( $ merge , $ config ) ; } $ success = file_put_contents ( $ this -> configPath , Yaml :: encode ( $ config ) ) ; if ( $ success === FALSE ) { throw new \ RuntimeException ( 'Could not write ' . $ this ... | Writes aggregated Behat configuration . |
36,405 | protected function make ( ) { $ info = [ 'core' => '8.x' , 'api' => 2 , 'defaults' => [ 'projects' => [ 'subdir' => 'contrib' , ] , ] , 'projects' => [ ] , 'libraries' => [ ] , ] ; $ lock = $ this -> locker -> getLockData ( ) ; foreach ( $ lock [ 'packages' ] as $ package ) { list ( , $ name ) = explode ( '/' , $ packa... | Generates a complete make file structure from the root package . |
36,406 | protected function buildProject ( array $ package ) { $ info = [ ] ; switch ( $ package [ 'type' ] ) { case 'drupal-core' : case 'drupal-theme' : case 'drupal-module' : $ info [ 'type' ] = substr ( $ package [ 'type' ] , 7 ) ; break ; } $ info += $ this -> buildPackage ( $ package ) ; if ( $ package [ 'type' ] === 'dru... | Builds a make structure for a Drupal module theme profile or core . |
36,407 | public function applyStandardProcessing ( array & $ element ) { if ( empty ( $ element [ '#process' ] ) ) { $ info = $ this -> elementInfo -> getInfo ( $ element [ '#type' ] ) ; if ( isset ( $ info [ '#process' ] ) ) { $ element [ '#process' ] = $ info [ '#process' ] ; } } } | Applies standard process functions to a form element . |
36,408 | protected static function getPatchedDependencyConstraints ( RootPackageInterface $ root_package ) { $ required = $ root_package -> getRequires ( ) ; $ extra = $ root_package -> getExtra ( ) ; $ patched = $ extra [ 'patches' ] ; return array_intersect_key ( $ required , $ patched ) ; } | Filters the requires section to packages that are patched . |
36,409 | protected static function packageIsUnpinned ( Link $ package ) { if ( $ package -> getTarget ( ) == 'drupal/core' ) { return FALSE ; } $ constraint = $ package -> getPrettyConstraint ( ) ; if ( preg_match ( '/[\^~*|]/' , $ constraint ) ) { return TRUE ; } } | Determines if a given package s constraint is pinned or not . |
36,410 | public function updateProfiles ( StyleInterface $ io ) { $ discovery = new ExtensionDiscovery ( $ this -> appRoot ) ; foreach ( $ discovery -> scan ( 'profile' ) as $ profile ) { $ info_file = $ profile -> getPathname ( ) ; if ( ! is_writeable ( $ info_file ) ) { $ message = $ this -> t ( 'Cannot write to @path, skippi... | Converts sub - profile info keys to the 8 . 6 . x API . |
36,411 | public function validateExcludedModules ( array $ excluded_modules ) { $ components = $ this -> componentDiscovery -> getAll ( ) ; unset ( $ components [ 'lightning_core' ] ) ; $ invalid = array_diff ( $ excluded_modules , array_keys ( $ components ) ) ; if ( $ invalid ) { $ error = sprintf ( $ this -> trans ( 'command... | Validates excluded modules . |
36,412 | protected function confirmComponent ( array $ info , DrupalStyle $ io ) { if ( $ info [ 'machine_name' ] == 'lightning_core' ) { $ include = TRUE ; } else { $ question = sprintf ( $ this -> trans ( 'commands.lightning.subprofile.questions.include-component' ) , $ info [ 'name' ] ) ; $ include = $ io -> confirm ( $ ques... | Asks the user about including or excluding a Lightning component . |
36,413 | protected function doExclude ( $ modules ) { if ( $ modules ) { $ modules = ( array ) $ modules ; $ this -> excludeList = array_merge ( $ this -> excludeList , $ modules ) ; $ this -> installList = array_diff ( $ this -> installList , $ modules ) ; } } | Adds a set of modules to the exclude list . |
36,414 | protected function excludeSubComponents ( array $ parent , DrupalStyle $ io ) { $ sub_components = $ parent [ 'components' ] ; sort ( $ sub_components ) ; $ question = sprintf ( $ this -> trans ( 'commands.lightning.subprofile.questions.exclude-components' ) , $ parent [ 'name' ] , count ( $ sub_components ) , Element ... | Asks the user about excluding a set of Lightning sub - components . |
36,415 | protected function getMainComponentInfo ( ) { if ( $ this -> componentInfo === NULL ) { $ components = $ this -> componentDiscovery -> getMainComponents ( ) ; Element :: order ( $ components , [ 'lightning_core' , 'lightning_media' , 'lightning_layout' , 'lightning_workflow' , 'lightning_preview' , ] ) ; $ this -> comp... | Returns info for top - level components . |
36,416 | protected function assertDetails ( $ summary , ElementInterface $ container ) { foreach ( $ container -> findAll ( 'css' , 'details > summary' ) as $ element ) { if ( $ element -> getText ( ) == $ summary ) { return $ element -> getParent ( ) ; } } throw new ExpectationException ( "Could not find a details element with... | Asserts the existence of a details element by its summary text . |
36,417 | public function update ( $ version ) { $ tasks = $ this -> restore ( $ version ) ; if ( $ tasks ) { $ tasks -> addTask ( $ this -> taskDrush ( 'updatedb' ) -> option ( 'yes' ) ) -> addTask ( $ this -> taskDrupal ( 'update:lightning' ) -> option ( 'no-interaction' ) -> arg ( $ version ) ) ; } return $ tasks ; } | Updates from a previous version of Lightning . |
36,418 | public function restore ( $ version ) { $ fixture = "tests/fixtures/$version.sql" ; if ( file_exists ( "$fixture.bz2" ) ) { return $ this -> collectionBuilder ( ) -> addTask ( $ this -> taskExec ( 'bunzip2' ) -> arg ( "$fixture.bz2" ) -> option ( 'keep' ) -> option ( 'force' ) ) -> addTask ( $ this -> taskDrupal ( 'dat... | Restores a database dump of a previous version of Lightning . |
36,419 | public static function calc ( $ sentence , $ DAG , $ options = array ( ) ) { $ N = mb_strlen ( $ sentence , 'UTF-8' ) ; self :: $ route = array ( ) ; self :: $ route [ $ N ] = array ( $ N => 1.0 ) ; for ( $ i = ( $ N - 1 ) ; $ i >= 0 ; $ i -- ) { $ candidates = array ( ) ; foreach ( $ DAG [ $ i ] as $ x ) { $ w_c = mb_... | Static method calc |
36,420 | public static function cutForSearch ( $ sentence , $ options = array ( ) ) { $ defaults = array ( 'mode' => 'default' ) ; $ options = array_merge ( $ defaults , $ options ) ; $ seg_list = array ( ) ; $ cut_seg_list = Jieba :: cut ( $ sentence ) ; foreach ( $ cut_seg_list as $ w ) { $ len = mb_strlen ( $ w , 'UTF-8' ) ;... | Static method cutForSearch |
36,421 | public static function loadModel ( $ f_name , $ options = array ( ) ) { $ defaults = array ( 'mode' => 'default' ) ; $ options = array_merge ( $ defaults , $ options ) ; return json_decode ( file_get_contents ( $ f_name ) , true ) ; } | Static method loadModel |
36,422 | public static function getTopStates ( $ t_state_v , $ top_k = 4 , $ options = array ( ) ) { arsort ( $ t_state_v ) ; $ top_states = array_slice ( $ t_state_v , 0 , $ top_k ) ; return $ top_states ; } | Static method getTopStates |
36,423 | public static function posTagReadable ( $ seg_list , $ options = array ( ) ) { $ defaults = array ( 'mode' => 'default' ) ; $ options = array_merge ( $ defaults , $ options ) ; $ new_seg_list = array ( ) ; foreach ( $ seg_list as $ seg ) { $ seg [ 'tag_readable' ] = self :: $ pos_tag_readable [ $ seg [ 'tag' ] ] ; arra... | Static method posTagReadable |
36,424 | public static function loadUserDict ( $ f_name , $ options = array ( ) ) { array_push ( self :: $ user_dictname , $ f_name ) ; $ content = fopen ( $ f_name , "r" ) ; while ( ( $ line = fgets ( $ content ) ) !== false ) { $ explode_line = explode ( " " , trim ( $ line ) ) ; $ word = $ explode_line [ 0 ] ; $ freq = isset... | Static method loadUserDict |
36,425 | public static function addWord ( $ word , $ freq , $ tag = '' , $ options = array ( ) ) { if ( isset ( self :: $ original_freq [ $ word ] ) ) { self :: $ total -= self :: $ original_freq [ $ word ] ; } self :: $ original_freq [ $ word ] = $ freq ; self :: $ total += $ freq ; $ l = mb_strlen ( $ word , 'UTF-8' ) ; $ wor... | Static method addWord |
36,426 | public static function tokenize ( $ sentence , $ options = array ( "HMM" => true ) ) { $ seg_list = self :: cut ( $ sentence , false , array ( "HMM" => $ options [ "HMM" ] ) ) ; $ tokenize_list = [ ] ; $ start = 0 ; $ end = 0 ; foreach ( $ seg_list as $ seg ) { $ end = $ start + mb_strlen ( $ seg , 'UTF-8' ) ; $ tokeni... | Static method tokenize |
36,427 | public static function setStopWords ( $ stop_words_path , $ options = array ( ) ) { $ content = fopen ( $ stop_words_path , "r" ) ; while ( ( $ line = fgets ( $ content ) ) !== false ) { $ stop_word = strtolower ( trim ( $ line ) ) ; if ( ! in_array ( $ stop_word , self :: $ stop_words ) ) { array_push ( self :: $ stop... | Static method setStopWords |
36,428 | public static function extractTags ( $ content , $ top_k = 20 , $ options = array ( ) ) { $ defaults = array ( 'mode' => 'default' ) ; $ options = array_merge ( $ defaults , $ options ) ; $ tags = array ( ) ; if ( isset ( $ options [ 'allowPOS' ] ) ) { $ wordsPos = Posseg :: cut ( $ content ) ; foreach ( $ wordsPos as ... | Static method extractTags |
36,429 | public static function parseFromFile ( $ filename ) { if ( file_exists ( $ filename ) && is_readable ( $ filename ) ) { return new self ( file_get_contents ( $ filename ) ) ; } else { throw new \ RuntimeException ( sprintf ( "File %s is not readable, or doesn't exist." , $ filename ) ) ; } } | Helper function to parse a file directly . |
36,430 | public function getCardAtIndex ( $ i ) { if ( isset ( $ this -> vcardObjects [ $ i ] ) ) { return $ this -> vcardObjects [ $ i ] ; } throw new \ OutOfBoundsException ( ) ; } | Fetch the imported VCard at the specified index . |
36,431 | public function download ( ) { $ output = $ this -> getOutput ( ) ; foreach ( $ this -> getHeaders ( false ) as $ header ) { header ( $ header ) ; } echo $ output ; } | Download a vcard or vcal file to the browser . |
36,432 | public function isIOS ( ) { $ browser = $ this -> getUserAgent ( ) ; return ( strpos ( $ browser , 'iphone' ) || strpos ( $ browser , 'ipod' ) || strpos ( $ browser , 'ipad' ) ) ; } | Is iOS - Check if the user is using an iOS - device |
36,433 | public function save ( ) { $ file = $ this -> getFilename ( ) . '.' . $ this -> getFileExtension ( ) ; if ( null !== $ this -> savePath ) { $ file = $ this -> savePath . $ file ; } file_put_contents ( $ file , $ this -> getOutput ( ) ) ; } | Save to a file |
36,434 | public function setSavePath ( $ savePath ) { if ( ! is_dir ( $ savePath ) ) { throw VCardException :: outputDirectoryNotExists ( ) ; } if ( substr ( $ savePath , - 1 ) != DIRECTORY_SEPARATOR ) { $ savePath .= DIRECTORY_SEPARATOR ; } $ this -> savePath = $ savePath ; } | Set the save path directory |
36,435 | protected function shouldAttachmentBeCal ( ) { $ browser = $ this -> getUserAgent ( ) ; $ matches = [ ] ; preg_match ( '/os (\d+)_(\d+)\s+/' , $ browser , $ matches ) ; $ version = isset ( $ matches [ 1 ] ) ? ( ( int ) $ matches [ 1 ] ) : 999 ; return ( $ version < 8 ) ; } | Checks if we should return vcard in cal wrapper |
36,436 | public function needsReload ( $ key ) { $ needsReload = true ; if ( $ this -> cache -> exists ( $ key ) ) { try { $ dateCache = $ this -> cache -> mtime ( $ key ) ; $ needsReload = false ; if ( time ( ) - $ this -> ttl >= $ dateCache ) { $ dateSource = $ this -> source -> mtime ( $ key ) ; $ needsReload = $ dateCache <... | Indicates whether the cache for the specified key needs to be reloaded . |
36,437 | public function needsRebuild ( $ cacheFile ) { $ needsRebuild = true ; if ( $ this -> serializeCache -> exists ( $ cacheFile ) ) { try { $ needsRebuild = time ( ) - $ this -> ttl >= $ this -> serializeCache -> mtime ( $ cacheFile ) ; } catch ( \ RuntimeException $ e ) { } } return $ needsRebuild ; } | Indicates whether the serialized cache file needs to be rebuild . |
36,438 | protected function computePath ( $ key ) { $ this -> ensureDirectoryExists ( $ this -> directory , $ this -> create ) ; return $ this -> normalizePath ( $ this -> directory . '/' . $ key ) ; } | Computes the path from the specified key . |
36,439 | protected function normalizePath ( $ path ) { $ path = Util \ Path :: normalize ( $ path ) ; if ( 0 !== strpos ( $ path , $ this -> directory ) ) { throw new \ OutOfBoundsException ( sprintf ( 'The path "%s" is out of the filesystem.' , $ path ) ) ; } return $ path ; } | Normalizes the given path . |
36,440 | protected function ensureDirectoryExists ( $ directory , $ create = false ) { if ( ! is_dir ( $ directory ) ) { if ( ! $ create ) { throw new \ RuntimeException ( sprintf ( 'The directory "%s" does not exist.' , $ directory ) ) ; } $ this -> createDirectory ( $ directory ) ; } } | Ensures the specified directory exists creates it if it does not . |
36,441 | protected function createDirectory ( $ directory ) { if ( ! @ mkdir ( $ directory , $ this -> mode , true ) && ! is_dir ( $ directory ) ) { throw new \ RuntimeException ( sprintf ( 'The directory \'%s\' could not be created.' , $ directory ) ) ; } } | Creates the specified directory and its parents . |
36,442 | public function deleteContainer ( $ containerName , DeleteContainerOptions $ options = null ) { $ this -> init ( ) ; try { $ this -> blobProxy -> deleteContainer ( $ containerName , $ options ) ; } catch ( ServiceException $ e ) { $ errorCode = $ this -> getErrorCodeFromServiceException ( $ e ) ; if ( $ errorCode !== s... | Deletes a container . |
36,443 | protected function failIfContainerNotFound ( ServiceException $ exception , $ action , $ containerName ) { $ errorCode = $ this -> getErrorCodeFromServiceException ( $ exception ) ; if ( $ errorCode === self :: ERROR_CONTAINER_NOT_FOUND ) { throw new \ RuntimeException ( sprintf ( 'Failed to %s: container "%s" not foun... | Throws a runtime exception if a give ServiceException derived from a container not found error . |
36,444 | protected function getErrorCodeFromServiceException ( ServiceException $ exception ) { $ xml = @ simplexml_load_string ( $ exception -> getResponse ( ) -> getBody ( ) ) ; if ( $ xml && isset ( $ xml -> Code ) ) { return ( string ) $ xml -> Code ; } return $ exception -> getErrorText ( ) ; } | Extracts the error code from a service exception . |
36,445 | protected function ensureBucketExists ( ) { if ( $ this -> bucketExists ) { return ; } try { $ this -> service -> buckets -> get ( $ this -> bucket ) ; $ this -> bucketExists = true ; return ; } catch ( \ Google_Service_Exception $ e ) { $ this -> bucketExists = false ; throw new \ RuntimeException ( sprintf ( 'The con... | Ensures the specified bucket exists . |
36,446 | public function setFiles ( array $ files ) { $ this -> files = array ( ) ; foreach ( $ files as $ key => $ file ) { if ( ! is_array ( $ file ) ) { $ file = array ( 'content' => $ file ) ; } $ file = array_merge ( array ( 'content' => null , 'mtime' => null , ) , $ file ) ; $ this -> setFile ( $ key , $ file [ 'content'... | Defines the files . |
36,447 | public function setFile ( $ key , $ content = null , $ mtime = null ) { if ( null === $ mtime ) { $ mtime = time ( ) ; } $ this -> files [ $ key ] = array ( 'content' => ( string ) $ content , 'mtime' => ( integer ) $ mtime , ) ; } | Defines a file . |
36,448 | private function ensureBucketExists ( ) { if ( $ this -> ensureBucket ) { return ; } if ( isset ( $ this -> options [ 'region' ] ) ) { $ this -> service -> set_region ( $ this -> options [ 'region' ] ) ; } if ( $ this -> service -> if_bucket_exists ( $ this -> bucket ) ) { $ this -> ensureBucket = true ; return ; } if ... | Ensures the specified bucket exists . If the bucket does not exists and the create parameter is set to true it will try to create the bucket . |
36,449 | private function computePath ( $ key ) { $ directory = $ this -> getDirectory ( ) ; if ( null === $ directory || '' === $ directory ) { return $ key ; } return sprintf ( '%s/%s' , $ directory , $ key ) ; } | Computes the path for the specified key taking the bucket in account . |
36,450 | public function getUrl ( $ key , array $ options = [ ] ) { @ trigger_error ( E_USER_DEPRECATED , 'Using AwsS3::getUrl() method was deprecated since v0.4. Please chek gaufrette/extras package if you want this feature' ) ; return $ this -> service -> getObjectUrl ( $ this -> bucket , $ this -> computePath ( $ key ) , iss... | Gets the publicly accessible URL of an Amazon S3 object . |
36,451 | protected function ensureBucketExists ( ) { if ( $ this -> bucketExists ) { return true ; } if ( $ this -> bucketExists = $ this -> service -> doesBucketExist ( $ this -> bucket ) ) { return true ; } if ( ! $ this -> options [ 'create' ] ) { throw new \ RuntimeException ( sprintf ( 'The configured bucket "%s" does not ... | Ensures the specified bucket exists . If the bucket does not exists and the create option is set to true it will try to create the bucket . The bucket is created using the same region as the supplied client object . |
36,452 | public function set ( $ domain , FilesystemInterface $ filesystem ) { if ( ! preg_match ( '/^[-_a-zA-Z0-9]+$/' , $ domain ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The specified domain "%s" is not a valid domain.' , $ domain ) ) ; } $ this -> filesystems [ $ domain ] = $ filesystem ; } | Register the given filesystem for the specified domain . |
36,453 | public function get ( $ domain ) { if ( ! $ this -> has ( $ domain ) ) { throw new \ InvalidArgumentException ( sprintf ( 'There is no filesystem defined for the "%s" domain.' , $ domain ) ) ; } return $ this -> filesystems [ $ domain ] ; } | Returns the filesystem registered for the specified domain . |
36,454 | public function remove ( $ domain ) { if ( ! $ this -> has ( $ domain ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cannot remove the "%s" filesystem as it is not defined.' , $ domain ) ) ; } unset ( $ this -> filesystems [ $ domain ] ) ; } | Removes the filesystem registered for the specified domain . |
36,455 | public function getDomains ( ) { $ res = $ this -> doRequest ( 'GET_DOMAINS' ) ; if ( ! $ res ) { return false ; } $ domains = array ( ) ; for ( $ i = 1 ; $ i <= $ res [ 'domains' ] ; ++ $ i ) { $ dom = 'domain' . $ i ; $ classes = array ( ) ; for ( $ j = 1 ; $ j <= $ res [ $ dom . 'classes' ] ; ++ $ j ) { $ classes [ ... | Get available domains and classes from tracker . |
36,456 | private function connect ( ) { if ( $ this -> socket ) { return $ this -> socket ; } shuffle ( $ this -> hosts ) ; foreach ( $ this -> hosts as $ host ) { list ( $ ip , $ port ) = explode ( ':' , $ host ) ; $ this -> socket = @ fsockopen ( $ ip , $ port , $ err_no , $ err_str , 1 ) ; if ( $ this -> socket ) { break ; }... | Tries to connect MogileFS tracker . |
36,457 | private function doRequest ( $ cmd , $ args = array ( ) ) { clearstatcache ( ) ; $ args [ 'domain' ] = $ this -> domain ; $ params = http_build_query ( $ args ) ; $ this -> connect ( ) ; fwrite ( $ this -> socket , "{$cmd} {$params}\n" ) ; $ line = fgets ( $ this -> socket ) ; $ words = explode ( ' ' , $ line ) ; if ( ... | Makes request to MogileFS tracker . |
36,458 | private function putFile ( $ path , $ data ) { $ info = false ; $ url = parse_url ( $ path ) ; $ fp = fsockopen ( $ url [ 'host' ] , $ url [ 'port' ] , $ errno , $ errstr , 5 ) ; if ( ! $ fp ) { return false ; } $ buffer = '' ; $ b = "\r\n" ; stream_set_blocking ( $ fp , true ) ; stream_set_timeout ( $ fp , 30 , 200000... | Sends file to MogileFS tracker . |
36,459 | protected function getContainer ( ) { if ( ! $ this -> objectStore ) { $ this -> objectStore = $ this -> objectStoreFactory -> getObjectStore ( ) ; } return parent :: getContainer ( ) ; } | Override parent to lazy - load object store . |
36,460 | protected function initialize ( ) { if ( $ this -> initialized ) { return ; } $ this -> ensureDirectoryExists ( $ this -> directory , $ this -> create ) ; $ this -> initialized = true ; } | Performs the adapter s initialization . |
36,461 | protected function ensureDirectoryExists ( $ directory , $ create = false ) { $ url = $ this -> sftp -> getUrl ( $ directory ) ; $ resource = @ opendir ( $ url ) ; if ( false === $ resource && ( ! $ create || ! $ this -> createDirectory ( $ directory ) ) ) { throw new \ RuntimeException ( sprintf ( 'The directory \'%s\... | Ensures the specified directory exists . |
36,462 | public function setContent ( $ content , $ metadata = array ( ) ) { $ this -> content = $ content ; $ this -> setMetadata ( $ metadata ) ; return $ this -> size = $ this -> filesystem -> write ( $ this -> key , $ this -> content , true ) ; } | Sets the content . |
36,463 | public function delete ( $ metadata = array ( ) ) { $ this -> setMetadata ( $ metadata ) ; return $ this -> filesystem -> delete ( $ this -> key ) ; } | Deletes the file from the filesystem . |
36,464 | public function rename ( $ newKey ) { $ this -> filesystem -> rename ( $ this -> key , $ newKey ) ; $ this -> key = $ newKey ; } | Rename the file and move it to its new location . |
36,465 | protected function setMetadata ( array $ metadata ) { if ( $ metadata && $ this -> supportsMetadata ( ) ) { $ this -> filesystem -> getAdapter ( ) -> setMetadata ( $ this -> key , $ metadata ) ; return true ; } return false ; } | Sets the metadata array to be stored in adapters that can support it . |
36,466 | public static function register ( $ scheme = 'gaufrette' ) { static :: streamWrapperUnregister ( $ scheme ) ; if ( ! static :: streamWrapperRegister ( $ scheme , __CLASS__ ) ) { throw new \ RuntimeException ( sprintf ( 'Could not register stream wrapper class %s for scheme %s.' , __CLASS__ , $ scheme ) ) ; } } | Registers the stream wrapper to handle the specified scheme . |
36,467 | public function listDirectory ( $ directory = '' ) { $ this -> ensureDirectoryExists ( $ this -> directory , $ this -> create ) ; $ directory = preg_replace ( '/^[\/]*([^\/].*)$/' , '/$1' , $ directory ) ; $ items = $ this -> parseRawlist ( ftp_rawlist ( $ this -> getConnection ( ) , '-al ' . $ this -> directory . $ di... | Lists files from the specified directory . If a pattern is specified it only returns files matching it . |
36,468 | protected function createDirectory ( $ directory ) { $ parent = \ Gaufrette \ Util \ Path :: dirname ( $ directory ) ; if ( ! $ this -> isDir ( $ parent ) ) { $ this -> createDirectory ( $ parent ) ; } $ created = ftp_mkdir ( $ this -> getConnection ( ) , $ directory ) ; if ( false === $ created ) { throw new \ Runtime... | Creates the specified directory and its parent directories . |
36,469 | private function parseRawlist ( array $ rawlist ) { $ parsed = array ( ) ; foreach ( $ rawlist as $ line ) { $ infos = preg_split ( "/[\s]+/" , $ line , 9 ) ; if ( $ this -> isLinuxListing ( $ infos ) ) { $ infos [ 7 ] = ( strrpos ( $ infos [ 7 ] , ':' ) != 2 ) ? ( $ infos [ 7 ] . ' 00:00' ) : ( date ( 'Y' ) . ' ' . $ ... | Parses the given raw list . |
36,470 | private function connect ( ) { if ( $ this -> ssl && ! function_exists ( 'ftp_ssl_connect' ) ) { throw new \ RuntimeException ( 'This Server Has No SSL-FTP Available.' ) ; } if ( ! $ this -> ssl ) { $ this -> connection = ftp_connect ( $ this -> host , $ this -> port , $ this -> timeout ) ; } else { $ this -> connectio... | Opens the adapter s ftp connection . |
36,471 | protected function getContainer ( ) { if ( $ this -> container ) { return $ this -> container ; } try { return $ this -> container = $ this -> objectStore -> getContainer ( $ this -> containerName ) ; } catch ( BadResponseException $ e ) { if ( ! $ this -> createContainer ) { throw new \ RuntimeException ( sprintf ( 'C... | Returns an initialized container . |
36,472 | public function write ( $ key , $ content ) { try { $ this -> getContainer ( ) -> uploadObject ( $ key , $ content ) ; } catch ( CreateUpdateError $ updateError ) { return false ; } return Util \ Size :: fromContent ( $ content ) ; } | Writes the given content into the file . |
36,473 | public function exists ( $ key ) { try { $ exists = $ this -> getContainer ( ) -> getPartialObject ( $ key ) !== false ; } catch ( BadResponseException $ objFetchError ) { return false ; } return $ exists ; } | Indicates whether the file exists . |
36,474 | public function mtime ( $ key ) { if ( $ object = $ this -> tryGetObject ( $ key ) ) { return ( new \ DateTime ( $ object -> getLastModified ( ) ) ) -> format ( 'U' ) ; } return false ; } | Returns the last modified time . |
36,475 | private function publishAllVendors ( ) { $ this -> call ( 'vendor:publish' , [ '--provider' => 'Spatie\\Permission\\PermissionServiceProvider' , '--tag' => 'migrations' ] ) ; $ this -> call ( 'vendor:publish' , [ '--provider' => 'Spatie\\Permission\\PermissionServiceProvider' , '--tag' => 'config' ] ) ; $ this -> call ... | Publishing all publishable files from all craftable packages |
36,476 | private function generatePasswordAndUpdateMigration ( ) { $ this -> password = str_random ( 10 ) ; $ files = File :: allFiles ( database_path ( 'migrations' ) ) ; foreach ( $ files as $ file ) { if ( strpos ( $ file -> getFilename ( ) , 'fill_default_admin_user_and_permissions.php' ) !== false ) { $ this -> strReplaceI... | Generate new password and change default password in igration to use new password |
36,477 | private function generateUserStuff ( Filesystem $ files ) { $ this -> call ( 'migrate' ) ; $ this -> call ( 'admin:generate:admin-user' , [ '--force' => true , ] ) ; $ this -> call ( 'admin:generate:admin-user:profile' ) ; } | Generate user administration and profile |
36,478 | private function scanAndSaveTranslations ( ) { $ this -> info ( 'Scanning codebase and storing all translations' ) ; $ this -> strReplaceInFile ( config_path ( 'admin-translations.php' ) , '// here you can add your own directories' , '// here you can add your own directories // base_path(\'routes\'), // uncommen... | Prepare translations config and rescan |
36,479 | private function isTimestampable ( ClassMetadata $ classMetadata ) { return $ this -> getClassAnalyzer ( ) -> hasTrait ( $ classMetadata -> reflClass , $ this -> timestampableTrait , $ this -> isRecursive ) ; } | Checks if entity is timestampable |
36,480 | public function getSql ( SqlWalker $ sqlWalker ) { $ entityLocation = $ this -> entityLocation -> dispatch ( $ sqlWalker ) ; return sprintf ( 'earth_distance(ll_to_earth(%s[0], %s[1]),ll_to_earth(%s, %s))' , $ entityLocation , $ entityLocation , $ this -> latitude -> dispatch ( $ sqlWalker ) , $ this -> longitude -> di... | Returns SQL representation of this function . |
36,481 | public function parse ( Parser $ parser ) { $ parser -> match ( Lexer :: T_IDENTIFIER ) ; $ parser -> match ( Lexer :: T_OPEN_PARENTHESIS ) ; $ this -> entityLocation = $ parser -> ArithmeticPrimary ( ) ; $ parser -> match ( Lexer :: T_COMMA ) ; $ this -> latitude = $ parser -> ArithmeticPrimary ( ) ; $ parser -> match... | Parses DQL function . |
36,482 | public function loadClassMetadata ( LoadClassMetadataEventArgs $ eventArgs ) { $ classMetadata = $ eventArgs -> getClassMetadata ( ) ; if ( null === $ classMetadata -> reflClass ) { return ; } if ( $ this -> isGeocodable ( $ classMetadata ) ) { if ( ! Type :: hasType ( 'point' ) ) { Type :: addType ( 'point' , 'Knp\Doc... | Adds doctrine point type |
36,483 | private function isGeocodable ( ClassMetadata $ classMetadata ) { return $ this -> getClassAnalyzer ( ) -> hasTrait ( $ classMetadata -> reflClass , $ this -> geocodableTrait , $ this -> isRecursive ) ; } | Checks if entity is geocodable |
36,484 | public function willBeDeleted ( \ DateTime $ at = null ) { if ( $ this -> deletedAt === null ) { return false ; } if ( $ at === null ) { return true ; } return $ this -> deletedAt <= $ at ; } | Checks whether the entity will be deleted . |
36,485 | private function currentDateTime ( ) { $ dateTime = \ DateTime :: createFromFormat ( 'U.u' , sprintf ( '%.6F' , microtime ( true ) ) ) ; $ dateTime -> setTimezone ( new \ DateTimeZone ( date_default_timezone_get ( ) ) ) ; return $ dateTime ; } | Get a instance of \ DateTime with the current data time including milliseconds . |
36,486 | public function setSort ( $ sort ) { $ this -> reordered = $ this -> sort !== $ sort ; $ this -> sort = $ sort ; return $ this ; } | Set sort . |
36,487 | public function updateTimestamps ( ) { $ dateTime = \ DateTime :: createFromFormat ( 'U.u' , sprintf ( '%.6F' , microtime ( true ) ) ) ; $ dateTime -> setTimezone ( new \ DateTimeZone ( date_default_timezone_get ( ) ) ) ; if ( null === $ this -> createdAt ) { $ this -> createdAt = $ dateTime ; } $ this -> updatedAt = $... | Updates createdAt and updatedAt timestamps . |
36,488 | private function isSluggable ( ClassMetadata $ classMetadata ) { return $ this -> getClassAnalyzer ( ) -> hasTrait ( $ classMetadata -> reflClass , $ this -> sluggableTrait , $ this -> isRecursive ) ; } | Checks if entity is sluggable |
36,489 | public function getTree ( $ path = '' , $ rootAlias = 't' , $ extraParams = array ( ) ) { $ results = $ this -> getFlatTree ( $ path , $ rootAlias , $ extraParams ) ; return $ this -> buildTree ( $ results ) ; } | Returns a node hydrated with its children and parents |
36,490 | public function buildTree ( $ results ) { if ( ! count ( $ results ) ) { return ; } $ root = $ results [ 0 ] ; $ root -> buildTree ( $ results ) ; return $ root ; } | Extracts the root node and constructs a tree using flat resultset |
36,491 | public function getFlatTreeQB ( $ path = '' , $ rootAlias = 't' , $ extraParams = array ( ) ) { $ qb = $ this -> createQueryBuilder ( $ rootAlias ) -> andWhere ( $ rootAlias . '.materializedPath LIKE :path' ) -> addOrderBy ( $ rootAlias . '.materializedPath' , 'ASC' ) -> setParameter ( 'path' , $ path . '%' ) ; $ paren... | Constructs a query builder to get a flat tree starting from a given path |
36,492 | public function getFlatTree ( $ path , $ rootAlias = 't' , $ extraParams = array ( ) ) { return $ this -> getFlatTreeQB ( $ path , $ rootAlias , $ extraParams ) -> getQuery ( ) -> execute ( ) ; } | Executes the flat tree query builder |
36,493 | public function addTranslation ( $ translation ) { $ this -> getTranslations ( ) -> set ( ( string ) $ translation -> getLocale ( ) , $ translation ) ; $ translation -> setTranslatable ( $ this ) ; return $ this ; } | Adds new translation . |
36,494 | public function mergeNewTranslations ( ) { foreach ( $ this -> getNewTranslations ( ) as $ newTranslation ) { if ( ! $ this -> getTranslations ( ) -> contains ( $ newTranslation ) && ! $ newTranslation -> isEmpty ( ) ) { $ this -> addTranslation ( $ newTranslation ) ; $ this -> getNewTranslations ( ) -> removeElement (... | Merges newly created translations into persisted translations . |
36,495 | protected function proxyCurrentLocaleTranslation ( $ method , array $ arguments = [ ] ) { return call_user_func_array ( [ $ this -> translate ( $ this -> getCurrentLocale ( ) ) , $ method ] , $ arguments ) ; } | An extra feature allows you to proxy translated fields of a translatable entity . |
36,496 | protected function findTranslationByLocale ( $ locale , $ withNewTranslations = true ) { $ translation = $ this -> getTranslations ( ) -> get ( $ locale ) ; if ( $ translation ) { return $ translation ; } if ( $ withNewTranslations ) { return $ this -> getNewTranslations ( ) -> get ( $ locale ) ; } } | Finds specific translation in collection by its locale . |
36,497 | public function onFlush ( OnFlushEventArgs $ args ) { $ em = $ args -> getEntityManager ( ) ; $ uow = $ em -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityDeletions ( ) as $ entity ) { $ classMetadata = $ em -> getClassMetadata ( get_class ( $ entity ) ) ; if ( $ this -> isSoftDeletable ( $ classMetadata ) ... | Listens to onFlush event . |
36,498 | private function isSoftDeletable ( ClassMetadata $ classMetadata ) { return $ this -> getClassAnalyzer ( ) -> hasTrait ( $ classMetadata -> reflClass , $ this -> softDeletableTrait , $ this -> isRecursive ) ; } | Checks if entity is softDeletable |
36,499 | public function convertToPHPValue ( $ value , AbstractPlatform $ platform ) { if ( ! $ value ) { return null ; } if ( $ platform instanceof MySqlPlatform ) { $ data = sscanf ( $ value , 'POINT(%f %f)' ) ; } else { $ data = sscanf ( $ value , "(%f,%f)" ) ; } return new Point ( $ data [ 0 ] , $ data [ 1 ] ) ; } | Converts SQL value to the PHP representation . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.