idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
227,400
private function createAdminController ( \ stdClass $ oModel ) : self { $ this -> oOutput -> write ( 'Creating admin controller... ' ) ; $ iExitCode = $ this -> callCommand ( 'make:controller:admin' , [ 'modelName' => $ oModel -> service_name , '--skip-check' => true , ] , false , true ) ; if ( $ iExitCode === static :...
Creates an admin controller
227,401
private function generateServiceDefinitions ( \ stdClass $ oModel ) : array { return [ implode ( "\n" , [ str_repeat ( ' ' , $ this -> iServicesIndent ) . '\'' . $ oModel -> service_name . '\' => function () {' , str_repeat ( ' ' , $ this -> iServicesIndent ) . ' return new ' . $ oModel -> class_path . '();' , str_r...
Genenrates the service file definitions for a model
227,402
private function addLocalisedUseStatement ( \ stdClass $ oModel ) : self { $ sFile = file_get_contents ( $ oModel -> path . $ oModel -> filename ) ; $ aClasses = [ ] ; if ( preg_match_all ( '/^use (.+);$/m' , $ sFile , $ aMatches ) ) { if ( ! empty ( $ aMatches [ 1 ] ) ) { $ aClasses = $ aMatches [ 1 ] ; } } $ aClasses...
Adds a use Localised statement to a model
227,403
private function convertTablesToLocalised ( \ stdClass $ oModel ) : self { $ oDb = Factory :: service ( 'Database' ) ; $ oLocale = Factory :: service ( 'Locale' ) ; $ aQueries = [ 'SET FOREIGN_KEY_CHECKS = 0;' , 'RENAME TABLE `' . $ oModel -> table_with_prefix . '` TO `' . $ oModel -> table_with_prefix . '_localised`;'...
Converts existing non - localised model tables to a localised version
227,404
public static function siteUrl ( string $ sUrl = null , bool $ bForceSecure = false ) : string { $ oConfig = \ Nails \ Factory :: service ( 'Config' ) ; return $ oConfig :: siteUrl ( $ sUrl , $ bForceSecure ) ; }
Create a local URL based on your basepath . Segments can be passed via the first parameter either as a string or an array .
227,405
public function getUrl ( string $ sKey = null ) : string { $ sUrl = rtrim ( $ this -> sUrl , '/' ) ; $ sUrl .= $ sKey ? '/' . $ sKey : '' ; return $ sUrl ; }
Return the URL for the public cache
227,406
public static function arraySortMulti ( array & $ aArray , $ sField ) { uasort ( $ aArray , function ( $ a , $ b ) use ( $ sField ) { $ oA = ( object ) $ a ; $ oB = ( object ) $ b ; $ mA = property_exists ( $ oA , $ sField ) ? strtolower ( $ oA -> $ sField ) : null ; $ mB = property_exists ( $ oB , $ sField ) ? strtolo...
Sorts a multi dimensional array
227,407
public static function arraySearchMulti ( $ sValue , $ sKey , array $ aArray ) { foreach ( $ aArray as $ k => $ val ) { if ( is_array ( $ val ) ) { if ( $ val [ $ sKey ] == $ sValue ) { return $ k ; } } elseif ( is_object ( $ val ) ) { if ( $ val -> $ sKey == $ sValue ) { return $ k ; } } } return false ; }
Searches a multi - dimensional array
227,408
public static function inArrayMulti ( $ sValue , $ sKey , array $ aArray ) : bool { return static :: arraySearchMulti ( $ sValue , $ sKey , $ aArray ) !== false ; }
Reports whether a value exists in a multi dimensional array
227,409
public static function arrayExtractProperty ( array $ aInput , $ sProperty ) { $ aOutput = [ ] ; foreach ( $ aInput as $ mItem ) { $ aItem = ( array ) $ mItem ; if ( array_key_exists ( $ sProperty , $ aItem ) ) { $ aOutput [ ] = $ aItem [ $ sProperty ] ; } } return $ aOutput ; }
Extracts the value of properties from a multi - dimensional array into an array of those values
227,410
public function show_error ( $ sSubject , $ sMessage = '' , $ sTemplate = '500' , $ iStatusCode = 500 , $ bUseException = true ) { if ( is_array ( $ sMessage ) ) { $ sMessage = implode ( '<br>' , $ sMessage ) ; } if ( $ bUseException ) { throw new NailsException ( $ sMessage , $ iStatusCode ) ; } else { $ oErrorHandler...
Override the show_error method and pass to the Nails ErrorHandler
227,411
public function show_exception ( $ oException ) { $ oErrorHandler = Factory :: service ( 'ErrorHandler' ) ; $ sMessage = implode ( '; ' , [ 'Code: ' . $ oException -> getCode ( ) , 'File: ' . $ oException -> getFile ( ) , 'Line: ' . $ oException -> getLine ( ) , ] ) ; $ oErrorHandler -> showFatalErrorScreen ( $ oExcept...
Override the show_exception method and pass to the Nails ErrorHandler
227,412
public function show_php_error ( $ iSeverity , $ sMessage , $ sFilePath , $ iLine ) { $ oErrorHandler = Factory :: service ( 'ErrorHandler' ) ; return $ oErrorHandler -> triggerError ( $ iSeverity , $ sMessage , $ sFilePath , $ iLine ) ; }
Overrides the show_php_error method in order to track errors
227,413
public function trigger ( $ sEvent , $ sNamespace = 'nails/common' , $ aData = [ ] ) { $ this -> addHistory ( $ sEvent , $ sNamespace ) ; $ sEvent = strtoupper ( $ sEvent ) ; $ sNamespace = strtoupper ( $ sNamespace ) ; if ( ! empty ( $ this -> aSubscriptions [ $ sNamespace ] [ $ sEvent ] ) ) { foreach ( $ this -> aSub...
Trigger the event and execute all callbacks
227,414
protected function addHistory ( $ sEvent , $ sNamespace = 'nails/common' ) { $ sEvent = strtoupper ( $ sEvent ) ; $ sNamespace = strtoupper ( $ sNamespace ) ; if ( ! array_key_exists ( $ sNamespace , $ this -> aHistory ) ) { $ this -> aHistory [ $ sNamespace ] = [ ] ; } if ( ! array_key_exists ( $ sEvent , $ this -> aH...
Adds a history item to the history array
227,415
public function getHistory ( $ sNamespace = null , $ sEvent = null ) { $ sEvent = strtoupper ( $ sEvent ) ; $ sNamespace = strtoupper ( $ sNamespace ) ; if ( empty ( $ sNamespace ) && empty ( $ sEvent ) ) { return $ this -> aHistory ; } elseif ( empty ( $ sEvent ) && ! empty ( $ sNamespace ) && array_key_exists ( $ sNa...
Retrieve a history item
227,416
public function set ( $ sType , $ sMessage ) { $ sType = strtoupper ( trim ( $ sType ) ) ; $ sMessage = trim ( $ sMessage ) ; $ this -> aMessages [ $ sType ] = $ sMessage ; return $ this ; }
Set a feedback message
227,417
public function get ( $ sType ) { $ sType = strtoupper ( trim ( $ sType ) ) ; if ( ! empty ( $ this -> aMessages [ $ sType ] ) ) { return $ this -> aMessages [ $ sType ] ; } else { return '' ; } }
Return a feedack message
227,418
public function clear ( $ sType = '' ) { if ( empty ( $ sType ) ) { $ this -> aMessages [ $ sType ] = array ( ) ; } else { $ this -> aMessages [ $ sType ] = '' ; } }
Clear feedback messages
227,419
public function getAllDateFormat ( ) { $ aFormats = static :: FORMAT_DATE ; $ oNow = Factory :: factory ( 'DateTime' ) ; foreach ( $ aFormats as & $ aFormat ) { $ aFormat = ( object ) $ aFormat ; $ aFormat -> example = $ oNow -> format ( $ aFormat -> format ) ; } return $ aFormats ; }
Returns all the defined date format objects
227,420
public function getAllDateFormatFlat ( ) { $ aOut = [ ] ; $ aFormats = $ this -> getAllDateFormat ( ) ; foreach ( $ aFormats as $ oFormat ) { $ aOut [ $ oFormat -> slug ] = $ oFormat -> example ; } return $ aOut ; }
Returns all the date format objects as a flat array
227,421
public function getDateFormatBySlug ( $ sSlug ) { $ aFormats = $ this -> getAllDateFormat ( ) ; foreach ( $ aFormats as $ oFormat ) { if ( $ oFormat -> slug === $ sSlug ) { return $ oFormat ; } } return null ; }
Looks for a date format by it s slug
227,422
public function getAllTimeFormat ( ) { $ aFormats = static :: FORMAT_TIME ; foreach ( $ aFormats as & $ aFormat ) { $ aFormat = ( object ) $ aFormat ; $ oDateTimeObject = static :: convert ( time ( ) , $ this -> sTimezoneUser ) ; $ aFormat -> example = $ oDateTimeObject -> format ( $ aFormat -> format ) ; } return $ aF...
Returns all the defined time format objects
227,423
public function getAllTimeFormatFlat ( ) { $ aOut = [ ] ; $ aFormats = $ this -> getAllTimeFormat ( ) ; foreach ( $ aFormats as $ oFormat ) { $ aOut [ $ oFormat -> slug ] = $ oFormat -> label ; } return $ aOut ; }
Returns all the time format objects as a flat array
227,424
public function getTimeFormatBySlug ( $ sSlug ) { $ aFormats = $ this -> getAllTimeFormat ( ) ; foreach ( $ aFormats as $ oFormat ) { if ( $ oFormat -> slug === $ sSlug ) { return $ oFormat ; } } return null ; }
Looks for a time format by it s slug
227,425
public function setDateFormat ( $ sSlug ) { $ oDateFormat = $ this -> getDateFormatBySlug ( $ sSlug ) ; if ( empty ( $ oDateFormat ) ) { $ oDateFormat = $ this -> getDateFormatDefault ( ) ; } $ this -> sUserFormatDate = $ oDateFormat -> format ; }
Set the date format to use uses default if slug cannot be found
227,426
public function setTimeFormat ( $ sSlug = null ) { $ oTimeFormat = $ this -> getTimeFormatBySlug ( $ sSlug ) ; if ( empty ( $ oTimeFormat ) ) { $ oTimeFormat = $ this -> getTimeFormatDefault ( ) ; } $ this -> sUserFormatTime = $ oTimeFormat -> format ; }
Set the time format to use uses default if slug cannot be found
227,427
public function toUserDate ( $ mTimestamp = null , $ sFormat = null ) { $ oConverted = static :: convert ( $ mTimestamp , $ this -> sTimezoneUser , $ this -> sTimezoneNails ) ; if ( is_null ( $ oConverted ) ) { return null ; } if ( is_null ( $ sFormat ) ) { $ sFormat = $ this -> sUserFormatDate ; } return $ oConverted ...
Convert a date timestamp to the User s timezone from the Nails timezone
227,428
public function toNailsDate ( $ mTimestamp = null ) { $ oConverted = static :: convert ( $ mTimestamp , $ this -> sTimezoneNails , $ this -> sTimezoneUser ) ; if ( is_null ( $ oConverted ) ) { return null ; } return $ oConverted -> format ( 'Y-m-d' ) ; }
Convert a date timestamp to the Nails timezone from the User s timezone formatted as Y - m - d
227,429
public function toUserDatetime ( $ mTimestamp = null , $ sFormat = null ) { $ oConverted = static :: convert ( $ mTimestamp , $ this -> sTimezoneUser , $ this -> sTimezoneNails ) ; if ( is_null ( $ oConverted ) ) { return null ; } if ( is_null ( $ sFormat ) ) { $ sFormat = $ this -> sUserFormatDate . ' ' . $ this -> sU...
Convert a datetime timestamp to the user s timezone from the Nails timezone
227,430
public function setTimezones ( $ sTzNails = null , $ sTzUser = null ) { $ this -> setNailsTimezone ( $ sTzNails ) ; $ this -> setUserTimezone ( $ sTzUser ) ; }
Sets the Nails and User timezones simultaneously
227,431
public function getAllTimezone ( ) { $ aZones = \ DateTimeZone :: listIdentifiers ( ) ; $ aLocations = [ 'UTC' => 'Coordinated Universal Time (UTC/GMT)' ] ; foreach ( $ aZones as $ sZone ) { $ aZoneExploded = explode ( '/' , $ sZone ) ; $ aZoneAcceptable = [ 'Africa' , 'America' , 'Antarctica' , 'Arctic' , 'Asia' , 'At...
Returns a multi - dimensional array of supported timezones
227,432
public function getAllTimezoneFlat ( ) { $ aTimezones = $ this -> getAllTimezone ( ) ; $ aOut = [ ] ; foreach ( $ aTimezones as $ sKey => $ mValue ) { if ( is_array ( $ mValue ) ) { foreach ( $ mValue as $ subKey => $ subValue ) { if ( is_string ( $ subValue ) ) { $ aOut [ $ subKey ] = $ sKey . ' - ' . $ subValue ; } }...
Returns all the supported timezones as a flat array
227,433
public static function getCodeFromTimezone ( $ sTimezone ) { $ aAbbreviations = \ DateTimeZone :: listAbbreviations ( ) ; foreach ( $ aAbbreviations as $ sCode => $ aValues ) { foreach ( $ aValues as $ aValue ) { if ( $ aValue [ 'timezone_id' ] == $ sTimezone ) { return strtoupper ( $ sCode ) ; } } } return false ; }
Get the timezone code from the timezone string
227,434
public static function getTimezoneFromCode ( $ sCode ) { $ aAbbreviations = \ DateTimeZone :: listAbbreviations ( ) ; foreach ( $ aAbbreviations as $ sTzCode => $ aValues ) { if ( strtolower ( $ sCode ) == $ sTzCode ) { $ aTimeZone = reset ( $ aValues ) ; return getFromArray ( 'timezone_id' , $ aTimeZone , false ) ; } ...
Get the timezone string from the timezone code
227,435
public static function convert ( $ mTimestamp , $ sToTz , $ sFromTz = 'UTC' ) { if ( is_null ( $ mTimestamp ) ) { $ oDateTime = Factory :: factory ( 'DateTime' ) ; } elseif ( is_numeric ( $ mTimestamp ) ) { $ oDateTime = Factory :: factory ( 'DateTime' ) ; $ oDateTime -> setTimestamp ( $ mTimestamp ) ; } elseif ( $ mTi...
Arbitrarily convert a timestamp between timezones
227,436
public function preProcessConfiguration ( array $ configs ) : array { $ newConfigs = $ configs ; $ prependConfigs = [ ] ; foreach ( $ configs as $ index => $ config ) { if ( isset ( $ config [ 'system' ] ) ) { $ prependConfigs [ ] = [ 'system' => $ config [ 'system' ] ] ; unset ( $ config [ 'system' ] ) ; $ newConfigs ...
Pre - processes the configuration before it is resolved .
227,437
public function postProcessConfiguration ( array $ config ) : array { $ config = $ this -> fixUpViewConfig ( $ config ) ; $ processor = new ConfigurationProcessor ( $ this -> container , $ this -> extension -> getAlias ( ) ) ; foreach ( array_keys ( $ config ) as $ key ) { if ( $ key === 'system' || ! in_array ( $ key ...
Post - processes the resolved configuration .
227,438
private function fixUpViewConfig ( array $ config ) : array { foreach ( $ config [ 'system' ] as $ scope => $ scopeConfig ) { if ( $ scope === 'default' ) { continue ; } foreach ( array_keys ( $ scopeConfig [ 'view' ] ) as $ viewName ) { if ( isset ( $ config [ 'system' ] [ 'default' ] [ 'view' ] [ $ viewName ] ) ) { f...
Ugly hack to support semantic view config . The problem is eZ semantic config supports only merging arrays up to second level but in view config we have three .
227,439
private function buildSectionFilterParameters ( ParameterBuilderInterface $ builder , array $ groups = [ ] ) : void { $ builder -> add ( 'filter_by_section' , ParameterType \ Compound \ BooleanType :: class , [ 'groups' => $ groups , ] ) ; $ builder -> get ( 'filter_by_section' ) -> add ( 'sections' , EzParameterType \...
Builds the parameters for filtering by sections .
227,440
private function getSectionFilterCriteria ( ParameterCollectionInterface $ parameterCollection ) : ? Criterion { if ( $ parameterCollection -> getParameter ( 'filter_by_section' ) -> getValue ( ) !== true ) { return null ; } $ sections = $ parameterCollection -> getParameter ( 'sections' ) -> getValue ( ) ?? [ ] ; if (...
Returns the criteria used to filter content by section .
227,441
private function getSectionIds ( array $ sectionIdentifiers ) : array { $ idList = [ ] ; foreach ( $ sectionIdentifiers as $ identifier ) { try { $ section = $ this -> sectionHandler -> loadByIdentifier ( $ identifier ) ; $ idList [ ] = $ section -> id ; } catch ( NotFoundException $ e ) { continue ; } } return $ idLis...
Returns section IDs for all provided section identifiers .
227,442
private function addLayoutsSubMenu ( ItemInterface $ menu ) : void { $ menuOrder = $ this -> getNewMenuOrder ( $ menu ) ; $ layouts = $ menu -> addChild ( 'nglayouts' ) -> setLabel ( 'menu.main_menu.header' ) -> setExtra ( 'translation_domain' , 'ngbm_admin' ) ; $ layouts -> addChild ( 'layout_resolver' , [ 'route' => ...
Adds the Netgen Layouts submenu to eZ Platform admin interface .
227,443
public function fix ( $ module , $ oConfig = null ) { if ( $ oConfig !== null ) { $ this -> setConfig ( $ oConfig ) ; } $ moduleId = $ module -> getId ( ) ; if ( ! $ this -> initialCacheClearDone ) { ModuleVariablesLocator :: resetModuleVariables ( ) ; if ( extension_loaded ( 'apc' ) && ini_get ( 'apc.enabled' ) ) { ap...
Fix module states task runs version extend files templates blocks settings and events information fix tasks
227,444
public function parseResponse ( $ response ) { $ this -> responseRaw = $ response ; try { $ parser = new \ Genesis \ Parser ( 'xml' ) ; $ parser -> skipRootNode ( ) ; $ parser -> parseDocument ( $ response ) ; $ this -> responseObj = $ parser -> getObject ( ) ; } catch ( \ Exception $ e ) { throw new \ Genesis \ Except...
Parse Genesis response to stdClass and apply transformation to known fields
227,445
public function isSuccessful ( ) { $ status = new Constants \ Transaction \ States ( isset ( $ this -> responseObj -> status ) ? $ this -> responseObj -> status : '' ) ; if ( $ status -> isValid ( ) ) { return ! $ status -> isError ( ) ; } return null ; }
Check whether the request was successful
227,446
public function isPartiallyApproved ( ) { if ( isset ( $ this -> responseObj -> partial_approval ) ) { return \ Genesis \ Utils \ Common :: stringToBoolean ( $ this -> responseObj -> partial_approval ) ; } return null ; }
Check whether the transaction was partially approved
227,447
public function suppressReconciliationException ( ) { $ instances = [ new \ Genesis \ API \ Request \ NonFinancial \ Reconcile \ DateRange ( ) , new \ Genesis \ API \ Request \ NonFinancial \ Reconcile \ Transaction ( ) , new \ Genesis \ API \ Request \ WPF \ Reconcile ( ) ] ; if ( isset ( $ this -> requestCtx ) && iss...
Suppress Reconciliation responses as their statuses reflect their transactions
227,448
public function getErrorDescription ( ) { if ( isset ( $ this -> responseObj -> code ) && ! empty ( $ this -> responseObj -> code ) ) { return Constants \ Errors :: getErrorDescription ( $ this -> responseObj -> code ) ; } if ( isset ( $ this -> responseObj -> response_code ) && ! empty ( $ this -> responseObj -> respo...
Try to fetch a description of the received Error Code
227,449
public static function transform ( $ obj ) { if ( is_array ( $ obj ) || is_object ( $ obj ) ) { foreach ( $ obj as & $ object ) { if ( isset ( $ object -> status ) ) { self :: transformObject ( $ object ) ; } self :: transform ( $ object ) ; } } }
Iterate and transform object
227,450
public static function transformObject ( & $ entry ) { $ filters = [ 'transformFilterAmounts' , 'transformFilterTimestamp' ] ; foreach ( $ filters as $ filter ) { if ( method_exists ( __CLASS__ , $ filter ) ) { $ result = call_user_func ( [ __CLASS__ , $ filter ] , $ entry ) ; if ( $ result ) { $ entry = $ result ; } }...
Apply filters to an entry object
227,451
public static function transformFilterTimestamp ( $ transaction ) { if ( isset ( $ transaction -> timestamp ) ) { try { $ transaction -> timestamp = new \ DateTime ( $ transaction -> timestamp ) ; } catch ( \ Exception $ e ) { error_log ( $ e -> getMessage ( ) ) ; } } return $ transaction ; }
Get DateTime object from the timestamp inside the response
227,452
public static function getCertificateBundle ( ) { $ bundle = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'Certificates' . DIRECTORY_SEPARATOR . 'ca-bundle.pem' ; if ( ! file_exists ( $ bundle ) ) { throw new \ Genesis \ Exceptions \ InvalidArgument ( 'CA Bundle file is missing or inaccessible' ) ; } return $ bundle ; ...
Get the CA PEM
227,453
public static function getInterface ( $ type ) { if ( array_key_exists ( $ type , self :: $ interfaces ) ) { return self :: $ interfaces [ $ type ] ; } return false ; }
Get configuration for an interface
227,454
public static function setInterface ( $ interface , $ value ) { if ( array_key_exists ( $ interface , self :: $ interfaces ) ) { self :: $ interfaces [ $ interface ] = $ value ; return true ; } return false ; }
Set an interface
227,455
public static function setEndpoint ( $ endpointArg ) { $ endpointArg = strtolower ( trim ( $ endpointArg ) ) ; $ aliases = [ \ Genesis \ API \ Constants \ Endpoints :: EMERCHANTPAY => [ 'emp' , 'emerchantpay' , \ Genesis \ API \ Constants \ Endpoints :: EMERCHANTPAY ] , \ Genesis \ API \ Constants \ Endpoints :: ECOMPR...
Set Genesis Endpoint
227,456
public static function getSubDomain ( $ sub ) { if ( isset ( self :: $ domains [ $ sub ] ) ) { return self :: $ domains [ $ sub ] [ self :: getEnvironment ( ) ] ; } return null ; }
Get a sub - domain host based on the environment
227,457
public static function loadSettings ( $ iniFile ) { if ( ! file_exists ( $ iniFile ) ) { throw new \ Genesis \ Exceptions \ InvalidArgument ( 'The provided configuration file is invalid or inaccessible!' ) ; } $ settings = parse_ini_file ( $ iniFile , true ) ; foreach ( $ settings [ 'Genesis' ] as $ option => $ value )...
Load settings from an ini File
227,458
public static function getCountryName ( $ iso_code ) { if ( isset ( self :: $ countries [ $ iso_code ] ) ) { return self :: $ countries [ $ iso_code ] ; } return false ; }
Get a country s name by its ISO Code
227,459
protected function _goUp ( AbstractQuery $ oQuery , outputInterface $ oOutput = null ) { if ( $ this -> isExecuted ( $ oQuery ) ) { return false ; } if ( $ oOutput ) { $ oOutput -> writeLn ( sprintf ( '[DEBUG] Migrating up %s %s' , $ oQuery -> getTimestamp ( ) , $ oQuery -> getClassName ( ) ) ) ; } $ oQuery -> up ( ) ;...
Executes an UP Migration
227,460
protected function _goDown ( AbstractQuery $ oQuery , OutputInterface $ oOutput = null ) { if ( ! $ this -> isExecuted ( $ oQuery ) ) { return false ; } if ( $ oOutput ) { $ oOutput -> writeLn ( sprintf ( '[DEBUG] Migrating down %s %s' , $ oQuery -> getTimestamp ( ) , $ oQuery -> getClassName ( ) ) ) ; } $ oQuery -> do...
Executes a DOWN Migration
227,461
public function isExecuted ( AbstractQuery $ oQuery ) { foreach ( $ this -> _aExecutedQueryNames as $ executedQuery ) { if ( $ oQuery -> getFilename ( ) == $ executedQuery [ 'version' ] ) { return true ; } } return false ; }
Is query already executed?
227,462
public function setExecuted ( AbstractQuery $ oQuery ) { $ sSQL = 'REPLACE INTO oxmigrationstatus SET version = ?' ; DatabaseProvider :: getDb ( ) -> execute ( $ sSQL , array ( $ oQuery -> getFilename ( ) ) ) ; }
Set query as executed
227,463
public function setUnexecuted ( AbstractQuery $ oQuery ) { $ sSQL = 'DELETE FROM oxmigrationstatus WHERE version = ?' ; DatabaseProvider :: getDb ( ) -> execute ( $ sSQL , array ( $ oQuery -> getFilename ( ) ) ) ; }
Set query as not executed
227,464
protected function _buildMigrationQueries ( ) { if ( ! is_dir ( $ this -> _sMigrationQueriesDir ) ) { return false ; } $ oDirectory = new \ RecursiveDirectoryIterator ( $ this -> _sMigrationQueriesDir ) ; $ oFlattened = new \ RecursiveIteratorIterator ( $ oDirectory ) ; $ aFiles = new \ RegexIterator ( $ oFlattened , A...
Load and build migration files
227,465
protected function _getClassNameFromFilePath ( $ sFilePath ) { $ sFileName = basename ( $ sFilePath ) ; $ aMatches = array ( ) ; if ( ! preg_match ( AbstractQuery :: REGEXP_FILE , $ sFileName , $ aMatches ) ) { throw new MigrationException ( 'Could not extract class name from file name' ) ; } return $ aMatches [ 2 ] . ...
Get migration queries class name parsed from file path
227,466
protected function _buildMigrationName ( array $ words ) { $ sMigrationName = '' ; foreach ( $ words as $ word ) { if ( ! $ word ) { continue ; } $ sMigrationName .= ucfirst ( $ word ) ; } return $ sMigrationName ; }
Build migration name from tokens
227,467
protected function verifyRequiredField ( $ field , $ value ) { if ( empty ( $ value ) ) { throw new \ Genesis \ Exceptions \ ErrorParameter ( sprintf ( 'Empty (null) item required parameter: %s' , $ field ) ) ; } }
Verify required field
227,468
protected function verifyNonNegativeField ( $ field , $ value ) { if ( ! empty ( $ value ) && $ value <= 0 ) { throw new \ Genesis \ Exceptions \ ErrorParameter ( sprintf ( 'Item parameter %s is set to %s, but expected to be positive number' , $ field , $ value ) ) ; } }
Verify non - negative filed
227,469
protected function verifyNegativeField ( $ field , $ value ) { if ( ! empty ( $ value ) && $ value > 0 ) { throw new \ Genesis \ Exceptions \ ErrorParameter ( sprintf ( 'Item parameter %s is set to %s, but expected to be negative number' , $ field , $ value ) ) ; } }
Verify negative filed
227,470
protected function verifyUnitPriceField ( $ value ) { $ this -> verifyRequiredField ( 'unit_price' , $ value ) ; if ( in_array ( $ this -> item_type , [ self :: ITEM_TYPE_DISCOUNT , self :: ITEM_TYPE_STORE_CREDIT ] ) ) { $ this -> verifyNegativeField ( 'unit_price' , $ value ) ; return ; } $ this -> verifyNonNegativeFi...
Verify unit_price filed
227,471
public function setItemType ( $ value ) { $ this -> verifyRequiredField ( 'item_type' , $ value ) ; $ item_types = array ( self :: ITEM_TYPE_PHYSICAL , self :: ITEM_TYPE_DISCOUNT , self :: ITEM_TYPE_SHIPPING_FEE , self :: ITEM_TYPE_DIGITAL , self :: ITEM_TYPE_GIFT_CARD , self :: ITEM_TYPE_STORE_CREDIT , self :: ITEM_TY...
Set item type
227,472
public function setQuantityUnit ( $ value ) { if ( ! empty ( $ value ) && strlen ( $ value ) > 8 ) { throw new \ Genesis \ Exceptions \ ErrorParameter ( sprintf ( 'Item parameter quantity_unit is set to %s, but expected to be string with max length 8 characters' , $ value ) ) ; } $ this -> quantity_unit = $ value ; ret...
Set item quantity unit
227,473
public function getTotalAmount ( ) { $ total_amount = $ this -> unit_price * $ this -> quantity ; if ( ! empty ( $ this -> total_discount_amount ) ) { return $ total_amount - $ this -> total_discount_amount ; } return $ total_amount ; }
Calculate order item total amount
227,474
public function getTotalTaxAmount ( ) { $ total_amount = CurrencyUtils :: amountToExponent ( $ this -> getTotalAmount ( ) , $ this -> currency ) ; $ tax_rate = CurrencyUtils :: amountToExponent ( $ this -> tax_rate , $ this -> currency ) ; $ total_tax_amount = ceil ( $ total_amount - ( ( $ total_amount * 10000 ) / ( 10...
Calculate order item total tax amount . Round it up to next whole number
227,475
public function toArray ( ) { return [ 'name' => $ this -> name , 'item_type' => $ this -> item_type , 'quantity' => $ this -> quantity , 'unit_price' => CurrencyUtils :: amountToExponent ( $ this -> unit_price , $ this -> currency ) , 'tax_rate' => CurrencyUtils :: amountToExponent ( $ this -> tax_rate , $ this -> cur...
Convert item to array
227,476
public static function getAll ( ) { $ aShopIds = DatabaseProvider :: getDb ( ) -> getCol ( 'SELECT oxid FROM oxshops' ) ; $ aConfigs = array ( ) ; foreach ( $ aShopIds as $ mShopId ) { $ aConfigs [ ] = new ShopConfig ( $ mShopId ) ; } return $ aConfigs ; }
Returns config arrays for all shops
227,477
public static function get ( $ mShopId ) { $ sSQL = 'SELECT 1 FROM oxshops WHERE oxid = %s' ; $ oDb = DatabaseProvider :: getDb ( ) ; if ( ! $ oDb -> getOne ( sprintf ( $ sSQL , $ oDb -> quote ( $ mShopId ) ) ) ) { return null ; } return new ShopConfig ( $ mShopId ) ; }
Get config object of given shop id
227,478
public function saveShopConfVar ( $ sVarType , $ sVarName , $ sVarVal , $ sShopId = null , $ sModule = '' ) { $ sShopId = $ sShopId === null ? $ this -> _iShopId : $ sShopId ; if ( $ sShopId == $ this -> _iShopId ) { $ storedType = $ this -> getShopConfType ( $ sVarName , $ sModule ) ; if ( $ sModule == Config :: OXMOD...
overwritten method for performance reasons
227,479
public function setLifetime ( $ lifetime ) { $ lifetime = intval ( $ lifetime ) ; if ( $ lifetime < 1 || $ lifetime > 44640 ) { throw new InvalidArgument ( 'Valid value ranges between 1 minute and 31 days given in minutes' ) ; } $ this -> lifetime = $ lifetime ; return $ this ; }
Number of minutes determining how long the WPF will be valid . Will be set to 30 minutes by default . Valid value ranges between 1 minute and 31 days given in minutes
227,480
public function addTransactionType ( $ name , $ parameters = [ ] ) { $ this -> verifyTransactionType ( $ name , $ parameters ) ; $ structure = [ 'transaction_type' => [ '@attributes' => [ 'name' => $ name ] , $ parameters ] ] ; array_push ( $ this -> transaction_types , $ structure ) ; return $ this ; }
Add transaction type to the list of available types
227,481
protected function verifyTransactionType ( $ transactionType , $ parameters = [ ] ) { if ( ! Types :: isValidWPFTransactionType ( $ transactionType ) ) { throw new \ Genesis \ Exceptions \ ErrorParameter ( sprintf ( 'Transaction type (%s) is not valid. Valid WPF transactions are: %s.' , $ transactionType , implode ( ',...
Verify that transaction type parameters are populated correctly
227,482
protected function checkEmptyRequiredParamsFor ( $ transactionType , $ customRequiredParam , $ txnParameters = [ ] ) { if ( CommonUtils :: isArrayKeyExists ( $ customRequiredParam , $ txnParameters ) && ! empty ( $ txnParameters [ $ customRequiredParam ] ) ) { return ; } foreach ( $ txnParameters as $ parameter ) { if ...
Performs a check there is an empty required param for the passed transaction type
227,483
public function setLanguage ( $ language = \ Genesis \ API \ Constants \ i18n :: EN ) { $ language = substr ( strtolower ( $ language ) , 0 , 2 ) ; if ( ! \ Genesis \ API \ Constants \ i18n :: isValidLanguageCode ( $ language ) ) { throw new \ Genesis \ Exceptions \ InvalidArgument ( 'The provided argument is not a val...
Add ISO 639 - 1 language code to the URL
227,484
public static function getSplitPaymentsTrxTypes ( ) { return [ self :: SALE , self :: SALE_3D , self :: TCS , self :: FASHIONCHEQUE , self :: INTERSOLVE ] ; }
Get valid split payment transaction types
227,485
public static function getCustomRequiredParameters ( $ type ) { $ method = 'for' . Common :: snakeCaseToCamelCase ( $ type ) ; if ( ! method_exists ( CustomRequiredParameters :: class , $ method ) ) { return false ; } return CustomRequiredParameters :: $ method ( ) ; }
Get custom required parameters with values per transaction
227,486
public static function amountToExponent ( $ amount , $ iso ) { $ iso = strtoupper ( $ iso ) ; if ( array_key_exists ( $ iso , self :: $ iso4217 ) ) { $ exp = intval ( self :: $ iso4217 [ $ iso ] [ 'exponent' ] ) ; if ( $ exp > 0 ) { return bcmul ( $ amount , pow ( 10 , $ exp ) , 0 ) ; } } return strval ( $ amount ) ; }
Convert amount to ISO - 4217 minor currency unit
227,487
public static function exponentToAmount ( $ amount , $ iso ) { $ iso = strtoupper ( $ iso ) ; if ( array_key_exists ( $ iso , self :: $ iso4217 ) ) { $ exp = intval ( self :: $ iso4217 [ $ iso ] [ 'exponent' ] ) ; if ( $ exp > 0 ) { return bcdiv ( $ amount , pow ( 10 , $ exp ) , $ exp ) ; } } return strval ( $ amount )...
Convert ISO - 4217 minor currency unit to amount
227,488
public function getDocument ( ) { $ this -> processRequestParameters ( ) ; if ( $ this -> treeStructure instanceof \ ArrayObject ) { $ this -> builderContext = new \ Genesis \ Builder ( ) ; $ this -> builderContext -> parseStructure ( $ this -> treeStructure -> getArrayCopy ( ) ) ; return $ this -> builderContext -> ge...
Generate the XML output
227,489
protected function verifyFieldRequirements ( ) { if ( isset ( $ this -> requiredFields ) ) { $ this -> requiredFields -> setIteratorClass ( 'RecursiveArrayIterator' ) ; $ iterator = new \ RecursiveIteratorIterator ( $ this -> requiredFields -> getIterator ( ) ) ; foreach ( $ iterator as $ fieldName ) { if ( empty ( $ t...
Verify that all required fields are populated
227,490
protected function verifyFieldValuesRequirements ( ) { if ( ! isset ( $ this -> requiredFieldValues ) ) { return ; } $ iterator = $ this -> requiredFieldValues -> getArrayCopy ( ) ; foreach ( $ iterator as $ fieldName => $ validator ) { if ( $ validator instanceof RequestValidator ) { $ validator -> run ( $ this , $ fi...
Verify that all required fields are populated with expected values
227,491
protected function verifyGroupRequirements ( ) { if ( isset ( $ this -> requiredFieldsGroups ) ) { $ fields = $ this -> requiredFieldsGroups -> getArrayCopy ( ) ; $ emptyFlag = false ; $ groupsFormatted = [ ] ; foreach ( $ fields as $ group => $ groupFields ) { $ groupsFormatted [ ] = sprintf ( '%s (%s)' , ucfirst ( $ ...
Verify that the group fields in the request are populated
227,492
protected function verifyConditionalFields ( ) { if ( isset ( $ this -> requiredFieldsOR ) ) { $ fields = $ this -> requiredFieldsOR -> getArrayCopy ( ) ; $ status = false ; foreach ( $ fields as $ fieldName ) { if ( isset ( $ this -> $ fieldName ) && ! empty ( $ this -> $ fieldName ) ) { $ status = true ; } } if ( ! $...
Verify conditional requirement where either one of the fields are populated
227,493
protected function transform ( $ method , $ args , $ prefix = 'transform' ) { $ method = $ prefix . CommonUtils :: snakeCaseToCamelCase ( $ method ) ; if ( method_exists ( $ this , $ method ) ) { $ result = call_user_func_array ( [ $ this , $ method ] , $ args ) ; if ( $ result ) { return $ result ; } } return reset ( ...
Perform a field transformation and return the result
227,494
protected function buildRequestURL ( $ sub = 'gateway' , $ path = '' , $ token = '' ) { $ protocol = ( $ this -> getApiConfig ( 'protocol' ) ) ? $ this -> getApiConfig ( 'protocol' ) : 'https' ; $ sub = \ Genesis \ Config :: getSubDomain ( $ sub ) ; $ domain = \ Genesis \ Config :: getEndpoint ( ) ; $ port = ( $ this -...
Build the complete URL for the request
227,495
protected function initApiGatewayConfiguration ( $ requestPath = 'process' , $ includeToken = true ) { $ this -> setApiConfig ( 'url' , $ this -> buildRequestURL ( 'gateway' , $ requestPath , ( $ includeToken ? \ Genesis \ Config :: getToken ( ) : false ) ) ) ; }
Initializes Api EndPoint Url with request path & terminal token
227,496
public function setCryptoAddress ( $ address ) { if ( ! $ this -> checkAddress ( $ address ) || ! preg_match ( static :: CRYPTO_ADDRESS_VALIDATION_REGEX , $ address ) ) { throw new ErrorParameter ( 'Invalid crypto address provided' ) ; } $ this -> crypto_address = $ address ; return $ this ; }
Valid crypto address where the funds will be received
227,497
private function decodeBase58 ( $ base58 ) { $ origbase58 = $ base58 ; $ base58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' ; $ return = '0' ; for ( $ i = 0 ; $ i < strlen ( $ base58 ) ; $ i ++ ) { $ current = ( string ) strpos ( $ base58chars , $ base58 [ $ i ] ) ; $ return = ( string ) bcmul (...
Convert a Base58 - encoded integer into the equivalent hex string representation
227,498
public function remove ( $ value ) { $ hash = self :: hash ( $ value ) ; if ( array_key_exists ( $ hash , $ this -> objects ) ) { unset ( $ this -> objects [ $ hash ] ) ; return true ; } return false ; }
If the value is in the set it will be removed and true is returned . otherwise false is returned .
227,499
public function contains ( $ value ) { $ hash = self :: hash ( $ value ) ; return array_key_exists ( $ hash , $ this -> objects ) ; }
Returns true if the value exist in the set . Otherwise false .