idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
25,800 | protected function createLocationEvent ( array $ data ) { $ result = new WxReceiveLocationEvent ( ) ; $ this -> initReceive ( $ result , $ data ) ; $ result -> setLatitude ( $ data [ 'Latitude' ] ) ; $ result -> setLongitude ( $ data [ 'Longitude' ] ) ; $ result -> setPrecision ( $ data [ 'Precision' ] ) ; return $ result ; } | create WxReceiveLocationEvent instance |
25,801 | protected function createViewEvent ( array $ data ) { $ result = new WxReceiveViewEvent ( ) ; $ this -> initReceive ( $ result , $ data ) ; $ result -> setEventKey ( $ data [ 'EventKey' ] ) ; return $ result ; } | create WxReceiveViewEvent instance |
25,802 | protected function createClickEvent ( array $ data ) { $ result = new WxReceiveClickEvent ( ) ; $ this -> initReceive ( $ result , $ data ) ; $ result -> setEventKey ( $ data [ 'EventKey' ] ) ; return $ result ; } | create WxReceiveClickEvent instance |
25,803 | protected function createScanEvent ( array $ data ) { $ result = new WxReceiveScanEvent ( ) ; $ this -> initReceive ( $ result , $ data ) ; $ result -> setEvent ( $ data [ 'Event' ] ) ; $ result -> setEventKey ( $ data [ 'EventKey' ] ) ; $ result -> setTicket ( $ data [ 'Ticket' ] ) ; return $ result ; } | create WxReceiveScanEvent instance |
25,804 | protected function createSubscribeEvent ( array $ data ) { if ( isset ( $ data [ 'EventKey' ] ) && isset ( $ data [ 'Ticket' ] ) && ( WxReceiveEvent :: EVENT_TYPE_SUBSCRIBE == $ data [ 'Event' ] ) ) { return $ this -> createScanEvent ( $ data ) ; } $ result = new WxReceiveSubscribeEvent ( ) ; $ this -> initReceive ( $ result , $ data ) ; $ result -> setEvent ( $ data [ 'Event' ] ) ; return $ result ; } | create WxReceiveEvent instance |
25,805 | public static function createFromFileOwner ( $ filename ) { if ( ! file_exists ( $ filename ) ) { throw new \ InvalidArgumentException ( 'Invalid file name provided.' ) ; } if ( ! function_exists ( 'posix_getuid' ) ) { throw new PosixNotAvailableException ( 'Could not retrieve information about the operating system user because POSIX functions ' . 'are not available to your PHP executable.' ) ; } if ( false === $ uid = \ fileowner ( $ filename ) ) { throw new \ Exception ( 'Could not get the owner of the file "' . $ filename . '".' ) ; } return new User ( $ uid ) ; } | Factory method to get the owner of a file . |
25,806 | public function load ( $ sourcePath , $ targetPath ) { $ mapper = new AssetMapper ( ) ; $ mapper -> map ( $ sourcePath , $ targetPath ) ; return $ mapper ; } | Add asset mapper from file or directory path |
25,807 | public function filter ( $ value ) { if ( ! is_string ( $ value ) ) { return $ value ; } $ value = preg_replace ( '{^\xEF\xBB\xBF|\x1A}' , '' , $ value ) ; $ value = preg_replace ( '{\r\n?}' , "\n" , $ value ) ; $ lambda = function ( $ text ) { $ text = htmlspecialchars ( $ text , ENT_COMPAT , 'UTF-8' ) ; $ text = preg_replace ( '/--/' , '—' , $ text ) ; $ text = nl2br ( $ text , false ) ; $ text = sprintf ( '<p>%s</p>' , $ text ) ; return $ text ; } ; $ paragraphs = preg_split ( '/\n{2,}/' , $ value , - 1 , PREG_SPLIT_NO_EMPTY ) ; $ paragraphs = array_map ( $ lambda , $ paragraphs ) ; return implode ( "\n\n" , $ paragraphs ) ; } | Convert paragraphs of text into filtered HTML . |
25,808 | public function fromResponse ( RequestInterface $ request , Response $ response ) { $ message = $ response -> json ( ) ; $ parts = array ( 'type' => isset ( $ message [ 'error' ] ) ? $ message [ 'error' ] : null , 'description' => isset ( $ message [ 'description' ] ) ? $ message [ 'description' ] : null , 'request_id' => $ response -> getHeaders ( ) -> get ( 'x-kinvey-request-id' ) , 'debug' => isset ( $ message [ 'debug' ] ) && ! empty ( $ message [ 'debug' ] ) ? $ message [ 'debug' ] : null , ) ; return $ this -> createException ( $ request , $ response , $ parts ) ; } | Returns a Kinvey service specific exception |
25,809 | protected function createException ( RequestInterface $ request , Response $ response , array $ parts ) { $ message = 'Status Code: ' . $ response -> getStatusCode ( ) . PHP_EOL . 'Kinvey Request ID: ' . $ parts [ 'request_id' ] . PHP_EOL . 'Kinvey Exception Type: ' . $ parts [ 'type' ] . PHP_EOL . 'Kinvey Error Message: ' . $ parts [ 'description' ] . PHP_EOL . 'Kinvey Debug: ' . $ parts [ 'debug' ] ; $ class = new KinveyResponseException ( $ message ) ; $ class -> setExceptionType ( $ parts [ 'type' ] ) ; $ class -> setResponse ( $ response ) ; $ class -> setRequest ( $ request ) ; $ class -> setRequestId ( $ parts [ 'request_id' ] ) ; $ class -> setDebug ( $ parts [ 'debug' ] ) ; return $ class ; } | Create an prepare an exception object |
25,810 | protected function _init ( ) { $ self = static :: _object ( ) ; if ( ! isset ( $ self -> _actsAs ) ) { $ self -> _actsAs = [ ] ; } foreach ( $ self -> _actsAs as $ name => $ config ) { if ( is_string ( $ config ) ) { $ name = $ config ; $ config = [ ] ; } static :: actsAs ( $ name , $ config ) ; } } | Initializer function called just after the model instanciation . |
25,811 | public static function actsAs ( $ name , $ config = [ ] , $ entry = null ) { $ self = static :: _object ( ) ; $ class = Libraries :: locate ( 'behavior' , $ name ) ; if ( $ config === true ) { if ( isset ( $ self -> _behaviors [ $ class ] ) ) { return $ self -> _behaviors [ $ class ] -> config ( $ entry ) ; } throw new RuntimeException ( "Unexisting Behavior named `{$class}`." ) ; } if ( $ config === false ) { unset ( $ self -> _behaviors [ $ class ] ) ; return true ; } $ model = get_called_class ( ) ; if ( isset ( $ self -> _behaviors [ $ class ] ) ) { $ self -> _behaviors [ $ class ] -> config ( $ config + compact ( 'model' ) ) ; return true ; } else { $ object = new $ class ( $ config + compact ( 'model' ) ) ; if ( $ object ) { $ self -> _behaviors [ $ class ] = $ object ; return true ; } } return false ; } | Bind a behavior class to the current model |
25,812 | protected function runChecks ( $ action , $ input = [ ] , $ original = [ ] ) { $ this -> checkAuthorisation ( $ action ) ; if ( ! empty ( $ input ) ) { $ filtered = $ this -> applyValidationRules ( $ action , $ input ) ; $ this -> applyDomainRules ( $ action , $ input , $ original ) ; return $ filtered ; } } | Run required checks for given action . |
25,813 | protected function applyValidationRules ( $ action , $ input = [ ] ) { if ( $ action == 'read' or $ action == 'destroy' ) { return ; } if ( ! $ this -> inputValidator ) { throw new RequiredInputValidatorException ( 'You must provide an inputValidator to perform a data modification / creation' ) ; } $ validation = $ this -> inputValidator -> make ( $ input ) ; $ validation -> scope ( [ $ action ] ) ; $ validation -> bind ( $ validation -> getInputs ( ) ) ; if ( $ validation -> fails ( ) ) { throw new ValidationException ( 'Validation failed' , $ validation -> errors ( ) -> all ( ) ) ; } else { return $ validation -> getInputs ( ) ; } } | Apply validation rules . |
25,814 | protected function applyDomainRules ( $ action , $ input = [ ] , $ original = [ ] ) { $ domainRulesMethod = 'domainRulesOn' . ucfirst ( $ action ) ; if ( $ action = 'update' ) { $ this -> { $ domainRulesMethod } ( $ input , $ original ) ; } else { $ this -> { $ domainRulesMethod } ( $ input ) ; } } | Apply domain rules . |
25,815 | public function from ( string $ table = null ) : Delete { $ this -> from = [ ] ; if ( ! \ is_string ( $ table ) && ! \ is_array ( $ table ) ) { throw new InvalidArgumentException ( '$table has to be an array or a string' ) ; } $ this -> from = $ this -> namesClass -> parse ( $ table , true ) ; return $ this ; } | Adds table names for delete |
25,816 | public function show ( $ id ) { $ peopleID = $ this -> helpers -> determinePeopleID ( $ id ) ; if ( ! $ this -> helpers -> isAllowedPeopleIdSingleContactDisplay ( $ peopleID ) ) { return redirect ( ) -> back ( ) ; } $ people = $ this -> peopleRepository -> getFind ( $ peopleID ) ; $ email = $ this -> peopleRepository -> getFirstWorkEmail ( $ peopleID ) ; $ telephone = $ this -> peopleRepository -> getFirstWorkTelephone ( $ peopleID ) ; return view ( 'lasallecrmcontact::single_crmcontact_basic' , [ 'people' => $ people , 'email' => $ email , 'telephone' => $ telephone , 'single_contact_display_contact_form' => Config :: get ( 'lasallecrmcontact.single_contact_display_contact_form' ) , 'Config' => Config :: class , ] ) ; } | Display a single contact from the LaSalleCRM database |
25,817 | public function multipleshow ( ) { $ displayTheseIDs = Config :: get ( 'lasallecrmcontact.multiple_contact_display_people_ids' ) ; $ contacts = [ ] ; $ i = 0 ; foreach ( $ displayTheseIDs as $ displayThisID ) { $ people = $ this -> peopleRepository -> getFind ( $ displayThisID ) ; $ email = $ this -> peopleRepository -> getFirstWorkEmail ( $ displayThisID ) ; $ telephone = $ this -> peopleRepository -> getFirstWorkTelephone ( $ displayThisID ) ; $ contacts [ $ i ] [ 'first_name' ] = $ people -> first_name ; $ contacts [ $ i ] [ 'middle_name' ] = $ people -> middle_name ; $ contacts [ $ i ] [ 'surname' ] = $ people -> surname ; $ contacts [ $ i ] [ 'link' ] = $ people -> first_name . '@' . $ people -> middle_name . '@' . $ people -> surname ; $ contacts [ $ i ] [ 'position' ] = $ people -> position ; $ contacts [ $ i ] [ 'featured_image' ] = $ people -> featured_image ; $ contacts [ $ i ] [ 'email' ] = $ email ; $ contacts [ $ i ] [ 'telephone' ] = $ telephone ; $ i ++ ; } return view ( 'lasallecrmcontact::multiple_crmcontact_basic' , [ 'contacts' => $ contacts , 'Config' => Config :: class , ] ) ; } | Display multiple contacts from the LaSalleCRM database |
25,818 | public function resolve ( $ var ) { $ filters = array ( ) ; if ( is_array ( $ var ) ) { $ name = array_shift ( $ var ) ; $ filters = isset ( $ var [ 'filters' ] ) ? $ var [ 'filters' ] : array ( ) ; } else { $ name = $ var ; } $ result = null ; if ( $ name [ 0 ] === ':' ) { $ object = $ this -> getVariable ( substr ( $ name , 1 ) ) ; if ( ! is_null ( $ object ) ) { $ result = $ object ; } } else { if ( $ name === 'true' ) { $ result = true ; } elseif ( $ name === 'false' ) { $ result = false ; } elseif ( preg_match ( '/^-?\d+(\.\d+)?$/' , $ name , $ matches ) ) { $ result = isset ( $ matches [ 1 ] ) ? floatval ( $ name ) : intval ( $ name ) ; } elseif ( preg_match ( '/^"([^"\\\\]*(?:\\.[^"\\\\]*)*)"|' . '\'([^\'\\\\]*(?:\\.[^\'\\\\]*)*)\'$/' , $ name ) ) { $ result = stripcslashes ( substr ( $ name , 1 , - 1 ) ) ; } } if ( ! empty ( self :: $ lookupTable ) && $ result == null ) { $ result = $ this -> externalLookup ( $ name ) ; } $ result = $ this -> applyFilters ( $ result , $ filters ) ; return $ result ; } | Variable name . |
25,819 | public function loadCommands ( ) { $ slickModules = $ this -> filterSlickModules ( ) ; $ classes = $ this -> getCommandClasses ( $ slickModules ) ; foreach ( $ classes as $ class ) { if ( is_subclass_of ( $ class , Command :: class ) ) { $ this -> application -> add ( new $ class ( ) ) ; } } } | Load all slick commands |
25,820 | protected function filterSlickModules ( ) { $ iterator = new \ ArrayIterator ( $ this -> psr4Data ) ; $ modules = [ ] ; foreach ( $ iterator as $ nameSpace => $ path ) { if ( preg_match ( '/^Slick\\\[a-z_]*\\\$/i' , $ nameSpace ) ) { $ modules [ $ nameSpace ] = reset ( $ path ) ; } } return $ modules ; } | Retrieves all Slick modules installed from composer |
25,821 | protected function getCommandClasses ( array $ modules ) { $ classes = [ ] ; foreach ( $ modules as $ nameSpace => $ path ) { $ classes = array_merge ( $ classes , $ this -> getClasses ( $ nameSpace , $ path ) ) ; } return $ classes ; } | Get user defined classes in Console \ Command name space of each module |
25,822 | protected function getClasses ( $ namespace , $ path ) { $ classes = [ ] ; $ path = "$path/Console/Command" ; if ( ! is_dir ( $ path ) ) { return $ classes ; } $ dir = new \ DirectoryIterator ( $ path ) ; $ classFiles = new \ RegexIterator ( $ dir , '/[a-z_]*\.php/i' ) ; foreach ( $ classFiles as $ file ) { $ classes [ ] = str_replace ( '.php' , '' , "{$namespace}Console\\Command\\{$file}" ) ; } return $ classes ; } | Get classes that implements the Command interface |
25,823 | public function setHeading ( $ heading_text , $ heading_size = 2 ) { $ this -> heading_text = $ heading_text ; $ this -> heading_size = is_int ( $ heading_size ) ? $ heading_size : 2 ; return $ this ; } | Set heading text and size |
25,824 | public function setSuccessStatus ( int $ status , string $ description = "" ) : RouteInterface { $ this -> statuses [ $ status ] = HttpStatus :: create ( ) -> setStatus ( $ status ) -> setDescription ( $ description ) -> setMainSuccess ( true ) ; return $ this -> addFirst ( new SuccessStatusMiddleware ( $ status ) ) ; } | Set status code in case of success response |
25,825 | public function setSuccessLocationHeader ( string $ location , EntityFactoryConfig $ config , int $ status = 302 ) : RouteInterface { return $ this -> addFirst ( new SuccessHeaderLocationMiddleware ( $ location , $ config , $ status ) ) ; } | Add a Location header to the response |
25,826 | public function buildMenu ( $ config ) { $ rootNodes = $ this -> queryForChildrenOf ( 'NE' ) ; $ options = [ [ '' , '' ] ] ; while ( $ row = $ GLOBALS [ 'TYPO3_DB' ] -> sql_fetch_assoc ( $ rootNodes ) ) { $ optionTitle = $ row [ 'descr' ] ; $ optionValue = $ row [ 'ppn' ] ; $ options [ ] = [ $ optionTitle , $ optionValue ] ; } $ config [ 'items' ] = array_merge ( $ config [ 'items' ] , $ options ) ; return $ config ; } | Called from Flexform to provide menu items with Neuerwerbungen subjects . |
25,827 | public function FetchView ( ) { $ ViewPath = $ this -> FetchViewLocation ( ) ; $ String = '' ; ob_start ( ) ; if ( is_object ( $ this -> _Sender ) && isset ( $ this -> _Sender -> Data ) ) { $ Data = $ this -> _Sender -> Data ; } else { $ Data = array ( ) ; } include ( $ ViewPath ) ; $ String = ob_get_contents ( ) ; @ ob_end_clean ( ) ; return $ String ; } | Returns the xhtml for this module as a fully parsed and rendered string . |
25,828 | public function FetchViewLocation ( $ View = '' , $ ApplicationFolder = '' ) { if ( $ View == '' ) $ View = strtolower ( $ this -> Name ( ) ) ; if ( substr ( $ View , - 6 ) == 'module' ) $ View = substr ( $ View , 0 , - 6 ) ; if ( substr ( $ View , 0 , 4 ) == 'gdn_' ) $ View = substr ( $ View , 4 ) ; if ( $ ApplicationFolder == '' ) $ ApplicationFolder = strpos ( $ this -> _ApplicationFolder , '/' ) ? $ this -> _ApplicationFolder : strtolower ( $ this -> _ApplicationFolder ) ; $ ThemeFolder = $ this -> _ThemeFolder ; $ ViewPath = NULL ; if ( Gdn :: Controller ( ) instanceof Gdn_Controller ) { try { $ ViewPath = Gdn :: Controller ( ) -> FetchViewLocation ( $ View , 'modules' , $ ApplicationFolder ) ; } catch ( Exception $ Ex ) { } } if ( ! $ ViewPath ) { $ ViewPaths = array ( ) ; if ( strpos ( $ View , '/' ) !== FALSE ) $ ViewPaths [ ] = $ View ; if ( $ ThemeFolder != '' ) { $ ViewPaths [ ] = CombinePaths ( array ( PATH_THEMES , $ ThemeFolder , $ ApplicationFolder , 'views' , 'modules' , $ View . '.php' ) ) ; $ ViewPaths [ ] = CombinePaths ( array ( PATH_THEMES , $ ThemeFolder , 'views' , 'modules' , $ View . '.php' ) ) ; } if ( $ this -> _ApplicationFolder ) $ ViewPaths [ ] = CombinePaths ( array ( PATH_APPLICATIONS , $ ApplicationFolder , 'views' , 'modules' , $ View . '.php' ) ) ; else $ ViewPaths [ ] = dirname ( $ this -> Path ( ) ) . "/../views/modules/$View.php" ; $ ViewPaths [ ] = CombinePaths ( array ( PATH_APPLICATIONS , 'dashboard' , 'views' , 'modules' , $ View . '.php' ) ) ; $ ViewPath = Gdn_FileSystem :: Exists ( $ ViewPaths ) ; } if ( $ ViewPath === FALSE ) throw new Exception ( ErrorMessage ( 'Could not find a `' . $ View . '` view for the `' . $ this -> Name ( ) . '` module in the `' . $ ApplicationFolder . '` application.' , get_class ( $ this ) , 'FetchView' ) , E_USER_ERROR ) ; return $ ViewPath ; } | Returns the location of the view for this module in the filesystem . |
25,829 | public function withLabels ( array $ labels = [ ] ) : Translator { $ labels = array_merge ( $ this -> labels , $ labels ) ; return new Translator ( $ labels , $ this -> templates ) ; } | Return a new translator with an additional list of labels . |
25,830 | public function withTemplates ( array $ templates = [ ] ) : Translator { $ templates = array_merge ( $ this -> templates , $ templates ) ; return new Translator ( $ this -> labels , $ templates ) ; } | Return a new translator with an additional list of templates . |
25,831 | public function getMessages ( string $ key , array $ errors = [ ] ) : array { if ( array_key_exists ( $ key , $ this -> templates ) ) { return [ $ this -> translate ( $ this -> templates [ $ key ] , [ 'attribute' => $ key ] ) ] ; } return array_reduce ( $ errors , function ( $ messages , $ error ) use ( $ key ) { $ rule = $ error -> getRule ( ) ; $ parameters = $ error -> getParameters ( ) ; $ template = $ this -> getTemplate ( $ key , $ rule ) ; $ message = $ this -> translate ( $ template , array_merge ( $ parameters , [ 'attribute' => $ key , ] ) ) ; return array_merge ( $ messages , [ $ message ] ) ; } , [ ] ) ; } | Return a list of messages from a rule key and its list of errors . |
25,832 | private function getTemplate ( string $ key , string $ rule ) : string { $ keyrule = implode ( '.' , [ $ key , $ rule ] ) ; if ( array_key_exists ( $ keyrule , $ this -> templates ) ) { return $ this -> templates [ $ keyrule ] ; } if ( array_key_exists ( $ rule , $ this -> templates ) ) { return $ this -> templates [ $ rule ] ; } if ( array_key_exists ( self :: DEFAULT_TEMPLATE_KEY , $ this -> templates ) ) { return $ this -> templates [ self :: DEFAULT_TEMPLATE_KEY ] ; } return self :: FALLBACK_TEMPLATE ; } | Return a template from a rule key and a rule name . First look for a key . rule template then for a rule template then for a default template and finally return the fallback template when none was found . |
25,833 | private function translate ( string $ template , array $ parameters ) : string { $ placeholders = array_map ( [ $ this , 'getPlaceholder' ] , array_keys ( $ parameters ) ) ; $ replacements = array_map ( [ $ this , 'getTranslatedValue' ] , array_values ( $ parameters ) ) ; return str_replace ( $ placeholders , $ replacements , $ template ) ; } | Return a template with placeholders replaced by translated parameters values . |
25,834 | public function is ( $ actual , $ expected ) { if ( ! is_scalar ( $ actual ) || ! is_scalar ( $ expected ) ) { throw new \ Exception ( "'try/predict-is' can only compare scalar values. 'try/predict' for complex predictions." ) ; } if ( $ actual !== $ expected ) { throw new \ Exception ( "Expected '$expected', but got '$actual'." ) ; } } | Method to test scalar values if they equal one another |
25,835 | public function actionSeed ( ) { $ tx = $ this -> db -> beginTransaction ( ) ; try { $ this -> seed ( ) ; $ tx -> commit ( ) ; } catch ( Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) ) ; $ tx -> rollback ( ) ; } } | This command is used when typing yiic seed . Demo data should be created here |
25,836 | public function set ( string $ key , $ value ) : MutableSerializationContext { $ cloned = clone $ this ; $ cloned -> payload [ $ key ] = $ value ; return $ cloned ; } | Set the new key - value to context |
25,837 | public function merge ( ResourceSerializationContext $ context ) : MutableSerializationContext { $ cloned = clone $ this ; $ cloned -> payload = array_merge ( $ cloned -> payload , $ context -> payload ) ; return $ cloned ; } | Merge serialization context |
25,838 | private function registerArcanesoftDatabase ( ) { $ connection = $ this -> config ( ) -> get ( 'core.database.default' , 'sqlite' ) ; $ this -> config ( ) -> set ( 'database.connections.arcanesoft' , $ this -> config ( ) -> get ( "core.database.connections.{$connection}" ) ) ; } | Register Foundation database . |
25,839 | public function addCommandLineArgument ( $ argument ) { $ args = ( array ) $ this -> getPhpCliArguments ( ) ; $ this -> setPhpCliArguments ( array_merge ( $ args , [ $ argument ] ) ) ; return $ this ; } | Add a command line argument . |
25,840 | public static function fromFloat ( $ float_value , $ precision = null ) { if ( $ precision === null ) { $ precision = static :: $ PRECISION ; } $ rounded_float = intval ( round ( $ float_value ) ) ; $ big_integer_int = ( new BigInt ( $ rounded_float ) ) -> multiply ( self :: precisionUnitsAsBigInt ( 1 , $ precision ) ) ; $ rounded_decimal = intval ( round ( floatval ( $ float_value - $ rounded_float ) * pow ( 10 , $ precision ) ) ) ; $ big_integer_decimal = new BigInt ( $ rounded_decimal ) ; return new static ( $ big_integer_int -> add ( $ big_integer_decimal ) , $ precision ) ; } | Creates a new quantity from a float value |
25,841 | public static function fromCryptoQuantity ( CryptoQuantity $ source_quantity , $ precision = null ) { if ( $ precision === null ) { $ precision = static :: $ PRECISION ; } $ round_up = false ; $ source_precision = $ source_quantity -> getPrecision ( ) ; $ precision_delta = $ precision - $ source_precision ; if ( $ precision_delta > 0 ) { $ satoshis_string = $ source_quantity -> getSatoshisString ( ) . str_repeat ( '0' , $ precision_delta ) ; } else if ( $ precision_delta < 0 ) { $ satoshis_string = $ source_quantity -> getSatoshisString ( ) ; $ round_digit = substr ( $ satoshis_string , $ precision_delta , 1 ) ; $ satoshis_string = substr ( $ satoshis_string , 0 , $ precision_delta ) ; $ round_up = ( $ round_digit >= 5 ) ; } else { return clone $ source_quantity ; } $ new_quantity = static :: fromSatoshis ( $ satoshis_string , $ precision ) ; if ( $ round_up ) { $ new_quantity = $ new_quantity -> add ( new BigInt ( 1 ) ) ; } return $ new_quantity ; } | Creates an asset quantity from another cryptoquantity and adjusts the precision This will round if the new precision is smaller than the previous precision |
25,842 | public static function unserialize ( $ serialized_quantity ) { if ( is_array ( $ serialized_quantity ) ) { $ json_array = $ serialized_quantity ; } else if ( is_object ( $ serialized_quantity ) ) { $ json_array = json_decode ( json_encode ( $ serialized_quantity ) , true ) ; } else { $ json_array = json_decode ( $ serialized_quantity , true ) ; } if ( ! is_array ( $ json_array ) ) { throw new Exception ( "Invalid serialized quantity" , 1 ) ; } return static :: fromSatoshis ( $ json_array [ 'value' ] , $ json_array [ 'precision' ] ) ; } | Unserialize a quantity object |
25,843 | public function getFloatValue ( ) { list ( $ quotient , $ remainder ) = $ this -> big_integer -> divide ( self :: precisionUnitsAsBigInt ( 1 , $ this -> precision ) ) ; return floatval ( $ quotient -> toString ( ) ) + floatval ( $ remainder -> toString ( ) / pow ( 10 , $ this -> precision ) ) ; } | Gets the amount as a float |
25,844 | public function gt ( $ other ) { if ( ! ( $ other instanceof self ) ) { $ other = new BigInt ( $ other ) ; } return ( $ this -> compare ( $ other ) > 0 ) ; } | Returns true if greater than |
25,845 | public function gte ( $ other ) { if ( ! ( $ other instanceof self ) ) { $ other = new BigInt ( $ other ) ; } return ( $ this -> compare ( $ other ) >= 0 ) ; } | Returns true if greater than or equal to |
25,846 | public function lt ( $ other ) { if ( ! ( $ other instanceof self ) ) { $ other = new BigInt ( $ other ) ; } return ( $ this -> compare ( $ other ) < 0 ) ; } | Returns true if less than |
25,847 | public function lte ( $ other ) { if ( ! ( $ other instanceof self ) ) { $ other = new BigInt ( $ other ) ; } return ( $ this -> compare ( $ other ) <= 0 ) ; } | Returns true if less than or equal to |
25,848 | public function equals ( $ other ) { if ( ! ( $ other instanceof self ) ) { $ other = new BigInt ( $ other ) ; } return ( $ this -> compare ( $ other ) === 0 ) ; } | Returns true if exactly equal to |
25,849 | public function getLocaleList ( ) { if ( null === $ this -> localeList ) { $ this -> setLocaleList ( LocaleUtils :: getNamedList ( Locale :: getDefault ( ) ) ) ; } return $ this -> localeList ; } | Return the locale list for checking allowed locales |
25,850 | public function is ( string $ env ) : bool { return $ this -> env === $ env || str_starts_with ( $ this -> env , "$env." ) ; } | Check if environment matches or is a parent . |
25,851 | public function getLevels ( int $ from = 1 , ? int $ to = null , ? callable $ callback = null ) : array { $ parts = explode ( '.' , $ this -> env ) ; $ n = isset ( $ to ) ? min ( count ( $ parts ) , $ to ) : count ( $ parts ) ; $ levels = [ ] ; for ( $ i = $ from ; $ i <= $ n ; $ i ++ ) { $ level = join ( '.' , array_slice ( $ parts , 0 , $ i ) ) ; $ levels [ ] = isset ( $ callback ) ? $ callback ( $ level ) : $ level ; } return $ levels ; } | Traverse through each level of the application env . |
25,852 | public function defineAbilities ( ) { $ this -> gate -> before ( function ( $ user , $ ability ) { if ( $ user -> isSuperuser ( ) ) return true ; } ) ; foreach ( $ this -> getPermissions ( ) as $ permission ) { $ this -> gate -> define ( $ permission -> name , function ( $ user ) use ( $ permission ) { return $ user -> hasPermission ( $ permission -> name ) ; } ) ; } } | Defines the Abilities for the application . |
25,853 | public function passesAuthorization ( ) { if ( ! $ this -> hasToBeAuthorized ( ) ) return true ; return $ this -> gate -> allows ( $ this -> route -> getName ( ) ) ; } | Authorizes a given route . |
25,854 | protected function hasToBeAuthorized ( ) { if ( in_array ( $ this -> route -> getName ( ) , self :: $ except ) ) return false ; return ( bool ) $ this -> route -> getName ( ) ; } | Determines if routes has to be authorized . |
25,855 | public static function typed ( string $ type , iterable $ input = [ ] ) : Stack { $ resolver = Resolver :: typed ( $ type ) ; return new static ( $ input , $ resolver ) ; } | Stack named constructor . |
25,856 | public function parseFile ( $ fileToParse ) { $ filename = $ this -> mdPath . $ fileToParse ; if ( file_exists ( $ filename ) ) { return $ this -> parse ( file_get_contents ( $ filename ) ) ; } throw new \ NachoNerd \ Silex \ Markdown \ Exceptions \ FileNotFound ( sprintf ( "File %s Not Found" , $ filename ) , 1 ) ; } | Parses the given file |
25,857 | public function getAllFiles ( ) { $ finder = new Finder ( ) ; return $ finder -> files ( ) -> name ( $ this -> filter ) -> in ( $ this -> mdPath ) ; } | Give All Files in directory given using filer given |
25,858 | public function getNLastFiles ( $ n ) { $ finder = new Finder ( ) ; $ finder -> files ( ) -> name ( $ this -> filter ) -> in ( $ this -> mdPath ) -> sortByModifiedTimeDesc ( ) ; return $ finder -> getNFirst ( $ n ) ; } | Give N Last Files in directory given using filer given |
25,859 | public function transactionsAction ( Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ changeLogFilter = $ this -> createForm ( StockChangeLogFilterType :: class , null , array ( 'action' => $ this -> generateUrl ( 'admin_warehouse_transactions' ) , 'method' => 'GET' , ) ) ; $ changeLogFilter -> handleRequest ( $ request ) ; $ filter = array ( ) ; $ filter [ 'product' ] = $ changeLogFilter -> get ( 'product' ) -> getData ( ) ; $ filter [ 'warehouse' ] = $ changeLogFilter -> get ( 'warehouse' ) -> getData ( ) ; $ qb = $ em -> getRepository ( StockChangeLog :: class ) -> findAllFilteredQB ( $ filter ) ; $ qb -> addOrderBy ( 'scl.id' , "DESC" ) ; $ paginator = $ this -> get ( 'knp_paginator' ) -> paginate ( $ qb , $ request -> query -> get ( 'page' , 1 ) , 20 ) ; return array ( 'form_filter' => $ changeLogFilter -> createView ( ) , 'paginator' => $ paginator , ) ; } | Lists all Warehouse entities . |
25,860 | public function showAction ( Warehouse $ warehouse ) { $ editForm = $ this -> createForm ( WarehouseType :: class , $ warehouse , array ( 'action' => $ this -> generateUrl ( 'admin_warehouse_update' , array ( 'id' => $ warehouse -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; $ deleteForm = $ this -> createDeleteForm ( $ warehouse -> getId ( ) , 'admin_warehouse_update' ) ; return array ( 'warehouse' => $ warehouse , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Finds and displays a Warehouse entity . |
25,861 | public function newAction ( ) { $ warehouse = new Warehouse ( ) ; $ form = $ this -> createForm ( WarehouseType :: class , $ warehouse ) ; return array ( 'warehouse' => $ warehouse , 'form' => $ form -> createView ( ) , ) ; } | Displays a form to create a new Warehouse entity . |
25,862 | public function createAction ( Request $ request ) { $ warehouse = new Warehouse ( ) ; $ form = $ this -> createForm ( WarehouseType :: class , $ warehouse ) ; if ( $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ warehouse ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_warehouse_show' , array ( 'id' => $ warehouse -> getId ( ) ) ) ) ; } return array ( 'warehouse' => $ warehouse , 'form' => $ form -> createView ( ) , ) ; } | Creates a new Warehouse entity . |
25,863 | public function updateAction ( Warehouse $ warehouse , Request $ request ) { $ editForm = $ this -> createForm ( new WarehouseType ( ) , $ warehouse , array ( 'action' => $ this -> generateUrl ( 'admin_warehouse_update' , array ( 'id' => $ warehouse -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; if ( $ editForm -> handleRequest ( $ request ) -> isValid ( ) ) { $ this -> getDoctrine ( ) -> getManager ( ) -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_warehouse_show' , array ( 'id' => $ warehouse -> getId ( ) ) ) ) ; } $ deleteForm = $ this -> createDeleteForm ( $ warehouse -> getId ( ) , 'admin_warehouse_delete' ) ; return array ( 'warehouse' => $ warehouse , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Edits an existing Warehouse entity . |
25,864 | final public function equals ( Enum $ enum = null ) { return $ enum !== null && $ this -> getValue ( ) === $ enum -> getValue ( ) && \ get_called_class ( ) === \ get_class ( $ enum ) ; } | Compares one Enum with another . |
25,865 | public static function fromKey ( $ name ) { foreach ( static :: values ( ) as $ key => $ enumInstance ) { if ( $ enumInstance -> getKey ( ) === $ name ) { return $ enumInstance ; } } return null ; } | Returns Enum by key |
25,866 | protected function addTasksNode ( ) { $ builder = new TreeBuilder ( ) ; $ node = $ builder -> root ( 'tasks' ) ; $ node -> isRequired ( ) -> requiresAtLeastOneElement ( ) -> useAttributeAsKey ( 'task' ) -> prototype ( 'array' ) -> children ( ) -> scalarNode ( 'description' ) -> defaultNull ( ) -> end ( ) -> arrayNode ( 'requires' ) -> useAttributeAsKey ( 'task' ) -> prototype ( 'scalar' ) -> end ( ) -> end ( ) -> append ( $ this -> addCommandsNode ( ) ) -> end ( ) -> end ( ) ; return $ node ; } | Returns the tasks node |
25,867 | protected function addArgumentsNode ( ) { $ builder = new TreeBuilder ( ) ; $ node = $ builder -> root ( 'arguments' ) ; $ node -> prototype ( 'variable' ) -> end ( ) ; return $ node ; } | Arguments that are passed to a command |
25,868 | protected function addOptionsNode ( ) { $ builder = new TreeBuilder ( ) ; $ node = $ builder -> root ( 'options' ) ; $ node -> prototype ( 'variable' ) -> end ( ) ; return $ node ; } | Options that are passed to a command |
25,869 | protected function validateOperations ( ) { $ errors = 0 ; foreach ( $ this -> operations as $ operation ) { $ operation -> setTransactionOperationSet ( $ this ) ; $ operation -> validate ( $ errors ) ; } } | Validate operations before applying |
25,870 | protected function runOperations ( ) { foreach ( $ this -> operations as $ operation ) { $ operation -> setTransactionOperationSet ( $ this ) ; $ operation -> runIfValid ( ) ; } } | Run operation these will be applied into DBMS |
25,871 | public function mapResult ( ResultIterator $ result , $ resultType = ArrayType :: BOTH ) { if ( $ result -> countRows ( ) == 0 ) return null ; $ this -> columnTypes = $ result -> getColumnTypes ( $ resultType ) ; if ( isset ( $ this -> resultMap ) ) $ this -> buildTypeHandlerList ( ) ; return $ this -> map ( $ result -> fetchArray ( $ resultType ) ) ; } | Returns a mapped array from a mysqli_result object |
25,872 | public static function handleError ( $ errno , $ errstr , $ errfile , $ errline , $ errcontext , $ isException = false ) { $ error = array ( 'number' => $ errno , 'desc' => $ errstr , 'file' => $ errfile , 'line' => $ errline , 'context' => $ errcontext , 'isException' => $ isException , ) ; $ handled = false ; if ( $ isException ) { $ handled = static :: call ( get_class ( $ errcontext ) , $ handled ) ; } if ( ! $ handled ) { static :: $ errors [ ] = $ error ; } } | Dient zum Handeln von PHP - Fehlern |
25,873 | public static function handleException ( $ exception ) { static :: handleError ( $ exception -> getCode ( ) , $ exception -> getMessage ( ) , $ exception -> getFile ( ) , $ exception -> getLine ( ) , $ exception , true ) ; } | Dient zum Handeln von Exceptions |
25,874 | public function addFormatter ( SymbolFormatterInterface $ formatter ) { if ( $ formatter instanceof self ) { $ this -> addFormatters ( $ formatter -> formatters ) ; } else { $ this -> formatters [ ] = $ formatter ; } return $ this ; } | Adds a formatter to the chain . |
25,875 | public function setMvcUrl ( $ controller = null , $ action = null , array $ params = [ ] ) { $ this -> mvcUrl = [ 'controller' => trim ( $ controller ) , 'action' => trim ( $ action ) , 'params' => $ params ] ; return $ this ; } | Define the MVC parameters of the url |
25,876 | public function setMvcParam ( string $ paramName , $ value = null ) { $ value = $ value === null ? null : trim ( $ value ) ; switch ( $ paramName ) { case 'controller' : case 'action' : $ this -> mvcUrl [ $ paramName ] = $ value ; break ; default : $ this -> mvcUrl [ 'params' ] [ $ paramName ] = $ value ; break ; } return $ this ; } | Define a MVC parameter individually |
25,877 | public function addScheme ( Route \ Scheme $ scheme ) { foreach ( $ scheme -> getPrefixes ( ) as $ prefix ) { $ this -> schemePrefixes [ $ prefix ] = $ scheme ; } foreach ( $ scheme -> getKeys ( ) as $ key ) { $ this -> schemeKeys [ $ key ] = $ scheme ; } } | Add a route scheme . |
25,878 | public function addPath ( $ route , array $ pattern , $ arity , $ priority = 5 ) { $ route = $ this -> validate ( $ route ) ; $ key = $ route -> __toString ( ) . '[' . $ arity . ']' ; if ( isset ( $ this -> paths [ $ key ] ) ) { if ( $ priority < $ this -> paths [ $ key ] [ 'priority' ] ) { return ; } } $ this -> paths [ $ key ] = [ 'pattern' => $ pattern , 'priority' => $ priority ] ; } | Add a path for a route . |
25,879 | public function getPathValidated ( Route \ Route $ route ) { $ parameters = $ route -> getParameters ( ) ; if ( count ( $ parameters ) ) { $ arity = '[' . count ( $ parameters ) . ']' ; } else { $ arity = '[0]' ; } $ key = $ route -> withoutAttributes ( ) -> __toString ( ) ; $ pattern = null ; if ( isset ( $ this -> paths [ $ key . $ arity ] ) ) { $ pattern = $ this -> paths [ $ key . $ arity ] [ 'pattern' ] ; } elseif ( isset ( $ this -> paths [ $ key . '[*]' ] ) ) { $ pattern = $ this -> paths [ $ key . '[*]' ] [ 'pattern' ] ; } $ path = $ route -> getPath ( $ pattern ) ; if ( ! isset ( $ path ) ) { throw new Route \ RouteException ( 'Could not find path for: ' . $ key . $ arity ) ; } return $ path ; } | Get path for a validated route . |
25,880 | public function getUri ( $ route , $ full = false ) { $ route = $ this -> validate ( $ route ) ; $ path = $ this -> getPathValidated ( $ route ) ; if ( is_string ( $ path ) ) { return new Message \ Uri ( $ path ) ; } if ( $ full ) { $ uri = $ this -> request -> getUri ( ) -> withPath ( $ this -> request -> pathToString ( $ path ) ) ; } else { $ uri = new Message \ Uri ( $ this -> request -> pathToString ( $ path ) ) ; } $ uri = $ uri -> withQuery ( $ this -> buildQuery ( $ route -> getQuery ( ) ) ) -> withFragment ( $ route -> getFragment ( ) ) ; return $ uri ; } | Get URI for a route . |
25,881 | public function applyPattern ( array $ pattern , array $ path ) { $ length = count ( $ pattern ) ; if ( $ length == 0 and count ( $ path ) > 0 ) { return null ; } if ( $ length < count ( $ path ) and $ pattern [ $ length - 1 ] != '**' and $ pattern [ $ length - 1 ] != ':*' ) { return null ; } $ parameters = [ ] ; foreach ( $ pattern as $ j => $ part ) { if ( $ part == '**' or $ part == ':*' ) { $ parameters = array_merge ( $ parameters , array_slice ( $ path , $ j ) ) ; break ; } elseif ( ! isset ( $ path [ $ j ] ) ) { return null ; } if ( $ path [ $ j ] == $ part ) { continue ; } if ( $ part == '*' ) { $ parameters [ ] = $ path [ $ j ] ; continue ; } if ( isset ( $ part [ 0 ] ) and $ part [ 0 ] == ':' ) { $ var = substr ( $ part , 1 ) ; if ( is_numeric ( $ var ) ) { $ parameters [ ( int ) $ var ] = $ path [ $ j ] ; } else { $ parameters [ $ var ] = $ path [ $ j ] ; } continue ; } return null ; } return $ parameters ; } | Apply a path pattern to a path . |
25,882 | public function findMatch ( array $ path , $ method ) { usort ( $ this -> patterns , [ 'Jivoo\Utilities' , 'prioritySorter' ] ) ; foreach ( $ this -> patterns as $ pattern ) { if ( $ pattern [ 'method' ] != 'ANY' and $ pattern [ 'method' ] != $ method ) { continue ; } $ parameters = $ this -> applyPattern ( $ pattern [ 'pattern' ] , $ path ) ; if ( isset ( $ parameters ) ) { return $ pattern [ 'route' ] -> withParameters ( $ parameters ) ; } } return null ; } | Find a route for a path . |
25,883 | public function redirectPath ( $ path , array $ query = [ ] , $ fragment = '' , $ permanent = false , $ rewrite = false ) { $ location = new Message \ Uri ( $ this -> request -> pathToString ( $ path , $ rewrite ) ) ; $ location = $ location -> withQuery ( $ this -> buildQuery ( $ query ) ) -> withFragment ( $ fragment ) ; return Message \ Response :: redirect ( $ location , $ permanent ) ; } | Create a path redirect . |
25,884 | public function redirect ( $ route , $ permanent = false ) { $ route = $ this -> validate ( $ route ) ; return $ this -> redirectPath ( $ this -> getPath ( $ route ) , $ route -> getQuery ( ) , $ route -> getFragment ( ) , $ permanent ) ; } | Create a route redirect . |
25,885 | public function refresh ( $ query = null , $ fragment = '' ) { if ( ! isset ( $ query ) ) { $ query = $ this -> request -> query ; } return $ this -> redirectPath ( $ this -> request -> path , $ query , $ fragment ) ; } | Create a refresh response . |
25,886 | public function authenticate ( IUser $ user ) { $ this -> app -> user -> setAttribute ( SessionKeys :: UserRole , $ user -> getRole ( ) ) ; $ this -> app -> user -> setAttribute ( SessionKeys :: UserConnected , $ user ) ; } | Authenticates a user from the given object . |
25,887 | public function HashUserPassword ( \ Puzzlout \ Framework \ BO \ F_user $ user ) { $ user -> setF_user_salt ( $ user -> F_user_password_is_hashed ( ) ? $ user -> F_user_salt ( ) : \ Puzzlout \ Framework \ Utility \ UUID :: v4 ( ) ) ; $ user -> setF_user_password ( $ this -> app -> security ( ) -> HashValue ( $ user -> F_user_salt ( ) , $ user -> F_user_password ( ) ) ) ; $ user -> setF_user_password_is_hashed ( 1 ) ; return $ user ; } | Retrieve the hash of the user password . |
25,888 | public function getAllAnonymousInstancesList ( SplObjectStorage $ instances ) { $ anonymousInstances = new SplObjectStorage ( ) ; foreach ( $ instances as $ instance ) { $ anonymousInstances -> addAll ( $ this -> getAnonymousAttachedInstances ( $ instance ) ) ; } return $ anonymousInstances ; } | This function will browse all instances passed in parameter and will return all anonymous instances bound to those objects . |
25,889 | public function registerMiddleware ( IMiddleware $ middleware ) : IOAuthClient { $ middleware -> setClient ( $ this ) ; foreach ( $ middleware :: statusCode ( ) as $ statusCode ) { $ this -> postRequestMiddlewares [ $ statusCode ] [ ] = $ middleware ; } return $ this ; } | Register the given middleware . |
25,890 | public function registerPreRequestMiddleware ( IPreRequestMiddleware $ middleware ) : IOAuthClient { $ this -> preRequestMiddlewares [ get_class ( $ middleware ) ] = $ middleware ; return $ this ; } | Register a pre request middleware |
25,891 | public function registerRefreshTokenMiddleware ( IRefreshTokenMiddleware $ middleware ) : IOAuthClient { $ middleware -> setClient ( $ this ) ; $ this -> refreshTokenMiddlewares [ get_class ( $ middleware ) ] = $ middleware ; return $ this ; } | Register a middleware to take care of refresh token |
25,892 | public function unregisterMiddleware ( IMiddleware $ middleware ) : IOAuthClient { $ middlewareClass = get_class ( $ middleware ) ; foreach ( $ middleware :: statusCode ( ) as $ statusCode ) { if ( ! isset ( $ this -> postRequestMiddlewares [ $ statusCode ] ) ) { continue ; } $ result = array_filter ( $ this -> postRequestMiddlewares [ $ statusCode ] , function ( IMiddleware $ currMiddleware ) use ( $ middlewareClass ) { return get_class ( $ currMiddleware ) != $ middlewareClass ; } ) ; if ( empty ( $ result ) ) { unset ( $ this -> postRequestMiddlewares [ $ statusCode ] ) ; } else { $ this -> postRequestMiddlewares [ $ statusCode ] = $ result ; } } return $ this ; } | Unregister the middleware . |
25,893 | private function processThrottleData ( ResponseInterface $ response ) { if ( empty ( $ rateLimit = $ response -> getHeader ( 'X-RateLimit-Limit' ) ) ) { return ; } if ( empty ( $ remaining = $ response -> getHeader ( 'X-RateLimit-Remaining' ) ) ) { return ; } if ( ! empty ( $ reset = $ response -> getHeader ( 'X-RateLimit-Reset' ) ) ) { $ this -> rateLimit -> setEndOfThrottle ( intval ( $ reset [ 0 ] ) ) ; } else { $ this -> rateLimit -> setEndOfThrottle ( null ) ; } $ this -> rateLimit -> setMaxPerMinute ( intval ( $ rateLimit [ 0 ] ) ) -> setRemaining ( intval ( $ remaining [ 0 ] ) ) ; } | Process the rate limit . |
25,894 | public static function stringLinesLimiter ( $ string , $ linesLimit , $ removeEmptyLines = false , $ stringLengthLimit = 189 , $ lineStringLengthLimit = 63 ) { $ lines = explode ( PHP_EOL , $ string ) ; if ( $ removeEmptyLines ) { for ( $ i = 0 ; $ i < count ( $ lines ) ; $ i ++ ) { $ element = trim ( self :: replaceNewlines ( $ lines [ $ i ] , '' ) ) ; if ( $ element == '' ) { unset ( $ lines [ $ i ] ) ; } } } $ stringLinesArray = array ( ) ; $ count = $ linesLimit ; $ charactersLeft = $ stringLengthLimit ; foreach ( $ lines as & $ line ) { $ line = self :: replaceNewlines ( $ line , '' ) ; if ( strlen ( $ line ) >= ( $ count * $ lineStringLengthLimit ) ) { $ stringLinesArray [ ] = self :: subString ( $ line , $ count * $ lineStringLengthLimit ) ; break ; } $ count = $ count - 1 ; if ( count ( $ lines ) > $ linesLimit && $ count < 1 ) { $ stringLinesArray [ ] = $ line . '...' ; } else { $ stringLinesArray [ ] = $ line ; } if ( $ count < 1 ) { break ; } } $ string = implode ( PHP_EOL , $ stringLinesArray ) ; return $ string ; } | Limits string to number of lines adds ... to the end |
25,895 | public function processPayment ( PaymillMethod $ paymentMethod , $ amount ) { $ paymentBridgeAmount = intval ( $ this -> paymentBridge -> getAmount ( ) ) ; if ( $ amount != $ paymentBridgeAmount ) { throw new PaymentAmountsNotMatchException ( sprintf ( 'Amounts differ. Requested: [%s] but in PaymentBridge: [%s].' , $ amount , $ paymentBridgeAmount ) ) ; } $ this -> paymentEventDispatcher -> notifyPaymentOrderLoad ( $ this -> paymentBridge , $ paymentMethod ) ; if ( ! $ this -> paymentBridge -> getOrder ( ) ) { throw new PaymentOrderNotFoundException ( ) ; } $ this -> paymentEventDispatcher -> notifyPaymentOrderCreated ( $ this -> paymentBridge , $ paymentMethod ) ; $ extraData = $ this -> paymentBridge -> getExtraData ( ) ; $ params = array ( 'amount' => $ paymentBridgeAmount , 'currency' => $ this -> paymentBridge -> getCurrency ( ) , 'token' => $ paymentMethod -> getApiToken ( ) , 'description' => $ extraData [ 'order_description' ] , ) ; try { $ transaction = $ this -> paymillTransactionWrapper -> create ( $ params [ 'amount' ] , $ params [ 'currency' ] , $ params [ 'token' ] , $ params [ 'description' ] ) ; } catch ( PaymillException $ e ) { $ transaction = new Transaction ( ) ; $ transaction -> setStatus ( 'failed' ) ; $ transaction -> setDescription ( $ e -> getCode ( ) . ' ' . $ e -> getMessage ( ) ) ; } $ this -> processTransaction ( $ transaction , $ paymentMethod ) ; return $ this ; } | Tries to process a payment through Paymill |
25,896 | private function processTransaction ( Transaction $ transaction , PaymillMethod $ paymentMethod ) { $ this -> paymentEventDispatcher -> notifyPaymentOrderDone ( $ this -> paymentBridge , $ paymentMethod ) ; $ transactionStatus = $ transaction -> getStatus ( ) ; if ( empty ( $ transactionStatus ) || $ transactionStatus != 'closed' ) { $ paymentMethod -> setTransaction ( $ transaction ) ; $ this -> paymentEventDispatcher -> notifyPaymentOrderFail ( $ this -> paymentBridge , $ paymentMethod ) ; throw new PaymentException ( ) ; } $ paymentMethod -> setTransactionId ( $ transaction -> getId ( ) ) -> setTransactionStatus ( $ transactionStatus ) -> setTransaction ( $ transaction ) ; $ this -> paymentEventDispatcher -> notifyPaymentOrderSuccess ( $ this -> paymentBridge , $ paymentMethod ) ; return $ this ; } | Given a paymillTransaction response as an array prform desired operations |
25,897 | static public function get ( $ apiManager , $ name ) { if ( ! array_key_exists ( $ name , self :: $ managerMap ) ) { throw new \ InvalidArgumentException ( 'Error in Factory Manager. This manager [' . $ name . ']is not supported' ) ; } $ className = self :: $ managerMap [ $ name ] ; return self :: factory ( $ apiManager , $ className ) ; } | get or create manager |
25,898 | public function add ( string $ content , string $ mimeType = null , $ encoding = null ) : void { $ contentPart = $ this -> make ( ) ; $ contentPart -> content = $ content ; if ( $ mimeType !== null ) { $ contentPart -> mimeType = $ mimeType ; } if ( $ encoding !== null ) { $ contentPart -> encoding = $ encoding ; } $ this -> set ( $ contentPart ) ; } | Add a content part . |
25,899 | static function atTime ( $ now , callable $ callback ) { if ( Clock :: isOverridden ( ) ) { $ previousOverride = Clock :: microtime ( ) ; } else { $ previousOverride = null ; } try { Clock :: override ( $ now ) ; return $ callback ( ) ; } finally { if ( $ previousOverride === null ) { Clock :: resume ( ) ; } else { Clock :: override ( $ previousOverride ) ; } } } | Override current time for the duration of the callback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.