idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
44,100 | public function getFieldType ( AttributeInterface $ attribute ) { $ type = FieldInterface :: FIELD_TYPE_TEXT ; if ( $ attribute -> getSourceModel ( ) == 'Magento\Eav\Model\Entity\Attribute\Source\Boolean' ) { $ type = FieldInterface :: FIELD_TYPE_BOOLEAN ; } elseif ( $ attribute -> getBackendType ( ) == 'int' ) { $ typ... | Get mapping field type for an attribute . |
44,101 | public function getIndexOptionsText ( AttributeInterface $ attribute , $ storeId , array $ optionIds ) { $ mapperKey = sprintf ( "options_%s_%s" , $ attribute -> getId ( ) , $ storeId ) ; if ( ! isset ( $ this -> attributeMappers [ $ mapperKey ] ) ) { $ this -> attributeMappers [ $ mapperKey ] = function ( $ optionId )... | Transform an array of options ids into an arrays of option values for attribute that uses a source . Values are localized for a store id . |
44,102 | public function getIndexOptionText ( AttributeInterface $ attribute , $ storeId , $ optionId ) { $ attribute = $ this -> getAttributeByStore ( $ attribute , $ storeId ) ; $ attributeId = $ attribute -> getAttributeId ( ) ; if ( ! isset ( $ this -> attributeOptionTextCache [ $ storeId ] ) || ! isset ( $ this -> attribut... | Transform an options id into an array of option value for attribute that uses a source . Value islocalized for a store id . |
44,103 | public function getFilterField ( AttributeInterface $ attribute ) { $ field = $ attribute -> getAttributeCode ( ) ; if ( $ attribute -> usesSource ( ) ) { $ field = $ this -> getOptionTextFieldName ( $ field ) ; } return $ field ; } | Returns field use for filtering for an attribute . |
44,104 | private function prepareSimpleIndexAttributeValue ( AttributeInterface $ attribute , $ value ) { if ( $ this -> getFieldType ( $ attribute ) == FieldInterface :: FIELD_TYPE_BOOLEAN ) { $ value = boolval ( $ value ) ; } elseif ( $ attribute -> getBackendType ( ) == 'decimal' ) { $ value = floatval ( $ value ) ; } elseif... | Ensure types of numerical values is correct before indexing . |
44,105 | private function getAttributeByStore ( $ attribute , $ storeId ) { $ attributeId = $ this -> getAttributeId ( $ attribute ) ; if ( ! isset ( $ this -> storeAttributes [ $ storeId ] ) || ! isset ( $ this -> storeAttributes [ $ storeId ] [ $ attributeId ] ) ) { $ storeAttribute = $ this -> attributeFactory -> create ( ) ... | Load the localized version of an attribute . This code uses a local cache to ensure correct performance during indexing . |
44,106 | private function getAttributeId ( $ attribute ) { $ attributeId = $ attribute ; if ( is_object ( $ attribute ) ) { $ attributeId = $ attribute -> getAttributeId ( ) ; } return $ attributeId ; } | This util method is used to ensure the attribute is an integer and uses it s id if it is an object . |
44,107 | private function getAggregationsConfig ( $ attributes ) { $ aggregations = [ ] ; foreach ( $ attributes as $ attribute ) { $ bucketConfig = $ this -> getBucketConfig ( $ attribute ) ; $ aggregations [ $ bucketConfig [ 'name' ] ] = $ bucketConfig ; } return $ aggregations ; } | Get aggregations config . |
44,108 | protected function convertNode ( \ DOMNode $ node , $ path = '' ) { $ output = [ ] ; if ( $ node -> nodeType == XML_ELEMENT_NODE ) { $ nodeName = $ this -> parseNodeName ( $ node ) ; $ output [ $ nodeName ] = $ this -> parseNodeData ( $ node , $ path ) ; } elseif ( $ node -> nodeType == XML_CDATA_SECTION_NODE || $ node... | Convert node oto array |
44,109 | protected function parseNodeName ( $ node ) { $ nodeName = $ node -> nodeName ; if ( $ node -> hasAttributes ( ) ) { $ storeCodeNode = $ node -> attributes -> getNamedItem ( 'store_code' ) ; $ containerNameNode = $ node -> attributes -> getNamedItem ( 'name' ) ; if ( $ containerNameNode ) { $ nodeName = $ containerName... | Retrieve proper node name |
44,110 | private function parseNodeData ( \ DOMNode $ node , $ path ) { $ nodeData = [ ] ; foreach ( $ node -> childNodes as $ childNode ) { $ childrenData = $ this -> convertNode ( $ childNode , ( $ path ? $ path . '/' : '' ) . $ childNode -> nodeName ) ; if ( $ childrenData === null ) { continue ; } $ nodeData = $ this -> mer... | Convert node onto array |
44,111 | private function mergeChildData ( $ nodeData , $ childrenData ) { if ( is_array ( $ childrenData ) ) { $ nodeData = array_merge ( $ nodeData , $ childrenData ) ; return $ nodeData ; } $ nodeData = $ childrenData ; return $ nodeData ; } | Merge child node data into current node |
44,112 | private function getValues ( \ Smile \ ElasticsuiteCore \ Search \ Adapter \ Elasticsuite \ Response \ QueryResponse $ response ) { $ bucket = $ response -> getAggregations ( ) -> getBucket ( 'search_terms' ) ; return $ bucket !== null ? $ bucket -> getValues ( ) : [ ] ; } | Return the bucket values from the main aggregation |
44,113 | public function addStoreFilter ( $ storeIds ) { $ defaultStoreId = Store :: DEFAULT_STORE_ID ; if ( ! is_array ( $ storeIds ) ) { $ storeIds = [ $ storeIds ] ; } if ( ! in_array ( $ defaultStoreId , $ storeIds ) ) { $ storeIds [ ] = $ defaultStoreId ; } $ this -> getSelect ( ) -> join ( [ 'store_table' => $ this -> get... | Filter collection by specified store ids |
44,114 | private function addTermFilterToSelect ( $ term ) { $ select = $ this -> getSelect ( ) ; if ( $ this -> termsLinked === false ) { $ select -> joinLeft ( [ 'expansion_table' => $ this -> getTable ( ThesaurusInterface :: EXPANSION_TABLE_NAME ) ] , new \ Zend_Db_Expr ( "main_table.thesaurus_id = expansion_table.thesaurus_... | Inject terms data on collection |
44,115 | private function addTermData ( $ termData ) { $ labelsByThesaurusId = [ ] ; foreach ( $ termData as $ currentTerm ) { $ label = $ currentTerm [ 'expansions_terms' ] ; if ( isset ( $ currentTerm [ 'expanded_term' ] ) && $ currentTerm [ 'expanded_term' ] ) { $ label = sprintf ( "%s => %s" , $ currentTerm [ 'expanded_term... | Process terms of each thesaurus and display a summary for each thesaurus . |
44,116 | public function getById ( $ thesaurusId ) { if ( ! isset ( $ this -> thesaurusRepositoryById [ $ thesaurusId ] ) ) { $ thesaurus = $ this -> thesaurusFactory -> create ( ) -> load ( $ thesaurusId ) ; if ( ! $ thesaurus -> getThesaurusId ( ) ) { throw NoSuchEntityException :: singleField ( 'thesaurusId' , $ thesaurusId ... | Retrieve a thesaurus by its ID |
44,117 | public function save ( \ Smile \ ElasticsuiteThesaurus \ Api \ Data \ ThesaurusInterface $ thesaurus ) { $ this -> validate ( $ thesaurus ) ; $ thesaurus -> save ( ) ; $ this -> thesaurusRepositoryById [ $ thesaurus -> getThesaurusId ( ) ] = $ thesaurus ; return $ thesaurus ; } | Save a thesaurus |
44,118 | public function delete ( \ Smile \ ElasticsuiteThesaurus \ Api \ Data \ ThesaurusInterface $ thesaurus ) { $ thesaurusId = $ thesaurus -> getThesaurusId ( ) ; $ thesaurus -> delete ( ) ; if ( isset ( $ this -> thesaurusRepositoryById [ $ thesaurusId ] ) ) { unset ( $ this -> thesaurusRepositoryById [ $ thesaurusId ] ) ... | Delete a thesaurus |
44,119 | protected function validate ( \ Smile \ ElasticsuiteThesaurus \ Api \ Data \ ThesaurusInterface $ thesaurus ) { $ exception = new \ Magento \ Framework \ Exception \ InputException ( ) ; $ validator = new \ Zend_Validate ( ) ; if ( ! $ validator -> is ( trim ( $ thesaurus -> getName ( ) ) , 'NotEmpty' ) ) { $ exception... | Validate thesaurus values |
44,120 | public function loadInventoryData ( $ storeId , $ productIds ) { $ websiteId = $ this -> getWebsiteId ( $ storeId ) ; $ stockId = $ this -> getStockId ( $ websiteId ) ; $ select = $ this -> getConnection ( ) -> select ( ) -> from ( [ 'ciss' => $ this -> getTable ( 'cataloginventory_stock_status' ) ] , [ 'product_id' , ... | Load inventory data for a list of product ids and a given store . |
44,121 | private function getStockId ( $ websiteId ) { if ( ! isset ( $ this -> stockIdByWebsite [ $ websiteId ] ) ) { $ stockId = $ this -> stockRegistry -> getStock ( $ websiteId ) -> getStockId ( ) ; $ this -> stockIdByWebsite [ $ websiteId ] = $ stockId ; } return $ this -> stockIdByWebsite [ $ websiteId ] ; } | Retrieve stock_id by store |
44,122 | public function rebuildStoreIndex ( $ storeId , $ productIds = null ) { $ productId = 0 ; if ( ! empty ( $ productIds ) ) { $ productIds = array_unique ( array_merge ( $ productIds , $ this -> resourceModel -> getRelationsByChild ( $ productIds ) ) ) ; } do { $ products = $ this -> getSearchableProducts ( $ storeId , $... | Get data for a list of product in a store id . If the product list ids is null all products data will be loaded . |
44,123 | public function getSortOrders ( ContainerConfigurationInterface $ containerConfiguration , SearchCriteriaInterface $ searchCriteria ) { $ sortOrders = [ ] ; foreach ( $ searchCriteria -> getSortOrders ( ) ?? [ ] as $ sortOrder ) { $ sortOrders [ $ sortOrder -> getField ( ) ] = [ 'direction' => $ sortOrder -> getDirecti... | Extract sort orders from the search criteria . |
44,124 | public function getFilters ( ContainerConfigurationInterface $ containerConfiguration , SearchCriteriaInterface $ searchCriteria ) { $ filters = [ ] ; foreach ( $ searchCriteria -> getFilterGroups ( ) ?? [ ] as $ filterGroup ) { foreach ( $ filterGroup -> getFilters ( ) ?? [ ] as $ filter ) { if ( $ filter -> getField ... | Extract filters from the search criteria . |
44,125 | protected function getFilterField ( \ Magento \ Catalog \ Model \ ResourceModel \ Eav \ Attribute $ attribute ) { return $ this -> mappingHelper -> getFilterField ( $ attribute ) ; } | Retrieve ES filter field . |
44,126 | public static function File ( $ filename , $ mimetype = '' , $ postname = '' ) { if ( class_exists ( 'CURLFile' ) ) { return new \ CURLFile ( $ filename , $ mimetype , $ postname ) ; } if ( function_exists ( 'curl_file_create' ) ) { return curl_file_create ( $ filename , $ mimetype , $ postname ) ; } return sprintf ( '... | Prepares a file for upload . To be used inside the parameters declaration for a request . |
44,127 | public function slugify ( $ string , $ options = null ) { if ( is_string ( $ options ) ) { $ separator = $ options ; $ options = [ ] ; $ options [ 'separator' ] = $ separator ; } $ options = array_merge ( $ this -> options , ( array ) $ options ) ; if ( isset ( $ options [ 'ruleset' ] ) ) { $ rules = array_merge ( $ th... | Returns the slug - version of the string . |
44,128 | public function addRules ( array $ rules ) { foreach ( $ rules as $ character => $ replacement ) { $ this -> addRule ( $ character , $ replacement ) ; } return $ this ; } | Adds multiple rules to Slugify . |
44,129 | public function registerSearchableMacros ( ) { $ self = $ this ; BaseCollection :: macro ( 'searchable' , function ( ) use ( $ self ) { $ self -> queueMakeSearchable ( $ this ) ; } ) ; BaseCollection :: macro ( 'unsearchable' , function ( ) use ( $ self ) { $ self -> queueRemoveFromSearch ( $ this ) ; } ) ; } | Register the searchable macros . |
44,130 | public function queueMakeSearchable ( $ models ) { if ( $ models -> isEmpty ( ) ) { return ; } if ( ! config ( 'scout.queue' ) ) { return $ models -> first ( ) -> searchableUsing ( ) -> update ( $ models ) ; } dispatch ( ( new MakeSearchable ( $ models ) ) -> onQueue ( $ models -> first ( ) -> syncWithSearchUsingQueue ... | Dispatch the job to make the given models searchable . |
44,131 | public static function search ( $ query = '' , $ callback = null ) { return app ( Builder :: class , [ 'model' => new static , 'query' => $ query , 'callback' => $ callback , 'softDelete' => static :: usesSoftDelete ( ) && config ( 'scout.soft_delete' , false ) , ] ) ; } | Perform a search against the model s indexed data . |
44,132 | public static function makeAllSearchable ( ) { $ self = new static ; $ softDelete = static :: usesSoftDelete ( ) && config ( 'scout.soft_delete' , false ) ; $ self -> newQuery ( ) -> when ( $ softDelete , function ( $ query ) { $ query -> withTrashed ( ) ; } ) -> orderBy ( $ self -> getKeyName ( ) ) -> searchable ( ) ;... | Make all instances of the model searchable . |
44,133 | public function getScoutModelsByIds ( Builder $ builder , array $ ids ) { $ query = static :: usesSoftDelete ( ) ? $ this -> withTrashed ( ) : $ this -> newQuery ( ) ; if ( $ builder -> queryCallback ) { call_user_func ( $ builder -> queryCallback , $ query ) ; } return $ query -> whereIn ( $ this -> getScoutKeyName ( ... | Get the requested models from an array of object IDs . |
44,134 | public function saved ( $ model ) { if ( static :: syncingDisabledFor ( $ model ) ) { return ; } if ( ! $ model -> shouldBeSearchable ( ) ) { $ model -> unsearchable ( ) ; return ; } $ model -> searchable ( ) ; } | Handle the saved event for the model . |
44,135 | public function createAlgoliaDriver ( ) { $ this -> ensureAlgoliaClientIsInstalled ( ) ; UserAgent :: addCustomUserAgent ( 'Laravel Scout' , '7.0.0' ) ; return new AlgoliaEngine ( Algolia :: create ( config ( 'scout.algolia.id' ) , config ( 'scout.algolia.secret' ) ) , config ( 'scout.soft_delete' ) ) ; } | Create an Algolia engine instance . |
44,136 | public function paginateRaw ( $ perPage = null , $ pageName = 'page' , $ page = null ) { $ engine = $ this -> engine ( ) ; $ page = $ page ? : Paginator :: resolveCurrentPage ( $ pageName ) ; $ perPage = $ perPage ? : $ this -> model -> getPerPage ( ) ; $ results = $ engine -> paginate ( $ this , $ perPage , $ page ) ;... | Paginate the given query into a simple paginator with raw data . |
44,137 | public function get ( Builder $ builder ) { return $ this -> map ( $ builder , $ this -> search ( $ builder ) , $ builder -> model ) ; } | Get the results of the given query mapped onto models . |
44,138 | public function getSitemap ( string $ url ) { return collect ( $ this -> tags ) -> first ( function ( Tag $ tag ) use ( $ url ) { return $ tag -> getType ( ) === 'sitemap' && $ tag -> url === $ url ; } ) ; } | Get sitemap tag . |
44,139 | public function getCommand ( ) { $ path = $ this -> getPath ( ) ; $ options = $ this -> getOptions ( ) ; $ this -> validateExecutable ( $ path ) ; if ( $ this -> cache ) { array_push ( $ options , '--disk-cache=true' ) ; } if ( $ this -> debug ) { array_push ( $ options , '--debug=true' ) ; } return sprintf ( '%s %s' ,... | Get PhantomJs run command with loader run options . |
44,140 | private function validateExecutable ( $ file ) { if ( ! file_exists ( $ file ) || ! is_executable ( $ file ) ) { throw new InvalidExecutableException ( sprintf ( 'File does not exist or is not executable: %s' , $ file ) ) ; } return true ; } | Validate execuable file . |
44,141 | public function getUrl ( ) { if ( ! in_array ( $ this -> getMethod ( ) , array ( RequestInterface :: METHOD_GET , RequestInterface :: METHOD_HEAD ) ) ) { return $ this -> url ; } $ url = $ this -> url ; if ( count ( $ this -> data ) ) { $ url .= false === strpos ( $ url , '?' ) ? '?' : '&' ; $ url .= http_build_query (... | Get request URL - Assembles query string for GET and HEAD requests |
44,142 | public function getBody ( ) { if ( in_array ( $ this -> getMethod ( ) , array ( RequestInterface :: METHOD_GET , RequestInterface :: METHOD_HEAD ) ) ) { return '' ; } return http_build_query ( $ this -> getRequestData ( ) ) ; } | Get content body - Returns query string if not GET or HEAD |
44,143 | public function getRequestData ( $ flat = true ) { if ( $ flat ) { return $ this -> flattenData ( $ this -> data ) ; } return $ this -> data ; } | Get request data |
44,144 | public function addCookie ( $ name , $ value , $ path , $ domain , $ httpOnly = true , $ secure = false , $ expires = null ) { $ filter = function ( $ value ) { return ! is_null ( $ value ) ; } ; $ this -> cookies [ 'add' ] [ ] = array_filter ( array ( 'name' => $ name , 'value' => $ value , 'path' => $ path , 'domain'... | Add cookie . |
44,145 | protected function flattenData ( array $ data , $ prefix = '' , $ format = '%s' ) { $ flat = array ( ) ; foreach ( $ data as $ name => $ value ) { $ ref = $ prefix . sprintf ( $ format , $ name ) ; if ( is_array ( $ value ) ) { $ flat += $ this -> flattenData ( $ value , $ ref , '[%s]' ) ; continue ; } $ flat [ $ ref ]... | Flatten data into single dimensional array |
44,146 | public function createProcedureLoader ( $ directory ) { $ procedureFactory = $ this -> procedureFactory ; $ fileLocator = $ this -> createFileLocator ( $ directory ) ; $ procedureLoader = new ProcedureLoader ( $ procedureFactory , $ fileLocator ) ; return $ procedureLoader ; } | Create procedure loader instance . |
44,147 | protected function createFileLocator ( $ directory ) { if ( ! is_dir ( $ directory ) || ! is_readable ( $ directory ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Could not create procedure loader as directory does not exist or is not readable: "%s"' , $ directory ) ) ; } return new FileLocator ( $ directory )... | Create file locator instance . |
44,148 | public function compile ( ProcedureInterface $ procedure , InputInterface $ input ) { $ cacheKey = sprintf ( 'phantomjs_%s_%s' , $ input -> getType ( ) , md5 ( $ procedure -> getTemplate ( ) ) ) ; if ( $ this -> cacheEnabled && $ this -> cacheHandler -> exists ( $ cacheKey ) ) { $ template = $ this -> cacheHandler -> f... | Compile partials into procedure . |
44,149 | public function load ( ) { if ( ! $ this -> esprima ) { $ this -> esprima = $ this -> loadFile ( $ this -> locator -> locate ( $ this -> file ) ) ; } return $ this -> esprima ; } | Load esprima script . |
44,150 | public function import ( array $ data ) { foreach ( $ data as $ param => $ value ) { if ( $ param === 'headers' ) { continue ; } if ( property_exists ( $ this , $ param ) ) { $ this -> $ param = $ value ; } } $ this -> headers = array ( ) ; if ( isset ( $ data [ 'headers' ] ) ) { $ this -> setHeaders ( ( array ) $ data... | Import response data |
44,151 | protected function setHeaders ( array $ headers ) { foreach ( $ headers as $ header ) { if ( isset ( $ header [ 'name' ] ) && isset ( $ header [ 'value' ] ) ) { $ this -> headers [ $ header [ 'name' ] ] = $ header [ 'value' ] ; } } return $ this ; } | Set headers array |
44,152 | public function getHeader ( $ code ) { if ( isset ( $ this -> headers [ $ code ] ) ) { return $ this -> headers [ $ code ] ; } return null ; } | Get HTTP header value for code |
44,153 | public function run ( InputInterface $ input , OutputInterface $ output ) { try { $ executable = $ this -> write ( $ this -> compile ( $ input ) ) ; $ descriptorspec = array ( array ( 'pipe' , 'r' ) , array ( 'pipe' , 'w' ) , array ( 'pipe' , 'w' ) ) ; $ process = proc_open ( escapeshellcmd ( sprintf ( '%s %s' , $ this... | Run procedure . |
44,154 | public function parse ( $ data ) { if ( $ data === null || ! is_string ( $ data ) ) { return array ( ) ; } if ( substr ( $ data , 0 , 1 ) !== '{' && substr ( $ data , 0 , 1 ) !== '[' ) { return array ( ) ; } return ( array ) json_decode ( $ data , true ) ; } | Parse json string into array . |
44,155 | protected function validateSyntax ( $ procedure ) { $ input = new Input ( ) ; $ output = new Output ( ) ; $ input -> set ( 'procedure' , $ procedure ) ; $ input -> set ( 'engine' , $ this -> engine -> toString ( ) ) ; $ validator = $ this -> procedureLoader -> load ( 'validator' ) ; $ validator -> run ( $ input , $ out... | Validate syntax . |
44,156 | protected function loadFile ( $ file ) { if ( ! stream_is_local ( $ file ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Procedure file is not a local file: "%s"' , $ file ) ) ; } if ( ! file_exists ( $ file ) ) { throw new NotExistsException ( sprintf ( 'Procedure file does not exist: "%s"' , $ file ) ) ; } re... | Load procedure file content . |
44,157 | public function createProcedure ( ) { $ procedure = new Procedure ( $ this -> engine , $ this -> parser , $ this -> cacheHandler , $ this -> renderer ) ; return $ procedure ; } | Create new procedure instance . |
44,158 | public function createRequest ( $ url = null , $ method = RequestInterface :: METHOD_GET , $ timeout = 5000 ) { return new Request ( $ url , $ method , $ timeout ) ; } | Create request instance . |
44,159 | public function createCaptureRequest ( $ url = null , $ method = RequestInterface :: METHOD_GET , $ timeout = 5000 ) { return new CaptureRequest ( $ url , $ method , $ timeout ) ; } | Create capture request instance . |
44,160 | public function createPdfRequest ( $ url = null , $ method = RequestInterface :: METHOD_GET , $ timeout = 5000 ) { return new PdfRequest ( $ url , $ method , $ timeout ) ; } | Create PDF request instance . |
44,161 | public function save ( $ id , $ data ) { $ file = $ this -> getFilename ( $ id ) ; if ( ! $ this -> isWritable ( $ file ) ) { throw new NotWritableException ( sprintf ( 'File could not be written to system as target is not writable: %s' , $ file ) ) ; } if ( $ this -> writeData ( $ file , $ data ) === false ) { $ this ... | Write data to storage . |
44,162 | public function fetch ( $ id ) { $ file = $ this -> getFilename ( $ id ) ; if ( ! $ this -> exists ( $ id ) ) { throw new NotExistsException ( sprintf ( 'Could not fetch data from file as file does not exist: %s' , $ file ) ) ; } return $ this -> readData ( $ file ) ; } | Fetch data from file . |
44,163 | public function delete ( $ id ) { $ files = glob ( $ this -> getFilename ( $ id ) ) ; if ( count ( $ files ) ) { array_map ( 'unlink' , $ files ) ; } } | Delete data from storage . |
44,164 | protected function isWritable ( $ file ) { return ( bool ) ( ( file_exists ( $ file ) && is_writable ( $ file ) ) || ( ! file_exists ( $ file ) && is_writable ( dirname ( $ file ) ) ) ) ; } | Is data writeable . |
44,165 | public function setOutputFile ( $ file ) { if ( ! is_writable ( dirname ( $ file ) ) ) { throw new NotWritableException ( sprintf ( 'Output file is not writeable by PhantomJs: %s' , $ file ) ) ; } $ this -> outputFile = $ file ; return $ this ; } | Set file to save output . |
44,166 | public function chmod ( int $ permissions ) : vfsStreamContent { $ this -> permissions = $ permissions ; $ this -> lastAttributeModified = time ( ) ; clearstatcache ( ) ; return $ this ; } | change file mode to given permissions |
44,167 | public function isReadable ( int $ user , int $ group ) : bool { if ( $ this -> user === $ user ) { $ check = 0400 ; } elseif ( $ this -> group === $ group ) { $ check = 0040 ; } else { $ check = 0004 ; } return ( bool ) ( $ this -> permissions & $ check ) ; } | checks whether content is readable |
44,168 | public function isWritable ( int $ user , int $ group ) : bool { if ( $ this -> user === $ user ) { $ check = 0200 ; } elseif ( $ this -> group === $ group ) { $ check = 0020 ; } else { $ check = 0002 ; } return ( bool ) ( $ this -> permissions & $ check ) ; } | checks whether content is writable |
44,169 | public function isExecutable ( int $ user , int $ group ) : bool { if ( $ this -> user === $ user ) { $ check = 0100 ; } elseif ( $ this -> group === $ group ) { $ check = 0010 ; } else { $ check = 0001 ; } return ( bool ) ( $ this -> permissions & $ check ) ; } | checks whether content is executable |
44,170 | public function chown ( int $ user ) : vfsStreamContent { $ this -> user = $ user ; $ this -> lastAttributeModified = time ( ) ; return $ this ; } | change owner of file to given user |
44,171 | public function chgrp ( int $ group ) : vfsStreamContent { $ this -> group = $ group ; $ this -> lastAttributeModified = time ( ) ; return $ this ; } | change owner group of file to given group |
44,172 | public function path ( ) : string { if ( null === $ this -> parentPath ) { return $ this -> name ; } return $ this -> parentPath . '/' . $ this -> name ; } | returns path to this content |
44,173 | public function setParentPath ( string $ parentPath ) { parent :: setParentPath ( $ parentPath ) ; foreach ( $ this -> children as $ child ) { $ child -> setParentPath ( $ this -> path ( ) ) ; } } | sets parent path |
44,174 | protected function getRealChildName ( string $ name ) : string { if ( $ this -> appliesTo ( $ name ) === true ) { return self :: getChildName ( $ name , $ this -> name ) ; } return $ name ; } | helper method to detect the real child name |
44,175 | protected static function getChildName ( string $ name , string $ ownName ) : string { if ( $ name === $ ownName ) { return $ name ; } return substr ( $ name , strlen ( $ ownName ) + 1 ) ; } | helper method to calculate the child name |
44,176 | public function key ( ) { $ child = current ( $ this -> children ) ; if ( false === $ child ) { return null ; } return $ child -> getName ( ) ; } | returns the name of the current child |
44,177 | protected function doRead ( int $ offset , int $ count ) : string { $ data = substr ( $ this -> content , $ offset , $ count ) ; return ( false === $ data ) ? '' : $ data ; } | actual reading of length starting at given offset |
44,178 | public function withContent ( $ content ) : vfsStreamFile { if ( is_string ( $ content ) ) { $ this -> content = new StringBasedFileContent ( $ content ) ; } elseif ( $ content instanceof FileContent ) { $ this -> content = $ content ; } else { throw new \ InvalidArgumentException ( 'Given content must either be a stri... | sets the contents of the file |
44,179 | public function openWithTruncate ( ) { $ this -> open ( ) ; $ this -> content -> truncate ( 0 ) ; $ time = time ( ) ; $ this -> lastAccessed = $ time ; $ this -> lastModified = $ time ; } | open file and truncate content |
44,180 | public function unlock ( $ resource ) { if ( $ this -> hasExclusiveLock ( $ resource ) ) { $ this -> exclusiveLock = null ; } if ( $ this -> hasSharedLock ( $ resource ) ) { unset ( $ this -> sharedLock [ $ this -> getResourceId ( $ resource ) ] ) ; } } | Removes lock from file acquired by given resource |
44,181 | public function isLocked ( $ resource = null ) : bool { return $ this -> hasSharedLock ( $ resource ) || $ this -> hasExclusiveLock ( $ resource ) ; } | checks whether file is locked |
44,182 | public function hasSharedLock ( $ resource = null ) : bool { if ( null !== $ resource ) { return isset ( $ this -> sharedLock [ $ this -> getResourceId ( $ resource ) ] ) ; } return ! empty ( $ this -> sharedLock ) ; } | checks whether file is locked in shared mode |
44,183 | public function getResourceId ( $ resource ) : string { if ( is_resource ( $ resource ) ) { $ data = stream_get_meta_data ( $ resource ) ; $ resource = $ data [ 'wrapper_data' ] ; } return spl_object_hash ( $ resource ) ; } | Returns unique resource id |
44,184 | public function hasExclusiveLock ( $ resource = null ) : bool { if ( null !== $ resource ) { return $ this -> exclusiveLock === $ this -> getResourceId ( $ resource ) ; } return null !== $ this -> exclusiveLock ; } | checks whether file is locked in exclusive mode |
44,185 | public function spaceLeft ( int $ usedSpace ) : int { if ( self :: UNLIMITED === $ this -> amount ) { return $ usedSpace ; } if ( $ usedSpace >= $ this -> amount ) { return 0 ; } $ spaceLeft = $ this -> amount - $ usedSpace ; if ( 0 >= $ spaceLeft ) { return 0 ; } return $ spaceLeft ; } | checks if given used space exceeda quota limit |
44,186 | protected function doRead ( int $ offset , int $ count ) : string { if ( ( $ offset + $ count ) > $ this -> size ) { $ count = $ this -> size - $ offset ; } $ result = '' ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ result .= $ this -> content [ $ i + $ offset ] ?? ' ' ; } return $ result ; } | actual reading of given byte count starting at given offset |
44,187 | public static function url ( string $ path ) : string { return self :: SCHEME . '://' . join ( '/' , array_map ( 'rawurlencode' , explode ( '/' , str_replace ( '\\' , '/' , $ path ) ) ) ) ; } | prepends the scheme to the given URL |
44,188 | public static function path ( string $ url ) : string { $ path = trim ( $ url , " \t\r\n\0\x0B/\\" ) ; $ path = substr ( $ path , strlen ( self :: SCHEME . '://' ) ) ; $ path = str_replace ( '\\' , '/' , $ path ) ; $ path = str_replace ( '//' , '/' , $ path ) ; return rawurldecode ( $ path ) ; } | restores the path from the url |
44,189 | public static function umask ( int $ umask = null ) : int { $ oldUmask = self :: $ umask ; if ( null !== $ umask ) { self :: $ umask = $ umask ; } return $ oldUmask ; } | sets new umask setting and returns previous umask setting |
44,190 | public static function create ( array $ structure , vfsStreamDirectory $ baseDir = null ) : vfsStreamDirectory { if ( null === $ baseDir ) { $ baseDir = vfsStreamWrapper :: getRoot ( ) ; } if ( null === $ baseDir ) { throw new \ InvalidArgumentException ( 'No baseDir given and no root directory set.' ) ; } return self ... | creates vfsStream directory structure from an array and adds it to given base dir |
44,191 | public static function newFile ( string $ name , int $ permissions = null ) : vfsStreamFile { return new vfsStreamFile ( $ name , $ permissions ) ; } | returns a new file with given name |
44,192 | public static function newBlock ( string $ name , int $ permissions = null ) : vfsStreamBlock { return new vfsStreamBlock ( $ name , $ permissions ) ; } | returns a new block with the given name |
44,193 | public static function inspect ( vfsStreamVisitor $ visitor , vfsStreamContent $ content = null ) : vfsStreamVisitor { if ( null !== $ content ) { return $ visitor -> visit ( $ content ) ; } $ root = vfsStreamWrapper :: getRoot ( ) ; if ( null === $ root ) { throw new \ InvalidArgumentException ( 'No content given and ... | use visitor to inspect a content structure |
44,194 | public static function unregister ( ) { if ( ! self :: $ registered ) { if ( in_array ( vfsStream :: SCHEME , stream_get_wrappers ( ) ) ) { throw new vfsStreamException ( 'The URL wrapper for the protocol ' . vfsStream :: SCHEME . ' was not registered with this version of vfsStream.' ) ; } return ; } if ( ! @ stream_wr... | Unregisters a previously registered URL wrapper for the vfs scheme . |
44,195 | public static function setRoot ( vfsStreamDirectory $ root ) : vfsStreamDirectory { self :: $ root = $ root ; clearstatcache ( ) ; return self :: $ root ; } | sets the root content |
44,196 | private function isInRoot ( string $ path ) : bool { return substr ( $ path , 0 , strlen ( self :: $ root -> getName ( ) ) ) === self :: $ root -> getName ( ) ; } | helper method to detect whether given path is in root path |
44,197 | private function createFile ( string $ path , string $ mode = null , int $ options = null ) { $ names = $ this -> splitPath ( $ path ) ; if ( empty ( $ names [ 'dirname' ] ) === true ) { if ( ( $ options & STREAM_REPORT_ERRORS ) === STREAM_REPORT_ERRORS ) { trigger_error ( 'File ' . $ names [ 'basename' ] . ' does not ... | creates a file at given path |
44,198 | protected function calculateMode ( string $ mode , bool $ extended ) : int { if ( true === $ extended ) { return self :: ALL ; } if ( self :: READ === $ mode ) { return self :: READONLY ; } return self :: WRITEONLY ; } | calculates the file mode |
44,199 | public function stream_truncate ( int $ size ) : bool { if ( self :: READONLY === $ this -> mode ) { return false ; } if ( $ this -> content -> isWritable ( vfsStream :: getCurrentUser ( ) , vfsStream :: getCurrentGroup ( ) ) === false ) { return false ; } if ( $ this -> content -> getType ( ) !== vfsStreamContent :: T... | truncates a file to a given length |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.