idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
15,200 | public function modify ( MessageUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ message = MessageQuery :: create ( ) -> findPk ( $ event -> getMessageId ( ) ) ) { $ message -> setDispatcher ( $ dispatcher ) -> setName ( $ event -> getMessageName ( ) ) -> setSecured ( $ event -> getSecured ( ) ) -> setLocale ( $ event -> getLocale ( ) ) -> setTitle ( $ event -> getTitle ( ) ) -> setSubject ( $ event -> getSubject ( ) ) -> setHtmlMessage ( $ event -> getHtmlMessage ( ) ) -> setTextMessage ( $ event -> getTextMessage ( ) ) -> setHtmlLayoutFileName ( $ event -> getHtmlLayoutFileName ( ) ) -> setHtmlTemplateFileName ( $ event -> getHtmlTemplateFileName ( ) ) -> setTextLayoutFileName ( $ event -> getTextLayoutFileName ( ) ) -> setTextTemplateFileName ( $ event -> getTextTemplateFileName ( ) ) -> save ( ) ; $ event -> setMessage ( $ message ) ; } } | Change a message |
15,201 | public function delete ( MessageDeleteEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== ( $ message = MessageQuery :: create ( ) -> findPk ( $ event -> getMessageId ( ) ) ) ) { $ message -> setDispatcher ( $ dispatcher ) -> delete ( ) ; $ event -> setMessage ( $ message ) ; } } | Delete a messageuration entry |
15,202 | public function getValidators ( ) { $ this -> validators = $ this -> generateInputs ( ) ; $ translatedInputs = [ ] ; foreach ( $ this -> validators as $ key => $ validator ) { $ translatedOperators = [ ] ; foreach ( $ validator [ 'availableOperators' ] as $ availableOperators ) { $ translatedOperators [ $ availableOperators ] = Operators :: getI18n ( $ this -> translator , $ availableOperators ) ; } $ validator [ 'availableOperators' ] = $ translatedOperators ; $ translatedInputs [ $ key ] = $ validator ; } $ validators = [ 'inputs' => $ translatedInputs , 'setOperators' => $ this -> operators , 'setValues' => $ this -> values ] ; return $ validators ; } | Return all validators |
15,203 | public function getSerializableCondition ( ) { $ serializableCondition = new SerializableCondition ( ) ; $ serializableCondition -> conditionServiceId = $ this -> getServiceId ( ) ; $ serializableCondition -> operators = $ this -> operators ; $ serializableCondition -> values = $ this -> values ; return $ serializableCondition ; } | Return a serializable Condition |
15,204 | protected function isCurrencyValid ( $ currencyValue ) { $ availableCurrencies = $ this -> facade -> getAvailableCurrencies ( ) ; $ currencyFound = false ; foreach ( $ availableCurrencies as $ currency ) { if ( $ currencyValue == $ currency -> getCode ( ) ) { $ currencyFound = true ; } } if ( ! $ currencyFound ) { throw new InvalidConditionValueException ( \ get_class ( ) , 'currency' ) ; } return true ; } | Check if currency if valid or not |
15,205 | protected function isPriceValid ( $ priceValue ) { $ floatType = new FloatType ( ) ; if ( ! $ floatType -> isValid ( $ priceValue ) || $ priceValue <= 0 ) { throw new InvalidConditionValueException ( \ get_class ( ) , 'price' ) ; } return true ; } | Check if price is valid |
15,206 | protected function drawBackOfficeInputOperators ( $ inputKey ) { $ html = '' ; $ inputs = $ this -> getValidators ( ) ; if ( isset ( $ inputs [ 'inputs' ] [ $ inputKey ] ) ) { $ html = $ this -> facade -> getParser ( ) -> render ( 'coupon/condition-fragments/condition-selector.html' , [ 'operators' => $ inputs [ 'inputs' ] [ $ inputKey ] [ 'availableOperators' ] , 'value' => isset ( $ this -> operators [ $ inputKey ] ) ? $ this -> operators [ $ inputKey ] : '' , 'inputKey' => $ inputKey ] ) ; } return $ html ; } | Draw the operator input displayed in the BackOffice allowing Admin to set its Coupon Conditions |
15,207 | protected function drawBackOfficeBaseInputsText ( $ label , $ inputKey ) { $ operatorSelectHtml = $ this -> drawBackOfficeInputOperators ( $ inputKey ) ; $ currentValue = '' ; if ( isset ( $ this -> values ) && isset ( $ this -> values [ $ inputKey ] ) ) { $ currentValue = $ this -> values [ $ inputKey ] ; } return $ this -> facade -> getParser ( ) -> render ( 'coupon/conditions-fragments/base-input-text.html' , [ 'label' => $ label , 'inputKey' => $ inputKey , 'currentValue' => $ currentValue , 'operatorSelectHtml' => $ operatorSelectHtml ] ) ; } | Draw the base input displayed in the BackOffice allowing Admin to set its Coupon Conditions |
15,208 | protected function drawBackOfficeInputQuantityValues ( $ inputKey , $ max = 10 , $ min = 0 ) { return $ this -> facade -> getParser ( ) -> render ( 'coupon/condition-fragments/quantity-selector.html' , [ 'min' => $ min , 'max' => $ max , 'value' => isset ( $ this -> values [ $ inputKey ] ) ? $ this -> values [ $ inputKey ] : '' , 'inputKey' => $ inputKey ] ) ; } | Draw the quantity input displayed in the BackOffice allowing Admin to set its Coupon Conditions |
15,209 | protected function drawBackOfficeCurrencyInput ( $ inputKey ) { $ currencies = CurrencyQuery :: create ( ) -> find ( ) ; $ cleanedCurrencies = [ ] ; foreach ( $ currencies as $ currency ) { $ cleanedCurrencies [ $ currency -> getCode ( ) ] = $ currency -> getSymbol ( ) ; } return $ this -> facade -> getParser ( ) -> render ( 'coupon/condition-fragments/currency-selector.html' , [ 'currencies' => $ cleanedCurrencies , 'value' => isset ( $ this -> values [ $ inputKey ] ) ? $ this -> values [ $ inputKey ] : '' , 'inputKey' => $ inputKey ] ) ; } | Draw the currency input displayed in the BackOffice allowing Admin to set its Coupon Conditions |
15,210 | private function setClass ( $ name , $ args ) { $ class = __NAMESPACE__ . '\\Notice\\' . ucfirst ( $ name ) ; return $ this -> class = class_exists ( $ class ) ? new $ class ( $ args ) : Filter :: add ( $ this ) ; } | Sets the class class property . |
15,211 | public static function show ( $ message , $ id , $ class = "notice notice-warning" ) { $ nonce = wp_nonce_field ( 'boldgrid_set_key' , 'set_key_auth' , true , false ) ; if ( self :: isDismissed ( $ id ) ) { return ; } printf ( '<div class="%1$s boldgrid-notice is-dismissible" data-notice-id="%2$s">%3$s%4$s</div>' , $ class , $ id , $ message , $ nonce ) ; self :: enqueue ( ) ; } | Show an admin notice . |
15,212 | public function add ( $ name = null ) { $ name = $ name ? $ name : $ this -> getName ( ) ; $ path = __DIR__ ; $ name = ucfirst ( $ name ) ; include "{$path}/Views/{$name}.php" ; } | Displays the license notice in the WordPress admin . |
15,213 | public function dismiss ( ) { if ( isset ( $ _POST [ 'set_key_auth' ] ) && check_ajax_referer ( 'boldgrid_set_key' , 'set_key_auth' , false ) ) { $ id = sanitize_key ( $ _POST [ 'notice' ] ) ; $ dismissal = array ( 'id' => $ id , 'timestamp' => time ( ) , ) ; if ( ! Notice :: isDismissed ( $ id ) ) { add_user_meta ( get_current_user_id ( ) , 'boldgrid_dismissed_admin_notices' , $ dismissal ) ; } } } | Handle dismissal of the key prompt notice . |
15,214 | public function undismiss ( ) { if ( isset ( $ _POST [ 'set_key_auth' ] ) && ! empty ( $ _POST [ 'notice' ] ) && check_ajax_referer ( 'boldgrid_set_key' , 'set_key_auth' , false ) ) { $ id = sanitize_key ( $ _POST [ 'notice' ] ) ; $ dismissals = get_user_meta ( get_current_user_id ( ) , 'boldgrid_dismissed_admin_notices' ) ; foreach ( $ dismissals as $ dismissal ) { if ( $ id === $ dismissal [ 'id' ] ) { delete_user_meta ( get_current_user_id ( ) , 'boldgrid_dismissed_admin_notices' , $ dismissal ) ; break ; } } } } | Handle undismissal of the key prompt notice . |
15,215 | public static function isDismissed ( $ id ) { $ dismissed = false ; $ id = sanitize_key ( $ id ) ; $ dismissals = get_user_meta ( get_current_user_id ( ) , 'boldgrid_dismissed_admin_notices' ) ; foreach ( $ dismissals as $ dismissal ) { if ( $ id === $ dismissal [ 'id' ] ) { $ dismissed = true ; break ; } } return $ dismissed ; } | Is there a user dismissal record for a particular admin notice id? |
15,216 | public function exec ( ) { if ( version_compare ( phpversion ( ) , '5.5' , '<' ) ) { $ this -> validationMessages [ 'php_version' ] [ 'text' ] = $ this -> getI18nPhpVersionText ( '5.5' , phpversion ( ) , false ) ; $ this -> validationMessages [ 'php_version' ] [ 'status' ] = false ; $ this -> validationMessages [ 'php_version' ] [ 'hint' ] = $ this -> getI18nPhpVersionHint ( ) ; } foreach ( $ this -> directoriesToBeWritable as $ directory ) { $ fullDirectory = THELIA_ROOT . $ directory ; $ this -> validationMessages [ $ directory ] [ 'text' ] = $ this -> getI18nDirectoryText ( $ fullDirectory , true ) ; if ( is_writable ( $ fullDirectory ) === false ) { if ( ! $ this -> makeDirectoryWritable ( $ fullDirectory ) ) { $ this -> isValid = false ; $ this -> validationMessages [ $ directory ] [ 'status' ] = false ; $ this -> validationMessages [ $ directory ] [ 'text' ] = $ this -> getI18nDirectoryText ( $ fullDirectory , false ) ; } } } foreach ( $ this -> minServerConfigurationNecessary as $ key => $ value ) { $ this -> validationMessages [ $ key ] [ 'text' ] = $ this -> getI18nConfigText ( $ key , $ this -> formatBytes ( $ value ) , ini_get ( $ key ) , true ) ; if ( ! $ this -> verifyServerMemoryValues ( $ key , $ value ) ) { $ this -> isValid = false ; $ this -> validationMessages [ $ key ] [ 'status' ] = false ; $ this -> validationMessages [ $ key ] [ 'text' ] = $ this -> getI18nConfigText ( $ key , $ this -> formatBytes ( $ value ) , ini_get ( $ key ) , false ) ; ; } } foreach ( $ this -> extensions as $ extension ) { $ this -> validationMessages [ $ extension ] [ 'text' ] = $ this -> getI18nExtensionText ( $ extension , true ) ; if ( false === extension_loaded ( $ extension ) ) { $ this -> isValid = false ; $ this -> validationMessages [ $ extension ] [ 'status' ] = false ; $ this -> validationMessages [ $ extension ] [ 'text' ] = $ this -> getI18nExtensionText ( $ extension , false ) ; } } return $ this -> isValid ; } | Perform file permission check |
15,217 | protected function getI18nDirectoryText ( $ directory , $ isValid ) { if ( $ this -> translator !== null ) { if ( $ isValid ) { $ sentence = 'The directory %directory% is writable' ; } else { $ sentence = 'The directory %directory% is not writable' ; } $ translatedText = $ this -> translator -> trans ( $ sentence , array ( '%directory%' => $ directory ) ) ; } else { $ translatedText = sprintf ( 'The directory %s should be writable' , $ directory ) ; } return $ translatedText ; } | Get Translated text about the directory state |
15,218 | protected function getI18nConfigText ( $ key , $ expectedValue , $ currentValue , $ isValid ) { if ( $ isValid ) { $ sentence = 'The PHP "%key%" configuration value (currently %currentValue%) is correct (%expectedValue% required).' ; } else { $ sentence = 'The PHP "%key%" configuration value (currently %currentValue%) is below minimal requirements to run Thelia2 (%expectedValue% required).' ; } $ translatedText = $ this -> translator -> trans ( $ sentence , array ( '%key%' => $ key , '%expectedValue%' => $ expectedValue , '%currentValue%' => $ currentValue , ) , 'install-wizard' ) ; return $ translatedText ; } | Get Translated text about the directory state Not usable with CLI |
15,219 | protected function getI18nPhpVersionText ( $ expectedValue , $ currentValue , $ isValid ) { if ( $ this -> translator !== null ) { if ( $ isValid ) { $ sentence = 'PHP version %currentValue% matches the minimum required (PHP %expectedValue%).' ; } else { $ sentence = 'The installer detected PHP version %currentValue%, but Thelia 2 requires PHP %expectedValue% or newer.' ; } $ translatedText = $ this -> translator -> trans ( $ sentence , array ( '%expectedValue%' => $ expectedValue , '%currentValue%' => $ currentValue , ) ) ; } else { $ translatedText = sprintf ( 'Thelia requires PHP %s or newer (%s currently).' , $ expectedValue , $ currentValue ) ; } return $ translatedText ; } | Get Translated hint about the PHP version requirement issue |
15,220 | protected function verifyServerMemoryValues ( $ key , $ necessaryValueInBytes ) { $ serverValueInBytes = $ this -> returnBytes ( ini_get ( $ key ) ) ; if ( $ serverValueInBytes == - 1 ) { return true ; } return ( $ serverValueInBytes >= $ necessaryValueInBytes ) ; } | Check if a server memory value is met or not |
15,221 | protected function returnBytes ( $ val ) { $ val = trim ( $ val ) ; $ last = strtolower ( $ val [ strlen ( $ val ) - 1 ] ) ; switch ( $ last ) { case 'g' : $ val = ( int ) $ val * 1024 ; case 'm' : $ val = ( int ) $ val * 1024 ; case 'k' : $ val = ( int ) $ val * 1024 ; } return $ val ; } | Return bytes from memory . ini value |
15,222 | public function isActionButtonActive ( $ actionwanted ) { $ active = 0 ; $ pathArrayConfig = '' ; switch ( $ actionwanted ) { case 'save' : $ pathArrayConfig = 'meliscms_page_action_save' ; break ; case 'delete' : $ pathArrayConfig = 'meliscms_page_action_delete' ; break ; case 'publish' : $ pathArrayConfig = 'meliscms_page_action_publishunpublish' ; break ; case 'unpublish' : $ pathArrayConfig = 'meliscms_page_action_publishunpublish' ; break ; } $ melisAppConfig = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreConfig' ) ; $ melisKeys = $ melisAppConfig -> getMelisKeys ( ) ; $ melisCoreAuth = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreAuth' ) ; $ xmlRights = $ melisCoreAuth -> getAuthRights ( ) ; $ melisCoreRights = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreRights' ) ; if ( ! empty ( $ melisKeys [ $ pathArrayConfig ] ) ) { $ isAccessible = $ melisCoreRights -> isAccessible ( $ xmlRights , MelisCoreRightsService :: MELISCORE_PREFIX_INTERFACE , $ melisKeys [ $ pathArrayConfig ] ) ; if ( $ isAccessible ) $ active = 1 ; } return $ active ; } | This function returns whether or not a user has access to the save delete publish unpublish action buttons in the interface . Allowing to expand the rights to php saving functions and updating treeview right menu |
15,223 | protected function trackMeter ( $ meterId , $ buckets , $ rates ) { $ trackKey = sprintf ( 'track:%s' , $ buckets [ 0 ] ) ; $ this -> redis -> hset ( $ trackKey , $ meterId , $ rates [ 0 ] ) ; $ expireAt = $ buckets [ 0 ] + ( $ this -> config [ 'bucket_size' ] * $ this -> config [ 'num_buckets' ] ) ; $ this -> redis -> expireat ( $ trackKey , $ expireAt ) ; } | This method allows you to change how the meter is tracked So if you d like to use a sorted set rather than a hash go on ahead! |
15,224 | public static function afterTax ( $ amount , Taxable $ taxable ) { return static :: beforeTax ( $ taxable -> getAmountWithoutTax ( static :: asMoney ( $ amount ) ) , $ taxable ) ; } | Make object with Tax . |
15,225 | public function getAmountWithTax ( ) : string { if ( ! $ this -> hasTax ( ) ) { return $ this -> getMoney ( ) -> getAmount ( ) ; } return $ this -> getTax ( ) -> getAmountWithTax ( $ this -> getMoney ( ) ) ; } | Returns the value represented by this object with Tax . |
15,226 | public function allocateWithTax ( array $ ratios ) : array { $ method = $ this -> hasTax ( ) ? 'afterTax' : 'withoutTax' ; $ results = [ ] ; $ allocates = static :: asMoney ( $ this -> getAmountWithTax ( ) ) -> allocate ( $ ratios ) ; foreach ( $ allocates as $ allocate ) { $ results [ ] = static :: { $ method } ( $ allocate -> getAmount ( ) , $ this -> getTax ( ) ) ; } return $ results ; } | Allocate the money according to a list of ratios with Tax . |
15,227 | public function allocateWithTaxTo ( int $ n ) : array { $ method = $ this -> hasTax ( ) ? 'afterTax' : 'withoutTax' ; $ results = [ ] ; $ allocates = static :: asMoney ( $ this -> getAmountWithTax ( ) ) -> allocateTo ( $ n ) ; foreach ( $ allocates as $ allocate ) { $ results [ ] = static :: { $ method } ( $ allocate -> getAmount ( ) , $ this -> getTax ( ) ) ; } return $ results ; } | Allocate the money among N targets with GST . |
15,228 | public static function getDefaultLanguage ( ) { if ( null === self :: $ defaultLanguage ) { self :: $ defaultLanguage = LangQuery :: create ( ) -> findOneByByDefault ( 1 ) ; if ( null === self :: $ defaultLanguage ) { throw new \ RuntimeException ( "No default language is defined. Please define one." ) ; } } return self :: $ defaultLanguage ; } | Return the default language object using a local variable to cache it . |
15,229 | private function convertValuesToIds ( $ varValue ) : array { $ aliasColumn = $ this -> getAliasColumn ( ) ; $ alias = [ ] ; foreach ( $ varValue as $ valueId => $ value ) { if ( array_key_exists ( $ aliasColumn , $ value ) ) { $ alias [ $ valueId ] = $ value [ $ aliasColumn ] ; continue ; } if ( array_key_exists ( self :: TAGS_RAW , $ value ) && array_key_exists ( $ aliasColumn , $ value [ self :: TAGS_RAW ] ) ) { $ alias [ $ valueId ] = $ value [ self :: TAGS_RAW ] [ $ aliasColumn ] ; } } return $ alias ; } | Convert the passed values to a value id list . |
15,230 | protected function calculateFilterOptionsCount ( $ items , & $ amountArray , $ idList ) { $ builder = $ this -> getConnection ( ) -> createQueryBuilder ( ) -> select ( 'value_id' ) -> addSelect ( 'COUNT(item_id) AS amount' ) -> from ( 'tl_metamodel_tag_relation' ) -> where ( 'att_id=:attId' ) -> setParameter ( 'attId' , $ this -> get ( 'id' ) ) -> groupBy ( 'value_id' ) ; if ( 0 < $ items -> getCount ( ) ) { $ ids = [ ] ; foreach ( $ items as $ item ) { $ ids [ ] = $ item -> get ( 'id' ) ; } $ builder -> andWhere ( 'value_id IN (:valueIds)' ) -> setParameter ( 'valueIds' , $ ids , Connection :: PARAM_STR_ARRAY ) ; if ( $ idList && \ is_array ( $ idList ) ) { $ builder -> andWhere ( 'item_id IN (:itemIds)' ) -> setParameter ( 'itemIds' , $ idList , Connection :: PARAM_STR_ARRAY ) ; } } $ counts = $ builder -> execute ( ) ; foreach ( $ counts -> fetchAll ( \ PDO :: FETCH_ASSOC ) as $ count ) { $ amountArray [ $ count [ 'value_id' ] ] = $ count [ 'amount' ] ; } } | Calculate the amount how often each value has been assigned . |
15,231 | public function getNextPosition ( ) { $ query = $ this -> createQuery ( ) -> orderByPosition ( Criteria :: DESC ) -> limit ( 1 ) ; $ this -> addCriteriaToPositionQuery ( $ query ) ; $ last = $ query -> findOne ( ) ; return $ last != null ? $ last -> getPosition ( ) + 1 : 1 ; } | Get the position of the next inserted object |
15,232 | protected function movePositionUpOrDown ( $ up = true ) { $ myPosition = $ this -> getPosition ( ) ; $ search = $ this -> createQuery ( ) ; $ this -> addCriteriaToPositionQuery ( $ search ) ; if ( $ up === true ) { $ search -> filterByPosition ( array ( 'max' => $ myPosition - 1 ) ) -> orderByPosition ( Criteria :: DESC ) ; } else { $ search -> filterByPosition ( array ( 'min' => $ myPosition + 1 ) ) -> orderByPosition ( Criteria :: ASC ) ; } $ result = $ search -> findOne ( ) ; if ( $ result ) { $ cnx = Propel :: getWriteConnection ( $ this -> getDatabaseName ( ) ) ; $ cnx -> beginTransaction ( ) ; try { $ this -> setPosition ( $ result -> getPosition ( ) ) -> save ( $ cnx ) ; if ( method_exists ( $ result , 'setDispatcher' ) && method_exists ( $ this , 'getDispatcher' ) ) { $ result -> setDispatcher ( $ this -> getDispatcher ( ) ) ; } $ result -> setPosition ( $ myPosition ) -> save ( $ cnx ) ; $ cnx -> commit ( ) ; } catch ( \ Exception $ e ) { $ cnx -> rollback ( ) ; } } } | Move up or down a object |
15,233 | public function changeAbsolutePosition ( $ newPosition ) { $ current_position = $ this -> getPosition ( ) ; if ( $ newPosition != null && $ newPosition > 0 && $ newPosition != $ current_position ) { $ search = $ this -> createQuery ( ) ; $ this -> addCriteriaToPositionQuery ( $ search ) ; if ( $ newPosition > $ current_position ) { $ search -> filterByPosition ( array ( 'min' => 1 + $ current_position , 'max' => $ newPosition ) ) ; $ delta = - 1 ; } else { $ search -> filterByPosition ( array ( 'min' => $ newPosition , 'max' => $ current_position - 1 ) ) ; $ delta = 1 ; } $ results = $ search -> find ( ) ; $ cnx = Propel :: getWriteConnection ( $ this -> getDatabaseName ( ) ) ; $ cnx -> beginTransaction ( ) ; try { foreach ( $ results as $ result ) { $ objNewPosition = $ result -> getPosition ( ) + $ delta ; if ( method_exists ( $ result , 'setDispatcher' ) && method_exists ( $ this , 'getDispatcher' ) ) { $ result -> setDispatcher ( $ this -> getDispatcher ( ) ) ; } $ result -> setPosition ( $ objNewPosition ) -> save ( $ cnx ) ; } $ this -> setPosition ( $ newPosition ) -> save ( $ cnx ) ; $ cnx -> commit ( ) ; } catch ( \ Exception $ e ) { $ cnx -> rollback ( ) ; } } } | Changes object position |
15,234 | public function findForActiveModules ( ) { $ fs = new Filesystem ( ) ; $ codes = $ this -> queryActiveModuleCodes ( ) ; foreach ( $ codes as $ key => $ code ) { if ( ! $ fs -> exists ( THELIA_MODULE_DIR . $ code ) ) { unset ( $ codes [ $ key ] ) ; } } $ codes = array_values ( $ codes ) ; return $ this -> findForModules ( $ codes ) ; } | Get schema documents for Thelia core and active modules as well as included external schemas . |
15,235 | protected function addModulesDependencies ( array $ modules = [ ] ) { if ( empty ( $ modules ) ) { return [ ] ; } if ( ! \ in_array ( 'Thelia' , $ modules ) ) { $ modules [ ] = 'Thelia' ; } foreach ( $ modules as $ module ) { if ( $ module === 'Thelia' ) { continue ; } $ moduleValidator = new ModuleValidator ( "{$this->theliaModuleDir}/{$module}" ) ; $ dependencies = $ moduleValidator -> getCurrentModuleDependencies ( true ) ; foreach ( $ dependencies as $ dependency ) { if ( ! \ in_array ( $ dependency [ 'code' ] , $ modules ) ) { $ modules [ ] = $ dependency [ 'code' ] ; } } } return $ modules ; } | Add dependencies of some modules . |
15,236 | protected function addExternalSchemaDocuments ( array $ schemaDocuments ) { $ fs = new Filesystem ( ) ; $ externalSchemaDocuments = [ ] ; foreach ( $ schemaDocuments as $ schemaDocument ) { foreach ( $ schemaDocument -> getElementsByTagName ( 'external-schema' ) as $ externalSchemaElement ) { if ( ! $ externalSchemaElement -> hasAttribute ( 'filename' ) ) { continue ; } $ externalSchemaPath = $ externalSchemaElement -> getAttribute ( 'filename' ) ; if ( ! $ fs -> exists ( $ externalSchemaPath ) ) { continue ; } $ externalSchemaDocument = new \ DOMDocument ( ) ; if ( ! $ externalSchemaDocument -> load ( $ externalSchemaPath ) ) { continue ; } $ externalSchemaDocuments [ ] = $ externalSchemaDocument ; } } return $ this -> mergeDOMDocumentsArrays ( [ $ schemaDocuments , $ externalSchemaDocuments ] ) ; } | Add external schema documents not already included . |
15,237 | public function reconnect ( $ name = null ) { $ name = $ name ? : $ this -> default ; $ this -> disconnect ( $ name ) ; return $ this -> connection ( $ name ) ; } | Reconnect to the given connection . |
15,238 | public function adminLogAppend ( $ resource , $ action , $ message , $ resourceId = null ) { AdminLog :: append ( $ resource , $ action , $ message , $ this -> getRequest ( ) , $ this -> getSecurityContext ( ) -> getAdminUser ( ) , true , $ resourceId ) ; } | Helper to append a message to the admin log . |
15,239 | public function processTemplateAction ( $ template ) { try { if ( ! empty ( $ template ) ) { return $ this -> render ( $ template ) ; } elseif ( null != $ view = $ this -> getRequest ( ) -> get ( 'view' ) ) { return $ this -> render ( $ view ) ; } } catch ( \ Exception $ ex ) { return $ this -> errorPage ( $ ex -> getMessage ( ) ) ; } return $ this -> pageNotFound ( ) ; } | This method process the rendering of view called from an admin page |
15,240 | protected function errorPage ( $ message , $ status = 500 ) { if ( $ message instanceof \ Exception ) { $ strMessage = $ this -> getTranslator ( ) -> trans ( "Sorry, an error occured: %msg" , [ '%msg' => $ message -> getMessage ( ) ] ) ; Tlog :: getInstance ( ) -> addError ( $ strMessage . ": " . $ message -> getTraceAsString ( ) ) ; $ message = $ strMessage ; } else { Tlog :: getInstance ( ) -> addError ( $ message ) ; } return $ this -> render ( 'general_error' , array ( "error_message" => $ message ) , $ status ) ; } | Return a general error page |
15,241 | protected function checkAuth ( $ resources , $ modules , $ accesses ) { $ resources = \ is_array ( $ resources ) ? $ resources : array ( $ resources ) ; $ modules = \ is_array ( $ modules ) ? $ modules : array ( $ modules ) ; $ accesses = \ is_array ( $ accesses ) ? $ accesses : array ( $ accesses ) ; if ( $ this -> getSecurityContext ( ) -> isGranted ( array ( "ADMIN" ) , $ resources , $ modules , $ accesses ) ) { return null ; } $ this -> adminLogAppend ( implode ( "," , $ resources ) , implode ( "," , $ accesses ) , "User is not granted for resources %s with accesses %s" , implode ( ", " , $ resources ) , implode ( ", " , $ accesses ) ) ; return $ this -> errorPage ( $ this -> getTranslator ( ) -> trans ( "Sorry, you're not allowed to perform this action" ) , 403 ) ; } | Check current admin user authorisations . An ADMIN role is assumed . |
15,242 | protected function setupFormErrorContext ( $ action , $ error_message , BaseForm $ form = null , \ Exception $ exception = null ) { if ( $ error_message !== false ) { Tlog :: getInstance ( ) -> error ( $ this -> getTranslator ( ) -> trans ( "Error during %action process : %error. Exception was %exc" , array ( '%action' => $ action , '%error' => $ error_message , '%exc' => $ exception != null ? $ exception -> getMessage ( ) : 'no exception' ) ) ) ; if ( $ form != null ) { $ form -> setErrorMessage ( $ error_message ) ; $ this -> getParserContext ( ) -> addForm ( $ form ) ; } $ this -> getParserContext ( ) -> setGeneralError ( $ error_message ) ; } } | Setup the error context when an error occurs in a action method . |
15,243 | protected function getCurrentEditionCurrency ( ) { if ( null !== $ edit_currency_id = $ this -> getRequest ( ) -> get ( 'edit_currency_id' , null ) ) { if ( null !== $ edit_currency = CurrencyQuery :: create ( ) -> findOneById ( $ edit_currency_id ) ) { return $ edit_currency ; } } return $ this -> getSession ( ) -> getAdminEditionCurrency ( ) ; } | Get the current edition currency ID checking if a change was requested in the current request . |
15,244 | protected function getCurrentEditionLang ( ) { if ( null !== $ edit_language_id = $ this -> getRequest ( ) -> get ( 'edit_language_id' , null ) ) { if ( null !== $ edit_language = LangQuery :: create ( ) -> findOneById ( $ edit_language_id ) ) { return $ edit_language ; } } return $ this -> getSession ( ) -> getAdminEditionLang ( ) ; } | Get the current edition lang ID checking if a change was requested in the current request . |
15,245 | protected function getUrlLanguage ( $ locale = null ) { if ( ! ConfigQuery :: isMultiDomainActivated ( ) ) { return null ; } if ( ! $ locale ) { $ locale = $ this -> getCurrentEditionLocale ( ) ; } return LangQuery :: create ( ) -> findOneByLocale ( $ locale ) -> getUrl ( ) ; } | A simple helper to get the URL based on the language . |
15,246 | protected function getListOrderFromSession ( $ objectName , $ requestParameterName , $ defaultListOrder , $ updateSession = true ) { $ orderSessionIdentifier = sprintf ( "admin.%s.currentListOrder" , $ objectName ) ; $ order = $ this -> getRequest ( ) -> get ( $ requestParameterName , $ this -> getSession ( ) -> get ( $ orderSessionIdentifier , $ defaultListOrder ) ) ; if ( $ updateSession ) { $ this -> getSession ( ) -> set ( $ orderSessionIdentifier , $ order ) ; } return $ order ; } | Return the current list order identifier for a given object name updating in using the current request . |
15,247 | public function appendParameter ( $ parameter ) { if ( is_callable ( $ parameter ) ) { $ parameter = $ parameter ( $ this ) ; } if ( ! ( $ parameter instanceof ParameterNode ) ) { throw new \ InvalidArgumentException ( ) ; } $ this -> parameters -> appendItem ( $ parameter ) ; return $ this ; } | Appends a parameter . |
15,248 | public function insertParameter ( ParameterNode $ parameter , $ index ) { $ this -> parameters -> insertItem ( $ parameter , $ index ) ; return $ this ; } | Insert parameter before parameter at index . |
15,249 | public function getParameter ( $ key ) { if ( is_string ( $ key ) ) { return $ this -> getParameterByName ( $ key ) ; } elseif ( is_integer ( $ key ) ) { return $ this -> getParameterAtIndex ( $ key ) ; } else { throw new \ InvalidArgumentException ( "Illegal parameter index {$key}." ) ; } } | Gets a parameter by name or index . |
15,250 | public function getParameterByName ( $ name ) { $ name = ltrim ( $ name , '$' ) ; foreach ( $ this -> getParameters ( ) -> reverse ( ) as $ parameter ) { if ( $ parameter -> getName ( ) === $ name ) { return $ parameter ; } } throw new \ UnexpectedValueException ( "Parameter {$name} does not exist." ) ; } | Gets a parameter by its name . |
15,251 | public function getBaseUrl ( $ scheme_only = false ) { if ( null === $ this -> baseUrlScheme ) { $ scheme = "http" ; $ port = 80 ; if ( $ host = $ this -> requestContext -> getHost ( ) ) { $ scheme = $ this -> requestContext -> getScheme ( ) ; $ port = '' ; if ( 'http' === $ scheme && 80 != $ this -> requestContext -> getHttpPort ( ) ) { $ port = ':' . $ this -> requestContext -> getHttpPort ( ) ; } elseif ( 'https' === $ scheme && 443 != $ this -> requestContext -> getHttpsPort ( ) ) { $ port = ':' . $ this -> requestContext -> getHttpsPort ( ) ; } } $ this -> baseUrlScheme = "$scheme://$host" . "$port" ; } return $ scheme_only ? $ this -> baseUrlScheme : $ this -> baseUrlScheme . $ this -> requestContext -> getBaseUrl ( ) ; } | Return the base URL either the base_url defined in Config or the URL of the current language if one_domain_foreach_lang is enabled . |
15,252 | public function adminViewUrl ( $ viewName , array $ parameters = array ( ) ) { $ path = sprintf ( "%s/admin/%s" , $ this -> getIndexPage ( ) , $ viewName ) ; return $ this -> absoluteUrl ( $ path , $ parameters ) ; } | Returns the Absolute URL to a administration view |
15,253 | public function viewUrl ( $ viewName , array $ parameters = array ( ) ) { $ path = sprintf ( "?view=%s" , $ viewName ) ; return $ this -> absoluteUrl ( $ path , $ parameters ) ; } | Returns the Absolute URL to a view |
15,254 | public function retrieve ( $ view , $ viewId , $ viewLocale ) { if ( ConfigQuery :: isRewritingEnable ( ) ) { $ this -> retriever -> loadViewUrl ( $ view , $ viewLocale , $ viewId ) ; } else { $ allParametersWithoutView = array ( ) ; $ allParametersWithoutView [ 'lang' ] = $ viewLocale ; if ( null !== $ viewId ) { $ allParametersWithoutView [ $ view . '_id' ] = $ viewId ; } $ this -> retriever -> rewrittenUrl = null ; $ this -> retriever -> url = URL :: getInstance ( ) -> viewUrl ( $ view , $ allParametersWithoutView ) ; } return $ this -> retriever ; } | Retrieve a rewritten URL from a view a view id and a locale |
15,255 | public function retrieveCurrent ( Request $ request ) { if ( ConfigQuery :: isRewritingEnable ( ) ) { $ view = $ request -> attributes -> get ( '_view' , null ) ; $ viewLocale = $ this -> getViewLocale ( $ request ) ; $ viewId = $ view === null ? null : $ request -> query -> get ( $ view . '_id' , null ) ; $ allOtherParameters = $ request -> query -> all ( ) ; if ( $ view !== null ) { unset ( $ allOtherParameters [ 'view' ] ) ; if ( $ viewId !== null ) { unset ( $ allOtherParameters [ $ view . '_id' ] ) ; } } if ( $ viewLocale !== null ) { unset ( $ allOtherParameters [ 'lang' ] ) ; unset ( $ allOtherParameters [ 'locale' ] ) ; } $ this -> retriever -> loadSpecificUrl ( $ view , $ viewLocale , $ viewId , $ allOtherParameters ) ; } else { $ allParametersWithoutView = $ request -> query -> all ( ) ; $ view = $ request -> attributes -> get ( '_view' ) ; if ( isset ( $ allOtherParameters [ 'view' ] ) ) { unset ( $ allOtherParameters [ 'view' ] ) ; } $ this -> retriever -> rewrittenUrl = null ; $ this -> retriever -> url = URL :: getInstance ( ) -> viewUrl ( $ view , $ allParametersWithoutView ) ; } return $ this -> retriever ; } | Retrieve a rewritten URL from the current GET parameters |
15,256 | private function getViewLocale ( Request $ request ) { $ viewLocale = $ request -> query -> get ( 'lang' , null ) ; if ( null === $ viewLocale ) { $ viewLocale = $ request -> query -> get ( 'locale' , null ) ; } return $ viewLocale ; } | Get the locale code from the lang attribute in URL . |
15,257 | public static function loadFromPostage ( $ postage ) { if ( $ postage instanceof OrderPostage ) { $ orderPostage = $ postage ; } else { $ orderPostage = new OrderPostage ( $ postage ) ; } return $ orderPostage ; } | Convert a amount or OrderPostage object to an OrderPostage object |
15,258 | public function processDocument ( DocumentEvent $ event ) { $ subdir = $ event -> getCacheSubdirectory ( ) ; $ sourceFile = $ event -> getSourceFilepath ( ) ; if ( null == $ subdir || null == $ sourceFile ) { throw new \ InvalidArgumentException ( "Cache sub-directory and source file path cannot be null" ) ; } $ originalDocumentPathInCache = $ this -> getCacheFilePath ( $ subdir , $ sourceFile , true ) ; if ( ! file_exists ( $ originalDocumentPathInCache ) ) { if ( ! file_exists ( $ sourceFile ) ) { throw new DocumentException ( sprintf ( "Source document file %s does not exists." , $ sourceFile ) ) ; } $ mode = ConfigQuery :: read ( self :: CONFIG_DELIVERY_MODE , 'symlink' ) ; if ( $ mode == 'symlink' ) { if ( false === symlink ( $ sourceFile , $ originalDocumentPathInCache ) ) { throw new DocumentException ( sprintf ( "Failed to create symbolic link for %s in %s document cache directory" , basename ( $ sourceFile ) , $ subdir ) ) ; } } else { if ( false === @ copy ( $ sourceFile , $ originalDocumentPathInCache ) ) { throw new DocumentException ( sprintf ( "Failed to copy %s in %s document cache directory" , basename ( $ sourceFile ) , $ subdir ) ) ; } } } $ documentUrl = $ this -> getCacheFileURL ( $ subdir , basename ( $ originalDocumentPathInCache ) ) ; $ event -> setDocumentPath ( $ documentUrl ) ; $ event -> setDocumentUrl ( URL :: getInstance ( ) -> absoluteUrl ( $ documentUrl , null , URL :: PATH_TO_FILE , $ this -> cdnBaseUrl ) ) ; } | Process document and write the result in the document cache . |
15,259 | public function create ( CategoryCreateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ category = new CategoryModel ( ) ; $ category -> setDispatcher ( $ dispatcher ) -> setLocale ( $ event -> getLocale ( ) ) -> setParent ( $ event -> getParent ( ) ) -> setVisible ( $ event -> getVisible ( ) ) -> setTitle ( $ event -> getTitle ( ) ) -> save ( ) ; $ event -> setCategory ( $ category ) ; } | Create a new category entry |
15,260 | public function update ( CategoryUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ category = CategoryQuery :: create ( ) -> findPk ( $ event -> getCategoryId ( ) ) ) { $ category -> setDispatcher ( $ dispatcher ) -> setDefaultTemplateId ( $ event -> getDefaultTemplateId ( ) == 0 ? null : $ event -> getDefaultTemplateId ( ) ) -> setLocale ( $ event -> getLocale ( ) ) -> setTitle ( $ event -> getTitle ( ) ) -> setDescription ( $ event -> getDescription ( ) ) -> setChapo ( $ event -> getChapo ( ) ) -> setPostscriptum ( $ event -> getPostscriptum ( ) ) -> setParent ( $ event -> getParent ( ) ) -> setVisible ( $ event -> getVisible ( ) ) -> save ( ) ; $ event -> setCategory ( $ category ) ; } } | Change a category |
15,261 | public function delete ( CategoryDeleteEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ category = CategoryQuery :: create ( ) -> findPk ( $ event -> getCategoryId ( ) ) ) { $ con = Propel :: getWriteConnection ( CategoryTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { $ fileList = [ 'images' => [ ] , 'documentList' => [ ] ] ; $ fileList [ 'images' ] [ 'list' ] = CategoryImageQuery :: create ( ) -> findByCategoryId ( $ event -> getCategoryId ( ) ) ; $ fileList [ 'images' ] [ 'type' ] = TheliaEvents :: IMAGE_DELETE ; $ fileList [ 'documentList' ] [ 'list' ] = CategoryDocumentQuery :: create ( ) -> findByCategoryId ( $ event -> getCategoryId ( ) ) ; $ fileList [ 'documentList' ] [ 'type' ] = TheliaEvents :: DOCUMENT_DELETE ; $ category -> setDispatcher ( $ dispatcher ) -> delete ( $ con ) ; $ event -> setCategory ( $ category ) ; foreach ( $ fileList as $ fileTypeList ) { foreach ( $ fileTypeList [ 'list' ] as $ fileToDelete ) { $ fileDeleteEvent = new FileDeleteEvent ( $ fileToDelete ) ; $ dispatcher -> dispatch ( $ fileTypeList [ 'type' ] , $ fileDeleteEvent ) ; } } $ con -> commit ( ) ; } catch ( \ Exception $ e ) { $ con -> rollback ( ) ; throw $ e ; } } } | Delete a category entry |
15,262 | public function toggleVisibility ( CategoryToggleVisibilityEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ category = $ event -> getCategory ( ) ; $ category -> setDispatcher ( $ dispatcher ) -> setVisible ( $ category -> getVisible ( ) ? false : true ) -> save ( ) ; $ event -> setCategory ( $ category ) ; } | Toggle category visibility . No form used here |
15,263 | public function viewCheck ( ViewCheckEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( $ event -> getView ( ) == 'category' ) { $ category = CategoryQuery :: create ( ) -> filterById ( $ event -> getViewId ( ) ) -> filterByVisible ( 1 ) -> count ( ) ; if ( $ category == 0 ) { $ dispatcher -> dispatch ( TheliaEvents :: VIEW_CATEGORY_ID_NOT_VISIBLE , $ event ) ; } } } | Check if is a category view and if category_id is visible |
15,264 | public function renderToolSiteHeaderAction ( ) { $ melisTool = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTool' ) ; $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ melisTool -> setMelisToolKey ( self :: TOOL_INDEX , self :: TOOL_KEY ) ; $ view = new ViewModel ( ) ; $ view -> title = $ melisTool -> getTitle ( ) ; return $ view ; } | Renders to the header section of the tool |
15,265 | public function renderToolSiteModalAddAction ( ) { $ melisTool = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTool' ) ; $ melisTool -> setMelisToolKey ( self :: TOOL_INDEX , self :: TOOL_KEY ) ; $ view = new ViewModel ( ) ; $ view -> setVariable ( 'meliscms_site_tool_creation_form' , $ melisTool -> getForm ( 'meliscms_site_tool_creation_form' ) ) ; return $ view ; } | Displays the add form in the modal |
15,266 | public function getSiteDomainPlatform ( ) { $ data = array ( ) ; if ( $ this -> getRequest ( ) -> isGet ( ) ) { $ siteDomain = $ this -> getServiceLocator ( ) -> get ( 'SiteDomain' ) ; $ data = $ siteDomain -> getSiteDomain ( ) ; } return $ data ; } | Return site domain |
15,267 | public function getSiteEnvironmentAction ( ) { $ json = array ( ) ; $ siteId = ( int ) $ this -> params ( ) -> fromQuery ( 'siteId' ) ; $ melisEngineTableSiteDomain = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableSiteDomain' ) ; $ sitePlatform = $ melisEngineTableSiteDomain -> getEntryByField ( 'sdom_site_id' , $ siteId ) ; $ sitePlatform = $ sitePlatform -> current ( ) ; $ siteDomainEnv = ( $ sitePlatform ) ? $ sitePlatform -> sdom_env : null ; return new JsonModel ( array ( 'data' => $ siteDomainEnv ) ) ; } | Fetching Current Platform on specific Site |
15,268 | public function getSiteEnvironmentsAction ( ) { $ json = array ( ) ; $ siteId = ( int ) $ this -> params ( ) -> fromQuery ( 'siteId' ) ; $ domainTable = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTablePlatform' ) ; $ domainData = $ domainTable -> fetchAll ( ) ; $ domainData = $ domainData -> toArray ( ) ; if ( $ domainData ) { foreach ( $ domainData as $ domainValues ) { $ json [ ] = $ domainValues [ 'plf_name' ] ; } } return new JsonModel ( array ( 'data' => $ json ) ) ; } | Fetching all Core Platforms |
15,269 | public function deleteSiteByIdAction ( ) { $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ request = $ this -> getRequest ( ) ; $ domainId = null ; $ success = 0 ; $ textTitle = 'tr_meliscms_tool_site' ; $ textMessage = '' ; $ eventDatas = array ( ) ; $ this -> getEventManager ( ) -> trigger ( 'meliscms_site_delete_by_id_start' , $ this , $ eventDatas ) ; if ( $ request -> isPost ( ) ) { $ domainTable = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableSiteDomain' ) ; $ site404Table = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableSite404' ) ; $ siteID = ( int ) $ request -> getPost ( 'siteid' ) ; $ siteEnv = $ request -> getPost ( 'env' ) ; $ site404PageId = $ request -> getPost ( 'site404Page' ) ; $ domainData = $ domainTable -> getDataBySiteIdAndEnv ( $ siteID , $ siteEnv ) ; $ domainData = $ domainData -> current ( ) ; if ( $ domainData ) { $ domainId = $ domainData -> sdom_id ; $ domainTable -> deleteByField ( 'sdom_id' , $ domainId ) ; $ success = 1 ; $ textMessage = 'tr_meliscms_tool_site_delete_env_success' ; } else { $ textMessage = 'tr_meliscms_tool_site_delete_env_failed' ; } } $ response = array ( 'success' => $ success , 'textTitle' => $ textTitle , 'textMessage' => $ textMessage , ) ; $ this -> getEventManager ( ) -> trigger ( 'meliscms_site_delete_by_id_end' , $ this , array_merge ( $ response , array ( 'typeCode' => 'CMS_SITE_ENV_DELETE' , 'itemId' => $ domainId ) ) ) ; return new JsonModel ( $ response ) ; } | Deletes the specific information of an environment |
15,270 | public function setAlias ( $ alias ) { if ( is_string ( $ alias ) ) { $ alias = new TokenNode ( T_STRING , $ alias ) ; } if ( $ alias instanceof TokenNode ) { if ( $ this -> hasAlias ( ) ) { $ this -> alias -> replaceWith ( $ alias ) ; } else { $ this -> alias = $ alias ; $ this -> addChild ( WhitespaceNode :: create ( ' ' ) ) ; $ this -> addChild ( Token :: _as ( ) ) ; $ this -> addChild ( WhitespaceNode :: create ( ' ' ) ) ; $ this -> addChild ( $ alias , 'alias' ) ; } } elseif ( $ alias === NULL && $ this -> hasAlias ( ) ) { $ this -> alias -> previousUntil ( Filter :: isInstanceOf ( '\Pharborist\Namespaces\NameNode' ) ) -> remove ( ) ; $ this -> alias -> remove ( ) ; $ this -> alias = NULL ; } else { throw new \ InvalidArgumentException ( ) ; } return $ this ; } | Sets the imported item s alias . If NULL is passed the alias is removed . |
15,271 | public function getBoundedName ( ) { if ( $ this -> alias ) { return $ this -> alias -> getText ( ) ; } else { return $ this -> name -> lastChild ( ) -> getText ( ) ; } } | Name bounded inside namespace . |
15,272 | public function orderCartClear ( OrderEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ session = $ this -> getSession ( ) ; $ session -> clearSessionCart ( $ dispatcher ) ; $ session -> setOrder ( new OrderModel ( ) ) ; } | Clear the cart and the order in the customer session once the order is placed and the payment performed . |
15,273 | public function getStockUpdateOnOrderStatusChange ( GetStockUpdateOperationOnOrderStatusChangeEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ order = $ event -> getOrder ( ) ; $ newStatus = $ event -> getNewOrderStatus ( ) ; if ( $ newStatus -> getId ( ) !== $ order -> getStatusId ( ) ) { if ( OrderVersionQuery :: create ( ) -> groupByStatusId ( ) -> filterById ( $ order -> getId ( ) ) -> count ( ) > 1 ) { $ manageStockOnCreation = false ; } else { $ manageStockOnCreation = $ order -> isStockManagedOnOrderCreation ( $ dispatcher ) ; } if ( ( $ order -> isPaid ( false ) && $ newStatus -> isNotPaid ( false ) ) || ( $ order -> isNotPaid ( true ) && $ newStatus -> isNotPaid ( false ) && $ manageStockOnCreation === true ) ) { $ event -> setOperation ( $ event :: INCREASE_STOCK ) ; } if ( $ order -> isNotPaid ( false ) && $ newStatus -> isPaid ( false ) && $ manageStockOnCreation === false ) { $ event -> setOperation ( $ event :: DECREASE_STOCK ) ; } Tlog :: getInstance ( ) -> addInfo ( "Checking stock operation for status change of order : " . $ order -> getRef ( ) . ", version: " . $ order -> getVersion ( ) . ", manageStockOnCreation: " . ( $ manageStockOnCreation ? 0 : 1 ) . ", paid:" . ( $ order -> isPaid ( false ) ? 1 : 0 ) . ", is not paid:" . ( $ order -> isNotPaid ( false ) ? 1 : 0 ) . ", new status paid:" . ( $ newStatus -> isPaid ( false ) ? 1 : 0 ) . ", new status is not paid:" . ( $ newStatus -> isNotPaid ( false ) ? 1 : 0 ) . " = operation: " . $ event -> getOperation ( ) ) ; } } | Check if a stock update is required on order products for a given order status change and compute if the stock should be decreased or increased . |
15,274 | protected function updateQuantity ( ModelOrder $ order , $ newStatus , EventDispatcherInterface $ dispatcher ) { if ( $ newStatus !== $ order -> getStatusId ( ) ) { if ( null !== $ newStatusModel = OrderStatusQuery :: create ( ) -> findPk ( $ newStatus ) ) { $ operationEvent = new GetStockUpdateOperationOnOrderStatusChangeEvent ( $ order , $ newStatusModel ) ; $ dispatcher -> dispatch ( TheliaEvents :: ORDER_GET_STOCK_UPDATE_OPERATION_ON_ORDER_STATUS_CHANGE , $ operationEvent ) ; if ( $ operationEvent -> getOperation ( ) !== $ operationEvent :: DO_NOTHING ) { $ orderProductList = $ order -> getOrderProducts ( ) ; foreach ( $ orderProductList as $ orderProduct ) { $ productSaleElementsId = $ orderProduct -> getProductSaleElementsId ( ) ; if ( null !== $ productSaleElements = ProductSaleElementsQuery :: create ( ) -> findPk ( $ productSaleElementsId ) ) { $ offset = 0 ; if ( $ operationEvent -> getOperation ( ) == $ operationEvent :: INCREASE_STOCK ) { $ offset = $ orderProduct -> getQuantity ( ) ; } elseif ( $ operationEvent -> getOperation ( ) == $ operationEvent :: DECREASE_STOCK ) { if ( $ orderProduct -> getQuantity ( ) > $ productSaleElements -> getQuantity ( ) && true === ConfigQuery :: checkAvailableStock ( ) ) { throw new TheliaProcessException ( $ productSaleElements -> getRef ( ) . " : Not enough stock 2" ) ; } $ offset = - $ orderProduct -> getQuantity ( ) ; } Tlog :: getInstance ( ) -> addError ( "Product stock: " . $ productSaleElements -> getQuantity ( ) . " -> " . ( $ productSaleElements -> getQuantity ( ) + $ offset ) ) ; $ productSaleElements -> setQuantity ( $ productSaleElements -> getQuantity ( ) + $ offset ) -> save ( ) ; } } } } } } | Update order products stock after an order status change |
15,275 | public function admin_notices ( ) { $ afterKeyAdded = get_option ( $ this -> option ) ; if ( empty ( $ afterKeyAdded ) ) { return ; } switch ( $ afterKeyAdded ) { case 'success' : echo '<div class="notice notice-success is-dismissible bglib-key-added"><p>' . esc_html ( 'Your new BoldGrid Connect Key has been successfully added!' , 'boldgrid-library' ) . '</p></div>' ; break ; case 'fail' : echo '<div class="notice notice-error is-dismissible bglib-key-added"><p>' . esc_html ( 'An unknown error occurred adding your new BoldGrid Connect Key.' , 'boldgrid-library' ) . '</p></div>' ; break ; } delete_option ( $ this -> option ) ; } | Admin notices . |
15,276 | public static function getCentralUrl ( ) { $ returnUrl = apply_filters ( 'Boldgrid\Library\Key\returnUrl' , admin_url ( 'options-general.php?page=boldgrid-connect.php' ) ) ; $ returnUrl = add_query_arg ( 'nonce' , wp_create_nonce ( 'bglib-key-prompt' ) , $ returnUrl ) ; return add_query_arg ( array ( 'wp-url' => urlencode ( $ returnUrl ) , ) , Configs :: get ( 'getNewKey' ) ) ; } | Get the url to BoldGrid Central for the user to get a new Connect Key . |
15,277 | public function processPost ( ) { if ( $ this -> isPosting ( ) ) { $ releaseChannel = new ReleaseChannel ; $ key = new Key ( $ releaseChannel ) ; $ hashed_key = md5 ( $ _POST [ 'activateKey' ] ) ; $ success = $ key -> addKey ( $ hashed_key ) ; update_option ( $ this -> option , $ success ? 'success' : 'fail' ) ; header ( 'Refresh:0' ) ; exit ; } } | Handle the submission of an api key via a post call . |
15,278 | private function isPosting ( ) { if ( empty ( $ _POST [ 'activateKey' ] ) ) { return false ; } if ( empty ( $ _GET [ 'nonce' ] ) || ! wp_verify_nonce ( $ _GET [ 'nonce' ] , 'bglib-key-prompt' ) ) { return false ; } if ( ! current_user_can ( 'update_plugins' ) ) { return false ; } return true ; } | Determine whether or not we are posting a new Connect Key to the dashboard . |
15,279 | public function setRestContent ( $ data ) { $ serializer = $ this -> getSerializer ( ) ; if ( isset ( $ data ) ) { $ this -> setContent ( $ serializer -> serialize ( $ data , $ this -> format ) ) ; } return $ this ; } | Set Content to be serialized in the response array or object |
15,280 | public static function create ( $ name ) { $ parts = explode ( '\\' , $ name ) ; $ name_node = new NameNode ( ) ; foreach ( $ parts as $ i => $ part ) { $ part = trim ( $ part ) ; if ( $ i > 0 ) { $ name_node -> append ( Token :: namespaceSeparator ( ) ) ; } if ( $ part !== '' ) { $ name_node -> append ( Token :: identifier ( $ part ) ) ; } } return $ name_node ; } | Create namespace path . |
15,281 | public function getPathInfo ( ) { $ first = $ this -> firstChild ( ) ; $ absolute = $ first -> getType ( ) === T_NS_SEPARATOR ; $ relative = $ first -> getType ( ) === T_NAMESPACE ; $ parts = $ this -> getParts ( ) ; return [ 'absolute' => $ absolute , 'relative' => $ relative , 'qualified' => ! $ absolute && count ( $ parts ) > 1 , 'unqualified' => ! $ absolute && count ( $ parts ) === 1 , 'parts' => $ parts , ] ; } | Return information about the name . |
15,282 | public function getPath ( ) { $ path = '' ; $ child = $ this -> head ; while ( $ child ) { $ type = $ child -> getType ( ) ; if ( $ type === T_NAMESPACE || $ type === T_NS_SEPARATOR || $ type === T_STRING ) { $ path .= $ child -> getText ( ) ; } $ child = $ child -> next ; } return $ path ; } | Get the namespace path . |
15,283 | protected function resolveUnqualified ( $ name ) { if ( $ this -> parent instanceof NamespaceNode ) { return '\\' . $ name ; } if ( $ this -> parent instanceof UseDeclarationNode ) { return '\\' . $ name ; } $ namespace = $ this -> getNamespace ( ) ; $ use_declarations = array ( ) ; if ( $ namespace ) { $ use_declarations = $ namespace -> getBody ( ) -> getUseDeclarations ( ) ; } else { $ root_node = $ this -> closest ( Filter :: isInstanceOf ( '\Pharborist\RootNode' ) ) ; if ( $ root_node ) { $ use_declarations = $ root_node -> getUseDeclarations ( ) ; } } if ( $ this -> parent instanceof FunctionCallNode ) { foreach ( $ use_declarations as $ use_declaration ) { if ( $ use_declaration -> isFunction ( ) && $ use_declaration -> getBoundedName ( ) === $ name ) { return '\\' . $ use_declaration -> getName ( ) -> getPath ( ) ; } } return $ this -> getParentPath ( ) . $ name ; } elseif ( $ this -> parent instanceof ConstantNode ) { foreach ( $ use_declarations as $ use_declaration ) { if ( $ use_declaration -> isConst ( ) && $ use_declaration -> getBoundedName ( ) === $ name ) { return '\\' . $ use_declaration -> getName ( ) -> getPath ( ) ; } } return $ this -> getParentPath ( ) . $ name ; } else { foreach ( $ use_declarations as $ use_declaration ) { if ( $ use_declaration -> isClass ( ) && $ use_declaration -> getBoundedName ( ) === $ name ) { return '\\' . $ use_declaration -> getName ( ) -> getPath ( ) ; } } return $ this -> getParentPath ( ) . $ name ; } } | Resolve an unqualified name to fully qualified name . |
15,284 | public function analyze ( string $ path ) { $ contents = ( string ) file_get_contents ( $ path ) ; $ traverser = new NodeTraverser ( ) ; $ traverser -> addVisitor ( new NameResolver ( ) ) ; $ traverser -> addVisitor ( $ imports = new ImportVisitor ( ) ) ; $ traverser -> addVisitor ( $ names = new NameVisitor ( ) ) ; $ traverser -> addVisitor ( $ docs = DocVisitor :: create ( $ contents ) ) ; $ traverser -> traverse ( $ this -> parser -> parse ( $ contents ) ) ; return array_values ( array_unique ( array_merge ( $ imports -> getImports ( ) , $ names -> getNames ( ) , DocProcessor :: process ( $ docs -> getDoc ( ) ) ) ) ) ; } | Get the fullyqualified imports and typehints . |
15,285 | public static function create ( $ comment ) { $ comment = trim ( $ comment ) ; $ nl_count = substr_count ( $ comment , "\n" ) ; if ( $ nl_count > 1 ) { return LineCommentBlockNode :: create ( $ comment ) ; } else { return new CommentNode ( T_COMMENT , '// ' . $ comment . "\n" ) ; } } | Create line comment . |
15,286 | public function getWebhookForClient ( $ name ) { return Arr :: get ( $ this -> clientsConfig [ $ name ] , 'webhook' ) ? : Arr :: get ( $ this -> clientsDefaults , 'webhook' ) ; } | Get the webhook for the given client . |
15,287 | public function getMessageDefaultsForClient ( $ name ) { return array_merge ( Arr :: get ( $ this -> clientsDefaults , 'message_defaults' , [ ] ) , Arr :: get ( $ this -> clientsConfig [ $ name ] , 'message_defaults' , [ ] ) ) ; } | Get the message defaults for the given client . |
15,288 | public function sendRestorePassword ( string $ email , string $ hash ) : void { $ mail = $ this -> createMail ( 'restorePassword' ) ; $ mail -> link = $ this -> link ( 'Cms:Sign:restorePassword' , [ 'hash' => $ hash ] ) ; $ mail -> setSubject ( 'cms.mailing.restorePassword.subject' ) -> addTo ( $ email ) ; $ mail -> send ( ) ; } | Odeslani linku pro zmenu hesla |
15,289 | public function sendNewUser ( string $ email , string $ username , string $ password ) : void { $ mail = $ this -> createMail ( 'newUser' ) ; $ mail -> link = $ this -> link ( 'Cms:Sign:in' ) ; $ mail -> username = $ username ; $ mail -> password = $ password ; $ mail -> setSubject ( 'cms.mailing.newUser.subject' ) -> addTo ( $ email ) ; $ mail -> send ( ) ; } | Posle email novemu uzivateli s loginem a heslem |
15,290 | public function toggleVisibility ( StateToggleVisibilityEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ state = $ event -> getState ( ) ; $ state -> setDispatcher ( $ dispatcher ) -> setVisible ( ! $ state -> getVisible ( ) ) -> save ( ) ; $ event -> setState ( $ state ) ; } | Toggle State visibility |
15,291 | public function getLineCount ( ) { $ count = 1 ; $ this -> find ( Filter :: isInstanceOf ( '\Pharborist\WhitespaceNode' ) ) -> each ( function ( WhitespaceNode $ node ) use ( & $ count ) { $ count += $ node -> getNewlineCount ( ) ; } ) ; return $ count ; } | Gets the number of lines spanned by this statement . |
15,292 | public function addCommentAbove ( $ comment ) { if ( $ comment instanceof LineCommentBlockNode ) { $ this -> before ( $ comment ) ; } elseif ( is_string ( $ comment ) ) { $ this -> addCommentAbove ( LineCommentBlockNode :: create ( $ comment ) ) ; } else { throw new \ InvalidArgumentException ( ) ; } return $ this ; } | Adds a line comment block above the statement . |
15,293 | public static function create ( $ parameter_name ) { $ parameter_name = '$' . ltrim ( $ parameter_name , '$' ) ; $ parameter_node = new ParameterNode ( ) ; $ parameter_node -> addChild ( new VariableNode ( T_VARIABLE , $ parameter_name ) , 'name' ) ; return $ parameter_node ; } | Create a parameter node . |
15,294 | public function getDocBlockTag ( ) { $ doc_comment = $ this -> getFunction ( ) -> getDocComment ( ) ; return $ doc_comment ? $ doc_comment -> getParameter ( $ this -> name -> getText ( ) ) : NULL ; } | Get the doc block tag associated with this parameter . |
15,295 | public function hasDocTypes ( ) { $ doc_comment = $ this -> getFunction ( ) -> getDocComment ( ) ; if ( ! $ doc_comment ) { return FALSE ; } $ param_tag = $ doc_comment -> getParameter ( $ this -> getName ( ) ) ; if ( ! $ param_tag ) { return FALSE ; } $ types = $ param_tag -> getTypes ( ) ; return ! empty ( $ types ) ; } | Return TRUE if parameter has a phpDoc type . |
15,296 | public function getDocTypes ( ) { $ types = [ 'mixed' ] ; $ doc_comment = $ this -> getFunction ( ) -> getDocComment ( ) ; if ( ! $ doc_comment ) { return $ types ; } $ param_tag = $ doc_comment -> getParameter ( $ this -> getName ( ) ) ; if ( ! $ param_tag ) { return $ types ; } $ types = Types :: normalize ( $ param_tag -> getTypes ( ) ) ; if ( empty ( $ types ) ) { $ types [ ] = 'mixed' ; } return $ types ; } | Get the php doc types for parameter . |
15,297 | public function getTypes ( ) { if ( $ this -> typeHint ) { if ( $ this -> typeHint instanceof TokenNode ) { if ( $ this -> typeHint -> getType ( ) === T_ARRAY ) { $ docTypes = $ this -> getDocTypes ( ) ; foreach ( $ docTypes as $ docType ) { if ( $ docType !== 'array' && substr ( $ docType , - 2 ) !== '[]' ) { return [ $ this -> typeHint -> getText ( ) ] ; } } return $ docTypes ; } else { return [ $ this -> typeHint -> getText ( ) ] ; } } else { return [ $ this -> typeHint -> getAbsolutePath ( ) ] ; } } return $ this -> getDocTypes ( ) ; } | Get the type of the parameter as defined by type hinting or doc comment . |
15,298 | public function addAdditionalFolderAction ( ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } $ folder_id = \ intval ( $ this -> getRequest ( ) -> request -> get ( 'additional_folder_id' ) ) ; if ( $ folder_id > 0 ) { $ event = new ContentAddFolderEvent ( $ this -> getExistingObject ( ) , $ folder_id ) ; try { $ this -> dispatch ( TheliaEvents :: CONTENT_ADD_FOLDER , $ event ) ; } catch ( \ Exception $ e ) { return $ this -> errorPage ( $ e ) ; } } return $ this -> redirectToEditionTemplate ( ) ; } | controller adding content to additional folder |
15,299 | public function removeAdditionalFolderAction ( ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } $ folder_id = \ intval ( $ this -> getRequest ( ) -> request -> get ( 'additional_folder_id' ) ) ; if ( $ folder_id > 0 ) { $ event = new ContentRemoveFolderEvent ( $ this -> getExistingObject ( ) , $ folder_id ) ; try { $ this -> dispatch ( TheliaEvents :: CONTENT_REMOVE_FOLDER , $ event ) ; } catch ( \ Exception $ e ) { return $ this -> errorPage ( $ e ) ; } } return $ this -> redirectToEditionTemplate ( ) ; } | controller removing additional folder to a content |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.