idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
20,100 | private static function extractColorAndOptions ( $ colorCode ) { $ options = array ( ) ; foreach ( self :: $ options as $ name => $ bit ) { if ( ( $ colorCode & $ bit ) === $ bit ) { $ options [ ] = self :: $ codes [ $ bit ] ; $ colorCode = $ colorCode & ~ $ bit ; } } if ( ! isset ( self :: $ codes [ $ colorCode ] ) ) { throw new ConsoleException ( "Cannot parse color code" ) ; } return array ( self :: $ codes [ $ colorCode ] , $ options ) ; } | Extracts the options and the color from a color code |
20,101 | public function setSecret ( $ name , $ value , $ expire = 604800 , $ path = '/' , $ domain = '' ) { $ value = \ ePHP \ Hash \ Encrypt :: encryptG ( $ value , md5 ( $ _SERVER [ 'HTTP_HOST' ] . APP_PATH . SERVER_MODE ) ) ; $ this -> set ( $ name , $ value , $ expire , $ path , $ domain ) ; } | Set Secret cookie |
20,102 | public function getSecret ( $ name ) { $ value = $ this -> get ( $ name ) ; if ( empty ( $ value ) ) { return false ; } else { return \ ePHP \ Hash \ Encrypt :: decryptG ( $ value , md5 ( $ _SERVER [ 'HTTP_HOST' ] . APP_PATH . SERVER_MODE ) ) ; } } | Get Secret cookie |
20,103 | public function get ( int $ vehicleId , ? Query $ query = null ) : Response { $ this -> requiresAccessToken ( ) ; return $ this -> send ( 'GET' , "vehicles/{$vehicleId}" , $ this -> getApiHeaders ( ) , $ this -> buildHttpQuery ( $ query ) ) ; } | Show single vehicle . |
20,104 | public function update ( int $ vehicleId , array $ payload ) : Response { $ this -> requiresAccessToken ( ) ; return $ this -> sendJson ( 'PATCH' , "vehicles/{$vehicleId}" , $ this -> getApiHeaders ( ) , $ payload ) ; } | Update vehicle information . |
20,105 | public function registerDataTypeHandler ( DataTypeHandlerInterface $ handler ) { foreach ( $ handler -> supports ( ) as $ name ) { $ this -> handlers [ $ name ] = $ handler ; } } | Register data - type handler |
20,106 | protected function processHandlerToResource ( Attribute $ definition , $ value ) { $ type = $ definition -> getType ( ) ; $ handler = $ this -> handlers [ $ type ] ; $ parameters = $ definition -> getTypeParameters ( ) ; if ( ! $ definition -> isMany ( ) ) { return $ handler -> toResource ( $ value , $ type , $ parameters ) ; } if ( ! $ value instanceof \ Traversable && ! is_array ( $ value ) ) { throw new NotIterableAttribute ( $ definition , $ value ) ; } $ collection = [ ] ; foreach ( $ value as $ item ) { $ collection [ ] = $ handler -> toResource ( $ item , $ type , $ parameters ) ; } return $ collection ; } | Process value by registered data - type handler . From object to resource . |
20,107 | protected function processHandlerFromResource ( Attribute $ definition , $ value ) { $ type = $ definition -> getType ( ) ; $ handler = $ this -> handlers [ $ type ] ; $ parameters = $ definition -> getTypeParameters ( ) ; if ( ! $ definition -> isMany ( ) ) { return $ handler -> fromResource ( $ value , $ type , $ parameters ) ; } if ( ! $ value instanceof \ Traversable && ! is_array ( $ value ) ) { throw new NotIterableAttribute ( $ definition , $ value ) ; } $ collection = new \ ArrayObject ( ) ; foreach ( $ value as $ item ) { $ collection [ ] = $ handler -> fromResource ( $ item , $ type , $ parameters ) ; } return $ collection ; } | Process value by registered data - type handler . From resource to object . |
20,108 | public static function filterFieldList ( $ fieldsList , $ filters = array ( ) ) { $ result = array ( ) ; foreach ( $ fieldsList as $ field ) { if ( in_array ( $ field -> id , $ filters , true ) ) { $ result [ ] = $ field ; } } return $ result ; } | Filter a Fields List to keap only given Fields Ids |
20,109 | public static function filterFieldListByTag ( $ fieldsList , $ itemType , $ itemProp ) { $ result = array ( ) ; $ tag = md5 ( $ itemProp . IDSPLIT . $ itemType ) ; foreach ( $ fieldsList as $ field ) { if ( $ field -> tag !== $ tag ) { continue ; } if ( ( $ field -> itemtype !== $ itemType ) || ( $ field -> itemprop !== $ itemProp ) ) { continue ; } $ result [ ] = $ field ; } return $ result ; } | Filter a Fields List to keap only given Fields Tags |
20,110 | public static function reduceFieldList ( $ fieldsList , $ isRead = false , $ isWrite = false ) { $ result = array ( ) ; foreach ( $ fieldsList as $ field ) { if ( $ isRead && ! $ field -> read ) { continue ; } if ( $ isWrite && ! $ field -> write ) { continue ; } $ result [ ] = $ field -> id ; } return $ result ; } | Redure a Fields List to an Array of Field Ids |
20,111 | public static function isListField ( $ fieldType ) { if ( empty ( $ fieldType ) ) { return false ; } $ list = explode ( LISTSPLIT , $ fieldType ) ; if ( is_array ( $ list ) && ( 2 == count ( $ list ) ) ) { return array ( 'fieldname' => $ list [ 0 ] , 'listname' => $ list [ 1 ] ) ; } return false ; } | Check if this id is a list identifier |
20,112 | public static function fieldName ( $ listFieldName ) { $ result = self :: isListField ( $ listFieldName ) ; if ( empty ( $ result ) ) { return false ; } return $ result [ 'fieldname' ] ; } | Retrieve Field Identifier from an List Field String |
20,113 | public static function listName ( $ listFieldName ) { $ result = self :: isListField ( $ listFieldName ) ; if ( empty ( $ result ) ) { return false ; } return $ result [ 'listname' ] ; } | Retrieve List Name from an List Field String |
20,114 | public static function baseType ( $ fieldId ) { if ( self :: isListField ( $ fieldId ) ) { $ fieldId = self :: fieldName ( $ fieldId ) ; } if ( self :: isIdField ( ( string ) $ fieldId ) ) { $ fieldId = self :: objectType ( ( string ) $ fieldId ) ; } return $ fieldId ; } | Retrieve Base Field Type from Field Type|Id String |
20,115 | public static function isIdField ( $ fieldId ) { if ( empty ( $ fieldId ) ) { return false ; } $ list = explode ( IDSPLIT , $ fieldId ) ; if ( is_array ( $ list ) && ( 2 == count ( $ list ) ) ) { $ result [ 'ObjectId' ] = $ list [ 0 ] ; $ result [ 'ObjectType' ] = $ list [ 1 ] ; return $ result ; } return false ; } | Identify if field is Object Identifier Data & Decode Field |
20,116 | public static function objectId ( $ fieldId ) { $ result = self :: isIdField ( $ fieldId ) ; if ( empty ( $ result ) ) { return false ; } return $ result [ 'ObjectId' ] ; } | Retrieve Object Id Name from an Object Identifier String |
20,117 | public static function objectType ( $ fieldId ) { $ result = self :: isIdField ( $ fieldId ) ; if ( empty ( $ result ) ) { return false ; } return $ result [ 'ObjectType' ] ; } | Retrieve Object Type Name from an Object Identifier String |
20,118 | public static function extractRawData ( $ objectData , $ filter ) { $ filteredData = self :: filterData ( $ objectData , array ( $ filter ) ) ; $ isList = self :: isListField ( $ filter ) ; if ( ! $ isList ) { if ( isset ( $ filteredData [ $ filter ] ) ) { return $ filteredData [ $ filter ] ; } } else { if ( ! isset ( $ filteredData [ self :: listName ( $ filter ) ] ) ) { return null ; } $ result = array ( ) ; foreach ( $ filteredData [ self :: listName ( $ filter ) ] as $ key => $ item ) { $ result [ $ key ] = $ item [ self :: fieldName ( $ filter ) ] ; } return $ result ; } return null ; } | Extract Raw Field Data from an Object Data Block |
20,119 | public static function filterData ( $ objectData , $ filters = array ( ) ) { $ result = array ( ) ; $ listFilters = array ( ) ; foreach ( $ filters as $ fieldId ) { $ isList = self :: isListField ( $ fieldId ) ; if ( ( ! $ isList ) && ( array_key_exists ( $ fieldId , $ objectData ) ) ) { $ result [ $ fieldId ] = $ objectData [ $ fieldId ] ; } elseif ( ! $ isList ) { continue ; } $ listName = $ isList [ 'listname' ] ; $ fieldName = $ isList [ 'fieldname' ] ; if ( ! array_key_exists ( $ listName , $ objectData ) ) { continue ; } if ( ! array_key_exists ( $ listName , $ listFilters ) ) { $ listFilters [ $ listName ] = array ( ) ; } $ listFilters [ $ listName ] [ ] = $ fieldName ; } foreach ( $ listFilters as $ listName => $ listFilters ) { $ result [ $ listName ] = self :: filterListData ( $ objectData [ $ listName ] , $ listFilters ) ; } return $ result ; } | Filter a Object Data Block to keap only given Fields |
20,120 | public static function filterListData ( $ objectData , $ filters = array ( ) ) { $ result = array ( ) ; foreach ( $ objectData as $ fieldData ) { $ filteredItems = array ( ) ; if ( ! is_array ( $ fieldData ) && ! ( $ fieldData instanceof ArrayObject ) ) { continue ; } if ( $ fieldData instanceof ArrayObject ) { $ fieldData = $ fieldData -> getArrayCopy ( ) ; } foreach ( $ filters as $ fieldId ) { if ( array_key_exists ( $ fieldId , $ fieldData ) ) { $ filteredItems [ $ fieldId ] = $ fieldData [ $ fieldId ] ; } } $ result [ ] = $ filteredItems ; } return $ result ; } | Filter a Object List Data Block to keap only given Fields |
20,121 | public function setNeededAction ( $ neededAction ) { if ( ! in_array ( $ neededAction , static :: $ allowedNeededActions ) ) { throw new RuntimeException ( "Unknown needed action: '{$neededAction}'" ) ; } $ this -> neededAction = $ neededAction ; return $ this ; } | Set action needed after API method request ended |
20,122 | public function getError ( ) { if ( $ this -> isError ( ) || $ this -> isDeclined ( ) ) { return new PaynetException ( $ this -> getErrorMessage ( ) , $ this -> getErrorCode ( ) ) ; } else { throw new RuntimeException ( 'Response has no error' ) ; } } | Get response error as Exception instance |
20,123 | protected function getAnyKey ( array $ keys ) { foreach ( $ keys as $ key ) { $ value = $ this -> getValue ( $ key ) ; if ( ! is_null ( $ value ) ) { return $ value ; } } } | Get value of first key that exists in Response |
20,124 | public function loadToken ( $ token , $ validate = true , $ verify = true ) { $ token = $ this -> getParser ( ) -> parse ( ( string ) $ token ) ; if ( $ validate && ! $ this -> validateToken ( $ token ) ) { return null ; } if ( $ verify && ! $ this -> verifyToken ( $ token ) ) { return null ; } return $ token ; } | Parses the JWT and returns a token class |
20,125 | private static function _toArray ( $ data , $ recursion = false ) { $ tmp = array ( ) ; $ data = ( array ) $ data ; foreach ( $ data as $ k => $ v ) { $ v = ( array ) $ v ; if ( isset ( $ v [ 0 ] ) && is_string ( $ v [ 0 ] ) ) { $ tmp [ $ k ] = $ v [ 0 ] ; } else { $ tmp [ $ k ] = self :: _toArray ( $ v , true ) ; } } return $ tmp ; } | SimpleXMLElement to array |
20,126 | public static function find ( $ filename , $ dirs = array ( ) ) { if ( empty ( $ dirs ) ) { if ( $ filename = realpath ( $ filename ) ) { return $ filename ; } } else { foreach ( ( array ) $ dirs as $ dir ) { $ pathname = self :: join ( $ dir , $ filename ) ; if ( $ pathname = realpath ( $ pathname ) ) { return $ pathname ; } } } return false ; } | Finds the first file that match the filename in any of the specified directories . |
20,127 | public static function filterFiles ( $ args , $ allowWildcards = true ) { $ files = array ( ) ; foreach ( $ args as $ arg ) { if ( file_exists ( $ arg ) ) { $ files [ ] = $ arg ; } else if ( $ allowWildcards && strpos ( $ arg , '*' ) !== false ) { $ files = array_merge ( $ files , glob ( $ arg ) ) ; } } return $ files ; } | Extracts files from an array of args |
20,128 | public static function join ( $ path1 , $ path2 ) { $ ds = DIRECTORY_SEPARATOR ; return str_replace ( "$ds$ds" , $ ds , implode ( $ ds , array_filter ( func_get_args ( ) ) ) ) ; } | Joins paths together |
20,129 | public static function touch ( $ filename , $ content = '' ) { self :: mkdir ( dirname ( $ filename ) ) ; file_put_contents ( $ filename , $ content ) ; } | Creates a file and its directory |
20,130 | public static function computeFuncParams ( ReflectionFunctionAbstract $ reflection , array $ args , array $ options , $ needTagInDocComment = true ) { if ( $ needTagInDocComment && ! preg_match ( '/@compute-params/' , $ reflection -> getDocComment ( ) ) ) { return array ( $ args , $ options ) ; } $ nbRequiredParams = $ reflection -> getNumberOfRequiredParameters ( ) ; if ( count ( $ args ) < $ nbRequiredParams ) { throw new ConsoleException ( "Not enough parameters in '" . $ reflection -> getName ( ) . "'" ) ; } $ params = $ args ; if ( count ( $ args ) > $ nbRequiredParams ) { $ params = array_slice ( $ args , 0 , $ nbRequiredParams ) ; $ args = array_slice ( $ args , $ nbRequiredParams ) ; } foreach ( $ reflection -> getParameters ( ) as $ param ) { if ( $ param -> isOptional ( ) && substr ( $ param -> getName ( ) , 0 , 1 ) !== '_' ) { if ( array_key_exists ( $ param -> getName ( ) , $ options ) ) { $ params [ ] = $ options [ $ param -> getName ( ) ] ; unset ( $ options [ $ param -> getName ( ) ] ) ; } else { $ params [ ] = $ param -> getDefaultValue ( ) ; } } } $ params [ ] = $ args ; $ params [ ] = $ options ; return $ params ; } | Creates an array of parameters according to the function definition |
20,131 | private function initialize ( AbstractController $ controller ) { foreach ( $ this -> initializers as $ initializer ) { if ( $ initializer instanceof InitializerInterface ) { $ initializer -> initialize ( $ controller , $ this ) ; } else { call_user_func ( $ initializer , $ controller , $ this ) ; } } } | injects Zend core services into the given controller |
20,132 | public function tell ( ) : int { if ( ! \ is_resource ( $ this -> resource ) ) { throw new Exception \ UntellableStreamException ( 'Stream is not resourceable' ) ; } $ result = \ ftell ( $ this -> resource ) ; if ( false === $ result ) { throw new Exception \ UntellableStreamException ( 'Unable to get the stream pointer position' ) ; } return $ result ; } | Gets the stream pointer position |
20,133 | public function isSeekable ( ) : bool { if ( ! \ is_resource ( $ this -> resource ) ) { return false ; } $ metadata = \ stream_get_meta_data ( $ this -> resource ) ; return $ metadata [ 'seekable' ] ; } | Checks if the stream is seekable |
20,134 | public function rewind ( ) : void { if ( ! \ is_resource ( $ this -> resource ) ) { throw new Exception \ UnseekableStreamException ( 'Stream is not resourceable' ) ; } if ( ! $ this -> isSeekable ( ) ) { throw new Exception \ UnseekableStreamException ( 'Stream is not seekable' ) ; } $ result = \ fseek ( $ this -> resource , 0 , \ SEEK_SET ) ; if ( ! ( 0 === $ result ) ) { throw new Exception \ UnseekableStreamException ( 'Unable to move the stream pointer to beginning' ) ; } } | Moves the stream pointer to begining |
20,135 | public function seek ( $ offset , $ whence = \ SEEK_SET ) : void { if ( ! \ is_resource ( $ this -> resource ) ) { throw new Exception \ UnseekableStreamException ( 'Stream is not resourceable' ) ; } if ( ! $ this -> isSeekable ( ) ) { throw new Exception \ UnseekableStreamException ( 'Stream is not seekable' ) ; } $ result = \ fseek ( $ this -> resource , $ offset , $ whence ) ; if ( ! ( 0 === $ result ) ) { throw new Exception \ UnseekableStreamException ( 'Unable to move the stream pointer to the given position' ) ; } } | Moves the stream pointer to the given position |
20,136 | public function isWritable ( ) : bool { if ( ! \ is_resource ( $ this -> resource ) ) { return false ; } $ metadata = \ stream_get_meta_data ( $ this -> resource ) ; return ! ( false === \ strpbrk ( $ metadata [ 'mode' ] , '+acwx' ) ) ; } | Checks if the stream is writable |
20,137 | public function write ( $ string ) : int { if ( ! \ is_resource ( $ this -> resource ) ) { throw new Exception \ UnwritableStreamException ( 'Stream is not resourceable' ) ; } if ( ! $ this -> isWritable ( ) ) { throw new Exception \ UnwritableStreamException ( 'Stream is not writable' ) ; } $ result = \ fwrite ( $ this -> resource , $ string ) ; if ( false === $ result ) { throw new Exception \ UnwritableStreamException ( 'Unable to write to the stream' ) ; } return $ result ; } | Writes the given string to the stream |
20,138 | public function read ( $ length ) : string { if ( ! \ is_resource ( $ this -> resource ) ) { throw new Exception \ UnreadableStreamException ( 'Stream is not resourceable' ) ; } if ( ! $ this -> isReadable ( ) ) { throw new Exception \ UnreadableStreamException ( 'Stream is not readable' ) ; } $ result = \ fread ( $ this -> resource , $ length ) ; if ( false === $ result ) { throw new Exception \ UnreadableStreamException ( 'Unable to read from the stream' ) ; } return $ result ; } | Reads the given number of bytes from the stream |
20,139 | public function getContents ( ) : string { if ( ! \ is_resource ( $ this -> resource ) ) { throw new Exception \ UnreadableStreamException ( 'Stream is not resourceable' ) ; } if ( ! $ this -> isReadable ( ) ) { throw new Exception \ UnreadableStreamException ( 'Stream is not readable' ) ; } $ result = \ stream_get_contents ( $ this -> resource ) ; if ( false === $ result ) { throw new Exception \ UnreadableStreamException ( 'Unable to read remainder of the stream' ) ; } return $ result ; } | Reads remainder of the stream |
20,140 | public function getMetadata ( $ key = null ) { if ( ! \ is_resource ( $ this -> resource ) ) { return null ; } $ metadata = \ stream_get_meta_data ( $ this -> resource ) ; if ( ! ( null === $ key ) ) { return $ metadata [ $ key ] ?? null ; } return $ metadata ; } | Gets the stream metadata |
20,141 | public function getSize ( ) : ? int { if ( ! \ is_resource ( $ this -> resource ) ) { return null ; } $ stats = \ fstat ( $ this -> resource ) ; if ( false === $ stats ) { return null ; } return $ stats [ 'size' ] ; } | Gets the stream size |
20,142 | public function executeHello ( array $ args , array $ options = array ( ) ) { $ name = 'unknown' ; if ( empty ( $ args ) ) { $ dialog = new Dialog ( $ this -> console ) ; $ name = $ dialog -> ask ( 'What is your name?' , $ name ) ; } else { $ name = $ args [ 0 ] ; } $ this -> writeln ( sprintf ( 'hello %s!' , $ name ) ) ; } | Says hello to someone |
20,143 | protected function filterPort ( $ port ) { if ( empty ( $ port ) ) { return null ; } if ( ! self :: validePort ( $ port ) ) { throw new \ InvalidArgumentException ( 'The port is not in the TCP/UDP port.' ) ; } return $ this -> scheme !== '' && ! $ this -> validPortStandard ( $ port ) ? ( int ) $ port : null ; } | Filtre un port . |
20,144 | protected function filterFragment ( $ fragment ) { $ fragmentStr = $ this -> filterString ( $ fragment ) ; $ fragmentDecode = rawurldecode ( $ fragmentStr ) ; return rawurlencode ( ltrim ( $ fragmentDecode , '#' ) ) ; } | Filtre une ancre . |
20,145 | protected function filterPath ( $ path ) { $ pathStr = $ this -> filterString ( $ path ) ; $ pathDecode = rawurldecode ( $ pathStr ) ; $ dataPath = array_map ( function ( $ value ) { return rawurlencode ( $ value ) ; } , explode ( '/' , $ pathDecode ) ) ; return implode ( '/' , $ dataPath ) ; } | Filtre un chemin . |
20,146 | protected function validPortStandard ( $ port ) { return in_array ( $ port , $ this -> ports ) && $ this -> scheme === array_keys ( $ this -> ports , $ port ) [ 0 ] ; } | Si le port est prise en charge . |
20,147 | public function migrate ( ) { $ table = 'fe_users' ; $ column = 'siteid' ; $ this -> msg ( sprintf ( 'Adding "%1$s" column to "%2$s" table' , $ column , $ table ) , 0 ) ; $ schema = $ this -> getSchema ( 'db-customer' ) ; if ( isset ( $ this -> migrate [ $ schema -> getName ( ) ] ) && $ schema -> tableExists ( $ table ) === true && $ schema -> columnExists ( $ table , $ column ) === false ) { foreach ( $ this -> migrate [ $ schema -> getName ( ) ] as $ stmt ) { $ this -> execute ( $ stmt ) ; } $ this -> status ( 'done' ) ; } else { $ this -> status ( 'OK' ) ; } } | Add column siteid to fe_users table . |
20,148 | private function getDefinitionsFilePath ( array $ config ) { $ filePath = __DIR__ . '/../../../../../../../config/php-di.config.php' ; if ( isset ( $ config [ 'definitionsFile' ] ) ) { $ filePath = $ config [ 'definitionsFile' ] ; } if ( ! file_exists ( $ filePath ) ) { throw new \ Exception ( 'DI definitions file missing.' ) ; } return $ filePath ; } | return definitions file path |
20,149 | public function clearCacheAction ( ) { $ cache = $ this -> serviceLocator -> get ( 'DiCache' ) ; if ( $ cache instanceof FlushableCache ) { $ cache -> flushAll ( ) ; } echo "PHP DI definitions cache was cleared." . PHP_EOL . PHP_EOL ; } | flushes php di definitions cache |
20,150 | protected function errorsToArray ( ) : array { $ errors = [ ] ; foreach ( $ this -> errors as $ error ) { $ errors [ ] = $ error -> toArray ( ) ; } return $ errors ; } | Cast errors to an array |
20,151 | public function addUploads ( EntityInterface $ entity , array $ uploads ) { $ attachments = [ ] ; foreach ( $ uploads as $ path => $ tags ) { if ( ! ( array_keys ( $ uploads ) !== range ( 0 , count ( $ uploads ) - 1 ) ) ) { $ path = $ tags ; $ tags = [ ] ; } $ file = Configure :: read ( 'Attachments.tmpUploadsPath' ) . $ path ; $ attachment = $ this -> createAttachmentEntity ( $ entity , $ file , $ tags ) ; $ this -> save ( $ attachment ) ; $ attachments [ ] = $ attachment ; } $ entity -> attachments = $ attachments ; } | Takes the array from the attachments area hidden form field and creates attachment records for the given entity |
20,152 | public function addUpload ( EntityInterface $ entity , $ upload ) { $ tags = [ ] ; $ path = $ upload ; if ( is_array ( $ upload ) ) { $ tags = reset ( $ upload ) ; $ path = reset ( array_flip ( $ upload ) ) ; } $ file = Configure :: read ( 'Attachments.tmpUploadsPath' ) . $ path ; $ attachment = $ this -> createAttachmentEntity ( $ entity , $ file , $ tags ) ; $ save = $ this -> save ( $ attachment ) ; if ( $ save ) { return $ attachment ; } return $ save ; } | Save one Attachemnt |
20,153 | public function afterSave ( Event $ event , Attachment $ attachment , \ ArrayObject $ options ) { if ( $ attachment -> tmpPath ) { $ folder = new Folder ( ) ; $ targetDir = Configure :: read ( 'Attachments.path' ) . dirname ( $ attachment -> filepath ) ; if ( ! $ folder -> create ( $ targetDir ) ) { throw new \ Exception ( "Folder {$targetDir} could not be created." ) ; } $ targetPath = Configure :: read ( 'Attachments.path' ) . $ attachment -> filepath ; if ( ! rename ( $ attachment -> tmpPath , $ targetPath ) ) { throw new \ Exception ( "Temporary file {$attachment->tmpPath} could not be moved to {$attachment->filepath}" ) ; } $ attachment -> tmpPath = null ; } } | afterSave Event . If an attachment entity has its tmpPath value set it will be moved to the defined filepath |
20,154 | public function createAttachmentEntity ( EntityInterface $ entity , $ filePath , array $ tags = [ ] ) { if ( ! file_exists ( $ filePath ) ) { throw new \ Exception ( "File {$filePath} does not exist." ) ; } if ( ! is_readable ( $ filePath ) ) { throw new \ Exception ( "File {$filePath} cannot be read." ) ; } $ file = new File ( $ filePath ) ; $ info = $ file -> info ( ) ; $ info = $ this -> __getFileName ( $ info , $ entity ) ; $ targetPath = $ entity -> source ( ) . '/' . $ entity -> id . '/' . $ info [ 'basename' ] ; $ attachment = $ this -> newEntity ( [ 'model' => $ entity -> source ( ) , 'foreign_key' => $ entity -> id , 'filename' => $ info [ 'basename' ] , 'filesize' => $ info [ 'filesize' ] , 'filetype' => $ info [ 'mime' ] , 'filepath' => $ targetPath , 'tmpPath' => $ filePath , 'tags' => $ tags ] ) ; return $ attachment ; } | Creates an Attachment entity based on the given file |
20,155 | private function __getFileName ( $ fileInfo , EntityInterface $ entity , $ id = 0 ) { if ( ! file_exists ( Configure :: read ( 'Attachments.path' ) . $ entity -> source ( ) . '/' . $ entity -> id . '/' . $ fileInfo [ 'basename' ] ) ) { return $ fileInfo ; } $ fileInfo [ 'basename' ] = $ fileInfo [ 'filename' ] . ' (' . ++ $ id . ').' . $ fileInfo [ 'extension' ] ; return $ this -> __getFileName ( $ fileInfo , $ entity , $ id ) ; } | recursive method to increase the filename in case the file already exists |
20,156 | public function hydrate ( $ source ) : AbstractDocument { if ( ! isset ( $ source -> data ) ) { return $ this -> processNoDataDocument ( $ source ) ; } if ( is_object ( $ source -> data ) ) { return $ this -> processSingleResourceDocument ( $ source ) ; } if ( is_array ( $ source -> data ) ) { return $ this -> processResourceCollectionDocument ( $ source ) ; } throw new InvalidDocumentException ( 'If data is present and is not null it must be an object or an array' ) ; } | Hydrate source to a document |
20,157 | protected function processNoDataDocument ( $ source ) : NoDataDocument { $ document = new NoDataDocument ( ) ; $ this -> hydrateObject ( $ document , $ source ) ; return $ document ; } | Process document contains no data |
20,158 | protected function processSingleResourceDocument ( $ source ) : SingleResourceDocument { $ resource = $ this -> hydrateResource ( $ source -> data ) ; $ document = new SingleResourceDocument ( $ resource ) ; $ this -> hydrateObject ( $ document , $ source ) ; return $ document ; } | Process document with single resource |
20,159 | protected function processResourceCollectionDocument ( $ source ) : ResourceCollectionDocument { $ document = new ResourceCollectionDocument ( ) ; foreach ( $ source -> data as $ resourceSrc ) { $ document -> addResource ( $ this -> hydrateResource ( $ resourceSrc ) ) ; } $ this -> hydrateObject ( $ document , $ source ) ; return $ document ; } | Process document with collection of resources |
20,160 | public function send ( $ first , $ last , $ email , $ message ) { $ quote = nl2br ( $ message ) ; $ name = $ first . ' ' . $ last ; $ this -> sendMessage ( $ name , $ email , $ quote ) ; $ this -> sendThanks ( $ first , $ email , $ quote ) ; } | Send the emails . |
20,161 | protected function streamToDocument ( StreamInterface $ stream ) : AbstractDocument { $ content = $ stream -> getContents ( ) ; $ decoded = json_decode ( $ content ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new \ RuntimeException ( 'Decoding error: "' . json_last_error_msg ( ) . '""' ) ; } return $ this -> hydrator -> hydrate ( $ decoded ) ; } | Create a JsonApi document by serialized data from stream |
20,162 | protected function documentToStream ( AbstractDocument $ document ) : StreamInterface { $ encoded = json_encode ( $ document -> toArray ( ) ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new \ RuntimeException ( 'Encoding error: "' . json_last_error_msg ( ) . '""' ) ; } $ stream = fopen ( 'php://memory' , 'r+' ) ; fwrite ( $ stream , $ encoded ) ; fseek ( $ stream , 0 ) ; return new Stream ( $ stream ) ; } | Create a stream contains serialized JsonApi - document |
20,163 | protected function getId ( $ id = null ) { $ id = ( empty ( $ id ) ) ? $ this -> resourceId : $ id ; if ( empty ( $ id ) ) { throw new \ Exception ( 'Invalid id supplied [' . $ id . ']. Operation requires valid resource id.' ) ; } return $ id ; } | Determines the resource id to use . |
20,164 | protected function request ( $ verb , $ path , $ resource = '' , array $ payload = [ ] ) { return $ this -> client -> request ( $ verb , $ path , $ this -> resourceType , $ resource , $ payload , $ this -> headers ) ; } | Makes the request for resources |
20,165 | public function render ( ) { require_once 'functions_include.php' ; $ block = [ ] ; foreach ( $ this -> blocks as $ key => & $ subTpl ) { $ block [ $ key ] = ! is_null ( $ subTpl ) ? $ this -> filter ( 'block.' . $ key , $ subTpl -> render ( ) ) : '' ; } foreach ( $ this -> vars as $ key => $ value ) { $ $ key = $ this -> filter ( 'var.' . $ key , $ value ) ; } ob_start ( ) ; require $ this -> path . $ this -> name ; $ html = ob_get_clean ( ) ; return $ this -> filter ( 'output' , $ html ) ; } | Compile la template ses sous templates et ses variables . |
20,166 | public function migrate ( ) { $ this -> msg ( 'Remove left over TYPO3 fe_users references' , 0 , '' ) ; foreach ( $ this -> sql as $ table => $ stmt ) { $ this -> msg ( sprintf ( 'Remove unused %1$s records' , $ table ) , 1 ) ; if ( $ this -> schema -> tableExists ( 'fe_users' ) && $ this -> schema -> tableExists ( $ table ) ) { $ this -> execute ( $ stmt ) ; $ this -> status ( 'done' ) ; } else { $ this -> status ( 'OK' ) ; } } } | Migrate database schema |
20,167 | public function group ( $ name , $ balise , callable $ callback , $ attr = null ) { $ form = new FormBuilder ( [ ] ) ; call_user_func_array ( $ callback , [ & $ form ] ) ; $ group = $ this -> merge_attr ( [ 'balise' => $ balise ] , $ attr ) ; return $ this -> input ( $ name , [ 'type' => 'group' , 'subform' => $ form , 'attr' => $ group ] ) ; } | Enregistre un groupe d input . |
20,168 | public function label ( $ name , $ label , array $ attr = null ) { return $ this -> input ( $ name , [ 'type' => 'label' , 'label' => $ label , 'attr' => $ attr ] ) ; } | Enregistre un label . |
20,169 | public function legend ( $ name , $ legend , array $ attr = null ) { return $ this -> input ( $ name , [ 'type' => 'legend' , 'legend' => $ legend , 'attr' => $ attr ] ) ; } | Enregistre une legende . |
20,170 | public function textarea ( $ name , $ id , $ content = '' , array $ attr = null ) { $ basic = $ this -> merge_attr ( [ 'id' => $ id ] , $ attr ) ; return $ this -> input ( $ name , [ 'id' => $ id , 'type' => 'textarea' , 'content' => $ content , 'attr' => $ basic ] ) ; } | Enregistre un textarea . |
20,171 | public function inputBasic ( $ type , $ name , $ id , array $ attr = null ) { $ basic = $ this -> merge_attr ( [ 'id' => $ id ] , $ attr ) ; return $ this -> input ( $ name , [ 'type' => $ type , 'attr' => $ basic ] ) ; } | Enregistre un input standard . |
20,172 | public function submit ( $ name , $ value , array $ attr = null ) { $ basic = $ this -> merge_attr ( [ 'value' => $ value ] , $ attr ) ; return $ this -> input ( $ name , [ 'type' => 'submit' , 'attr' => $ basic ] ) ; } | Enregistre un submit . |
20,173 | protected function input ( $ name , array $ attr ) { $ previous = end ( $ this -> form ) ; if ( $ previous && $ previous [ 'type' ] == 'label' && ! isset ( $ previous [ 'attr' ] [ 'for' ] ) && isset ( $ attr [ 'attr' ] [ 'id' ] ) ) { $ this -> form [ key ( $ this -> form ) ] [ 'attr' ] [ 'for' ] = $ attr [ 'attr' ] [ 'id' ] ; } $ this -> form [ $ name ] = $ attr ; return $ this ; } | Enregistre un input . |
20,174 | protected function getAttributesCSS ( array $ attr ) { $ output = [ ] ; foreach ( $ attr as $ key => $ values ) { if ( in_array ( $ key , $ this -> attributesCss ) && $ values !== '' ) { $ output [ ] = $ key . '="' . $ values . '"' ; } } $ implode = implode ( ' ' , $ output ) ; return $ implode ? " $implode" : '' ; } | Met en forme les attributs CSS pour les balises . |
20,175 | protected function getAttributesInput ( array $ attr ) { $ output = [ ] ; foreach ( $ attr as $ key => $ values ) { if ( empty ( $ values ) ) { continue ; } if ( in_array ( $ key , $ this -> attributesUnique ) ) { $ output [ ] = $ key ; } elseif ( ! in_array ( $ key , $ this -> attributesCss ) && $ key !== 'selected' ) { $ output [ ] = $ key . '="' . $ values . '"' ; } } $ implode = implode ( ' ' , $ output ) ; return $ implode ? " $implode" : '' ; } | Met en forme les attributs pour les balises inputs standards . |
20,176 | protected function getSize ( $ value ) { if ( is_numeric ( $ value ) ) { return $ value + 0 ; } if ( is_string ( $ value ) ) { return strlen ( $ value ) ; } if ( is_array ( $ value ) ) { return count ( $ value ) ; } if ( $ value instanceof UploadedFileInterface ) { if ( $ value -> getError ( ) !== UPLOAD_ERR_OK ) { return 0 ; } return $ value -> getStream ( ) -> getSize ( ) ; } if ( is_resource ( $ value ) ) { $ stats = fstat ( $ value ) ; return isset ( $ stats [ 'size' ] ) ? $ stats [ 'size' ] : 0 ; } if ( is_object ( $ value ) && method_exists ( $ value , '__toString' ) ) { return strlen ( ( string ) $ value ) ; } throw new \ InvalidArgumentException ( 'The between function can not test this type of value.' ) ; } | Retourne la longueur de valeur en fonction de son type . |
20,177 | public function format ( $ bytes , $ precision = null ) { $ precision === null && $ precision = $ this -> getPrecision ( ) ; $ log = log ( $ bytes , $ this -> getBase ( ) ) ; $ exponent = $ this -> hasFixedExponent ( ) ? $ this -> getFixedExponent ( ) : max ( 0 , $ log | 0 ) ; $ value = round ( pow ( $ this -> getBase ( ) , $ log - $ exponent ) , $ precision ) ; $ units = $ this -> getUnitDecorator ( ) -> decorate ( $ exponent , $ this -> getBase ( ) , $ value ) ; return trim ( sprintf ( $ this -> sprintfFormat , $ this -> formatValue ( $ value , $ precision ) , $ units ) ) ; } | Formats the specified number of bytes as a human - readable string . |
20,178 | private function formatValue ( $ value , $ precision ) { $ formatted = sprintf ( "%0.${precision}F" , $ value ) ; if ( $ this -> hasAutomaticPrecision ( ) ) { $ formattedParts = explode ( '.' , $ formatted ) ; if ( isset ( $ formattedParts [ 1 ] ) ) { if ( ! $ formattedParts [ 1 ] = chop ( $ formattedParts [ 1 ] , '0' ) ) { unset ( $ formattedParts [ 1 ] ) ; } $ formatted = join ( '.' , $ formattedParts ) ; } } return $ formatted ; } | Formats the specified number with the specified precision . |
20,179 | protected function relationshipsToArray ( ) : array { $ relationships = [ ] ; foreach ( $ this -> relationships as $ name => $ relationship ) { $ relationships [ $ name ] = $ relationship -> toArray ( ) ; } return $ relationships ; } | Cast relationships to an array |
20,180 | protected function dispatchOnRequest ( RequestInterface $ request ) : RequestInterface { $ requestEvent = new RequestEvent ( $ request ) ; $ this -> dispatcher -> dispatch ( $ this -> requestEvent , $ requestEvent ) ; return $ requestEvent -> getRequest ( ) ; } | Dispatch on - request event |
20,181 | protected function dispatchOnResponse ( ResponseInterface $ response ) : ResponseInterface { $ responseEvent = new ResponseEvent ( $ response ) ; $ this -> dispatcher -> dispatch ( $ this -> responseEvent , $ responseEvent ) ; return $ responseEvent -> getResponse ( ) ; } | Dispatch on - response event |
20,182 | public function saveItem ( \ Aimeos \ MShop \ Common \ Item \ Iface $ item , $ fetch = true ) { self :: checkClass ( \ Aimeos \ MShop \ Customer \ Item \ Group \ Iface :: class , $ item ) ; if ( ! $ item -> isModified ( ) ) { return $ item ; } $ context = $ this -> getContext ( ) ; $ dbm = $ context -> getDatabaseManager ( ) ; $ dbname = $ this -> getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ id = $ item -> getId ( ) ; if ( $ id === null ) { $ path = 'mshop/customer/manager/group/typo3/insert' ; } else { $ path = 'mshop/customer/manager/group/typo3/update' ; } $ stmt = $ this -> getCachedStatement ( $ conn , $ path ) ; $ stmt -> bind ( 1 , $ this -> pid , \ Aimeos \ MW \ DB \ Statement \ Base :: PARAM_INT ) ; $ stmt -> bind ( 2 , $ item -> getCode ( ) ) ; $ stmt -> bind ( 3 , $ item -> getLabel ( ) ) ; $ stmt -> bind ( 4 , time ( ) , \ Aimeos \ MW \ DB \ Statement \ Base :: PARAM_INT ) ; if ( $ id !== null ) { $ stmt -> bind ( 5 , $ id , \ Aimeos \ MW \ DB \ Statement \ Base :: PARAM_INT ) ; $ item -> setId ( $ id ) ; } else { $ stmt -> bind ( 5 , time ( ) ) ; } $ stmt -> execute ( ) -> finish ( ) ; if ( $ id === null && $ fetch === true ) { $ path = 'mshop/customer/manager/group/typo3/newid' ; $ item -> setId ( $ this -> newId ( $ conn , $ path ) ) ; } $ dbm -> release ( $ conn , $ dbname ) ; } catch ( \ Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } return $ item ; } | Inserts a new or updates an existing customer group item |
20,183 | public function process ( \ ReflectionClass $ reflection , Definition $ definition ) { foreach ( $ reflection -> getProperties ( ) as $ property ) { $ this -> processProperty ( $ property , $ definition ) ; } } | Process properties of class |
20,184 | protected function handleDataControl ( RelationshipAnnotation $ annotation , Relationship $ relationship ) { $ relationship -> setIncludeData ( $ annotation -> dataAllowed ) ; $ relationship -> setDataLimit ( $ annotation -> dataLimit ) ; } | Handle control of data - section |
20,185 | protected function resolveType ( RelationshipAnnotation $ annotation ) : int { if ( $ annotation -> type === RelationshipAnnotation :: TYPE_ONE ) { return Relationship :: TYPE_X_TO_ONE ; } if ( $ annotation -> type === RelationshipAnnotation :: TYPE_MANY ) { return Relationship :: TYPE_X_TO_MANY ; } throw new \ LogicException ( sprintf ( 'Invalid type of relation "%s" defined.' , $ annotation -> type ) ) ; } | Resolve type of relationship |
20,186 | public function addCommand ( $ callback , $ alias = null , $ default = false ) { if ( $ alias instanceof \ Closure && is_string ( $ callback ) ) { list ( $ alias , $ callback ) = array ( $ callback , $ alias ) ; } if ( is_array ( $ callback ) && is_string ( $ callback [ 0 ] ) ) { $ callback = implode ( '::' , $ callback ) ; } $ name = '' ; if ( is_string ( $ callback ) ) { $ name = $ callback ; if ( is_callable ( $ callback ) ) { if ( strpos ( $ callback , '::' ) !== false ) { list ( $ classname , $ methodname ) = explode ( '::' , $ callback ) ; $ name = Utils :: dashized ( $ methodname ) ; } else { $ name = strtolower ( trim ( str_replace ( '_' , '-' , $ name ) , '-' ) ) ; } } else { if ( substr ( $ name , - 7 ) === 'Command' ) { $ name = substr ( $ name , 0 , - 7 ) ; } $ name = Utils :: dashized ( basename ( str_replace ( '\\' , '/' , $ name ) ) ) ; } } else if ( is_object ( $ callback ) && ! ( $ callback instanceof Closure ) ) { $ classname = get_class ( $ callback ) ; if ( ! ( $ callback instanceof Command ) ) { throw new ConsoleException ( "'$classname' must inherit from 'ConsoleKit\Command'" ) ; } if ( substr ( $ classname , - 7 ) === 'Command' ) { $ classname = substr ( $ classname , 0 , - 7 ) ; } $ name = Utils :: dashized ( basename ( str_replace ( '\\' , '/' , $ classname ) ) ) ; } else if ( ! $ alias ) { throw new ConsoleException ( "Commands using closures must have an alias" ) ; } $ name = $ alias ? : $ name ; $ this -> commands [ $ name ] = $ callback ; if ( $ default ) { $ this -> defaultCommand = $ name ; } return $ this ; } | Registers a command |
20,187 | public function addCommandsFromDir ( $ dir , $ namespace = '' , $ includeFiles = false ) { foreach ( new DirectoryIterator ( $ dir ) as $ file ) { $ filename = $ file -> getFilename ( ) ; if ( $ file -> isDir ( ) || substr ( $ filename , 0 , 1 ) === '.' || strlen ( $ filename ) <= 11 || strtolower ( substr ( $ filename , - 11 ) ) !== 'command.php' ) { continue ; } if ( $ includeFiles ) { include $ file -> getPathname ( ) ; } $ className = trim ( $ namespace . '\\' . substr ( $ filename , 0 , - 4 ) , '\\' ) ; $ this -> addCommand ( $ className ) ; } return $ this ; } | Registers commands from a directory |
20,188 | public function writeln ( $ text = '' , $ pipe = TextWriter :: STDOUT ) { $ this -> textWriter -> writeln ( $ text , $ pipe ) ; return $ this ; } | Writes a line of text |
20,189 | public function writeException ( \ Exception $ e ) { if ( $ this -> verboseException ) { $ text = sprintf ( "[%s]\n%s\nIn %s at line %s\n%s" , get_class ( $ e ) , $ e -> getMessage ( ) , $ e -> getFile ( ) , $ e -> getLine ( ) , $ e -> getTraceAsString ( ) ) ; } else { $ text = sprintf ( "\n[%s]\n%s\n" , get_class ( $ e ) , $ e -> getMessage ( ) ) ; } $ box = new Widgets \ Box ( $ this -> textWriter , $ text , '' ) ; $ out = Colors :: colorizeLines ( $ box , Colors :: WHITE , Colors :: RED ) ; $ out = TextFormater :: apply ( $ out , array ( 'indent' => 2 ) ) ; $ this -> textWriter -> writeln ( $ out ) ; return $ this ; } | Writes an error message to stderr |
20,190 | protected function validatePaymentTransaction ( PaymentTransaction $ paymentTransaction ) { $ this -> validateQueryConfig ( $ paymentTransaction ) ; $ errorMessage = '' ; $ missedFields = array ( ) ; $ invalidFields = array ( ) ; foreach ( static :: $ requestFieldsDefinition as $ fieldDescription ) { list ( $ fieldName , $ propertyPath , $ isFieldRequired , $ validationRule ) = $ fieldDescription ; $ fieldValue = PropertyAccessor :: getValue ( $ paymentTransaction , $ propertyPath , false ) ; if ( ! empty ( $ fieldValue ) ) { try { Validator :: validateByRule ( $ fieldValue , $ validationRule ) ; } catch ( ValidationException $ e ) { $ invalidFields [ ] = "Field '{$fieldName}' from property path '{$propertyPath}', {$e->getMessage()}." ; } } elseif ( $ isFieldRequired ) { $ missedFields [ ] = "Field '{$fieldName}' from property path '{$propertyPath}' missed or empty." ; } } if ( ! empty ( $ missedFields ) ) { $ errorMessage .= "Some required fields missed or empty in PaymentTransaction: \n" . implode ( "\n" , $ missedFields ) . "\n" ; } if ( ! empty ( $ invalidFields ) ) { $ errorMessage .= "Some fields invalid in PaymentTransaction: \n" . implode ( "\n" , $ invalidFields ) . "\n" ; } if ( ! empty ( $ errorMessage ) ) { throw new ValidationException ( $ errorMessage ) ; } } | Validates payment transaction before request constructing |
20,191 | protected function paymentTransactionToRequest ( PaymentTransaction $ paymentTransaction ) { $ requestFields = array ( ) ; foreach ( static :: $ requestFieldsDefinition as $ fieldDescription ) { list ( $ fieldName , $ propertyPath ) = $ fieldDescription ; $ fieldValue = PropertyAccessor :: getValue ( $ paymentTransaction , $ propertyPath ) ; if ( ! empty ( $ fieldValue ) ) { $ requestFields [ $ fieldName ] = $ fieldValue ; } } return new Request ( $ requestFields ) ; } | Creates request from payment transaction |
20,192 | protected function validateResponseOnSuccess ( PaymentTransaction $ paymentTransaction , Response $ response ) { if ( $ response -> getType ( ) !== static :: $ successResponseType ) { throw new ValidationException ( "Response type '{$response->getType()}' does not match " . "success response type '" . static :: $ successResponseType . "'" ) ; } $ missedFields = array ( ) ; foreach ( static :: $ responseFieldsDefinition as $ fieldName ) { if ( empty ( $ response [ $ fieldName ] ) ) { $ missedFields [ ] = $ fieldName ; } } if ( ! empty ( $ missedFields ) ) { throw new ValidationException ( "Some required fields missed or empty in Response: " . implode ( ', ' , $ missedFields ) . ". \n" ) ; } $ this -> validateClientId ( $ paymentTransaction , $ response ) ; } | Validates response before payment transaction updating if payment transaction is processing or approved |
20,193 | protected function validateResponseOnError ( PaymentTransaction $ paymentTransaction , Response $ response ) { $ allowedTypes = array ( static :: $ successResponseType , 'error' , 'validation-error' ) ; if ( ! in_array ( $ response -> getType ( ) , $ allowedTypes ) ) { throw new ValidationException ( "Unknown response type '{$response->getType()}'" ) ; } $ this -> validateClientId ( $ paymentTransaction , $ response ) ; } | Validates response before payment transaction updating if payment transaction is not processing or approved |
20,194 | protected function updatePaymentTransactionOnSuccess ( PaymentTransaction $ paymentTransaction , Response $ response ) { $ paymentTransaction -> setStatus ( $ response -> getStatus ( ) ) ; $ this -> setPaynetId ( $ paymentTransaction , $ response ) ; } | Updates payment transaction by query response data if payment transaction is processing or approved |
20,195 | protected function updatePaymentTransactionOnError ( PaymentTransaction $ paymentTransaction , Response $ response ) { if ( $ response -> isDeclined ( ) ) { $ paymentTransaction -> setStatus ( $ response -> getStatus ( ) ) ; } else { $ paymentTransaction -> setStatus ( PaymentTransaction :: STATUS_ERROR ) ; } $ paymentTransaction -> addError ( $ response -> getError ( ) ) ; $ this -> setPaynetId ( $ paymentTransaction , $ response ) ; } | Updates payment transaction by query response data if payment transaction is not processing or approved |
20,196 | protected function validateQueryDefinition ( ) { if ( empty ( static :: $ requestFieldsDefinition ) ) { throw new RuntimeException ( 'You must configure requestFieldsDefinition property' ) ; } if ( empty ( static :: $ signatureDefinition ) ) { throw new RuntimeException ( 'You must configure signatureDefinition property' ) ; } if ( empty ( static :: $ responseFieldsDefinition ) ) { throw new RuntimeException ( 'You must configure responseFieldsDefinition property' ) ; } if ( empty ( static :: $ successResponseType ) ) { throw new RuntimeException ( 'You must configure allowedResponseTypes property' ) ; } } | Validates query object definition |
20,197 | protected function validateQueryConfig ( PaymentTransaction $ paymentTransaction ) { $ queryConfig = $ paymentTransaction -> getQueryConfig ( ) ; if ( strlen ( $ queryConfig -> getSigningKey ( ) ) === 0 ) { throw new ValidationException ( "Property 'signingKey' does not defined in PaymentTransaction property 'queryConfig'" ) ; } if ( strlen ( $ queryConfig -> getEndPoint ( ) ) == 0 && strlen ( $ queryConfig -> getEndPointGroup ( ) ) === 0 ) { throw new ValidationException ( "Properties 'endPont' and 'endPointGroup' do not defined in " . "PaymentTransaction property 'queryConfig'. Set one of them." ) ; } if ( strlen ( $ queryConfig -> getEndPoint ( ) ) > 0 && strlen ( $ queryConfig -> getEndPointGroup ( ) ) > 0 ) { throw new ValidationException ( "Property 'endPont' was set and property 'endPointGroup' was set in " . "PaymentTransaction property 'queryConfig'. Set only one of them." ) ; } } | Validates payment transaction query config |
20,198 | protected function validateClientId ( PaymentTransaction $ paymentTransaction , Response $ response ) { $ paymentClientId = $ paymentTransaction -> getPayment ( ) -> getClientId ( ) ; $ responseClientId = $ response -> getPaymentClientId ( ) ; if ( strlen ( $ responseClientId ) > 0 && $ paymentClientId != $ responseClientId ) { throw new ValidationException ( "Response clientId '{$responseClientId}' does " . "not match Payment clientId '{$paymentClientId}'" ) ; } } | Check is payment transaction client order id and query response client order id equal or not . |
20,199 | protected function setPaynetId ( PaymentTransaction $ paymentTransaction , Response $ response ) { $ responsePaynetId = $ response -> getPaymentPaynetId ( ) ; if ( strlen ( $ responsePaynetId ) > 0 ) { $ paymentTransaction -> getPayment ( ) -> setPaynetId ( $ responsePaynetId ) ; } } | Set PaynetEasy payment id to payment transaction Payment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.