idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
45,800 | protected function addCategoryData ( $ iCategoryID , $ bActiveCategory = false ) { $ obCategoryItem = CategoryItem :: make ( $ iCategoryID ) ; if ( $ obCategoryItem -> isEmpty ( ) ) { return ; } $ this -> arResult [ ] = [ 'id' => $ obCategoryItem -> id , 'name' => $ obCategoryItem -> name , 'slug' => $ obCategoryItem -... | Add category data |
45,801 | public function getTotalQuantity ( ) { $ iQuantityCount = 0 ; $ arOfferList = $ this -> all ( ) ; foreach ( $ arOfferList as $ arOfferItem ) { $ iQuantityCount += $ arOfferItem -> quantity ; } return $ iQuantityCount ; } | Get the total count of all order positions |
45,802 | protected function afterAttach ( $ obModel , $ arAttachedIDList , $ arInsertData ) { $ this -> clearListByPromoBlock ( $ arAttachedIDList ) ; $ this -> clearListByCategory ( $ arAttachedIDList ) ; } | After attach event handler |
45,803 | protected function clearListByPromoBlock ( $ arAttachedIDList ) { if ( $ this -> sRelationName != 'promo_block' ) { return ; } foreach ( $ arAttachedIDList as $ iPromoBlockID ) { ProductListStore :: instance ( ) -> promo_block -> clear ( $ iPromoBlockID ) ; } } | Clear cached product list by promo block ID |
45,804 | protected function clearListByCategory ( $ arAttachedIDList ) { if ( $ this -> sRelationName != 'additional_category' ) { return ; } foreach ( $ arAttachedIDList as $ iCategoryID ) { BrandListStore :: instance ( ) -> category -> clear ( $ iCategoryID ) ; ProductListStore :: instance ( ) -> category -> clear ( $ iCatego... | Clear cached product list by category ID |
45,805 | protected function disableDefaultCurrency ( ) { $ obCurrencyList = Currency :: isDefault ( ) -> get ( ) ; if ( $ obCurrencyList -> isEmpty ( ) ) { return ; } foreach ( $ obCurrencyList as $ obCurrency ) { if ( $ obCurrency -> id == $ this -> id ) { continue ; } $ obCurrency -> is_default = false ; $ obCurrency -> save ... | Disable default currency because only one can be an active currency |
45,806 | public function switchCountry ( $ sCountryCode ) { if ( empty ( $ sCountryCode ) || ! PluginManager :: instance ( ) -> hasPlugin ( 'RainLab.Location' ) ) { return ; } $ this -> obActiveCountry = \ RainLab \ Location \ Models \ Country :: whereCode ( $ sCountryCode ) -> first ( ) ; } | Switch active country by code |
45,807 | public function switchState ( $ sStateCode ) { if ( empty ( $ sStateCode ) || ! PluginManager :: instance ( ) -> hasPlugin ( 'RainLab.Location' ) ) { return ; } $ this -> obActiveState = \ RainLab \ Location \ Models \ State :: whereCode ( $ sStateCode ) -> first ( ) ; } | Switch active state by code |
45,808 | public function getPriceWithoutTax ( $ fPrice , $ fPricePercent ) { $ fPriceResult = $ fPrice ; if ( $ this -> bPriceIncludeTax ) { $ fPriceResult = $ this -> calculatePriceWithoutTax ( $ fPrice , $ fPricePercent ) ; } return $ fPriceResult ; } | Get price value without tax |
45,809 | public function getPriceWithTax ( $ fPrice , $ fPricePercent ) { $ fPriceResult = $ fPrice ; if ( ! $ this -> bPriceIncludeTax ) { $ fPriceResult = $ this -> calculatePriceWithTax ( $ fPrice , $ fPricePercent ) ; } return $ fPriceResult ; } | Get price value with tax |
45,810 | public function calculatePriceWithTax ( $ fPrice , $ fTax ) { $ fPrice = ( $ fPrice * ( 100 + $ fTax ) ) / 100 ; $ fPrice = PriceHelper :: round ( $ fPrice ) ; return $ fPrice ; } | Calculate price + tax |
45,811 | public function calculatePriceWithoutTax ( $ fPrice , $ fTax ) { $ fPrice = ( $ fPrice * 100 ) / ( 100 + $ fTax ) ; $ fPrice = PriceHelper :: round ( $ fPrice ) ; return $ fPrice ; } | Calculate price - tax |
45,812 | public function getTaxPercent ( $ obTaxList ) { if ( empty ( $ obTaxList ) || $ obTaxList -> isEmpty ( ) ) { return 0 ; } $ fTaxPercent = 0 ; foreach ( $ obTaxList as $ obTaxItem ) { $ fTaxPercent += $ obTaxItem -> percent ; } $ fTaxPercent = PriceHelper :: round ( $ fTaxPercent ) ; return $ fTaxPercent ; } | Get tax percent |
45,813 | public function category ( $ arCategoryIDList , $ bWithChildren = false ) { if ( ! is_array ( $ arCategoryIDList ) ) { $ arCategoryIDList = [ $ arCategoryIDList ] ; } $ arResultIDList = [ ] ; foreach ( $ arCategoryIDList as $ iCategoryID ) { $ arResultIDList = array_merge ( $ arResultIDList , ( array ) ProductListStore... | Filter product list by category ID |
45,814 | public function brand ( $ iBrandID ) { $ arResultIDList = ProductListStore :: instance ( ) -> brand -> get ( $ iBrandID ) ; return $ this -> intersect ( $ arResultIDList ) ; } | Filter product list by brand ID |
45,815 | public function promo ( $ iPromoBlockID ) { $ arResultIDList = ProductListStore :: instance ( ) -> promo_block -> get ( $ iPromoBlockID ) ; $ arEventDataList = Event :: fire ( PromoBlock :: EVENT_GET_PRODUCT_LIST , $ iPromoBlockID ) ; if ( empty ( $ arEventDataList ) ) { return $ this -> intersect ( $ arResultIDList ) ... | Filter product list by promo block ID + different extensions |
45,816 | public function promoBlock ( $ iPromoBlockID ) { $ arResultIDList = ProductListStore :: instance ( ) -> promo_block -> get ( $ iPromoBlockID ) ; return $ this -> intersect ( $ arResultIDList ) ; } | Filter product list by promo block ID |
45,817 | public function getOfferMinPrice ( $ sPriceTypeCode = null ) { $ obProductList = clone $ this ; $ sSorting = ProductListStore :: SORT_PRICE_ASC ; if ( ! empty ( $ sPriceTypeCode ) ) { $ sSorting .= '|' . $ sPriceTypeCode ; } $ obProductList -> sort ( $ sSorting ) ; $ obProductItem = $ obProductList -> first ( ) ; if ( ... | Get offer with min price |
45,818 | protected function getIDListChildrenCategory ( $ iCategoryID ) : array { $ obCategoryItem = CategoryItem :: make ( $ iCategoryID ) ; if ( $ obCategoryItem -> isEmpty ( ) || $ obCategoryItem -> children -> isEmpty ( ) ) { return [ ] ; } $ arResultIDList = [ ] ; foreach ( $ obCategoryItem -> children as $ obChildCategory... | Get product ID list for children categories |
45,819 | protected function getCustomSortingList ( ) : array { $ arEventResult = Event :: fire ( 'shopaholic.promo_block.sorting.get.list' , [ $ this -> sValue ] ) ; if ( empty ( $ arEventResult ) ) { return [ ] ; } $ arElementIDList = [ ] ; foreach ( $ arEventResult as $ arEventPromoBlockIDList ) { if ( empty ( $ arEventPromoB... | Get element list with custom sorting |
45,820 | public function importData ( $ arElementList , $ sSessionKey = null ) { if ( empty ( $ arElementList ) ) { return ; } $ obImport = new ImportProductModel ( ) ; $ obImport -> setDeactivateFlag ( ) ; foreach ( $ arElementList as $ iKey => $ arImportData ) { $ obImport -> import ( $ arImportData ) ; $ sResultMethod = $ ob... | Import item list from CSV file |
45,821 | public function attach ( ServerObserver $ observer ) { if ( $ this -> state ) { throw new \ Error ( "Cannot attach observers after the server has started" ) ; } $ this -> observers -> attach ( $ observer ) ; } | Attach an observer . |
45,822 | public function stop ( int $ timeout = self :: DEFAULT_SHUTDOWN_TIMEOUT ) : Promise { switch ( $ this -> state ) { case self :: STARTED : return new Coroutine ( $ this -> doStop ( $ timeout ) ) ; case self :: STOPPED : return new Success ; default : return new Failure ( new \ Error ( "Cannot stop server: currently " . ... | Stop the server . |
45,823 | public function start ( HttpDriverFactory $ driverFactory ) { if ( $ this -> readWatcher ) { throw new \ Error ( "Client already started" ) ; } $ this -> timeoutCache -> renew ( $ this -> id ) ; $ this -> writeWatcher = Loop :: onWritable ( $ this -> socket , $ this -> callableFromInstanceMethod ( "onWritable" ) ) ; Lo... | Listen for requests on the client and parse them using the given HTTP driver . |
45,824 | private function parse ( string $ data = "" ) { try { $ promise = $ this -> requestParser -> send ( $ data ) ; if ( $ promise instanceof Promise && ! $ this -> isExported && ! ( $ this -> status & self :: CLOSED_RDWR ) ) { $ this -> paused = true ; $ promise -> onResolve ( $ this -> resume ) ; if ( $ this -> paused ) {... | Sends data to the request parser . |
45,825 | private function negotiateCrypto ( string $ watcher , $ socket , HttpDriverFactory $ driverFactory ) { if ( $ handshake = @ \ stream_socket_enable_crypto ( $ this -> socket , true ) ) { Loop :: cancel ( $ this -> readWatcher ) ; $ this -> isEncrypted = true ; $ this -> cryptoInfo = \ stream_get_meta_data ( $ this -> so... | Called by the onReadable watcher after the client connects until encryption is enabled . |
45,826 | private function onWritable ( ) { $ bytesWritten = @ \ fwrite ( $ this -> socket , $ this -> writeBuffer ) ; if ( $ bytesWritten === false ) { $ this -> close ( ) ; return ; } if ( $ bytesWritten === 0 ) { return ; } $ this -> timeoutCache -> renew ( $ this -> id ) ; if ( $ bytesWritten !== \ strlen ( $ this -> writeBu... | Called by the onWritable watcher . |
45,827 | private function write ( string $ data , bool $ close = false ) : Promise { if ( $ this -> status & self :: CLOSED_WR ) { return new Failure ( new ClientException ( "The client disconnected" ) ) ; } if ( ! $ this -> writeDeferred ) { $ bytesWritten = @ \ fwrite ( $ this -> socket , $ data ) ; if ( $ bytesWritten === fa... | Adds the given data to the buffer of data to be written to the client socket . Returns a promise that resolves once the client write buffer has emptied . |
45,828 | private function onMessage ( Request $ request , string $ buffer = '' ) : Promise { \ assert ( $ this -> logger -> debug ( \ sprintf ( "%s %s HTTP/%s @ %s:%s" , $ request -> getMethod ( ) , $ request -> getUri ( ) , $ request -> getProtocolVersion ( ) , $ this -> clientAddress , $ this -> clientPort ) ) || true ) ; $ t... | Invoked by the HTTP parser when a request is parsed . |
45,829 | private function resume ( \ Throwable $ exception = null ) { if ( $ exception ) { $ this -> close ( ) ; return ; } if ( ! $ this -> isExported && ! ( $ this -> status & self :: CLOSED_RDWR ) ) { $ this -> paused = false ; Loop :: enable ( $ this -> readWatcher ) ; $ this -> parse ( ) ; } } | Resumes the request parser after it has yielded a promise . |
45,830 | private function respond ( Request $ request , string $ buffer ) : \ Generator { try { $ method = $ request -> getMethod ( ) ; if ( ! \ in_array ( $ method , $ this -> options -> getAllowedMethods ( ) , true ) ) { if ( ! \ in_array ( $ method , HttpDriver :: KNOWN_METHODS , true ) ) { $ response = yield from $ this -> ... | Respond to a parsed request . |
45,831 | private function makeExceptionResponse ( Request $ request ) : \ Generator { $ status = Status :: INTERNAL_SERVER_ERROR ; try { return yield $ this -> errorHandler -> handleError ( $ status , null , $ request ) ; } catch ( \ Throwable $ exception ) { $ this -> logger -> error ( $ exception ) ; return yield self :: $ de... | Used if an exception is thrown from a request handler . |
45,832 | private function export ( callable $ upgrade , string $ buffer ) { if ( $ this -> status & self :: CLOSED_RDWR || $ this -> isExported ) { return ; } $ this -> clear ( ) ; $ this -> isExported = true ; \ assert ( $ this -> logger -> debug ( "Upgrade {$this->clientAddress}:{$this->clientPort} #{$this->id}" ) || true ) ;... | Invokes the export function on Response with the socket detached from the HTTP server . |
45,833 | public function renew ( int $ id ) { $ this -> updates [ $ id ] = $ this -> now + $ this -> timeout ; } | Renews the timeout for the given ID . |
45,834 | public function clear ( int $ id ) { unset ( $ this -> updates [ $ id ] ) ; $ this -> cache -> remove ( $ id ) ; } | Clears the timeout for the given ID removing it completely from the list . |
45,835 | public function setBody ( $ stringOrStream ) { if ( $ stringOrStream instanceof InputStream ) { $ this -> body = $ stringOrStream ; $ this -> removeHeader ( "content-length" ) ; return ; } try { $ this -> setBodyFromString ( $ stringOrStream ?? "" ) ; } catch ( \ TypeError $ e ) { throw new \ TypeError ( "The response ... | Sets the stream for the message body . Note that using a string will automatically set the Content - Length header to the length of the given string . Setting a stream will remove the Content - Length header . |
45,836 | public function setHeaders ( array $ headers ) { $ cookies = $ this -> cookies ; try { parent :: setHeaders ( $ headers ) ; } catch ( \ Throwable $ e ) { $ this -> cookies = $ cookies ; throw $ e ; } } | Sets the headers from the given array . Any cookie headers will automatically populate the contained array of ResponseCookie objects . |
45,837 | public function setStatus ( int $ code , string $ reason = null ) { $ this -> status = $ this -> validateStatusCode ( $ code ) ; $ this -> reason = $ reason ?? Status :: getReason ( $ this -> status ) ; if ( $ this -> upgrade && $ this -> status !== Status :: SWITCHING_PROTOCOLS ) { $ this -> upgrade = null ; } } | Sets the response status code and reason phrase . Use null for the reason phrase to use the default phrase associated with the status code . |
45,838 | public function setCookie ( ResponseCookie $ cookie ) { $ this -> cookies [ $ cookie -> getName ( ) ] = $ cookie ; $ this -> setHeadersFromCookies ( ) ; } | Adds a cookie to the response . |
45,839 | public function removeCookie ( string $ name ) { if ( isset ( $ this -> cookies [ $ name ] ) ) { unset ( $ this -> cookies [ $ name ] ) ; $ this -> setHeadersFromCookies ( ) ; } } | Removes a cookie from the response . |
45,840 | public function getBody ( ) : RequestBody { if ( $ this -> body === null ) { $ this -> body = new RequestBody ( new InMemoryStream ) ; } return $ this -> body ; } | Retrieve the request body . |
45,841 | public function setBody ( $ stringOrStream ) { if ( $ stringOrStream instanceof RequestBody ) { $ this -> body = $ stringOrStream ; $ this -> removeHeader ( "content-length" ) ; return ; } if ( $ stringOrStream instanceof InputStream ) { $ this -> body = new RequestBody ( $ stringOrStream ) ; $ this -> removeHeader ( "... | Sets the stream for the message body . Note that using a string will automatically set the Content - Length header to the length of the given string . Using an InputStream or Body instance will remove the Content - Length header . |
45,842 | public function setCookie ( RequestCookie $ cookie ) { $ this -> cookies [ $ cookie -> getName ( ) ] = $ cookie ; $ this -> setHeadersFromCookies ( ) ; } | Adds a cookie to the request . |
45,843 | public function getAttribute ( string $ name ) { if ( ! $ this -> hasAttribute ( $ name ) ) { throw new MissingAttributeError ( "The requested attribute '{$name}' does not exist" ) ; } return $ this -> attributes [ $ name ] ; } | Retrieve a variable from the request s mutable local storage . |
45,844 | private function updateTime ( ) { $ this -> currentTime = \ time ( ) ; $ this -> currentHttpDate = \ gmdate ( "D, d M Y H:i:s" , $ this -> currentTime ) . " GMT" ; foreach ( $ this -> callbacks as $ callback ) { $ callback ( $ this -> currentTime , $ this -> currentHttpDate ) ; } } | Updates the context with the current time . |
45,845 | private function sendErrorResponse ( ClientException $ exception ) : \ Generator { $ message = $ exception -> getMessage ( ) ; $ status = $ exception -> getCode ( ) ? : Status :: BAD_REQUEST ; $ response = yield $ this -> errorHandler -> handleError ( $ status , $ message ) ; $ response -> setHeader ( "connection" , "c... | Creates an error response from the error handler and sends that response to the client . |
45,846 | private function filter ( Response $ response , string $ protocol = "1.0" , array $ connection = [ ] ) : array { $ headers = $ response -> getHeaders ( ) ; if ( $ response -> getStatus ( ) < Status :: OK ) { unset ( $ headers [ 'content-length' ] ) ; return $ headers ; } $ push = $ response -> getPush ( ) ; if ( ! empt... | Filters and updates response headers based on protocol and connection header from the request . |
45,847 | protected function storeOldTimestamp ( $ key ) { return $ this -> config ( 'forbid_old_passwords' ) === true ? $ this -> sessionPut ( Constants :: SESSION_OTP_TIMESTAMP , $ key ) : $ key ; } | Store the old OTP timestamp . |
45,848 | protected function passwordExpired ( ) { if ( ( $ minutes = $ this -> config ( 'lifetime' ) ) !== 0 && $ this -> minutesSinceLastActivity ( ) > $ minutes ) { event ( new OneTimePasswordExpired ( $ this -> getUser ( ) ) ) ; $ this -> logout ( ) ; return true ; } $ this -> keepAlive ( ) ; return false ; } | Check if OTP has expired . |
45,849 | public function verifyGoogle2FA ( $ secret , $ one_time_password ) { return $ this -> verifyKey ( $ secret , $ one_time_password , $ this -> config ( 'window' ) , null , $ this -> getOldTimestamp ( ) ? : Google2FAConstants :: ARGUMENT_NOT_SET ) ; } | Verify the OTP . |
45,850 | protected function getAuth ( ) { if ( is_null ( $ this -> auth ) ) { $ this -> auth = app ( $ this -> config ( 'auth' ) ) ; } return $ this -> auth ; } | Get or make an auth instance . |
45,851 | protected function getOneTimePassword ( ) { if ( is_null ( $ password = $ this -> getInputOneTimePassword ( ) ) || empty ( $ password ) ) { event ( new EmptyOneTimePasswordReceived ( ) ) ; if ( $ this -> config ( 'throw_exceptions' , true ) ) { throw new InvalidOneTimePassword ( 'One Time Password cannot be empty.' ) ;... | Get the OTP from user input . |
45,852 | protected function checkOTP ( ) { if ( ! $ this -> inputHasOneTimePassword ( ) ) { return false ; } if ( $ isValid = $ this -> verifyOneTimePassword ( ) ) { $ this -> login ( ) ; } return $ this -> fireLoginEvent ( $ isValid ) ; } | Check if the input OTP is valid . |
45,853 | protected function makeHtmlResponse ( $ statusCode ) { $ view = $ this -> getView ( ) ; if ( $ statusCode !== SymfonyResponse :: HTTP_OK ) { $ view -> withErrors ( $ this -> getErrorBagForStatusCode ( $ statusCode ) ) ; } return new IlluminateHtmlResponse ( $ view , $ statusCode ) ; } | Make a web response . |
45,854 | public function makeRequestOneTimePasswordResponse ( ) { event ( app ( ) -> version ( ) < '5.4' ? new OneTimePasswordRequested53 ( $ this -> getUser ( ) ) : new OneTimePasswordRequested ( $ this -> getUser ( ) ) ) ; $ expectJson = app ( ) -> version ( ) < '5.4' ? $ this -> getRequest ( ) -> wantsJson ( ) : $ this -> ge... | Create a response to request the OTP . |
45,855 | protected function makeSessionVarName ( $ name = null ) { return $ this -> config ( 'session_var' ) . ( is_null ( $ name ) || empty ( $ name ) ? '' : '.' . $ name ) ; } | Make a session var name for . |
45,856 | public function sessionGet ( $ var = null , $ default = null ) { if ( $ this -> stateless ) { return $ default ; } return $ this -> getRequest ( ) -> session ( ) -> get ( $ this -> makeSessionVarName ( $ var ) , $ default ) ; } | Get a session var value . |
45,857 | protected function sessionPut ( $ var , $ value ) { if ( $ this -> stateless ) { return $ value ; } $ this -> getRequest ( ) -> session ( ) -> put ( $ this -> makeSessionVarName ( $ var ) , $ value ) ; return $ value ; } | Put a var value to the current session . |
45,858 | protected function sessionForget ( $ var = null ) { if ( $ this -> stateless ) { return ; } $ this -> getRequest ( ) -> session ( ) -> forget ( $ this -> makeSessionVarName ( $ var ) ) ; } | Forget a session var . |
45,859 | public function upvoters ( ) { return $ this -> morphToMany ( config ( 'follow.user_model' ) , config ( 'follow.morph_prefix' ) , config ( 'follow.followable_table' ) ) -> wherePivot ( 'relation' , '=' , Follow :: RELATION_UPVOTE ) -> withPivot ( 'followable_type' , 'relation' , 'created_at' ) ; } | Return upvoters . |
45,860 | public function downvoters ( ) { return $ this -> morphToMany ( config ( 'follow.user_model' ) , config ( 'follow.morph_prefix' ) , config ( 'follow.followable_table' ) ) -> wherePivot ( 'relation' , '=' , Follow :: RELATION_DOWNVOTE ) -> withPivot ( 'followable_type' , 'relation' , 'created_at' ) ; } | Return downvoters . |
45,861 | public function bookmarkers ( ) { return $ this -> morphToMany ( config ( 'follow.user_model' ) , config ( 'follow.morph_prefix' ) , config ( 'follow.followable_table' ) ) -> wherePivot ( 'relation' , '=' , Follow :: RELATION_BOOKMARK ) -> withPivot ( 'followable_type' , 'relation' , 'created_at' ) ; } | Return bookmarkers . |
45,862 | public function favorites ( $ class = __CLASS__ ) { return $ this -> morphedByMany ( $ class , config ( 'follow.morph_prefix' ) , config ( 'follow.followable_table' ) ) -> wherePivot ( 'relation' , '=' , Follow :: RELATION_FAVORITE ) -> withPivot ( 'followable_type' , 'relation' , 'created_at' ) ; } | Return item favorites . |
45,863 | public function favoriters ( ) { return $ this -> morphToMany ( config ( 'follow.user_model' ) , config ( 'follow.morph_prefix' ) , config ( 'follow.followable_table' ) ) -> wherePivot ( 'relation' , '=' , Follow :: RELATION_FAVORITE ) -> withPivot ( 'followable_type' , 'relation' , 'created_at' ) ; } | Return favoriters . |
45,864 | public function areFollowingEachOther ( $ target , $ class = __CLASS__ ) { return Follow :: isRelationExists ( $ this , 'followings' , $ target , $ class ) && Follow :: isRelationExists ( $ target , 'followings' , $ this , $ class ) ; } | Check if user and target user is following each other . |
45,865 | public function followings ( $ class = __CLASS__ ) { $ table = config ( 'follow.followable_table' ) ; $ foreignKey = config ( 'follow.users_table_foreign_key' , 'user_id' ) ; $ targetTable = ( new $ class ( ) ) -> getTable ( ) ; $ tablePrefixedForeignKey = app ( 'db.connection' ) -> getQueryGrammar ( ) -> wrap ( \ spri... | Return item followings . |
45,866 | public function vote ( $ targets , $ type = 'upvote' , $ class = __CLASS__ ) { $ this -> cancelVote ( $ targets ) ; return Follow :: attachRelations ( $ this , str_plural ( $ type ) , $ targets , $ class ) ; } | Vote an item or items . |
45,867 | public function cancelVote ( $ targets , $ class = __CLASS__ ) { $ this -> hasUpvoted ( $ targets ) && Follow :: detachRelations ( $ this , 'upvotes' , $ targets , $ class ) ; $ this -> hasDownvoted ( $ targets ) && Follow :: detachRelations ( $ this , 'downvotes' , $ targets , $ class ) ; return $ this ; } | Cancel vote for an item or items . |
45,868 | public function votes ( $ class = __CLASS__ ) { return $ this -> morphedByMany ( $ class , config ( 'follow.morph_prefix' ) , config ( 'follow.followable_table' ) ) -> wherePivotIn ( 'relation' , [ Follow :: RELATION_UPVOTE , Follow :: RELATION_DOWNVOTE ] ) -> withPivot ( 'followable_type' , 'relation' , 'created_at' )... | Return item votes . |
45,869 | public function upvotes ( $ class = __CLASS__ ) { return $ this -> morphedByMany ( $ class , config ( 'follow.morph_prefix' ) , config ( 'follow.followable_table' ) ) -> wherePivot ( 'relation' , '=' , Follow :: RELATION_UPVOTE ) -> withPivot ( 'followable_type' , 'relation' , 'created_at' ) ; } | Return item upvotes . |
45,870 | public function downvotes ( $ class = __CLASS__ ) { return $ this -> morphedByMany ( $ class , config ( 'follow.morph_prefix' ) , config ( 'follow.followable_table' ) ) -> wherePivot ( 'relation' , '=' , Follow :: RELATION_DOWNVOTE ) -> withPivot ( 'followable_type' , 'relation' , 'created_at' ) ; } | Return item downvotes . |
45,871 | public function boot ( ) { $ this -> publishes ( [ realpath ( __DIR__ . '/../config/follow.php' ) => config_path ( 'follow.php' ) , ] , 'config' ) ; $ this -> publishes ( [ realpath ( __DIR__ . '/../database/migrations' ) => database_path ( 'migrations' ) , ] , 'migrations' ) ; } | Application bootstrap event . |
45,872 | public function subscriptions ( $ class = __CLASS__ ) { return $ this -> morphedByMany ( $ class , config ( 'follow.morph_prefix' ) , config ( 'follow.followable_table' ) ) -> wherePivot ( 'relation' , '=' , Follow :: RELATION_SUBSCRIBE ) -> withPivot ( 'followable_type' , 'relation' , 'created_at' ) ; } | Return user subscriptions . |
45,873 | public function bookmarks ( $ class = __CLASS__ ) { return $ this -> morphedByMany ( $ class , config ( 'follow.morph_prefix' ) , config ( 'follow.followable_table' ) ) -> wherePivot ( 'relation' , '=' , Follow :: RELATION_BOOKMARK ) -> withPivot ( 'followable_type' , 'relation' , 'created_at' ) ; } | Return item bookmarks . |
45,874 | public function likes ( $ class = __CLASS__ ) { return $ this -> morphedByMany ( $ class , config ( 'follow.morph_prefix' ) , config ( 'follow.followable_table' ) ) -> wherePivot ( 'relation' , '=' , Follow :: RELATION_LIKE ) -> withPivot ( 'followable_type' , 'relation' , 'created_at' ) ; } | Return item likes . |
45,875 | public static function load ( $ class ) { if ( substr ( $ class , 0 , strlen ( self :: PACKAGE ) ) != self :: PACKAGE ) return false ; $ path = sprintf ( '%s/%s.php' , self :: $ _path , str_replace ( '_' , '/' , $ class ) ) ; if ( file_exists ( $ path ) ) require_once ( $ path ) ; } | Attempts to load a Pheanstalk class file . |
45,876 | private function _peek ( $ tube , $ method ) { try { $ job = $ this -> _client -> useTube ( $ tube ) -> { $ method } ( ) ; $ peek = array ( 'id' => $ job -> getId ( ) , 'data' => $ job -> getData ( ) , 'stats' => $ this -> _client -> statsJob ( $ job ) ) ; } catch ( Exception $ ex ) { $ peek = array ( ) ; } if ( $ peek... | Pheanstalk class instance |
45,877 | public function log ( $ write ) { if ( $ this -> isFull ( ) ) array_shift ( $ this -> _data ) ; $ this -> _data [ ] = ( int ) $ write ; return $ write ; } | Logs the return value from a write call . Returns the input value . |
45,878 | public function peek ( $ jobId ) { $ response = $ this -> _dispatch ( new Pheanstalk_Command_PeekCommand ( $ jobId ) ) ; return new Pheanstalk_Job ( $ response [ 'id' ] , $ response [ 'jobdata' ] ) ; } | Inspect a job in the system regardless of what tube it is in . |
45,879 | public function peekReady ( ) { $ response = $ this -> _dispatch ( new Pheanstalk_Command_PeekCommand ( Pheanstalk_Command_PeekCommand :: TYPE_READY ) ) ; return new Pheanstalk_Job ( $ response [ 'id' ] , $ response [ 'jobdata' ] ) ; } | Inspect the next ready job in the currently used tube . |
45,880 | public function peekDelayed ( ) { $ response = $ this -> _dispatch ( new Pheanstalk_Command_PeekCommand ( Pheanstalk_Command_PeekCommand :: TYPE_DELAYED ) ) ; return new Pheanstalk_Job ( $ response [ 'id' ] , $ response [ 'jobdata' ] ) ; } | Inspect the shortest - remaining - delayed job in the currently used tube . |
45,881 | public function peekBuried ( ) { $ response = $ this -> _dispatch ( new Pheanstalk_Command_PeekCommand ( Pheanstalk_Command_PeekCommand :: TYPE_BURIED ) ) ; return new Pheanstalk_Job ( $ response [ 'id' ] , $ response [ 'jobdata' ] ) ; } | Inspect the next job in the list of buried jobs of the currently used tube . |
45,882 | public function put ( $ data , $ priority = self :: DEFAULT_PRIORITY , $ delay = self :: DEFAULT_DELAY , $ ttr = self :: DEFAULT_TTR ) { $ response = $ this -> _dispatch ( new Pheanstalk_Command_PutCommand ( $ data , $ priority , $ delay , $ ttr ) ) ; return $ response [ 'id' ] ; } | Puts a job on the queue . |
45,883 | private function _getSocket ( ) { if ( ! isset ( $ this -> _socket ) ) { $ this -> _socket = new Pheanstalk_Socket_NativeSocket ( $ this -> _hostname , $ this -> _port , $ this -> _connectTimeout ) ; } return $ this -> _socket ; } | Socket handle for the connection to beanstalkd |
45,884 | public function convertSplittersToRegexPattern ( $ splitters ) { $ regex_parts = array ( ) ; foreach ( $ splitters as $ part ) { $ part = preg_quote ( $ part ) ; switch ( $ part ) { case "\r\n" : $ part = '\r\n' ; break ; case "\t" : $ part = '\t' ; break ; case "\n" : $ part = '\n' ; break ; case " " : $ part = '\s' ;... | Convert an array of splitter tokens to a regex pattern string . |
45,885 | protected function removeParenthesisFromStart ( $ token ) { $ parenthesisRemoved = 0 ; $ trim = trim ( $ token ) ; if ( $ trim !== '' && $ trim [ 0 ] === '(' ) { $ parenthesisRemoved ++ ; $ trim [ 0 ] = ' ' ; $ trim = trim ( $ trim ) ; } $ parenthesis = $ parenthesisRemoved ; $ i = 0 ; $ string = 0 ; $ stringOpened = '... | This method removes parenthesis from start of the given string . It removes also the associated closing parenthesis . |
45,886 | public function toArray ( $ tokenList ) { $ expr = array ( ) ; foreach ( $ tokenList as $ token ) { if ( $ token instanceof \ PHPSQLParser \ utils \ ExpressionToken ) { $ expr [ ] = $ token -> toArray ( ) ; } else { $ expr [ ] = $ token ; } } return $ expr ; } | translates an array of objects into an associative array |
45,887 | protected function balanceCharacter ( $ tokens , $ idx , $ char ) { $ token_count = count ( $ tokens ) ; $ i = $ idx + 1 ; while ( $ i < $ token_count ) { if ( ! isset ( $ tokens [ $ i ] ) ) { $ i ++ ; continue ; } $ token = $ tokens [ $ i ] ; $ tokens [ $ idx ] .= $ token ; unset ( $ tokens [ $ i ] ) ; if ( $ token ==... | to re - combine some tokens |
45,888 | protected function processPHPVersion ( $ commentStart , $ commentEnd , $ commentText ) { if ( strstr ( strtolower ( $ commentText ) , 'php version' ) === false ) { $ error = 'PHP version not specified' ; $ this -> currentFile -> addWarning ( $ error , $ commentEnd , 'MissingVersion' ) ; } } | Check that the PHP version is specified . |
45,889 | protected function getIndentation ( $ tagName , $ tagElement ) { if ( $ tagElement instanceof PHP_CodeSniffer_CommentParser_SingleElement ) { if ( $ tagElement -> getContent ( ) !== '' ) { return ( strlen ( $ tagName ) + substr_count ( $ tagElement -> getWhitespaceBeforeContent ( ) , ' ' ) ) ; } } else if ( $ tagElemen... | Get the indentation information of each tag . |
45,890 | public static function escapeFunction ( $ parameter ) : string { $ result = $ parameter ; switch ( true ) { case is_string ( $ result ) && ! preg_match ( '//u' , $ result ) : $ result = '0x' . strtoupper ( bin2hex ( $ result ) ) ; break ; case is_string ( $ result ) : $ result = "'" . addslashes ( $ result ) . "'" ; br... | Escape parameters of a SQL query DON T USE THIS FUNCTION OUTSIDE ITS INTENDED SCOPE |
45,891 | public function calculate ( float $ percentage , PriceCollection $ prices , SalesChannelContext $ context ) : CalculatedPrice { $ price = $ prices -> sum ( ) ; $ discount = $ this -> rounding -> round ( $ price -> getTotalPrice ( ) / 100 * $ percentage , $ context -> getContext ( ) -> getCurrencyPrecision ( ) ) ; $ rul... | Provide a negative percentage value for discount or a positive percentage value for a surcharge |
45,892 | public function sortDeliveries ( ) : self { $ this -> sort ( function ( Delivery $ a , Delivery $ b ) { if ( $ a -> getLocation ( ) !== $ b -> getLocation ( ) ) { return - 1 ; } return $ a -> getDeliveryDate ( ) -> getEarliest ( ) > $ b -> getDeliveryDate ( ) -> getEarliest ( ) ; } ) ; return $ this ; } | Sorts the delivery collection by earliest delivery date |
45,893 | private function getFieldsForPrimaryKeyMapping ( array $ fields ) : array { $ primaryKeys = array_filter ( $ fields , function ( Field $ field ) { return $ field -> is ( PrimaryKey :: class ) ; } ) ; $ references = array_filter ( $ fields , function ( Field $ field ) { return $ field instanceof ManyToOneAssociationFiel... | Returns all fields which are relevant to extract and map the primary key data of an entity definition data array . In case a primary key consist of Foreign Key fields the corresponding association for these foreign keys must be returned in order to guarantee the creation of these sub entities and to extract the corresp... |
45,894 | public function getAutomaticPromotions ( SalesChannelContext $ context ) : EntityCollection { $ criteria = new Criteria ( [ ] ) ; $ criteria -> addFilter ( new MultiFilter ( MultiFilter :: CONNECTION_AND , [ new EqualsFilter ( 'useCodes' , false ) , new EqualsFilter ( 'active' , true ) , new EqualsFilter ( 'promotion.s... | Gets a list of all available active promotions that do not require a code within the current checkout context . |
45,895 | private function getDateRangeFilter ( ) : Filter { $ today = new \ DateTime ( ) ; $ today = $ today -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) ; $ todayStart = $ today -> format ( 'Y-m-d H:i:s 0:0:0' ) ; $ todayEnd = $ today -> format ( 'Y-m-d H:i:s 23:59:59' ) ; $ filterNoDateRange = new MultiFilter ( MultiFilter... | This is the basic filter that can be added to get only promotions valid for the current time period . |
45,896 | public function getField ( string $ fieldName , EntityDefinition $ definition , string $ root ) : ? Field { $ original = $ fieldName ; $ prefix = $ root . '.' ; if ( strpos ( $ fieldName , $ prefix ) === 0 ) { $ fieldName = substr ( $ fieldName , \ strlen ( $ prefix ) ) ; } $ fields = $ definition -> getFields ( ) ; $ ... | Returns the field instance of the provided fieldName . |
45,897 | public function getFieldAccessor ( string $ fieldName , EntityDefinition $ definition , string $ root , Context $ context ) : string { $ fieldName = str_replace ( 'extensions.' , '' , $ fieldName ) ; $ original = $ fieldName ; $ prefix = $ root . '.' ; if ( strpos ( $ fieldName , $ prefix ) === 0 ) { $ fieldName = subs... | Builds the sql field accessor for the provided field . |
45,898 | public function getBaseQuery ( QueryBuilder $ query , EntityDefinition $ definition , Context $ context ) : QueryBuilder { $ table = $ definition -> getEntityName ( ) ; $ query -> from ( self :: escape ( $ table ) ) ; $ useVersionFallback = ( $ definition -> isVersionAware ( ) && $ context -> getVersionId ( ) !== Defau... | Creates the basic root query for the provided entity definition and application context . It considers the current context version . |
45,899 | public function resolveAccessor ( string $ fieldName , EntityDefinition $ definition , string $ root , QueryBuilder $ query , Context $ context ) : void { $ fieldName = str_replace ( 'extensions.' , '' , $ fieldName ) ; $ original = $ fieldName ; $ prefix = $ root . '.' ; if ( strpos ( $ fieldName , $ prefix ) === 0 ) ... | Used for dynamic sql joins . In case that the given fieldName is unknown or event nested with multiple association roots the function can resolve each association part of the field name even if one part of the fieldName contains a translation or event inherited data field . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.