idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
45,700 | public static function getUrlEncodedPath ( $ path ) : string { $ entities = array ( '+' , '%21' , '%2A' , '%27' , '%28' , '%29' , '%3B' , '%3A' , '%40' , '%26' , '%3D' , '%2B' , '%24' , '%2C' , '%2F' , '%3F' , '%25' , '%23' , '%5B' , '%5D' ) ; $ replacements = array ( ' ' , '!' , '*' , "'" , '(' , ')' , ';' , ':' , '@'... | URL encode the asset path properly |
45,701 | private function registerEffects ( ) { ImagerService :: registerEffect ( 'grayscale' , GreyscaleEffect :: class ) ; ImagerService :: registerEffect ( 'greyscale' , GreyscaleEffect :: class ) ; ImagerService :: registerEffect ( 'negative' , NegativeEffect :: class ) ; ImagerService :: registerEffect ( 'blur' , BlurEffec... | Register built - in effects |
45,702 | private function registerOptimizers ( ) { ImagerService :: registerOptimizer ( 'jpegoptim' , JpegoptimOptimizer :: class ) ; ImagerService :: registerOptimizer ( 'jpegtran' , JpegtranOptimizer :: class ) ; ImagerService :: registerOptimizer ( 'mozjpeg' , MozjpegOptimizer :: class ) ; ImagerService :: registerOptimizer ... | Register built - in optimizers |
45,703 | public function store ( CraftTransformedImageModel $ image , bool $ isFinalVersion ) { $ config = ImagerService :: getConfig ( ) ; if ( empty ( $ config -> storages ) ) { return ; } $ path = $ image -> path ; $ uri = str_replace ( $ config -> imagerSystemPath , '' , $ path ) ; foreach ( $ config -> storages as $ storag... | Store transformed image in configured storages |
45,704 | private function getFilterMethod ( $ transform ) : string { $ config = ImagerService :: getConfig ( ) ; return ImagerService :: $ imageDriver === 'imagick' ? ImagerService :: $ filterKeyTranslate [ ( string ) $ config -> getSetting ( 'resizeFilter' , $ transform ) ] : ImageInterface :: FILTER_UNDEFINED ; } | Returns the filter method for resize operations |
45,705 | private function saveAsWebp ( $ imageInstance , $ path , $ sourceExtension , $ saveOptions ) { $ config = ImagerService :: getConfig ( ) ; if ( $ config -> getSetting ( 'useCwebp' ) ) { $ tempFile = $ this -> saveTemporaryFile ( $ imageInstance , $ sourceExtension ) ; $ command = escapeshellcmd ( $ config -> getSetting... | Saves image as webp |
45,706 | private function getSaveOptions ( $ extension , $ transform ) : array { $ config = ImagerService :: getConfig ( ) ; switch ( mb_strtolower ( $ extension ) ) { case 'jpg' : case 'jpeg' : return [ 'jpeg_quality' => $ config -> getSetting ( 'jpegQuality' , $ transform ) ] ; case 'gif' : return [ 'flatten' => false ] ; cas... | Get the save options based on extension and transform |
45,707 | private function applyLetterbox ( & $ imageInstance , $ transform ) { if ( isset ( $ transform [ 'width' ] , $ transform [ 'height' ] ) ) { $ config = ImagerService :: getConfig ( ) ; $ letterboxDef = $ config -> getSetting ( 'letterbox' , $ transform ) ; try { $ size = new Box ( $ transform [ 'width' ] , $ transform [... | Apply letterbox to image |
45,708 | private function applyBackgroundColor ( & $ imageInstance , $ bgColor ) { $ palette = new RGB ( ) ; $ color = $ palette -> color ( $ bgColor ) ; try { $ topLeft = new Point ( 0 , 0 ) ; } catch ( InvalidArgumentException $ e ) { Craft :: error ( $ e -> getMessage ( ) , __METHOD__ ) ; throw new ImagerException ( $ e -> g... | Apply background color to image when converting from transparent to non - transparent |
45,709 | private function applyEffects ( $ image , $ effects ) { foreach ( $ effects as $ effect => $ value ) { $ effect = mb_strtolower ( $ effect ) ; if ( isset ( ImagerService :: $ effects [ $ effect ] ) ) { $ effectClass = ImagerService :: $ effects [ $ effect ] ; $ effectClass :: apply ( $ image , $ value ) ; } } } | Applies effects to image . |
45,710 | private function getFramesVars ( $ layers , $ transform ) : array { $ startFrame = 0 ; $ endFrame = \ count ( $ layers ) - 1 ; $ interval = 1 ; if ( isset ( $ transform [ 'frames' ] ) ) { $ framesIntArr = explode ( '@' , $ transform [ 'frames' ] ) ; if ( \ count ( $ framesIntArr ) > 1 ) { $ interval = $ framesIntArr [ ... | Get vars for animated gif frames setup |
45,711 | private function shouldOptimizeByExtension ( string $ extension , array $ validExtensions ) : bool { return \ in_array ( $ extension === 'jpeg' ? 'jpg' : $ extension , $ validExtensions , true ) ; } | Checks if extension is in array of extensions |
45,712 | private function createOptimizeJob ( string $ handle , string $ filePath , array $ settings ) { $ queue = Craft :: $ app -> getQueue ( ) ; $ jobId = $ queue -> push ( new OptimizeJob ( [ 'description' => Craft :: t ( 'imager' , 'Optimizing images (' . $ handle . ')' ) , 'optimizer' => $ handle , 'optimizerSettings' => ... | Creates optimize queue job |
45,713 | private function createTargetFilename ( $ source , $ transform ) : string { $ config = ImagerService :: getConfig ( ) ; $ useFilenamePattern = $ config -> getSetting ( 'useFilenamePattern' , $ transform ) ; $ hashFilename = $ config -> getSetting ( 'hashFilename' , $ transform ) ; $ shortHashLength = $ config -> getSet... | Creates target filename base on source and transform |
45,714 | private function getLetterboxColor ( $ letterboxDef ) : string { $ color = $ letterboxDef [ 'color' ] ; $ opacity = $ letterboxDef [ 'opacity' ] ; $ color = str_replace ( '#' , '' , $ color ) ; if ( \ strlen ( $ color ) === 3 ) { $ opacity = dechex ( $ opacity * 15 ) ; return $ opacity . $ color ; } if ( \ strlen ( $ c... | Gets letterbox params string |
45,715 | private function getQualityFromExtension ( $ ext , $ transform = null ) : string { $ config = ImagerService :: getConfig ( ) ; switch ( $ ext ) { case 'png' : $ pngCompression = $ config -> getSetting ( 'pngCompressionLevel' , $ transform ) ; return max ( 100 - ( $ pngCompression * 10 ) , 1 ) ; case 'webp' : return $ c... | Gets the quality setting based on the extension . |
45,716 | private function getPathsForLocalAsset ( Asset $ image ) { try { $ volume = $ image -> getVolume ( ) ; $ this -> transformPath = ImagerHelpers :: getTransformPathForAsset ( $ image ) ; } catch ( InvalidConfigException $ e ) { Craft :: error ( $ e -> getMessage ( ) , __METHOD__ ) ; throw new ImagerException ( $ e -> get... | Get paths for a local asset |
45,717 | private function getPathsForVolumeAsset ( $ image ) { try { $ this -> transformPath = ImagerHelpers :: getTransformPathForAsset ( $ image ) ; } catch ( InvalidConfigException $ e ) { Craft :: error ( $ e -> getMessage ( ) , __METHOD__ ) ; throw new ImagerException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; ... | Get paths for an asset on an external Craft volume . |
45,718 | private function getPathsForLocalImagerFile ( $ image ) { $ config = ImagerService :: getConfig ( ) ; $ imageString = '/' . str_replace ( $ config -> getSetting ( 'imagerUrl' ) , '' , $ image ) ; $ pathParts = pathinfo ( $ imageString ) ; $ this -> transformPath = $ pathParts [ 'dirname' ] ; $ this -> path = FileHelper... | Get paths for a local file that s in the imager path |
45,719 | private function getPathsForLocalFile ( $ image ) { $ this -> transformPath = ImagerHelpers :: getTransformPathForPath ( $ image ) ; $ pathParts = pathinfo ( $ image ) ; $ this -> path = FileHelper :: normalizePath ( Yii :: getAlias ( '@webroot' ) . '/' . $ pathParts [ 'dirname' ] ) ; $ this -> url = $ image ; $ this -... | Get paths for a local file that s not in the imager path |
45,720 | public function getSetting ( $ key , $ transform = null ) { if ( isset ( $ transform [ $ key ] ) ) { return $ transform [ $ key ] ; } return $ this [ $ key ] ; } | Get setting by key . If there is an override in transform that is returned instead of the value in the model . |
45,721 | private function addToOverrideFilestring ( $ key , $ value ) { $ r = ( ImagerService :: $ transformKeyTranslate [ $ key ] ?? $ key ) . ( \ is_array ( $ value ) ? md5 ( implode ( '-' , $ value ) ) : $ value ) ; $ this -> configOverrideString .= '_' . str_replace ( '%' , '' , str_replace ( [ ' ' , '.' ] , '-' , $ r ) ) ;... | Creates additional file string based on config overrides that is appended to filename |
45,722 | private static function runShellCommand ( $ commandString ) : string { $ shellCommand = new Command ( ) ; $ shellCommand -> setCommand ( $ commandString ) ; if ( $ shellCommand -> execute ( ) ) { $ result = $ shellCommand -> getOutput ( ) ; } else { $ result = $ shellCommand -> getError ( ) ; } return $ result ; } | Runs a shell command through mikehaertl \ shellcommand |
45,723 | private static function colorBlend ( $ imagickInstance , $ color , $ alpha = 1 , $ composite_flag = \ Imagick :: COMPOSITE_COLORIZE ) { $ draw = new \ ImagickDraw ( ) ; $ draw -> setFillColor ( $ color ) ; $ width = $ imagickInstance -> getImageWidth ( ) ; $ height = $ imagickInstance -> getImageHeight ( ) ; $ draw -> ... | Color blend filter more advanced version of colorize . |
45,724 | public function performAction ( ElementQueryInterface $ query ) : bool { try { foreach ( $ query -> all ( ) as $ asset ) { Plugin :: $ plugin -> imager -> removeTransformsForAsset ( $ asset ) ; } } catch ( Exception $ exception ) { $ this -> setMessage ( $ exception -> getMessage ( ) ) ; return false ; } $ this -> setM... | Clears transforms for selected assets |
45,725 | public static function getDefaultChannel ( $ hostname , array $ opts ) { $ channel_opts = self :: updateOpts ( $ opts ) ; return new Channel ( $ hostname , $ opts ) ; } | Creates and returns the default Channel |
45,726 | private function _get_jwt_aud_uri ( $ method ) { $ last_slash_idx = strrpos ( $ method , '/' ) ; if ( $ last_slash_idx === false ) { throw new \ InvalidArgumentException ( 'service name must have a slash' ) ; } $ service_name = substr ( $ method , 0 , $ last_slash_idx ) ; if ( $ this -> hostname_override ) { $ hostname... | constructs the auth uri for the jwt . |
45,727 | private function _validate_and_normalize_metadata ( $ metadata ) { $ metadata_copy = [ ] ; foreach ( $ metadata as $ key => $ value ) { if ( ! preg_match ( '/^[A-Za-z\d_-]+$/' , $ key ) ) { throw new \ InvalidArgumentException ( 'Metadata keys must be nonempty strings containing only ' . 'alphanumeric characters, hyphe... | validate and normalize the metadata array . |
45,728 | private function _StreamUnaryCallFactory ( $ channel ) { if ( is_a ( $ channel , 'Grpc\Internal\InterceptorChannel' ) ) { return function ( $ method , $ deserialize , array $ metadata = [ ] , array $ options = [ ] ) use ( $ channel ) { return $ channel -> getInterceptor ( ) -> interceptStreamUnary ( $ method , $ deseri... | Create a function which can be used to create ClientStreamingCall |
45,729 | protected function _clientStreamRequest ( $ method , $ deserialize , array $ metadata = [ ] , array $ options = [ ] ) { $ call_factory = $ this -> _StreamUnaryCallFactory ( $ this -> channel ) ; $ call = $ call_factory ( $ method , $ deserialize , $ metadata , $ options ) ; return $ call ; } | Call a remote method that takes a stream of arguments and has a single output . |
45,730 | public function write ( $ data , array $ options = [ ] ) { $ message_array = [ 'message' => $ this -> _serializeMessage ( $ data ) ] ; if ( array_key_exists ( 'flags' , $ options ) ) { $ message_array [ 'flags' ] = $ options [ 'flags' ] ; } $ this -> call -> startBatch ( [ OP_SEND_MESSAGE => $ message_array , ] ) ; } | Write a single message to the server . This cannot be called after wait is called . |
45,731 | public function start ( $ data , array $ metadata = [ ] , array $ options = [ ] ) { $ message_array = [ 'message' => $ this -> _serializeMessage ( $ data ) ] ; if ( array_key_exists ( 'flags' , $ options ) ) { $ message_array [ 'flags' ] = $ options [ 'flags' ] ; } $ this -> call -> startBatch ( [ OP_SEND_INITIAL_METAD... | Start the call . |
45,732 | public static function intercept ( $ channel , $ interceptors ) { if ( is_array ( $ interceptors ) ) { for ( $ i = count ( $ interceptors ) - 1 ; $ i >= 0 ; $ i -- ) { $ channel = new Internal \ InterceptorChannel ( $ channel , $ interceptors [ $ i ] ) ; } } else { $ channel = new Internal \ InterceptorChannel ( $ chan... | Intercept the methods with Channel |
45,733 | protected function readObject ( $ path ) { $ options = [ 'Bucket' => $ this -> bucket , 'Key' => $ this -> applyPathPrefix ( $ path ) , ] ; if ( isset ( $ this -> options [ '@http' ] ) ) { $ options [ '@http' ] = $ this -> options [ '@http' ] ; } $ command = $ this -> s3Client -> getCommand ( 'getObject' , $ options + ... | Read an object and normalize the response . |
45,734 | protected function getRawVisibility ( $ path ) { $ command = $ this -> s3Client -> getCommand ( 'getObjectAcl' , [ 'Bucket' => $ this -> bucket , 'Key' => $ this -> applyPathPrefix ( $ path ) , ] ) ; $ result = $ this -> s3Client -> execute ( $ command ) ; $ visibility = AdapterInterface :: VISIBILITY_PRIVATE ; foreach... | Get the object acl presented as a visibility . |
45,735 | protected function upload ( $ path , $ body , Config $ config ) { $ key = $ this -> applyPathPrefix ( $ path ) ; $ options = $ this -> getOptionsFromConfig ( $ config ) ; $ acl = array_key_exists ( 'ACL' , $ options ) ? $ options [ 'ACL' ] : 'private' ; if ( ! isset ( $ options [ 'ContentType' ] ) ) { $ options [ 'Cont... | Upload an object . |
45,736 | protected function normalizeResponse ( array $ response , $ path = null ) { $ result = [ 'path' => $ path ? : $ this -> removePathPrefix ( isset ( $ response [ 'Key' ] ) ? $ response [ 'Key' ] : $ response [ 'Prefix' ] ) , ] ; $ result = array_merge ( $ result , Util :: pathinfo ( $ result [ 'path' ] ) ) ; if ( isset (... | Normalize the object result array . |
45,737 | public function from ( $ username , $ icon = null ) { $ this -> username = $ username ; if ( ! is_null ( $ icon ) ) { $ this -> icon = $ icon ; } return $ this ; } | Set a custom username and optional emoji icon for the Slack message . |
45,738 | public function attachment ( Closure $ callback ) { $ this -> attachments [ ] = $ attachment = new SlackAttachment ; $ callback ( $ attachment ) ; return $ this ; } | Define an attachment for the message . |
45,739 | public function title ( $ title , $ url = null ) { $ this -> title = $ title ; $ this -> url = $ url ; return $ this ; } | Set the title of the attachment . |
45,740 | public function author ( $ name , $ link = null , $ icon = null ) { $ this -> authorName = $ name ; $ this -> authorLink = $ link ; $ this -> authorIcon = $ icon ; return $ this ; } | Set the author of the attachment . |
45,741 | protected function buildJsonPayload ( SlackMessage $ message ) { $ optionalFields = array_filter ( [ 'channel' => data_get ( $ message , 'channel' ) , 'icon_emoji' => data_get ( $ message , 'icon' ) , 'icon_url' => data_get ( $ message , 'image' ) , 'link_names' => data_get ( $ message , 'linkNames' ) , 'unfurl_links' ... | Build up a JSON payload for the Slack webhook . |
45,742 | protected function initParentCategory ( ) { if ( ! array_key_exists ( 'parent_id' , $ this -> arImportData ) ) { return ; } $ iParentID = array_get ( $ this -> arImportData , 'parent_id' ) ; array_forget ( $ this -> arImportData , 'parent_id' ) ; if ( empty ( $ iParentID ) ) { $ this -> obParentCategory = false ; retur... | Find parent category by external ID and set parent_id |
45,743 | protected function setProductField ( ) { $ sProductID = array_get ( $ this -> arImportData , 'product_id' ) ; if ( $ sProductID === null ) { return ; } $ obProduct = Product :: withTrashed ( ) -> getByExternalID ( $ sProductID ) -> first ( ) ; if ( empty ( $ obProduct ) ) { $ this -> arImportData [ 'product_id' ] = nul... | Set product_id filed value |
45,744 | protected function setQuantityField ( ) { $ iQuantity = array_get ( $ this -> arImportData , 'quantity' ) ; if ( $ iQuantity === null ) { return ; } $ iQuantity = ( int ) $ iQuantity ; if ( $ iQuantity < 0 ) { $ iQuantity = 0 ; } $ this -> arImportData [ 'quantity' ] = $ iQuantity ; } | Set quantity field value |
45,745 | public static function getTypeList ( ) : array { $ arResult = [ self :: PROMO_BLOCK_TYPE => Lang :: get ( 'lovata.shopaholic::lang.field.promo_block_type' ) , ] ; $ arEventDataList = Event :: fire ( self :: EVENT_GET_TYPE_LIST ) ; if ( empty ( $ arEventDataList ) ) { return $ arResult ; } foreach ( $ arEventDataList as... | Fire event and get promo content type list |
45,746 | protected function getPriceTypeObject ( ) { $ arValuePartList = explode ( '|' , $ this -> sValue ) ; $ sPriceTypeCode = array_pop ( $ arValuePartList ) ; $ obPriceType = PriceTypeHelper :: instance ( ) -> findByCode ( $ sPriceTypeCode ) ; return $ obPriceType ; } | Get price type object |
45,747 | public function getPageUrl ( $ sPageCode = 'promo-block' ) { $ arParamList = $ this -> getPageParamList ( $ sPageCode ) ; $ sURL = CmsPage :: url ( $ sPageCode , $ arParamList ) ; return $ sURL ; } | Returns URL of a promo block page . |
45,748 | public function category ( $ iCategoryID ) { $ arResultIDList = BrandListStore :: instance ( ) -> category -> get ( $ iCategoryID ) ; return $ this -> intersect ( $ arResultIDList ) ; } | Filter brand list by category ID |
45,749 | public function disableActiveCurrency ( ) { if ( empty ( $ this -> obDefaultCurrency ) ) { return ; } $ this -> sActiveCurrencyCode = $ this -> obDefaultCurrency -> code ; $ this -> obActiveCurrency = $ this -> obDefaultCurrency ; } | Set default currency as active Used in backend |
45,750 | public function getCurrencySymbol ( $ sCurrencyCode ) { $ obCurrency = $ this -> obCurrencyList -> where ( 'code' , $ sCurrencyCode ) -> first ( ) ; if ( empty ( $ obCurrency ) ) { return null ; } return $ obCurrency -> symbol ; } | Get currency symbol |
45,751 | public function getCurrencyCode ( $ sCurrencyCode ) { $ obCurrency = $ this -> obCurrencyList -> where ( 'code' , $ sCurrencyCode ) -> first ( ) ; if ( empty ( $ obCurrency ) ) { return null ; } return $ obCurrency -> code ; } | Get currency code |
45,752 | protected function getActiveCurrencyFromStorage ( ) { $ obUserStorage = $ this -> getUserStorage ( ) ; $ sActiveCurrencyCode = $ obUserStorage -> get ( self :: FIELD_NAME ) ; return $ sActiveCurrencyCode ; } | Get active currency code from user storage |
45,753 | protected function getCurrencyAttribute ( ) { if ( empty ( $ this -> sActiveCurrency ) ) { return CurrencyHelper :: instance ( ) -> getActiveCurrencySymbol ( ) ; } $ sResult = CurrencyHelper :: instance ( ) -> getCurrencySymbol ( $ this -> sActiveCurrency ) ; $ this -> sActiveCurrency = null ; return $ sResult ; } | Get currency value |
45,754 | protected function getCurrencyCodeAttribute ( ) { if ( empty ( $ this -> sActiveCurrency ) ) { return CurrencyHelper :: instance ( ) -> getActiveCurrencyCode ( ) ; } $ sResult = CurrencyHelper :: instance ( ) -> getCurrencyCode ( $ this -> sActiveCurrency ) ; $ this -> sActiveCurrency = null ; return $ sResult ; } | Get currency code value |
45,755 | protected function getPriceWithTaxValueAttribute ( ) { $ fPrice = TaxHelper :: instance ( ) -> getPriceWithTax ( $ this -> price_value , $ this -> tax_percent ) ; return $ fPrice ; } | Get price_with_tax_value attribute value |
45,756 | protected function getOldPriceWithTaxValueAttribute ( ) { $ fPrice = TaxHelper :: instance ( ) -> getPriceWithTax ( $ this -> old_price_value , $ this -> tax_percent ) ; return $ fPrice ; } | Get old_price_with_tax_value attribute value |
45,757 | protected function getDiscountPriceWithTaxValueAttribute ( ) { $ fPrice = TaxHelper :: instance ( ) -> getPriceWithTax ( $ this -> discount_price_value , $ this -> tax_percent ) ; return $ fPrice ; } | Get discount_price_with_tax_value attribute value |
45,758 | protected function getPriceWithoutTaxValueAttribute ( ) { $ fPrice = TaxHelper :: instance ( ) -> getPriceWithoutTax ( $ this -> price_value , $ this -> tax_percent ) ; return $ fPrice ; } | Get price_without_tax_value attribute value |
45,759 | protected function getOldPriceWithoutTaxValueAttribute ( ) { $ fPrice = TaxHelper :: instance ( ) -> getPriceWithoutTax ( $ this -> old_price_value , $ this -> tax_percent ) ; return $ fPrice ; } | Get old_price_without_tax_value attribute value |
45,760 | protected function getDiscountPriceWithoutTaxValueAttribute ( ) { $ fPrice = TaxHelper :: instance ( ) -> getPriceWithoutTax ( $ this -> discount_price_value , $ this -> tax_percent ) ; return $ fPrice ; } | Get discount_price_without_tax_value attribute value |
45,761 | protected function getTaxPercentAttribute ( ) { $ fTaxPercent = $ this -> getAttribute ( 'tax_percent' ) ; if ( $ fTaxPercent === null ) { $ fTaxPercent = TaxHelper :: instance ( ) -> getTaxPercent ( $ this -> tax_list ) ; $ this -> setAttribute ( 'tax_percent' , $ fTaxPercent ) ; } return $ fTaxPercent ; } | Get tax_percent attribute value |
45,762 | protected function getTaxListAttribute ( ) { $ obTaxList = $ this -> getAttribute ( 'tax_list' ) ; if ( $ obTaxList === null ) { $ obTaxList = $ this -> getAppliedTaxList ( ) ; $ this -> setAttribute ( 'tax_list' , $ obTaxList ) ; } return $ obTaxList ; } | Get tax_list attribute value |
45,763 | protected function getAppliedTaxList ( ) { $ obResultTaxList = TaxHelper :: instance ( ) -> getTaxList ( ) ; if ( $ obResultTaxList -> isEmpty ( ) ) { return $ obResultTaxList ; } foreach ( $ obResultTaxList as $ obTaxItem ) { $ bSkipTax = ! $ obTaxItem -> is_global && ! $ obTaxItem -> isAvailableForCategory ( $ this -... | Get applied tax list |
45,764 | public function getPriceObject ( $ iPriceTypeID = null ) { if ( empty ( $ iPriceTypeID ) ) { $ obPriceModel = $ this -> main_price ; } else { $ obPriceModel = $ this -> price_link -> where ( 'price_type_id' , $ iPriceTypeID ) -> first ( ) ; } return $ obPriceModel ; } | Get price object |
45,765 | public function afterSave ( ) { $ this -> savePriceValue ( null , $ this -> fSavedPrice , $ this -> fSavedOldPrice ) ; $ this -> savePriceListValue ( ) ; } | After save model event |
45,766 | public function setQuantityAttribute ( $ iQuantity ) { $ iQuantity = ( int ) $ iQuantity ; if ( empty ( $ iQuantity ) || $ iQuantity < 0 ) { $ iQuantity = 0 ; } $ this -> attributes [ 'quantity' ] = $ iQuantity ; } | Set quantity attribute value |
45,767 | protected function getOldPriceValueAttribute ( ) { $ obPriceModel = $ this -> getPriceObject ( $ this -> getActivePriceType ( ) ) ; $ this -> setActivePriceType ( null ) ; if ( empty ( $ obPriceModel ) ) { return 0 ; } $ fPrice = $ obPriceModel -> old_price_value ; $ fPrice = CurrencyHelper :: instance ( ) -> convert (... | Get old_price_value attribute |
45,768 | protected function getPriceListAttribute ( ) { $ arResult = [ ] ; foreach ( $ this -> price_link as $ obPrice ) { $ arResult [ $ obPrice -> price_type_id ] = [ 'price' => $ obPrice -> price , 'old_price' => $ obPrice -> old_price , ] ; } return $ arResult ; } | Get price_list attribute |
45,769 | protected function setPriceListAttribute ( $ arPriceList ) { if ( empty ( $ arPriceList ) || ! is_array ( $ arPriceList ) ) { return ; } if ( isset ( $ arPriceList [ 0 ] ) ) { $ this -> fSavedPrice = array_get ( $ arPriceList [ 0 ] , 'price' ) ; $ this -> fSavedOldPrice = array_get ( $ arPriceList [ 0 ] , 'old_price' )... | Set price list attribute Create or update Price model object |
45,770 | protected function savePriceValue ( $ iPriceTypeID , $ fPrice , $ fOldPrice ) { $ obPriceModel = $ this -> getPriceObject ( $ iPriceTypeID ) ; if ( empty ( $ obPriceModel ) ) { $ obPriceModel = Price :: create ( [ 'item_id' => $ this -> id , 'item_type' => static :: class , 'price' => $ fPrice , 'old_price' => $ fOldPr... | Create or update main price object |
45,771 | protected function savePriceListValue ( ) { if ( empty ( $ this -> arSavedPriceList ) ) { return ; } foreach ( $ this -> arSavedPriceList as $ iPriceTypeID => $ arPriceData ) { if ( empty ( $ iPriceTypeID ) ) { continue ; } $ this -> savePriceValue ( $ iPriceTypeID , array_get ( $ arPriceData , 'price' ) , array_get ( ... | Save additional price list |
45,772 | public function isAvailableForCategory ( $ obCategoryItem ) : bool { $ arCategoryIDList = ( array ) $ this -> category_id_list ; if ( empty ( $ arCategoryIDList ) || empty ( $ obCategoryItem ) ) { return false ; } if ( in_array ( $ obCategoryItem -> id , $ arCategoryIDList ) ) { return true ; } if ( $ obCategoryItem ->... | Check tax is available for category |
45,773 | public function isAvailableForProduct ( $ obProductItem ) : bool { $ arProductIDList = ( array ) $ this -> product_id_list ; $ bResult = ! empty ( $ arProductIDList ) && ! empty ( $ obProductItem ) && in_array ( $ obProductItem -> id , $ arProductIDList ) ; return $ bResult ; } | Check tax is available for product |
45,774 | public function isAvailableForCountry ( $ obCountry ) : bool { $ arCountryIDList = ( array ) $ this -> country_id_list ; $ bResult = ! empty ( $ arCountryIDList ) && ! empty ( $ obCountry ) && in_array ( $ obCountry -> id , $ arCountryIDList ) ; return $ bResult ; } | Check tax is available for country |
45,775 | public function isAvailableForState ( $ obState ) : bool { $ arStateIDList = ( array ) $ this -> state_id_list ; $ bResult = ! empty ( $ arStateIDList ) && ! empty ( $ obState ) && in_array ( $ obState -> id , $ arStateIDList ) ; return $ bResult ; } | Check tax is available for state |
45,776 | protected function getElementData ( ) { $ arResult = [ 'category_id_list' => $ this -> obElement -> category ( ) -> lists ( 'id' ) , 'product_id_list' => $ this -> obElement -> product ( ) -> lists ( 'id' ) , ] ; if ( PluginManager :: instance ( ) -> hasPlugin ( 'RainLab.Location' ) ) { $ arResult [ 'country_id_list' ]... | Set model data from object |
45,777 | protected function getIDListFromCache ( ) : array { $ arElementIDList = parent :: getIDListFromCache ( ) ; $ arActiveProductIDList = ProductListStore :: instance ( ) -> active -> get ( ) ; if ( empty ( $ arActiveProductIDList ) || empty ( $ arElementIDList ) ) { return [ ] ; } $ arResult = [ ] ; foreach ( $ arElementID... | Get ID list from cache |
45,778 | protected function clearSortingList ( ) { PromoBlockListStore :: instance ( ) -> sorting -> clear ( PromoBlockListStore :: SORT_DEFAULT ) ; PromoBlockListStore :: instance ( ) -> sorting -> clear ( PromoBlockListStore :: SORT_DATE_BEGIN_ASC ) ; PromoBlockListStore :: instance ( ) -> sorting -> clear ( PromoBlockListSto... | Clear sorting list |
45,779 | protected function filterPageList ( $ obPageList ) { $ arCmsPageList = [ ] ; if ( empty ( $ obPageList ) || $ obPageList -> isEmpty ( ) ) { return $ arCmsPageList ; } foreach ( $ obPageList as $ obPage ) { if ( ! $ obPage -> hasComponent ( 'CategoryPage' ) ) { continue ; } $ arPropertyList = $ obPage -> getComponentPro... | Filter page list add pages with CategoryPage component to result |
45,780 | protected function listSubCategoryOptions ( ) { $ arResult = [ ] ; $ obCategoryList = CategoryCollection :: make ( ) -> tree ( ) ; if ( $ obCategoryList -> isEmpty ( ) ) { return $ arResult ; } $ arResult = $ this -> getCategoryMenuOptions ( $ obCategoryList ) ; return $ arResult ; } | Get subcategories list |
45,781 | protected function getCategoryMenuOptions ( $ obCategoryList ) { if ( empty ( $ obCategoryList ) || $ obCategoryList -> isEmpty ( ) ) { return null ; } $ arResult = [ ] ; foreach ( $ obCategoryList as $ obCategory ) { if ( $ obCategory -> children -> isEmpty ( ) ) { $ arResult [ $ obCategory -> id ] = $ obCategory -> n... | Get option array for category |
45,782 | protected function afterCreate ( ) { parent :: afterCreate ( ) ; ProductListStore :: instance ( ) -> sorting -> clear ( ProductListStore :: SORT_NEW ) ; ProductListStore :: instance ( ) -> sorting -> clear ( ProductListStore :: SORT_NO ) ; } | After create event handler |
45,783 | protected function processOfferAfterDelete ( ) { $ obOfferList = $ this -> obElement -> offer ; if ( $ obOfferList -> isEmpty ( ) ) { return ; } foreach ( $ obOfferList as $ obOffer ) { $ obOffer -> active = false ; $ obOffer -> save ( ) ; } } | Set active = false in offer list after product was removed |
45,784 | protected function checkCategoryIDField ( ) { if ( ! $ this -> isFieldChanged ( 'category_id' ) ) { return ; } ProductListStore :: instance ( ) -> category -> clear ( $ this -> obElement -> category_id ) ; ProductListStore :: instance ( ) -> category -> clear ( ( int ) $ this -> obElement -> getOriginal ( 'category_id'... | Check product category_id field if it was changed then clear cache |
45,785 | protected function checkBrandIDField ( ) { if ( $ this -> obElement -> getOriginal ( 'brand_id' ) == $ this -> obElement -> brand_id ) { return ; } ProductListStore :: instance ( ) -> brand -> clear ( $ this -> obElement -> brand_id ) ; ProductListStore :: instance ( ) -> brand -> clear ( ( int ) $ this -> obElement ->... | Check product brand_id field if it was changed then clear cache |
45,786 | protected function clearCategoryProductCount ( $ iCategoryID ) { $ obCategoryItem = CategoryItem :: make ( $ iCategoryID ) ; if ( $ obCategoryItem -> isNotEmpty ( ) ) { $ obCategoryItem -> clearProductCount ( ) ; } } | Clear product count cache in category item |
45,787 | public function clearProductCount ( ) { $ arCacheTag = [ static :: class ] ; $ sCacheKey = 'product_count_' . $ this -> id ; CCache :: clear ( $ arCacheTag , $ sCacheKey ) ; ItemStorage :: clear ( static :: class , $ this -> id ) ; $ obParentItem = $ this -> parent ; if ( $ obParentItem -> isEmpty ( ) ) { return ; } $ ... | Clear product count cache |
45,788 | protected function getSlugList ( ) : array { $ arResult = [ $ this -> slug ] ; $ obParentCategory = $ this -> parent ; while ( $ obParentCategory -> isNotEmpty ( ) ) { $ arResult [ ] = $ obParentCategory -> slug ; $ obParentCategory = $ obParentCategory -> parent ; } return $ arResult ; } | Get array with categories slugs |
45,789 | protected function getProductCountAttribute ( ) { $ iProductCount = $ this -> getAttribute ( 'product_count' ) ; if ( $ iProductCount !== null ) { return $ iProductCount ; } $ arCacheTag = [ static :: class ] ; $ sCacheKey = 'product_count_' . $ this -> id ; $ iProductCount = CCache :: get ( $ arCacheTag , $ sCacheKey ... | Get product count for category |
45,790 | protected function getMenuTypeObject ( $ sType ) { switch ( $ sType ) { case CategoryMenuType :: MENU_TYPE : return new CategoryMenuType ( ) ; case CatalogMenuType :: MENU_TYPE : return new CatalogMenuType ( ) ; case AllCategoriesMenuType :: MENU_TYPE : return new AllCategoriesMenuType ( ) ; default : return null ; } } | Get new menu object by type value |
45,791 | protected function checkProductIDField ( ) { $ iOriginalProductID = $ this -> obElement -> getOriginal ( 'product_id' ) ; $ iProductID = $ this -> obElement -> getAttribute ( 'product_id' ) ; if ( $ iOriginalProductID == $ iProductID ) { return ; } if ( ! empty ( $ iOriginalProductID ) ) { $ this -> clearProductItemCac... | Clear cache if product ID field changed |
45,792 | protected function addEventListener ( ) { Event :: subscribe ( ExtendMenuHandler :: class ) ; Event :: subscribe ( BrandModelHandler :: class ) ; Event :: subscribe ( CategoryModelHandler :: class ) ; Event :: subscribe ( CurrencyModelHandler :: class ) ; Event :: subscribe ( OfferModelHandler :: class ) ; Event :: sub... | Add event listeners |
45,793 | protected function setBrandField ( ) { $ sBrandID = array_get ( $ this -> arImportData , 'brand_id' ) ; if ( $ sBrandID === null ) { return ; } $ obBrand = Brand :: getByExternalID ( $ sBrandID ) -> first ( ) ; if ( empty ( $ obBrand ) ) { $ this -> arImportData [ 'brand_id' ] = null ; } else { $ this -> arImportData [... | Set brand_id filed value |
45,794 | protected function setCategoryField ( ) { $ sCategoryID = array_get ( $ this -> arImportData , 'category_id' ) ; if ( $ sCategoryID === null ) { return ; } $ obCategory = Category :: getByExternalID ( $ sCategoryID ) -> first ( ) ; if ( empty ( $ obCategory ) ) { $ this -> arImportData [ 'category_id' ] = null ; } else... | Set category_id filed value |
45,795 | protected function initAdditionalCategoryField ( ) { $ sCategoryList = array_get ( $ this -> arImportData , 'additional_category' ) ; if ( $ sCategoryList === null ) { return ; } $ arCategoryIDList = explode ( ',' , $ sCategoryList ) ; foreach ( $ arCategoryIDList as $ iKey => & $ iCategoryID ) { $ iCategoryID = trim (... | Init additional category ID list |
45,796 | protected function syncAdditionalCategoryList ( ) { if ( $ this -> arAdditionalCategoryList === null ) { return ; } $ this -> obModel -> additional_category ( ) -> sync ( $ this -> arAdditionalCategoryList ) ; } | Sync link product with additional categories |
45,797 | public function getByCategoryID ( $ iCategoryID ) { if ( empty ( $ iCategoryID ) ) { return [ ] ; } $ this -> addCategoryData ( $ iCategoryID , true ) ; $ this -> arResult = array_reverse ( $ this -> arResult ) ; return $ this -> arResult ; } | Get breadcrumbs for category page by category id |
45,798 | public function getByTagID ( $ iTagID ) { if ( ! PluginManager :: instance ( ) -> hasPlugin ( 'Lovata.TagsShopaholic' ) || empty ( $ iTagID ) ) { return $ this -> arResult ; } $ obTagItem = \ Lovata \ TagsShopaholic \ Classes \ Item \ TagItem :: make ( $ iTagID ) ; if ( $ obTagItem -> isEmpty ( ) ) { return $ this -> a... | Get breadcrumbs for tag page by tag ID |
45,799 | public function getByProductID ( $ iProductID ) { if ( empty ( $ iProductID ) ) { return $ this -> arResult ; } $ obProductItem = ProductItem :: make ( $ iProductID ) ; if ( $ obProductItem -> isEmpty ( ) ) { return $ this -> arResult ; } $ this -> arResult [ ] = [ 'id' => $ obProductItem -> id , 'name' => $ obProductI... | Get breadcrumbs by product ID |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.