idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
7,800 | public function addResource ( $ format , $ resource , $ locale , $ domain = null ) { $ this -> standardResources [ ] = array ( 'format' => $ format , 'path' => $ resource , 'locale' => $ locale , 'domain' => $ domain === null ? 'messages' : $ domain , ) ; } | Override the addResource so that we can keep tracking standard resources but we don t call the parent method as we don t want to use them anymore . |
7,801 | public function getStandardResources ( ) { if ( ! $ this -> initialized && isset ( $ this -> options [ 'resource_files' ] ) ) { foreach ( $ this -> options [ 'resource_files' ] as $ files ) { foreach ( $ files as $ file ) { list ( $ domain , $ locale , $ format ) = explode ( '.' , basename ( $ file ) , 3 ) ; $ this -> ... | Return the list of standard resources . |
7,802 | public function loadResource ( $ resource ) { if ( in_array ( $ resource [ 'format' ] , array ( 'xliff' , 'xlf' ) ) ) { return $ this -> container -> get ( 'liip.translation.xliff.loader' ) -> load ( $ resource [ 'path' ] , $ resource [ 'locale' ] , $ resource [ 'domain' ] ) ; } foreach ( $ this -> loaderIds as $ servi... | Load a specific resource . |
7,803 | protected function initialize ( ) { if ( $ this -> initialized ) { return ; } parent :: initialize ( ) ; $ standardResources = $ this -> getStandardResources ( ) ; foreach ( $ standardResources as $ resource ) { parent :: addResource ( $ resource [ 'format' ] , $ resource [ 'path' ] , $ resource [ 'locale' ] , $ resour... | Initialize the translation before loading catalogues from the storage . |
7,804 | public function isDayAHoliday ( DateTime $ dateTime , $ region ) { $ holidayList = $ this -> holidayCalculator -> calculateHolidaysForYear ( ( int ) $ dateTime -> format ( 'Y' ) , $ region , $ dateTime -> getTimezone ( ) ) ; $ filteredHolidays = ( new IncludeTimespanFilter ( ) ) -> filter ( $ holidayList , [ IncludeTim... | Returns if the given date is a holiday in the given region . |
7,805 | public function getHolidaysForMonth ( $ year , $ month , $ region , DateTimeZone $ timezone = null ) { $ holidayList = $ this -> holidayCalculator -> calculateHolidaysForYear ( $ year , $ region , $ timezone ) ; $ date = new DateTime ( sprintf ( '%s-%s-01' , $ year , $ month ) , $ timezone ) ; $ lastDayOfMonth = ( int ... | Returns all holidays for the given month in the given region . |
7,806 | public function getHolidaysByName ( $ year , $ holidayName , $ region , DateTimeZone $ timezone = null ) { $ holidayList = $ this -> holidayCalculator -> calculateHolidaysForYear ( $ year , $ region , $ timezone ) ; $ filteredHolidays = ( new IncludeHolidayNameFilter ( ) ) -> filter ( $ holidayList , [ IncludeHolidayNa... | Returns all holidays with the given name for the given year in the given region . Note that holiday names are not necessarily unique and therefore a HolidayList object is returned . |
7,807 | public function getNoWorkDaysForTimespan ( DateTime $ firstDay , DateTime $ lastDay , $ region , array $ noWorkWeekdayProviders = [ ] ) { if ( count ( $ noWorkWeekdayProviders ) > 0 ) { $ noWork = $ noWorkWeekdayProviders ; } else { $ noWork = [ new Sundays ( ) , ] ; } $ startYear = ( int ) $ firstDay -> format ( 'Y' )... | Returns all days in the given timespan and the region in which normally employees do not need to work . Be aware that this method is quite heavy - weight if multiple no - work days for multiple years are requested . |
7,808 | public function mergeHolidayLists ( array $ holidayLists ) { $ newList = new HolidayList ( ) ; foreach ( $ holidayLists as $ holidayList ) { foreach ( $ holidayList -> getList ( ) as $ holiday ) { $ newList -> add ( $ holiday ) ; } } return ( new SortByDateFilter ( ) ) -> filter ( $ newList ) ; } | Returns a merged list of all the HolidayList objects given . |
7,809 | public function log ( $ error ) { if ( $ error instanceof \ Error || $ error instanceof \ ErrorException ) { return $ this -> logError ( $ error ) ; } if ( $ error instanceof \ Exception ) { return $ this -> logException ( $ error ) ; } $ message = "Unable to log a " . ( is_object ( $ error ) ? get_class ( $ error ) . ... | Log an error or exception |
7,810 | protected function logException ( \ Exception $ exception ) { $ level = $ this -> getLogLevel ( ) ; $ message = sprintf ( 'Uncaught Exception %s: "%s" at %s line %s' , get_class ( $ exception ) , $ exception -> getMessage ( ) , $ exception -> getFile ( ) , $ exception -> getLine ( ) ) ; $ context = compact ( 'exception... | Log an exception |
7,811 | final public static function createByName ( string $ name ) { $ canonicalName = strtoupper ( $ name ) ; if ( $ canonicalName !== $ name ) { $ name = $ canonicalName ; trigger_error ( 'PSR-1 requires constant to be declared in upper case.' , E_USER_NOTICE ) ; } $ const = static :: getConstList ( ) ; if ( ! \ in_array ( ... | Creates enum instance by name |
7,812 | private static function createNamedInstance ( string $ name ) { $ class = self :: findParentClassForConst ( $ name ) ; $ key = self :: getConstKey ( $ class , $ name ) ; if ( ! array_key_exists ( $ key , self :: $ instances ) ) { self :: $ instances [ $ key ] = new static ( $ name ) ; } return self :: $ instances [ $ k... | Create named enum instance |
7,813 | private function _call ( $ method , $ path , $ param , $ header = false ) { $ this -> curl -> resetConnection ( ) ; if ( $ header ) { foreach ( $ header as $ name => $ value ) { $ this -> curl -> setHeader ( $ name , $ value ) ; } } if ( $ param ) { $ payload = false ; if ( $ method != 'GET' ) { $ param = json_encode (... | Connection logic ; send requests to the Gdax API . |
7,814 | public static function createComposerInMemoryPackage ( $ targetDir , $ tag ) { $ package = new Package ( 'apiaryio/drafter' , 'drafter' , $ tag ) ; $ package -> setTargetDir ( $ targetDir ) ; $ package -> setInstallationSource ( 'source' ) ; $ package -> setSourceUrl ( 'https://github.com/apiaryio/drafter' ) ; $ packag... | Create composer in memory package |
7,815 | private function generateMessage ( $ notification ) { $ message = ucfirst ( $ notification [ 'type' ] ) . '\n\n' ; if ( ! is_null ( $ notification [ 'title' ] ) ) { $ message .= $ this -> escapeTitle ( $ notification [ 'title' ] ) . '\n\n' ; } return $ this -> escapeMessage ( $ message . $ notification [ 'message' ] ) ... | Generate the message for a native alert |
7,816 | public function run ( ) { if ( empty ( $ this -> items ) ) { return ; } if ( ! isset ( $ this -> containerOptions [ 'id' ] ) ) { $ this -> containerOptions [ 'id' ] = $ this -> getId ( ) ; } echo $ this -> renderItems ( ) . "\n" ; $ this -> registerAssets ( ) ; } | Render range slider |
7,817 | public function renderItems ( ) { $ items = [ ] ; for ( $ i = 0 , $ count = count ( $ this -> items ) ; $ i < $ count ; $ i ++ ) { $ items [ ] = Html :: tag ( 'li' , $ this -> items [ $ i ] , $ this -> itemOptions ) ; } return Html :: tag ( 'ul' , implode ( "\n" , $ items ) , $ this -> containerOptions ) ; } | Renders slider items . |
7,818 | public function saveUnit ( Unit $ unit ) { $ propelUnit = UnitQuery :: create ( ) -> findOneByDomainAndKey ( $ unit -> getDomain ( ) , $ unit -> getKey ( ) ) ; if ( ! $ propelUnit ) { $ propelUnit = new PropelUnit ( ) ; } $ propelUnit -> updateFromModel ( $ unit ) ; $ propelUnit -> save ( ) ; } | Save the given Unit to the persistence layer . |
7,819 | public function getAuthorizedLocaleList ( $ securityChecker ) { $ this -> validateSecurityChecker ( $ securityChecker ) ; if ( ! $ securityChecker || ! $ this -> isSecuredByLocale ( ) ) { return $ this -> getLocaleList ( ) ; } $ authorizedLocaleList = array ( ) ; foreach ( $ this -> getLocaleList ( ) as $ locale ) { if... | Return the list of locales authorized by the provided security context . |
7,820 | public function load ( $ resource , $ locale , $ domain = 'messages' ) { $ base_catalogue = parent :: load ( $ resource , $ locale , $ domain ) ; $ catalogue = new MessageCatalogue ( $ locale ) ; $ catalogue -> addCatalogue ( $ base_catalogue ) ; $ xml = simplexml_load_file ( $ resource ) ; $ xml -> registerXPathNamesp... | Load translations and metadata of the trans - unit . |
7,821 | public function setUnits ( $ units ) { $ this -> unitsByLocaleAndDomain = array ( ) ; foreach ( $ units as $ unit ) { foreach ( $ unit -> getTranslations ( ) as $ translation ) { $ this -> unitsByLocaleAndDomain [ $ translation -> getLocale ( ) ] [ $ translation -> getDomain ( ) ] [ ] = $ translation ; } } } | Set the units you want to export . |
7,822 | public function createZipContent ( ) { $ zipFile = $ this -> createZipFile ( ) ; $ content = file_get_contents ( $ zipFile ) ; unlink ( $ zipFile ) ; return $ content ; } | Create the data of a zip file from the current units . |
7,823 | public function createZipFile ( $ path = null ) { if ( $ path === null ) { $ path = tempnam ( sys_get_temp_dir ( ) , 'temp-zip-' ) ; } $ zip = new \ ZipArchive ( ) ; $ zip -> open ( $ path , \ ZipArchive :: CREATE ) ; $ this -> addYmlFiles ( $ zip ) ; $ zip -> close ( ) ; return $ path ; } | Create a zip file from the current units . |
7,824 | public function convertToModel ( ) { $ unit = new \ Liip \ TranslationBundle \ Model \ Unit ( $ this -> getDomain ( ) , $ this -> getKey ( ) , $ this -> getMetadata ( ) ) ; foreach ( $ this -> getTranslations ( ) as $ translation ) { $ unit -> setTranslation ( $ translation -> getLocale ( ) , $ translation -> getValue ... | Create a ModelUnit representation of a this object . |
7,825 | public function updateFromModel ( ModelUnit $ unit ) { $ this -> setDomain ( $ unit -> getDomain ( ) ) ; $ this -> setKey ( $ unit -> getKey ( ) ) ; $ this -> setMetadata ( $ unit -> getMetadata ( ) ) ; } | Update the current object from a ModelUnit . |
7,826 | public function getOrCreateTranslationForLocale ( $ locale ) { foreach ( $ this -> getTranslations ( ) as $ propelTranslation ) { if ( $ propelTranslation -> getLocale ( ) == $ locale ) { return $ propelTranslation ; } } $ propelTranslation = new PropelTranslation ( ) ; $ propelTranslation -> setLocale ( $ locale ) ; $... | Get or create a Propel Tranlation object for the given locale . |
7,827 | public function getIBAN ( ) { if ( ! is_null ( $ this -> iban ) ) { return $ this -> iban ; } $ this -> country = strtoupper ( $ this -> country ) ; $ part1 = ord ( $ this -> country [ 0 ] ) - ord ( 'A' ) + 10 ; $ part2 = ord ( $ this -> country [ 1 ] ) - ord ( 'A' ) + 10 ; $ accountPrefix = 0 ; $ accountNumber = $ thi... | Converts account and bank numbers to IBAN |
7,828 | public function resetConnection ( ) { $ this -> reset ( ) ; $ this -> setOpt ( CURLOPT_TIMEOUT_MS , $ this -> timeout ) ; $ this -> setHeader ( "Content-Type" , "application/json" ) ; } | Reset the curl connection . |
7,829 | public function setError ( $ error ) { if ( isset ( $ error ) && ! $ error instanceof \ Error && ! $ error instanceof \ Exception ) { $ type = ( is_object ( $ error ) ? get_class ( $ error ) . ' ' : '' ) . gettype ( $ error ) ; trigger_error ( "Excpeted an Error or Exception, got a $type" , E_USER_WARNING ) ; return ; ... | Set the caught error |
7,830 | public function onFatalError ( $ callback , $ clearOutput = false ) { if ( ! $ clearOutput ) { $ this -> onFatalError = $ callback ; } else { $ this -> onFatalError = function ( $ error ) use ( $ callback ) { $ this -> clearOutputBuffer ( ) ; $ callback ( $ error ) ; } ; } } | Set a callback for when the script dies because of a fatal non - catchable error . The callback should have an ErrorException as only argument . |
7,831 | public function cost ( array $ route ) : float { $ result = 0 ; if ( count ( $ route ) > 0 ) { $ num = count ( $ route ) - 1 ; for ( $ i = 0 ; $ i < $ num ; $ i ++ ) { if ( ! isset ( $ this -> nodes [ $ route [ $ i ] ] [ $ route [ $ i + 1 ] ] ) ) { throw new \ UnexpectedValueException ( "edge from {$route[$i]} to {$rou... | calculate cost of route |
7,832 | public function updateFromModel ( ModelTranslation $ translation ) { $ this -> setLocale ( $ translation -> getLocale ( ) ) ; $ this -> setValue ( $ translation -> getValue ( ) ) ; $ this -> setMetadata ( $ translation -> getMetadata ( ) ) ; } | Update this object from a ModelTranslation . |
7,833 | public function add ( Holiday $ holiday ) { if ( - 1 !== $ index = $ this -> getIndexByNameAndDate ( $ holiday -> getName ( ) , $ holiday -> getDate ( ) ) ) { $ this -> holidayList [ $ index ] = new Holiday ( $ holiday -> getName ( ) , $ holiday -> getDate ( ) , $ holiday -> getType ( ) | $ this -> holidayList [ $ inde... | Adds a holiday to the list . If there already is a holiday with the same name and date then the holiday will not be added a second time but its types will be added to the existing one . |
7,834 | public function fetch ( $ url , $ key ) { $ bucketMgr = $ this -> getBucketManager ( ) ; list ( $ ret , $ err ) = $ bucketMgr -> fetch ( $ url , $ this -> bucket , $ key ) ; if ( $ err !== null ) { $ this -> logQiniuError ( $ err ) ; return false ; } else { return $ ret [ 'key' ] ; } } | Fetch a file from url . |
7,835 | public function getRelationData ( $ attribute ) { return isset ( $ this -> relationalData [ $ attribute ] ) ? $ this -> relationalData [ $ attribute ] [ 'data' ] : null ; } | Return relation data of attribute |
7,836 | public function canSetProperty ( $ name , $ checkVars = true ) { return array_key_exists ( $ name , $ this -> relationalFields ) || parent :: canSetProperty ( $ name , $ checkVars ) ; } | Permission for this behavior to set relational attributes . |
7,837 | protected function loadData ( ) { foreach ( $ this -> relationalData as $ attribute => & $ data ) { $ getter = 'get' . ucfirst ( $ attribute ) ; $ data [ 'activeQuery' ] = $ activeQuery = $ this -> owner -> $ getter ( ) ; $ data [ 'newModels' ] = [ ] ; $ data [ 'oldModels' ] = [ ] ; $ data [ 'newRows' ] = [ ] ; $ data ... | Load relational data from owner - model getter . |
7,838 | protected function validateData ( ) { foreach ( $ this -> relationalData as $ attribute => & $ data ) { $ activeQuery = $ data [ 'activeQuery' ] ; foreach ( $ data [ 'newModels' ] as & $ model ) { if ( ! $ model -> validate ( ) ) { $ _errors = $ model -> getErrors ( ) ; $ errors = [ ] ; foreach ( $ _errors as $ related... | Validate relational models return true only if all models successfully validated . Skip errors for foreign columns . |
7,839 | public function saveData ( ) { $ needSaveOwner = false ; foreach ( $ this -> relationalData as $ attribute => $ data ) { $ this -> deleteModels ( $ attribute ) ; $ this -> saveModels ( $ attribute ) ; if ( ! $ data [ 'activeQuery' ] -> multiple && ( count ( $ data [ 'newModels' ] ) == 0 || ! $ data [ 'newModels' ] [ 0 ... | Save changed related models . |
7,840 | protected function relationsMap ( $ relations , $ callback ) { try { if ( is_callable ( $ callback ) ) { array_map ( $ callback , $ relations ) ; } } catch ( \ Exception $ e ) { Yii :: $ app -> getDb ( ) -> getTransaction ( ) -> rollBack ( ) ; throw new RelationException ( 'Owner-model not saved due to unknown error' )... | Execute callback for each relation |
7,841 | protected function replaceExistingModel ( $ model , $ attribute ) { $ modelAttributes = $ model -> attributes ; unset ( $ modelAttributes [ $ model -> primaryKey ( ) [ 0 ] ] ) ; foreach ( $ this -> relationalData [ $ attribute ] [ 'oldModels' ] as $ oldModel ) { $ oldModelAttributes = $ oldModel -> attributes ; unset (... | Return existing model if it found in old models |
7,842 | protected function isExistingRow ( $ row , $ attribute ) { $ rowAttributes = $ row ; unset ( $ rowAttributes [ $ this -> relationalData [ $ attribute ] [ 'junctionColumn' ] ] ) ; foreach ( $ this -> relationalData [ $ attribute ] [ 'oldRows' ] as $ oldRow ) { $ oldModelAttributes = $ oldRow ; unset ( $ oldModelAttribut... | Check existing row if it found in old rows |
7,843 | public function afterDelete ( ) { foreach ( $ this -> relationalFields as $ attribute => $ value ) { $ getter = 'get' . ucfirst ( $ attribute ) ; $ activeQuery = $ this -> owner -> $ getter ( ) ; $ models = [ ] ; if ( empty ( $ activeQuery -> via ) ) { $ models = $ activeQuery -> all ( ) ; } else { if ( $ activeQuery -... | Delete related models . Rollback transaction and throw RelationException if error occurred while deleting . |
7,844 | protected function validateOnCondition ( $ activeQuery ) { if ( ! ArrayHelper :: isAssociative ( $ activeQuery -> on ) && ! empty ( $ activeQuery -> on ) ) { return false ; } if ( $ activeQuery -> multiple && ! empty ( $ activeQuery -> via ) && is_array ( $ activeQuery -> via ) && is_object ( $ activeQuery -> via [ 1 ]... | Validate ON condition in ActiveQuery |
7,845 | protected function loadModelsOneToOne ( $ attribute ) { $ data = $ this -> relationalData [ $ attribute ] ; $ activeQuery = $ data [ 'activeQuery' ] ; $ class = $ activeQuery -> modelClass ; $ model = new $ class ( $ data [ 'data' ] ) ; if ( isset ( $ this -> relations [ $ attribute ] ) && is_callable ( $ this -> relat... | Load new model from POST for one - to - one relation |
7,846 | protected function loadModelsOneToMany ( $ attribute ) { $ data = $ this -> relationalData [ $ attribute ] ; $ activeQuery = $ data [ 'activeQuery' ] ; $ class = $ activeQuery -> modelClass ; $ params = ! ArrayHelper :: isAssociative ( $ activeQuery -> on ) ? [ ] : $ activeQuery -> on ; foreach ( $ activeQuery -> link ... | Load new models from POST for one - to - many relation |
7,847 | protected function loadModelsManyToManyViaTable ( $ attribute ) { $ data = $ this -> relationalData [ $ attribute ] ; $ activeQuery = $ data [ 'activeQuery' ] ; $ class = $ activeQuery -> modelClass ; $ via = $ activeQuery -> via ; $ data [ 'junctionTable' ] = $ via -> from [ 0 ] ; list ( $ data [ 'junctionColumn' ] ) ... | Load new models from POST for many - to - many relation with viaTable |
7,848 | protected function loadModelsManyToManyVia ( $ attribute ) { $ data = $ this -> relationalData [ $ attribute ] ; $ activeQuery = $ data [ 'activeQuery' ] ; $ class = $ activeQuery -> modelClass ; if ( ! is_object ( $ activeQuery -> via [ 1 ] ) ) { throw new RelationException ( 'via condition for attribute ' . $ attribu... | Load new models from POST for many - to - many relation with via |
7,849 | protected function saveModels ( $ attribute ) { $ data = $ this -> relationalData [ $ attribute ] ; foreach ( $ data [ 'newModels' ] as $ model ) { if ( $ model -> isNewRecord ) { if ( ! empty ( $ data [ 'activeQuery' ] -> via ) ) { $ junctionColumn = $ data [ 'junctionColumn' ] ; $ model -> $ junctionColumn = $ this -... | Save all new models for attribute |
7,850 | protected function deleteModels ( $ attribute ) { $ data = $ this -> relationalData [ $ attribute ] ; foreach ( $ data [ 'oldModels' ] as $ model ) { if ( $ this -> isDeletedModel ( $ model , $ attribute ) ) { if ( ! $ model -> delete ( ) ) { Yii :: $ app -> getDb ( ) -> getTransaction ( ) -> rollBack ( ) ; throw new R... | Delete all old models for attribute if it needed |
7,851 | public function indexAction ( ) { return $ this -> render ( 'LiipTranslationBundle:Import:index.html.twig' , array ( 'upload_form' => $ this -> createForm ( new FileImportType ( ) ) -> createView ( ) , 'translations' => $ this -> getSessionImporter ( ) -> getCurrentTranslations ( ) , ) ) ; } | Importating dashboard . |
7,852 | public function uploadAction ( Request $ request ) { $ form = $ this -> createForm ( new FileImportType ( ) ) ; $ data = $ form -> handleRequest ( $ request ) -> getData ( ) ; $ session = $ this -> getSession ( ) ; try { $ counters = $ this -> getSessionImporter ( ) -> handleUploadedFile ( $ data [ 'file' ] ) ; if ( $ ... | File upload handling redirect to the dashboard . |
7,853 | public function removeEntryAction ( $ locale , $ domain , $ key ) { $ this -> securityCheck ( $ domain , $ locale ) ; $ this -> getSessionImporter ( ) -> remove ( $ domain , $ key , $ locale ) ; $ session = $ this -> getSession ( ) ; $ session -> getFlashBag ( ) -> set ( 'success' , 'Entry removed' ) ; return $ this ->... | Remove an entry from the session . |
7,854 | public function processAction ( $ locale ) { $ stats = $ this -> getSessionImporter ( ) -> comfirmImportation ( $ locale ) ; $ session = $ this -> getSession ( ) ; $ session -> getFlashBag ( ) -> set ( 'success' , "Import success ({$stats['translations']['text']})" ) ; return $ this -> redirect ( $ this -> generateUrl ... | Process the importation for the given locale and redirect to the dashboard . |
7,855 | public static function fromFile ( $ file , array $ option = array ( ) ) { if ( ! file_exists ( $ file ) ) { throw new \ InvalidArgumentException ( 'File not found: ' . $ file ) ; } return new self ( new FileIterator ( $ file ) , $ option ) ; } | Returns new instance from CSV file |
7,856 | public static function fromString ( $ csv , array $ option = array ( ) ) { $ lines = array ( ) ; if ( $ csv !== '' ) { if ( ! preg_match ( '/(\r|\n|\r\n)\Z/m' , $ csv ) ) { $ csv .= "\n" ; } preg_match_all ( '/[^\r\n]*(?:\r|\n|\r\n)+/m' , $ csv , $ matches ) ; $ lines = $ matches [ 0 ] ; } return self :: fromArray ( $ ... | Returns new instance from string |
7,857 | public static function decode ( $ json ) { $ flags = 0 ; if ( PHP_INT_SIZE === 4 ) { $ flags |= JSON_BIGINT_AS_STRING ; } $ data = json_decode ( $ json , false , 512 , $ flags ) ; $ error = json_last_error ( ) ; if ( $ error !== JSON_ERROR_NONE ) { throw new \ InvalidArgumentException ( sprintf ( 'Failed to decode JSON... | Special decoder to keep big numbers on x86 PHP builds . |
7,858 | protected function decodeJwtTokenCookie ( $ request ) { return ( array ) JWT :: decode ( $ this -> encrypter -> decrypt ( $ request -> cookie ( Passport :: cookie ( ) ) ) , $ this -> encrypter -> getKey ( ) , [ 'HS256' ] ) ; } | Decode and decrypt the JWT token cookie . |
7,859 | private static function customPBKDF2 ( $ algorithm , $ password , $ salt , $ count , $ key_length ) { $ hash_length = strlen ( hash ( $ algorithm , '' , true ) ) ; if ( 0 === $ key_length ) { $ key_length = $ hash_length ; } $ block_count = ceil ( $ key_length / $ hash_length ) ; $ output = '' ; for ( $ i = 1 ; $ i <= ... | Pure PHP PBKDF2 key derivation function . |
7,860 | public function createRequest ( $ method , $ uri , array $ headers = [ ] , $ body = null , $ protocol_version = '1.1' ) { return ( new Request ( $ uri , $ method , $ this -> stream -> createStream ( $ body ) , $ headers ) ) -> withProtocolVersion ( $ protocol_version ) ; } | Create a PSR - 7 request |
7,861 | public function createResponse ( $ status = 200 , $ reason = null , array $ headers = [ ] , $ body = null , $ protocol_version = '1.1' ) { return ( new Response ( $ this -> stream -> createStream ( $ body ) , $ status , $ headers ) ) -> withProtocolVersion ( $ protocol_version ) ; } | Create a PSR - 7 response |
7,862 | public static function create ( RequestInterface $ request , ResponseInterface $ response , Exception $ last_exception = null ) { $ message = sprintf ( '[url] %s [http method] %s [status code] %s [reason phrase] %s' , $ request -> getRequestTarget ( ) , $ request -> getMethod ( ) , $ response -> getStatusCode ( ) , $ r... | Create a new exception with standardized error message |
7,863 | public function getValidToken ( $ user , $ client ) { return $ client -> tokens ( ) -> whereUserId ( $ user -> getKey ( ) ) -> whereRevoked ( 0 ) -> where ( 'expires_at' , '>' , Carbon :: now ( ) ) -> first ( ) ; } | Get a valid token instance for the given user and client . |
7,864 | public function addHeader ( $ header_line ) { $ header_parts = explode ( ':' , $ header_line , 2 ) ; if ( count ( $ header_parts ) !== 2 ) { throw new InvalidArgumentException ( "'$header_line' is not a valid HTTP header line" ) ; } $ header_name = trim ( $ header_parts [ 0 ] ) ; $ header_value = trim ( $ header_parts ... | Add response header from header line string |
7,865 | public function setHeadersFromArray ( array $ headers ) { $ status = array_shift ( $ headers ) ; $ this -> setStatus ( $ status ) ; foreach ( $ headers as $ header ) { $ header_line = trim ( $ header ) ; if ( $ header_line === '' ) { continue ; } $ this -> addHeader ( $ header_line ) ; } return $ this ; } | Set response headers from header line array |
7,866 | public function setHeadersFromString ( $ headers ) { if ( is_string ( $ headers ) || ( is_object ( $ headers ) && method_exists ( $ headers , '__toString' ) ) ) { $ this -> setHeadersFromArray ( explode ( "\r\n" , $ headers ) ) ; return $ this ; } throw new InvalidArgumentException ( sprintf ( '%s expects parameter 1 t... | Set response headers from header line string |
7,867 | public function setStatus ( $ status_line ) { $ status_parts = explode ( ' ' , $ status_line , 3 ) ; $ parts_count = count ( $ status_parts ) ; if ( $ parts_count < 2 || strpos ( strtoupper ( $ status_parts [ 0 ] ) , 'HTTP/' ) !== 0 ) { throw new InvalidArgumentException ( "'$status_line' is not a valid HTTP status lin... | Set reponse status |
7,868 | function updateTarget ( $ id , $ target ) { if ( is_array ( $ target ) ) { $ target = new Target ( $ target ) ; } else if ( ! ( $ target instanceof Target ) ) { throw new Exception ( "Invalid target type. Only array and VuforiaWebService/Target are supported" ) ; } if ( ! empty ( $ target -> name ) ) { if ( ! empty ( $... | Update target with info by ID |
7,869 | public function edit ( $ id , Request $ request ) { $ content = json_decode ( $ request -> getContent ( ) , true ) ; if ( empty ( $ content ) ) { return ; } $ document = $ this -> get ( $ id ) ; if ( isset ( $ content [ 'messages' ] ) ) { $ this -> updateMessages ( $ document , $ content [ 'messages' ] ) ; unset ( $ co... | Edits object from translation . |
7,870 | public function getAll ( array $ filters = null ) { $ search = $ this -> repository -> createSearch ( ) ; $ search -> addQuery ( new MatchAllQuery ( ) ) ; $ search -> setScroll ( '2m' ) ; if ( $ filters ) { foreach ( $ filters as $ field => $ value ) { $ search -> addQuery ( new TermsQuery ( $ field , $ value ) ) ; } }... | Returns all translations if filters are not specified |
7,871 | private function getGroupTypeInfo ( $ type ) { $ search = $ this -> repository -> createSearch ( ) ; $ search -> addAggregation ( new TermsAggregation ( $ type , $ type ) ) ; $ result = $ this -> repository -> findDocuments ( $ search ) ; $ aggregation = $ result -> getAggregation ( $ type ) ; $ items = [ ] ; foreach (... | Returns a list of available tags or domains . |
7,872 | private function establishConnection ( $ host , $ port , Connection $ connection , $ timeout ) { $ this -> logger -> info ( sprintf ( 'Connecting to %s:%d...' , $ host , $ port ) ) ; return $ this -> client -> connect ( $ host , $ port , $ connection , $ timeout ) ; } | Establishes a connection to the FBNS server . |
7,873 | public function connect ( $ host , $ port , Connection $ connection , $ timeout = 5 ) { $ deferred = new Deferred ( ) ; $ this -> disconnect ( ) -> then ( function ( ) use ( $ deferred , $ host , $ port , $ connection , $ timeout ) { $ this -> establishConnection ( $ host , $ port , $ connection , $ timeout ) -> then (... | Connects to a FBNS server . |
7,874 | private function mapTopic ( $ topic ) { if ( array_key_exists ( $ topic , self :: TOPIC_TO_ID_ENUM ) ) { $ result = self :: TOPIC_TO_ID_ENUM [ $ topic ] ; $ this -> logger -> debug ( sprintf ( 'Topic "%s" has been mapped to "%s".' , $ topic , $ result ) ) ; } else { $ result = $ topic ; $ this -> logger -> debug ( spri... | Maps human readable topic to its ID . |
7,875 | private function unmapTopic ( $ topic ) { if ( array_key_exists ( $ topic , self :: ID_TO_TOPIC_ENUM ) ) { $ result = self :: ID_TO_TOPIC_ENUM [ $ topic ] ; $ this -> logger -> debug ( sprintf ( 'Topic ID "%s" has been unmapped to "%s".' , $ topic , $ result ) ) ; } else { $ result = $ topic ; $ this -> logger -> debug... | Maps topic ID to human readable name . |
7,876 | public function register ( $ packageName , $ appId ) { $ this -> logger -> info ( sprintf ( 'Registering application "%s" (%s).' , $ packageName , $ appId ) ) ; $ message = json_encode ( [ 'pkg_name' => ( string ) $ packageName , 'appid' => ( string ) $ appId , ] ) ; return $ this -> publish ( self :: REG_REQ_TOPIC , $... | Registers an application . |
7,877 | private function handleFilter ( QueryBuilder $ queryBuilder , ClassMetadata $ resourceMetadata , array $ aliases , array $ associationsMetadata , $ property , $ value , $ parameter = null ) { $ queryExpr = [ ] ; if ( false !== strpos ( $ property , '.' ) ) { $ explodedProperty = explode ( '.' , $ property ) ; } else { ... | Handles the given filter to call the proper operator . At this point it s unclear if the value passed is the real value operator . |
7,878 | private function normalizeValue ( ClassMetadata $ metadata , $ property , $ value ) { if ( self :: PARAMETER_ID_KEY === $ property ) { return $ this -> getFilterValueFromUrl ( $ value ) ; } if ( self :: PARAMETER_NULL_VALUE === $ value ) { return null ; } switch ( $ metadata -> getTypeOfField ( $ property ) ) { case 'b... | Normalizes the value . If the key is an ID get the real ID value . If is null set the value to null . Otherwise return unchanged value . |
7,879 | protected function getFilterValueFromUrl ( $ value ) { try { if ( $ item = $ this -> iriConverter -> getItemFromIri ( $ value ) ) { return $ this -> propertyAccessor -> getValue ( $ item , 'id' ) ; } } catch ( \ InvalidArgumentException $ e ) { } return $ value ; } | Gets the ID from an URI or a raw ID . |
7,880 | private function getResourceAliasForProperty ( array & $ aliases , array $ explodedProperty ) { if ( 0 === count ( $ explodedProperty ) ) { return 'o' ; } foreach ( $ explodedProperty as $ property ) { if ( false === isset ( $ aliases [ $ property ] ) ) { $ aliases [ $ property ] = sprintf ( 'WhereFilter_%sAlias' , imp... | Gets the alias used for the entity to which the property belongs . |
7,881 | private function getAssociationMetadataForProperty ( ClassMetadata $ resourceMetadata , array & $ associationsMetadata , array $ explodedProperty ) { if ( 0 === count ( $ explodedProperty ) ) { return $ resourceMetadata ; } $ parentResourceMetadata = $ resourceMetadata ; foreach ( $ explodedProperty as $ index => $ pro... | Gets the metadata to which belongs the property . |
7,882 | private function setFiltersManager ( $ repository , ContainerBuilder $ container ) { $ definition = new Definition ( 'ONGR\FilterManagerBundle\Search\FilterManager' , [ new Reference ( 'ongr_translations.filters_container' ) , new Reference ( $ repository ) , new Reference ( 'event_dispatcher' ) , new Reference ( 'jms_... | Adds filter manager for displaying translations gui . |
7,883 | function verifySignedJwtWithCerts ( $ jwt , $ certs , $ required_audience ) { $ segments = explode ( "." , $ jwt ) ; if ( count ( $ segments ) != 3 ) { throw new AuthException ( "Wrong number of segments in token: $jwt" ) ; } $ signed = $ segments [ 0 ] . "." . $ segments [ 1 ] ; $ signature = Utils :: urlSafeB64Decode... | Visible for testing . |
7,884 | public static function groupBy ( $ data , $ key ) { $ res = [ ] ; for ( $ i = 0 , $ l = sizeof ( $ data ) ; $ i < $ l ; $ i ++ ) { $ item = $ data [ $ i ] ; $ value = empty ( $ item [ $ key ] ) ? __undefined : $ item [ $ key ] ; if ( empty ( $ res [ $ value ] ) ) { $ res [ $ value ] = [ ] ; } $ res [ $ value ] [ ] = $ ... | Group up selectors by some key |
7,885 | public function getId ( ) { if ( ! $ this -> id ) { $ this -> setId ( sha1 ( $ this -> getDomain ( ) . $ this -> getKey ( ) ) ) ; } return $ this -> id ; } | Returns document id . |
7,886 | public function getMessagesArray ( ) { $ result = [ ] ; foreach ( $ this -> getMessages ( ) as $ message ) { $ result [ $ message -> getLocale ( ) ] = $ message ; } return $ result ; } | Returns messages as array . |
7,887 | public function copyItem ( string $ targetId , string $ itemId , bool $ overwrite = false ) : array { $ parameters = $ this -> buildHttpQuery ( [ 'targetid' => $ targetId , 'overwrite' => $ overwrite , ] ) ; return $ this -> post ( "Items({$itemId})/Copy?{$parameters}" ) ; } | Copy an item . |
7,888 | public function getItemDownloadUrl ( string $ itemId , bool $ includeallversions = false ) : array { $ parameters = $ this -> buildHttpQuery ( [ 'includeallversions' => $ includeallversions , 'redirect' => false , ] ) ; return $ this -> get ( "Items({$itemId})/Download?{$parameters}" ) ; } | Get temporary download URL for an item . |
7,889 | public function getItemContents ( string $ itemId , bool $ includeallversions = false ) { $ parameters = $ this -> buildHttpQuery ( [ 'includeallversions' => $ includeallversions , 'redirect' => true , ] ) ; return $ this -> get ( "Items({$itemId})/Download?{$parameters}" ) ; } | Get contents of and item . |
7,890 | public function getChunkUri ( string $ method , string $ filename , string $ folderId , bool $ unzip = false , $ overwrite = true , bool $ notify = true , bool $ raw = false , $ stream = null ) : array { $ parameters = $ this -> buildHttpQuery ( [ 'method' => $ method , 'raw' => $ raw , 'fileName' => basename ( $ filen... | Get the Chunk Uri to start a file - upload . |
7,891 | public function uploadFileStandard ( string $ filename , string $ folderId , bool $ unzip = false , bool $ overwrite = true , bool $ notify = true ) : string { $ chunkUri = $ this -> getChunkUri ( 'standard' , $ filename , $ folderId , $ unzip , $ overwrite , $ notify ) ; $ response = $ this -> client -> request ( 'POS... | Upload a file using a single HTTP POST . |
7,892 | public function uploadFileStreamed ( $ stream , string $ folderId , string $ filename = null , bool $ unzip = false , bool $ overwrite = true , bool $ notify = true , int $ chunkSize = null ) : string { $ filename = $ filename ?? stream_get_meta_data ( $ stream ) [ 'uri' ] ; if ( empty ( $ filename ) ) { return 'Error:... | Upload a file using multiple HTTP POSTs . |
7,893 | public function getThumbnailUrl ( string $ itemId , int $ size = 75 ) : array { $ parameters = $ this -> buildHttpQuery ( [ 'size' => $ size , 'redirect' => false , ] ) ; return $ this -> get ( "Items({$itemId})/Thumbnail?{$parameters}" ) ; } | Get Thumbnail of an item . |
7,894 | public function createShare ( array $ options , $ notify = false ) : array { $ parameters = $ this -> buildHttpQuery ( [ 'notify' => $ notify , 'direct' => true , ] ) ; return $ this -> post ( "Shares?{$parameters}" , $ options ) ; } | Share Share for external user . |
7,895 | public function getItemAccessControls ( string $ itemId , string $ userId = '' ) : array { if ( ! empty ( $ userId ) ) { return $ this -> get ( "AccessControls(principalid={$userId},itemid={$itemId})" ) ; } else { return $ this -> get ( "Items({$itemId})/AccessControls" ) ; } } | Get AccessControl List for an item . |
7,896 | protected function uploadChunk ( $ uri , $ data ) { $ response = $ this -> client -> request ( 'POST' , $ uri , [ 'headers' => [ 'Content-Length' => strlen ( $ data ) , 'Content-Type' => 'application/octet-stream' , ] , 'body' => $ data , ] ) ; return ( string ) $ response -> getBody ( ) ; } | Upload a chunk of data using HTTP POST body . |
7,897 | protected function determineException ( ClientException $ exception ) : Exception { if ( in_array ( $ exception -> getResponse ( ) -> getStatusCode ( ) , [ 400 , 403 , 404 , 409 ] ) ) { return new BadRequest ( $ exception -> getResponse ( ) ) ; } return $ exception ; } | Handle ClientException . |
7,898 | protected function buildHttpQuery ( array $ parameters ) : string { return http_build_query ( array_map ( function ( $ parameter ) { if ( ! is_bool ( $ parameter ) ) { return $ parameter ; } return $ parameter ? 'true' : 'false' ; } , $ parameters ) ) ; } | Build HTTP query . |
7,899 | protected function jsonValidator ( $ data = null ) : bool { if ( ! empty ( $ data ) ) { @ json_decode ( $ data ) ; return json_last_error ( ) === JSON_ERROR_NONE ; } return false ; } | Validate JSON . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.