idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
58,000 | public static function Text ( $ Mixed , $ AddBreaks = TRUE ) { if ( ! is_string ( $ Mixed ) ) return self :: To ( $ Mixed , 'Text' ) ; else { $ Charset = C ( 'Garden.Charset' , 'UTF-8' ) ; $ Result = htmlspecialchars ( strip_tags ( preg_replace ( '`<br\s?/?>`' , "\n" , html_entity_decode ( $ Mixed , ENT_QUOTES , $ Char... | Takes a mixed variable formats it for display on the screen as plain text . |
58,001 | public static function To ( $ Mixed , $ FormatMethod ) { if ( $ FormatMethod == '' ) return $ Mixed ; if ( is_string ( $ Mixed ) ) { if ( method_exists ( 'Gdn_Format' , $ FormatMethod ) ) { $ Mixed = self :: $ FormatMethod ( $ Mixed ) ; } elseif ( function_exists ( $ FormatMethod ) ) { $ Mixed = $ FormatMethod ( $ Mixe... | Takes a mixed variable formats it in the specified format type and returns it . |
58,002 | public static function ToDate ( $ Timestamp = '' ) { if ( $ Timestamp == '' ) $ Timestamp = time ( ) ; elseif ( ! is_numeric ( $ Timestamp ) ) $ Timestamp = self :: ToTimestamp ( $ Timestamp ) ; return date ( 'Y-m-d' , $ Timestamp ) ; } | Format a timestamp or the current time to go into the database . |
58,003 | public static function ToTimestamp ( $ DateTime = '' ) { if ( ( $ TestTime = strtotime ( $ DateTime ) ) !== FALSE ) { return $ TestTime ; } elseif ( preg_match ( '/^(\d{4})-(\d{1,2})-(\d{1,2})(?:\s{1}(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?)?$/' , $ DateTime , $ Matches ) ) { $ Year = $ Matches [ 1 ] ; $ Month = $ Matches [ ... | Convert a datetime to a timestamp |
58,004 | public static function ToTimezone ( $ Timestamp ) { static $ GuestHourOffset ; $ Now = time ( ) ; $ Session = Gdn :: Session ( ) ; $ HourOffset = 0 ; if ( $ Session -> UserID > 0 ) { $ HourOffset = $ Session -> User -> HourOffset ; } elseif ( class_exists ( 'DateTimeZone' ) ) { if ( ! isset ( $ GuestHourOffset ) ) { $ ... | Formats a timestamp to the current user s timezone . |
58,005 | public static function Url ( $ Mixed ) { if ( ! is_string ( $ Mixed ) ) return self :: To ( $ Mixed , 'Url' ) ; $ Mixed = strip_tags ( html_entity_decode ( $ Mixed , ENT_COMPAT , 'UTF-8' ) ) ; $ Mixed = strtr ( $ Mixed , self :: $ _UrlTranslations ) ; $ UnicodeSupport = ( preg_replace ( '`[\pP]`u' , '' , 'P' ) != '' ) ... | Creates URL codes containing only lowercase Roman letters digits and hyphens . |
58,006 | public static function Unserialize ( $ SerializedString ) { $ Result = $ SerializedString ; if ( is_string ( $ SerializedString ) ) { if ( substr_compare ( 'a:' , $ SerializedString , 0 , 2 ) === 0 || substr_compare ( 'O:' , $ SerializedString , 0 , 2 ) === 0 ) $ Result = unserialize ( $ SerializedString ) ; elseif ( s... | Takes a serialized variable and unserializes it back into it s original state . |
58,007 | private function createPalette ( \ Imagick $ imagick ) { switch ( $ imagick -> getImageColorspace ( ) ) { case \ Imagick :: COLORSPACE_RGB : case \ Imagick :: COLORSPACE_SRGB : return new RGB ( ) ; case \ Imagick :: COLORSPACE_CMYK : return new CMYK ( ) ; case \ Imagick :: COLORSPACE_GRAY : return new Grayscale ( ) ; d... | Returns the palette corresponding to an \ Imagick resource colorspace . |
58,008 | private function getVersion ( \ Imagick $ imagick ) { $ v = $ imagick -> getVersion ( ) ; list ( $ version ) = sscanf ( $ v [ 'versionString' ] , 'ImageMagick %s %04d-%02d-%02d %s %s' ) ; return $ version ; } | Returns ImageMagick version . |
58,009 | public function sortableConcreteData ( ) { $ list = [ ] ; foreach ( $ this as $ index => $ value ) { $ list [ $ index ] = $ value ; } return $ list ; } | this function return the filtered and sanitized internal array |
58,010 | private function sortableResetArray ( $ list ) { $ removedKeys = array_keys ( $ this -> baseConcreteData ) ; foreach ( $ list as $ index => $ value ) { $ this [ $ index ] = $ value ; if ( ( $ key = array_search ( $ index , $ removedKeys ) ) !== false ) { unset ( $ removedKeys [ $ key ] ) ; } } unset ( $ list ) ; foreac... | this function remap current data array with a new one |
58,011 | private function sortableCallByReference ( $ function , $ arguments ) { $ list = $ this -> sortableConcreteData ( ) ; $ params = array_merge ( [ & $ list ] , $ arguments ) ; $ result = call_user_func_array ( $ function , $ params ) ; if ( $ result ) { $ this -> sortableResetArray ( $ list ) ; } return $ result ; } | call a function by reference and send this array filtered data to it as argument one and then resort the data by new array that calculated in the function |
58,012 | private function sortableCallSpecial ( $ function , $ arguments ) { $ params = array_merge ( array_slice ( $ arguments , 0 , 1 ) , [ $ this -> sortableConcreteData ( ) ] , array_values ( array_slice ( $ arguments , 1 ) ) ) ; return call_user_func_array ( $ function , $ params ) ; } | call a function by reference and send this array filtered data to it as argument two |
58,013 | protected function renderPage ( $ page , $ widgetInstances ) { $ title = isset ( $ page [ 'title' ] ) ? $ page [ 'title' ] : '' ; $ widgets = array_map ( function ( $ w ) { return $ w -> render ( ) ; } , $ widgetInstances ) ; $ banner = $ this -> banner ; $ page_number = $ this -> pageNumber ; if ( ! isset ( $ page [ '... | Renders the page |
58,014 | protected function findProxyFile ( string $ class ) : ? string { $ class = substr ( $ class , 24 ) ; $ filePath = $ this -> directory . '/Proxy/' . str_replace ( '\\' , '/' , $ class ) . '.php' ; if ( file_exists ( $ filePath ) && is_file ( $ filePath ) ) { return $ filePath ; } return null ; } | Find proxy file |
58,015 | public function createPathAlias ( $ alias , $ path ) { $ this -> _alias = $ alias ; $ this -> _path = $ path ; Yii :: setPathOfAlias ( $ alias , $ path ) ; } | Creates a path alias for the extension . |
58,016 | public static function deleteBlankLines ( array $ activeConfig = [ ] ) { $ cleanedActiveConfig = [ ] ; foreach ( array_map ( 'trim' , $ activeConfig ) as $ line ) { if ( $ line != '' ) { $ cleanedActiveConfig [ ] = $ line ; } } return $ cleanedActiveConfig ; } | Trim all blank lines . |
58,017 | public static function continuingDirectives ( array $ activeConfig = [ ] ) { $ cleanedActiveConfig = [ ] ; foreach ( $ activeConfig as $ line ) { if ( ! self :: setLineIfPrevious ( $ line ) ) { $ cleanedActiveConfig [ ] = $ line ; } } return $ cleanedActiveConfig ; } | Reassembles discontinued simple directives in one line . |
58,018 | private static function setLineIfPrevious ( & $ line ) { static $ previousLine = '' ; if ( $ previousLine ) { $ line = $ previousLine . ' ' . trim ( $ line ) ; $ previousLine = '' ; } if ( preg_match ( '/(.+)\\\$/' , $ line , $ container ) ) { $ previousLine = $ container [ 1 ] ; } return $ previousLine ; } | Helps to gather continuing lines as one . |
58,019 | private static function normalize ( & $ val ) : void { if ( is_array ( $ val ) ) { array_walk ( $ val , [ __CLASS__ , 'normalize' ] ) ; } elseif ( is_scalar ( $ val ) ) { $ val = strlen ( $ val ) ? $ val : null ; } } | Internal helper to recursively normalize a value . |
58,020 | public function exists ( $ path ) { $ metadata = $ this -> dropbox -> getMetadata ( $ this -> pathRoot . $ path ) ; return is_array ( $ metadata ) && isset ( $ metadata [ 'path' ] ) ; } | If path exists |
58,021 | public function showAction ( BrandModel $ brandModel ) { $ deleteForm = $ this -> createDeleteForm ( $ brandModel ) ; return array ( 'entity' => $ brandModel , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Finds and displays a BrandModel entity . |
58,022 | private function createDeleteForm ( BrandModel $ brandModel ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'ecommerce_brandmodel_delete' , array ( 'id' => $ brandModel -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; } | Creates a form to delete a BrandModel entity . |
58,023 | public function modelJsonAction ( $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ brand = $ em -> getRepository ( 'EcommerceBundle:Brand' ) -> find ( $ id ) ; if ( ! $ brand instanceof Brand ) { throw $ this -> createNotFoundException ( 'Unable to find Brand entity.' ) ; } $ entities = $ em -> getReposi... | Returns a list of BrandModel entities in JSON format . |
58,024 | public static function cnpj ( $ cnpj ) { return substr ( $ cnpj , 0 , 2 ) . '.' . substr ( $ cnpj , 2 , 3 ) . '.' . substr ( $ cnpj , 5 , 3 ) . '/' . substr ( $ cnpj , 8 , 4 ) . '-' . substr ( $ cnpj , 12 , 2 ) ; } | Formats Brazilian CNPJ |
58,025 | public static function cpf ( $ cpf ) { return substr ( $ cpf , 0 , 3 ) . '.' . substr ( $ cpf , 3 , 3 ) . '.' . substr ( $ cpf , 6 , 3 ) . '-' . substr ( $ cpf , 9 , 2 ) ; } | Formats Brazilian CPF |
58,026 | public static function dateRange ( $ date0 , $ date1 , $ prefix = true ) { $ date0 = strtotime ( 'Today 00:00:00' , strtotime ( $ date0 ) ) ; $ date1 = strtotime ( 'Today 00:00:00' , strtotime ( $ date1 ) ) ; $ range = [ date ( 'd/m/Y' , min ( $ date0 , $ date1 ) ) ] ; if ( $ date0 != $ date1 ) { $ range [ ] = date ( '... | Formats two dates to represent a range |
58,027 | public static function money ( $ val , $ country = 'BR' ) { switch ( $ country ) { case 'US' : $ arr = [ 'US$' , ',' , '.' ] ; break ; case 'BR' : default : $ arr = [ 'R$' , '.' , ',' ] ; } return ( $ arr [ 0 ] . ' ' . number_format ( $ val , 2 , $ arr [ 2 ] , $ arr [ 1 ] ) ) ; } | Formats money value based in a country code |
58,028 | public static function naturalLanguageJoin ( array $ arr , string $ last = null , string $ glue = null ) { $ last_item = array_pop ( $ arr ) ; if ( $ arr ) { return implode ( $ glue ?? ', ' , $ arr ) . ' ' . ( $ last ?? 'and' ) . ' ' . $ last_item ; } return $ last_item ; } | Implodes an array with and and before last element |
58,029 | public static function multiReplace ( $ map , $ subject , $ repeat = false ) { do { $ count = $ c = 0 ; foreach ( $ map as $ search => $ replace ) { $ subject = str_replace ( $ search , $ replace , $ subject , $ c ) ; $ count += $ c ; } } while ( $ repeat && $ count > 0 ) ; return $ subject ; } | Replaces keys of an array by its values in a string |
58,030 | private function registerSettingsPackage ( ) { $ this -> registerProvider ( SettingsServiceProvider :: class ) ; $ this -> alias ( 'Settings' , \ Arcanedev \ LaravelSettings \ Facades \ Settings :: class ) ; } | Register the Settings Package . |
58,031 | private function registerHasherPackage ( ) { $ this -> registerProvider ( HasherServiceProvider :: class ) ; $ this -> alias ( 'Hasher' , \ Arcanedev \ Hasher \ Facades \ Hasher :: class ) ; } | Register the Hasher Package . |
58,032 | private function registerLaravelHtmlPackage ( ) { $ this -> registerProvider ( HtmlServiceProvider :: class ) ; $ this -> alias ( 'Html' , \ Arcanedev \ LaravelHtml \ Facades \ Html :: class ) ; $ this -> alias ( 'Form' , \ Arcanedev \ LaravelHtml \ Facades \ Form :: class ) ; } | Register the Laravel Html Package |
58,033 | private function registerSeoHelperPackage ( ) { $ this -> registerProvider ( SeoHelperServiceProvider :: class ) ; $ this -> alias ( 'SeoHelper' , \ Arcanedev \ SeoHelper \ Facades \ SeoHelper :: class ) ; } | Register SEO Helper Package . |
58,034 | private function registerBreadcrumbsPackage ( ) { $ this -> registerProvider ( BreadcrumbsServiceProvider :: class ) ; $ this -> alias ( 'Breadcrumbs' , \ Arcanedev \ Breadcrumbs \ Facades \ Breadcrumbs :: class ) ; } | Register the Breadcrumbs Package . |
58,035 | private function registerNotifyPackage ( ) { $ this -> registerProvider ( \ Arcanedev \ Notify \ NotifyServiceProvider :: class ) ; $ this -> alias ( 'Notify' , \ Arcanedev \ Notify \ Facades \ Notify :: class ) ; } | Register the Notify Package . |
58,036 | private function registerSidebarPackage ( ) { $ this -> registerProvider ( SidebarServiceProvider :: class ) ; $ this -> alias ( 'Sidebar' , \ Arcanesoft \ Sidebar \ Facades \ Sidebar :: class ) ; } | Register the Sidebar Package . |
58,037 | public function getTime ( ? int $ format = null ) : float { $ result = $ this -> endTime - $ this -> startTime ; return $ this -> formatTime ( $ result , $ format ) ; } | Returns the resulting time |
58,038 | final protected function filter ( array & $ data , array $ scheme = [ ] ) { if ( empty ( $ scheme ) ) { $ scheme = $ this -> scheme ; } if ( empty ( $ scheme [ 'filter' ] ) ) { return $ data ; } $ filter = [ ] ; foreach ( $ scheme [ 'filter' ] as $ f => $ r ) { $ filter [ $ f ] = $ r ; } if ( empty ( $ filter ) ) { ret... | Filters the fields value by using the set filter statements |
58,039 | protected function validate ( array & $ data , array $ fields = [ ] , bool $ filter_before_validate = true , array $ skip = [ ] ) { static $ validator ; if ( empty ( $ fields ) ) { if ( empty ( $ this -> scheme [ 'fields' ] ) ) { return $ data ; } $ fields = $ this -> scheme [ 'fields' ] ; } if ( empty ( $ fields ) ) {... | Validates data against the set validation rules |
58,040 | protected function paramsToString ( ) { $ out = "" ; foreach ( $ this -> attributes as $ name => $ value ) { $ out .= " {$name}=\"{$value}\"" ; } return $ this -> standalone ? $ out . " /" : $ out ; } | transforms all params to their string form |
58,041 | public static function set ( array & $ values , $ path , $ value ) { if ( is_array ( $ path ) ) { $ segments = $ path ; } else { $ path = ( string ) $ path ; $ path = ltrim ( $ path , sprintf ( '%s ' , static :: PATH_DELIMITER ) ) ; $ path = rtrim ( $ path , sprintf ( '%s %s' , static :: PATH_DELIMITER , static :: PATH... | Set an array value using dot notation . |
58,042 | public static function arrayWalkRecursiveDelete ( & $ values , Closure $ callback , $ data = null ) { foreach ( $ values as $ key => & $ value ) { if ( is_array ( $ value ) ) { $ value = static :: arrayWalkRecursiveDelete ( $ value , $ callback , $ data ) ; } if ( $ callback ( $ value , $ key , $ data ) ) { unset ( $ v... | Remove any elements where the callback returns true . |
58,043 | public static function mergeUnique ( array $ first , array $ second , $ preserveNumericKeys = false ) { foreach ( $ second as $ key => $ value ) { if ( $ value instanceof MergeReplaceKeyInterface ) { $ first [ $ key ] = $ value -> getData ( ) ; } elseif ( array_key_exists ( $ key , $ first ) ) { if ( $ value instanceof... | Merge two arrays together . If an integer key exists in both arrays and preserveNumericKeys is false the value from the second array will be appended to the first array if it does not exists . If both values are arrays they are merged together else the value of the second array overwrites the one of the first array . |
58,044 | public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ handler ) : ResponseInterface { try { return $ handler -> handle ( $ request ) ; } catch ( Throwable $ e ) { throw new HttpException ( $ e ) ; } } | Proxy the given handler and wrap any exception in a http exception . |
58,045 | final public function add ( $ capability , $ specUrl , $ specVersion ) { if ( array_key_exists ( $ capability , $ this -> rpc_capabilities ) ) { $ this -> logger -> warning ( "Cannot add capability $capability: duplicate entry" ) ; return false ; } else { $ this -> rpc_capabilities [ $ capability ] = array ( 'specUrl' ... | Add a capability |
58,046 | final public function delete ( $ capability ) { if ( array_key_exists ( $ capability , $ this -> rpc_capabilities ) ) { unset ( $ this -> rpc_capabilities [ $ capability ] ) ; $ this -> logger -> debug ( "Deleted capability $capability" ) ; return true ; } else { $ this -> logger -> warning ( "Cannot delete capability ... | Delete a capability |
58,047 | public function addGroupBy ( $ field ) { $ this -> groupByFields = array_merge ( $ this -> groupByFields , is_array ( $ field ) ? $ field : func_get_args ( ) ) ; return $ this ; } | Add a GROUP BY clause to the query |
58,048 | public function parameter ( $ value ) { if ( is_array ( $ value ) ) { if ( count ( $ value ) === 1 ) { $ value = current ( $ value ) ; } else { return $ this -> parameters ( $ value ) ; } } $ this -> parameters [ ] = $ value ; return '?' ; } | Insert a parameter placeholder into the query |
58,049 | public function getByPrimaryKey ( $ primaryKeys ) { if ( is_array ( $ primaryKeys ) && empty ( $ primaryKeys ) ) { return [ ] ; } $ records = $ this -> getByField ( $ this -> entity -> getPrimaryKey ( ) , $ primaryKeys ) ; if ( ! is_array ( $ primaryKeys ) ) { return current ( $ records ) ; } return $ records ; } | Get one or multiple records by primary key |
58,050 | public function getByField ( $ fieldName , $ keys ) { $ keys = ( array ) $ keys ; if ( empty ( $ keys ) ) { return [ ] ; } $ table = $ this -> entity -> getTable ( ) ; if ( ! empty ( $ this -> with ) ) { if ( strpos ( $ fieldName , '.' ) === false ) { $ fieldName = $ this -> getTableAlias ( $ table ) . '.' . $ fieldNam... | Get one or multiple records by a specific field |
58,051 | public function getSingleByField ( $ fieldName , $ key ) { $ record = $ this -> setMaxResults ( 1 ) -> getByField ( $ fieldName , $ key ) ; return reset ( $ record ) ; } | Fetch a single record from the database by field |
58,052 | public function delete ( $ parameters = [ ] ) { if ( ! is_array ( $ parameters ) ) { if ( func_num_args ( ) !== 1 ) { $ parameters = func_get_args ( ) ; } $ this -> deleteByPrimaryKey ( $ parameters ) ; return ; } $ relations = $ this -> entity -> getRelations ( ) ; if ( empty ( $ relations ) ) { $ this -> manager -> p... | Delete selected records |
58,053 | public function count ( array $ parameters = [ ] ) { $ this -> manager -> commit ( ) ; $ count = $ this -> applyFilters ( $ this -> queryBuilder -> select ( 'count(*) as count' ) -> from ( $ this -> entity -> getTable ( ) , $ this -> alias ) ) -> query ( array_merge ( $ this -> parameters , $ parameters ) ) -> fetch ( ... | Count selected records |
58,054 | private function validateAddress ( $ ip_address ) { return filter_var ( $ ip_address , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) || filter_var ( $ ip_address , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ) ; } | Validate IP address . |
58,055 | public function verifyAssertion ( $ assertion ) { $ postdata = 'assertion=' . urlencode ( $ assertion ) . '&audience=' . $ this -> guessAudience ( ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , "https://verifier.login.persona.org/verify" ) ; curl_setopt ( $ ch , CURLOPT_POST , true ) ; curl_setopt ( $ ch... | Verify the validity of the assertion received from the user |
58,056 | public function parseString ( $ string ) { $ lines = preg_split ( '(\r\n|\r|\n)' , $ string ) ; $ lineCount = count ( $ lines ) ; $ diffs = array ( ) ; $ diff = null ; $ collected = array ( ) ; for ( $ i = 0 ; $ i < $ lineCount ; ++ $ i ) { if ( preg_match ( '(^---\\s+(?P<file>\\S+))' , $ lines [ $ i ] , $ fromMatch ) ... | Parse diff string |
58,057 | protected function parseFileDiff ( \ Arbit \ VCSWrapper \ Diff \ Collection $ diff , array $ lines ) { $ chunks = array ( ) ; while ( count ( $ lines ) ) { while ( ! preg_match ( '(^@@\\s+-(?P<start>\\d+)(?:,\\s*(?P<startrange>\\d+))?\\s+\\+(?P<end>\\d+)(?:,\\s*(?P<endrange>\\d+))?\\s+@@)' , $ last = array_shift ( $ li... | Parse the diff of one file |
58,058 | public function build ( ) { $ pageNumber = - 1 ; $ count = 0 ; while ( $ count < count ( $ this -> posts ) ) { $ i = 0 ; $ pageNumber ++ ; if ( $ pageNumber == 0 ) $ pagination = new Pagination ( $ pageNumber , '/index.html' ) ; else $ pagination = new Pagination ( $ pageNumber , '/index' . $ pageNumber . '.html' ) ; w... | Create an array of pagination |
58,059 | public function updateNavCLasses ( $ sorted_menu_items , $ args ) { $ object_post_type = get_post_type ( ) ; if ( ! get_post_type ( ) ) { return $ sorted_menu_items ; } $ page_ids = $ this -> get_page_ids ( ) ; if ( ! isset ( $ page_ids [ $ object_post_type ] ) ) { return $ sorted_menu_items ; } foreach ( $ sorted_menu... | Set nav classes |
58,060 | protected function get_page_ids ( ) { $ page_ids = array ( ) ; foreach ( get_post_types ( array ( ) , 'objects' ) as $ post_type ) { if ( ! $ post_type -> has_archive ) { continue ; } if ( ! get_option ( "page_for_{$post_type->name}" ) ) { continue ; } $ page_ids [ $ post_type -> name ] = get_option ( "page_for_{$post_... | Return array with page for post type Ids |
58,061 | public function putComposerJsonAction ( Request $ request ) { $ content = $ request -> getContent ( ) ; try { $ errors = $ this -> checkComposerJson ( $ content ) ; } catch ( \ Exception $ e ) { $ errors = [ 'errors' => [ [ 'line' => 0 , 'msg' => 'Invalid payload' ] ] , 'warnings' => [ ] , ] ; } if ( ! empty ( $ errors... | Update the composer . json with the given data if it is valid . |
58,062 | private function checkComposerJson ( $ content ) { $ tempFile = $ this -> getTensideDataDir ( ) . '/composer.json.tmp' ; file_put_contents ( $ tempFile , $ content ) ; $ validator = new ConfigValidator ( new BufferIO ( ) ) ; list ( $ errors , $ publishErrors , $ warnings ) = $ validator -> validate ( $ tempFile ) ; unl... | Check the json contents and return the error array . |
58,063 | public function generateEntityClass ( EntityMetadata $ meta ) { $ placeholders = array ( '<namespace>' , '<classAnnotations>' , '<className>' , '<implements>' , '<traits>' ) ; $ replacements = array ( $ this -> namespace , $ this -> generateClassAnnotations ( $ meta -> getTraits ( ) ) , $ meta -> getClassName ( ) , $ t... | Generates a Doctrine 2 entity class from the given EntityMetadata instance |
58,064 | public function getColumnFlex ( $ size = 'phone' ) { $ flex = [ ] ; foreach ( $ this -> _cells as $ column ) { $ flex [ $ column -> id ] = $ column -> getFlex ( $ size ) ; } arsort ( $ flex , SORT_NUMERIC ) ; return $ flex ; } | Get column flex . |
58,065 | public function getDistributionColumns ( $ size = null ) { $ auto = [ ] ; foreach ( $ this -> _cells as $ cell ) { if ( $ cell -> getColumns ( $ size ) === 'auto' ) { $ auto [ $ cell -> id ] = $ cell ; } } return $ auto ; } | Get distribution columns . |
58,066 | public function getColumnCount ( ) { $ columnCount = 0 ; foreach ( $ this -> _cells as $ item ) { if ( $ item -> columns === 'auto' ) { continue ; } $ columnCount += $ item -> columns ; } return $ columnCount ; } | Get column count . |
58,067 | public function checkSecret ( $ secret ) { if ( in_array ( OAuth2 :: GRANT_TYPE_CLIENT_CREDENTIALS , $ this -> getAllowedGrantTypes ( ) ) ) { return array ( 'scope' => 'API_USER' ) ; } return ( null === $ this -> secret || $ secret === $ this -> secret ) ; } | Check secret if client credential grant flow set scope |
58,068 | public function action ( $ method = 'GET' ) { return isset ( $ this -> actions [ $ method ] ) ? $ this -> actions [ $ method ] : null ; } | Retrieves the registered internal state for a certain action . Not really used at the moment but might come in handy sometimes . |
58,069 | public function any ( $ state ) : State { foreach ( [ 'GET' , 'POST' , 'PUT' , 'DELETE' , 'HEAD' , 'OPTIONS' ] as $ verb ) { $ this -> addCallback ( $ verb , $ state ) ; } return $ this ; } | Add a response for _any_ supported HTTP verb . |
58,070 | public function get ( $ state ) : State { $ this -> addCallback ( 'GET' , $ state ) ; if ( ! isset ( $ this -> actions [ 'POST' ] ) ) { $ this -> addCallback ( 'POST' , $ state ) ; } return $ this ; } | Add a response for the GET verb . If no POST handler was defined this response also doubles for a POST . |
58,071 | private function addCallback ( string $ method , $ state ) : void { $ state = $ this -> makeCallable ( $ state ) ; $ this -> actions [ $ method ] = $ state ; } | Add a state callback for an method . If the state is something non - callable it is auto - wrapped in a Closure . |
58,072 | private function makeCallable ( $ state ) : callable { if ( is_callable ( $ state ) ) { return $ state ; } return function ( ) use ( $ state ) { if ( is_string ( $ state ) && class_exists ( $ state ) ) { $ state = new $ state ; } return $ state ; } ; } | Helper method to wrap a state in a callback if it is not callable yet . |
58,073 | private function parseArguments ( callable $ call , array $ matches ) : array { if ( is_object ( $ call ) && method_exists ( $ call , '__invoke' ) ) { $ reflection = new ReflectionMethod ( $ call , '__invoke' ) ; } elseif ( is_array ( $ call ) && method_exists ( $ call [ 0 ] , $ call [ 1 ] ) ) { $ reflection = new Refl... | Internal helper to parse arguments for a callable inject the correct values if found and remove unused parameters . |
58,074 | public function setAncestorId ( $ id , $ relatedId ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Lineage not found.' ] ) ; } if ( $ this -> doSetAncestorId ( $ model , $ relatedId ) ) { $ this -> dispatch ( LineageEvent :: PRE_ANCESTOR_UPDATE , $ model ) ; $ this... | Sets the Ancestor id |
58,075 | protected function doSetAncestorId ( Lineage $ model , $ relatedId ) { if ( $ model -> getAncestorId ( ) !== $ relatedId ) { $ model -> setAncestorId ( $ relatedId ) ; return true ; } return false ; } | Internal mechanism to set the Ancestor id |
58,076 | public function set_temporal_properties ( $ stamp , $ timestamp_end_col , $ timestamp_start_col ) { $ this -> timestamp = $ stamp ; $ this -> timestamp_end_col = $ timestamp_end_col ; $ this -> timestamp_start_col = $ timestamp_start_col ; return $ this ; } | Sets the timestamp to be used on joins . If set to null the latest revision is used . |
58,077 | protected function modify_join_result ( $ join_result , $ name ) { if ( ! is_null ( $ this -> timestamp ) and is_subclass_of ( $ join_result [ $ name ] [ 'model' ] , '\Orm\Model_Temporal' ) ) { $ table = $ join_result [ $ name ] [ 'table' ] [ 1 ] ; $ query_time = \ DB :: escape ( $ this -> timestamp ) ; $ join_result [... | Adds extra where conditions when temporal filtering is needed . |
58,078 | private function checkException ( $ response ) { if ( ( true === $ this -> getThrowExceptions ( ) ) and ( $ this -> isErroneousResponse ( $ response ) ) ) { throw new ClientException ( $ response -> detail , $ response -> status ) ; } return $ response ; } | Check if exception should be thrown |
58,079 | private function isErroneousResponse ( $ response ) { return ( isset ( $ response -> type ) and isset ( $ response -> title ) and isset ( $ response -> status ) and isset ( $ response -> detail ) ) ; } | is erroneous reponse |
58,080 | public function resolve ( $ name , $ args = array ( ) ) { if ( $ this -> container -> has ( $ name ) ) { return $ this -> container -> get ( $ name ) ; } if ( ! class_exists ( $ name ) ) { throw new \ InvalidArgumentException ( "$name is not a defined class or container service name." ) ; } $ reflection = new \ Reflect... | Takes a class name and extra named args and returns an instance of the class injected its dependencies resolved from the container as well as the extra arguments passed in . |
58,081 | public static function convertToPascalCase ( $ word ) { $ word = str_replace ( '_' , ' ' , $ word ) ; $ word = strtolower ( $ word ) ; $ word = ucwords ( $ word ) ; return str_replace ( ' ' , '' , $ word ) ; } | Convert any string to PascalCase |
58,082 | protected function sortHandlers ( string $ eventType ) : void { $ this -> sorted [ $ eventType ] = [ ] ; if ( isset ( $ this -> handlers [ $ eventType ] ) ) { krsort ( $ this -> handlers [ $ eventType ] ) ; $ this -> sorted [ $ eventType ] = call_user_func_array ( 'array_merge' , $ this -> handlers [ $ eventType ] ) ; ... | Sorts event handlers by priority |
58,083 | private function getRouteAsMiddleware ( ResultInterface $ result ) : MiddlewareInterface { $ callback = $ result -> getRoute ( ) -> getCallback ( ) ; if ( is_string ( $ callback ) ) { $ callback = ( $ this -> container ? $ this -> container -> get ( $ callback ) : null ) ; } if ( is_array ( $ callback ) && count ( $ ca... | Get the route as a middleware |
58,084 | protected function setAsInteger ( $ field , $ value ) { if ( in_array ( $ field , $ this -> getColumns ( ) ) && ( ! array_key_exists ( $ field , $ this -> object ) || $ this -> object [ $ field ] !== $ value ) ) { $ this -> dirtyFields [ $ field ] = true ; } $ this -> object [ $ field ] = ( int ) $ value ; return $ thi... | Set the given field with the given value typecasted as an integer |
58,085 | protected function setAsFloat ( $ field , $ value ) { if ( in_array ( $ field , $ this -> getColumns ( ) ) && ( ! array_key_exists ( $ field , $ this -> object ) || $ this -> object [ $ field ] !== $ value ) ) { $ this -> dirtyFields [ $ field ] = true ; } $ this -> object [ $ field ] = ( float ) $ value ; return $ thi... | Set the given field with the given value typecasted as a float |
58,086 | protected function setAsBoolean ( $ field , $ value ) { if ( in_array ( $ field , $ this -> getColumns ( ) ) && ( ! array_key_exists ( $ field , $ this -> object ) || $ this -> object [ $ field ] !== $ value ) ) { $ this -> dirtyFields [ $ field ] = true ; } $ this -> object [ $ field ] = ( bool ) $ value ; return $ th... | Set the given field with the given value typecasted as a boolean |
58,087 | protected function setAsString ( $ field , $ value ) { if ( in_array ( $ field , $ this -> getColumns ( ) ) && ( ! array_key_exists ( $ field , $ this -> object ) || $ this -> object [ $ field ] !== $ value ) ) { $ this -> dirtyFields [ $ field ] = true ; } $ this -> object [ $ field ] = ( string ) $ value ; return $ t... | Set the given field with the given value typecasted as a string |
58,088 | protected function render ( ResponseInterface $ response ) { $ stream = new Stream ( 'php://memory' , 'rw+' ) ; $ content = $ this -> getEngine ( ) -> parse ( $ this -> getTemplate ( ) ) -> process ( $ this -> getData ( ) ) ; $ stream -> write ( $ content ) ; $ response = $ response -> withBody ( $ stream ) ; return $ ... | Processes and renders the response |
58,089 | protected function getEngine ( ) { Template :: addPath ( dirname ( __DIR__ ) . '/templates' ) ; $ template = new Template ( ) ; $ template -> addExtension ( HtmlExtension :: class ) ; return $ template -> initialize ( ) ; } | Creates the engine for this rendering |
58,090 | public function addDmsRow ( $ column , $ value , $ foreignID ) { $ tableGateway = $ this -> tableGateway ; $ trData = array ( 'model' => get_class ( $ tableGateway ) , 'foreign_key' => $ foreignID , 'field' => $ column , 'content' => $ value ) ; $ dmsTable = $ this -> getDmsTable ( ) ; $ dmsTable -> insert ( $ trData )... | Add Dms data for a row with specific primary key |
58,091 | public function createNew ( string $ name , string $ event , bool $ running , bool $ success , string $ message ) : array { return $ this -> sendPost ( sprintf ( '/profiles/%s/processes/%s/tasks' , $ this -> userName , $ this -> processId ) , [ ] , [ 'name' => $ name , 'event' => $ event , 'running' => $ running , 'suc... | Creates a new task for the given user . |
58,092 | public function listAll ( array $ filters = [ ] ) : array { return $ this -> sendGet ( sprintf ( '/profiles/%s/processes/%s/tasks' , $ this -> userName , $ this -> processId ) , $ filters ) ; } | Lists all tasks . |
58,093 | public function getOne ( int $ taskId ) : array { return $ this -> sendGet ( sprintf ( '/profiles/%s/processes/%s/tasks/%s' , $ this -> userName , $ this -> processId , $ taskId ) ) ; } | Retrieves a task given its slug . |
58,094 | public function updateOne ( int $ taskId , string $ name , string $ event , bool $ running , bool $ success , string $ message ) : array { return $ this -> sendPatch ( sprintf ( '/profiles/%s/processes/%s/tasks/%s' , $ this -> userName , $ this -> processId , $ taskId ) , [ ] , [ 'name' => $ name , 'event' => $ event ,... | Updates a task given its slug . |
58,095 | public function getTimestampDifference ( $ time = null ) { $ time = ( is_null ( $ time ) ) ? $ this -> getCurrentTimestamp ( ) : $ time ; return ( $ time - $ this -> initialTimestamp ) ; } | Returns difference between provided timestamp and initial timestamp . If null is provided the current timestamp is used . |
58,096 | public function setInitialTimestamp ( $ time = null ) { $ time = ( is_null ( $ time ) ) ? $ this -> getCurrentTimestamp ( ) : $ time ; $ this -> initialTimestamp = $ time ; return $ this ; } | Adds manipulation for initial timestamp . If null is provided the current timestamp is used . |
58,097 | public function fromReflectionClass ( ClassInterface $ reflectionClass ) { $ reflectionClass -> addAnnotationAlias ( Controller :: ANNOTATION , Controller :: __getClass ( ) ) ; $ reflectionClass -> addAnnotationAlias ( RequestMapping :: ANNOTATION , RequestMapping :: __getClass ( ) ) ; parent :: fromReflectionClass ( $... | Initializes the controller descriptor instance from the passed reflection class instance . |
58,098 | private function setHeader ( ) { ob_get_clean ( ) ; header ( "Content-Type: video/mp4" ) ; header ( "Cache-Control: max-age=2592000, public" ) ; header ( "Expires: " . gmdate ( 'D, d M Y H:i:s' , time ( ) + 2592000 ) . ' GMT' ) ; header ( "Last-Modified: " . gmdate ( 'D, d M Y H:i:s' , @ filemtime ( $ this -> path ) ) ... | Set proper header to serve the video content |
58,099 | private function stream ( ) { $ i = $ this -> start ; set_time_limit ( 0 ) ; while ( ! feof ( $ this -> stream ) && $ i <= $ this -> end ) { $ bytesToRead = $ this -> buffer ; if ( ( $ i + $ bytesToRead ) > $ this -> end ) $ bytesToRead = $ this -> end - $ i + 1 ; $ data = fread ( $ this -> stream , $ bytesToRead ) ; e... | perform the streaming of calculated range |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.