idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
14,200 | private function populate_properties ( ) { global $ wp ; $ this -> is_mobile = ( bool ) \ wp_is_mobile ( ) ; $ this -> scheme = \ is_ssl ( ) ? 'https' : 'http' ; $ this -> matched_query = $ wp -> matched_query ; $ this -> matched_rule = $ wp -> matched_rule ; $ this -> url = Theme_Utils :: get_current_url ( ) ; $ this ... | Populates Request class parameters . |
14,201 | public function resolveArguments ( Callable $ callable , Request $ request , Array $ route_info ) { $ arguments = array ( ) ; $ ref = new \ ReflectionMethod ( $ callable [ 0 ] , $ callable [ 1 ] ) ; $ req_attr = $ request -> query -> all ( ) ; foreach ( $ ref -> getParameters ( ) as $ parameter ) { if ( array_key_exist... | resolveArguments Resolve controller method arguments from the request object and data from the Router . |
14,202 | public function setShipping ( $ shipping ) { NumericValidator :: validate ( $ shipping , "Shipping" ) ; $ shipping = Formatter :: formatToPrice ( $ shipping ) ; $ this -> shipping = $ shipping ; return $ this ; } | Amount charged for shipping . |
14,203 | public function setHandlingFee ( $ handlingFee ) { NumericValidator :: validate ( $ handlingFee , "Handling Fee" ) ; $ handlingFee = Formatter :: formatToPrice ( $ handlingFee ) ; $ this -> handlingFee = $ handlingFee ; return $ this ; } | Amount being charged for the handling fee . |
14,204 | public function setShippingDiscount ( $ shippingDiscount ) { NumericValidator :: validate ( $ shippingDiscount , "Shipping Discount" ) ; $ shippingDiscount = Formatter :: formatToPrice ( $ shippingDiscount ) ; $ this -> shippingDiscount = $ shippingDiscount ; return $ this ; } | Amount being discounted for the shipping fee . |
14,205 | public function setGiftWrap ( $ giftWrap ) { NumericValidator :: validate ( $ giftWrap , "Gift Wrap" ) ; $ giftWrap = Formatter :: formatToPrice ( $ giftWrap ) ; $ this -> giftWrap = $ giftWrap ; return $ this ; } | Amount being charged as gift wrap fee . |
14,206 | public function setFee ( $ fee ) { NumericValidator :: validate ( $ fee , "Fee" ) ; $ fee = Formatter :: formatToPrice ( $ fee ) ; $ this -> fee = $ fee ; return $ this ; } | Fee charged by PayU . In case of a refund this is the fee amount refunded to the original recipient of the payment . |
14,207 | public function make ( Settings $ settings ) : string { $ cacheKey = $ this -> getCacheKey ( $ settings ) ; if ( $ this -> hasCachedData ( $ cacheKey ) ) { return $ this -> getCachedData ( $ cacheKey ) ; } $ settings -> hasRequiredSettings ( ) ; return $ this -> cacheData ( $ cacheKey , $ this -> createOutput ( $ setti... | Make url string |
14,208 | protected function cacheData ( string $ key , string $ data ) : string { $ this -> cache [ $ key ] = $ data ; return $ data ; } | Add an item to the cache |
14,209 | protected function getToken ( HTTPRequest $ request ) : ? string { if ( $ authHeader = $ request -> getHeader ( 'Authorization' ) ) { if ( stripos ( $ authHeader , 'Bearer ' ) === 0 ) { return substr ( $ authHeader , 6 ) ; } } return null ; } | Extract the token from the authorization header . |
14,210 | public function getPayment ( $ request , $ match ) { Pluf :: loadFunction ( 'Pluf_Shortcuts_GetObjectOr404' ) ; $ wallet = Pluf_Shortcuts_GetObjectOr404 ( 'Bank_Wallet' , $ match [ 'parentId' ] ) ; if ( $ request -> user -> getId ( ) !== $ wallet -> owner_id && ! User_Precondition :: isOwner ( $ request ) ) { throw new... | Returns the payment with given id . It also creates a transfer if payment is successfully payed . |
14,211 | public function refund ( array $ params ) { if ( ! isset ( $ params [ 'identifier' ] ) ) { throw new MonetivoException ( '$transaction["identifier"] is not set' ) ; } return $ this -> merchantApi -> call ( 'post' , 'transactions/' . $ params [ 'identifier' ] . '/refund' , [ 'form_params' => $ params ] ) -> toArray ( ) ... | Refunds the transaction |
14,212 | public static function getCommand ( $ command = null ) { if ( is_null ( $ command ) ) { $ command = ( PHP_OS == 'Darwin' ) ? 'ctags' : 'ctags-exuberant' ; } if ( exec ( "which $command" ) ) { return $ command ; } throw new \ Exception ( "command not found: $command" ) ; } | Attempts to find and return the installed ctags command . |
14,213 | protected function getUserId ( $ user ) : ? int { if ( $ user === null ) { return null ; } if ( is_int ( $ user ) ) { return $ user ; } if ( $ user instanceof Authenticatable ) { return $ user -> getAuthIdentifier ( ) ; } return null ; } | Get user ID |
14,214 | protected function track ( ? int $ typeId = null , ? int $ itemId = null , int $ flag = 0 , $ data = null , $ user = null ) { $ this -> writer -> register ( [ 'user' => $ this -> getUserId ( $ user ) , 'type' => $ this -> type , 'typeId' => $ typeId , 'itemId' => $ itemId , 'flagLevel' => $ flag , 'data' => $ data , ] ... | Track the event |
14,215 | protected function scanTo ( $ path , $ scope ) { if ( ! ( $ sub = array_shift ( $ path ) ) || ! isset ( $ scope [ $ sub ] ) ) { return null ; } if ( ! $ path ) { return $ scope [ $ sub ] ; } return $ this -> scanTo ( $ path , $ scope [ $ sub ] ) ; } | Scan to a given value . |
14,216 | public function getConfigValue ( $ path ) { $ chunks = explode ( '/' , $ path ) ; if ( ! $ chunks [ 0 ] ) { array_shift ( $ chunks ) ; } return $ this -> scanTo ( $ chunks , $ this -> data ) ; } | Retrieve a config value . |
14,217 | public function definedIn ( string ... $ fileNames ) : self { $ instance = clone $ this ; foreach ( $ fileNames as $ fileName ) { $ instance -> fileNames [ ] = $ fileName ; } return $ instance ; } | Clones the construct and adds the file name to the list of files the construct is defined in . |
14,218 | public function setContainerId ( $ objectOrId ) { if ( $ objectOrId instanceof Model ) { $ objectOrId = $ objectOrId -> getId ( ) ; } $ this -> setValue ( 'containerId' , ( string ) $ objectOrId ) ; } | Set container identifier that contains this workspace . |
14,219 | public function afterGetProduct ( \ Magento \ Quote \ Model \ Quote \ Item \ AbstractItem $ subject , \ Magento \ Catalog \ Model \ Product $ result ) { $ quote = $ subject -> getQuote ( ) ; return $ result ; } | Add warehouse & group prices to product loaded as quote item . |
14,220 | public static function c ( $ message , $ number , $ args = [ ] , $ domain = 'core' , $ locale = 'en_EN' ) { return self :: getInstance ( ) -> translator -> transChoice ( $ message , $ number , $ args , $ domain , $ locale ) ; } | Choice typo . |
14,221 | public static function t ( $ message , $ args = [ ] , $ domain = 'core' , $ locale = 'en_EN' ) { return self :: getInstance ( ) -> translator -> trans ( $ message , $ args , $ domain , $ locale ) ; } | Translate typo . |
14,222 | public function aroundGetStockItem ( \ Magento \ CatalogInventory \ Model \ StockRegistryProvider $ subject , \ Closure $ proceed , $ productId , $ scopeId ) { $ result = $ this -> storeStockRegistry -> getStockItem ( $ productId , $ scopeId ) ; if ( null === $ result ) { $ criteria = $ this -> factStockItemCrit -> cre... | Detect current stock and get appropriate stock item . |
14,223 | public function getQuery ( QueryBuilder $ queryBuilder , FullyQualifiedClassName $ section , array $ fetchFields ) : QueryBuilder { return $ this -> buildQuery ( $ queryBuilder , $ section , $ fetchFields ) ; } | I might want to add caching of the created query here |
14,224 | private function buildQuery ( QueryBuilder $ queryBuilder , FullyQualifiedClassName $ section , array $ fetchFields ) : QueryBuilder { $ this -> buildReflections ( $ section , $ fetchFields ) ; reset ( $ this -> reflections ) ; $ start = $ this -> reflections [ key ( $ this -> reflections ) ] ; $ this -> makeSelectProp... | Run the steps required to make the query |
14,225 | private function stackReflections ( ) { foreach ( $ this -> reflections as & $ reflection ) { foreach ( $ reflection [ 'fields' ] as & $ field ) { if ( ! empty ( $ field [ 'relatedToSection' ] ) ) { if ( isset ( $ this -> reflections [ $ field [ 'relatedToSection' ] ] ) ) { $ field [ 'sectionDetails' ] = $ this -> refl... | Nesting of reflected entities |
14,226 | public function actionCreate ( ) { if ( \ Yii :: $ app -> user -> can ( 'create' ) ) { $ model = new Author ( ) ; if ( $ model -> load ( \ Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'index' ] ) ; } else { return $ this -> render ( 'create' , [ 'model' => $ model , ] )... | Creates a new Author model . If creation is successful the browser will be redirected to the index page . |
14,227 | public function findModel ( $ id ) { if ( $ this -> _model === null ) { if ( $ this -> _model = $ id ? Author :: findOne ( $ id ) : null ) { return $ this -> _model ; } else { throw new NotFoundHttpException ( Module :: t ( 'core' , 'The requested model does not exist.' ) ) ; } } } | Finds the User model based on its primary key value or by name . If the model is not found a 404 HTTP exception will be thrown . |
14,228 | private function getNewMailer ( $ email = '' ) { $ mail = new PHPMailer ( ) ; $ mail -> isSMTP ( ) ; $ mail -> Host = 'smtp.mandrillapp.com' ; $ mail -> SMTPAuth = true ; $ mail -> Username = 'smtp username' ; $ mail -> Password = 'smtp-password' ; $ mail -> SMTPSecure = 'tls' ; $ mail -> Port = 587 ; $ mail -> CharSet... | Return one new PHPMailer |
14,229 | public static function sendGenericEmail ( $ email , $ subject , $ bodyHtml , $ bodyHtmlAlt = '' ) { $ mail = self :: getNewMailer ( $ email ) ; $ mail -> WordWrap = 50 ; $ mail -> isHTML ( true ) ; $ mail -> Subject = $ subject ; $ mail -> Body = $ bodyHtml ; $ mail -> AltBody = $ bodyHtmlAlt ; return $ mail -> send ( ... | Send new generic email |
14,230 | public static function detailView ( array $ config = [ ] ) { $ grid = Yii :: createObject ( ArrayHelper :: merge ( [ 'class' => get_called_class ( ) , 'dataProvider' => new ArrayDataProvider ( [ 'allModels' => [ $ config [ 'model' ] ] ] ) , ] , ArrayHelper :: remove ( $ config , 'gridOptions' , [ ] ) ) ) ; $ class = $ ... | Runs DetailView widget based on this GridView . |
14,231 | private function resolveContext ( array $ context ) { $ defaultOptions = [ self :: OPTION_OBJECT => $ this -> object , self :: OPTION_EXCEPTION_ON_INVALID_TYPE => $ this -> exceptionOnInvalidType , self :: OPTION_OBJECT_FOR_MAP => $ this -> objectForMap , self :: OPTION_MULTI_LINE_LITERAL_BLOCK => $ this -> multiLineLi... | Merges the default options of the Yaml Encoder with the passed context . |
14,232 | public static function match ( string $ str , string $ start , string $ end ) { $ start = preg_quote ( $ start ) ; $ end = preg_quote ( $ end ) ; if ( preg_match ( '/' . $ start . '(.*)' . $ end . '/' , $ str , $ matches ) ) { return $ matches [ 1 ] . '' ; } return false ; } | Match single occurrence in a string |
14,233 | public static function emails ( string $ str ) { preg_match_all ( self :: REGEXP_EMAIL , $ str , $ matches ) ; return $ matches [ 0 ] ?? false ; } | Match all email addresses |
14,234 | protected function renderTitle ( $ title , $ cellPadding , $ columnsWidths ) { $ columnsNumber = count ( $ columnsWidths ) ; $ tableWidth = array_sum ( $ columnsWidths ) + $ columnsNumber + ( $ columnsNumber * $ cellPadding * 2 ) - 1 ; $ content = '+' . str_repeat ( '-' , $ tableWidth ) . '+' . PHP_EOL ; $ content .= '... | Render the table s title |
14,235 | protected function renderTable ( $ data , $ cellPadding , $ columnsWidths ) { $ tableRows = [ ] ; foreach ( $ data as $ row ) { $ row = array_values ( $ row ) ; $ tableCol = '|' ; $ columnsNumber = count ( $ columnsWidths ) ; for ( $ colNm = 0 ; $ colNm < $ columnsNumber ; ++ $ colNm ) { $ colWidth = $ columnsWidths [ ... | Render the table s content |
14,236 | public static function make ( string $ file , array $ variables = [ ] ) : bool { $ fileLocation = static :: fileAnalyzer ( $ file ) ; if ( file_exists ( $ fileLocation ) ) : ob_start ( getConstant ( 'MINIFY_HTML_OUTPUT' ) ? 'minifyHTMLOutput' : NULL ) ; if ( ! empty ( $ variables ) ) self :: with ( $ variables ) ; extr... | Make a view . |
14,237 | final public static function with ( array $ variables ) : View { foreach ( $ variables as $ variableName => $ variableValue ) static :: $ passedVariables [ $ variableName ] = $ variableValue ; return new View ; } | Set the class property passedVariables to pass variables to the view . |
14,238 | public function sendRequest ( $ path , $ method = 'GET' , array $ payload = null ) { $ this -> getLogger ( ) -> debug ( sprintf ( '%s %s' , $ method , $ path ) ) ; $ request = $ this -> messageFactory -> createRequest ( $ method , $ this -> baseUri . '/' . ltrim ( $ path , '/' ) , [ 'apiKey' => $ this -> token ] ) ; if... | Send request to Tracker and return response . |
14,239 | private function buildRequestBody ( RequestInterface $ request , array $ payload ) { $ hasFiles = false ; foreach ( $ payload as $ value ) { if ( $ value instanceof File ) { $ hasFiles = true ; break ; } } if ( $ hasFiles ) { $ builder = $ this -> getMultipartStreamBuilder ( ) ; foreach ( $ payload as $ key => $ value ... | Build request body from a given payload . |
14,240 | private function parseJson ( $ json ) { $ data = @ json_decode ( $ json , true ) ; if ( null === $ data ) { throw new RuntimeException ( 'JSON parsing failed: ' . json_last_error_msg ( ) ) ; } if ( ! array_key_exists ( 'response' , $ data ) || ! array_key_exists ( 'success' , $ data ) || ! $ data [ 'success' ] ) { $ ex... | Parse JSON response . |
14,241 | public function set ( $ id , $ data , $ lifetime = null , $ tags = null ) { $ backend = $ this -> getBackend ( ) ; if ( $ tags !== null ) { if ( ! $ backend instanceof TaggableInterface ) { throw new NoTagsSupported ( 'Unable to set the data with the tag(s) due to a tags does not supported by the backend "' . get_class... | Store the data |
14,242 | public function setMany ( array $ data , $ lifetime = null , $ tags = null ) { $ backend = $ this -> getBackend ( ) ; if ( $ tags !== null ) { if ( ! $ backend instanceof TaggableInterface ) { throw new NoTagsSupported ( 'Unable to set the data with the tag(s) due to the tags does not supported by the backend "' . get_... | Set the many of the data |
14,243 | public function getMany ( array $ id ) { $ preparedIds = array_map ( [ $ this , 'prepareId' ] , $ id ) ; $ result = $ this -> getBackend ( ) -> getMany ( $ preparedIds ) ; if ( empty ( $ result ) ) { return $ result ; } if ( $ this -> _namespace !== null ) { $ ids = array_intersect_key ( array_combine ( $ preparedIds ,... | Fetch the many of the data |
14,244 | public function removeMany ( array $ ids ) { $ ids = array_map ( [ $ this , 'prepareId' ] , $ ids ) ; return $ this -> getBackend ( ) -> removeMany ( $ ids ) ; } | Remove the many of the data |
14,245 | public function inc ( $ id , $ value = 1 ) { $ id = $ this -> prepareId ( $ id ) ; return $ this -> getBackend ( ) -> inc ( $ id , $ value ) ; } | Increment the data |
14,246 | public function dec ( $ id , $ value = 1 ) { $ id = $ this -> prepareId ( $ id ) ; return $ this -> getBackend ( ) -> dec ( $ id , $ value ) ; } | Decrement the data |
14,247 | function load ( ) { if ( $ this -> _isProcessingLoad ( ) ) throw new \ RuntimeException ( sprintf ( 'Conflict while loading config (%s); another process interrupt loading (%s).' , $ this -> path , static :: $ isProcessingLoading ) ) ; $ this -> _setFlagProcessingLoad ( ) ; $ path = $ this -> path ; $ config = $ this ->... | Load Configs Properties From Given Configuration |
14,248 | public static function convertByParent ( $ data , $ parent_field , $ options = [ ] ) { $ pointers = [ ] ; foreach ( $ data as $ k => $ v ) { if ( empty ( $ v [ $ parent_field ] ) ) { continue ; } if ( ! empty ( $ data [ $ v [ $ parent_field ] ] ) ) { $ data [ $ v [ $ parent_field ] ] [ 'options' ] [ $ k ] = $ data [ $ ... | Convert array to a tree using parent field |
14,249 | public static function findKeyInATree ( $ data , $ key , $ hashes = [ ] ) { if ( ! empty ( $ data [ $ key ] ) ) { $ hashes [ ] = $ key ; return $ hashes ; } else { foreach ( $ data as $ k => $ v ) { if ( empty ( $ v [ 'options' ] ) ) { continue ; } $ hashes2 = $ hashes ; $ hashes2 [ ] = $ k ; $ hashes2 [ ] = 'options' ... | Find a key in a tree |
14,250 | public function generateToken ( $ userId ) { $ user = $ this -> users -> find ( $ userId ) ; if ( ! is_null ( $ user ) ) { $ user -> generateInvitationToken ( ) ; $ user -> trackTime ( 'invited_at' ) ; $ user -> setStatus ( Status :: INACTIVE ) ; } } | Generate an invitation token for a user . |
14,251 | public function resend ( $ tokenString ) { $ token = $ this -> findToken ( $ tokenString ) ; if ( ! is_null ( $ token ) ) { session ( ) -> forget ( 'inactive_email' ) ; $ token -> user -> resendInvite ( ) ; } } | Find the invitation token extend it s expire time and resend the email . |
14,252 | public function activate ( $ tokenString ) { $ token = $ this -> findToken ( $ tokenString ) ; if ( is_null ( $ token ) || $ token -> isExpired ( ) ) { return Response :: failed ( 'Activation failed.' ) -> route ( 'auth.invitation.failed' , $ tokenString ) ; } $ token -> user -> activateInvitation ( ) ; auth ( ) -> log... | Attempt to activate the user by the provided token . |
14,253 | public static function registerExtension ( string $ fileExtension , $ class ) { if ( in_array ( 'Aidantwoods\BetterOptions\FileLoader' , class_implements ( $ class ) , true ) ) { self :: $ classMap [ strtolower ( $ fileExtension ) ] = $ class ; } else { throw new Exception ( "Classes must implement the " . "Aidantwoods... | Register a custom class to handle a particular file extension |
14,254 | private static function registerSymfonyYaml ( ) { if ( ! isset ( self :: $ classMap [ 'yaml' ] ) and ! isset ( self :: $ classMap [ 'yml' ] ) and class_exists ( self :: SYMFONY_YAML ) ) { self :: registerExtension ( 'yaml' , self :: YAML_ADAPTER ) ; self :: registerExtension ( 'yml' , self :: YAML_ADAPTER ) ; } } | Register the built in YAML adapter for Symfony s YAML parser if Symfony s YAML parser is loaded and no class is loaded for the YAML extension |
14,255 | protected static function updateVariantByIdRequest ( $ variant_id , $ variant ) { if ( $ variant_id === null || ( is_array ( $ variant_id ) && count ( $ variant_id ) === 0 ) ) { throw new \ InvalidArgumentException ( 'Missing the required parameter $variant_id when calling updateVariantById' ) ; } if ( $ variant === nu... | Create request for operation updateVariantById |
14,256 | public function getLoggersFactory ( ) { if ( $ this -> _loggersFactory !== null ) { return $ this -> _loggersFactory ; } if ( ! $ this instanceof LocatorAwareInterface ) { throw new NoFactory ( 'Neither a service\'s locator nor loggers\' factory has been specified' ) ; } if ( $ this -> hasLocator ( ) ) { $ this -> _log... | Get a loggers factory |
14,257 | public function hasLogger ( $ considerFactory = true ) { if ( $ this -> _logger !== null ) { return true ; } if ( $ this instanceof LocatorAwareInterface && $ this -> hasLocator ( ) && $ this -> getLocator ( ) -> has ( $ this -> getLoggerServiceId ( ) ) ) { return true ; } return $ considerFactory ? $ this -> hasLogger... | Has a logger |
14,258 | public function hasLoggersFactory ( ) { if ( $ this -> _loggersFactory !== null ) { return true ; } if ( $ this instanceof LocatorAwareInterface && $ this -> hasLocator ( ) && $ this -> getLocator ( ) -> has ( $ this -> getLoggersFactoryServiceId ( ) ) ) { return true ; } return false ; } | Has a loggers factory |
14,259 | protected function createSequenceNumber ( ) : int { $ session = $ this -> request -> session ( ) ; $ value = random_int ( 100 , 10000 ) ; $ add = random_int ( 10 , 1000 ) ; $ session -> put ( self :: SESSION_KEY , [ 'value' => $ value , 'add' => $ add , 'total' => $ value , ] ) ; return $ value ; } | Generate sequence number and store in session . |
14,260 | public static function getCategoryFilterValues ( $ filter , $ categoryId ) { $ class = $ filter -> type -> class_name ; $ objects = $ class :: find ( ) -> joinWith ( 'products p' ) -> where ( [ 'p.category_id' => $ categoryId ] ) -> all ( ) ; return $ objects ; } | This method return only these rows which product_id complies existing product . |
14,261 | public static function load ( string $ filename ) { $ data = parse_ini_file ( $ filename , true ) ; if ( ! empty ( $ data [ 'registry' ] ) ) { foreach ( $ data [ 'registry' ] as $ k => $ v ) { array_key_set ( self :: $ settings , explode ( '.' , $ k ) , $ v ) ; } } } | Load ini file |
14,262 | private function reverse_chunk ( $ s ) : string { $ res = '' ; while ( strlen ( $ s ) ) { $ pos = strpos ( $ s , "\r\n" ) ; if ( $ pos === false ) { $ res .= $ s ; break ; } $ l = hexdec ( substr ( $ s , 0 , $ pos ) ) ; $ res .= substr ( $ s , $ pos + 2 , $ l ) ; $ s = substr ( $ s , $ l + $ pos + 2 ) ; } return $ res ... | Makes one boyd string from chunks |
14,263 | public function format ( $ memory , $ params = null , $ locale = null ) { if ( $ memory == 0 ) { return 0 ; } if ( $ memory < 1024 ) { return round ( $ memory ) . 'b' ; } if ( $ memory < 1048576 ) { return round ( $ memory / 1024 , 2 ) . 'K' ; } if ( $ memory < 10485760 ) { return round ( $ memory / 1024 , 1 ) . 'K' ; ... | Format the memory |
14,264 | public function getOrders ( ) { $ orders = Order :: find ( ) -> joinWith ( 'orderProducts' ) -> where ( [ 'product_id' => $ this -> id ] ) -> all ( ) ; return $ orders ; } | Gets orders which have this product |
14,265 | public function getOrderedNumber ( ) { $ orderedProductsNumber = Order :: find ( ) -> select ( 'count' ) -> joinWith ( 'orderProducts' ) -> where ( [ 'product_id' => $ this -> id ] ) -> sum ( 'count' ) ; return $ orderedProductsNumber ?? 0 ; } | Gets number of units that have already bought . |
14,266 | public function getProductAttributes ( ) { $ attributes = [ ] ; foreach ( $ this -> combinations as $ combination ) { if ( ! empty ( $ combination -> combinationAttributes ) ) { foreach ( $ combination -> combinationAttributes as $ combinationAttribute ) { $ attributes [ ] = $ combinationAttribute -> productAttribute ;... | Gets attributes which used in product combinations |
14,267 | public function isFavorite ( ) { $ favoriteProduct = FavoriteProduct :: find ( ) -> where ( [ 'product_id' => $ this -> id , 'user_id' => \ Yii :: $ app -> user -> id ] ) -> one ( ) ; if ( ! empty ( $ favoriteProduct ) ) return true ; else return false ; } | Return true if product has added to favorites already or false if not . |
14,268 | public static function generateImageName ( $ baseName ) { $ fileName = hash ( 'crc32' , $ baseName . time ( ) ) ; if ( file_exists ( Yii :: getAlias ( '@frontend/web/images/shop/' . $ fileName . '-original.jpg' ) ) ) { return static :: generateImageName ( $ baseName ) ; } return $ fileName ; } | Generates unique name by string . |
14,269 | protected function addFragment ( $ format , $ var , $ sanitize = true ) { foreach ( ( array ) $ var as $ v ) { if ( $ var ) { $ this -> rdf .= sprintf ( $ format , $ sanitize ? \ BOTK \ Filters :: FILTER_SANITIZE_TURTLE_STRING ( $ v ) : $ v ) ; $ this -> tripleCount ++ ; } } } | adds a turtle fragment managing cardinality > 1 |
14,270 | public static function configure ( $ config = [ ] ) { $ defaults = include dirname ( __DIR__ ) . '/conf/defaults.php' ; self :: $ config = array_replace ( $ defaults , $ config ) ; } | Apply configuration to Nymph - PubSub . |
14,271 | public function install ( SchemaSetupInterface $ setup , ModuleContextInterface $ context ) { $ installer = $ setup ; $ installer -> startSetup ( ) ; $ connection = $ installer -> getConnection ( ) ; if ( ! $ installer -> tableExists ( 'faonni_catalog_product_index_sale' ) ) { $ table = $ connection -> newTable ( $ ins... | Installs DB schema for a module Faonni_ProductSaleIndexer |
14,272 | public function set_value ( array $ value ) { foreach ( $ value as $ n => $ v ) { $ component = $ this -> get_component ( $ n ) ; $ component -> value = $ v ; } } | Apply the value to each of the child components . |
14,273 | public function set_name ( $ name ) { foreach ( $ this -> components as $ c ) { $ c -> name_template = str_replace ( '{{parent_name}}' , $ this -> get_name ( ) , $ c -> composite_name_template ) ; } } | Apply the new name to each of the child components . |
14,274 | public function parse_template ( ) { $ self = $ this ; return preg_replace_callback ( '/\{\{([a-zA-Z\d-_]+)\}\}/' , function ( $ a ) use ( $ self ) { $ component = $ self -> get_component ( $ a [ 1 ] ) ; return $ component -> render ( ) ; } , $ this -> model [ 'template' ] ) ; } | Parse the template by converting the name tokens into UI components . |
14,275 | public function get_component ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> components ) ) { throw new \ RuntimeException ( "Composite sub-component not found with name $name" ) ; } return $ this -> components [ $ name ] ; } | Get a child component by name . |
14,276 | protected function on_created ( ) { foreach ( $ this -> model [ 'components' ] as $ args ) { $ this -> components [ $ args [ 'name' ] ] = $ this -> create_component ( $ args ) ; } } | Instantiate child UI components when created . |
14,277 | public function onMessage ( ConnectionInterface $ from , $ msg ) { $ data = json_decode ( $ msg , true ) ; if ( ! $ data [ 'action' ] || ! in_array ( $ data [ 'action' ] , [ 'authenticate' , 'subscribe' , 'unsubscribe' , 'publish' ] ) ) { return ; } switch ( $ data [ 'action' ] ) { case 'authenticate' : $ this -> handl... | Handle a message from a client . |
14,278 | public function onClose ( ConnectionInterface $ conn ) { $ this -> logger -> notice ( "Client skedaddled. ({$conn->resourceId})" ) ; $ mess = 0 ; foreach ( $ this -> querySubs as $ curEtype => & $ curSubscriptions ) { foreach ( $ curSubscriptions as $ curQuery => & $ curClients ) { if ( $ curClients -> contains ( $ con... | Clean up after users who leave . |
14,279 | private function handleAuthentication ( ConnectionInterface $ from , $ data ) { $ token = $ data [ 'token' ] ; if ( isset ( $ token ) ) { $ this -> sessions [ $ from ] = $ token ; } elseif ( $ this -> sessions -> contains ( $ from ) ) { unset ( $ this -> sessions [ $ from ] ) ; } } | Handle an authentication from a client . |
14,280 | private function handleSubscription ( ConnectionInterface $ from , $ data ) { if ( isset ( $ data [ 'query' ] ) ) { $ this -> handleSubscriptionQuery ( $ from , $ data ) ; } elseif ( isset ( $ data [ 'uid' ] ) && is_string ( $ data [ 'uid' ] ) ) { $ this -> handleSubscriptionUid ( $ from , $ data ) ; } } | Handle a subscribe or unsubscribe from a client . |
14,281 | private function handleSubscriptionUid ( ConnectionInterface $ from , $ data ) { if ( $ data [ 'action' ] === 'subscribe' ) { if ( ! key_exists ( $ data [ 'uid' ] , $ this -> uidSubs ) ) { $ this -> uidSubs [ $ data [ 'uid' ] ] = new \ SplObjectStorage ( ) ; } $ this -> uidSubs [ $ data [ 'uid' ] ] [ $ from ] = [ 'coun... | Handle a subscribe or unsubscribe for a UID from a client . |
14,282 | private function handlePublish ( ConnectionInterface $ from , $ msg , $ data ) { if ( isset ( $ data [ 'guid' ] ) && ( $ data [ 'event' ] === 'delete' || ( isset ( $ data [ 'entity' ] ) && ( $ data [ 'event' ] === 'create' || $ data [ 'event' ] === 'update' ) ) ) ) { $ this -> relay ( $ msg ) ; $ this -> handlePublishE... | Handle a publish from a client . |
14,283 | private function handlePublishUid ( ConnectionInterface $ from , $ data ) { $ this -> logger -> notice ( "Received a UID publish! (" . ( isset ( $ data [ 'name' ] ) ? $ data [ 'name' ] : "{$data['oldName']} => {$data['newName']}" ) . ", {$data['event']}, {$from->resourceId})" ) ; foreach ( $ data as $ key => $ name ) {... | Handle a UID publish from a client . |
14,284 | private function relay ( $ message ) { if ( ! Server :: $ config [ 'relays' ] ) { return ; } foreach ( Server :: $ config [ 'relays' ] as $ host ) { $ client = new TextalkWebSocketClient ( $ host ) ; $ client -> send ( $ message ) ; } } | Relay publish data to other servers . |
14,285 | private function init ( ) { foreach ( $ this -> get ( Registry :: class ) -> get ( 'services' , [ ] ) as $ name => $ definition ) { $ this -> set ( $ name , $ definition ) ; } } | Initialize services from registry |
14,286 | public function has ( $ name ) { return isset ( $ this -> payload [ $ name ] ) || isset ( $ this -> map [ ltrim ( $ name , '/' ) ] ) ; } | Check whether given service exists |
14,287 | public function get ( $ name ) { $ item = $ this -> getFactory ( $ name ) -> get ( ) ; if ( $ item instanceof ContainerAwareInterface ) { $ item -> setContainer ( $ this ) ; } return $ item ; } | Fetch object from container |
14,288 | public function getFactory ( $ name ) { if ( false === $ this -> has ( $ name ) ) { if ( class_exists ( $ name ) ) { $ this -> resolve ( $ name ) ; } else { throw new NotFoundException ( 'Service "' . $ name . '" is unknown' ) ; } } if ( true === isset ( $ this -> map [ $ class = ltrim ( $ name , '/' ) ] ) ) { $ name =... | Fetch factory for given service or class from container |
14,289 | public function resolve ( $ class , $ name = null ) { $ class = ltrim ( $ class , '/' ) ; if ( null === $ name ) { $ name = $ class ; } if ( false === $ this -> has ( $ name ) ) { $ this -> set ( $ name , $ class , null ) ; } return $ this -> getFactory ( $ name ) -> get ( ) ; } | Return instance of given class automatically satisfy dependencies from container payload |
14,290 | protected function cacheSet ( $ id , $ data , $ lifetime = null , $ tags = null ) { return $ this -> getCacheFrontend ( ) -> set ( $ id , $ data , $ lifetime , $ tags ) ; } | Store the data in the cache |
14,291 | public function getCacheFrontend ( ) { if ( $ this -> _cacheFrontendWrapper === null ) { if ( $ this instanceof LocatorAwareInterface && $ this -> hasLocator ( ) ) { $ locator = $ this -> getLocator ( ) ; $ serviceId = $ this -> getCacheFrontendServiceId ( ) ; if ( $ locator -> has ( $ serviceId ) ) { $ this -> _cacheF... | Get the wrapper cache frontend |
14,292 | public function hasCacheFrontend ( ) { if ( $ this -> _cacheFrontendWrapper !== null ) { return true ; } if ( $ this instanceof LocatorAwareInterface && $ this -> hasLocator ( ) && $ this -> getLocator ( ) -> has ( $ this -> getCacheFrontendServiceId ( ) ) ) { return true ; } return false ; } | Has the wrapper cache frontend |
14,293 | public function getCacheFrontendFactory ( ) { if ( $ this -> _cacheFrontendFactory === null ) { if ( $ this instanceof LocatorAwareInterface && $ this -> hasLocator ( ) ) { $ locator = $ this -> getLocator ( ) ; $ serviceId = $ this -> getCacheFrontendFactoryServiceId ( ) ; if ( $ locator -> has ( $ serviceId ) ) { $ t... | Get the cache frontends factory |
14,294 | public function hasCacheFrontendFactory ( ) { if ( $ this -> _cacheFrontendFactory !== null ) { return true ; } if ( $ this instanceof LocatorAwareInterface && $ this -> hasLocator ( ) && $ this -> getLocator ( ) -> has ( $ this -> getCacheFrontendFactoryServiceId ( ) ) ) { return true ; } return false ; } | Has the cache frontends factory |
14,295 | public function replace ( $ html ) { $ this -> setOption ( self :: OPTION_VALUE , $ html ) ; $ this -> setOption ( self :: OPTION_METHOD , 'replace' ) ; return $ this ; } | Replace container html with this html without animation Keeps element display property |
14,296 | public function removeClass ( $ class ) { $ this -> setOption ( self :: OPTION_METHOD , "removeClass" ) ; $ this -> setOption ( self :: OPTION_REMOVE_CLASS , $ class ) ; return $ this ; } | Remove CSS class from container |
14,297 | public function addClass ( $ class ) { $ this -> setOption ( self :: OPTION_METHOD , "addClass" ) ; $ this -> setOption ( self :: OPTION_ADD_CLASS , $ class ) ; return $ this ; } | Add CSS class to container |
14,298 | public function attr ( $ attribute , $ value ) { $ this -> setOption ( self :: OPTION_METHOD , "attr" ) ; $ this -> setOption ( self :: OPTION_ATTR , $ attribute ) ; $ this -> setOption ( self :: OPTION_VALUE , $ value ) ; return $ this ; } | Changes attribute value of container |
14,299 | public function myMethod ( $ s , $ i , $ e = null , $ b = true , array $ a = null ) { if ( ! ReflectionTypeHint :: isValid ( ) ) return false ; } | This is myMethod! |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.