idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
33,400 | public function join ( $ table ) { if ( ! empty ( $ this -> currentJoin ) ) { $ this -> joins [ ] = $ this -> currentJoin ; } $ this -> currentJoin = array ( ) ; $ this -> currentJoin [ 'table' ] = $ table ; $ this -> currentJoin [ 'direction' ] = 'INNER' ; return $ this ; } | Join to a table |
33,401 | protected function pushColumns ( ) { if ( ! $ this -> columns || $ this -> columns == '*' ) { $ this -> parts [ ] = '*' ; } else if ( is_array ( $ this -> columns ) ) { $ cols = array ( ) ; foreach ( $ this -> columns as $ col ) { $ cols [ ] = $ this -> quoteIdentifierIfNotExpression ( $ col ) ; } $ this -> parts [ ] = join ( ', ' , $ cols ) ; } else if ( is_string ( $ this -> columns ) ) { $ this -> parts [ ] = $ this -> quoteIdentifierIfNotExpression ( $ this -> columns ) ; } else if ( $ this -> columns instanceof Expression ) { $ this -> parts [ ] = ( string ) $ this -> columns ; } } | Push columns onto parts |
33,402 | protected function pushHint ( ) { if ( $ this -> hint ) { $ this -> parts [ ] = $ this -> hintMode ? : 'USE' ; $ this -> parts [ ] = 'INDEX' ; if ( is_array ( $ this -> hint ) ) { $ this -> parts [ ] = '(' . join ( ', ' , array_map ( array ( $ this , 'quoteIdentifierIfNotExpression' ) , $ this -> hint ) ) . ')' ; } else { $ this -> parts [ ] = '(' . $ this -> quoteIdentifierIfNotExpression ( $ this -> hint ) . ')' ; } } } | Push hint onto parts |
33,403 | public function actionRun ( $ n = null ) { $ cProcessor = new CommandProcessor ( ) ; if ( $ cProcessor -> run ( $ n ) === false ) { $ this -> stdout ( 'Errors had ocurred during the mapper process phase. Please see the log in order to know more about it' , Console :: FG_RED ) ; } else { $ this -> stdout ( $ n . ' CommandMapper' . ( $ n === 1 ? '' : 's' ) . ' processed.' , Console :: FG_GREY ) ; } echo PHP_EOL ; } | Runs the CommandProcesor to process the n CommandMappers provided as argument or all of them if no param is specified . |
33,404 | function getPrevLevel ( $ level ) { $ levels = $ this -> getLevels ( ) ; $ level_incdeces = $ this -> getLevelIndeces ( ) ; $ level_index = $ level_incdeces [ $ level ] ; if ( ! isset ( $ levels [ $ level_index - 1 ] ) ) { return false ; } $ prev_level = $ levels [ $ level_index - 1 ] ; return $ prev_level ; } | Get the level that comes immediatly previous to the requested level or false if none |
33,405 | function getNextLevel ( $ level ) { $ levels = $ this -> getLevels ( ) ; $ level_incdeces = $ this -> getLevelIndeces ( ) ; $ level_index = $ level_incdeces [ $ level ] ; if ( ! isset ( $ levels [ $ level_index + 1 ] ) ) { return false ; } $ next_level = $ levels [ $ level_index + 1 ] ; return $ next_level ; } | Get the level that comes immediatly after to the requested level or false if none |
33,406 | function getNextLevels ( $ deltaLevel ) { $ prevLevels = $ this -> getPrevLevels ( $ deltaLevel ) ; $ return = $ this -> getLevels ( ) ; foreach ( $ return as $ key => $ level ) { if ( in_array ( $ level , $ prevLevels ) || $ level == $ deltaLevel ) { unset ( $ return [ $ key ] ) ; } } return array_values ( $ return ) ; } | Get levels that come after to the requested level not including the requested level |
33,407 | public function transform ( $ number , $ decimals = 2 ) { return number_format ( $ number , $ decimals , $ this -> _dsep , $ this -> _tsep ) ; } | Returns the formatted number . |
33,408 | protected function getWithdrawableOperations ( ) { $ toWithdrawSuccess = $ this -> operationManager -> findByStatus ( new Status ( Status :: TRANSFER_SUCCESS ) ) ; $ toWithdrawFailed = $ this -> operationManager -> findByStatus ( new Status ( Status :: WITHDRAW_FAILED ) ) ; $ toWithdrawNegative = $ this -> operationManager -> findByStatus ( new Status ( Status :: WITHDRAW_NEGATIVE ) ) ; $ toWithdrawBlocked = $ this -> operationManager -> findByStatus ( new Status ( Status :: WITHDRAW_PAYMENT_BLOCKED ) ) ; return array_merge ( $ toWithdrawBlocked , $ toWithdrawNegative , $ toWithdrawFailed , $ toWithdrawSuccess ) ; } | Fetch the operation to withdraw from the storage |
33,409 | public function addInputText ( ) : Input \ Text { $ input = new Input \ Text ( $ this -> form , $ this -> name . '[]' ) ; $ this -> inputs [ ] = $ input ; return $ input ; } | Adds a text input to this group and returns it . |
33,410 | public function padBoth ( $ length , $ padStr = ' ' ) { $ padding = $ length - $ this -> getLength ( ) ; return $ this -> applyPadding ( floor ( $ padding / 2 ) , ceil ( $ padding / 2 ) , $ padStr ) ; } | Adds padding to both sides of the string equally . |
33,411 | protected function applyPadding ( $ left = 0 , $ right = 0 , $ padStr = ' ' ) { $ length = UTF8 :: strlen ( $ padStr , $ this -> encoding ) ; $ strLength = $ this -> getLength ( ) ; $ paddedLength = $ strLength + $ left + $ right ; if ( ! $ length || $ paddedLength <= $ strLength ) return $ this ; $ leftPadding = UTF8 :: substr ( UTF8 :: str_repeat ( $ padStr , ceil ( $ left / $ length ) ) , 0 , $ left , $ this -> encoding ) ; $ rightPadding = UTF8 :: substr ( UTF8 :: str_repeat ( $ padStr , ceil ( $ right / $ length ) ) , 0 , $ right , $ this -> encoding ) ; return $ this -> newSelf ( $ leftPadding . $ this -> scalarString . $ rightPadding ) ; } | Pad internal helper adds padding to the left and right of the string . |
33,412 | protected function parseFields ( ) { $ this -> fields = array ( ) ; $ matches = array ( ) ; preg_match_all ( '/{(.*?)}/i' , $ this -> format , $ matches ) ; foreach ( $ matches [ 1 ] as $ match ) { $ this -> fields [ ] = strtoupper ( $ match ) ; } } | Method to parse the format string into an array of fields . |
33,413 | public function addRadio ( ) : Radio { $ radio = new Radio ( $ this -> form , $ this -> name ) ; $ radio -> setRequired ( $ this -> isRequired ( ) ) ; $ this -> radios [ ] = $ radio ; return $ radio ; } | Adds a radio button in this group and returns it . |
33,414 | protected function _process ( array $ stmts ) { $ this -> _msg ( 'Renaming service configuration' , 0 ) ; if ( $ this -> _schema -> tableExists ( 'mshop_service' ) && $ this -> _schema -> columnExists ( 'mshop_service' , 'config' ) === true ) { $ cntRows = 0 ; foreach ( $ stmts as $ stmt ) { $ result = $ this -> _conn -> create ( $ stmt ) -> execute ( ) ; $ cntRows += $ result -> affectedRows ( ) ; $ result -> finish ( ) ; } if ( $ cntRows > 0 ) { $ this -> _status ( sprintf ( 'done (%1$d)' , $ cntRows ) ) ; } else { $ this -> _status ( 'OK' ) ; } } else { $ this -> _status ( 'OK' ) ; } } | Renames the service configuration if necessary . |
33,415 | public function getNode ( Argument $ argument ) : Expr { $ dependencyIndex = ( string ) $ argument ; if ( ! $ this -> injector instanceof ScriptInjector ) { return $ this -> getDefault ( $ argument ) ; } try { $ isSingleton = $ this -> injector -> isSingleton ( $ dependencyIndex ) ; } catch ( NotCompiled $ e ) { return $ this -> getDefault ( $ argument ) ; } $ func = $ isSingleton ? 'singleton' : 'prototype' ; $ args = $ this -> getInjectionProviderParams ( $ argument ) ; $ node = new Expr \ FuncCall ( new Expr \ Variable ( $ func ) , $ args ) ; return $ node ; } | Return on - demand dependency pull code for not compiled |
33,416 | private function getDefault ( Argument $ argument ) : Expr { if ( $ argument -> isDefaultAvailable ( ) ) { $ default = $ argument -> getDefaultValue ( ) ; return ( $ this -> normalizer ) ( $ default ) ; } throw new Unbound ( $ argument -> getMeta ( ) ) ; } | Return default argument value |
33,417 | private function getSetterParams ( array $ arguments , bool $ isOptional ) { $ args = [ ] ; foreach ( $ arguments as $ argument ) { try { $ args [ ] = $ this -> factoryCompiler -> getArgStmt ( $ argument ) ; } catch ( Unbound $ e ) { if ( $ isOptional ) { return false ; } } } return $ args ; } | Return setter method parameters |
33,418 | function getFits ( ) { if ( ! is_null ( $ this -> fits ) ) { return $ this -> fits ; } if ( $ productId = ( int ) $ this -> getId ( ) ) { $ this -> fits = $ this -> doGetFits ( $ productId ) ; return $ this -> fits ; } return array ( ) ; } | Get a result set for the fits for this product |
33,419 | protected function _getTypeItem ( $ prefix , $ domain , $ code ) { $ manager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , $ prefix ) ; $ prefix = str_replace ( '/' , '.' , $ prefix ) ; $ search = $ manager -> createSearch ( ) ; $ expr = array ( $ search -> compare ( '==' , $ prefix . '.domain' , $ domain ) , $ search -> compare ( '==' , $ prefix . '.code' , $ code ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ result = $ manager -> searchItems ( $ search ) ; if ( ( $ item = reset ( $ result ) ) === false ) { throw new Exception ( sprintf ( 'No type item for "%1$s/%2$s" in "%3$s" found' , $ domain , $ code , $ prefix ) ) ; } return $ item ; } | Returns the attribute type item specified by the code . |
33,420 | public function setLanguageId ( $ id ) { if ( $ id === $ this -> getLanguageId ( ) ) { return ; } if ( $ id !== null ) { if ( strlen ( $ id ) !== 2 || ctype_alpha ( $ id ) === false ) { throw new MShop_Product_Exception ( sprintf ( 'Invalid characters in ISO language code "%1$s"' , $ id ) ) ; } $ id = ( string ) $ id ; } $ this -> _values [ 'langid' ] = $ id ; $ this -> setModified ( ) ; } | Sets the language ID of the product tag item . |
33,421 | public function setTypeId ( $ id ) { $ id = ( int ) $ id ; if ( $ id === $ this -> getTypeId ( ) ) { return ; } $ this -> _values [ 'typeid' ] = ( int ) $ id ; $ this -> setModified ( ) ; } | Sets the new type of the product tag item |
33,422 | public function toSingular ( $ language = 'en' ) { if ( ! class_exists ( '\\ICanBoogie\\Inflector' ) ) { throw new \ RuntimeException ( "This method requires ICanBoogie\Inflector. " . "Install with: composer require icanboogie/inflector" ) ; } return $ this -> newSelf ( \ ICanBoogie \ Inflector :: get ( $ language ) -> singularize ( $ this -> scalarString ) ) ; } | Returns the singular version of the word . |
33,423 | public function toPlural ( $ language = 'en' ) { if ( ! class_exists ( '\\ICanBoogie\\Inflector' ) ) { throw new \ RuntimeException ( "This method requires ICanBoogie\Inflector. " . "Install with: composer require icanboogie/inflector" ) ; } return $ this -> newSelf ( \ ICanBoogie \ Inflector :: get ( $ language ) -> pluralize ( $ this -> scalarString ) ) ; } | Returns the plural version of the word . |
33,424 | public function toBoolean ( ) { $ key = $ this -> toLowerCase ( ) -> scalarString ; $ map = [ 'true' => true , '1' => true , 'on' => true , 'yes' => true , 'false' => false , '0' => false , 'off' => false , 'no' => false ] ; if ( array_key_exists ( $ key , $ map ) ) { return $ map [ $ key ] ; } elseif ( is_numeric ( $ this -> scalarString ) ) { return ( ( int ) $ this -> scalarString > 0 ) ; } else { return ( bool ) $ this -> regexReplace ( '[[:space:]]' , '' ) -> scalarString ; } } | Returns a boolean representation of the given logical string value . |
33,425 | public function toSpaces ( $ tabLength = 4 ) { return $ this -> newSelf ( UTF8 :: str_replace ( "\t" , UTF8 :: str_repeat ( ' ' , $ tabLength ) , $ this -> scalarString ) ) ; } | Converts tabs to spaces . |
33,426 | public function toTabs ( $ tabLength = 4 ) { return $ this -> newSelf ( UTF8 :: str_replace ( UTF8 :: str_repeat ( ' ' , $ tabLength ) , "\t" , $ this -> scalarString ) ) ; } | Converts spaces to tabs . |
33,427 | public function toCamelCase ( $ upperFirst = false ) { $ camelCase = $ this -> trim ( ) -> lowerCaseFirst ( ) ; $ camelCase = preg_replace ( '/^[-_]+/' , '' , ( string ) $ camelCase ) ; $ camelCase = preg_replace_callback ( '/[-_\s]+(.)?/u' , function ( $ match ) { if ( isset ( $ match [ 1 ] ) ) { return UTF8 :: strtoupper ( $ match [ 1 ] , $ this -> encoding ) ; } else { return '' ; } } , $ camelCase ) ; $ camelCase = preg_replace_callback ( '/[\d]+(.)?/u' , function ( $ match ) { return UTF8 :: strtoupper ( $ match [ 0 ] , $ this -> encoding ) ; } , $ camelCase ) ; $ camelCase = $ this -> newSelf ( $ camelCase ) ; if ( $ upperFirst === true ) $ camelCase = $ camelCase -> upperCaseFirst ( ) ; return $ camelCase ; } | Returns a camelCase version of the string . |
33,428 | public function toTitleCase ( $ ignore = null ) { return $ this -> newSelf ( preg_replace_callback ( '/([\S]+)/u' , function ( $ match ) use ( $ ignore ) { if ( $ ignore && in_array ( $ match [ 0 ] , $ ignore , true ) ) { return $ match [ 0 ] ; } else { return ( string ) $ this -> newSelf ( $ match [ 0 ] ) -> toLowerCase ( ) -> upperCaseFirst ( ) ; } } , ( string ) $ this -> trim ( ) ) ) ; } | Returns a trimmed string with the first letter of each word capitalized . |
33,429 | public function toSlugCase ( $ replacement = '-' , $ language = 'en' , $ strToLower = true ) { if ( ! class_exists ( '\\voku\\helper\\URLify' ) ) { throw new \ RuntimeException ( "This method requires \voku\helper\URLify. " . "Install with: composer require voku/urlify" ) ; } return $ this -> newSelf ( \ voku \ helper \ URLify :: slug ( $ this -> scalarString , $ language , $ replacement , $ strToLower ) ) ; } | Converts the string into an URL slug . |
33,430 | public function get_attribute ( $ key ) { if ( 'id' === $ key ) { return $ this -> get_id ( ) ; } if ( ! array_key_exists ( $ key , $ this -> attributes ) ) { return ; } $ value = $ this -> attributes [ $ key ] ; if ( $ this -> has_cast ( $ key ) ) { return $ this -> cast_attribute ( $ key , $ value ) ; } return $ value ; } | Get an attribute from this object . |
33,431 | public function set_attribute ( $ key , $ value ) { $ this -> attributes [ $ key ] = $ this -> sanitize_attribute ( $ key , $ value ) ; return $ this ; } | Sets an attribute to new value . |
33,432 | public function fill ( array $ attributes ) { foreach ( $ attributes as $ key => $ value ) { if ( ! array_key_exists ( $ key , $ this -> attributes ) ) { continue ; } $ this -> set_attribute ( $ key , $ value ) ; } return $ this ; } | Fill the object with an array of attributes . |
33,433 | public function set_raw_attributes ( array $ attributes , $ sync = false ) { $ this -> attributes = $ attributes ; if ( $ sync ) { $ this -> sync_original ( ) ; } return $ this ; } | Set the array of object attributes . |
33,434 | public function sync_original_attribute ( $ attribute ) { if ( array_key_exists ( $ attribute , $ this -> attributes ) ) { $ this -> original [ $ attribute ] = $ this -> attributes [ $ attribute ] ; } return $ this ; } | Sync a single original attribute with its current value . |
33,435 | public function revert_attribute ( $ attribute ) { if ( array_key_exists ( $ attribute , $ this -> attributes ) ) { $ this -> attributes [ $ attribute ] = $ this -> original [ $ attribute ] ; } return $ this ; } | Revert a attribute to the original value . |
33,436 | protected function has_changes ( array $ changes , $ attributes = null ) { if ( empty ( $ attributes ) ) { return count ( $ changes ) > 0 ; } foreach ( ( array ) $ attributes as $ attribute ) { if ( array_key_exists ( $ attribute , $ changes ) ) { return true ; } } return false ; } | Determine if the given attributes were changed . |
33,437 | public function plainInput ( $ type , $ name , $ value = null , $ options = [ ] ) { return parent :: input ( $ type , $ name , $ value , $ options ) ; } | Create a plain form input field . |
33,438 | public function plainTextarea ( $ name , $ value = null , $ options = [ ] ) { return parent :: textarea ( $ name , $ value , $ options ) ; } | Create a plain textarea input field . |
33,439 | public static function createClient ( MShop_Context_Item_Interface $ context , array $ templatePaths , $ name = null ) { if ( $ name === null ) { $ name = $ context -> getConfig ( ) -> get ( 'classes/client/html/basket/mini/name' , 'Default' ) ; } if ( ctype_alnum ( $ name ) === false ) { $ classname = is_string ( $ name ) ? 'Client_Html_Basket_Mini_' . $ name : '<not a string>' ; throw new Client_Html_Exception ( sprintf ( 'Invalid characters in class name "%1$s"' , $ classname ) ) ; } $ iface = 'Client_Html_Interface' ; $ classname = 'Client_Html_Basket_Mini_' . $ name ; $ client = self :: _createClient ( $ context , $ classname , $ iface , $ templatePaths ) ; return self :: _addClientDecorators ( $ context , $ client , 'basket/mini' ) ; } | Creates a mini basket client object . |
33,440 | public function cached ( ) { $ fileID = $ this -> getCacheID ( ) ; $ storage = Storage :: disk ( $ this -> cache_disk ) ; if ( $ storage -> exists ( $ this -> generateCacheFilePath ( $ fileID , true ) ) ) { return $ this -> makeImage ( $ this -> storagePath ( $ this -> generateCacheFilePath ( $ fileID , true ) ) ) ; } } | Check if image is cache if yes return Image handle . |
33,441 | public function cache ( $ handle ) { $ fileID = $ this -> getCacheID ( ) ; $ storage = Storage :: disk ( $ this -> cache_disk ) ; $ storage -> put ( $ this -> generateCacheFilePath ( $ fileID , true ) , $ handle -> encode ( $ this -> extension ( ) , config ( 'images.image_quality' , 90 ) ) ) ; } | Save image to cache . |
33,442 | public function getHandleFromCache ( ) { $ fileID = $ this -> getCacheID ( ) ; if ( ! $ this -> isCached ( $ fileID ) ) { $ this -> saveOriginalImageToCache ( $ fileID ) ; } return $ this -> makeImage ( $ this -> storagePath ( $ this -> generateCacheFilePath ( $ fileID ) ) ) ; } | Get handle to original file from cache . |
33,443 | public function saveOriginalImageToCache ( $ fileID ) { Storage :: disk ( $ this -> cache_disk ) -> put ( $ this -> generateCacheFilePath ( $ fileID ) , $ this -> getOriginalImageFile ( ) ) ; } | Save original image to cache . |
33,444 | public function isCached ( $ fileID ) { if ( Storage :: disk ( $ this -> cache_disk ) -> exists ( $ this -> generateCacheFilePath ( $ fileID ) ) ) { return true ; } } | Check if file exists in cache . |
33,445 | public function generateCacheFilePath ( $ fileID , $ add_parameters = false ) { if ( empty ( $ this -> cache_extension ) ) { $ this -> cache_extension = config ( 'images.cache_extension' ) ; } $ fileID = str_replace ( '.' , '' , $ fileID ) ; $ parameters = [ 'i' ] ; if ( $ add_parameters ) { if ( $ this -> size ( ) ) { $ parameters [ ] = $ this -> size ( ) ; } if ( $ this -> watermarkPath ( ) ) { $ parameters [ ] = 'w-' . md5 ( $ this -> watermarkPath ( ) ) ; } } $ path = config ( 'images.cache_path' ) ; $ path .= "images/{$fileID}/" . implode ( '-' , $ parameters ) ; $ path .= '.' . $ this -> cache_extension ; return $ path ; } | Generate path to cache file . |
33,446 | public function acquire ( $ name = 'db' ) { try { $ adapter = $ this -> _config -> get ( 'resource/' . $ name . '/adapter' , 'mysql' ) ; if ( ! isset ( $ this -> _connections [ $ name ] ) || empty ( $ this -> _connections [ $ name ] ) ) { if ( ! isset ( $ this -> _count [ $ name ] ) ) { $ this -> _count [ $ name ] = 0 ; } $ limit = $ this -> _config -> get ( 'resource/' . $ name . '/limit' , - 1 ) ; if ( $ limit >= 0 && $ this -> _count [ $ name ] >= $ limit ) { throw new MW_DB_Exception ( sprintf ( 'Maximum number of connections (%1$d) exceeded' , $ limit ) ) ; } $ this -> _connections [ $ name ] = array ( $ this -> _createConnection ( $ name , $ adapter ) ) ; $ this -> _count [ $ name ] ++ ; } switch ( $ adapter ) { case 'sqlite' : case 'sqlite3' : return $ this -> _connections [ $ name ] [ 0 ] ; } return array_pop ( $ this -> _connections [ $ name ] ) ; } catch ( PDOException $ e ) { throw new MW_DB_Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> errorInfo ) ; } } | Returns a database connection . |
33,447 | public function release ( MW_DB_Connection_Interface $ connection , $ name = 'db' ) { if ( ( $ connection instanceof MW_DB_Connection_PDO ) === false ) { throw new MW_DB_Exception ( 'Connection object isn\'t of type PDO' ) ; } $ this -> _connections [ $ name ] [ ] = $ connection ; } | Releases the connection for reuse |
33,448 | protected function parse ( ) { $ descriptionDone = false ; $ this -> fullDescriptionDone = false ; $ lines = explode ( "\n" , $ this -> comment ) ; foreach ( $ lines as $ line ) { $ pos = strpos ( $ line , '* @' ) ; if ( trim ( $ line ) == '/**' || trim ( $ line ) == '*/' ) { } elseif ( ! ( $ pos === false ) ) { $ this -> parseTagLine ( substr ( $ line , $ pos + 3 ) ) ; $ descriptionDone = true ; } elseif ( ! $ descriptionDone ) { $ this -> parseDescription ( $ line ) ; } } if ( trim ( str_replace ( array ( "\n" , "\r" ) , array ( '' , '' ) , $ this -> obj -> fullDescription ) ) == '' ) { $ this -> obj -> fullDescription = $ this -> obj -> smallDescription ; } } | parses the comment line for line . |
33,449 | protected function parseDescription ( $ descriptionLine ) { if ( strpos ( $ descriptionLine , '*' ) <= 2 ) { $ descriptionLine = substr ( $ descriptionLine , ( strpos ( $ descriptionLine , '*' ) + 1 ) ) ; } if ( trim ( str_replace ( array ( "\n" , "\r" ) , array ( '' , '' ) , $ descriptionLine ) ) == '' ) { if ( $ this -> obj -> fullDescription == '' ) { $ descriptionLine = '' ; } $ this -> smallDescriptionDone = true ; } if ( ! $ this -> smallDescriptionDone ) { $ this -> obj -> smallDescription .= $ descriptionLine ; } else { $ this -> obj -> fullDescription .= $ descriptionLine ; } } | Parses the description to the small and full description properties . |
33,450 | protected function _buildSQL ( ) { if ( $ this -> _stmt !== null ) { return $ this -> _stmt ; } $ i = 1 ; foreach ( $ this -> _parts as $ part ) { $ this -> _stmt .= $ part ; if ( isset ( $ this -> _binds [ $ i ] ) ) { $ this -> _stmt .= $ this -> _binds [ $ i ] ; } $ i ++ ; } return $ this -> _stmt ; } | Creates the SQL string with bound parameters . |
33,451 | protected function loadFile ( string $ file , array $ options ) { return parse_ini_file ( $ file , $ options [ 'process_sections' ] ?? true , $ options [ 'mode' ] ?? INI_SCANNER_NORMAL ) ; } | Parse ini file |
33,452 | public function register ( ) { $ this -> mergeConfigFrom ( __DIR__ . '/config.php' , 'ibrand.setting' ) ; $ this -> app -> singleton ( SettingInterface :: class , function ( $ app ) { $ repository = new EloquentSetting ( new SystemSetting ( ) ) ; if ( ! config ( 'ibrand.setting.cache' ) ) { return $ repository ; } return new CacheDecorator ( $ repository ) ; } ) ; $ this -> app -> alias ( SettingInterface :: class , 'system_setting' ) ; } | register service provider |
33,453 | protected function setup_metadata ( ) { if ( ! $ this -> meta_type ) { return ; } $ metadata = $ this -> get_metadata ( ) ; foreach ( $ this -> get_mapping ( ) as $ attribute => $ meta ) { if ( isset ( $ metadata [ $ meta ] ) ) { $ this -> set_attribute ( $ attribute , $ metadata [ $ meta ] ) ; } } } | Mapped metadata with the attributes . |
33,454 | public function get_meta ( $ key ) { $ metadata = $ this -> get_metadata ( ) ; if ( ! array_key_exists ( $ key , $ metadata ) ) { return ; } return $ metadata [ $ key ] ; } | Get a metadata by meta key . |
33,455 | public function add_meta ( $ meta_key , $ meta_value ) { return add_metadata ( $ this -> meta_type , $ this -> get_id ( ) , $ meta_key , $ meta_value , true ) ; } | Add metadata . |
33,456 | public function get_metadata ( ) { if ( is_null ( $ this -> metadata ) ) { $ this -> metadata = $ this -> fetch_metadata ( ) ; } return $ this -> metadata ; } | Get all metadata of this object . |
33,457 | protected function fetch_metadata ( ) { if ( ! $ this -> meta_type ) { return array ( ) ; } $ raw_metadata = get_metadata ( $ this -> meta_type , $ this -> get_id ( ) ) ; $ metadata = [ ] ; foreach ( $ raw_metadata as $ meta_key => $ meta_values ) { if ( in_array ( $ meta_key , [ '_edit_lock' , '_edit_last' ] ) ) { continue ; } $ metadata [ $ meta_key ] = maybe_unserialize ( $ meta_values [ 0 ] ) ; } return $ metadata ; } | Fetch metadata of current object . |
33,458 | public function get_mapping_metakey ( $ attribute ) { $ mapping = $ this -> get_mapping ( ) ; return isset ( $ mapping [ $ attribute ] ) ? $ mapping [ $ attribute ] : null ; } | Get the mapping metakey by special attribute . |
33,459 | public function get_mapping_attribute ( $ metakey ) { $ mapping = array_flip ( $ this -> get_mapping ( ) ) ; return isset ( $ mapping [ $ metakey ] ) ? $ mapping [ $ metakey ] : null ; } | Get the mapping attribute by special metakey . |
33,460 | public function get_mapping ( ) { if ( is_null ( $ this -> mapping ) ) { $ this -> mapping = $ this -> normalize_mapping ( ) ; } return $ this -> mapping ; } | Get normalized of mapping . |
33,461 | protected function normalize_mapping ( ) { $ mapping = [ ] ; foreach ( $ this -> maps as $ attribute => $ metadata ) { $ attribute = is_int ( $ attribute ) ? $ metadata : $ attribute ; if ( array_key_exists ( $ attribute , $ this -> attributes ) ) { $ mapping [ $ attribute ] = $ metadata ; } } return $ mapping ; } | Normalize mapping metadata . |
33,462 | protected function perform_update_metadata ( array $ changes ) { if ( ! $ this -> meta_type ) { return ; } $ mapping = $ this -> get_mapping ( ) ; $ changes = $ this -> recently_created ? array_keys ( $ mapping ) : $ this -> get_changes_only ( $ changes , array_keys ( $ mapping ) ) ; if ( empty ( $ changes ) ) { return ; } $ updated = [ ] ; foreach ( $ changes as $ attribute ) { $ meta_key = $ this -> get_mapping_metakey ( $ attribute ) ; if ( is_null ( $ meta_key ) ) { continue ; } if ( $ this -> update_meta ( $ meta_key , $ this -> get_attribute ( $ attribute ) ) ) { $ updated [ ] = $ attribute ; } } return $ updated ; } | Run perform update object metadata . |
33,463 | public static function parse ( ? string $ json = null , int $ options = 0 , int $ depth = 512 ) : ? array { if ( $ json === null ) { return null ; } $ json = ( string ) $ json ; $ data = @ json_decode ( $ json , true , $ depth , $ options ) ; if ( $ data === null && ( $ json === '' || ( json_last_error ( ) ) !== JSON_ERROR_NONE ) ) { $ code = json_last_error ( ) ; if ( isset ( $ code ) && ( $ code === JSON_ERROR_UTF8 || $ code === JSON_ERROR_DEPTH ) ) { throw new ParseException ( sprintf ( 'JSON parsing failed: %s' , json_last_error_msg ( ) ) , - 1 , null , $ code ) ; } try { ( new JsonParser ( ) ) -> parse ( $ json ) ; } catch ( ParsingException $ e ) { throw ParseException :: castFromJson ( $ e ) ; } } return $ data ; } | Parses JSON into a PHP array . |
33,464 | public function setAttributes ( $ selector , array $ attributes ) { $ nodes = $ this -> get ( $ selector ) ; foreach ( $ nodes as $ node ) { $ node -> setAttributes ( $ attributes ) ; } } | set a list of attributes |
33,465 | public function sendEmail ( $ subject , $ view , $ vars = [ ] ) { $ vars [ 'email' ] = $ email = $ this -> email ; $ vars [ 'username' ] = $ username = $ this -> username ; Mail :: queue ( [ 'text' => $ view ] , $ vars , function ( $ message ) use ( $ email , $ username , $ subject ) { $ message -> subject ( $ subject ) -> to ( $ email , $ username ) ; if ( config ( ) -> has ( 'mail.reply_to' ) ) { $ message -> replyTo ( config ( 'mail.reply_to.email' ) , config ( 'mail.reply_to.name' ) ) ; } } ) ; } | Shortcut method for sending a user an email . |
33,466 | public function getAcquaintances ( ) { $ acquaintances = new Collection ( ) ; foreach ( $ this -> messages ( ) -> received ( ) -> with ( 'sender' ) -> get ( ) as $ message ) { $ acquaintances = $ acquaintances -> push ( $ message -> sender ) ; } foreach ( $ this -> messages ( ) -> sent ( ) -> with ( 'recipient' ) -> get ( ) as $ message ) { $ acquaintances = $ acquaintances -> push ( $ message -> recipient ) ; } foreach ( $ this -> purchases ( ) -> with ( 'item.seller' ) -> get ( ) as $ purchase ) { $ acquaintances = $ acquaintances -> push ( $ purchase -> item -> seller ) ; } foreach ( $ this -> items ( ) -> with ( 'purchases.buyer' ) -> get ( ) as $ item ) { foreach ( $ item -> purchases as $ purchase ) { $ acquaintances = $ acquaintances -> push ( $ purchase -> buyer ) ; } } return $ acquaintances -> unique ( ) ; } | Get users the user has a substantial connection with . |
33,467 | public function isWatching ( Item $ item ) { return ( bool ) $ this -> watching ( ) -> where ( 'items.item_id' , $ item -> itemId ) -> count ( ) ; } | Return true if user is watching the item . |
33,468 | public static function register ( $ email , $ password , $ username ) { $ user = new self ( ) ; $ user -> email = $ email ; $ user -> password = bcrypt ( $ password ) ; $ user -> username = $ username ; $ user -> joined = time ( ) ; $ user -> save ( ) ; return $ user ; } | Shortcut method for signing up a new user . |
33,469 | public static function totalRegistered ( $ since = 0 , $ until = null ) { $ until = $ until ? : time ( ) ; return ( int ) self :: where ( 'joined' , '>=' , $ since ) -> where ( 'joined' , '<=' , $ until ) -> count ( ) ; } | Return the total number of users . |
33,470 | public static function totalBidders ( $ since = 0 , $ until = null ) { $ until = $ until ? : time ( ) ; return ( int ) self :: join ( 'bids' ) -> where ( 'placed' , '>=' , $ since ) -> where ( 'placed' , '<=' , $ until ) -> count ( \ DB :: raw ( 'DISTINCT(users.user_id)' ) ) ; } | Return the total number of users that have placed bids . |
33,471 | protected function publish ( $ theme ) { $ theme = $ theme instanceof Theme ? $ theme : $ this -> laravel [ 'themes' ] -> find ( $ theme ) ; if ( ! is_null ( $ theme ) ) { $ assetsPath = $ theme -> getPath ( 'assets' ) ; $ destinationPath = public_path ( 'themes/' . $ theme -> getLowerName ( ) ) ; $ this -> laravel [ 'files' ] -> copyDirectory ( $ assetsPath , $ destinationPath ) ; $ this -> line ( "Asset published from: <info>{$theme->getName()}</info>" ) ; } } | Publish theme . |
33,472 | public function toString ( Array $ tree ) { $ text = '' ; while ( ! empty ( $ tree ) ) { $ node = array_shift ( $ tree ) ; $ text .= str_repeat ( ' ' , $ node -> getDepth ( ) ) . ( string ) $ node . "\n" ; } return $ text ; } | Converts a NestedSet flat - Array into a human readable text format |
33,473 | public function generate ( $ method , $ url , array $ data = [ ] , array $ headers = [ ] , $ basicAuthCredentials = '' ) { $ signatureParts = [ $ method , $ url ] ; $ signatureParts [ ] = http_build_query ( $ data ) ; $ signatureParts [ ] = http_build_query ( $ headers ) ; $ signatureParts [ ] = $ basicAuthCredentials ; return implode ( '|' , $ signatureParts ) ; } | Generate a signature that identifies a request |
33,474 | public function relatedPost ( ApiRequest $ request , $ resourceModel ) { $ requestModel = $ request -> asRequestModel ( ) ; $ this -> validate ( $ requestModel , $ this -> getCreatingRules ( ) ) ; $ relation = $ this -> getRelation ( $ resourceModel ) ; return $ this -> createRelationshipModel ( $ relation , $ requestModel ) ; } | post request on To - One relationship |
33,475 | public function statusExist ( $ status ) { $ generator = $ this -> getStatuses ( ) ; $ list = iterator_to_array ( $ generator ) ; return in_array ( $ status , $ list ) ; } | Check status existence . |
33,476 | public function getContacts ( ) { $ nodes = $ this -> get ( '//epp:epp/epp:response/epp:resData/domain:infData/domain:contact' ) ; foreach ( $ nodes as $ node ) { yield $ node -> getAttribute ( 'type' ) => $ node -> nodeValue ; } } | Other nichandles with the types associated with the domain object . |
33,477 | public function getTransferDate ( $ format = null ) { $ node = $ this -> getFirst ( '//epp:epp/epp:response/epp:resData/domain:infData/domain:trDate' ) ; if ( $ node === null ) { return null ; } if ( $ format === null ) { return $ node -> nodeValue ; } return date_create_from_format ( $ format , $ node -> nodeValue ) ; } | The date and time of the most recent successful domain object transfer . |
33,478 | public function send ( $ timeout = null ) { $ format = $ this -> params -> getString ( "format" , null ) ; if ( ! strrpos ( $ this -> method , "." ) ) { $ this -> host = "socialize." . $ this -> apiDomain ; $ this -> path = "/socialize." . $ this -> method ; } else { $ tokens = explode ( "." , $ this -> method ) ; $ this -> host = $ tokens [ 0 ] . "." . $ this -> apiDomain ; $ this -> path = "/" . $ this -> method ; } if ( empty ( $ format ) ) { $ format = "json" ; $ this -> setParam ( "format" , $ format ) ; } if ( ! empty ( $ timeout ) ) { $ this -> traceField ( "timeout" , $ timeout ) ; } if ( empty ( $ this -> method ) || ( empty ( $ this -> apiKey ) and empty ( $ this -> userKey ) ) ) { return new GSResponse ( $ this -> method , null , $ this -> params , 400002 , null , $ this -> traceLog ) ; } if ( $ this -> useHTTPS && empty ( GSRequest :: $ cafile ) ) { return new GSResponse ( $ this -> method , null , $ this -> params , 400003 , null , $ this -> traceLog ) ; } try { $ this -> setParam ( "httpStatusCodes" , "false" ) ; $ this -> traceField ( "userKey" , $ this -> userKey ) ; $ this -> traceField ( "apiKey" , $ this -> apiKey ) ; $ this -> traceField ( "apiMethod" , $ this -> method ) ; $ this -> traceField ( "params" , $ this -> params ) ; $ this -> traceField ( "useHTTPS" , $ this -> useHTTPS ) ; $ responseStr = $ this -> sendRequest ( "POST" , $ this -> host , $ this -> path , $ this -> params , $ this -> apiKey , $ this -> secretKey , $ this -> useHTTPS , $ timeout , $ this -> userKey ) ; return new GSResponse ( $ this -> method , $ responseStr , null , 0 , null , $ this -> traceLog ) ; } catch ( Exception $ ex ) { $ errcode = 500000 ; $ errMsg = $ ex -> getMessage ( ) ; $ length = strlen ( "Operation timed out" ) ; if ( ( substr ( $ ex -> getMessage ( ) , 0 , $ length ) === "Operation timed out" ) ) { $ errcode = 504002 ; $ errMsg = "Request Timeout" ; } return new GSResponse ( $ this -> method , null , $ this -> params , $ errcode , $ errMsg , $ this -> traceLog ) ; } } | Send the request synchronously |
33,479 | public static function buildQS ( $ params ) { $ val ; $ ret = "" ; foreach ( $ params -> getKeys ( ) as $ key ) { $ val = $ params -> getString ( $ key ) ; if ( isset ( $ val ) ) { $ ret .= "$key=" . urlencode ( $ val ) ; } $ ret .= '&' ; } $ ret = rtrim ( $ ret , "&" ) ; return $ ret ; } | Converts a GSObject to a query string |
33,480 | public function parseURL ( $ url ) { try { $ u = parse_url ( $ url ) ; if ( isset ( $ u [ "query" ] ) ) $ this -> parseQueryString ( $ u [ "query" ] ) ; if ( isset ( $ u [ "fragment" ] ) ) $ this -> parseQueryString ( $ u [ "fragment" ] ) ; } catch ( Exception $ e ) { } } | Parse parameters from URL into the dictionary |
33,481 | protected function mergeConfigFrom ( $ path , $ key ) { $ config = $ this -> app [ 'config' ] -> get ( $ key , [ ] ) ; $ this -> app [ 'config' ] -> set ( $ key , recursive_merge ( require $ path , $ config ) ) ; } | Merge the given configuration with the existing configuration . |
33,482 | public function validateConfig ( array $ config ) { $ required = [ 'model' , 'token_key' , ] ; foreach ( $ required as $ require_key ) { if ( ! isset ( $ config [ $ require_key ] ) ) { throw new \ LogicException ( "User Provider config is missing the $require_key configuration." ) ; } } } | Validate configuration options |
33,483 | public static function revokeSessionsForOwnerTypeAndId ( $ owner_type , $ owner_id ) { DB :: table ( 'oauth_sessions' ) -> where ( 'owner_type' , '=' , $ owner_type ) -> where ( 'owner_id' , '=' , $ owner_id ) -> delete ( ) ; } | Revoke all sessions for the owner . |
33,484 | public function processFileClasses ( array $ classes , string $ file ) { foreach ( $ classes as $ name => $ class ) { if ( is_null ( $ class [ 'docblock' ] ) ) { $ this -> errors [ ] = [ 'type' => 'class' , 'file' => $ file , 'class' => $ name , 'line' => $ class [ 'line' ] , ] ; } } } | Process classes . |
33,485 | public function processFileMethods ( array $ methods , string $ file ) { foreach ( $ methods as $ name => $ method ) { if ( is_null ( $ method [ 'docblock' ] ) ) { $ this -> errors [ ] = [ 'type' => 'method' , 'file' => $ file , 'class' => $ name , 'method' => $ name , 'line' => $ method [ 'line' ] , ] ; } } } | Process methods . |
33,486 | public function processFileSignatues ( array $ methods , string $ file ) { foreach ( $ methods as $ name => $ method ) { if ( ! empty ( $ method [ 'params' ] ) ) { $ this -> processMethodParams ( $ method , $ file , $ name ) ; } if ( ! empty ( $ method [ 'return' ] ) ) { $ this -> processMethodReturn ( $ method , $ file , $ name ) ; } } } | Process signatues . |
33,487 | protected function processMethodParams ( array $ method , string $ file , string $ name ) { if ( ! empty ( $ method [ 'docblock' ] [ 'inheritdoc' ] ) ) { return ; } foreach ( $ method [ 'params' ] as $ param => $ type ) { if ( is_array ( $ type ) ) { $ type = implode ( '|' , $ type ) ; } if ( ! isset ( $ method [ 'docblock' ] [ 'params' ] [ $ param ] ) ) { $ this -> warnings [ ] = [ 'type' => 'param-missing' , 'file' => $ file , 'class' => $ name , 'method' => $ name , 'line' => $ method [ 'line' ] , 'param' => $ param , ] ; return ; } if ( empty ( $ type ) ) { return ; } $ paramType = $ method [ 'docblock' ] [ 'params' ] [ $ param ] ; if ( $ paramType !== $ type ) { if ( ! ( $ type == 'array' && substr ( $ paramType , - 2 ) == '[]' ) ) { $ this -> warnings [ ] = [ 'type' => 'param-mismatch' , 'file' => $ file , 'class' => $ name , 'method' => $ name , 'line' => $ method [ 'line' ] , 'param' => $ param , 'param-type' => $ type , 'doc-type' => $ method [ 'docblock' ] [ 'params' ] [ $ param ] , ] ; } } } } | Process method params . |
33,488 | public function processMethodReturn ( array $ method , string $ file , string $ name ) { if ( ! empty ( $ method [ 'docblock' ] [ 'inheritdoc' ] ) ) { return ; } if ( empty ( $ method [ 'docblock' ] [ 'return' ] ) ) { $ this -> warnings [ ] = [ 'type' => 'return-missing' , 'file' => $ file , 'class' => $ name , 'method' => $ name , 'line' => $ method [ 'line' ] , ] ; } elseif ( is_array ( $ method [ 'return' ] ) ) { $ docblockTypes = explode ( '|' , $ method [ 'docblock' ] [ 'return' ] ) ; sort ( $ docblockTypes ) ; if ( $ method [ 'return' ] != $ docblockTypes ) { $ warnings = true ; $ this -> warnings [ ] = [ 'type' => 'return-mismatch' , 'file' => $ file , 'class' => $ name , 'method' => $ name , 'line' => $ method [ 'line' ] , 'return-type' => implode ( '|' , $ method [ 'return' ] ) , 'doc-type' => $ method [ 'docblock' ] [ 'return' ] , ] ; } } elseif ( $ method [ 'docblock' ] [ 'return' ] != $ method [ 'return' ] ) { if ( $ method [ 'return' ] == 'array' && substr ( $ method [ 'docblock' ] [ 'return' ] , - 2 ) == '[]' ) { } else { $ this -> warnings [ ] = [ 'type' => 'return-mismatch' , 'file' => $ file , 'class' => $ name , 'method' => $ name , 'line' => $ method [ 'line' ] , 'return-type' => $ method [ 'return' ] , 'doc-type' => $ method [ 'docblock' ] [ 'return' ] , ] ; } } } | Process method return . |
33,489 | public function actionView ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ providerBlock = new \ yii \ data \ ArrayDataProvider ( [ 'allModels' => $ model -> blocks , ] ) ; $ providerComment = new \ yii \ data \ ArrayDataProvider ( [ 'allModels' => $ model -> comments , ] ) ; $ providerPost = new \ yii \ data \ ArrayDataProvider ( [ 'allModels' => $ model -> posts , ] ) ; $ providerProduct = new \ yii \ data \ ArrayDataProvider ( [ 'allModels' => $ model -> products , ] ) ; $ providerTerm = new \ yii \ data \ ArrayDataProvider ( [ 'allModels' => $ model -> terms , ] ) ; return $ this -> render ( 'view' , [ 'model' => $ this -> findModel ( $ id ) , 'providerBlock' => $ providerBlock , 'providerComment' => $ providerComment , 'providerPost' => $ providerPost , 'providerProduct' => $ providerProduct , 'providerTerm' => $ providerTerm , ] ) ; } | Displays a single User model . |
33,490 | public function item ( ResourceManager $ resourceManager , ApiRequest $ request , int $ version , string $ resource , $ id ) { $ resourceManager -> version ( $ version ) ; $ handler = $ this -> initializeHandler ( $ resourceManager , $ resource , $ request , HandlesItemRequest :: class ) ; $ parameters = $ request -> asParameters ( ) ; $ repository = $ this -> initializeRepository ( $ resourceManager , $ resource , $ parameters ) ; $ result = $ handler -> handle ( $ id , $ repository , $ parameters ) ; if ( $ result instanceof \ Illuminate \ Support \ Collection ) { $ document = $ this -> makeDocumentFromCollection ( $ resourceManager , $ resource , $ result , $ parameters , $ handler ) ; } else { $ document = $ this -> makeDocumentFromResource ( $ resourceManager , $ resource , $ result , $ parameters , $ handler ) ; } return $ this -> respond ( $ document ) ; } | handles an item request to a resource |
33,491 | public function relatedItem ( ResourceManager $ resourceManager , ApiRequest $ request , int $ version , string $ resource , $ id , string $ relationship , $ parameter ) { $ resourceManager -> version ( $ version ) ; $ handler = $ this -> initializeHandler ( $ resourceManager , $ resource . '.' . $ relationship , $ request , HandlesRelationshipItemRequest :: class ) ; $ parameters = $ request -> asParameters ( ) ; $ resourceRepository = $ this -> initializeRepository ( $ resourceManager , $ resource , $ parameters ) ; $ model = $ resourceRepository -> findOrFail ( $ id ) ; $ repository = $ resourceManager -> resolveRepository ( $ resource . '.' . $ relationship ) ; $ result = $ handler -> relatedItem ( $ model , $ parameter , $ repository ) ; $ document = $ this -> makeDocumentFromResource ( $ resourceManager , $ resource . '.' . $ relationship , $ result , $ parameters , $ handler ) ; if ( config ( 'json-api.response.relationships.item.links.self' , false ) ) { $ document -> addLink ( 'self' , apiRouteRelationship ( $ resource , $ id , $ relationship , null , $ version ) ) ; } if ( config ( 'json-api.response.relationships.item.links.related' , false ) ) { $ document -> addLink ( 'related' , apiRoute ( $ resource , $ id ) ) ; } return $ this -> respond ( $ document ) ; } | handles relationship item request |
33,492 | private function assignAndResolveIncludes ( ResourceManager $ resourceManager , string $ resource , ElementInterface $ resourceOrCollection , Parameters $ parameters ) { $ relations = collect ( ) ; $ availableIncludes = $ this -> retrieveRelationsRecursive ( $ resource , $ relations , $ resourceManager ) ; $ resourceOrCollection -> with ( $ parameters -> getInclude ( $ availableIncludes -> all ( ) ) ) ; } | assigns resolved includes from request |
33,493 | private function initializeHandler ( ResourceManager $ resourceManager , string $ resource , ApiRequest $ request , string $ checkInterface = null ) { $ handler = $ resourceManager -> resolveRequestHandler ( $ resource ) ; if ( $ handler instanceof NeedsAuthenticatedUser && ! \ Auth :: check ( ) ) { throw new HttpException ( 401 , 'Unauthorized Request' ) ; } if ( $ checkInterface !== null ) { if ( ! $ handler instanceof $ checkInterface ) { throw new HttpException ( 400 , 'Bad Request' ) ; } } $ filterFactory = $ resourceManager -> resolveFilterFactory ( $ resource ) ; $ handler -> setRequest ( $ request ) -> setFilters ( $ request -> filters ( ) ) -> setFilterFactory ( $ filterFactory ) ; return $ handler ; } | returns initialized handler |
33,494 | private function makeDocumentFromCollection ( ResourceManager $ resourceManager , string $ resource , $ result , Parameters $ parameters , ApiRequestHandler $ handler ) { $ document = new Document ( ) ; $ serializer = $ resourceManager -> resolveSerializer ( $ resource ) ; if ( $ handler instanceof ModifiesSerializer ) { $ serializer = $ handler -> modify ( $ serializer ) ; } $ collection = new Collection ( $ result , $ serializer ) ; if ( $ handler instanceof HasElementIncludes ) { $ handler -> includes ( $ collection ) ; } $ this -> assignAndResolveIncludes ( $ resourceManager , $ resource , $ collection , $ parameters ) ; $ document -> setData ( $ collection ) ; if ( $ handler instanceof HasDocumentMeta ) { $ handler -> meta ( $ document ) ; } if ( config ( 'json-api.response.resources.links.self' , false ) ) { $ document -> addLink ( 'self' , apiRoute ( $ resource , null , request ( ) -> route ( 'version' ) ) ) ; } return $ document ; } | makes a document from collection |
33,495 | protected function setName ( $ name ) { if ( ! Preg :: match ( $ name , self :: PATTERN_NAME ) ) { throw new InvalidArgumentException ( sprintf ( "name can only be of '%s'. '%s' given" , self :: PATTERN_NAME , $ name ) ) ; } $ this -> name = $ name ; return $ this ; } | Its not allowed to change the name of the app |
33,496 | private function getRequest ( ) { $ token = $ this -> getParam ( 'token' ) ; if ( empty ( $ token ) ) { throw new ConfigurationException ( __CLASS__ . ' is not configured properly. Please set "token" parameter properly.' ) ; } $ request = new Request ( ) ; $ request -> setUri ( $ this -> url ) ; $ request -> setMethod ( Request :: METHOD_POST ) ; $ request -> getHeaders ( ) -> addHeaders ( array ( 'accept' => 'application/json' , 'content-type' => 'application/json' , 'authorization' => 'Basic ' . $ token ) ) ; return $ request ; } | Prepare request configuration |
33,497 | private function parseResponseMessage ( $ msg ) { if ( in_array ( $ msg -> status -> groupId , [ self :: STATUS_GROUPS_UNDELIVERABLE , self :: STATUS_GROUPS_EXPIRED , self :: STATUS_GROUPS_REJECTED ] ) ) { $ code = $ msg -> status -> id ; $ text = sprintf ( "Error id=%d (groupId=%d). Message: %s" , $ msg -> status -> id , $ msg -> status -> groupId , $ msg -> status -> description ) ; $ this -> addError ( new SendingError ( $ msg -> to , $ code , $ text ) ) ; return false ; } return true ; } | Parses response message . Optionally register errors . |
33,498 | public function transform ( $ groups ) { $ value = array ( ) ; if ( $ groups instanceof Collection ) { foreach ( $ groups as $ group ) { $ value [ $ group -> getId ( ) ] = array ( 'group' => true ) ; } } return array ( 'groups_collection' => $ value ) ; } | Transform an ArrayCollection of groups to array of group id |
33,499 | public function reverseTransform ( $ groups ) { $ value = new ArrayCollection ( ) ; if ( is_array ( $ groups ) && array_key_exists ( 'groups_collection' , $ groups ) ) { $ groups = $ groups [ 'groups_collection' ] ; foreach ( $ groups as $ groupId => $ group ) { if ( array_key_exists ( 'group' , $ group ) && $ group [ 'group' ] ) { $ group = $ this -> groupRepository -> find ( $ groupId ) ; if ( null !== $ group && in_array ( $ group -> getSite ( ) -> getId ( ) , $ this -> availableSiteIds ) ) { $ value -> add ( $ group ) ; } } } } return $ value ; } | Transform an array of group id to ArrayCollection of groups |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.