idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
33,100 | public function equalsTo ( $ value ) { if ( is_object ( $ value ) && $ value instanceof Enum ) { return $ value -> getValue ( ) == $ this -> value ; } return $ value == $ this -> value ; } | Compares given enum value to another value |
33,101 | public static function isValidValue ( $ value , $ strict = true ) : bool { $ values = array_values ( self :: getConstants ( ) ) ; return in_array ( $ value , $ values , $ strict ) ; } | Checks if given value is valid for this enum class . |
33,102 | public static function validate ( $ value , $ strict = true ) { if ( static :: isValidValue ( $ value , $ strict ) === false ) { throw new InvalidEnumValueException ( static :: getConstants ( ) ) ; } return $ value ; } | Returns validated value for this enum class or throws exception if not . |
33,103 | public static function url_parser ( $ url ) { $ regex = '/(?<=v=|v\/|vi=|vi\/|youtu.be\/|embed\/)([a-zA-Z0-9_-]{11})/' ; if ( ! empty ( $ url ) ) { if ( strpos ( $ url , 'youtu' ) !== false ) { if ( preg_match ( $ regex , $ url , $ matches ) ) { return $ matches [ 1 ] ; } } elseif ( strlen ( $ url ) == 11 ) { return $ url ; } } return false ; } | Parse YouTube URL into a valid 11 - character ID . |
33,104 | protected function _getServiceItem ( MShop_Order_Item_Base_Interface $ order , $ type , $ code = null ) { $ context = $ this -> _getContext ( ) ; $ serviceManager = MShop_Factory :: createManager ( $ context , 'service' ) ; $ search = $ serviceManager -> createSearch ( true ) ; $ expr = array ( ) ; if ( $ code !== null ) { $ expr [ ] = $ search -> compare ( '==' , 'service.code' , $ code ) ; } $ expr [ ] = $ search -> compare ( '==' , 'service.type.code' , $ type ) ; $ expr [ ] = $ search -> getConditions ( ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ search -> setSortations ( array ( $ search -> sort ( '+' , 'service.position' ) ) ) ; $ result = $ serviceManager -> searchItems ( $ search , array ( 'media' , 'price' , 'text' ) ) ; foreach ( $ result as $ item ) { $ provider = $ serviceManager -> getProvider ( $ item ) ; if ( $ provider -> isAvailable ( $ order ) === true ) { $ orderServiceManager = MShop_Factory :: createManager ( $ context , 'order/base/service' ) ; $ orderServiceItem = $ orderServiceManager -> createItem ( ) ; $ orderServiceItem -> copyFrom ( $ item ) ; $ orderServiceItem -> setPrice ( $ provider -> calcPrice ( $ order ) ) ; return $ orderServiceItem ; } } } | Returns the order service item for the given type and code if available . |
33,105 | protected function _setAddresses ( MShop_Order_Item_Base_Interface $ order , MShop_Order_Item_Interface $ item ) { $ addresses = $ order -> getAddresses ( ) ; if ( empty ( $ addresses ) && $ this -> _getConfigValue ( 'autofill.orderaddress' , true ) == true ) { $ manager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order/base/address' ) ; $ search = $ manager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'order.base.address.baseid' , $ item -> getBaseId ( ) ) ) ; $ addresses = $ manager -> searchItems ( $ search ) ; foreach ( $ addresses as $ address ) { $ order -> setAddress ( $ address , $ address -> getType ( ) ) ; } } } | Adds the addresses from the given order item to the basket . |
33,106 | protected function _setServices ( MShop_Order_Item_Base_Interface $ order , MShop_Order_Item_Interface $ item ) { $ services = $ order -> getServices ( ) ; if ( empty ( $ services ) && $ this -> _getConfigValue ( 'autofill.orderservice' , true ) == true ) { $ manager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order/base/service' ) ; $ search = $ manager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'order.base.service.baseid' , $ item -> getBaseId ( ) ) ) ; $ services = $ manager -> searchItems ( $ search ) ; foreach ( $ services as $ service ) { $ type = $ service -> getType ( ) ; if ( ( $ item = $ this -> _getServiceItem ( $ order , $ type , $ service -> getCode ( ) ) ) !== null ) { $ order -> setService ( $ item , $ type ) ; } } } } | Adds the services from the given order item to the basket . |
33,107 | protected function _setServicesDefault ( MShop_Order_Item_Base_Interface $ order ) { $ services = $ order -> getServices ( ) ; $ type = MShop_Order_Item_Base_Service_Abstract :: TYPE_DELIVERY ; if ( ! isset ( $ services [ $ type ] ) && $ this -> _getConfigValue ( 'autofill.delivery' , false ) == true && ( ( $ item = $ this -> _getServiceItem ( $ order , $ type , $ this -> _getConfigValue ( 'autofill.deliverycode' ) ) ) !== null || ( $ item = $ this -> _getServiceItem ( $ order , $ type ) ) !== null ) ) { $ order -> setService ( $ item , $ type ) ; } $ type = MShop_Order_Item_Base_Service_Abstract :: TYPE_PAYMENT ; if ( ! isset ( $ services [ $ type ] ) && $ this -> _getConfigValue ( 'autofill.payment' , false ) == true && ( ( $ item = $ this -> _getServiceItem ( $ order , $ type , $ this -> _getConfigValue ( 'autofill.paymentcode' ) ) ) !== null || ( $ item = $ this -> _getServiceItem ( $ order , $ type ) ) !== null ) ) { $ order -> setService ( $ item , $ type ) ; } } | Adds the default services to the basket if they are not available . |
33,108 | protected function _process ( $ stmts ) { $ tablename = 'mshop_order_base_product' ; $ this -> _msg ( 'Changing collation in mshop_order_base_product' , 0 ) ; $ this -> _status ( '' ) ; foreach ( $ stmts as $ columnname => $ stmt ) { $ this -> _msg ( sprintf ( 'Checking column "%1$s": ' , $ columnname ) , 1 ) ; if ( $ this -> _schema -> tableExists ( $ tablename ) === true && $ this -> _schema -> columnExists ( $ tablename , $ columnname ) === true && $ this -> _schema -> getColumnDetails ( $ tablename , $ columnname ) -> getCollationType ( ) !== 'utf8_bin' ) { $ this -> _execute ( $ stmt ) ; $ this -> _status ( 'changed' ) ; } else { $ this -> _status ( 'OK' ) ; } } } | Changes collation of mshop_order_base_product . |
33,109 | private function isProjectEshopInstallation ( ) { $ vendorCommunityEditionPath = Path :: join ( $ this -> getVendorPath ( ) , self :: COMPOSER_VENDOR_OXID_ESALES , self :: COMPOSER_PACKAGE_OXIDESHOP_CE ) ; return is_dir ( $ vendorCommunityEditionPath ) ; } | Determine if the given OXID eShop is a project installation . |
33,110 | public function getAllProfilesAction ( ) { $ profiles = [ ] ; $ repo = $ this -> get ( $ this -> getParameter ( 'ongr_settings.repo' ) ) ; $ search = $ repo -> createSearch ( ) ; $ search -> addAggregation ( new TermsAggregation ( 'profiles' , 'profile' ) ) ; $ result = $ repo -> findDocuments ( $ search ) ; foreach ( $ result -> getAggregation ( 'profiles' ) as $ agg ) { $ profiles [ ] = $ agg -> getValue ( 'key' ) ; } if ( empty ( $ profiles ) || ! in_array ( 'default' , $ profiles ) ) { array_unshift ( $ profiles , 'default' ) ; } return new JsonResponse ( $ profiles ) ; } | Returns a json list of profiles |
33,111 | public function toggleProfileAction ( Request $ request ) { $ settingName = $ this -> getParameter ( 'ongr_settings.active_profiles' ) ; $ manager = $ this -> get ( 'ongr_settings.settings_manager' ) ; if ( ! $ manager -> has ( $ settingName ) ) { $ manager -> create ( [ 'name' => $ settingName , 'value' => [ ] , 'type' => 'hidden' , ] ) ; } $ profileName = $ request -> get ( 'name' ) ; $ activeProfiles = ( array ) $ manager -> getValue ( $ settingName , [ ] ) ; $ key = array_search ( $ profileName , $ activeProfiles ) ; if ( $ key === false ) { $ activeProfiles [ ] = $ profileName ; } else { unset ( $ activeProfiles [ $ key ] ) ; } $ manager -> update ( $ settingName , [ 'value' => array_values ( $ activeProfiles ) ] ) ; $ this -> get ( 'ong_settings.cache_provider' ) -> deleteAll ( ) ; return new JsonResponse ( [ 'error' => false ] ) ; } | Toggle profile activation . |
33,112 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'order.base.product.id' : $ item -> setId ( $ value ) ; break ; case 'order.base.product.type' : $ item -> setType ( $ value ) ; break ; case 'order.base.product.baseid' : $ item -> setBaseId ( $ value ) ; break ; case 'order.base.product.orderproductid' : $ item -> setOrderProductId ( $ value ) ; break ; case 'order.base.product.suppliercode' : $ item -> setSupplierCode ( $ value ) ; break ; case 'order.base.product.prodcode' : $ item -> setProductCode ( $ value ) ; break ; case 'order.base.product.quantity' : $ item -> setQuantity ( $ value ) ; break ; case 'order.base.product.name' : $ item -> setName ( $ value ) ; break ; case 'order.base.product.flags' : $ item -> setFlags ( $ value ) ; break ; case 'order.base.product.status' : $ item -> setStatus ( $ value ) ; break ; case 'order.base.product.position' : $ item -> setPosition ( $ value ) ; break ; } } return $ item ; } | Creates a new order base product item and sets the properties from the given array . |
33,113 | public function getArgStmt ( Argument $ argument ) : NodeAbstract { $ dependencyIndex = ( string ) $ argument ; if ( $ dependencyIndex === 'Ray\Di\InjectionPointInterface-' . Name :: ANY ) { return $ this -> getInjectionPoint ( ) ; } $ hasDependency = isset ( $ this -> container -> getContainer ( ) [ $ dependencyIndex ] ) ; if ( ! $ hasDependency ) { return $ this -> nodeFactory -> getNode ( $ argument ) ; } $ dependency = $ this -> container -> getContainer ( ) [ $ dependencyIndex ] ; if ( $ dependency instanceof Instance ) { return ( $ this -> normalizer ) ( $ dependency -> value ) ; } return ( $ this -> functionCompiler ) ( $ argument , $ dependency ) ; } | Return method argument code |
33,114 | public function when ( $ request , $ permission , $ httpVerbs = null ) { foreach ( ( array ) $ request as $ uri ) { $ this -> router -> when ( $ uri , $ permission , $ httpVerbs ? : $ this -> httpVerbs ) ; } } | Register new filter for the specified request . |
33,115 | public function init ( ) { $ ds = DIRECTORY_SEPARATOR ; $ this -> _projectPath = realpath ( dirname ( __FILE__ ) . $ ds . '..' . $ ds . '..' ) ; require_once $ this -> _projectPath . $ ds . 'Arcavias.php' ; spl_autoload_register ( 'Arcavias::autoload' ) ; $ this -> _arcavias = new Arcavias ( ) ; $ incPath = $ this -> _arcavias -> getIncludePaths ( 'lib' ) ; $ incPath [ ] = get_include_path ( ) ; set_include_path ( implode ( PATH_SEPARATOR , $ incPath ) ) ; return true ; } | Initializes the object . |
33,116 | public function main ( ) { $ ds = DIRECTORY_SEPARATOR ; $ this -> _msg ( 'Generating JSB2 packages' ) ; $ abslen = strlen ( $ this -> _projectPath ) ; foreach ( $ this -> _arcavias -> getCustomPaths ( 'client/extjs' ) as $ base => $ paths ) { foreach ( $ paths as $ path ) { $ jsbPath = $ base . $ ds . $ path ; $ message = sprintf ( 'Package: %1$s ' , $ jsbPath ) ; $ this -> _msg ( sprintf ( 'Package: %1$s ' , $ jsbPath ) ) ; if ( ! is_file ( $ jsbPath ) || ! is_readable ( $ jsbPath ) ) { $ this -> _msg ( $ message , 'failed' ) ; $ this -> _msg ( sprintf ( 'No manifest file found in %1$s' , $ jsbPath ) ) ; continue ; } try { $ jsbParser = new MW_Jsb2_Default ( $ jsbPath ) ; $ jsbParser -> deploy ( 'js' ) ; $ this -> _msg ( $ message , 'done' ) ; } catch ( Exception $ e ) { $ this -> _msg ( $ message , 'failed' ) ; $ this -> _msg ( sprintf ( 'Error: %1$s' , $ e -> getMessage ( ) ) ) ; } } } } | Generates JS package files given in the manifests including extensions . |
33,117 | public function getVendors ( DateTime $ lastUpdate = null ) { $ this -> dispatcher -> dispatch ( 'before.vendor.get' ) ; $ return = $ this -> mirakl -> getVendors ( $ lastUpdate ) ; $ return = array_filter ( $ return , array ( $ this , 'filterVendors' ) ) ; $ this -> dispatcher -> dispatch ( 'after.vendor.get' ) ; return $ return ; } | Fetch the vendors from Mirakl . |
33,118 | public function hasWallet ( $ email ) { $ event = new CheckAvailability ( $ email ) ; $ this -> dispatcher -> dispatch ( 'before.availability.check' , $ event ) ; $ result = $ this -> hipay -> isAvailable ( $ email , $ event -> getEntity ( ) ) ; $ this -> dispatcher -> dispatch ( 'after.availability.check' , $ event ) ; return ! $ result ; } | Check if the vendor already has a wallet . |
33,119 | protected function createWallet ( array $ shopData ) { $ userAccount = new UserAccount ( $ shopData ) ; $ event = new CreateWallet ( $ userAccount ) ; $ this -> dispatcher -> dispatch ( 'before.wallet.create' , $ event ) ; $ walletInfo = $ this -> hipay -> createFullUseraccountV2 ( $ event -> getUserAccount ( ) ) ; $ this -> dispatcher -> dispatch ( 'after.wallet.create' , $ event ) ; return $ walletInfo ; } | Create a HiPay wallet . |
33,120 | protected function getWalletUserInfo ( array $ shopData , VendorInterface $ vendor = null ) { $ userAccount = new UserAccount ( $ shopData ) ; $ event = new CreateWallet ( $ userAccount ) ; $ walletInfo = $ this -> hipay -> getWalletInfo ( $ event -> getUserAccount ( ) , $ vendor ) ; return $ walletInfo ; } | Get a HiPay wallet . |
33,121 | protected function createVendor ( $ email , $ walletId , $ walletSpaceId , $ identified , $ miraklId , $ vatNumber , $ callbackSalt , $ miraklData ) { $ this -> logger -> debug ( "The wallet number is $walletId" , array ( 'miraklId' => $ miraklId , "action" => "Wallet creation" ) ) ; $ vendor = $ this -> vendorManager -> create ( $ email , $ miraklId , $ walletId , $ walletSpaceId , $ identified , $ vatNumber , $ callbackSalt , $ miraklData ) ; $ vendor -> setEmail ( $ email ) ; $ vendor -> setHiPayId ( $ walletId ) ; $ vendor -> setMiraklId ( $ miraklId ) ; $ vendor -> setHiPayUserSpaceId ( $ walletSpaceId ) ; $ vendor -> setHiPayIdentified ( $ identified ) ; $ vendor -> setVatNumber ( $ vatNumber ) ; $ vendor -> setCallbackSalt ( $ callbackSalt ) ; $ vendor -> setEnabled ( true ) ; $ vendor -> setCountry ( $ miraklData [ "contact_informations" ] [ "country" ] ) ; $ vendor -> setPaymentBlocked ( $ miraklData [ "payment_details" ] [ "payment_blocked" ] ) ; $ this -> logger -> info ( '[OK] Wallet recorded' , array ( 'miraklId' => $ miraklId , "action" => "Wallet creation" ) ) ; return $ vendor ; } | To record a wallet in the database in the case there was an error . |
33,122 | protected function getImmutableValues ( VendorInterface $ vendor ) { $ previousValues [ 'email' ] = $ vendor -> getEmail ( ) ; $ previousValues [ 'hipayId' ] = $ vendor -> getHiPayId ( ) ; $ previousValues [ 'miraklId' ] = $ vendor -> getMiraklId ( ) ; return $ previousValues ; } | Return the values who should t change after the registration of the hipay wallet . |
33,123 | protected function indexMiraklData ( $ miraklData ) { $ indexedMiraklData = array ( ) ; foreach ( $ miraklData as $ data ) { $ indexedMiraklData [ $ data [ 'shop_id' ] ] = $ data ; } return $ indexedMiraklData ; } | Index mirakl data fetched with a call to S20 resource from their API |
33,124 | protected function isBankInfosSynchronised ( VendorInterface $ vendor , BankInfo $ miraklBankInfo ) { $ hipayBankInfo = $ this -> getBankInfo ( $ vendor ) ; $ event = new CheckBankInfos ( $ miraklBankInfo , $ hipayBankInfo ) ; $ ibanCheck = ( $ hipayBankInfo -> getIban ( ) == $ miraklBankInfo -> getIban ( ) ) ; $ this -> dispatcher -> dispatch ( 'check.bankInfos.synchronicity' , $ event ) ; return $ ibanCheck && $ event -> isSynchrony ( ) ; } | Check that the bank information is the same in the two services . |
33,125 | public function isBankInfoUsable ( VendorInterface $ vendor , $ miraklBankInfo , $ checkBankStatus = false ) { if ( $ checkBankStatus ) { $ bankInfoStatus = $ this -> getBankInfoStatus ( $ vendor ) ; if ( trim ( $ bankInfoStatus ) == BankInfoStatus :: VALIDATED ) { return false ; } } if ( is_array ( $ miraklBankInfo ) ) { $ bankInfo = new BankInfo ( ) ; $ miraklBankInfo = $ bankInfo -> setMiraklData ( $ miraklBankInfo ) ; } return $ this -> isBankInfosSynchronised ( $ vendor , $ miraklBankInfo ) ; } | Return true if banking information is the same at Mirakl and HiPay The soap call will fail if the bank info status at HiPay is not validated |
33,126 | public function addBankInformation ( $ vendor , $ miraklBankInfo , $ checkBankStatus = false ) { if ( $ checkBankStatus ) { $ bankInfoStatus = $ this -> getBankInfoStatus ( $ vendor ) ; if ( trim ( $ bankInfoStatus ) == BankInfoStatus :: BLANK ) { return false ; } } if ( is_array ( $ miraklBankInfo ) ) { $ bankInfo = new BankInfo ( ) ; $ miraklBankInfo = $ bankInfo -> setMiraklData ( $ miraklBankInfo ) ; } return $ this -> sendBankAccount ( $ vendor , $ miraklBankInfo ) ; } | Add the bank information to a wallet The call will fail if the bank information status is not blank |
33,127 | public function recordVendor ( $ email , $ miraklId ) { $ miraklData = current ( $ this -> mirakl -> getVendors ( null , false , array ( $ miraklId ) ) ) ; $ hipayInfo = $ this -> hipay -> getWalletInfo ( $ miraklData [ 'contact_informations' ] [ 'email' ] ) ; $ hipayInfo -> setVatNumber ( $ miraklData [ 'pro_details' ] [ 'VAT_number' ] ) ; $ vendor = $ this -> createVendor ( $ email , $ hipayInfo -> getUserAccountld ( ) , $ hipayInfo -> getUserSpaceld ( ) , $ hipayInfo -> getIdentified ( ) , $ miraklId , $ miraklData ) ; $ this -> vendorManager -> save ( $ vendor ) ; } | Save a vendor in case there was an error . |
33,128 | public function getWallets ( $ merchantGroupId , DateTime $ pastDate = null ) { if ( ! $ pastDate ) { $ pastDate = new DateTime ( '1970-01-01' ) ; } return $ this -> hipay -> getMerchantsGroupAccounts ( $ merchantGroupId , $ pastDate ) ; } | Returns the wallet registered at HiPay |
33,129 | private function getFileBack ( $ fileType , $ allMiraklFiles , $ frontFile , $ shopId , $ tmpFilePath ) { try { $ backType = $ this -> getFileBackType ( $ fileType ) ; if ( ! $ backType ) { return null ; } $ files = array_filter ( $ allMiraklFiles , function ( $ aFile ) use ( $ backType ) { return $ aFile [ 'type' ] == $ backType ; } ) ; if ( empty ( $ files ) ) { return null ; } $ file = end ( $ files ) ; $ this -> checkExtensionFile ( $ file [ 'file_name' ] , $ file , $ shopId ) ; $ tmpFile = $ tmpFilePath . '/' . time ( ) . preg_replace ( "/[^A-Za-z0-9\.]/" , '' , $ file [ 'file_name' ] ) ; file_put_contents ( $ tmpFile , $ this -> mirakl -> downloadDocuments ( array ( $ file [ 'id' ] ) ) ) ; return array ( 'filePath' => $ tmpFile , 'fileObject' => $ file ) ; } catch ( Exception $ e ) { throw new Exception ( 'Document ' . $ frontFile [ 'id' ] . ' (type: ' . $ fileType . ') for Mirakl for shop ' . $ shopId . ' will not be uploaded because file of type ' . $ backType . ' not uploaded in Mirakl or uploaded with wrong extension' ) ; } } | get file corresponding to the back of a file type |
33,130 | private function getFileBackType ( $ type ) { switch ( $ type ) { case Mirakl :: DOCUMENT_LEGAL_IDENTITY_OF_REPRESENTATIVE : return Mirakl :: DOCUMENT_LEGAL_IDENTITY_OF_REP_REAR ; case Mirakl :: DOCUMENT_SOLE_MAN_BUS_IDENTITY : return Mirakl :: DOCUMENT_SOLE_MAN_BUS_IDENTITY_REAR ; default : return false ; } } | return back of a document type |
33,131 | private function filterVendors ( $ element ) { $ additionnalField = array ( 'code' => 'hipay-process' , 'type' => 'BOOLEAN' , 'value' => 'true' ) ; if ( isset ( $ element [ 'shop_additional_fields' ] ) && in_array ( $ additionnalField , $ element [ 'shop_additional_fields' ] ) ) { return true ; } else { $ this -> logger -> info ( 'Shop ' . $ element [ 'shop_id' ] . ' will not be processed beacause additionnal field hipay-process set to false' , array ( 'miraklId' => $ element [ 'shop_id' ] , "action" => "Wallet creation" ) ) ; $ this -> disableVendor ( $ element ) ; } } | Filter function for Vendors array from Mirakl |
33,132 | private function disableVendor ( $ vendorData ) { $ vendor = $ this -> vendorManager -> findByMiraklId ( $ vendorData [ 'shop_id' ] ) ; $ logVendor = $ this -> logVendorManager -> findByMiraklId ( $ vendorData [ 'shop_id' ] ) ; if ( $ vendor ) { $ this -> logger -> info ( 'Shop ' . $ vendorData [ 'shop_id' ] . ' found in database' , array ( 'miraklId' => $ vendorData [ 'shop_id' ] , "action" => "Wallet creation" ) ) ; if ( $ vendor -> getEnabled ( ) || $ vendor -> getEnabled ( ) === null ) { $ vendor -> setEnabled ( false ) ; $ this -> vendorManager -> save ( $ vendor ) ; if ( $ logVendor !== null ) { $ logVendor -> setEnabled ( false ) ; $ this -> logVendorManager -> save ( $ logVendor ) ; } $ this -> logger -> info ( 'Shop ' . $ vendorData [ 'shop_id' ] . ' disabled' , array ( 'miraklId' => $ vendorData [ 'shop_id' ] , "action" => "Wallet creation" ) ) ; } else { $ this -> logger -> info ( 'Shop ' . $ vendorData [ 'shop_id' ] . ' already disabled' , array ( 'miraklId' => $ vendorData [ 'shop_id' ] , "action" => "Wallet creation" ) ) ; } } } | If Vendor exist and HIPAY_PROCESS = NO disable it |
33,133 | function uniqueCode ( ) { $ i = 1 ; $ codeFormat = 'code-%d' ; do { $ code = sprintf ( $ codeFormat , $ i ) ; $ note = $ this -> findByCode ( $ code ) ; if ( ! $ note ) { return $ code ; } $ i ++ ; } while ( true ) ; } | Generates a unique code along these formats code - 1 code - 2 to be used for inserting a new note |
33,134 | public function actionIndex ( $ queueIds = '0' , $ currentTime = null , $ forceNoParallel = 0 ) { $ currentTime = $ currentTime ? intval ( $ currentTime ) : time ( ) ; $ this -> forceNoParallel = intval ( $ forceNoParallel ) === 1 ; if ( $ this -> getMutex ( ) -> acquire ( 'DeferredQueueSelect' ) === false ) { return 0 ; } $ this -> stdout ( "Getting queue\n" , Console :: FG_GREEN ) ; if ( intval ( $ queueIds ) === 0 ) { $ queueIds = null ; } else { $ queueIds = explode ( ',' , $ queueIds ) ; array_walk ( $ queueIds , 'intval' ) ; } $ queue = DeferredQueue :: getNextTasks ( $ currentTime , $ queueIds ) ; if ( count ( $ queue ) === 0 ) { $ this -> getMutex ( ) -> release ( 'DeferredQueueSelect' ) ; $ this -> stdout ( "No tasks to run\n" , Console :: FG_GREEN ) ; return 0 ; } $ grouppedQueue = [ ] ; $ ids = [ ] ; foreach ( $ queue as $ item ) { $ ids [ ] = $ item -> id ; $ itemCanBeAdded = true ; if ( isset ( $ grouppedQueue [ $ item -> deferred_group_id ] ) === false ) { if ( $ item -> deferred_group_id > 0 ) { $ itemCanBeAdded = $ this -> getMutex ( ) -> acquire ( 'DeferredQueueGroup:' . $ item -> deferred_group_id ) ; $ grouppedQueue [ $ item -> deferred_group_id ] = [ ] ; } } if ( $ itemCanBeAdded === true ) { $ grouppedQueue [ $ item -> deferred_group_id ] [ ] = $ item ; } } $ queue = null ; Yii :: $ app -> db -> createCommand ( ) -> update ( DeferredQueue :: tableName ( ) , [ 'status' => DeferredQueue :: STATUS_RUNNING ] , [ 'id' => $ ids ] ) -> execute ( ) ; $ this -> getMutex ( ) -> release ( 'DeferredQueueSelect' ) ; if ( $ this -> canRunInParallel ( ) && $ this -> forceNoParallel === false ) { $ fork = new Fork ; foreach ( $ grouppedQueue as $ groupId => $ items ) { $ fork -> call ( function ( ) use ( $ groupId , $ items ) { $ this -> processGroup ( $ groupId , $ items ) ; } , [ $ groupId , $ items ] ) ; } $ fork -> wait ( ) ; } else { foreach ( $ grouppedQueue as $ groupId => $ items ) { $ this -> processGroup ( $ groupId , $ items ) ; } } $ this -> stdout ( "All tasks finished\n" , Console :: FG_GREEN ) ; return 0 ; } | Runs all deferred commands |
33,135 | private function grouppedNotification ( & $ group , & $ queue ) { if ( is_object ( $ group ) === false ) { return ; } if ( intval ( $ group -> group_notifications ) === 0 ) { return ; } foreach ( $ queue as & $ item ) { $ item -> complete ( ) ; } $ this -> trigger ( self :: EVENT_DEFERRED_QUEUE_GROUP_COMPLETE , new DeferredQueueGroupCompleteEvent ( $ queue , $ group ) ) ; } | Sends groupped notification if needed |
33,136 | private function immediateNotification ( & $ group , & $ item ) { $ item -> complete ( ) ; $ immediateNotification = false ; if ( is_object ( $ group ) === true ) { if ( intval ( $ group -> group_notifications ) === 0 ) { $ immediateNotification = true ; } } else { $ immediateNotification = true ; } if ( $ immediateNotification === true ) { $ this -> trigger ( self :: EVENT_DEFERRED_QUEUE_COMPLETE , new DeferredQueueCompleteEvent ( $ item ) ) ; } } | Sends immediate notification if needed |
33,137 | protected function safeDbReconnection ( ) { if ( empty ( Yii :: $ app -> db -> pdo -> getAttribute ( constant ( "PDO::ATTR_PERSISTENT" ) ) ) ) { Yii :: $ app -> db -> close ( ) ; Yii :: $ app -> db -> open ( ) ; } } | Reconnection to base if isn t used by persistent connection |
33,138 | public function verifyLastHash ( Blakechain $ chain , string $ lastHash ) : bool { $ nodes = $ chain -> getNodes ( ) ; $ count = \ count ( $ nodes ) ; $ prevHash = '' ; for ( $ i = 0 ; $ i < $ count ; ++ $ i ) { $ curr = $ nodes [ $ i ] ; $ actualHash = SodiumCompat :: crypto_generichash ( $ curr -> getData ( ) , $ prevHash ) ; if ( ! \ hash_equals ( $ actualHash , $ curr -> getHash ( true ) ) ) { $ this -> lastErrorData = [ 'index' => $ i , 'item' => [ 'prev' => $ curr -> getPrevHash ( ) , 'data' => $ curr -> getData ( ) , 'hash' => $ curr -> getHash ( ) ] , 'failure' => static :: HASH_DOES_NOT_MATCH ] ; return false ; } $ prevHash = $ curr -> getHash ( true ) ; } $ decoded = Base64UrlSafe :: decode ( $ lastHash ) ; if ( ! \ hash_equals ( $ prevHash , $ decoded ) ) { $ this -> lastErrorData = [ 'item' => null , 'expected' => $ lastHash , 'calculated' => Base64UrlSafe :: encode ( $ prevHash ) , 'failure' => static :: FINAL_HASH_MISMATCH ] ; return false ; } return true ; } | Walk down the entire chain recalculate the final hash then verify that it matches what we expect . |
33,139 | public function verifySequenceHashes ( Blakechain $ chain , int $ offset = 0 , int $ limit = PHP_INT_MAX ) : bool { $ subchain = $ chain -> getPartialChain ( $ offset , $ limit ) ; $ prev = '' ; foreach ( $ subchain as $ idx => $ item ) { $ prevHash = Base64UrlSafe :: decode ( $ item [ 'prev' ] ) ; $ storedHash = Base64UrlSafe :: decode ( $ item [ 'hash' ] ) ; $ actualHash = SodiumCompat :: crypto_generichash ( $ item [ 'data' ] , $ prevHash ) ; if ( ! \ hash_equals ( $ actualHash , $ storedHash ) ) { $ this -> lastErrorData = [ 'index' => $ idx , 'item' => $ item , 'failure' => static :: HASH_DOES_NOT_MATCH ] ; return false ; } if ( ! empty ( $ prev ) ) { if ( ! \ hash_equals ( $ prev , $ item [ 'prev' ] ) ) { $ this -> lastErrorData = [ 'index' => $ idx , 'prev' => $ prev , 'item' => $ item , 'failure' => static :: PREV_DOES_NOT_MATCH ] ; return false ; } } $ prev = $ item [ 'hash' ] ; } return true ; } | This is a self - consistency check for a subset of a Blakechain . |
33,140 | public function parse ( string $ source ) : array { $ this -> tokens = [ ] ; if ( $ this -> isolatePHP ) { $ source = $ this -> isolator -> isolatePHP ( $ source ) ; } $ quotas = '' ; $ buffer = '' ; $ length = strlen ( $ source ) ; $ position = self :: POSITION_PLAIN_TEXT ; for ( $ pointer = 0 ; $ pointer < $ length ; $ pointer ++ ) { $ char = $ source [ $ pointer ] ; switch ( $ char ) { case '<' : if ( $ position == self :: POSITION_IN_QUOTAS ) { $ buffer .= $ char ; break ; } if ( $ position == self :: POSITION_IN_TAG ) { $ buffer = '<' . $ buffer ; } $ this -> handleToken ( self :: PLAIN_TEXT , $ buffer ) ; $ position = self :: POSITION_IN_TAG ; $ buffer = '' ; break ; case '>' : if ( $ position != self :: POSITION_IN_TAG ) { $ buffer .= $ char ; break ; } $ this -> handleToken ( null , $ buffer ) ; $ position = self :: POSITION_PLAIN_TEXT ; $ buffer = '' ; break ; case '"' : case "'" : if ( $ position == self :: POSITION_IN_TAG ) { $ position = self :: POSITION_IN_QUOTAS ; $ quotas = $ char ; } elseif ( $ position == self :: POSITION_IN_QUOTAS && $ char == $ quotas ) { $ position = self :: POSITION_IN_TAG ; $ quotas = '' ; } default : if ( $ position == self :: POSITION_IN_TAG ) { if ( ! preg_match ( '/[a-z0-9 \._\-="\':\/\r\n\t]/i' , $ char ) ) { $ buffer = '<' . $ buffer ; $ position = self :: POSITION_PLAIN_TEXT ; } } $ buffer .= $ char ; } } $ this -> handleToken ( self :: PLAIN_TEXT , $ buffer ) ; return $ this -> tokens ; } | Parse HTML content and return it s tokens . |
33,141 | public function compile ( ) : string { $ result = '' ; foreach ( $ this -> tokens as $ token ) { $ result .= $ this -> compileToken ( $ token ) ; } return $ result ; } | Compile all parsed tokens back into html form . |
33,142 | public function compileToken ( array $ token ) : string { if ( in_array ( $ token [ self :: TOKEN_TYPE ] , [ self :: PLAIN_TEXT , self :: TAG_CLOSE ] ) ) { return $ token [ HtmlTokenizer :: TOKEN_CONTENT ] ; } $ result = $ token [ HtmlTokenizer :: TOKEN_NAME ] ; $ attributes = [ ] ; foreach ( $ token [ self :: TOKEN_ATTRIBUTES ] as $ attribute => $ value ) { if ( $ value === null ) { $ attributes [ ] = $ attribute ; continue ; } $ attributes [ ] = $ attribute . '="' . $ value . '"' ; } if ( ! empty ( $ attributes ) ) { $ result .= ' ' . join ( ' ' , $ attributes ) ; } if ( $ token [ HtmlTokenizer :: TOKEN_TYPE ] == HtmlTokenizer :: TAG_SHORT ) { $ result .= '/' ; } return '<' . $ result . '>' ; } | Compile parsed token . |
33,143 | protected function parseToken ( string $ content ) : array { $ token = [ self :: TOKEN_NAME => '' , self :: TOKEN_TYPE => self :: TAG_OPEN , self :: TOKEN_CONTENT => '<' . ( $ content = $ this -> repairPHP ( $ content ) ) . '>' , self :: TOKEN_ATTRIBUTES => [ ] ] ; if ( ! preg_match ( '/^\/?[a-z0-9_:\/][a-z 0-9\._\-:\/]*/i' , $ content ) ) { $ token [ self :: TOKEN_TYPE ] = self :: PLAIN_TEXT ; unset ( $ token [ self :: TOKEN_NAME ] , $ token [ self :: TOKEN_NAME ] ) ; return $ token ; } $ isolator = new Isolator ( '-argument-' , '-block-' ) ; $ content = $ isolator -> isolatePHP ( $ content ) ; $ attribute = '/(?P<name>[a-z0-9_\-\.\:]+)[ \n\t\r]*(?:(?P<equal>=)[ \n\t\r]*' . '(?P<value>[a-z0-9\-]+|\'[^\']+\'|\"[^\"]+\"|\"\"))?/si' ; preg_match_all ( $ attribute , $ content , $ attributes ) ; foreach ( $ attributes [ 'value' ] as $ index => $ value ) { if ( $ value && ( $ value { 0 } == "'" || $ value { 0 } == '"' ) ) { $ value = trim ( $ value , $ value { 0 } ) ; } $ name = $ this -> repairPHP ( $ isolator -> repairPHP ( $ attributes [ 'name' ] [ $ index ] ) ) ; $ token [ self :: TOKEN_ATTRIBUTES ] [ $ name ] = $ this -> repairPHP ( $ isolator -> repairPHP ( $ value ) ) ; if ( empty ( $ attributes [ 'equal' ] [ $ index ] ) ) { $ token [ self :: TOKEN_ATTRIBUTES ] [ $ name ] = null ; } } $ name = $ isolator -> repairPHP ( current ( explode ( ' ' , $ content ) ) ) ; if ( $ name { 0 } == '/' ) { $ token [ self :: TOKEN_TYPE ] = self :: TAG_CLOSE ; unset ( $ token [ self :: TOKEN_ATTRIBUTES ] ) ; } if ( $ content { strlen ( $ content ) - 1 } == '/' ) { $ token [ self :: TOKEN_TYPE ] = self :: TAG_SHORT ; } $ token [ self :: TOKEN_NAME ] = $ name = trim ( $ name , '/' ) ; unset ( $ token [ self :: TOKEN_ATTRIBUTES ] [ $ name ] ) ; $ token [ self :: TOKEN_NAME ] = trim ( $ token [ self :: TOKEN_NAME ] ) ; if ( $ token [ self :: TOKEN_TYPE ] == self :: TAG_OPEN && in_array ( $ token [ self :: TOKEN_NAME ] , $ this -> voidTags ) ) { $ token [ self :: TOKEN_TYPE ] = self :: TAG_VOID ; } return $ token ; } | Parses tag body for arguments name etc . |
33,144 | protected function handleToken ( $ tokenType , string $ content ) { if ( $ tokenType == self :: PLAIN_TEXT ) { if ( empty ( $ content ) ) { return ; } $ token = [ self :: TOKEN_TYPE => self :: PLAIN_TEXT , self :: TOKEN_CONTENT => $ this -> repairPHP ( $ content ) ] ; } else { $ token = $ this -> parseToken ( $ content ) ; } $ this -> tokens [ ] = $ token ; } | Handles single token and passes it to a callback function if specified . |
33,145 | protected function repairPHP ( string $ source ) : string { if ( ! $ this -> isolatePHP ) { return $ source ; } return $ this -> isolator -> repairPHP ( $ source ) ; } | Will restore all existing PHP blocks to their original content . |
33,146 | public function saveItem ( MShop_Common_Item_Interface $ item , $ fetch = true ) { $ iface = 'MShop_Locale_Item_Site_Interface' ; if ( ! ( $ item instanceof $ iface ) ) { throw new MShop_Locale_Exception ( sprintf ( 'Object is not of required type "%1$s"' , $ iface ) ) ; } if ( $ item -> getId ( ) === null ) { throw new MShop_Locale_Exception ( sprintf ( 'Newly created site can not be saved using method "saveItem()". Try using method "insertItem()" instead.' ) ) ; } if ( ! $ item -> isModified ( ) ) { return ; } $ context = $ this -> _getContext ( ) ; $ dbm = $ context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ id = $ item -> getId ( ) ; $ path = 'mshop/locale/manager/site/default/item/update' ; $ stmt = $ this -> _getCachedStatement ( $ conn , $ path ) ; $ stmt -> bind ( 1 , $ item -> getCode ( ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ stmt -> bind ( 2 , $ item -> getLabel ( ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ stmt -> bind ( 3 , json_encode ( $ item -> getConfig ( ) ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ stmt -> bind ( 4 , $ item -> getStatus ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 5 , $ context -> getEditor ( ) ) ; $ stmt -> bind ( 6 , date ( 'Y-m-d H:i:s' , time ( ) ) ) ; $ stmt -> bind ( 7 , $ id , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> execute ( ) -> finish ( ) ; $ item -> setId ( $ id ) ; $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } } | Adds a new site to the storage or updates an existing one . |
33,147 | public function createSearch ( $ default = false ) { if ( $ default === true ) { $ search = parent :: _createSearch ( 'locale.site' ) ; } else { $ search = parent :: createSearch ( ) ; } $ expr = array ( $ search -> compare ( '==' , 'locale.site.level' , 0 ) , $ search -> getConditions ( ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; return $ search ; } | Creates a search object and sets base criteria . |
33,148 | public function getPath ( $ id , array $ ref = array ( ) ) { $ item = $ this -> getTree ( $ id , $ ref , MW_Tree_Manager_Abstract :: LEVEL_ONE ) ; return array ( $ item -> getId ( ) => $ item ) ; } | Returns a list of item IDs that are in the path of given item ID . |
33,149 | protected function _getStepActive ( MW_View_Interface $ view , array $ steps , $ default ) { $ current = $ view -> param ( 'c-step' , $ default ) ; $ cpos = $ cpos = array_search ( $ current , $ steps ) ; if ( ! isset ( $ view -> standardStepActive ) || ( ( $ apos = array_search ( $ view -> standardStepActive , $ steps ) ) !== false && $ cpos !== false && $ cpos < $ apos ) ) { $ view -> standardStepActive = $ current ; } return $ view -> standardStepActive ; } | Returns the current active step . |
33,150 | public static function checkDbConnection ( ) { try { Yii :: $ app -> db -> isActive ; return TRUE ; } catch ( Exception $ e ) { print_r ( $ e -> getMessage ( ) ) ; } return FALSE ; } | Checks if database connections works |
33,151 | public function actionAdmin ( ) { $ model = new User ( ) ; $ profile = new Profile ( ) ; $ model -> scenario = 'register' ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( Yii :: $ app -> request -> isAjax ) { Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; return ActiveForm :: validate ( $ model ) ; } if ( $ model -> register ( TRUE ) ) return $ this -> redirect ( Yii :: $ app -> urlManager -> createUrl ( '//installer/config/finished' ) ) ; } return $ this -> render ( 'admin' , [ 'model' => $ model , 'profile' => $ profile ] ) ; } | Setup Administrative User |
33,152 | public function htmlDecode ( $ flags = ENT_COMPAT ) { return $ this -> newSelf ( UTF8 :: html_entity_decode ( $ this -> scalarString , $ flags , $ this -> encoding ) ) ; } | Convert all HTML entities to their applicable characters . |
33,153 | public function htmlEncode ( $ flags = null , $ doubleEncode = true ) { if ( $ flags === null ) $ flags = ENT_QUOTES | ENT_SUBSTITUTE ; return $ this -> newSelf ( UTF8 :: htmlentities ( $ this -> scalarString , $ flags , $ this -> encoding , $ doubleEncode ) ) ; } | Convert all applicable characters to HTML entities . |
33,154 | public function htmlXssClean ( ) { static $ antiXss = null ; if ( $ antiXss === null ) { if ( class_exists ( '\\voku\\helper\\AntiXSS' ) ) { $ antiXss = new \ voku \ helper \ AntiXSS ( ) ; } else { throw new \ RuntimeException ( "This method requires \voku\helper\AntiXSS. " . "Install with: composer require voku/anti-xss" ) ; } } return $ this -> newSelf ( $ antiXss -> xss_clean ( $ this -> scalarString ) ) ; } | Sanitizes data so that Cross Site Scripting Hacks can be prevented . |
33,155 | public function htmlStripTags ( $ allowableTags = null ) { return $ this -> newSelf ( UTF8 :: strip_tags ( $ this -> scalarString , $ allowableTags ) ) ; } | Strip HTML and PHP tags from a string . |
33,156 | public function isAvailable ( MShop_Order_Item_Base_Interface $ basket ) { $ addresses = $ basket -> getAddresses ( ) ; $ paymentType = MShop_Order_Item_Base_Address_Abstract :: TYPE_PAYMENT ; $ deliveryType = MShop_Order_Item_Base_Address_Abstract :: TYPE_DELIVERY ; if ( isset ( $ addresses [ $ deliveryType ] ) ) { $ code = strtoupper ( $ addresses [ $ deliveryType ] -> getCountryId ( ) ) ; if ( $ this -> _checkCountryCode ( $ code , 'country.delivery-include' ) === false || $ this -> _checkCountryCode ( $ code , 'country.delivery-exclude' ) === true ) { return false ; } } else if ( isset ( $ addresses [ $ paymentType ] ) ) { $ code = strtoupper ( $ addresses [ $ paymentType ] -> getCountryId ( ) ) ; if ( $ this -> _checkCountryCode ( $ code , 'country.delivery-include' ) === false || $ this -> _checkCountryCode ( $ code , 'country.delivery-exclude' ) === true ) { return false ; } } if ( isset ( $ addresses [ $ paymentType ] ) ) { $ code = strtoupper ( $ addresses [ $ paymentType ] -> getCountryId ( ) ) ; if ( $ this -> _checkCountryCode ( $ code , 'country.billing-include' ) === false || $ this -> _checkCountryCode ( $ code , 'country.billing-exclude' ) === true ) { return false ; } } return $ this -> _getProvider ( ) -> isAvailable ( $ basket ) ; } | Checks if the country code is allowed for the service provider . |
33,157 | protected function _checkCountryCode ( $ code , $ key ) { if ( ( $ str = $ this -> _getConfigValue ( array ( $ key ) ) ) === null ) { return null ; } return in_array ( $ code , explode ( ',' , str_replace ( ' ' , '' , strtoupper ( $ str ) ) ) ) ; } | Checks if the country code is in the list of codes specified by the given key |
33,158 | public function processRecord ( NodeTemplate $ nodeTemplate , array $ data ) { $ this -> unsetAllNodeTemplateProperties ( $ nodeTemplate ) ; $ externalIdentifier = $ this -> getExternalIdentifierFromRecordData ( $ data ) ; if ( ! isset ( $ data [ 'uriPathSegment' ] ) ) { $ data [ 'uriPathSegment' ] = Slug :: create ( $ this -> getLabelFromRecordData ( $ data ) ) -> getValue ( ) ; } $ this -> nodeTemplate -> setNodeType ( $ this -> nodeType ) ; $ this -> nodeTemplate -> setName ( $ this -> renderNodeName ( $ externalIdentifier ) ) ; if ( ! isset ( $ data [ 'mode' ] ) ) { throw new \ Exception ( sprintf ( 'Could not determine command mode from data record with external identifier %s. Please make sure that "mode" exists in that record.' , $ externalIdentifier ) , 1462985246103 ) ; } $ commandMethodName = $ data [ 'mode' ] . 'Command' ; if ( ! method_exists ( $ this , $ commandMethodName ) ) { throw new \ Exception ( sprintf ( 'Could not find a command method "%s" in %s for processing record with external identifier %s.' , $ commandMethodName , get_class ( $ this ) , $ externalIdentifier ) , 1462985425892 ) ; } $ this -> $ commandMethodName ( $ externalIdentifier , $ data ) ; } | Processes a single command |
33,159 | public function getCompiler ( ContextInterface $ context ) : CompilerInterface { if ( empty ( $ this -> compiler ) ) { throw new EngineException ( "No associated compiler found." ) ; } $ this -> compiler -> getLoader ( ) -> setContext ( $ context ) ; return $ this -> compiler ; } | Return compiler locked into specific context . |
33,160 | protected function className ( ViewSource $ source , ContextInterface $ context ) { return sprintf ( "StemplerView_%s" , md5 ( $ source -> getNamespace ( ) . '.' . $ source -> getName ( ) . '.' . $ context -> getID ( ) ) ) ; } | Get unique template name . |
33,161 | static function formatClassName ( $ name ) { $ n = explode ( '\\' , $ name ) ; $ c = array_pop ( $ n ) ; return sprintf ( "<span class='__type hint--rounded hint--top' data-hint='%s'>%s</span>" , $ name , $ c ) ; } | Returns a formatted HTML span showing the given class name without the namespace part but it also including the namespace via a tooltip . |
33,162 | public static function grid ( $ value , $ title = '' , $ maxDepth = 1 , $ excludeProps = [ ] , $ excludeEmpty = false , $ depth = 0 ) { if ( is_null ( $ value ) || is_scalar ( $ value ) ) return self :: toString ( $ value ) ; if ( $ depth >= $ maxDepth ) return "<i>(...)</i>" ; if ( is_object ( $ value ) ) { if ( method_exists ( $ value , '__debugInfo' ) ) $ value = $ value -> __debugInfo ( ) ; else $ value = get_object_vars ( $ value ) ; } if ( $ title ) $ title = "<p><b>$title</b></p>" ; $ value = array_diff_key ( $ value , array_fill_keys ( $ excludeProps , false ) ) ; if ( $ excludeEmpty ) $ value = array_prune_empty ( $ value ) ; return $ value ? "$title<table class=__console-table><colgroup><col width=160><col width=100%></colgroup>" . implode ( '' , map ( $ value , function ( $ v , $ k ) use ( $ depth , $ maxDepth , $ excludeProps , $ excludeEmpty ) { $ v = self :: grid ( $ v , '' , $ maxDepth , $ excludeProps , $ excludeEmpty , $ depth + 1 ) ; return "<tr><th>$k<td>$v" ; } ) ) . "</table>" : '<i>[]</i>' ; } | Generates a table with a header column and a value column from the given array . |
33,163 | public static function rawGrid ( array $ value , $ title = '' ) { if ( $ title ) $ title = "<caption>$title</caption>" ; return "<table class=__console-table>$title<colgroup><col width=160><col width=100%></colgroup>" . implode ( '' , map ( $ value , function ( $ v , $ k ) { return "<tr><th>$k<td>$v" ; } ) ) . "</table>" ; } | Generates a table with a header column and a raw HTML text column from the given array . |
33,164 | public static function logException ( LoggerInterface $ logger , Exception $ exception ) { $ logger -> error ( sprintf ( "%s, at %s(%s)" , $ exception -> getMessage ( ) , ErrorConsole :: shortFileName ( $ exception -> getFile ( ) ) , $ exception -> getLine ( ) ) ) ; } | Shortcut to log a formatted exception on the provided logger . |
33,165 | public static function toString ( $ v , $ enhanced = true ) { if ( isset ( $ v ) ) { if ( $ v instanceof \ Closure ) return '<i>(native code)</i>' ; elseif ( is_bool ( $ v ) ) return $ v ? '<span class=__type>true</span>' : '<span class=__type>false</span>' ; elseif ( is_string ( $ v ) ) { $ l = strlen ( self :: RAW_TEXT ) ; return substr ( $ v , 0 , $ l ) == self :: RAW_TEXT ? substr ( $ v , $ l ) : sprintf ( "<i>'</i>%s<i>'</i>" , htmlspecialchars ( $ v ) ) ; } elseif ( $ v instanceof \ PowerString ) return sprintf ( "<i>(</i>%s<i>)'</i>%s<i>'</i>" , $ enhanced ? self :: shortenType ( \ PowerString :: class ) : typeOf ( $ v ) , htmlspecialchars ( $ v ) ) ; elseif ( ! is_array ( $ v ) && ! is_object ( $ v ) ) return htmlspecialchars ( str_replace ( ' ' , ' ' , trim ( print_r ( $ v , true ) ) ) ) ; } return $ enhanced ? sprintf ( '<span class=__type>%s</span>' , self :: getType ( $ v ) ) : typeOf ( $ v ) ; } | Returns an HTML - formatted textual representation of a given value . |
33,166 | public function store ( eZContentClass $ class , array $ attributes , array & $ unorderedParameters ) { $ script = eZScheduledScript :: create ( 'syncobjectattributes.php' , eZINI :: instance ( 'ezscriptmonitor.ini' ) -> variable ( 'GeneralSettings' , 'PhpCliCommand' ) . ' extension/ezscriptmonitor/bin/' . eZScheduledScript :: SCRIPT_NAME_STRING . ' -s ' . eZScheduledScript :: SITE_ACCESS_STRING . ' --classid=' . $ class -> attribute ( 'id' ) ) ; $ script -> store ( ) ; $ unorderedParameters [ 'ScheduledScriptID' ] = $ script -> attribute ( 'id' ) ; $ class -> storeVersioned ( $ attributes , eZContentClass :: VERSION_STATUS_MODIFIED ) ; } | Create a scheduled script that will store the modification made to an eZContentClass . |
33,167 | public function aggregate ( MW_Common_Criteria_Interface $ search , $ key ) { $ required = array ( trim ( $ this -> _prefix , '.' ) ) ; return $ this -> _aggregate ( $ search , $ key , $ this -> _configPath . 'aggregate' , $ required ) ; } | Counts the number items that are available for the values of the given key . |
33,168 | public function searchItems ( MW_Common_Criteria_Interface $ search , array $ ref = array ( ) , & $ total = null ) { $ items = $ map = $ typeIds = array ( ) ; $ dbm = $ this -> _getContext ( ) -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ domain = explode ( '.' , $ this -> _prefix ) ; if ( ( $ topdomain = array_shift ( $ domain ) ) === null ) { throw new MShop_Exception ( sprintf ( 'Configuration not available' ) ) ; } $ level = MShop_Locale_Manager_Abstract :: SITE_ALL ; $ cfgPathSearch = $ this -> _configPath . 'search' ; $ cfgPathCount = $ this -> _configPath . 'count' ; $ name = trim ( $ this -> _prefix , '.' ) ; $ required = array ( $ name ) ; $ results = $ this -> _searchItems ( $ conn , $ search , $ cfgPathSearch , $ cfgPathCount , $ required , $ total , $ level ) ; while ( ( $ row = $ results -> fetch ( ) ) !== false ) { if ( ( $ row [ 'config' ] = json_decode ( $ row [ 'config' ] , true ) ) === null ) { $ row [ 'config' ] = array ( ) ; } $ map [ $ row [ 'id' ] ] = $ row ; $ typeIds [ $ row [ 'typeid' ] ] = null ; } $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } if ( ! empty ( $ typeIds ) ) { $ typeManager = $ this -> getSubManager ( 'type' ) ; $ typeSearch = $ typeManager -> createSearch ( ) ; $ typeSearch -> setConditions ( $ typeSearch -> compare ( '==' , $ name . '.type.id' , array_keys ( $ typeIds ) ) ) ; $ typeSearch -> setSlice ( 0 , $ search -> getSliceSize ( ) ) ; $ typeItems = $ typeManager -> searchItems ( $ typeSearch ) ; foreach ( $ map as $ id => $ row ) { if ( isset ( $ typeItems [ $ row [ 'typeid' ] ] ) ) { $ row [ 'type' ] = $ typeItems [ $ row [ 'typeid' ] ] -> getCode ( ) ; } $ items [ $ row [ 'id' ] ] = $ this -> _createItem ( $ row ) ; } } return $ items ; } | Search for all list items based on the given critera . |
33,169 | public function updateDb ( $ ldapObject , $ userObject ) { if ( $ userObject == null ) { $ entity = $ this -> getEntity ( ) ; } else { $ entity = $ userObject ; } if ( isset ( $ ldapObject [ 'uid' ] [ '0' ] ) ) { $ entity -> setUsername ( $ ldapObject [ 'uid' ] [ '0' ] ) ; $ entity -> setDisplayName ( $ ldapObject [ 'cn' ] [ '0' ] ) ; $ entity -> setEmail ( $ ldapObject [ 'mail' ] [ '0' ] ) ; $ entity -> setPassword ( md5 ( 'HandledByLdap' ) ) ; $ entity -> setRoles ( serialize ( $ this -> getLdapRoles ( $ ldapObject ) ) ) ; if ( $ userObject == null ) { $ this -> insert ( $ entity , $ this -> tableName , new HydratorInterface ( ) ) ; } else { $ this -> update ( $ entity , null , $ this -> tableName , new HydratorInterface ( ) ) ; } } return $ entity ; } | Insert or Update DB entry depending if a User Object is set . |
33,170 | protected function _addItem ( MW_Container_Content_Interface $ contentItem , MShop_Attribute_Item_Interface $ item , $ langid ) { $ listTypes = array ( ) ; foreach ( $ item -> getListItems ( 'text' ) as $ listItem ) { $ listTypes [ $ listItem -> getRefId ( ) ] = $ listItem -> getType ( ) ; } foreach ( $ this -> _getTextTypes ( 'attribute' ) as $ textTypeItem ) { $ textItems = $ item -> getRefItems ( 'text' , $ textTypeItem -> getCode ( ) ) ; if ( ! empty ( $ textItems ) ) { foreach ( $ textItems as $ textItem ) { $ listType = ( isset ( $ listTypes [ $ textItem -> getId ( ) ] ) ? $ listTypes [ $ textItem -> getId ( ) ] : '' ) ; $ items = array ( $ langid , $ item -> getType ( ) , $ item -> getCode ( ) , $ listType , $ textTypeItem -> getCode ( ) , '' , '' ) ; if ( ( $ textItem -> getLanguageId ( ) == $ langid || is_null ( $ textItem -> getLanguageId ( ) ) ) && $ textItem -> getTypeId ( ) == $ textTypeItem -> getId ( ) ) { $ items [ 0 ] = $ textItem -> getLanguageId ( ) ; $ items [ 5 ] = $ textItem -> getId ( ) ; $ items [ 6 ] = $ textItem -> getContent ( ) ; } $ contentItem -> add ( $ items ) ; } } else { $ items = array ( $ langid , $ item -> getType ( ) , $ item -> getCode ( ) , 'default' , $ textTypeItem -> getCode ( ) , '' , '' ) ; $ contentItem -> add ( $ items ) ; } } } | Adds all texts belonging to an attribute item . |
33,171 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'locale.site.id' : $ item -> setId ( $ value ) ; break ; case 'locale.site.code' : $ item -> setCode ( $ value ) ; break ; case 'locale.site.label' : $ item -> setLabel ( $ value ) ; break ; case 'locale.site.status' : $ item -> setStatus ( $ value ) ; break ; case 'locale.site.config' : $ item -> setConfig ( ( array ) $ value ) ; break ; } } return $ item ; } | Creates a new locale site item and sets the properties from the given array . |
33,172 | protected function _ensureUrl ( ) { if ( \ Yii :: $ app -> urlManager -> rules ) { foreach ( \ Yii :: $ app -> urlManager -> rules as $ rule ) { if ( $ rule instanceof BackendUrlRule ) { $ request = \ Yii :: $ app -> request ; $ pathInfo = $ request -> getPathInfo ( ) ; $ params = $ request -> getQueryParams ( ) ; if ( ! $ pathInfo ) { return true ; } $ firstPrefix = StringHelper :: substr ( $ pathInfo , 0 , StringHelper :: strlen ( $ rule -> urlPrefix ) ) ; if ( $ firstPrefix == $ rule -> urlPrefix ) { return true ; } } } } throw new NotFoundHttpException ( "This is controller allow only with urlPrefix!" ) ; } | Ensure prefix url |
33,173 | public function initCommand ( $ preset , $ parts = '' ) { $ parts = Arrays :: trimExplode ( ',' , $ parts ) ; $ presetSettings = $ this -> loadPreset ( $ preset ) ; array_walk ( $ presetSettings [ 'parts' ] , function ( $ partSetting , $ partName ) use ( $ preset , $ parts ) { $ this -> outputLine ( ) ; $ this -> outputPartTitle ( $ partSetting , $ partName ) ; if ( $ parts !== array ( ) && ! in_array ( $ partName , $ parts ) ) { $ this -> outputLine ( '<error>~</error> Skipped' ) ; return ; } if ( ! isset ( $ partSetting [ 'importerClassName' ] ) ) { $ this -> outputLine ( '<error>Missing importerClassName in the current preset part (%s/%s), check your settings</error>' , [ $ preset , $ partName ] ) ; return ; } $ identifier = $ partSetting [ 'importerClassName' ] . '@' . $ preset . '/' . $ partName ; foreach ( $ this -> recordMapperRepository -> findByImporterClassName ( $ identifier ) as $ recordMapper ) { $ this -> recordMapperRepository -> remove ( $ recordMapper ) ; } } ) ; $ vault = new Vault ( $ preset ) ; $ vault -> flush ( ) ; } | Reset the mapping between external identifier and local nodes |
33,174 | public function showCommand ( $ preset ) { $ presetSettings = $ this -> loadPreset ( $ preset ) ; array_walk ( $ presetSettings [ 'parts' ] , function ( $ partSetting , $ partName ) use ( $ preset ) { $ this -> outputLine ( ) ; $ this -> outputPartTitle ( $ partSetting , $ partName ) ; } ) ; } | Show the different pars of the preset |
33,175 | public function batchCommand ( $ preset , $ parts = '' , $ batchSize = null , $ identifier = null , $ force = false ) { try { $ this -> importService -> start ( $ identifier , $ force ) ; } catch ( ImportAlreadyExecutedException $ e ) { $ this -> outputLine ( $ e -> getMessage ( ) ) ; $ this -> outputLine ( 'Import skipped. You can force running this import again by specifying --force.' ) ; $ this -> quit ( 1 ) ; } $ this -> startTime = microtime ( true ) ; $ parts = Arrays :: trimExplode ( ',' , $ parts ) ; $ identifier = $ this -> importService -> getCurrentImportIdentifier ( ) ; $ this -> outputLine ( 'Start import with identifier <b>%s</b>' , [ $ identifier ] ) ; $ presetSettings = $ this -> loadPreset ( $ preset ) ; array_walk ( $ presetSettings [ 'parts' ] , function ( $ partSetting , $ partName ) use ( $ preset , $ parts , $ batchSize , $ identifier ) { $ this -> elapsedTime = 0 ; $ this -> batchCounter = 0 ; $ this -> outputLine ( ) ; $ this -> outputPartTitle ( $ partSetting , $ partName ) ; $ partSetting [ '__currentPresetName' ] = $ preset ; $ partSetting [ '__currentPartName' ] = $ partName ; if ( $ batchSize !== null ) { $ partSetting [ 'batchSize' ] = $ batchSize ; } $ partSetting = new PresetPartDefinition ( $ partSetting , $ identifier ) ; if ( $ parts !== array ( ) && ! in_array ( $ partName , $ parts ) ) { $ this -> outputLine ( '<error>~</error> Skipped' ) ; return ; } if ( $ partSetting -> getBatchSize ( ) && $ partSetting -> isDebug ( ) === false ) { while ( ( $ count = $ this -> executeCommand ( $ partSetting ) ) > 0 ) { $ partSetting -> nextBatch ( ) ; } } else { $ this -> executeCommand ( $ partSetting ) ; } } ) ; $ this -> importService -> stop ( ) ; $ import = $ this -> importService -> getLastImport ( ) ; $ this -> outputLine ( ) ; $ this -> outputLine ( '<b>Import finished</b>' ) ; $ this -> outputLine ( sprintf ( '<info>-</info> Started %s' , $ import -> getStartTime ( ) -> format ( DATE_RFC2822 ) ) ) ; $ this -> outputLine ( sprintf ( '<info>-</info> Finished %s' , $ import -> getEndTime ( ) -> format ( DATE_RFC2822 ) ) ) ; $ this -> outputLine ( sprintf ( '<info>-</info> Runtime %d seconds' , $ import -> getElapsedTime ( ) ) ) ; $ this -> outputLine ( ) ; $ this -> outputLine ( 'See log for more details and possible errors.' ) ; } | Run batch import |
33,176 | public function executeBatchCommand ( $ presetName , $ partName , $ dataProviderClassName , $ importerClassName , $ currentImportIdentifier , $ offset = null , $ batchSize = null ) { try { $ vault = new Vault ( $ presetName ) ; $ dataProviderOptions = Arrays :: getValueByPath ( $ this -> settings , [ 'presets' , $ presetName , 'parts' , $ partName , 'dataProviderOptions' ] ) ; $ dataProviderOptions [ '__presetName' ] = $ presetName ; $ dataProviderOptions [ '__partName' ] = $ partName ; $ dataProvider = $ dataProviderClassName :: create ( is_array ( $ dataProviderOptions ) ? $ dataProviderOptions : [ ] , $ offset , $ batchSize ) ; $ importerOptions = Arrays :: getValueByPath ( $ this -> settings , [ 'presets' , $ presetName , 'parts' , $ partName , 'importerOptions' ] ) ; $ importerOptions = is_array ( $ importerOptions ) ? $ importerOptions : [ ] ; $ importerOptions [ '__presetName' ] = $ presetName ; $ importerOptions [ '__partName' ] = $ partName ; $ importer = $ this -> objectManager -> get ( $ importerClassName , $ importerOptions , $ currentImportIdentifier , $ vault ) ; $ importer -> getImportService ( ) -> addEventMessage ( sprintf ( '%s:Batch:Started' , $ importerClassName ) , sprintf ( '%s batch started (%s)' , $ importerClassName , $ dataProviderClassName ) ) ; $ importer -> initialize ( $ dataProvider ) ; $ importer -> process ( ) ; $ importer -> getImportService ( ) -> addEventMessage ( sprintf ( '%s:Batch:Ended' , $ importerClassName ) , sprintf ( '%s batch ended (%s)' , $ importerClassName , $ dataProviderClassName ) ) ; $ this -> output ( $ importer -> getProcessedRecords ( ) ) ; } catch ( \ Exception $ exception ) { $ this -> logger -> logException ( $ exception ) ; $ this -> outputLine ( '<error>%s</error>' , [ $ exception -> getMessage ( ) ] ) ; $ this -> sendAndExit ( 1 ) ; } } | Import a single batch |
33,177 | protected function checkForPartsSettingsOrQuit ( array $ presetSettings , $ preset ) { if ( ! isset ( $ presetSettings [ 'parts' ] ) ) { $ this -> outputLine ( '<b>No "parts" array found for import preset "%s</b>".' , [ $ preset ] ) ; $ this -> outputLine ( ) ; $ this -> outputLine ( 'Please note that the settings structure has changed slightly. Instead of just defining' ) ; $ this -> outputLine ( 'parts as a sub-array of the respective preset, you now need to define them in a sub-array' ) ; $ this -> outputLine ( 'called "parts".' ) ; $ this -> outputLine ( '' ) ; $ this -> outputLine ( 'Ttree:' ) ; $ this -> outputLine ( ' ContentRepositoryImporter:' ) ; $ this -> outputLine ( ' presets:' ) ; $ this -> outputLine ( " '$preset':" ) ; $ this -> outputLine ( " parts:" ) ; if ( is_array ( $ presetSettings ) && count ( $ presetSettings ) > 0 ) { $ firstPart = array_keys ( $ presetSettings ) [ 0 ] ; $ this -> outputLine ( " '$firstPart':" ) ; } $ this -> outputLine ( " ..." ) ; $ this -> quit ( 1 ) ; } } | Checks if the preset settings contain a parts segment and quits if it does not . |
33,178 | public function transform ( MShop_Media_Item_Interface $ item , $ baseurl = null , array $ boxAttributes = array ( ) , array $ itemAttributes = array ( ) ) { $ url = $ item -> getUrl ( ) ; $ enc = $ this -> encoder ( ) ; $ previewUrl = $ item -> getPreview ( ) ; $ tag = $ this -> _createMediaTag ( $ item , $ boxAttributes , $ itemAttributes , $ baseurl ) ; if ( strncmp ( $ url , 'http' , 4 ) !== 0 && strncmp ( $ url , 'data' , 4 ) !== 0 && $ baseurl !== null ) { $ url = $ baseurl . '/' . $ url ; } if ( strncmp ( $ previewUrl , 'http' , 4 ) !== 0 && strncmp ( $ previewUrl , 'data' , 4 ) !== 0 && $ baseurl !== null ) { $ previewUrl = $ baseurl . '/' . $ previewUrl ; } $ mimetype = $ enc -> attr ( $ item -> getMimetype ( ) ) ; $ name = $ enc -> html ( $ item -> getName ( ) ) ; return sprintf ( $ tag , $ enc -> attr ( $ url ) , $ enc -> attr ( $ previewUrl ) , $ name , $ mimetype ) ; } | Returns the media HTML tag . |
33,179 | protected function _createAssociatedMediaString ( array $ mediaItems , $ baseurl = null , $ attributes ) { $ string = '' ; $ enc = $ this -> encoder ( ) ; foreach ( $ mediaItems as $ item ) { $ url = $ item -> getUrl ( ) ; $ previewUrl = $ item -> getPreview ( ) ; $ parts = explode ( '/' , $ item -> getMimetype ( ) ) ; switch ( $ parts [ 0 ] ) { case 'audio' : case 'video' : $ tag = "<source src=\"%1\$s\" title=\"%3\$s\" type=\"%4\$s\" ${attributes} />" ; break ; case 'image' : $ tag = "<img src=\"%2\$s\" title=\"%3\$s\" ${attributes} />" ; break ; default : $ tag = '' ; } if ( strncmp ( $ url , 'http' , 4 ) !== 0 && strncmp ( $ url , 'data' , 4 ) !== 0 && $ baseurl !== null ) { $ url = $ baseurl . '/' . $ url ; } if ( strncmp ( $ previewUrl , 'http' , 4 ) !== 0 && strncmp ( $ previewUrl , 'data' , 4 ) !== 0 && $ baseurl !== null ) { $ previewUrl = $ baseurl . '/' . $ previewUrl ; } $ mimetype = $ enc -> attr ( $ item -> getMimetype ( ) ) ; $ name = $ enc -> html ( $ item -> getName ( ) ) ; $ string .= sprintf ( $ tag , $ enc -> attr ( $ url ) , $ enc -> attr ( $ previewUrl ) , $ name , $ mimetype ) ; } return $ string ; } | Creates the inner tags for associated media items . |
33,180 | protected function _createMediaTag ( MShop_Media_Item_Interface $ item , array $ boxAttributes , array $ itemAttributes , $ baseurl ) { $ enc = $ this -> encoder ( ) ; $ mediaItems = $ item -> getRefItems ( 'media' ) ; $ parts = explode ( '/' , $ item -> getMimetype ( ) ) ; $ boxattr = '' ; foreach ( $ boxAttributes as $ name => $ value ) { $ boxattr .= $ name . ( $ value != null ? '="' . $ enc -> attr ( $ value ) . '"' : '' ) . ' ' ; } $ itemattr = '' ; foreach ( $ itemAttributes as $ name => $ value ) { $ itemattr .= $ name . ( $ value != null ? '="' . $ enc -> attr ( $ value ) . '"' : '' ) . ' ' ; } switch ( $ parts [ 0 ] ) { case 'audio' : $ tag = "<audio ${boxattr}>" ; $ tag .= "<source src=\"%1\$s\" title=\"%3\$s\" type=\"%4\$s\" ${itemattr} />" ; $ tag .= $ this -> _createAssociatedMediaString ( $ mediaItems , $ baseurl , $ itemattr ) ; $ tag .= '%3$s' ; $ tag .= '</audio>' ; break ; case 'video' : $ tag = "<video ${boxattr}>" ; $ tag .= "<source src=\"%1\$s\" title=\"%3\$s\" type=\"%4\$s\" ${itemattr} />" ; $ tag .= $ this -> _createAssociatedMediaString ( $ mediaItems , $ baseurl , $ itemattr ) ; $ tag .= '%3$s' ; $ tag .= '</video>' ; break ; case 'image' : $ tag = "<div ${boxattr}>" ; $ tag .= "<img src=\"%2\$s\" title=\"%3\$s\" ${itemattr} />" ; $ tag .= $ this -> _createAssociatedMediaString ( $ mediaItems , $ baseurl , $ itemattr ) ; $ tag .= '</div>' ; break ; default : $ tag = "<a href=\"%1\$s\" ${boxattr}>" ; $ tag .= "<img src=\"%2\$s\" title=\"%3\$s\" ${itemattr} />" ; $ tag .= $ this -> _createAssociatedMediaString ( $ mediaItems , $ baseurl , $ itemattr ) ; $ tag .= '%3$s' ; $ tag .= '</a>' ; break ; } return $ tag ; } | Creates the HTML tag for the given media items . |
33,181 | public function isAvailable ( $ email , $ entity = false ) { $ this -> resetRestClient ( ) ; $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-user' , $ this -> login ) ; $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-pw' , $ this -> password ) ; $ parameters = array ( 'userEmail' => $ email , 'entity' => $ entity ? : $ this -> entity ) ; $ command = $ this -> restClient -> getCommand ( 'IsAvailable' , $ parameters ) ; $ result = $ this -> executeRest ( $ command , $ parameters ) ; return $ result [ 'is_available' ] ; } | Check if given email can be used to create an HiPay wallet Enforce the entity to the one given on object construction if false . |
33,182 | public function createFullUseraccountV2 ( UserAccount $ userAccount ) { $ this -> resetRestClient ( ) ; if ( ! $ userAccount -> getLocale ( ) ) { $ userAccount -> setLocale ( $ this -> locale ) ; } if ( ! $ userAccount -> getTimeZone ( ) ) { $ userAccount -> setTimeZone ( $ this -> timezone ) ; } if ( ! $ userAccount -> getEntityCode ( ) ) { $ userAccount -> setEntityCode ( $ this -> entity ) ; } if ( ! $ userAccount -> getCredential ( ) ) { $ userAccount -> setCredential ( array ( 'wslogin' => $ this -> login , 'wspassword' => $ this -> password , ) ) ; } $ parameters = $ userAccount -> mergeIntoParameters ( ) ; $ command = $ this -> restClient -> getCommand ( 'RegisterNewAccount' , $ parameters [ 'userAccount' ] ) ; $ result = $ this -> executeRest ( $ command , $ parameters ) ; return new AccountInfo ( $ result [ 'account_id' ] , $ result [ 'user_space_id' ] , $ result [ 'status' ] === Identified :: YES , $ result [ 'callback_salt' ] ) ; } | Create an new account on HiPay wallet Enforce the entity to the one given on object construction Enforce the locale to the one given on object construction if false Enforce the timezone to the one given on object construction if false . |
33,183 | public function bankInfosRegister ( VendorInterface $ vendor , BankInfo $ bankInfo ) { $ this -> resetRestClient ( ) ; $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-user' , $ this -> login ) ; $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-pw' , $ this -> password ) ; if ( ! is_null ( $ vendor -> getHiPayId ( ) ) ) { $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-subaccount-id' , $ vendor -> getHiPayId ( ) ) ; } $ parameters = $ bankInfo -> mergeIntoParameters ( ) ; $ command = $ this -> restClient -> getCommand ( 'RegisterBankInfo' , $ parameters ) ; $ result = $ this -> executeRest ( $ command , $ parameters ) ; return $ result ; } | Create a bank account in HiPay . |
33,184 | public function getWalletInfo ( UserAccount $ userAccount , $ vendor ) { $ result = $ this -> getAccountInfos ( $ userAccount , $ vendor ) ; return new AccountInfo ( $ result [ 'user_account_id' ] , $ result [ 'user_space_id' ] , $ result [ 'identified' ] === 1 , $ result [ 'callback_salt' ] , $ result [ 'message' ] ) ; } | Return the hipay account information . |
33,185 | public function isIdentified ( VendorInterface $ vendor ) { $ this -> resetRestClient ( ) ; $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-user' , $ this -> login ) ; $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-pw' , $ this -> password ) ; if ( ! empty ( $ vendor -> getHiPayId ( ) ) ) { $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-subaccount-id' , $ vendor -> getHiPayId ( ) ) ; } $ command = $ this -> restClient -> getCommand ( 'GetUserAccount' , array ( ) ) ; $ result = $ this -> executeRest ( $ command ) ; return $ result [ 'identified' ] == 1 ? true : false ; } | Return the identified status of the account . |
33,186 | public function getBalance ( VendorInterface $ vendor ) { $ this -> resetRestClient ( ) ; $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-user' , $ this -> login ) ; $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-pw' , $ this -> password ) ; if ( ! is_null ( $ vendor -> getHiPayId ( ) ) ) { $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-subaccount-id' , $ vendor -> getHiPayId ( ) ) ; } elseif ( ! is_null ( $ vendor -> getLogin ( ) ) ) { $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-subaccount-login' , $ vendor -> getLogin ( ) ) ; } $ command = $ this -> restClient -> getCommand ( 'GetBalance' , array ( ) ) ; try { $ result = $ this -> executeRest ( $ command ) ; } catch ( ClientErrorResponseException $ e ) { if ( $ e -> getResponse ( ) -> getStatusCode ( ) == '401' ) { $ this -> restClient -> getConfig ( ) -> setPath ( 'request.options/headers/php-auth-subaccount-login' , strtolower ( $ vendor -> getEmail ( ) ) ) ; $ command = $ this -> restClient -> getCommand ( 'GetBalance' , array ( ) ) ; $ result = $ this -> executeRest ( $ command ) ; } } return $ result [ 'balances' ] [ 0 ] [ 'balance' ] ; } | Return the wallet current balance |
33,187 | private function transferSoap ( Transfer $ transfer , VendorInterface $ vendor = null ) { if ( ! $ transfer -> getEntity ( ) ) { $ transfer -> setEntity ( $ this -> entity ) ; } $ parameters = $ transfer -> mergeIntoParameters ( ) ; if ( $ vendor ) { $ parameters = $ this -> mergeSubAccountParameters ( $ vendor ) ; } $ result = $ this -> callSoap ( 'direct' , $ parameters ) ; return $ result [ 'transactionId' ] ; } | Make a transfer . |
33,188 | private function withdrawSoap ( VendorInterface $ vendor , $ amount , $ label ) { $ parameters = array ( 'amount' => $ amount , 'label' => $ label ) ; $ parameters = $ this -> mergeSubAccountParameters ( $ vendor , $ parameters ) ; $ result = $ this -> callSoap ( 'create' , $ parameters ) ; return $ result [ 'transactionPublicId' ] ; } | Make a withdrawal . |
33,189 | private function executeRest ( $ command , $ parameters = array ( ) ) { $ result = $ this -> restClient -> execute ( $ command ) ; if ( isset ( $ result [ 'code' ] ) && $ result [ 'code' ] === 0 ) { return $ result ; } throw new Exception ( "There was an error with the Rest call " . $ command -> getName ( ) . PHP_EOL . $ result [ 'code' ] . ' : ' . $ result [ 'message' ] . PHP_EOL . print_r ( $ result [ 'errors' ] , true ) . PHP_EOL . 'Parameters : ' . print_r ( $ parameters , true ) . PHP_EOL , $ result [ 'code' ] ) ; } | Exec Guzzle command Wallet API doesn t send HTTP error code in case of parameters errors send 200 instead Error is in request body |
33,190 | private static function getLibraryVersion ( ) { $ path = dirname ( __FILE__ ) . '/../../composer.json' ; if ( file_exists ( $ path ) ) { $ contents = file_get_contents ( $ path ) ; $ contents = utf8_encode ( $ contents ) ; $ composer = json_decode ( $ contents , true ) ; } else { $ composer [ "version" ] = "N/A" ; } return $ composer [ "version" ] ; } | Get library version from composer . json file |
33,191 | protected function loadFile ( string $ file , array $ options ) { $ yaml = file_get_contents ( $ file ) ; error_clear_last ( ) ; $ unused = null ; $ data = @ yaml_parse ( $ yaml , $ options [ 'pos' ] ?? 0 , $ unused , $ options [ 'callbacks' ] ?? [ ] ) ; return $ data ; } | Parse a yaml file . |
33,192 | public function setAttribute ( string $ name , string $ value ) : Label { $ this -> tag -> setAttribute ( $ name , $ value ) ; return $ this ; } | Sets an attribute on the label tag . |
33,193 | public function install ( InstalledRepositoryInterface $ repo , PackageInterface $ package ) { $ downloadPath = $ this -> getInstallPath ( $ package ) ; $ fileSystem = new Filesystem ( ) ; if ( ! is_dir ( $ downloadPath ) || $ fileSystem -> isDirEmpty ( $ downloadPath ) ) { return parent :: install ( $ repo , $ package ) ; } $ actualLegacyDir = $ this -> ezpublishLegacyDir ; $ this -> ezpublishLegacyDir = $ this -> generateTempDirName ( ) ; if ( $ this -> io -> isVerbose ( ) ) { $ this -> io -> write ( "Installing in temporary directory." ) ; } parent :: install ( $ repo , $ package ) ; if ( $ this -> io -> isVerbose ( ) ) { $ this -> io -> write ( "Updating new code over existing installation." ) ; } $ fileSystem -> copyThenRemove ( $ this -> ezpublishLegacyDir , $ actualLegacyDir ) ; if ( method_exists ( $ this , 'removeBinaries' ) ) { $ this -> removeBinaries ( $ package ) ; } else { $ this -> binaryInstaller -> removeBinaries ( $ package ) ; } $ this -> ezpublishLegacyDir = $ actualLegacyDir ; if ( method_exists ( $ this , 'installBinaries' ) ) { $ this -> installBinaries ( $ package ) ; } else { $ this -> binaryInstaller -> installBinaries ( $ package , $ this -> getInstallPath ( $ package ) ) ; } } | If composer tries to install into a non - empty folder we risk to effectively erase an existing installation . This is not a composer limitation we can fix - it happens because composer might be using git to download the sources and git can not clone a repo into a non - empty folder . |
33,194 | public function toArray ( ) { $ list = parent :: toArray ( ) ; $ list [ $ this -> _prefix . 'code' ] = $ this -> getCode ( ) ; $ list [ $ this -> _prefix . 'domain' ] = $ this -> getDomain ( ) ; $ list [ $ this -> _prefix . 'label' ] = $ this -> getLabel ( ) ; $ list [ $ this -> _prefix . 'status' ] = $ this -> getStatus ( ) ; return $ list ; } | Returns an associative list of item properties . |
33,195 | public function cleanup ( ) { $ conn = $ this -> _dbm -> acquire ( $ this -> _dbname ) ; try { $ date = date ( 'Y-m-d H:i:00' ) ; $ search = new MW_Common_Criteria_SQL ( $ conn ) ; $ search -> setConditions ( $ search -> compare ( '<' , $ this -> _searchConfig [ 'cache.expire' ] [ 'code' ] , $ date ) ) ; $ types = $ this -> _getSearchTypes ( $ this -> _searchConfig ) ; $ translations = $ this -> _getSearchTranslations ( $ this -> _searchConfig ) ; $ conditions = $ search -> getConditionString ( $ types , $ translations ) ; $ stmt = $ conn -> create ( str_replace ( ':cond' , $ conditions , $ this -> _sql [ 'delete' ] ) ) ; $ stmt -> bind ( 1 , $ this -> _siteid , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> execute ( ) -> finish ( ) ; $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; } catch ( Exception $ e ) { $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; throw $ e ; } } | Removes all expired cache entries . |
33,196 | public function flush ( ) { $ conn = $ this -> _dbm -> acquire ( $ this -> _dbname ) ; try { $ stmt = $ conn -> create ( str_replace ( ':cond' , '1' , $ this -> _sql [ 'delete' ] ) ) ; $ stmt -> bind ( 1 , $ this -> _siteid , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> execute ( ) -> finish ( ) ; $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; } catch ( Exception $ e ) { $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; throw $ e ; } } | Removes all entries of the site from the cache . |
33,197 | public function getList ( array $ keys ) { $ list = array ( ) ; $ conn = $ this -> _dbm -> acquire ( $ this -> _dbname ) ; try { $ search = new MW_Common_Criteria_SQL ( $ conn ) ; $ expires = array ( $ search -> compare ( '>' , 'cache.expire' , date ( 'Y-m-d H:i:00' ) ) , $ search -> compare ( '==' , 'cache.expire' , null ) , ) ; $ expr = array ( $ search -> compare ( '==' , 'cache.id' , $ keys ) , $ search -> combine ( '||' , $ expires ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ types = $ this -> _getSearchTypes ( $ this -> _searchConfig ) ; $ translations = $ this -> _getSearchTranslations ( $ this -> _searchConfig ) ; $ conditions = $ search -> getConditionString ( $ types , $ translations ) ; $ stmt = $ conn -> create ( str_replace ( ':cond' , $ conditions , $ this -> _sql [ 'get' ] ) ) ; $ stmt -> bind ( 1 , $ this -> _siteid , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ result = $ stmt -> execute ( ) ; while ( ( $ row = $ result -> fetch ( ) ) !== false ) { $ list [ $ row [ 'id' ] ] = $ row [ 'value' ] ; } $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; } catch ( Exception $ e ) { $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; throw $ e ; } return $ list ; } | Returns the cached values for the given cache keys if available . |
33,198 | public function actionPrerequisites ( ) { $ checks = SystemCheck :: getResults ( ) ; $ hasError = FALSE ; foreach ( $ checks as $ check ) { if ( $ check [ 'state' ] == 'ERROR' ) $ hasError = TRUE ; } return $ this -> render ( 'prerequisites' , [ 'checks' => $ checks , 'hasError' => $ hasError ] ) ; } | Prerequisites action checks application requirement using the SystemCheck Library |
33,199 | public function actionInit ( ) { if ( ! InstallerModule :: checkDbConnection ( ) ) Yii :: $ app -> db -> open ( ) ; if ( Yii :: $ app -> cache ) { Yii :: $ app -> cache -> flush ( ) ; } $ data = file_get_contents ( ( dirname ( __DIR__ ) . '/migrations/data.sql' ) ) ; Yii :: $ app -> db -> createCommand ( $ data ) -> execute ( ) ; return $ this -> redirect ( Yii :: $ app -> urlManager -> createUrl ( '//installer/config/index' ) ) ; } | The init action imports the database structure & initial data |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.