idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
16,000 | public function replaceWith ( $ nodes ) { $ first = TRUE ; foreach ( $ this -> nodes as $ node ) { if ( ! $ first ) { if ( is_array ( $ nodes ) ) { $ nodes = new NodeCollection ( $ nodes , FALSE ) ; } $ nodes = clone $ nodes ; } $ node -> replaceWith ( $ nodes ) ; $ first = FALSE ; } return $ this ; } | Replace each node in the set of matched nodes with the provided new nodes and return the set of nodes that was removed . |
16,001 | public function replaceAll ( $ targets ) { if ( $ targets instanceof Node ) { $ targets -> replaceWith ( $ this -> nodes ) ; } elseif ( $ targets instanceof NodeCollection || is_array ( $ targets ) ) { $ first = TRUE ; foreach ( $ targets as $ target ) { $ target -> replaceWith ( $ first ? $ this -> nodes : clone $ this ) ; $ first = FALSE ; } } return $ this ; } | Replace each target node with the set of matched nodes . |
16,002 | public function add ( $ nodes ) { if ( $ nodes instanceof Node ) { $ this -> nodes [ ] = $ nodes ; } elseif ( $ nodes instanceof NodeCollection ) { $ this -> nodes = array_merge ( $ this -> nodes , $ nodes -> nodes ) ; } elseif ( is_array ( $ nodes ) ) { $ this -> nodes = array_merge ( $ this -> nodes , $ nodes ) ; } else { throw new \ InvalidArgumentException ( ) ; } $ this -> nodes = static :: sortUnique ( $ this -> nodes ) ; return $ this ; } | Add nodes to this collection . |
16,003 | public function enterNode ( Node $ node ) { if ( $ node instanceof UseUse ) { $ this -> imports [ ] = $ node -> name -> toString ( ) ; } return $ node ; } | Enter the node and record the import . |
16,004 | protected function deleteHooks ( $ module ) { $ query = ModuleHookQuery :: create ( ) ; if ( null !== $ module ) { $ query -> filterByModule ( $ module ) -> delete ( ) ; } else { $ query -> deleteAll ( ) ; } $ query = IgnoredModuleHookQuery :: create ( ) ; if ( null !== $ module ) { $ query -> filterByModule ( $ module ) -> delete ( ) ; } else { $ query -> deleteAll ( ) ; } } | Delete module hooks |
16,005 | public function getFormDefinedUrl ( $ parameterName , $ default = null ) { $ formDefinedUrl = $ this -> form -> get ( $ parameterName ) -> getData ( ) ; if ( empty ( $ formDefinedUrl ) ) { if ( $ default === null ) { $ default = ConfigQuery :: read ( 'base_url' , '/' ) ; } $ formDefinedUrl = $ default ; } return URL :: getInstance ( ) -> absoluteUrl ( $ formDefinedUrl ) ; } | Build an absolute URL using the value of a form parameter . |
16,006 | private function findNextPrev ( LoopResultRow $ loopResultRow , $ imageId , $ imageType , $ currentPosition ) { if ( $ imageType == 'product' ) { $ imageRow = ProductImageQuery :: create ( ) -> filterById ( $ imageId ) -> findOne ( ) ; if ( $ imageRow != null ) { $ previousQuery = ProductImageQuery :: create ( ) -> filterByProductId ( $ imageRow -> getProductId ( ) ) -> filterByPosition ( $ currentPosition , Criteria :: LESS_THAN ) ; $ nextQuery = ProductImageQuery :: create ( ) -> filterByProductId ( $ imageRow -> getProductId ( ) ) -> filterByPosition ( $ currentPosition , Criteria :: GREATER_THAN ) ; if ( ! $ this -> getBackendContext ( ) ) { $ previousQuery -> useProductQuery ( ) -> filterByVisible ( true ) -> endUse ( ) ; $ previousQuery -> useProductQuery ( ) -> filterByVisible ( true ) -> endUse ( ) ; } $ previous = $ previousQuery -> orderByPosition ( Criteria :: DESC ) -> findOne ( ) ; $ next = $ nextQuery -> orderByPosition ( Criteria :: ASC ) -> findOne ( ) ; $ loopResultRow -> set ( "HAS_PREVIOUS" , $ previous != null ? 1 : 0 ) -> set ( "HAS_NEXT" , $ next != null ? 1 : 0 ) -> set ( "PREVIOUS" , $ previous != null ? $ previous -> getId ( ) : - 1 ) -> set ( "NEXT" , $ next != null ? $ next -> getId ( ) : - 1 ) ; return ; } } $ loopResultRow -> set ( "HAS_PREVIOUS" , 0 ) -> set ( "HAS_NEXT" , 0 ) ; } | Set the fields HAS_PREVIOUS HAS_NEXT PREVIOUS NEXT for the image loop |
16,007 | public function update ( BrandUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ brand = BrandQuery :: create ( ) -> findPk ( $ event -> getBrandId ( ) ) ) { $ brand -> setDispatcher ( $ dispatcher ) ; $ brand -> setVisible ( $ event -> getVisible ( ) ) -> setLogoImageId ( \ intval ( $ event -> getLogoImageId ( ) ) == 0 ? null : $ event -> getLogoImageId ( ) ) -> setLocale ( $ event -> getLocale ( ) ) -> setTitle ( $ event -> getTitle ( ) ) -> setDescription ( $ event -> getDescription ( ) ) -> setChapo ( $ event -> getChapo ( ) ) -> setPostscriptum ( $ event -> getPostscriptum ( ) ) -> save ( ) ; $ event -> setBrand ( $ brand ) ; } } | process update brand |
16,008 | public function toggleVisibility ( BrandToggleVisibilityEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ brand = $ event -> getBrand ( ) ; $ brand -> setDispatcher ( $ dispatcher ) -> setVisible ( ! $ brand -> getVisible ( ) ) -> save ( ) ; $ event -> setBrand ( $ brand ) ; } | Toggle Brand visibility |
16,009 | public function viewCheck ( ViewCheckEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( $ event -> getView ( ) == 'brand' ) { $ brand = BrandQuery :: create ( ) -> filterById ( $ event -> getViewId ( ) ) -> filterByVisible ( 1 ) -> count ( ) ; if ( $ brand == 0 ) { $ dispatcher -> dispatch ( TheliaEvents :: VIEW_BRAND_ID_NOT_VISIBLE , $ event ) ; } } } | Check if is a brand view and if brand_id is visible |
16,010 | public function addLeftLink ( string $ name , string $ link = null , bool $ ajax = false ) : Item { return $ this -> leftItems [ ] = new Item ( $ name , [ 'link' => $ link ?? '#' , 'ajax' => $ ajax ] ) ; } | Prida link do dockbaru vlevo |
16,011 | public function addRightLink ( string $ name , string $ link = null , bool $ ajax = false ) : Item { return $ this -> rightItems [ ] = new Item ( $ name , [ 'link' => $ link ?? '#' , 'ajax' => $ ajax ] ) ; } | Prida link do dockbaru vpravo |
16,012 | public function isLinkAllowed ( string $ link ) : bool { if ( isset ( $ this -> allowedLinks [ $ link ] ) ) { return true ; } else { $ pos = strrpos ( $ link , ':' ) ; $ link = substr ( $ link , 0 , ( $ pos + 1 ) ) ; return isset ( $ this -> allowedLinks [ $ link ] ) ; } } | Ma opravneni zobrazit stranku? |
16,013 | private function checkHandlerPermission ( bool $ ajax = true ) : void { if ( ! isset ( $ this -> allowedHandler [ $ this -> presenter -> getSignal ( ) [ 1 ] ] ) ) { $ this -> presenter -> terminate ( ) ; } if ( $ ajax && ! $ this -> presenter -> isAjax ( ) ) { $ this -> presenter -> terminate ( ) ; } } | Zkontroluje opravneni a pokud je nema ukonci aplikaci |
16,014 | public function getAreaForCountry ( Country $ country ) { $ area = null ; if ( null !== $ areaDeliveryModule = AreaDeliveryModuleQuery :: create ( ) -> findByCountryAndModule ( $ country , $ this -> getModuleModel ( ) ) ) { $ area = $ areaDeliveryModule -> getArea ( ) ; } return $ area ; } | Return the first area that matches the given country for the given module |
16,015 | protected function createLexicalVariables ( ) { if ( ! $ this -> hasLexicalVariables ( ) ) { $ this -> lexicalUse = Token :: _use ( ) ; $ this -> lexicalOpenParen = Token :: openParen ( ) ; $ this -> lexicalVariables = new CommaListNode ( ) ; $ this -> lexicalCloseParen = Token :: closeParen ( ) ; $ this -> closeParen -> after ( [ Token :: space ( ) , $ this -> lexicalUse , Token :: space ( ) , $ this -> lexicalOpenParen , $ this -> lexicalVariables , $ this -> lexicalCloseParen , ] ) ; } } | Creates an empty lexical variables list if it does not already exist . |
16,016 | public function loadRelatedAjaxTabAction ( ) { return $ this -> render ( 'ajax/product-related-tab' , array ( 'product_id' => $ this -> getRequest ( ) -> get ( 'product_id' , 0 ) , 'folder_id' => $ this -> getRequest ( ) -> get ( 'folder_id' , 0 ) , 'accessory_category_id' => $ this -> getRequest ( ) -> get ( 'accessory_category_id' , 0 ) ) ) ; } | Related information ajax tab loading |
16,017 | public function getVirtualDocumentListAjaxAction ( $ productId , $ pseId ) { $ this -> checkAuth ( AdminResources :: PRODUCT , array ( ) , AccessManager :: VIEW ) ; $ this -> checkXmlHttpRequest ( ) ; $ selectedId = \ intval ( MetaDataQuery :: getVal ( 'virtual' , MetaData :: PSE_KEY , $ pseId ) ) ; $ documents = ProductDocumentQuery :: create ( ) -> filterByProductId ( $ productId ) -> filterByVisible ( 0 ) -> orderByPosition ( ) -> find ( ) ; $ results = [ ] ; if ( null !== $ documents ) { foreach ( $ documents as $ document ) { $ results [ ] = [ 'id' => $ document -> getId ( ) , 'title' => $ document -> getTitle ( ) , 'file' => $ document -> getFile ( ) , 'selected' => ( $ document -> getId ( ) == $ selectedId ) ] ; } } return $ this -> jsonResponse ( json_encode ( $ results ) ) ; } | return a list of document which will be displayed in AJAX |
16,018 | public function updateAccessoryPositionAction ( ) { $ accessory = AccessoryQuery :: create ( ) -> findPk ( $ this -> getRequest ( ) -> get ( 'accessory_id' , null ) ) ; return $ this -> genericUpdatePositionAction ( $ accessory , TheliaEvents :: PRODUCT_UPDATE_ACCESSORY_POSITION ) ; } | Update accessory position |
16,019 | public function updateContentPositionAction ( ) { $ content = ProductAssociatedContentQuery :: create ( ) -> findPk ( $ this -> getRequest ( ) -> get ( 'content_id' , null ) ) ; return $ this -> genericUpdatePositionAction ( $ content , TheliaEvents :: PRODUCT_UPDATE_CONTENT_POSITION ) ; } | Update related content position |
16,020 | public function setProductTemplateAction ( $ productId ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } $ product = ProductQuery :: create ( ) -> findPk ( $ productId ) ; if ( $ product != null ) { $ template_id = \ intval ( $ this -> getRequest ( ) -> get ( 'template_id' , 0 ) ) ; $ this -> dispatch ( TheliaEvents :: PRODUCT_SET_TEMPLATE , new ProductSetTemplateEvent ( $ product , $ template_id , $ this -> getCurrentEditionCurrency ( ) -> getId ( ) ) ) ; } return $ this -> redirectToEditionTemplate ( ) ; } | Change product template for a given product . |
16,021 | public function updateAttributesAndFeaturesAction ( $ productId ) { $ product = ProductQuery :: create ( ) -> findPk ( $ productId ) ; if ( $ product != null ) { $ featureTemplate = FeatureTemplateQuery :: create ( ) -> filterByTemplateId ( $ product -> getTemplateId ( ) ) -> find ( ) ; if ( $ featureTemplate !== null ) { $ allFeatures = FeatureQuery :: create ( ) -> filterByFeatureTemplate ( $ featureTemplate ) -> find ( ) ; $ updatedFeatures = array ( ) ; $ featureValues = $ this -> getRequest ( ) -> get ( 'feature_value' , array ( ) ) ; foreach ( $ featureValues as $ featureId => $ featureValueList ) { $ event = new FeatureProductDeleteEvent ( $ productId , $ featureId ) ; $ this -> dispatch ( TheliaEvents :: PRODUCT_FEATURE_DELETE_VALUE , $ event ) ; foreach ( $ featureValueList as $ featureValue ) { $ event = new FeatureProductUpdateEvent ( $ productId , $ featureId , $ featureValue ) ; $ this -> dispatch ( TheliaEvents :: PRODUCT_FEATURE_UPDATE_VALUE , $ event ) ; } $ updatedFeatures [ ] = $ featureId ; } $ featureTextValues = $ this -> getRequest ( ) -> get ( 'feature_text_value' , array ( ) ) ; foreach ( $ featureTextValues as $ featureId => $ featureValue ) { $ freeTextFeatureProduct = FeatureProductQuery :: create ( ) -> filterByProductId ( $ productId ) -> filterByIsFreeText ( true ) -> findOneByFeatureId ( $ featureId ) ; if ( \ is_null ( $ freeTextFeatureProduct ) && empty ( $ featureValue ) ) { continue ; } $ event = new FeatureProductUpdateEvent ( $ productId , $ featureId , $ featureValue , true ) ; $ event -> setLocale ( $ this -> getCurrentEditionLocale ( ) ) ; $ this -> dispatch ( TheliaEvents :: PRODUCT_FEATURE_UPDATE_VALUE , $ event ) ; $ updatedFeatures [ ] = $ featureId ; } foreach ( $ allFeatures as $ feature ) { if ( ! \ in_array ( $ feature -> getId ( ) , $ updatedFeatures ) ) { $ event = new FeatureProductDeleteEvent ( $ productId , $ feature -> getId ( ) ) ; $ this -> dispatch ( TheliaEvents :: PRODUCT_FEATURE_DELETE_VALUE , $ event ) ; } } } } if ( $ this -> getRequest ( ) -> get ( 'save_mode' ) == 'stay' ) { return $ this -> redirectToEditionTemplate ( ) ; } return $ this -> redirectToListTemplate ( ) ; } | Update product attributes and features |
16,022 | protected function processSingleProductSaleElementUpdate ( $ data ) { $ event = new ProductSaleElementUpdateEvent ( $ this -> getExistingObject ( ) , $ data [ 'product_sale_element_id' ] ) ; $ event -> setReference ( $ data [ 'reference' ] ) -> setPrice ( $ data [ 'price' ] ) -> setCurrencyId ( $ data [ 'currency' ] ) -> setWeight ( $ data [ 'weight' ] ) -> setQuantity ( $ data [ 'quantity' ] ) -> setSalePrice ( $ data [ 'sale_price' ] ) -> setOnsale ( $ data [ 'onsale' ] ) -> setIsnew ( $ data [ 'isnew' ] ) -> setIsdefault ( $ data [ 'isdefault' ] ) -> setEanCode ( $ data [ 'ean_code' ] ) -> setTaxRuleId ( $ data [ 'tax_rule' ] ) -> setFromDefaultCurrency ( $ data [ 'use_exchange_rate' ] ) ; $ this -> dispatch ( TheliaEvents :: PRODUCT_UPDATE_PRODUCT_SALE_ELEMENT , $ event ) ; if ( null !== $ changedObject = $ event -> getProductSaleElement ( ) ) { $ this -> adminLogAppend ( $ this -> resourceCode , AccessManager :: UPDATE , sprintf ( "Product Sale Element (ID %s) for product reference %s modified" , $ changedObject -> getId ( ) , $ event -> getProduct ( ) -> getRef ( ) ) , $ changedObject -> getId ( ) ) ; } } | Process a single PSE update using form data array . |
16,023 | protected function processProductSaleElementUpdate ( $ changeForm ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } try { $ form = $ this -> validateForm ( $ changeForm , "POST" ) ; $ data = $ form -> getData ( ) ; if ( \ is_array ( $ data [ 'product_sale_element_id' ] ) ) { $ tmp_data = array ( 'tax_rule' => $ data [ 'tax_rule' ] , 'currency' => $ data [ 'currency' ] , 'use_exchange_rate' => $ data [ 'use_exchange_rate' ] , ) ; $ count = \ count ( $ data [ 'product_sale_element_id' ] ) ; for ( $ idx = 0 ; $ idx < $ count ; $ idx ++ ) { $ tmp_data [ 'product_sale_element_id' ] = $ pse_id = $ data [ 'product_sale_element_id' ] [ $ idx ] ; $ tmp_data [ 'reference' ] = $ data [ 'reference' ] [ $ idx ] ; $ tmp_data [ 'price' ] = $ data [ 'price' ] [ $ idx ] ; $ tmp_data [ 'weight' ] = $ data [ 'weight' ] [ $ idx ] ; $ tmp_data [ 'quantity' ] = $ data [ 'quantity' ] [ $ idx ] ; $ tmp_data [ 'sale_price' ] = $ data [ 'sale_price' ] [ $ idx ] ; $ tmp_data [ 'onsale' ] = isset ( $ data [ 'onsale' ] [ $ idx ] ) ? 1 : 0 ; $ tmp_data [ 'isnew' ] = isset ( $ data [ 'isnew' ] [ $ idx ] ) ? 1 : 0 ; $ tmp_data [ 'isdefault' ] = $ data [ 'default_pse' ] == $ pse_id ; $ tmp_data [ 'ean_code' ] = $ data [ 'ean_code' ] [ $ idx ] ; $ this -> processSingleProductSaleElementUpdate ( $ tmp_data ) ; } } else { $ this -> processSingleProductSaleElementUpdate ( $ data ) ; } if ( $ this -> getRequest ( ) -> get ( 'save_mode' ) == 'stay' ) { return $ this -> redirectToEditionTemplate ( ) ; } return $ this -> generateSuccessRedirect ( $ changeForm ) ; } catch ( FormValidationException $ ex ) { $ error_msg = $ this -> createStandardFormValidationErrorMessage ( $ ex ) ; } catch ( \ Exception $ ex ) { $ error_msg = $ ex -> getMessage ( ) ; } $ this -> setupFormErrorContext ( $ this -> getTranslator ( ) -> trans ( "ProductSaleElement modification" ) , $ error_msg , $ changeForm , $ ex ) ; return $ this -> renderEditionTemplate ( ) ; } | Change a product sale element |
16,024 | public function buildCombinationsAction ( ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } $ changeForm = $ this -> createForm ( AdminForm :: PRODUCT_COMBINATION_GENERATION ) ; try { $ form = $ this -> validateForm ( $ changeForm , "POST" ) ; $ data = $ form -> getData ( ) ; $ combinations = $ attributes_av_list = $ tmp = array ( ) ; foreach ( $ data [ 'attribute_av' ] as $ item ) { list ( $ attribute_id , $ attribute_av_id ) = explode ( ':' , $ item ) ; if ( ! isset ( $ attributes_av_list [ $ attribute_id ] ) ) { $ attributes_av_list [ $ attribute_id ] = array ( ) ; } $ attributes_av_list [ $ attribute_id ] [ ] = $ attribute_av_id ; } $ this -> combine ( $ attributes_av_list , $ combinations , $ tmp ) ; $ event = new ProductCombinationGenerationEvent ( $ this -> getExistingObject ( ) , $ data [ 'currency' ] , $ combinations ) ; $ event -> setReference ( $ data [ 'reference' ] == null ? '' : $ data [ 'reference' ] ) -> setPrice ( $ data [ 'price' ] == null ? 0 : $ data [ 'price' ] ) -> setWeight ( $ data [ 'weight' ] == null ? 0 : $ data [ 'weight' ] ) -> setQuantity ( $ data [ 'quantity' ] == null ? 0 : $ data [ 'quantity' ] ) -> setSalePrice ( $ data [ 'sale_price' ] == null ? 0 : $ data [ 'sale_price' ] ) -> setOnsale ( $ data [ 'onsale' ] == null ? false : $ data [ 'onsale' ] ) -> setIsnew ( $ data [ 'isnew' ] == null ? false : $ data [ 'isnew' ] ) -> setEanCode ( $ data [ 'ean_code' ] == null ? '' : $ data [ 'ean_code' ] ) ; $ this -> dispatch ( TheliaEvents :: PRODUCT_COMBINATION_GENERATION , $ event ) ; $ this -> adminLogAppend ( $ this -> resourceCode , AccessManager :: CREATE , sprintf ( "Combination generation for product reference %s" , $ event -> getProduct ( ) -> getRef ( ) ) , $ event -> getProduct ( ) -> getId ( ) ) ; return $ this -> generateSuccessRedirect ( $ changeForm ) ; } catch ( FormValidationException $ ex ) { $ error_msg = $ this -> createStandardFormValidationErrorMessage ( $ ex ) ; } catch ( \ Exception $ ex ) { $ error_msg = $ ex -> getMessage ( ) ; } $ this -> setupFormErrorContext ( $ this -> getTranslator ( ) -> trans ( "Combination builder" ) , $ error_msg , $ changeForm , $ ex ) ; return $ this -> renderEditionTemplate ( ) ; } | Build combinations from the combination output builder |
16,025 | public function priceCalculator ( ) { $ return_price = 0 ; $ price = \ floatval ( $ this -> getRequest ( ) -> query -> get ( 'price' , 0 ) ) ; $ product_id = \ intval ( $ this -> getRequest ( ) -> query -> get ( 'product_id' , 0 ) ) ; $ action = $ this -> getRequest ( ) -> query -> get ( 'action' , '' ) ; $ convert = \ intval ( $ this -> getRequest ( ) -> query -> get ( 'convert_from_default_currency' , 0 ) ) ; if ( null !== $ product = ProductQuery :: create ( ) -> findPk ( $ product_id ) ) { if ( $ action == 'to_tax' ) { $ return_price = $ this -> computePrice ( $ price , 'without_tax' , $ product ) ; } elseif ( $ action == 'from_tax' ) { $ return_price = $ this -> computePrice ( $ price , 'with_tax' , $ product ) ; } else { $ return_price = $ price ; } if ( $ convert != 0 ) { $ return_price = $ price * Currency :: getDefaultCurrency ( ) -> getRate ( ) ; } } return new JsonResponse ( array ( 'result' => $ this -> formatPrice ( $ return_price ) ) ) ; } | Invoked through Ajax ; this method calculates the taxed price from the untaxed price and vice versa . |
16,026 | public function loadConvertedPrices ( ) { $ product_sale_element_id = \ intval ( $ this -> getRequest ( ) -> get ( 'product_sale_element_id' , 0 ) ) ; $ currency_id = \ intval ( $ this -> getRequest ( ) -> get ( 'currency_id' , 0 ) ) ; $ price_with_tax = $ price_without_tax = $ sale_price_with_tax = $ sale_price_without_tax = 0 ; if ( null !== $ pse = ProductSaleElementsQuery :: create ( ) -> findPk ( $ product_sale_element_id ) ) { if ( $ currency_id > 0 && $ currency_id != Currency :: getDefaultCurrency ( ) -> getId ( ) && null !== $ currency = CurrencyQuery :: create ( ) -> findPk ( $ currency_id ) ) { $ productPrice = ProductPriceQuery :: create ( ) -> filterByCurrency ( Currency :: getDefaultCurrency ( ) ) -> filterByProductSaleElementsId ( $ product_sale_element_id ) -> findOne ( ) ; if ( null !== $ productPrice ) { $ price_without_tax = $ productPrice -> getPrice ( ) * $ currency -> getRate ( ) ; $ sale_price_without_tax = $ productPrice -> getPromoPrice ( ) * $ currency -> getRate ( ) ; } } if ( null !== $ product = $ pse -> getProduct ( ) ) { $ price_with_tax = $ this -> computePrice ( $ price_without_tax , 'with_tax' , $ product ) ; $ sale_price_with_tax = $ this -> computePrice ( $ sale_price_without_tax , 'with_tax' , $ product ) ; } } return new JsonResponse ( array ( 'price_with_tax' => $ this -> formatPrice ( $ price_with_tax ) , 'price_without_tax' => $ this -> formatPrice ( $ price_without_tax ) , 'sale_price_with_tax' => $ this -> formatPrice ( $ sale_price_with_tax ) , 'sale_price_without_tax' => $ this -> formatPrice ( $ sale_price_without_tax ) ) ) ; } | Calculate all prices |
16,027 | public function parse ( $ nodes , $ filename = NULL ) { $ this -> nodes = $ nodes ; $ this -> filename = $ filename ; $ this -> position = 0 ; $ this -> length = count ( $ nodes ) ; $ this -> operators = [ $ this -> sentinel ] ; $ this -> operands = [ ] ; $ this -> E ( ) ; if ( $ this -> next ( ) ) { $ next = $ this -> next ( ) ; throw new ParserException ( $ this -> filename , $ next -> getLineNumber ( ) , $ next -> getColumnNumber ( ) , "invalid expression" ) ; } return self :: arrayLast ( $ this -> operands ) ; } | Parse the expression nodes into a tree . |
16,028 | public function changeValuesAction ( ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } $ variables = $ this -> getRequest ( ) -> get ( 'variable' , array ( ) ) ; foreach ( $ variables as $ id => $ value ) { $ event = new ConfigUpdateEvent ( $ id ) ; $ event -> setValue ( $ value ) ; $ this -> dispatch ( TheliaEvents :: CONFIG_SETVALUE , $ event ) ; } return $ this -> generateRedirectFromRoute ( 'admin.configuration.variables.default' ) ; } | Change values modified directly from the variable list |
16,029 | public function isExpired ( ) { $ ret = true ; $ now = new \ DateTime ( ) ; if ( $ this -> expirationDate > $ now ) { $ ret = false ; } return $ ret ; } | Check if the Coupon is already Expired |
16,030 | public function drawBackOfficeInputs ( ) { return $ this -> facade -> getParser ( ) -> render ( 'coupon/type-fragments/remove-x.html' , [ 'label' => $ this -> getInputName ( ) , 'fieldId' => self :: AMOUNT_FIELD_NAME , 'fieldName' => $ this -> makeCouponFieldName ( self :: AMOUNT_FIELD_NAME ) , 'value' => $ this -> amount ] ) ; } | Draw the input displayed in the BackOffice allowing Admin to set its Coupon effect Override this method to do something useful |
16,031 | protected function getCouponFieldValue ( $ fieldName , $ data , $ defaultValue = null ) { if ( isset ( $ data [ self :: COUPON_DATASET_NAME ] [ $ fieldName ] ) ) { return $ this -> checkCouponFieldValue ( $ fieldName , $ data [ self :: COUPON_DATASET_NAME ] [ $ fieldName ] ) ; } elseif ( null !== $ defaultValue ) { return $ defaultValue ; } else { throw new \ InvalidArgumentException ( sprintf ( "The coupon field name %s was not found in the coupon form" , $ fieldName ) ) ; } } | A helper to get the value of a standard field name |
16,032 | public function getEffects ( $ data ) { $ effects = [ ] ; foreach ( $ this -> getFieldList ( ) as $ fieldName ) { $ effects [ $ fieldName ] = $ this -> getCouponFieldValue ( $ fieldName , $ data ) ; } return $ effects ; } | Create the effect array from the list of fields |
16,033 | public function verifyAccount ( $ value , ExecutionContextInterface $ context ) { if ( $ value == 1 ) { $ data = $ context -> getRoot ( ) -> getData ( ) ; if ( false === $ data [ 'password' ] || ( empty ( $ data [ 'password' ] ) && '0' != $ data [ 'password' ] ) ) { $ context -> getViolations ( ) -> add ( new ConstraintViolation ( Translator :: getInstance ( ) -> trans ( 'This value should not be blank.' ) , 'account_password' , array ( ) , $ context -> getRoot ( ) , 'children[password].data' , 'propertyPath' ) ) ; } } } | If the user select Yes I have a password we check the password . |
16,034 | public function verifyExistingEmail ( $ value , ExecutionContextInterface $ context ) { $ data = $ context -> getRoot ( ) -> getData ( ) ; if ( $ data [ "account" ] == 0 ) { $ customer = CustomerQuery :: create ( ) -> findOneByEmail ( $ value ) ; if ( $ customer ) { $ context -> addViolation ( Translator :: getInstance ( ) -> trans ( "A user already exists with this email address. Please login or if you've forgotten your password, go to Reset Your Password." ) ) ; } } } | If the user select I am a new customer we make sure is email address does not exit in the database . |
16,035 | public function exportChangePosition ( UpdatePositionEvent $ updatePositionEvent , $ eventName , EventDispatcherInterface $ dispatcher ) { $ this -> handler -> getExport ( $ updatePositionEvent -> getObjectId ( ) , true ) ; $ this -> genericUpdatePosition ( new ExportQuery , $ updatePositionEvent , $ dispatcher ) ; } | Handle export change position event |
16,036 | public function exportCategoryChangePosition ( UpdatePositionEvent $ updatePositionEvent , $ eventName , EventDispatcherInterface $ dispatcher ) { $ this -> handler -> getCategory ( $ updatePositionEvent -> getObjectId ( ) , true ) ; $ this -> genericUpdatePosition ( new ExportCategoryQuery , $ updatePositionEvent , $ dispatcher ) ; } | Handle export category change position event |
16,037 | public function getPricesByCurrency ( Currency $ currency , $ discount = 0 ) { $ defaultCurrency = Currency :: getDefaultCurrency ( ) ; $ productPrice = ProductPriceQuery :: create ( ) -> filterByProductSaleElementsId ( $ this -> getId ( ) ) -> filterByCurrencyId ( $ currency -> getId ( ) ) -> findOne ( ) ; if ( null === $ productPrice || $ productPrice -> getFromDefaultCurrency ( ) ) { $ productPrice = ProductPriceQuery :: create ( ) -> filterByProductSaleElementsId ( $ this -> getId ( ) ) -> filterByCurrencyId ( $ defaultCurrency -> getId ( ) ) -> findOne ( ) ; if ( null !== $ productPrice ) { $ price = $ productPrice -> getPrice ( ) * $ currency -> getRate ( ) / $ defaultCurrency -> getRate ( ) ; $ promoPrice = $ productPrice -> getPromoPrice ( ) * $ currency -> getRate ( ) / $ defaultCurrency -> getRate ( ) ; } else { throw new \ RuntimeException ( 'Cannot find product prices for currency id: `' . $ currency -> getId ( ) . '`' ) ; } } else { $ price = $ productPrice -> getPrice ( ) ; $ promoPrice = $ productPrice -> getPromoPrice ( ) ; } if ( $ discount > 0 ) { $ price = $ price * ( 1 - ( $ discount / 100 ) ) ; $ promoPrice = $ promoPrice * ( 1 - ( $ discount / 100 ) ) ; } $ productPriceTools = new ProductPriceTools ( $ price , $ promoPrice ) ; return $ productPriceTools ; } | Get product prices for a specific currency . |
16,038 | public function getAllFiles ( $ sources ) { $ files = array ( ) ; foreach ( $ sources as $ source ) { if ( ! is_dir ( $ source ) ) { $ files [ ] = $ source ; continue ; } $ recursiveFiles = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ source ) ) ; foreach ( $ recursiveFiles as $ file ) { if ( $ file -> isDir ( ) ) { continue ; } $ path = $ file -> getPathname ( ) ; $ info = pathinfo ( basename ( $ path ) ) ; if ( array_key_exists ( 'extension' , $ info ) && $ info [ 'extension' ] == 'php' ) { $ files [ ] = $ path ; } } } return $ files ; } | Check how of list is dir and find all files . |
16,039 | protected function addStandardModuleTemplatesToParserEnvironment ( $ parser , $ module ) { $ stdTpls = TemplateDefinition :: getStandardTemplatesSubdirsIterator ( ) ; foreach ( $ stdTpls as $ templateType => $ templateSubdirName ) { $ this -> addModuleTemplateToParserEnvironment ( $ parser , $ module , $ templateType , $ templateSubdirName ) ; } } | Add all module s standard templates to the parser environment |
16,040 | protected function addModuleTemplateToParserEnvironment ( $ parser , $ module , $ templateType , $ templateSubdirName ) { $ templateDirectory = $ module -> getAbsoluteTemplateDirectoryPath ( $ templateSubdirName ) ; try { $ templateDirBrowser = new \ DirectoryIterator ( $ templateDirectory ) ; $ code = ucfirst ( $ module -> getCode ( ) ) ; foreach ( $ templateDirBrowser as $ templateDirContent ) { if ( $ templateDirContent -> isDir ( ) && ! $ templateDirContent -> isDot ( ) ) { $ parser -> addMethodCall ( 'addTemplateDirectory' , array ( $ templateType , $ templateDirContent -> getFilename ( ) , $ templateDirContent -> getPathName ( ) , $ code ) ) ; } } } catch ( \ UnexpectedValueException $ ex ) { } } | Add a module template directory to the parser environment |
16,041 | public function viewCheck ( ViewCheckEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( $ event -> getView ( ) == 'folder' ) { $ folder = FolderQuery :: create ( ) -> filterById ( $ event -> getViewId ( ) ) -> filterByVisible ( 1 ) -> count ( ) ; if ( $ folder == 0 ) { $ dispatcher -> dispatch ( TheliaEvents :: VIEW_FOLDER_ID_NOT_VISIBLE , $ event ) ; } } } | Check if is a folder view and if folder_id is visible |
16,042 | protected function setDefault ( int $ localeId ) : void { $ this -> orm -> locales -> getById ( $ localeId ) -> setDefault ( ) ; } | Nastavi vychozi jazyk |
16,043 | protected function setAllowed ( array $ allowed ) : void { $ locales = $ this -> orm -> locales -> findAll ( ) ; foreach ( $ locales as $ locale ) { if ( in_array ( $ locale -> id , $ allowed ) ) { $ locale -> allowed = true ; } else { $ locale -> allowed = false ; } $ this -> orm -> persist ( $ locale ) ; } $ this -> orm -> flush ( ) ; } | Nastavi povolene jazyky |
16,044 | public function checkWritableI18nDirectory ( $ dir ) { if ( file_exists ( $ dir ) ) { return is_writable ( $ dir ) ; } $ parentDir = dirname ( $ dir ) ; return file_exists ( $ parentDir ) && is_writable ( $ parentDir ) ; } | Check if a directory is writable or if the parent directory is writable |
16,045 | public function make ( array $ config ) { Arr :: requires ( $ config , [ 'token' ] ) ; $ client = new Client ( ) ; return new HipchatGateway ( $ client , $ config ) ; } | Create a new hipchat gateway instance . |
16,046 | protected function parse ( $ body ) { $ disableEntities = libxml_disable_entity_loader ( true ) ; $ internalErrors = libxml_use_internal_errors ( true ) ; try { $ xml = new SimpleXMLElement ( ( string ) $ body ? : '<root />' , LIBXML_NONET ) ; return json_decode ( json_encode ( $ xml ) , true ) ; } catch ( Exception $ e ) { } catch ( Throwable $ e ) { } finally { libxml_disable_entity_loader ( $ disableEntities ) ; libxml_use_internal_errors ( $ internalErrors ) ; } } | Parse an xml string to an array . |
16,047 | public function getZipCodeRE ( ) { $ zipCodeFormat = $ this -> getZipCodeFormat ( ) ; if ( empty ( $ zipCodeFormat ) ) { return null ; } $ zipCodeRE = preg_replace ( "/\\s+/" , ' ' , $ zipCodeFormat ) ; $ trans = [ "N" => "\\d" , "L" => "[a-zA-Z]" , "C" => ".+" , " " => " +" ] ; $ zipCodeRE = "#^" . strtr ( $ zipCodeRE , $ trans ) . "$#" ; return $ zipCodeRE ; } | get a regex pattern according to the zip code format field to match a zip code for this country . |
16,048 | public function getAreaId ( ) { $ firstAreaCountry = CountryAreaQuery :: create ( ) -> findOneByCountryId ( $ this -> getId ( ) ) ; if ( null !== $ firstAreaCountry ) { return $ firstAreaCountry -> getAreaId ( ) ; } return null ; } | This method ensure backward compatibility to Thelia 2 . 1 where a country belongs to one and only one shipping zone . |
16,049 | public static function getDefaultCountry ( ) { if ( null === self :: $ defaultCountry ) { self :: $ defaultCountry = CountryQuery :: create ( ) -> findOneByByDefault ( true ) ; if ( null === self :: $ defaultCountry ) { throw new \ LogicException ( Translator :: getInstance ( ) -> trans ( "Cannot find a default country. Please define one." ) ) ; } } return self :: $ defaultCountry ; } | Return the default country |
16,050 | public static function getShopLocation ( ) { $ countryId = ConfigQuery :: getStoreCountry ( ) ; if ( empty ( $ countryId ) ) { return self :: getDefaultCountry ( ) ; } $ shopCountry = CountryQuery :: create ( ) -> findPk ( $ countryId ) ; if ( $ shopCountry === null ) { throw new \ LogicException ( Translator :: getInstance ( ) -> trans ( "Cannot find the shop country. Please select a shop country." ) ) ; } return $ shopCountry ; } | Return the shop country |
16,051 | protected function getAliasColumn ( ) { $ strColNameAlias = $ this -> get ( 'tag_alias' ) ; if ( $ this -> isTreePicker ( ) || ! $ strColNameAlias ) { $ strColNameAlias = $ this -> getIdColumn ( ) ; } return $ strColNameAlias ; } | Determine the correct alias column to use . |
16,052 | private function setDataForItem ( $ itemId , $ tags , $ thisExisting ) { if ( $ tags === null ) { $ tagIds = [ ] ; } else { $ tagIds = \ array_keys ( $ tags ) ; } $ valuesToRemove = \ array_diff ( $ thisExisting , $ tagIds ) ; if ( $ valuesToRemove ) { $ this -> connection -> createQueryBuilder ( ) -> delete ( 'tl_metamodel_tag_relation' ) -> where ( 'att_id=:attId' ) -> andWhere ( 'item_id=:itemId' ) -> andWhere ( 'value_id IN (:valueIds)' ) -> setParameter ( 'attId' , $ this -> get ( 'id' ) ) -> setParameter ( 'itemId' , $ itemId ) -> setParameter ( 'valueIds' , $ valuesToRemove , Connection :: PARAM_STR_ARRAY ) -> execute ( ) ; } $ valuesToAdd = \ array_diff ( $ tagIds , $ thisExisting ) ; $ insertValues = [ ] ; if ( $ valuesToAdd ) { foreach ( $ valuesToAdd as $ valueId ) { $ insertValues [ ] = [ 'attId' => $ this -> get ( 'id' ) , 'itemId' => $ itemId , 'sorting' => ( int ) $ tags [ $ valueId ] [ 'tag_value_sorting' ] , 'valueId' => $ valueId ] ; } } $ valuesToUpdate = \ array_diff ( $ tagIds , $ valuesToAdd ) ; if ( $ valuesToUpdate ) { $ query = $ this -> connection -> createQueryBuilder ( ) -> update ( 'tl_metamodel_tag_relation' ) -> set ( 'value_sorting' , ':sorting' ) -> where ( 'att_id=:attId' ) -> andWhere ( 'item_id=:itemId' ) -> andWhere ( 'value_id=:valueId' ) -> setParameter ( 'attId' , $ this -> get ( 'id' ) ) -> setParameter ( 'itemId' , $ itemId ) ; foreach ( $ valuesToUpdate as $ valueId ) { if ( ! array_key_exists ( 'tag_value_sorting' , $ tags [ $ valueId ] ) ) { continue ; } $ query -> setParameter ( 'sorting' , ( int ) $ tags [ $ valueId ] [ 'tag_value_sorting' ] ) -> setParameter ( 'valueId' , $ valueId ) -> execute ( ) ; } } return $ insertValues ; } | Update the tag ids for a given item . |
16,053 | public function updateChannel ( $ old , $ new , $ option ) { $ old [ 'release_channel' ] = ! empty ( $ old [ 'release_channel' ] ) ? $ old [ 'release_channel' ] : null ; $ new [ 'release_channel' ] = ! empty ( $ new [ 'release_channel' ] ) ? $ new [ 'release_channel' ] : 'stable' ; $ old [ 'theme_release_channel' ] = ! empty ( $ old [ 'theme_release_channel' ] ) ? $ old [ 'theme_release_channel' ] : null ; $ new [ 'theme_release_channel' ] = ! empty ( $ new [ 'theme_release_channel' ] ) ? $ new [ 'theme_release_channel' ] : 'stable' ; if ( $ old [ 'release_channel' ] !== $ new [ 'release_channel' ] ) { Util \ Option :: deletePluginTransients ( ) ; wp_update_plugins ( ) ; } if ( $ old [ 'theme_release_channel' ] !== $ new [ 'theme_release_channel' ] ) { do_action ( 'Boldgrid\Library\Library\ReleaseChannel\theme_channel_updated' , $ old [ 'theme_release_channel' ] , $ new [ 'theme_release_channel' ] ) ; delete_site_transient ( 'boldgrid_api_data' ) ; delete_site_transient ( 'update_themes' ) ; wp_update_themes ( ) ; } return $ new ; } | Update Plugin Channel . |
16,054 | public function getParentList ( ) { if ( null === $ this -> parentList ) { $ this -> parentList = [ ] ; $ parent = $ this -> getDescriptor ( ) -> getParent ( ) ; for ( $ index = 1 ; null !== $ parent ; $ index ++ ) { $ this -> parentList [ $ parent -> getName ( ) . '-' ] = $ parent ; $ parent = $ parent -> getDescriptor ( ) -> getParent ( ) ; } } return $ this -> parentList ; } | Return the template parent list |
16,055 | public function getTemplateFilePath ( $ templateName ) { $ templateList = array_merge ( [ $ this ] , $ this -> getParentList ( ) ) ; foreach ( $ templateList as $ templateDefinition ) { $ templateFilePath = sprintf ( '%s%s/%s' , THELIA_TEMPLATE_DIR , $ templateDefinition -> getPath ( ) , $ templateName ) ; if ( file_exists ( $ templateFilePath ) ) { return $ templateFilePath ; } } throw new TemplateException ( "Template file not found: $templateName" ) ; } | Find a template file path considering the template parents if any . |
16,056 | public function create ( CurrencyCreateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ currency = new CurrencyModel ( ) ; $ isDefault = CurrencyQuery :: create ( ) -> count ( ) === 0 ; $ currency -> setDispatcher ( $ dispatcher ) -> setLocale ( $ event -> getLocale ( ) ) -> setName ( $ event -> getCurrencyName ( ) ) -> setSymbol ( $ event -> getSymbol ( ) ) -> setFormat ( $ event -> getFormat ( ) ) -> setRate ( $ event -> getRate ( ) ) -> setCode ( strtoupper ( $ event -> getCode ( ) ) ) -> setByDefault ( $ isDefault ) -> save ( ) ; $ event -> setCurrency ( $ currency ) ; } | Create a new currencyuration entry |
16,057 | public function update ( CurrencyUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ currency = CurrencyQuery :: create ( ) -> findPk ( $ event -> getCurrencyId ( ) ) ) { $ currency -> setDispatcher ( $ dispatcher ) -> setLocale ( $ event -> getLocale ( ) ) -> setName ( $ event -> getCurrencyName ( ) ) -> setSymbol ( $ event -> getSymbol ( ) ) -> setFormat ( $ event -> getFormat ( ) ) -> setRate ( $ event -> getRate ( ) ) -> setCode ( strtoupper ( $ event -> getCode ( ) ) ) -> save ( ) ; $ event -> setCurrency ( $ currency ) ; } } | Change a currency |
16,058 | public function setDefault ( CurrencyUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ currency = CurrencyQuery :: create ( ) -> findPk ( $ event -> getCurrencyId ( ) ) ) { CurrencyQuery :: create ( ) -> filterByByDefault ( true ) -> update ( array ( 'ByDefault' => false ) ) ; $ currency -> setDispatcher ( $ dispatcher ) -> setVisible ( $ event -> getVisible ( ) ) -> setByDefault ( $ event -> getIsDefault ( ) ) -> save ( ) ; if ( $ event -> getIsDefault ( ) ) { $ updateRateEvent = new CurrencyUpdateRateEvent ( ) ; $ dispatcher -> dispatch ( TheliaEvents :: CURRENCY_UPDATE_RATES , $ updateRateEvent ) ; } $ event -> setCurrency ( $ currency ) ; } } | Set the default currency |
16,059 | public function delete ( CurrencyDeleteEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== ( $ currency = CurrencyQuery :: create ( ) -> findPk ( $ event -> getCurrencyId ( ) ) ) ) { if ( $ currency -> getByDefault ( ) ) { throw new \ RuntimeException ( Translator :: getInstance ( ) -> trans ( 'It is not allowed to delete the default currency' ) ) ; } $ currency -> setDispatcher ( $ dispatcher ) -> delete ( ) ; $ event -> setCurrency ( $ currency ) ; } } | Delete a currencyuration entry |
16,060 | public function getActivityConfigs ( $ activity , $ config_path ) { $ configs = array ( ) ; if ( file_exists ( $ config_path ) ) { $ configs = require $ config_path ; } return isset ( $ configs [ $ activity ] ) ? $ configs [ $ activity ] : array ( ) ; } | Get the configs for a particular activity . |
16,061 | public function getActivityCount ( $ activity ) { $ plugin_activities = $ this -> getPluginActivities ( ) ; return empty ( $ plugin_activities [ $ activity ] ) ? 0 : $ plugin_activities [ $ activity ] ; } | Get the count for an activity . |
16,062 | public function getPluginActivities ( ) { $ activities = $ this -> getActivities ( ) ; if ( ! isset ( $ activities [ $ this -> plugin ] ) ) { $ activities [ $ this -> plugin ] = array ( ) ; } return $ activities [ $ this -> plugin ] ; } | Get all activities for a plugin . |
16,063 | public function maybeAddRatingPrompt ( $ activity , $ config_path ) { $ added = false ; $ configs = $ this -> getActivityConfigs ( $ activity , $ config_path ) ; if ( isset ( $ configs [ 'threshold' ] ) && $ this -> getActivityCount ( $ activity ) >= $ configs [ 'threshold' ] ) { $ rating_prompt = new \ Boldgrid \ Library \ Library \ RatingPrompt ( ) ; $ added = $ rating_prompt -> addPrompt ( $ configs [ 'prompt' ] ) ; } return $ added ; } | Maybe add a rating prompt for an activity . |
16,064 | public function savePluginActivities ( $ plugin_activities ) { $ activities = $ this -> getActivities ( ) ; $ activities [ $ this -> plugin ] = $ plugin_activities ; return $ this -> saveActivities ( $ activities ) ; } | Save all activities for this plugin . |
16,065 | protected function cleanFormData ( array $ data ) { foreach ( $ data as $ key => $ value ) { if ( \ is_array ( $ value ) ) { $ data [ $ key ] = $ this -> cleanFormData ( $ value ) ; } elseif ( \ is_object ( $ value ) ) { unset ( $ data [ $ key ] ) ; } } return $ data ; } | Remove all objects in data because they are probably not serializable |
16,066 | public function addForm ( BaseForm $ form ) { $ formErrorInformation = $ this -> getSession ( ) -> getFormErrorInformation ( ) ; $ formFieldErrors = [ ] ; foreach ( $ form -> getForm ( ) -> getIterator ( ) as $ field ) { $ errors = $ field -> getErrors ( ) ; if ( \ count ( $ errors ) > 0 ) { $ formFieldErrors [ $ field -> getName ( ) ] = [ ] ; foreach ( $ errors as $ error ) { $ formFieldErrors [ $ field -> getName ( ) ] [ ] = [ 'message' => $ error -> getMessage ( ) , 'template' => $ error -> getMessageTemplate ( ) , 'parameters' => $ error -> getMessageParameters ( ) , 'pluralization' => $ error -> getMessagePluralization ( ) ] ; } } } $ this -> set ( \ get_class ( $ form ) . ":" . $ form -> getType ( ) , $ form ) ; $ formErrorInformation [ \ get_class ( $ form ) . ":" . $ form -> getType ( ) ] = [ 'data' => $ this -> cleanFormData ( $ form -> getForm ( ) -> getData ( ) ) , 'hasError' => $ form -> hasError ( ) , 'errorMessage' => $ form -> getErrorMessage ( ) , 'method' => $ this -> requestStack -> getCurrentRequest ( ) -> getMethod ( ) , 'timestamp' => time ( ) , 'validation_groups' => $ form -> getForm ( ) -> getConfig ( ) -> getOption ( 'validation_groups' ) , 'field_errors' => $ formFieldErrors ] ; $ this -> getSession ( ) -> setFormErrorInformation ( $ formErrorInformation ) ; return $ this ; } | Add a new form to the error form context |
16,067 | public function getForm ( $ formId , $ formClass , $ formType ) { if ( isset ( $ this -> store [ $ formClass . ":" . $ formType ] ) && $ this -> store [ $ formClass . ":" . $ formType ] instanceof BaseForm ) { return $ this -> store [ $ formClass . ":" . $ formType ] ; } $ formErrorInformation = $ this -> getSession ( ) -> getFormErrorInformation ( ) ; if ( isset ( $ formErrorInformation [ $ formClass . ":" . $ formType ] ) ) { $ formInfo = $ formErrorInformation [ $ formClass . ":" . $ formType ] ; if ( \ is_array ( $ formInfo [ 'data' ] ) ) { $ form = $ this -> formFactory -> createForm ( $ formId , $ formType , $ formInfo [ 'data' ] , [ 'validation_groups' => $ formInfo [ 'validation_groups' ] ] ) ; if ( true === $ formInfo [ 'hasError' ] ) { try { $ this -> formValidator -> validateForm ( $ form , $ formInfo [ 'method' ] ) ; } catch ( \ Exception $ ex ) { } foreach ( $ formInfo [ 'field_errors' ] as $ fieldName => $ errors ) { $ field = $ form -> getForm ( ) -> get ( $ fieldName ) ; if ( null !== $ field && \ count ( $ field -> getErrors ( ) ) == 0 ) { foreach ( $ errors as $ errorData ) { $ error = new FormError ( $ errorData [ 'message' ] , $ errorData [ 'template' ] , $ errorData [ 'parameters' ] , $ errorData [ 'pluralization' ] ) ; $ field -> addError ( $ error ) ; } } } } $ form -> setError ( $ formInfo [ 'hasError' ] ) ; if ( ! empty ( $ formInfo [ 'errorMessage' ] ) ) { $ form -> setErrorMessage ( $ formInfo [ 'errorMessage' ] ) ; } return $ form ; } } return null ; } | Check if the specified form has errors and return an instance of this form if it s the case . |
16,068 | public function clearForm ( BaseForm $ form ) { $ formErrorInformation = $ this -> getSession ( ) -> getFormErrorInformation ( ) ; $ formClass = \ get_class ( $ form ) . ':' . $ form -> getType ( ) ; if ( isset ( $ formErrorInformation [ $ formClass ] ) ) { unset ( $ formErrorInformation [ $ formClass ] ) ; $ this -> getSession ( ) -> setFormErrorInformation ( $ formErrorInformation ) ; } return $ this ; } | Remove form from the saved form error information . |
16,069 | protected function cleanOutdatedFormErrorInformation ( ) { $ formErrorInformation = $ this -> getSession ( ) -> getFormErrorInformation ( ) ; if ( ! empty ( $ formErrorInformation ) ) { $ now = time ( ) ; foreach ( $ formErrorInformation as $ name => $ formData ) { if ( $ now - $ formData [ 'timestamp' ] > self :: FORM_ERROR_LIFETIME_SECONDS ) { unset ( $ formErrorInformation [ $ name ] ) ; } } $ this -> getSession ( ) -> setFormErrorInformation ( $ formErrorInformation ) ; } return $ this ; } | Remove obsolete form error information . |
16,070 | public function sendEmailToShopManagers ( $ messageCode , $ messageParameters = [ ] , $ replyTo = [ ] ) { $ storeName = ConfigQuery :: getStoreName ( ) ; $ recipients = ConfigQuery :: getNotificationEmailsList ( ) ; $ to = [ ] ; foreach ( $ recipients as $ recipient ) { $ to [ $ recipient ] = $ storeName ; } $ this -> sendEmailMessage ( $ messageCode , [ ConfigQuery :: getStoreEmail ( ) => $ storeName ] , $ to , $ messageParameters , null , [ ] , [ ] , $ replyTo ) ; } | Send a message to the shop managers . |
16,071 | public function createEmailMessage ( $ messageCode , $ from , $ to , $ messageParameters = [ ] , $ locale = null , $ cc = [ ] , $ bcc = [ ] , $ replyTo = [ ] ) { if ( null !== $ message = MessageQuery :: getFromName ( $ messageCode ) ) { if ( $ locale === null ) { $ locale = Lang :: getDefaultLanguage ( ) -> getLocale ( ) ; } $ message -> setLocale ( $ locale ) ; foreach ( $ messageParameters as $ name => $ value ) { $ this -> parser -> assign ( $ name , $ value ) ; } $ this -> parser -> assign ( 'locale' , $ locale ) ; $ instance = $ this -> getMessageInstance ( ) ; $ this -> setupMessageHeaders ( $ instance , $ from , $ to , $ cc , $ bcc , $ replyTo ) ; $ message -> buildMessage ( $ this -> parser , $ instance ) ; return $ instance ; } throw new \ RuntimeException ( Translator :: getInstance ( ) -> trans ( "Failed to load message with code '%code%', propably because it does'nt exists." , [ '%code%' => $ messageCode ] ) ) ; } | Create a SwiftMessage instance from a given message code . |
16,072 | public function createSimpleEmailMessage ( $ from , $ to , $ subject , $ htmlBody , $ textBody , $ cc = [ ] , $ bcc = [ ] , $ replyTo = [ ] ) { $ instance = $ this -> getMessageInstance ( ) ; $ this -> setupMessageHeaders ( $ instance , $ from , $ to , $ cc , $ bcc , $ replyTo ) ; $ instance -> setSubject ( $ subject ) ; if ( empty ( $ htmlMessage ) ) { $ instance -> setBody ( $ textBody , 'text/plain' ) ; } else { $ instance -> setBody ( $ htmlBody , 'text/html' ) ; if ( ! empty ( $ textMessage ) ) { $ instance -> addPart ( $ textBody , 'text/plain' ) ; } } return $ instance ; } | Create a SwiftMessage instance from text |
16,073 | public function create ( TemplateCreateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ template = new TemplateModel ( ) ; $ template -> setDispatcher ( $ dispatcher ) -> setLocale ( $ event -> getLocale ( ) ) -> setName ( $ event -> getTemplateName ( ) ) -> save ( ) ; $ event -> setTemplate ( $ template ) ; } | Create a new template entry |
16,074 | public function duplicate ( TemplateDuplicateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ source = TemplateQuery :: create ( ) -> findPk ( $ event -> getSourceTemplateId ( ) ) ) { $ source -> setLocale ( $ event -> getLocale ( ) ) ; $ createEvent = new TemplateCreateEvent ( ) ; $ createEvent -> setLocale ( $ event -> getLocale ( ) ) -> setTemplateName ( Translator :: getInstance ( ) -> trans ( "Copy of %tpl" , [ "%tpl" => $ source -> getName ( ) ] ) ) ; $ dispatcher -> dispatch ( TheliaEvents :: TEMPLATE_CREATE , $ createEvent ) ; $ clone = $ createEvent -> getTemplate ( ) ; $ attrList = AttributeTemplateQuery :: create ( ) -> findByTemplateId ( $ source -> getId ( ) ) ; foreach ( $ attrList as $ feat ) { $ dispatcher -> dispatch ( TheliaEvents :: TEMPLATE_ADD_ATTRIBUTE , new TemplateAddAttributeEvent ( $ clone , $ feat -> getAttributeId ( ) ) ) ; } $ featList = FeatureTemplateQuery :: create ( ) -> findByTemplateId ( $ source -> getId ( ) ) ; foreach ( $ featList as $ feat ) { $ dispatcher -> dispatch ( TheliaEvents :: TEMPLATE_ADD_FEATURE , new TemplateAddFeatureEvent ( $ clone , $ feat -> getFeatureId ( ) ) ) ; } $ event -> setTemplate ( $ clone ) ; } } | Dupliucate an existing template entry |
16,075 | public function update ( TemplateUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ template = TemplateQuery :: create ( ) -> findPk ( $ event -> getTemplateId ( ) ) ) { $ template -> setDispatcher ( $ dispatcher ) -> setLocale ( $ event -> getLocale ( ) ) -> setName ( $ event -> getTemplateName ( ) ) -> save ( ) ; $ event -> setTemplate ( $ template ) ; } } | Change a product template |
16,076 | public function delete ( TemplateDeleteEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== ( $ template = TemplateQuery :: create ( ) -> findPk ( $ event -> getTemplateId ( ) ) ) ) { $ productCount = ProductQuery :: create ( ) -> findByTemplateId ( $ template -> getId ( ) ) -> count ( ) ; if ( $ productCount <= 0 ) { $ con = Propel :: getWriteConnection ( TemplateTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { $ template -> setDispatcher ( $ dispatcher ) -> delete ( $ con ) ; CategoryQuery :: create ( ) -> filterByDefaultTemplateId ( $ event -> getTemplateId ( ) ) -> update ( [ 'DefaultTemplateId' => null ] , $ con ) ; $ con -> commit ( ) ; } catch ( \ Exception $ ex ) { $ con -> rollback ( ) ; throw $ ex ; } } $ event -> setTemplate ( $ template ) ; $ event -> setProductCount ( $ productCount ) ; } } | Delete a product template entry |
16,077 | public function autodiscover ( ) : void { $ entityMappings = [ ] ; foreach ( $ this -> fileSystem -> getEntityDirectories ( ) as $ entityDirectory ) { $ namespace = $ this -> namespaceDetector -> detectFromDirectory ( $ entityDirectory ) ; if ( ! $ namespace ) { continue ; } $ entityMappings [ ] = [ 'name' => $ namespace , 'prefix' => $ namespace , 'type' => 'annotation' , 'dir' => $ entityDirectory -> getRealPath ( ) , 'is_bundle' => false , ] ; } $ xmlNamespaces = [ ] ; $ directoryByNamespace = $ this -> resolveDirectoryByNamespace ( $ this -> fileSystem -> getEntityXmlFiles ( ) ) ; foreach ( $ directoryByNamespace as $ namespace => $ directory ) { if ( in_array ( $ namespace , $ xmlNamespaces , true ) ) { continue ; } $ xmlNamespaces [ ] = $ namespace ; $ entityMappings [ ] = [ 'name' => $ namespace , 'prefix' => $ namespace , 'type' => 'xml' , 'dir' => $ directory , 'is_bundle' => false , ] ; } if ( ! count ( $ entityMappings ) ) { return ; } $ this -> containerBuilder -> prependExtensionConfig ( 'doctrine' , [ 'orm' => [ 'mappings' => $ entityMappings ] , ] ) ; } | Needs to run before |
16,078 | protected function createFormDataArray ( $ object ) { return array ( "label" => $ object -> getLabel ( ) , "title" => $ object -> getTitleId ( ) , "firstname" => $ object -> getFirstname ( ) , "lastname" => $ object -> getLastname ( ) , "address1" => $ object -> getAddress1 ( ) , "address2" => $ object -> getAddress2 ( ) , "address3" => $ object -> getAddress3 ( ) , "zipcode" => $ object -> getZipcode ( ) , "city" => $ object -> getCity ( ) , "country" => $ object -> getCountryId ( ) , "state" => $ object -> getStateId ( ) , "cellphone" => $ object -> getCellphone ( ) , "phone" => $ object -> getPhone ( ) , "company" => $ object -> getCompany ( ) ) ; } | Fills in the form data array |
16,079 | protected function renderEditionTemplate ( ) { return $ this -> render ( 'customer-edit' , array ( "address_id" => $ this -> getRequest ( ) -> get ( 'address_id' ) , "page" => $ this -> getRequest ( ) -> get ( 'page' ) , "customer_id" => $ this -> getCustomerId ( ) ) ) ; } | Render the edition template |
16,080 | public function renderToolTemplateHeaderRefreshAction ( ) { $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ view = new ViewModel ( ) ; $ view -> melisKey = $ melisKey ; return $ view ; } | Renders the refresh button into the Header section of the Tool |
16,081 | public function renderToolTemplateContentFiltersSitesAction ( ) { $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ siteTable = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableSite' ) ; $ sites = array ( ) ; $ sites [ ] = '<option value="">' . $ translator -> translate ( 'tr_meliscms_tool_templates_tpl_label_choose' ) . '</option>' ; foreach ( $ siteTable -> fetchAll ( ) as $ site ) { $ siteName = ! empty ( $ site -> site_label ) ? $ site -> site_label : $ site -> site_name ; $ sites [ ] = '<option value="' . $ site -> site_id . '">' . $ siteName . '</option>' ; } $ view = new ViewModel ( ) ; $ view -> sites = $ sites ; return $ view ; } | Renders to the site filter selection in the filter bar in the datatable |
16,082 | public function renderToolTemplatesModalAddHandlerAction ( ) { $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ melisTool = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTool' ) ; $ melisTool -> setMelisToolKey ( 'meliscms' , 'meliscms_tool_templates' ) ; $ view = new ViewModel ( ) ; $ view -> addModalHandler = $ melisTool -> getModal ( 'meliscms_tool_template_add_modal' ) ; $ view -> melisKey = $ melisKey ; return $ view ; } | Renders the Add Tab and Content for the modal |
16,083 | public function renderToolTemplatesModalEditHandlerAction ( ) { $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ melisTool = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTool' ) ; $ melisTool -> setMelisToolKey ( 'meliscms' , 'meliscms_tool_templates' ) ; $ view = new ViewModel ( ) ; $ view -> editModalHandler = $ melisTool -> getModal ( 'meliscms_tool_template_edit_modal' ) ; $ view -> melisKey = $ melisKey ; return $ view ; } | Renders the Update Tab and Content for the modal |
16,084 | public function renderToolTemplatesModalEmptyHandlerAction ( ) { $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ view = new ViewModel ( ) ; $ view -> melisKey = $ melisKey ; return $ view ; } | Handles the empty modal if there s no available modal form for the user . |
16,085 | public function modalTabToolTemplateAddAction ( ) { $ melisTool = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTool' ) ; $ melisTool -> setMelisToolKey ( 'meliscms' , 'meliscms_tool_templates' ) ; $ view = new ViewModel ( ) ; $ view -> setVariable ( 'meliscms_tool_template_add' , $ melisTool -> getForm ( 'meliscms_tool_template_generic_form' ) ) ; return $ view ; } | This will be used to render the add form in the modal tab |
16,086 | public function getTemplateByPageIdAction ( ) { $ success = 0 ; $ request = $ this -> getRequest ( ) ; $ data = array ( ) ; if ( $ request -> isPost ( ) ) { $ template = $ this -> getServiceLocator ( ) -> get ( "MelisPageTemplate" ) ; $ success = 2 ; $ data = $ template -> getTemplate ( $ pageId ) ; } return $ data ; } | Return template of a page |
16,087 | protected function getControllers ( string $ controllersPath ) : array { $ controllers = [ ] ; if ( is_dir ( $ controllersPath ) ) { foreach ( scandir ( $ controllersPath ) as $ controller ) { if ( $ controller == '.' || $ controller == '..' || is_dir ( $ controllersPath . '/' . $ controller ) ) { continue ; } $ filePath = $ controllersPath . '/' . $ controller ; $ fileExt = pathinfo ( $ filePath ) [ 'extension' ] ; if ( $ fileExt == 'php' && is_file ( $ filePath ) ) { $ controllers [ ] = $ controller ; } } } return $ controllers ; } | Returns a module s controllers |
16,088 | public function getTemplateDataByIdAction ( ) { $ request = $ this -> getRequest ( ) ; $ data = array ( ) ; if ( $ request -> isPost ( ) ) { $ templatesModel = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableTemplate' ) ; $ templateId = $ request -> getPost ( 'templateId' ) ; if ( is_numeric ( $ templateId ) ) $ data = $ templatesModel -> getEntryById ( $ templateId ) ; } return new JsonModel ( $ data ) ; } | Returns all information of the specific template data |
16,089 | public function ajaxClear ( ) { $ plugin = ! empty ( $ _POST [ 'plugin' ] ) ? sanitize_text_field ( $ _POST [ 'plugin' ] ) : null ; if ( empty ( $ plugin ) ) { wp_send_json_error ( __ ( 'Unknown plugin.' , 'boldgrid-library' ) ) ; } if ( ! current_user_can ( 'manage_options' ) ) { wp_send_json_error ( __ ( 'Access denied.' , 'boldgrid-library' ) ) ; } $ success = $ this -> clearTransient ( ) ; if ( ! $ success ) { wp_send_json_error ( array ( 'string' => sprintf ( __ ( 'Failed to clear license data. Unable to delete site transient "%1$s".' , 'boldgrid-library' ) , $ this -> getKey ( ) ) , ) ) ; } $ this -> initLicense ( ) ; $ return = array ( 'isPremium' => $ this -> isPremium ( $ plugin ) , 'string' => $ this -> licenseString , ) ; wp_send_json_success ( $ return ) ; } | Handle ajax request to clear license data . |
16,090 | public function registerScripts ( ) { $ handle = 'bglib-license' ; wp_register_script ( $ handle , Library \ Configs :: get ( 'libraryUrl' ) . 'src/assets/js/license.js' , 'jQuery' ) ; $ translations = array ( 'unknownError' => __ ( 'Unknown error' , 'boldgrid-library' ) , ) ; wp_localize_script ( $ handle , 'bglibLicense' , $ translations ) ; } | Register scripts . |
16,091 | private function setLicense ( ) { if ( ! $ this -> getApiKey ( ) ) { $ license = 'Missing Connect Key' ; } else if ( ! ( $ license = $ this -> getTransient ( ) ) || ! $ this -> isVersionValid ( $ license ) ) { delete_site_transient ( $ this -> getKey ( ) ) ; $ license = $ this -> getRemoteLicense ( ) ; } return $ this -> license = $ license ; } | Set the license class property . |
16,092 | private function setTransient ( ) { return ! $ this -> getTransient ( ) && set_site_transient ( $ this -> getKey ( ) , $ this -> getLicense ( ) , $ this -> getExpiration ( $ this -> getData ( ) ) ) ; } | Sets the transient for the license data . |
16,093 | private function isValid ( ) { $ data = $ this -> getTransient ( ) ; $ valid = array ( 'key' , 'cipher' , 'iv' , 'data' ) ; if ( is_object ( $ data ) ) { $ props = array_keys ( get_object_vars ( $ data ) ) ; $ valid = array_diff ( $ valid , $ props ) ; } return empty ( $ valid ) ; } | Check if the current license is valid . |
16,094 | private function setData ( ) { if ( $ license = $ this -> getLicense ( ) ) { $ data = json_decode ( openssl_decrypt ( $ license -> data , $ license -> cipher , $ license -> key , 0 , urldecode ( $ license -> iv ) ) ) ; } return $ this -> data = $ data ; } | Set the data class property . |
16,095 | public function deactivate ( ) { if ( ! $ this -> isValid ( ) && Configs :: get ( 'licenseActivate' ) ) { delete_site_transient ( $ this -> getKey ( ) ) ; deactivate_plugins ( Configs :: get ( 'file' ) ) ; } } | Runs plugin deactivation when deactivate_plugins is available . |
16,096 | private function getRemoteLicense ( ) { $ call = new Api \ Call ( Configs :: get ( 'api' ) . '/api/plugin/getLicense?v=' . $ this -> apiVersion ) ; if ( ! $ response = $ call -> getError ( ) ) { $ response = $ call -> getResponse ( ) -> result -> data ; } return $ response ; } | Get the latest license data from the API server . |
16,097 | public function initLicense ( ) { $ this -> license = $ this -> setLicense ( ) ; if ( is_object ( $ this -> getLicense ( ) ) ) { $ this -> data = $ this -> setData ( ) ; $ this -> setTransient ( $ this -> getData ( ) ) ; $ licenseData = array ( 'licenseData' => $ this -> getData ( ) ) ; Configs :: set ( $ licenseData , Configs :: get ( ) ) ; } } | Init the license . |
16,098 | public function isPremium ( $ product ) { $ isPremium = isset ( $ this -> getData ( ) -> $ product ) ; $ this -> licenseString = $ isPremium ? __ ( 'Premium' , 'boldgrid-connect' ) : __ ( 'Free' , 'boldgrid-library' ) ; return $ isPremium ; } | Checks if product is premium or free . |
16,099 | public function isVersionValid ( $ license ) { return ( ! empty ( $ license -> version ) && ! empty ( $ license -> iv ) && 16 === strlen ( urldecode ( $ license -> iv ) ) && $ this -> apiVersion === $ license -> version ) ; } | Check if the license version and encoding is correct . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.