idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
15,500 | public function make ( array $ config ) { Arr :: requires ( $ config , [ 'token' ] ) ; $ client = new Client ( ) ; return new GitterGateway ( $ client , $ config ) ; } | Create a new gitter gateway instance . |
15,501 | public function getPriceOffsets ( ) { $ currencyOffsets = SaleOffsetCurrencyQuery :: create ( ) -> filterBySaleId ( $ this -> getId ( ) ) -> find ( ) ; $ offsetList = [ ] ; foreach ( $ currencyOffsets as $ currencyOffset ) { $ offsetList [ $ currencyOffset -> getCurrencyId ( ) ] = $ currencyOffset -> getPriceOffsetValue ( ) ; } return $ offsetList ; } | Get the price offsets for each of the currencies . |
15,502 | public function getSaleProductList ( ) { $ saleProducts = SaleProductQuery :: create ( ) -> filterBySaleId ( $ this -> getId ( ) ) -> groupByProductId ( ) -> find ( ) ; return $ saleProducts ; } | Return the products included in this sale . |
15,503 | public function getSaleProductsAttributeList ( ) { $ saleProducts = SaleProductQuery :: create ( ) -> filterBySaleId ( $ this -> getId ( ) ) -> orderByProductId ( ) -> find ( ) ; $ selectedAttributes = [ ] ; $ currentProduct = false ; foreach ( $ saleProducts as $ saleProduct ) { if ( $ currentProduct != $ saleProduct -> getProductId ( ) ) { $ currentProduct = $ saleProduct -> getProductId ( ) ; $ selectedAttributes [ $ currentProduct ] = [ ] ; } $ selectedAttributes [ $ currentProduct ] [ ] = $ saleProduct -> getAttributeAvId ( ) ; } return $ selectedAttributes ; } | Return the selected attributes values for each of the selected products . |
15,504 | public function noAction ( Request $ request ) { $ view = null ; if ( ! $ view = $ request -> query -> get ( 'view' ) ) { if ( $ request -> request -> has ( 'view' ) ) { $ view = $ request -> request -> get ( 'view' ) ; } } if ( null !== $ view ) { $ request -> attributes -> set ( '_view' , $ view ) ; } if ( null === $ view && null === $ request -> attributes -> get ( "_view" ) ) { $ request -> attributes -> set ( "_view" , "index" ) ; } if ( ConfigQuery :: isRewritingEnable ( ) ) { if ( $ request -> attributes -> get ( '_rewritten' , false ) === false ) { $ rewrittenUrl = URL :: getInstance ( ) -> retrieveCurrent ( $ request ) ; if ( $ rewrittenUrl -> rewrittenUrl !== null ) { throw new RedirectException ( $ rewrittenUrl -> rewrittenUrl , 301 ) ; } } } } | This is the default Thelia behaviour if no action is defined . |
15,505 | public function isMatching ( ConditionCollection $ conditions ) { $ isMatching = true ; foreach ( $ conditions as $ condition ) { if ( ! $ condition -> isMatching ( ) ) { return false ; } } return $ isMatching ; } | Check if an Event matches SerializableCondition |
15,506 | public function variableOpComparison ( $ v1 , $ o , $ v2 ) { switch ( $ o ) { case Operators :: DIFFERENT : return ( $ v1 != $ v2 ) ; case Operators :: SUPERIOR : return ( $ v1 > $ v2 ) ; case Operators :: SUPERIOR_OR_EQUAL : return ( $ v1 >= $ v2 ) ; case Operators :: INFERIOR : return ( $ v1 < $ v2 ) ; case Operators :: INFERIOR_OR_EQUAL : return ( $ v1 <= $ v2 ) ; case Operators :: EQUAL : return ( $ v1 == $ v2 ) ; case Operators :: IN : return ( \ in_array ( $ v1 , $ v2 ) ) ; case Operators :: OUT : return ( ! \ in_array ( $ v1 , $ v2 ) ) ; default : throw new \ Exception ( 'Unrecognized operator ' . $ o ) ; } } | Do variable comparison |
15,507 | public function getArgument ( $ key , $ default = null ) { return array_key_exists ( $ key , $ this -> arguments ) ? $ this -> arguments [ $ key ] : $ default ; } | Get an argument |
15,508 | public function getTemplateVar ( $ templateVariableName ) { if ( ! isset ( $ this -> templateVars [ $ templateVariableName ] ) ) { throw new \ InvalidArgumentException ( sprintf ( "Template variable '%s' is not defined." , $ templateVariableName ) ) ; } return $ this -> templateVars [ $ templateVariableName ] ; } | Return a template variable value . An exception is thorwn if the variable is not defined . |
15,509 | public function sanitizeValue ( ) { $ strColNameId = $ this -> objAttribute -> get ( 'tag_id' ) ? : 'id' ; $ strColNameAlias = $ this -> objAttribute -> get ( 'tag_alias' ) ; $ arrValues = \ is_array ( $ this -> value ) ? $ this -> value : \ explode ( ',' , $ this -> value ) ; if ( ! $ this -> isMetaModel ( ) ) { if ( $ strColNameAlias ) { $ builder = $ this -> connection -> createQueryBuilder ( ) -> select ( $ strColNameId ) -> from ( $ this -> objAttribute -> get ( 'tag_table' ) ) ; foreach ( $ arrValues as $ index => $ value ) { $ builder -> orWhere ( $ strColNameAlias . ' LIKE :value_' . $ index ) -> setParameter ( 'value_' . $ index , $ value ) ; } $ arrValues = $ builder -> execute ( ) -> fetchAll ( \ PDO :: FETCH_COLUMN ) ; } else { $ arrValues = \ array_map ( 'intval' , $ arrValues ) ; } } else { if ( $ strColNameAlias == 'id' ) { $ values = $ arrValues ; } else { $ values = [ ] ; foreach ( $ arrValues as $ value ) { $ values [ ] = \ array_values ( $ this -> getTagMetaModel ( ) -> getAttribute ( $ strColNameAlias ) -> searchFor ( $ value ) ) ; } } $ arrValues = $ this -> flatten ( $ values ) ; } return $ arrValues ; } | Ensure the value is either a proper id or array od ids - converts aliases to ids . |
15,510 | public function make ( array $ config ) { if ( ! isset ( $ config [ 'driver' ] ) ) { throw new InvalidArgumentException ( 'A driver must be specified.' ) ; } return $ this -> factory ( $ config [ 'driver' ] ) -> make ( $ config ) ; } | Create a new gateway instance . |
15,511 | public function factory ( $ name ) { if ( isset ( $ this -> factories [ $ name ] ) ) { return $ this -> factories [ $ name ] ; } if ( class_exists ( $ class = $ this -> inflect ( $ name ) ) ) { return $ this -> factories [ $ name ] = new $ class ( ) ; } throw new InvalidArgumentException ( "Unsupported factory [$name]." ) ; } | Get a factory instance by name . |
15,512 | public function getRoot ( $ categoryId ) { $ category = CategoryQuery :: create ( ) -> findPk ( $ categoryId ) ; if ( 0 !== $ category -> getParent ( ) ) { $ parentCategory = CategoryQuery :: create ( ) -> findPk ( $ category -> getParent ( ) ) ; if ( null !== $ parentCategory ) { $ categoryId = $ this -> getRoot ( $ parentCategory -> getId ( ) ) ; } } return $ categoryId ; } | Get the root category |
15,513 | public function addRemoteFile ( string $ file , string $ locale = null ) : self { $ collection = $ this -> getCollection ( $ this -> getType ( $ file ) , $ locale ) ; $ collection -> addRemoteFile ( $ file ) ; return $ this ; } | Prida remote soubor |
15,514 | public function createCssLoader ( ) : CssLoader { $ compiler = Compiler :: createCssCompiler ( $ this -> files [ self :: CSS ] [ null ] , $ this -> wwwDir . '/' . $ this -> outputDir ) ; foreach ( $ this -> filters [ self :: CSS ] as $ filter ) { $ compiler -> addFileFilter ( $ filter ) ; } return new CssLoader ( $ compiler , $ this -> httpRequest -> getUrl ( ) -> basePath . $ this -> outputDir ) ; } | Vytvori komponentu css |
15,515 | public function createJavaScriptLoader ( string $ locale = null ) : JavaScriptLoader { $ compilers [ ] = $ this -> createJSCompiler ( $ this -> files [ self :: JS ] [ null ] ) ; if ( $ locale !== null && isset ( $ this -> files [ self :: JS ] [ $ locale ] ) ) { $ compilers [ ] = $ this -> createJSCompiler ( $ this -> files [ self :: JS ] [ $ locale ] ) ; } return new JavaScriptLoader ( $ this -> httpRequest -> getUrl ( ) -> basePath . $ this -> outputDir , ... $ compilers ) ; } | Vytvori komponentu js |
15,516 | private function getCollection ( string $ type , string $ locale = null ) : FileCollection { if ( ! isset ( $ this -> files [ $ type ] [ $ locale ] ) ) { $ this -> files [ $ type ] [ $ locale ] = new FileCollection ( $ this -> root ) ; } return $ this -> files [ $ type ] [ $ locale ] ; } | Vrati kolekci souboru |
15,517 | private function getType ( string $ file ) : string { $ css = '/\.(css|less)$/' ; $ js = '/\.js$/' ; if ( preg_match ( $ css , $ file ) ) { return self :: CSS ; } elseif ( preg_match ( $ js , $ file ) ) { return self :: JS ; } throw new InvalidArgumentException ( "Unknown assets file '$file'" ) ; } | Vrati typ souboru |
15,518 | protected function getDefaultCategoryId ( $ product ) { $ defaultCategoryId = null ; if ( ( bool ) $ product -> getVirtualColumn ( 'is_default_category' ) ) { $ defaultCategoryId = $ product -> getVirtualColumn ( 'default_category_id' ) ; } else { $ defaultCategoryId = $ product -> getDefaultCategoryId ( ) ; } return $ defaultCategoryId ; } | Get the default category id for a product |
15,519 | protected function createComponentPasswordForm ( ) : Form { $ form = $ this -> formFactory -> create ( ) ; $ form -> setAjaxRequest ( ) ; $ form -> addPassword ( 'oldPassword' , 'cms.user.oldPassword' ) -> setRequired ( ) ; $ form -> addPassword ( 'password' , 'cms.user.newPassword' ) -> setRequired ( ) -> addRule ( Form :: MIN_LENGTH , null , $ this -> minPasswordLength ) ; $ form -> addPassword ( 'passwordVerify' , 'cms.user.passwordVerify' ) -> setRequired ( ) -> addRule ( Form :: EQUAL , null , $ form [ 'password' ] ) ; $ form -> addProtection ( ) ; $ form -> addSubmit ( 'save' , 'form.save' ) ; $ form -> onSuccess [ ] = [ $ this , 'passwordFormSucceeded' ] ; return $ form ; } | Formular zmeny hesla |
15,520 | public function create ( ProductSaleElementCreateEvent $ event ) { $ con = Propel :: getWriteConnection ( ProductSaleElementsTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { $ salesElement = ProductSaleElementsQuery :: create ( ) -> filterByProductId ( $ event -> getProduct ( ) -> getId ( ) ) -> joinAttributeCombination ( null , Criteria :: LEFT_JOIN ) -> add ( AttributeCombinationTableMap :: COL_PRODUCT_SALE_ELEMENTS_ID , null , Criteria :: ISNULL ) -> findOne ( $ con ) ; if ( $ salesElement == null ) { $ salesElement = $ event -> getProduct ( ) -> createProductSaleElement ( $ con , 0 , 0 , 0 , $ event -> getCurrencyId ( ) , false ) ; } else { $ salesElement -> setIsDefault ( true ) -> save ( $ con ) ; } $ combinationAttributes = $ event -> getAttributeAvList ( ) ; if ( \ count ( $ combinationAttributes ) > 0 ) { foreach ( $ combinationAttributes as $ attributeAvId ) { $ attributeAv = AttributeAvQuery :: create ( ) -> findPk ( $ attributeAvId ) ; if ( $ attributeAv !== null ) { $ attributeCombination = new AttributeCombination ( ) ; $ attributeCombination -> setAttributeAvId ( $ attributeAvId ) -> setAttribute ( $ attributeAv -> getAttribute ( ) ) -> setProductSaleElements ( $ salesElement ) -> save ( $ con ) ; } } } $ event -> setProductSaleElement ( $ salesElement ) ; $ con -> commit ( ) ; } catch ( \ Exception $ ex ) { $ con -> rollback ( ) ; throw $ ex ; } } | Create a new product sale element with or without combination |
15,521 | public function update ( ProductSaleElementUpdateEvent $ event ) { $ salesElement = ProductSaleElementsQuery :: create ( ) -> findPk ( $ event -> getProductSaleElementId ( ) ) ; $ con = Propel :: getWriteConnection ( ProductSaleElementsTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { $ event -> getProduct ( ) -> setTaxRuleId ( $ event -> getTaxRuleId ( ) ) -> save ( $ con ) ; if ( $ salesElement == null ) { $ salesElement = new ProductSaleElements ( ) ; $ salesElement -> setProduct ( $ event -> getProduct ( ) ) ; } $ defaultStatus = $ event -> getIsDefault ( ) ; if ( $ defaultStatus ) { ProductSaleElementsQuery :: create ( ) -> filterByProduct ( $ event -> getProduct ( ) ) -> filterByIsDefault ( true ) -> filterById ( $ event -> getProductSaleElementId ( ) , Criteria :: NOT_EQUAL ) -> update ( [ 'IsDefault' => false ] , $ con ) ; } else { if ( $ salesElement -> getIsDefault ( ) && ProductSaleElementsQuery :: create ( ) -> filterByProduct ( $ event -> getProduct ( ) ) -> filterByIsDefault ( true ) -> filterById ( $ salesElement -> getId ( ) , Criteria :: NOT_EQUAL ) -> count ( ) === 0 ) { $ defaultStatus = true ; } } $ salesElement -> setRef ( $ event -> getReference ( ) ) -> setQuantity ( $ event -> getQuantity ( ) ) -> setPromo ( $ event -> getOnsale ( ) ) -> setNewness ( $ event -> getIsnew ( ) ) -> setWeight ( $ event -> getWeight ( ) ) -> setIsDefault ( $ defaultStatus ) -> setEanCode ( $ event -> getEanCode ( ) ) -> save ( ) ; $ productPrice = ProductPriceQuery :: create ( ) -> filterByCurrencyId ( $ event -> getCurrencyId ( ) ) -> filterByProductSaleElementsId ( $ salesElement -> getId ( ) ) -> findOne ( $ con ) ; if ( $ productPrice == null ) { $ productPrice = new ProductPrice ( ) ; $ productPrice -> setProductSaleElements ( $ salesElement ) -> setCurrencyId ( $ event -> getCurrencyId ( ) ) ; } $ productPrice -> setFromDefaultCurrency ( $ event -> getFromDefaultCurrency ( ) ) ; if ( $ event -> getFromDefaultCurrency ( ) == 0 ) { $ productPrice -> setPromoPrice ( $ event -> getSalePrice ( ) ) -> setPrice ( $ event -> getPrice ( ) ) ; } else { $ productPrice -> setPromoPrice ( 0 ) -> setPrice ( 0 ) ; } $ productPrice -> save ( $ con ) ; $ con -> commit ( ) ; } catch ( \ Exception $ ex ) { $ con -> rollback ( ) ; throw $ ex ; } } | Update an existing product sale element |
15,522 | public function delete ( ProductSaleElementDeleteEvent $ event ) { if ( null !== $ pse = ProductSaleElementsQuery :: create ( ) -> findPk ( $ event -> getProductSaleElementId ( ) ) ) { $ product = $ pse -> getProduct ( ) ; $ con = Propel :: getWriteConnection ( ProductSaleElementsTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { if ( $ product -> countSaleElements ( $ con ) === 1 ) { $ pse -> setIsDefault ( true ) -> save ( $ con ) ; AttributeCombinationQuery :: create ( ) -> filterByProductSaleElementsId ( $ pse -> getId ( ) ) -> delete ( $ con ) ; } else { $ pse -> delete ( $ con ) ; if ( $ pse -> getIsDefault ( ) ) { $ newDefaultPse = ProductSaleElementsQuery :: create ( ) -> filterByProductId ( $ product -> getId ( ) ) -> filterById ( $ pse -> getId ( ) , Criteria :: NOT_EQUAL ) -> orderByCreatedAt ( Criteria :: DESC ) -> findOne ( $ con ) ; if ( null !== $ newDefaultPse ) { $ newDefaultPse -> setIsDefault ( true ) -> save ( $ con ) ; } } } $ con -> commit ( ) ; } catch ( \ Exception $ ex ) { $ con -> rollback ( ) ; throw $ ex ; } } } | Delete a product sale element |
15,523 | public function generateCombinations ( ProductCombinationGenerationEvent $ event ) { $ con = Propel :: getWriteConnection ( ProductSaleElementsTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { ProductSaleElementsQuery :: create ( ) -> filterByProductId ( $ event -> product -> getId ( ) ) -> delete ( ) ; $ isDefault = true ; foreach ( $ event -> getCombinations ( ) as $ combinationAttributesAvIds ) { $ saleElement = $ event -> getProduct ( ) -> createProductSaleElement ( $ con , $ event -> getWeight ( ) , $ event -> getPrice ( ) , $ event -> getSalePrice ( ) , $ event -> getCurrencyId ( ) , $ isDefault , $ event -> getOnsale ( ) , $ event -> getIsnew ( ) , $ event -> getQuantity ( ) , $ event -> getEanCode ( ) , $ event -> getReference ( ) ) ; $ isDefault = false ; $ this -> createCombination ( $ con , $ saleElement , $ combinationAttributesAvIds ) ; } $ con -> commit ( ) ; } catch ( \ Exception $ ex ) { $ con -> rollback ( ) ; throw $ ex ; } } | Generate combinations . All existing combinations for the product are deleted . |
15,524 | protected function createCombination ( ConnectionInterface $ con , ProductSaleElements $ salesElement , $ combinationAttributes ) { foreach ( $ combinationAttributes as $ attributeAvId ) { $ attributeAv = AttributeAvQuery :: create ( ) -> findPk ( $ attributeAvId ) ; if ( $ attributeAv !== null ) { $ attributeCombination = new AttributeCombination ( ) ; $ attributeCombination -> setAttributeAvId ( $ attributeAvId ) -> setAttribute ( $ attributeAv -> getAttribute ( ) ) -> setProductSaleElements ( $ salesElement ) -> save ( $ con ) ; } } } | Create a combination for a given product sale element |
15,525 | public function clonePSE ( ProductCloneEvent $ event ) { $ clonedProduct = $ event -> getClonedProduct ( ) ; $ originalProductPSEs = ProductSaleElementsQuery :: create ( ) -> orderByIsDefault ( Criteria :: DESC ) -> findByProductId ( $ event -> getOriginalProduct ( ) -> getId ( ) ) ; foreach ( $ originalProductPSEs as $ key => $ originalProductPSE ) { $ currencyId = ProductPriceQuery :: create ( ) -> filterByProductSaleElementsId ( $ originalProductPSE -> getId ( ) ) -> select ( 'CURRENCY_ID' ) -> findOne ( ) ; $ clonedProductPSEId = $ this -> createClonePSE ( $ event , $ originalProductPSE , $ currencyId ) ; $ this -> updateClonePSE ( $ event , $ clonedProductPSEId , $ originalProductPSE , $ key ) ; $ originalProductPSEImages = ProductSaleElementsProductImageQuery :: create ( ) -> findByProductSaleElementsId ( $ originalProductPSE -> getId ( ) ) ; if ( null !== $ originalProductPSEImages ) { $ this -> clonePSEAssociatedFiles ( $ clonedProduct -> getId ( ) , $ clonedProductPSEId , $ originalProductPSEImages , $ type = 'image' ) ; } $ originalProductPSEDocuments = ProductSaleElementsProductDocumentQuery :: create ( ) -> findByProductSaleElementsId ( $ originalProductPSE -> getId ( ) ) ; if ( null !== $ originalProductPSEDocuments ) { $ this -> clonePSEAssociatedFiles ( $ clonedProduct -> getId ( ) , $ clonedProductPSEId , $ originalProductPSEDocuments , $ type = 'document' ) ; } } } | Clone product s PSEs and associated datas |
15,526 | public function getCustomerLang ( ) { $ lang = $ this -> getLangModel ( ) ; if ( $ lang === null ) { $ lang = ( new LangQuery ) -> filterByByDefault ( 1 ) -> findOne ( ) ; } return $ lang ; } | Return the customer lang or the default one if none is defined . |
15,527 | public function setPassword ( $ password ) { if ( $ this -> isNew ( ) && ( $ password === null || trim ( $ password ) == "" ) ) { throw new InvalidArgumentException ( "customer password is mandatory on creation" ) ; } if ( $ password !== null && trim ( $ password ) != "" ) { $ this -> setAlgo ( "PASSWORD_BCRYPT" ) ; parent :: setPassword ( password_hash ( $ password , PASSWORD_BCRYPT ) ) ; } return $ this ; } | create hash for plain password and set it in Customer object |
15,528 | public function getDownloadUrl ( ) { $ url = Configs :: get ( 'api' ) . '/v1/plugins/' . $ this -> slug . '/download' ; $ url = add_query_arg ( 'key' , Configs :: get ( 'key' ) , $ url ) ; return $ url ; } | Return the download url for a plugin . |
15,529 | protected function createComponentUploadForm ( ) : Form { $ form = $ this -> formFactory -> create ( ) ; $ form -> addUpload ( 'sql' , 'cms.database.file' ) -> setRequired ( ) ; $ form -> addSubmit ( 'upload' , 'cms.database.upload' ) ; $ form -> onSuccess [ ] = [ $ this , 'uploadFormSucceeded' ] ; return $ form ; } | Formular nahrani databaze |
15,530 | public static function getSolrType ( ) { $ relationships = PlatformAppConfig :: get ( 'relationships' ) ; if ( ! isset ( $ relationships [ 'solr' ] ) ) { return FALSE ; } list ( $ solr_key , ) = explode ( ':' , $ relationships [ 'solr' ] ) ; $ solr_config = self :: get ( $ solr_key ) ; if ( ! isset ( $ solr_config [ 'type' ] ) ) { return FALSE ; } return $ solr_config [ 'type' ] ; } | Gets the solr type . |
15,531 | public static function getSolrMajorVersion ( ) { $ type = static :: getSolrType ( ) ; $ version = FALSE ; if ( $ type ) { list ( , $ version ) = explode ( ":" , $ type ) ; if ( preg_match ( '/^(\d)\./' , $ version , $ matches ) ) { $ version = $ matches [ 1 ] ; } else { $ version = '4' ; } if ( $ version === '3' ) { $ version = '4' ; } } return $ version ; } | Gets the solr major version |
15,532 | public function getArchivers ( $ isAvailable = null ) { if ( $ isAvailable === null ) { return $ this -> archivers ; } $ filteredArchivers = [ ] ; foreach ( $ this -> archivers as $ archiver ) { if ( $ archiver -> isAvailable ( ) === ( bool ) $ isAvailable ) { $ filteredArchivers [ ] = $ archiver ; } } return $ filteredArchivers ; } | Get all archivers or only those match availability |
15,533 | public function get ( $ archiverId , $ isAvailable = null ) { $ this -> has ( $ archiverId , true ) ; if ( $ isAvailable === null ) { return $ this -> archivers [ $ archiverId ] ; } if ( $ this -> archivers [ $ archiverId ] -> isAvailable ( ) === ( bool ) $ isAvailable ) { return $ this -> archivers [ $ archiverId ] ; } return null ; } | Get an archiver |
15,534 | protected function getMessageBody ( $ parser , $ message , $ layout , $ template , $ compressOutput = true ) { $ body = false ; if ( ! empty ( $ template ) ) { try { $ body = $ parser -> render ( $ template , [ ] , $ compressOutput ) ; } catch ( ResourceNotFoundException $ ex ) { Tlog :: getInstance ( ) -> addError ( "Failed to get mail message template body $template" ) ; } } if ( $ body === false ) { $ body = $ parser -> renderString ( $ message , [ ] , $ compressOutput ) ; } if ( ! empty ( $ layout ) ) { $ parser -> assign ( 'message_body' , $ body ) ; $ body = $ parser -> render ( $ layout , [ ] , $ compressOutput ) ; } return $ body ; } | Calculate the message body given the HTML entered in the back - office the message layout and the message template |
15,535 | public function getHtmlMessageBody ( ParserInterface $ parser ) { return $ this -> getMessageBody ( $ parser , $ this -> getHtmlMessage ( ) , $ this -> getHtmlLayoutFileName ( ) , $ this -> getHtmlTemplateFileName ( ) ) ; } | Get the HTML message body |
15,536 | public function getTextMessageBody ( ParserInterface $ parser ) { $ message = $ this -> getMessageBody ( $ parser , $ this -> getTextMessage ( ) , $ this -> getTextLayoutFileName ( ) , $ this -> getTextTemplateFileName ( ) , true ) ; return preg_replace ( "/<br>/i" , "\n" , $ message ) ; } | Get the TEXT message body |
15,537 | public function buildMessage ( ParserInterface $ parser , \ Swift_Message $ messageInstance , $ useFallbackTemplate = true ) { $ parser -> pushTemplateDefinition ( $ parser -> getTemplateHelper ( ) -> getActiveMailTemplate ( ) , $ useFallbackTemplate ) ; $ subject = $ parser -> renderString ( $ this -> getSubject ( ) ) ; $ htmlMessage = $ this -> getHtmlMessageBody ( $ parser ) ; $ textMessage = $ this -> getTextMessageBody ( $ parser ) ; $ messageInstance -> setSubject ( $ subject ) ; if ( empty ( $ htmlMessage ) ) { $ messageInstance -> setBody ( $ textMessage , 'text/plain' ) ; } else { $ messageInstance -> setBody ( $ htmlMessage , 'text/html' ) ; if ( ! empty ( $ textMessage ) ) { $ messageInstance -> addPart ( $ textMessage , 'text/plain' ) ; } } $ parser -> popTemplateDefinition ( ) ; return $ messageInstance ; } | Add a subject and a body ( TEXT HTML or both depending on the message configuration . |
15,538 | public function renderPlatformModalContentAction ( ) { $ pids_id = $ this -> params ( ) -> fromQuery ( 'id' ) ; $ melisMelisCoreConfig = $ this -> serviceLocator -> get ( 'MelisCoreConfig' ) ; $ genericPlatformForm = $ melisMelisCoreConfig -> getFormMergedAndOrdered ( 'meliscms/tools/meliscms_platform_tool/forms/meliscms_tool_platform_generic_form' , 'meliscms_tool_platform_generic_form' ) ; $ factory = new \ Zend \ Form \ Factory ( ) ; $ formElements = $ this -> serviceLocator -> get ( 'FormElementManager' ) ; $ factory -> setFormElementManager ( $ formElements ) ; $ propertyForm = $ factory -> createForm ( $ genericPlatformForm ) ; $ view = new ViewModel ( ) ; $ melisEngineTablePlatformIds = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTablePlatformIds' ) ; $ availablePlatform = $ melisEngineTablePlatformIds -> getAvailablePlatforms ( ) -> toArray ( ) ; if ( ! empty ( $ pids_id ) ) { $ platformIdsData = $ melisEngineTablePlatformIds -> getEntryById ( $ pids_id ) ; $ platformIdsData = $ platformIdsData -> current ( ) ; $ platformTable = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTablePlatform' ) ; $ platformData = $ platformTable -> getEntryById ( $ pids_id ) ; $ platformData = $ platformData -> current ( ) ; $ platformIdsData -> pids_name_input = $ platformData -> plf_name ; $ propertyForm -> remove ( 'pids_name_select' ) ; $ propertyForm -> bind ( $ platformIdsData ) ; $ view -> pids_id = $ pids_id ; $ view -> tabTitle = 'tr_meliscms_tool_platform_ids_btn_edit' ; } else { $ propertyForm -> remove ( 'pids_id' ) ; $ propertyForm -> remove ( 'pids_name_input' ) ; $ view -> tabTitle = 'tr_meliscms_tool_platform_ids_btn_add' ; } $ view -> setVariable ( 'meliscms_tool_platform_generic_form' , $ propertyForm ) ; $ view -> setVariable ( 'available_platform' , $ availablePlatform ) ; $ view -> melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; return $ view ; } | Render Platform Content Modal |
15,539 | public function getPlatformList ( ) { $ success = 0 ; $ data = array ( ) ; if ( $ this -> getRequest ( ) -> isPost ( ) ) { $ success = 0 ; $ platform = $ this -> getServiceLocator ( ) -> get ( "Melisplatform" ) ; $ data = $ platform -> getPlatformList ( ) ; } return $ data ; } | Return list of platform |
15,540 | public function getExport ( $ exportId , $ dispatchException = false ) { $ export = ( new ExportQuery ) -> findPk ( $ exportId ) ; if ( $ export === null && $ dispatchException ) { throw new \ ErrorException ( Translator :: getInstance ( ) -> trans ( 'There is no id "%id" in the exports' , [ '%id' => $ exportId ] ) ) ; } return $ export ; } | Get export model based on given identifier |
15,541 | public function getExportByRef ( $ exportRef , $ dispatchException = false ) { $ export = ( new ExportQuery ) -> findOneByRef ( $ exportRef ) ; if ( $ export === null && $ dispatchException ) { throw new \ ErrorException ( Translator :: getInstance ( ) -> trans ( 'There is no ref "%ref" in the exports' , [ '%ref' => $ exportRef ] ) ) ; } return $ export ; } | Get export model based on given reference |
15,542 | public function getCategory ( $ exportCategoryId , $ dispatchException = false ) { $ category = ( new ExportCategoryQuery ) -> findPk ( $ exportCategoryId ) ; if ( $ category === null && $ dispatchException ) { throw new \ ErrorException ( Translator :: getInstance ( ) -> trans ( 'There is no id "%id" in the export categories' , [ '%id' => $ exportCategoryId ] ) ) ; } return $ category ; } | Get export category model based on given identifier |
15,543 | protected function processExportImages ( AbstractExport $ export , ArchiverInterface $ archiver ) { foreach ( $ export -> getImagesPaths ( ) as $ imagePath ) { $ archiver -> add ( $ imagePath ) ; } } | Add images to archive |
15,544 | protected function processExportDocuments ( AbstractExport $ export , ArchiverInterface $ archiver ) { foreach ( $ export -> getDocumentsPaths ( ) as $ documentPath ) { $ archiver -> add ( $ documentPath ) ; } } | Add documents to archive |
15,545 | protected function configureI18nProcessing ( ModelCriteria $ search , $ columns = array ( 'TITLE' , 'CHAPO' , 'DESCRIPTION' , 'POSTSCRIPTUM' ) , $ foreignTable = null , $ foreignKey = 'ID' , $ forceReturn = false ) { $ this -> locale = ModelCriteriaTools :: getI18n ( $ this -> getBackendContext ( ) , $ this -> getLang ( ) , $ search , $ this -> getCurrentRequest ( ) -> getSession ( ) -> getLang ( ) -> getLocale ( ) , $ columns , $ foreignTable , $ foreignKey , $ this -> getForceReturn ( ) ) ; } | Setup ModelCriteria for proper i18n processing |
15,546 | public function isMultidimensional ( ) { foreach ( $ this -> elements -> getItems ( ) as $ element ) { if ( $ element instanceof ArrayPairNode ) { if ( $ element -> getValue ( ) instanceof ArrayNode ) { return TRUE ; } } elseif ( $ element instanceof ArrayNode ) { return TRUE ; } } return FALSE ; } | Tests if the array contains another array . |
15,547 | public function toValue ( ) { $ ret = array ( ) ; foreach ( $ this -> elements -> getItems ( ) as $ element ) { if ( $ element instanceof ArrayNode ) { $ ref [ ] = $ element -> toValue ( ) ; } elseif ( $ element instanceof ArrayPairNode ) { $ key = $ element -> getKey ( ) ; $ value = $ element -> getValue ( ) ; $ value_convertable = $ value instanceof ScalarNode || $ value instanceof ArrayNode ; if ( ! ( $ key instanceof ScalarNode && $ value_convertable ) ) { throw new \ BadMethodCallException ( 'Can only convert scalar arrays.' ) ; } $ ret [ $ key -> toValue ( ) ] = $ value -> toValue ( ) ; } elseif ( $ element instanceof ScalarNode || $ element instanceof ArrayNode ) { $ ret [ ] = $ element -> toValue ( ) ; } else { throw new \ BadMethodCallException ( 'Can only convert scalar arrays.' ) ; } } return $ ret ; } | Convert to PHP array . |
15,548 | public function hasKey ( $ key , $ recursive = TRUE ) { if ( ! ( $ key instanceof ExpressionNode ) && ! is_scalar ( $ key ) ) { throw new \ InvalidArgumentException ( ) ; } $ keys = $ this -> getKeys ( $ recursive ) ; if ( is_scalar ( $ key ) ) { return $ keys -> filter ( Filter :: isInstanceOf ( '\Pharborist\Types\ScalarNode' ) ) -> is ( function ( ScalarNode $ node ) use ( $ key ) { return $ node -> toValue ( ) === $ key ; } ) ; } else { return $ keys -> is ( function ( ExpressionNode $ expr ) use ( $ key ) { return $ expr -> getText ( ) === $ key -> getText ( ) ; } ) ; } } | Returns if the array has a specific key . |
15,549 | public function getKeys ( $ recursive = TRUE ) { $ keys = new NodeCollection ( ) ; $ index = 0 ; foreach ( $ this -> elements -> getItems ( ) as $ element ) { if ( $ element instanceof ArrayPairNode ) { $ keys -> add ( $ element -> getKey ( ) ) ; $ value = $ element -> getValue ( ) ; } else { $ keys -> add ( Token :: integer ( $ index ++ ) ) ; $ value = $ element ; } if ( $ recursive && $ value instanceof ArrayNode ) { $ keys -> add ( $ value -> getKeys ( $ recursive ) ) ; } } return $ keys ; } | Get the keys of the array . |
15,550 | public function getValues ( $ recursive = TRUE ) { $ values = new NodeCollection ( ) ; foreach ( $ this -> elements -> getItems ( ) as $ element ) { if ( $ element instanceof ArrayPairNode ) { $ value = $ element -> getValue ( ) ; if ( $ recursive && $ value instanceof ArrayNode ) { $ values -> add ( $ value -> getValues ( $ recursive ) ) ; } else { $ values -> add ( $ value ) ; } } else { $ values -> add ( $ element ) ; } } return $ values ; } | Get the values of the array . |
15,551 | public function configureAction ( $ id ) { $ exportHandler = $ this -> container -> get ( 'thelia.export.handler' ) ; $ export = $ exportHandler -> getExport ( $ id ) ; if ( $ export === null ) { return $ this -> pageNotFound ( ) ; } $ templateName = 'export-page' ; if ( $ this -> getRequest ( ) -> isXmlHttpRequest ( ) ) { $ templateName = 'ajax/export-modal' ; } return $ this -> render ( $ templateName , [ 'exportId' => $ id , 'hasImages' => $ export -> hasImages ( ) , 'hasDocuments' => $ export -> hasDocuments ( ) , 'useRange' => $ export -> useRangeDate ( ) ] ) ; } | Display export configuration view |
15,552 | public function exportAction ( $ id ) { $ exportHandler = $ this -> container -> get ( 'thelia.export.handler' ) ; $ export = $ exportHandler -> getExport ( $ id ) ; if ( $ export === null ) { return $ this -> pageNotFound ( ) ; } $ form = $ this -> createForm ( AdminForm :: EXPORT ) ; try { $ validatedForm = $ this -> validateForm ( $ form ) ; set_time_limit ( 0 ) ; $ lang = ( new LangQuery ) -> findPk ( $ validatedForm -> get ( 'language' ) -> getData ( ) ) ; $ serializerManager = $ this -> container -> get ( RegisterSerializerPass :: MANAGER_SERVICE_ID ) ; $ serializer = $ serializerManager -> get ( $ validatedForm -> get ( 'serializer' ) -> getData ( ) ) ; $ archiver = null ; if ( $ validatedForm -> get ( 'do_compress' ) -> getData ( ) ) { $ archiverManager = $ this -> container -> get ( RegisterArchiverPass :: MANAGER_SERVICE_ID ) ; $ archiver = $ archiverManager -> get ( $ validatedForm -> get ( 'archiver' ) -> getData ( ) ) ; } $ rangeDate = null ; if ( $ validatedForm -> get ( 'range_date_start' ) -> getData ( ) && $ validatedForm -> get ( 'range_date_end' ) -> getData ( ) ) { $ rangeDate = [ 'start' => $ validatedForm -> get ( 'range_date_start' ) -> getData ( ) , 'end' => $ validatedForm -> get ( 'range_date_end' ) -> getData ( ) ] ; } $ exportEvent = $ exportHandler -> export ( $ export , $ serializer , $ archiver , $ lang , $ validatedForm -> get ( 'images' ) -> getData ( ) , $ validatedForm -> get ( 'documents' ) -> getData ( ) , $ rangeDate ) ; $ contentType = $ exportEvent -> getSerializer ( ) -> getMimeType ( ) ; $ fileExt = $ exportEvent -> getSerializer ( ) -> getExtension ( ) ; if ( $ exportEvent -> getArchiver ( ) !== null ) { $ contentType = $ exportEvent -> getArchiver ( ) -> getMimeType ( ) ; $ fileExt = $ exportEvent -> getArchiver ( ) -> getExtension ( ) ; } $ header = [ 'Content-Type' => $ contentType , 'Content-Disposition' => sprintf ( '%s; filename="%s.%s"' , ResponseHeaderBag :: DISPOSITION_ATTACHMENT , $ exportEvent -> getExport ( ) -> getFileName ( ) , $ fileExt ) ] ; return new BinaryFileResponse ( $ exportEvent -> getFilePath ( ) , 200 , $ header , false ) ; } catch ( FormValidationException $ e ) { $ form -> setErrorMessage ( $ this -> createStandardFormValidationErrorMessage ( $ e ) ) ; } catch ( \ Exception $ e ) { $ this -> getParserContext ( ) -> setGeneralError ( $ e -> getMessage ( ) ) ; } $ this -> getParserContext ( ) -> addForm ( $ form ) ; return $ this -> configureAction ( $ id ) ; } | Handle export action |
15,553 | public function current ( ) { if ( $ this -> position >= $ this -> length ) { return NULL ; } return $ this -> tokens [ $ this -> position ] ; } | Return the current token . |
15,554 | public function peek ( $ offset ) { if ( $ this -> position + $ offset >= $ this -> length ) { return NULL ; } return $ this -> tokens [ $ this -> position + $ offset ] ; } | Peek ahead . |
15,555 | public function next ( ) { $ this -> position ++ ; if ( $ this -> position >= $ this -> length ) { $ this -> position = $ this -> length ; return NULL ; } return $ this -> tokens [ $ this -> position ] ; } | Move to the next token and return it . |
15,556 | public function make ( array $ config ) { Arr :: requires ( $ config , [ 'token' ] ) ; $ client = new Client ( ) ; return new YoGateway ( $ client , $ config ) ; } | Create a new yo gateway instance . |
15,557 | public function isNotPaid ( $ exact = true ) { if ( $ exact ) { return $ this -> hasStatusHelper ( OrderStatus :: CODE_NOT_PAID ) ; } else { return ! $ this -> isPaid ( false ) ; } } | Check if the current status is NOT PAID |
15,558 | public function isPaid ( $ exact = true ) { return $ this -> hasStatusHelper ( $ exact ? OrderStatus :: CODE_PAID : [ OrderStatus :: CODE_PAID , OrderStatus :: CODE_PROCESSING , OrderStatus :: CODE_SENT ] ) ; } | Check if the current status is PAID |
15,559 | private function checkAvailability ( ) { $ available = get_site_transient ( 'boldgrid_available' ) ; $ wp_http = new WP_Http ( ) ; $ url = $ this -> getUrl ( ) ; if ( $ wp_http -> block_request ( $ url ) === false ) { $ available = 1 ; } set_site_transient ( 'boldgrid_available' , ( int ) $ available , 2 * MINUTE_IN_SECONDS ) ; return $ available ; } | Checks that the API can be reached . |
15,560 | public function getTreePagesByPageIdAction ( ) { $ idPage = $ this -> params ( ) -> fromQuery ( 'nodeId' , - 1 ) ; $ this -> getEventManager ( ) -> trigger ( 'melis_cms_tree_get_pages_start' , $ this , array ( 'idPage' => $ idPage ) ) ; if ( $ idPage == - 1 ) $ rootPages = $ this -> getRootForUser ( ) ; else $ rootPages = array ( $ idPage ) ; $ final = $ this -> getPagesDatas ( $ rootPages ) ; $ triggerResponse = $ this -> getEventManager ( ) -> trigger ( 'melis_cms_tree_get_pages_end' , $ this , array ( 'parentId' => $ idPage , 'request' => $ final ) ) ; $ response = null ; if ( isset ( $ triggerResponse [ 0 ] ) && ! empty ( $ triggerResponse [ 0 ] ) ) $ response = $ this -> formatTreeResponse ( $ triggerResponse [ 0 ] ) ; else $ response = $ this -> formatTreeResponse ( $ final ) ; return $ response ; } | Get the children of an idPage If called in http will return an html view If called in xhr will return a json view with the html and others informations like javascript datas . |
15,561 | public function getTreePagesForRightsManagementAction ( ) { $ idPage = $ this -> params ( ) -> fromQuery ( 'nodeId' , - 1 ) ; if ( $ idPage == MelisCmsRightsService :: MELISCMS_PREFIX_PAGES . '_root' ) $ idPage = - 1 ; else $ idPage = str_replace ( MelisCmsRightsService :: MELISCMS_PREFIX_PAGES . '_' , '' , $ idPage ) ; $ rootPages = array ( $ idPage ) ; $ final = $ this -> getPagesDatas ( $ rootPages ) ; return $ this -> formatTreeResponse ( $ final , true ) ; } | Gets the root page when showing the tree of pages in rights tool so that all pages are displayed and not only the one you have access to |
15,562 | private function cleanBreadcrumb ( $ breadcrumb ) { $ newArray = array ( ) ; if ( ! empty ( $ breadcrumb ) ) foreach ( $ breadcrumb as $ page ) { if ( ! empty ( $ page -> tree_page_id ) ) array_push ( $ newArray , $ page -> tree_page_id ) ; } return $ newArray ; } | Creates a simple array with the page ids from the result of db |
15,563 | private function getRootForUser ( ) { $ melisEngineTree = $ this -> serviceLocator -> get ( 'MelisEngineTree' ) ; $ melisCoreAuth = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreAuth' ) ; $ melisCmsRights = $ this -> getServiceLocator ( ) -> get ( 'MelisCmsRights' ) ; $ xmlRights = $ melisCoreAuth -> getAuthRights ( ) ; $ rightsObj = simplexml_load_string ( $ xmlRights ) ; $ rootPages = array ( ) ; $ breadcrumbRightPages = array ( ) ; $ sectionId = MelisCmsRightsService :: MELISCMS_PREFIX_PAGES ; if ( empty ( $ rightsObj -> $ sectionId ) ) return array ( ) ; foreach ( $ rightsObj -> $ sectionId -> id as $ rightsPageId ) { $ rightsPageId = ( int ) $ rightsPageId ; if ( $ rightsPageId == - 1 ) return array ( - 1 ) ; $ breadcrumb = $ melisEngineTree -> getPageBreadcrumb ( $ rightsPageId , 0 , true ) ; $ breadcrumb = $ this -> cleanBreadcrumb ( $ breadcrumb ) ; $ add = true ; for ( $ i = 0 ; $ i < count ( $ breadcrumbRightPages ) ; $ i ++ ) { $ result = array_intersect ( $ breadcrumb , $ breadcrumbRightPages [ $ i ] ) ; if ( $ result === $ breadcrumb ) { $ add = false ; $ breadcrumbRightPages [ $ i ] = $ breadcrumb ; break ; } if ( $ result === $ breadcrumbRightPages [ $ i ] ) { $ add = false ; break ; } } if ( $ add ) $ breadcrumbRightPages [ count ( $ breadcrumbRightPages ) ] = $ breadcrumb ; } foreach ( $ breadcrumbRightPages as $ breadcrumbPage ) { if ( count ( $ breadcrumbPage ) > 0 ) array_push ( $ rootPages , $ breadcrumbPage [ count ( $ breadcrumbPage ) - 1 ] ) ; } return $ rootPages ; } | Gets the root pages for a user depending on his rights |
15,564 | public function getPageIdBreadcrumbAction ( ) { $ idPage = $ this -> params ( ) -> fromRoute ( 'idPage' , $ this -> params ( ) -> fromQuery ( 'idPage' , '' ) ) ; $ idPage = ( $ idPage == 'root' ) ? - 1 : $ idPage ; $ includeSelf = $ this -> params ( ) -> fromRoute ( 'includeSelf' , $ this -> params ( ) -> fromQuery ( 'includeSelf' , '' ) ) ; $ melisEngineTree = $ this -> serviceLocator -> get ( 'MelisEngineTree' ) ; $ breadcrumb = $ melisEngineTree -> getPageBreadcrumb ( $ idPage , 0 , true ) ; $ pageFatherId = $ idPage ; $ jsonresult = array ( ) ; if ( $ includeSelf ) { array_unshift ( $ jsonresult , $ pageFatherId ) ; } while ( $ pageFatherId != NULL ) { $ page = $ melisEngineTree -> getPageFather ( $ pageFatherId , 'saved' ) -> current ( ) ; $ pageFatherId = ! empty ( $ page ) ? $ page -> tree_father_page_id : NULL ; if ( ! empty ( $ pageFatherId ) ) { array_unshift ( $ jsonresult , $ pageFatherId ) ; } } return new JsonModel ( $ jsonresult ) ; } | Sends back the pageId breadcrumb |
15,565 | public function canEditPagesAction ( ) { $ melisCoreAuth = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreAuth' ) ; $ xmlRights = $ melisCoreAuth -> getAuthRights ( ) ; $ rightsObj = simplexml_load_string ( $ xmlRights ) ; $ sectionId = MelisCmsRightsService :: MELISCMS_PREFIX_PAGES ; if ( empty ( $ rightsObj -> $ sectionId -> id ) ) $ edit = 0 ; else $ edit = 1 ; $ result = array ( 'success' => 1 , 'edit' => $ edit ) ; return new JsonModel ( $ result ) ; } | Sends back if a page can be edited by the user or not |
15,566 | public function getDiscount ( ) { $ discount = 0.00 ; $ coupons = $ this -> facade -> getCurrentCoupons ( ) ; if ( \ count ( $ coupons ) > 0 ) { $ couponsKept = $ this -> sortCoupons ( $ coupons ) ; $ discount = $ this -> getEffect ( $ couponsKept ) ; $ checkoutTotalPrice = $ this -> facade -> getCartTotalTaxPrice ( ) ; if ( $ discount >= $ checkoutTotalPrice ) { $ discount = $ checkoutTotalPrice ; } } return $ discount ; } | Get Discount for the given Coupons |
15,567 | public function isCouponRemovingPostage ( Order $ order ) { $ coupons = $ this -> facade -> getCurrentCoupons ( ) ; if ( \ count ( $ coupons ) == 0 ) { return false ; } $ couponsKept = $ this -> sortCoupons ( $ coupons ) ; foreach ( $ couponsKept as $ coupon ) { if ( $ coupon -> isRemovingPostage ( ) ) { $ couponCountries = $ coupon -> getFreeShippingForCountries ( ) ; if ( ! $ couponCountries -> isEmpty ( ) ) { if ( null === $ deliveryAddress = AddressQuery :: create ( ) -> findPk ( $ order -> getChoosenDeliveryAddress ( ) ) ) { continue ; } $ countryValid = false ; $ deliveryCountryId = $ deliveryAddress -> getCountryId ( ) ; foreach ( $ couponCountries as $ couponCountry ) { if ( $ deliveryCountryId == $ couponCountry -> getCountryId ( ) ) { $ countryValid = true ; break ; } } if ( ! $ countryValid ) { continue ; } } $ couponModules = $ coupon -> getFreeShippingForModules ( ) ; if ( ! $ couponModules -> isEmpty ( ) ) { $ moduleValid = false ; $ shippingModuleId = $ order -> getDeliveryModuleId ( ) ; foreach ( $ couponModules as $ couponModule ) { if ( $ shippingModuleId == $ couponModule -> getModuleId ( ) ) { $ moduleValid = true ; break ; } } if ( ! $ moduleValid ) { continue ; } } return true ; } } return false ; } | Check if there is a Coupon removing Postage |
15,568 | protected function sortCoupons ( array $ coupons ) { $ couponsKept = array ( ) ; foreach ( $ coupons as $ coupon ) { if ( $ coupon && ! $ coupon -> isExpired ( ) ) { if ( $ coupon -> isCumulative ( ) ) { if ( isset ( $ couponsKept [ 0 ] ) ) { $ previousCoupon = $ couponsKept [ 0 ] ; if ( $ previousCoupon -> isCumulative ( ) ) { $ couponsKept [ ] = $ coupon ; } else { $ couponsKept = array ( $ coupon ) ; } } else { $ couponsKept = array ( $ coupon ) ; } } else { $ couponsKept = array ( $ coupon ) ; } } } $ coupons = $ couponsKept ; $ couponsKept = array ( ) ; foreach ( $ coupons as $ coupon ) { try { if ( $ coupon -> isMatching ( ) ) { $ couponsKept [ ] = $ coupon ; } } catch ( UnmatchableConditionException $ e ) { continue ; } } return $ couponsKept ; } | Sort Coupon to keep Coupon not cumulative cancels previous |
15,569 | protected function getEffect ( array $ coupons ) { $ discount = 0.00 ; foreach ( $ coupons as $ coupon ) { $ discount += $ coupon -> exec ( $ this -> facade ) ; } return $ discount ; } | Process given Coupon in order to get their cumulative effects |
15,570 | public function clear ( ) { $ coupons = $ this -> facade -> getCurrentCoupons ( ) ; foreach ( $ coupons as $ coupon ) { $ coupon -> clear ( ) ; } } | Clear all data kept by coupons |
15,571 | public function decrementQuantity ( Coupon $ coupon , $ customerId = null ) { if ( $ coupon -> isUsageUnlimited ( ) ) { return true ; } else { try { $ usageLeft = $ coupon -> getUsagesLeft ( $ customerId ) ; if ( $ usageLeft > 0 ) { if ( $ coupon -> getPerCustomerUsageCount ( ) ) { if ( null == $ customerId ) { throw new \ LogicException ( "Customer should not be null at this time." ) ; } $ ccc = CouponCustomerCountQuery :: create ( ) -> filterByCouponId ( $ coupon -> getId ( ) ) -> filterByCustomerId ( $ customerId ) -> findOne ( ) ; if ( $ ccc === null ) { $ ccc = new CouponCustomerCount ( ) ; $ ccc -> setCustomerId ( $ customerId ) -> setCouponId ( $ coupon -> getId ( ) ) -> setCount ( 0 ) ; } $ newCount = 1 + $ ccc -> getCount ( ) ; $ ccc -> setCount ( $ newCount ) -> save ( ) ; return $ usageLeft - $ newCount ; } else { $ coupon -> setMaxUsage ( -- $ usageLeft ) ; $ coupon -> save ( ) ; return $ usageLeft ; } } } catch ( \ Exception $ ex ) { Tlog :: getInstance ( ) -> addError ( sprintf ( "Failed to decrement coupon %s: %s" , $ coupon -> getCode ( ) , $ ex -> getMessage ( ) ) ) ; } } return false ; } | Decrement this coupon quantity |
15,572 | public function format ( AddressInterface $ address , $ locale = null , $ html = true , $ htmlTag = "p" , $ htmlAttributes = [ ] ) { $ locale = $ this -> normalizeLocale ( $ locale ) ; $ addressFormatRepository = new AddressFormatRepository ( ) ; $ countryRepository = new CountryRepository ( ) ; $ subdivisionRepository = new SubdivisionRepository ( ) ; $ formatter = new DefaultFormatter ( $ addressFormatRepository , $ countryRepository , $ subdivisionRepository , $ locale ) ; $ formatter -> setOption ( 'html' , $ html ) ; $ formatter -> setOption ( 'html_tag' , $ htmlTag ) ; $ formatter -> setOption ( 'html_attributes' , $ htmlAttributes ) ; $ addressFormatted = $ formatter -> format ( $ address ) ; return $ addressFormatted ; } | Format an address |
15,573 | public function postalLabelFormat ( AddressInterface $ address , $ locale = null , $ originCountry = null , $ options = [ ] ) { $ locale = $ this -> normalizeLocale ( $ locale ) ; $ addressFormatRepository = new AddressFormatRepository ( ) ; $ countryRepository = new CountryRepository ( ) ; $ subdivisionRepository = new SubdivisionRepository ( ) ; if ( null === $ originCountry ) { $ countryId = Country :: getShopLocation ( ) ; if ( null === $ country = CountryQuery :: create ( ) -> findPk ( $ countryId ) ) { $ country = Country :: getDefaultCountry ( ) ; } $ originCountry = $ country -> getIsoalpha2 ( ) ; } $ formatter = new PostalLabelFormatter ( $ addressFormatRepository , $ countryRepository , $ subdivisionRepository , $ originCountry , $ locale , $ options ) ; $ addressFormatted = $ formatter -> format ( $ address ) ; return $ addressFormatted ; } | Format an address to a postal label |
15,574 | public function getTranslator ( ) { if ( null === $ this -> translator ) { $ this -> translator = $ this -> container -> get ( 'thelia.translator' ) ; } return $ this -> translator ; } | return the Translator |
15,575 | protected function retrieveFormBasedUrl ( $ parameterName , BaseForm $ form = null ) { $ url = null ; if ( $ form != null ) { $ url = $ form -> getFormDefinedUrl ( $ parameterName ) ; } else { $ url = $ this -> container -> get ( 'request_stack' ) -> getCurrentRequest ( ) -> get ( $ parameterName ) ; } return $ url ; } | Search url in a form parameter or in a request parameter . |
15,576 | protected function getRoute ( $ routeId , $ parameters = array ( ) , $ referenceType = Router :: ABSOLUTE_URL ) { return $ this -> getRouteFromRouter ( $ this -> getCurrentRouter ( ) , $ routeId , $ parameters , $ referenceType ) ; } | Return the route path defined for the givent route ID |
15,577 | protected function getRouteFromRouter ( $ routerName , $ routeId , $ parameters = array ( ) , $ referenceType = Router :: ABSOLUTE_URL ) { $ router = $ this -> getRouter ( $ routerName ) ; if ( $ router == null ) { throw new \ InvalidArgumentException ( sprintf ( "Router '%s' does not exists." , $ routerName ) ) ; } return $ router -> generate ( $ routeId , $ parameters , $ referenceType ) ; } | Get a route path from the route id . |
15,578 | protected function checkXmlHttpRequest ( ) { if ( false === $ this -> container -> get ( 'request_stack' ) -> getCurrentRequest ( ) -> isXmlHttpRequest ( ) && false === $ this -> isDebug ( ) ) { $ this -> accessDenied ( ) ; } } | check if the current http request is a XmlHttpRequest . |
15,579 | protected function performAdditionalDeleteAction ( $ deleteEvent ) { if ( $ deleteEvent -> getProductCount ( ) > 0 ) { $ this -> getParserContext ( ) -> setGeneralError ( $ this -> getTranslator ( ) -> trans ( "This template is in use in some of your products, and cannot be deleted. Delete it from all your products and try again." ) ) ; return $ this -> renderList ( ) ; } return null ; } | Process delete failure which may occurs if template is in use . |
15,580 | public static function append ( $ resource , $ action , $ message , Request $ request , UserInterface $ adminUser = null , $ withRequestContent = true , $ resourceId = null ) { $ log = new AdminLog ( ) ; $ log -> setAdminLogin ( $ adminUser !== null ? $ adminUser -> getUsername ( ) : '<no login>' ) -> setAdminFirstname ( $ adminUser !== null && $ adminUser instanceof Admin ? $ adminUser -> getFirstname ( ) : '<no first name>' ) -> setAdminLastname ( $ adminUser !== null && $ adminUser instanceof Admin ? $ adminUser -> getLastname ( ) : '<no last name>' ) -> setResource ( $ resource ) -> setResourceId ( $ resourceId ) -> setAction ( $ action ) -> setMessage ( $ message ) -> setRequest ( $ request -> toString ( $ withRequestContent ) ) ; try { $ log -> save ( ) ; } catch ( \ Exception $ ex ) { Tlog :: getInstance ( ) -> err ( "Failed to insert new entry in AdminLog: {ex}" , array ( 'ex' => $ ex ) ) ; } } | A simple helper to insert an entry in the admin log |
15,581 | protected function spaceBefore ( Node $ node ) { $ prev = $ node -> previousToken ( ) ; if ( $ prev instanceof WhitespaceNode ) { $ prev -> setText ( ' ' ) ; } else { $ node -> before ( Token :: space ( ) ) ; } } | Set a single space before a node . |
15,582 | protected function spaceAfter ( Node $ node ) { $ next = $ node -> nextToken ( ) ; if ( $ next instanceof WhitespaceNode ) { $ next -> setText ( ' ' ) ; } else { $ node -> after ( Token :: space ( ) ) ; } } | Set a single space after a node . |
15,583 | protected function removeSpaceBefore ( Node $ node ) { $ prev = $ node -> previousToken ( ) ; if ( $ prev instanceof WhitespaceNode ) { $ prev -> remove ( ) ; } } | Remove whitespace before a node . |
15,584 | protected function removeSpaceAfter ( Node $ node ) { $ next = $ node -> nextToken ( ) ; if ( $ next instanceof WhitespaceNode ) { $ next -> remove ( ) ; } } | Remove whitespace after a node . |
15,585 | protected function newlineBefore ( Node $ node , $ close = FALSE ) { $ prev = $ node -> previousToken ( ) ; if ( $ prev instanceof WhitespaceNode ) { $ prev_ws = $ prev -> previousToken ( ) ; if ( $ prev_ws instanceof CommentNode && $ prev_ws -> isLineComment ( ) && $ prev -> getNewlineCount ( ) === 0 ) { $ prev -> setText ( $ this -> getIndent ( $ close ) ) ; } else { $ prev -> setText ( $ this -> getNewlineIndent ( $ prev , $ close ) ) ; } } else { if ( $ prev instanceof CommentNode && $ prev -> isLineComment ( ) ) { if ( $ this -> indentLevel > 0 ) { $ node -> before ( Token :: whitespace ( $ this -> getIndent ( $ close ) ) ) ; } } else { $ node -> before ( Token :: whitespace ( $ this -> getNewlineIndent ( NULL , $ close ) ) ) ; } } } | Set so there a newline before a node . |
15,586 | protected function newlineAfter ( Node $ node ) { $ next = $ node -> nextToken ( ) ; if ( $ next instanceof WhitespaceNode ) { $ next -> setText ( $ this -> getNewlineIndent ( $ next ) ) ; } else { $ node -> after ( Token :: whitespace ( $ this -> getNewlineIndent ( ) ) ) ; } } | Set so there a newline after a node . |
15,587 | protected function handleBuiltinConstantNode ( ConstantNode $ node ) { $ to_upper = $ this -> config [ 'boolean_null_upper' ] ; if ( $ to_upper ) { $ node -> toUpperCase ( ) ; } else { $ node -> toLowerCase ( ) ; } } | Handle formatting of constant node . |
15,588 | protected function encloseBlock ( $ node ) { if ( $ node && ! ( $ node instanceof StatementBlockNode ) ) { $ blockNode = new StatementBlockNode ( ) ; $ blockNode -> append ( [ Token :: openBrace ( ) , clone $ node , Token :: closeBrace ( ) ] ) ; $ node -> replaceWith ( $ blockNode ) ; } } | Wrap single line body statements in braces . |
15,589 | protected function handleParens ( $ node ) { $ open_paren = $ node -> getOpenParen ( ) ; $ this -> removeSpaceAfter ( $ open_paren ) ; $ this -> spaceBefore ( $ open_paren ) ; $ close_paren = $ node -> getCloseParen ( ) ; $ this -> removeSpaceBefore ( $ close_paren ) ; } | Handle whitespace around and inside parens for control structures . |
15,590 | protected function handleControlStructure ( $ node ) { $ this -> handleParens ( $ node ) ; $ colons = $ node -> children ( Filter :: isTokenType ( ':' ) ) ; foreach ( $ colons as $ colon ) { $ this -> removeSpaceBefore ( $ colon ) ; } if ( $ colons -> isNotEmpty ( ) ) { $ this -> newlineBefore ( $ node -> lastChild ( ) -> previous ( ) ) ; } } | Generic formatting rules for control structures . |
15,591 | protected function isDeclaration ( ParentNode $ node ) { return $ node instanceof FunctionDeclarationNode || $ node instanceof SingleInheritanceNode || $ node instanceof InterfaceNode || $ node instanceof ClassMethodNode || $ node instanceof InterfaceMethodNode ; } | Test if declaration_brace_newline setting applies to node . |
15,592 | protected function calculateColumnPosition ( Node $ node ) { $ column_position = 1 ; $ start_token = $ node instanceof ParentNode ? $ node -> firstToken ( ) : $ node ; $ token = $ start_token ; while ( $ token = $ token -> previousToken ( ) ) { if ( $ token instanceof WhitespaceNode && $ token -> getNewlineCount ( ) > 0 ) { $ lines = explode ( $ this -> config [ 'nl' ] , $ token -> getText ( ) ) ; $ last_line = end ( $ lines ) ; $ column_position += strlen ( $ last_line ) ; break ; } $ column_position += strlen ( $ token -> getText ( ) ) ; } return $ column_position ; } | Calculate the column start position of the node . |
15,593 | public function setEffects ( array $ effects ) { $ this -> amount = isset ( $ effects [ 'amount' ] ) ? $ effects [ 'amount' ] : 0 ; $ this -> effects = $ effects ; } | Set effects ready to be serialized |
15,594 | public function toMessage ( ) { return array_merge ( $ this -> attributes , [ 'topic' => $ this -> topic , 'event' => $ this -> name , 'version' => $ this -> version , ] ) ; } | Return the event in a message format ready for publishing . |
15,595 | public function matches ( $ expr ) { $ params = self :: parseEventExpr ( $ expr ) ; if ( $ params [ 'topic' ] === '*' ) { return true ; } elseif ( $ this -> topic !== $ params [ 'topic' ] ) { return false ; } if ( $ params [ 'event' ] === '*' ) { return true ; } elseif ( $ this -> name !== $ params [ 'event' ] ) { return false ; } if ( $ params [ 'version' ] === '*' ) { return true ; } else { return Semver :: satisfies ( $ this -> version , $ params [ 'version' ] ) ; } } | Check whether or not the event matches the given expression . |
15,596 | public static function createOperator ( $ token_type , $ static_only = FALSE ) { if ( array_key_exists ( $ token_type , self :: $ operators ) ) { list ( $ assoc , $ precedence , $ static , $ binary_class_name , $ unary_class_name ) = self :: $ operators [ $ token_type ] ; if ( $ static_only && ! $ static ) { return NULL ; } $ operator = new Operator ( ) ; $ operator -> type = $ token_type ; $ operator -> associativity = $ assoc ; $ operator -> precedence = $ precedence ; $ operator -> hasBinaryMode = $ binary_class_name !== NULL ; $ operator -> hasUnaryMode = $ unary_class_name !== NULL ; $ operator -> binaryClassName = $ binary_class_name ; $ operator -> unaryClassName = $ unary_class_name ; return $ operator ; } return NULL ; } | Create an OperatorNode for the given token type . |
15,597 | public static function getPluginFile ( $ slug ) { if ( ! function_exists ( 'get_plugins' ) ) { require ABSPATH . '/wp-admin/includes/plugin.php' ; } $ plugins = get_plugins ( ) ; foreach ( $ plugins as $ file => $ info ) { $ basename = dirname ( plugin_basename ( $ file ) ) ; if ( $ basename === $ slug ) { return $ file ; } } return null ; } | Helper to get and verify the plugin file . |
15,598 | public function buildCouponFromCode ( $ couponCode ) { $ couponModel = $ this -> facade -> findOneCouponByCode ( $ couponCode ) ; if ( $ couponModel === null ) { return false ; } if ( ! $ couponModel -> getIsEnabled ( ) ) { throw new InactiveCouponException ( $ couponCode ) ; } $ nowDateTime = new \ DateTime ( ) ; if ( $ couponModel -> getStartDate ( ) !== null && $ couponModel -> getStartDate ( ) > $ nowDateTime ) { throw new CouponNotReleaseException ( $ couponCode ) ; } if ( $ couponModel -> getExpirationDate ( ) < $ nowDateTime ) { throw new CouponExpiredException ( $ couponCode ) ; } if ( ! $ couponModel -> isUsageUnlimited ( ) ) { if ( null === $ customer = $ this -> facade -> getCustomer ( ) ) { throw new UnmatchableConditionException ( $ couponCode ) ; } if ( $ couponModel -> getUsagesLeft ( $ customer -> getId ( ) ) <= 0 ) { throw new CouponNoUsageLeftException ( $ couponCode ) ; } } $ couponInterface = $ this -> buildCouponFromModel ( $ couponModel ) ; if ( $ couponInterface && $ couponInterface -> getConditions ( ) -> count ( ) == 0 ) { throw new InvalidConditionException ( \ get_class ( $ couponInterface ) ) ; } return $ couponInterface ; } | Build a CouponInterface from its database data |
15,599 | public function buildCouponFromModel ( Coupon $ model ) { $ isCumulative = ( $ model -> getIsCumulative ( ) == 1 ? true : false ) ; $ isRemovingPostage = ( $ model -> getIsRemovingPostage ( ) == 1 ? true : false ) ; if ( ! $ this -> container -> has ( $ model -> getType ( ) ) ) { return false ; } $ couponManager = $ this -> container -> get ( $ model -> getType ( ) ) ; $ couponManager -> set ( $ this -> facade , $ model -> getCode ( ) , $ model -> getTitle ( ) , $ model -> getShortDescription ( ) , $ model -> getDescription ( ) , $ model -> getEffects ( ) , $ isCumulative , $ isRemovingPostage , $ model -> getIsAvailableOnSpecialOffers ( ) , $ model -> getIsEnabled ( ) , $ model -> getMaxUsage ( ) , $ model -> getExpirationDate ( ) , $ model -> getFreeShippingForCountries ( ) , $ model -> getFreeShippingForModules ( ) , $ model -> getPerCustomerUsageCount ( ) ) ; $ conditionFactory = $ this -> container -> get ( 'thelia.condition.factory' ) ; $ conditions = $ conditionFactory -> unserializeConditionCollection ( $ model -> getSerializedConditions ( ) ) ; $ couponManager -> setConditions ( $ conditions ) ; return clone $ couponManager ; } | Build a CouponInterface from its Model data contained in the DataBase |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.