idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
4,200 | public function init ( ) { parent :: init ( ) ; if ( $ data = $ this -> getShortcodeData ( ) ) { $ this -> isnew = false ; $ this -> shortcodableclass = $ data [ 'name' ] ; } elseif ( $ type = $ this -> request -> requestVar ( 'ShortcodeType' ) ) { $ this -> shortcodableclass = $ type ; } else { $ this -> shortcodablec... | Get the shortcodable class by whatever means possible . Determine if this is a new shortcode or editing an existing one . |
4,201 | public function Link ( $ action = null ) { if ( $ this -> shortcodableclass ) { return Controller :: join_links ( $ this -> config ( ) -> url_base , $ this -> config ( ) -> sc_url_segment , 'edit' , $ this -> shortcodableclass ) ; } return Controller :: join_links ( $ this -> config ( ) -> url_base , $ this -> config (... | Point to edit link if shortcodable class exists . |
4,202 | protected function getShortcodeData ( ) { if ( $ this -> shortcodedata ) { return $ this -> shortcodedata ; } $ data = false ; if ( $ shortcode = $ this -> request -> requestVar ( 'Shortcode' ) ) { $ shortcode = str_replace ( "\xEF\xBB\xBF" , '' , $ shortcode ) ; $ data = singleton ( '\Silverstripe\Shortcodable\Shortco... | Get the shortcode data from the request . |
4,203 | public function shortcodePlaceHolder ( $ request ) { if ( ! Permission :: check ( 'CMS_ACCESS_CMSMain' ) ) { return ; } $ classname = $ request -> param ( 'ID' ) ; $ id = $ request -> param ( 'OtherID' ) ; if ( ! class_exists ( $ classname ) ) { return ; } if ( $ id ) { $ object = $ classname :: get ( ) -> byID ( $ id ... | Generates shortcode placeholder to display inside TinyMCE instead of the shortcode . |
4,204 | public static function parseOperationName ( Operation $ operation ) { $ verb = self :: deriveAction ( $ operation -> httpMethod , $ operation -> uri ) ; $ wordifiedPath = self :: wordifyPath ( $ operation -> uri ) ; if ( $ operation -> version == 'stream' ) { $ wordifiedPath = $ wordifiedPath . 'Stream' ; } if ( preg_m... | Parse Operation name . |
4,205 | public static function wordifyPath ( $ path ) { $ path = preg_replace ( '/{[a-z_]*}/' , '' , $ path ) ; $ path = preg_replace ( '/[0-9]*/' , '' , $ path ) ; $ path = str_replace ( '_' , '/' , $ path ) ; $ parts = array_filter ( explode ( '/' , $ path ) ) ; $ parts = array_map ( 'ucfirst' , $ parts ) ; return implode ( ... | Converts the url parts into words . |
4,206 | public static function deriveAction ( $ method , $ path ) { $ method = strtolower ( $ method ) ; if ( $ method == 'get' ) { return $ method ; } if ( $ method == 'delete' ) { return $ method ; } if ( $ method == 'post' && $ path == '/{urlname}' ) { return 'edit' ; } if ( $ method == 'post' && ( strpos ( $ path , '{id}' ... | Derives a Verb for the endpoint . |
4,207 | function getPrimaryKeys ( $ tableName ) { $ primary_key_index = $ this -> schema -> listTableDetails ( $ tableName ) -> getPrimaryKey ( ) ; return $ primary_key_index ? $ primary_key_index -> getColumns ( ) : [ ] ; } | Returns array of fields matched as primary keys in table |
4,208 | public function imageToHtml ( ) { if ( empty ( $ this -> data [ 'file.url' ] ) ) { return '' ; } $ text = $ this -> data [ 'text' ] ?? '' ; if ( ! empty ( $ text ) ) { $ text = $ this -> parser -> toHtml ( $ text ) ; } $ url = $ this -> data [ 'file.url' ] ?? '' ; try { $ size = getimagesize ( $ url ) ; } catch ( Excep... | Converts the image to html . |
4,209 | public function gettyimagesToHtml ( ) { return $ this -> view ( 'image.gettyimages' , [ 'remote_id' => $ this -> data [ 'remote_id' ] , 'width' => $ this -> config [ 'gettyimages.width' ] ?? 594 , 'height' => $ this -> config [ 'gettyimages.height' ] ?? 465 , 'placeholder' => $ this -> config [ 'gettyimages.placeholder... | Converts GettyImage to html . |
4,210 | public static function buildConfig ( $ config = array ( ) ) { $ default = static :: getDefaultParameters ( ) ; $ required = static :: getRequiredParameters ( ) ; $ config = Collection :: fromConfig ( $ config , $ default , $ required ) ; $ standardHeaders = array ( 'Accept-Charset' => 'utf-8' , 'Accept' => 'application... | Builds array of configurations into final config . |
4,211 | public static function loadDefinitions ( Client $ client ) { $ serviceDescriptions = ServiceDescription :: factory ( __DIR__ . '/Resources/config/meetup.json' ) ; foreach ( $ serviceDescriptions -> getOperations ( ) as $ operation ) { $ operation -> setClass ( 'DMS\Service\Meetup\Command\MeetupCommand' ) ; } $ client -... | Loads API method definitions . |
4,212 | private static function init ( ) { if ( ! self :: $ _env ) { self :: $ _env = new DbEnvironment ( ) ; } if ( ! self :: $ _ops ) { self :: $ _ops = new DbOps ( self :: $ _env ) ; } } | Db initiator . |
4,213 | private static function deprecationWarning ( ) { $ caller = next ( debug_backtrace ( ) ) ; $ msg = 'Deprecated Db-function in function ' . $ caller [ 'function' ] . ' called from ' . $ caller [ 'file' ] ; $ msg .= ' on line ' . $ caller [ 'line' ] ; trigger_error ( $ msg , E_USER_NOTICE ) ; } | Creates a NOTICE |
4,214 | protected function registerDatabaseCommand ( ) { $ app = $ this -> app ; $ app [ 'command.queue.database' ] = $ app -> share ( function ( $ app ) { return new DatabaseCommand ( ) ; } ) ; $ this -> commands ( 'command.queue.database' ) ; } | Register the queue listener console command . |
4,215 | public function registerDebugHandlers ( $ shutdownLog = false , $ exception = true , $ error = true ) { $ debug = $ this -> builder -> components ( ) -> debug ( ) ; $ debug -> registerHandlers ( $ shutdownLog , $ exception , $ error ) ; } | Register error and exception handlers |
4,216 | private function normalize ( string $ path ) : string { if ( $ path === '' ) { return '/' ; } if ( strlen ( $ path ) > 1 ) { if ( $ this -> trailingSlash ) { if ( substr ( $ path , - 1 ) !== '/' && ! pathinfo ( $ path , PATHINFO_EXTENSION ) ) { return $ path . '/' ; } } else { return rtrim ( $ path , '/' ) ; } } return... | Normalize the trailing slash . |
4,217 | public function process ( $ value ) { if ( $ value instanceof \ PHPixie \ HTTP \ Responses \ Response ) { return $ value ; } if ( $ value instanceof \ Psr \ Http \ Message \ ResponseInterface ) { return $ value ; } if ( $ value instanceof \ PHPixie \ Template \ Container ) { $ value = $ value -> render ( ) ; } if ( is_... | Convert data to a HTTP response |
4,218 | public static function decode ( $ json , $ assoc = FALSE ) { $ json = utf8_encode ( $ json ) ; $ json = str_replace ( array ( "\n" , "\r" ) , "" , $ json ) ; $ json = preg_replace ( '/([{,])(\s*)([^"]+?)\s*:/' , '$1"$3":' , $ json ) ; return json_decode ( $ json , $ assoc ) ; } | Decode a JSON string that is not strictly formed . |
4,219 | public function templateExtensions ( ) { return array ( new Extensions \ Template \ Extension \ Debug ( $ this -> components ( ) -> debug ( ) ) , new Extensions \ Template \ Extension \ RouteTranslator ( 'http' , $ this -> builder -> http ( ) -> routeTranslator ( ) ) ) ; } | Extensions for the Template component |
4,220 | public function authProviderBuilders ( ) { return array ( $ this -> buildAuthLogin ( ) -> providers ( ) , $ this -> buildAuthHttp ( ) -> providers ( ) , $ this -> buildAuthSocial ( ) -> providers ( ) ) ; } | Provider builders for the Auth component |
4,221 | protected function operandi ( $ string , $ set = false , $ prepared = false ) { if ( empty ( $ string ) && $ string !== "0" ) { return ( $ set ? ' = NULL' : ' IS NULL' ) ; } $ firstLetter = strtolower ( substr ( $ string , 0 , 1 ) ) ; switch ( $ firstLetter ) { case '>' : case '<' : $ return = ' ' . $ firstLetter . ' "... | EASY markup interpretation to influence conditions - behavior |
4,222 | protected function selectandi ( $ string ) { $ firstLetter = strtolower ( substr ( $ string , 0 , 1 ) ) ; $ rest = substr ( $ string , 1 ) ; switch ( $ firstLetter ) { case '#' : $ return = 'UNIX_TIMESTAMP(' . $ this -> _sanitizeAndAddBackticks ( $ this -> cleanAs ( $ rest ) ) . ')*1000' ; break ; case '$' : $ return =... | EASY markup interpretation to influence select - behavior |
4,223 | protected function addBackticks ( $ string ) { $ parts = explode ( '.' , $ string ) ; $ result = '' ; foreach ( $ parts as $ i => $ part ) { $ result .= ( $ i > 0 ? '.' : '' ) ; if ( $ part !== '*' ) { $ result .= '`' . $ part . '`' ; } else { $ result .= $ part ; } } return $ result ; } | Adds backticks to keys tables & columns |
4,224 | public function httpExceptionResponse ( $ configData ) { $ components = $ this -> builder -> components ( ) ; return new Processors \ HTTP \ Response \ Exception ( $ components -> debug ( ) , $ components -> http ( ) , $ components -> template ( ) , $ configData ) ; } | Processor that renders the exception response |
4,225 | public function httpNotFoundResponse ( $ configData ) { $ components = $ this -> builder -> components ( ) ; return new Processors \ HTTP \ Response \ NotFound ( $ components -> http ( ) , $ components -> template ( ) , $ configData ) ; } | Processor for the not found page |
4,226 | public function httpNormalizeResponse ( ) { $ components = $ this -> builder -> components ( ) ; return new Processors \ HTTP \ Response \ Normalize ( $ components -> http ( ) ) ; } | Processor that turns return values into HTTP Responses . |
4,227 | public static function iterate ( Mongo_Document $ document , $ name , $ model = false ) { if ( is_bool ( $ model ) ) $ model = get_called_class ( ) ; else if ( is_object ( $ model ) ) $ model = get_class ( $ model ) ; $ value = $ document -> get ( $ name ) ; if ( ! is_array ( $ value ) && ! ( $ value instanceof Iterato... | Returns a subdocument for every value in the array . |
4,228 | public function userShow ( $ user_id ) { $ response = $ this -> getGuzzleClient ( ) -> get ( '/users/' . $ user_id , $ this -> setQuery ( ) ) ; return $ this -> serializer -> deserialize ( $ response -> getBody ( ) -> getContents ( ) , User :: class , 'json' ) ; } | User show resource |
4,229 | public function userPackages ( $ user_id , $ filters = [ ] ) { $ response = $ this -> getGuzzleClient ( ) -> get ( '/users/' . $ user_id . '/classifieds_promotion_packs' , $ this -> setQuery ( $ filters ) ) ; return $ this -> serializer -> deserialize ( $ response -> getBody ( ) -> getContents ( ) , "array<" . Package ... | Hired packages by user |
4,230 | public function categoryList ( $ site_id ) { $ response = $ this -> getGuzzleClient ( ) -> get ( '/sites/' . $ site_id . '/categories' , $ this -> setQuery ( ) ) ; return $ this -> serializer -> deserialize ( $ response -> getBody ( ) -> getContents ( ) , "array<" . Category :: class . ">" , 'json' ) ; } | Category list resource |
4,231 | public function categoryPredict ( $ site_id , $ title ) { $ response = $ this -> getGuzzleClient ( ) -> get ( '/sites/' . $ site_id . '/category_predictor/predict' , $ this -> setQuery ( [ 'title' => $ title ] ) ) ; return $ this -> serializer -> deserialize ( $ response -> getBody ( ) -> getContents ( ) , CategoryPred... | Category Predict resource |
4,232 | public function itemList ( $ user_id ) { $ response = $ this -> getGuzzleClient ( ) -> get ( '/users/' . $ user_id . '/items/search' , $ this -> setQuery ( ) ) ; return $ this -> serializer -> deserialize ( $ response -> getBody ( ) -> getContents ( ) , ItemList :: class , 'json' ) ; } | Item List resource |
4,233 | public function itemShow ( $ item_id ) { $ response = $ this -> getGuzzleClient ( ) -> get ( '/items/' . $ item_id , $ this -> setQuery ( ) ) ; return $ this -> serializer -> deserialize ( $ response -> getBody ( ) -> getContents ( ) , Item :: class , 'json' ) ; } | Item Show resource |
4,234 | public function itemUpdateListingType ( $ item_id , $ listing_type ) { $ response = $ this -> getGuzzleClient ( ) -> post ( '/items/' . $ item_id . '/listing_type' , array_merge ( $ this -> setQuery ( ) , $ this -> setBodyArray ( [ 'id' => $ listing_type ] ) ) ) ; return $ this -> serializer -> deserialize ( $ response... | Item update listing type |
4,235 | public function storeJob ( $ job , $ data , $ queue , $ timestamp = 0 ) { $ payload = $ this -> createPayload ( $ job , $ data ) ; $ job = new Job ( ) ; $ job -> setConnection ( $ this -> database -> getName ( ) ) ; $ job -> queue = ( $ queue ? $ queue : $ this -> default ) ; $ job -> status = Job :: STATUS_OPEN ; $ jo... | Store the job in the database |
4,236 | public function processSapiRequest ( ) { $ http = $ this -> builder -> components ( ) -> http ( ) ; $ serverRequest = $ http -> sapiServerRequest ( ) ; $ response = $ this -> processor ( ) -> process ( $ serverRequest ) ; $ http -> output ( $ response , $ this -> builder -> context ( ) -> httpContext ( ) ) ; } | Process a PHP request from globals and output the response |
4,237 | public function processServerRequest ( $ serverRequest ) { $ response = $ this -> processor ( ) -> process ( $ serverRequest ) ; return $ response -> asResponseMessage ( $ this -> builder -> context ( ) -> httpContext ( ) ) ; } | Process a PSR7 ServerRequest into a PSR7 Response |
4,238 | protected function buildProcessor ( ) { $ processors = $ this -> builder -> components ( ) -> processors ( ) ; return $ processors -> catchException ( $ processors -> chain ( array ( $ this -> requestProcessor ( ) , $ this -> contextProcessor ( ) , $ processors -> checkIsProcessable ( $ this -> builder -> configuration... | Builds the HTTP request processor |
4,239 | protected function requestProcessor ( ) { $ components = $ this -> builder -> components ( ) ; $ processors = $ components -> processors ( ) ; $ httpProcessors = $ components -> httpProcessors ( ) ; return $ processors -> chain ( array ( $ httpProcessors -> parseBody ( ) , $ this -> parseRouteProcessor ( ) , $ httpProc... | Builds the processor that takes care of generating the PHPixie HTTP Request |
4,240 | protected function parseRouteProcessor ( ) { $ frameworkProcessors = $ this -> builder -> processors ( ) ; $ translator = $ this -> routeTranslator ( ) ; return $ frameworkProcessors -> httpParseRoute ( $ translator ) ; } | Builds the processor that takes care of parsing the Request and populating route data |
4,241 | protected function dispatchProcessor ( ) { $ processors = $ this -> builder -> components ( ) -> processors ( ) ; $ frameworkProcessors = $ this -> builder -> processors ( ) ; return $ processors -> chain ( array ( $ this -> builder -> configuration ( ) -> httpProcessor ( ) , $ frameworkProcessors -> httpNormalizeRespo... | Builds the processor that takes care of dispatching the request . |
4,242 | protected function exceptionProcessor ( ) { $ frameworkProcessors = $ this -> builder -> processors ( ) ; $ httpConfig = $ this -> builder -> configuration ( ) -> httpConfig ( ) ; return $ frameworkProcessors -> httpExceptionResponse ( $ httpConfig -> slice ( 'exceptionResponse' ) ) ; } | Builds the processor that handles uncaught exception |
4,243 | protected function notFoundProcessor ( ) { $ frameworkProcessors = $ this -> builder -> processors ( ) ; $ httpConfig = $ this -> builder -> configuration ( ) -> httpConfig ( ) ; return $ frameworkProcessors -> httpNotFoundResponse ( $ httpConfig -> slice ( 'notFoundResponse' ) ) ; } | Builds the processor that handles non - existing urls |
4,244 | public function generateUri ( $ resolverPath = null , $ attributes = array ( ) , $ withHost = false ) { return $ this -> routeTranslator ( ) -> generateUri ( $ resolverPath , $ attributes , $ withHost ) ; } | Generate a PSR - 7 URI from route path and attributes |
4,245 | public function redirectResponse ( $ resolverPath = null , $ attributes = array ( ) ) { $ path = $ this -> generatePath ( $ resolverPath , $ attributes ) ; $ http = $ this -> builder -> components ( ) -> http ( ) ; return $ http -> responses ( ) -> redirect ( $ path ) ; } | Generate a redirect response from route path and attributes |
4,246 | public function newUuid ( ) { $ q = Db :: query ( 'SELECT REPLACE(UUID(),"-","") as id' ) ; while ( $ row = $ q [ 'result' ] -> fetch_assoc ( ) ) { $ this -> uuid = strtoupper ( $ row [ 'id' ] ) ; } return $ this ; } | Generates new UUID |
4,247 | public function convertBinaryResults ( $ resultArray ) { foreach ( $ resultArray as $ i => $ item ) { if ( is_numeric ( $ i ) ) { $ resultArray [ $ i ] = $ this -> convertBinaryResults ( $ item ) ; } elseif ( is_string ( $ item ) ) { if ( DbOps :: isBinary ( $ item ) ) { $ resultArray [ $ i ] = strtoupper ( bin2hex ( $... | handles binary to hex conversion |
4,248 | public function convertToCompliantUuid ( $ uuid = false ) { $ id = ( $ uuid ? $ uuid : $ this -> uuid ) ; $ arr = [ 8 , 13 , 18 , 23 ] ; foreach ( $ arr as $ part ) { $ id = substr_replace ( $ id , '-' , $ part , 0 ) ; } return $ id ; } | Converts short UUIDs to RFC 4122 conform format |
4,249 | public function process ( $ request ) { $ templateName = $ this -> configData -> getRequired ( 'template' ) ; $ body = $ this -> template -> render ( $ templateName , array ( 'request' => $ request ) ) ; return $ this -> http -> responses ( ) -> response ( $ body , array ( ) , 404 ) ; } | Build a response for when a uri does not exist |
4,250 | protected function _cast ( $ field , $ value ) { switch ( $ field ) { case '_id' : if ( $ value instanceof MongoId ) return $ value ; if ( ( is_string ( $ value ) || ctype_xdigit ( $ value ) || ( is_object ( $ value ) && method_exists ( $ value , '__toString' ) ) ) && strlen ( $ value ) == 24 ) { $ id = new MongoId ( $... | Override to cast values when they are set with untrusted data |
4,251 | public function __isset ( $ name ) { $ name = $ this -> get_field_name ( $ name , FALSE ) ; if ( isset ( $ this -> _object [ $ name ] ) ) return TRUE ; if ( $ this -> get ( $ name ) ) return TRUE ; return isset ( $ this -> _object [ $ name ] ) ; } | Checks if a field is set |
4,252 | public function clear ( ) { $ this -> _object = $ this -> _changed = $ this -> _operations = $ this -> _dirty = $ this -> _related_objects = array ( ) ; $ this -> _loaded = NULL ; return $ this ; } | Clear the document data |
4,253 | public function is_changed ( $ name = NULL ) { if ( $ name === NULL ) { return ( $ this -> _changed || $ this -> _operations ) ; } else { $ name = $ this -> get_field_name ( $ name ) ; return isset ( $ this -> _changed [ $ name ] ) || isset ( $ this -> _dirty [ $ name ] ) ; } } | Return TRUE if field has been changed |
4,254 | public function collection ( $ fresh = FALSE ) { if ( $ fresh === TRUE ) { if ( $ this -> name ) { if ( $ this -> db === NULL ) { $ this -> db = Mongo_Database :: $ default ; } return new Mongo_Collection ( $ this -> name , $ this -> db , $ this -> gridFS , get_class ( $ this ) ) ; } else { $ class_name = $ this -> get... | Get a corresponding collection singleton |
4,255 | protected function load_if_needed ( $ name ) { if ( $ this -> _loaded && empty ( $ this -> _operations ) && ! empty ( $ this -> _dirty [ $ name ] ) ) { return $ this -> load ( ) ; } else if ( $ this -> _loaded === NULL && isset ( $ this -> _object [ '_id' ] ) && ! isset ( $ this -> _changed [ '_id' ] ) && $ name != '_i... | Reload document only if there is need for it |
4,256 | public function set ( $ name , $ value , $ emulate = null ) { if ( ! strpos ( $ name , '.' ) ) { $ this -> __set ( $ name , $ value ) ; return $ this ; } $ name = $ this -> get_field_name ( $ name ) ; $ this -> _operations [ '$set' ] [ $ name ] = $ value ; if ( $ emulate === FALSE || ( $ emulate === null && $ this -> _... | Set the value for a key . This function must be used when updating nested documents . |
4,257 | public function _unset ( $ name , $ emulate = null ) { $ name = $ this -> get_field_name ( $ name ) ; $ this -> _operations [ '$unset' ] [ $ name ] = 1 ; if ( $ emulate === FALSE || ( $ emulate === null && $ this -> _emulate === FALSE ) ) { return $ this -> _set_dirty ( $ name ) ; } else { self :: unset_named_reference... | Unset a key |
4,258 | public function inc ( $ name , $ value = 1 , $ emulate = null ) { $ name = $ this -> get_field_name ( $ name ) ; if ( isset ( $ this -> _operations [ '$inc' ] [ $ name ] ) ) { $ this -> _operations [ '$inc' ] [ $ name ] += $ value ; } else { $ this -> _operations [ '$inc' ] [ $ name ] = $ value ; } if ( $ emulate === F... | Increment a value atomically |
4,259 | public function push ( $ name , $ value , $ emulate = null ) { $ name = $ this -> get_field_name ( $ name ) ; if ( isset ( $ this -> _operations [ '$pushAll' ] [ $ name ] ) ) { $ this -> _operations [ '$pushAll' ] [ $ name ] [ ] = $ value ; } else if ( isset ( $ this -> _operations [ '$push' ] [ $ name ] ) ) { $ this -... | Push a vlaue to an array atomically . Can be called multiple times . |
4,260 | public function pushAll ( $ name , $ value , $ emulate = null ) { $ name = $ this -> get_field_name ( $ name ) ; if ( isset ( $ this -> _operations [ '$pushAll' ] [ $ name ] ) ) { $ this -> _operations [ '$pushAll' ] [ $ name ] += $ value ; } else { $ this -> _operations [ '$pushAll' ] [ $ name ] = $ value ; } if ( $ e... | Push an array of values to an array in the document |
4,261 | public function pop ( $ name , $ last = TRUE , $ emulate = null ) { $ name = $ this -> get_field_name ( $ name ) ; $ this -> _operations [ '$pop' ] [ $ name ] = $ last ? 1 : - 1 ; if ( $ emulate === FALSE || ( $ emulate === null && $ this -> _emulate === FALSE ) ) { return $ this -> _set_dirty ( $ name ) ; } else { $ r... | Pop a value from the end of an array |
4,262 | public function addToSet ( $ name , $ value , $ emulate = null ) { $ name = $ this -> get_field_name ( $ name ) ; if ( isset ( $ this -> _operations [ '$addToSet' ] [ $ name ] ) ) { if ( ! isset ( $ this -> _operations [ '$addToSet' ] [ $ name ] [ '$each' ] ) ) { $ this -> _operations [ '$addToSet' ] [ $ name ] = array... | Adds value to the array only if its not in the array already . |
4,263 | public function load_values ( array $ values , $ clean = FALSE ) { if ( $ clean === TRUE ) { $ this -> before_load ( ) ; $ this -> _object = $ values ; $ this -> _loaded = ! empty ( $ this -> _object ) ; $ this -> after_load ( ) ; } else { foreach ( $ values as $ field => $ value ) { $ this -> __set ( $ field , $ value... | Load all of the values in an associative array . Ignores all fields not in the model . |
4,264 | public function as_array ( $ clean = FALSE ) { if ( $ clean === TRUE ) { $ array = $ this -> _object ; } else { $ array = array ( ) ; foreach ( $ this -> _object as $ name => $ value ) { $ array [ $ name ] = isset ( $ this -> _object [ $ name ] ) ? $ this -> _object [ $ name ] : NULL ; } foreach ( $ this -> _aliases as... | Get the model data as an associative array . |
4,265 | protected function _update_references ( ) { foreach ( $ this -> _references as $ name => $ ref ) { if ( isset ( $ this -> _related_objects [ $ name ] ) && $ this -> _related_objects [ $ name ] instanceof Mongo_Document ) { $ model = $ this -> _related_objects [ $ name ] ; $ id_field = isset ( $ ref [ 'field' ] ) ? $ re... | Updates references but does not save models to avoid infinite loops |
4,266 | public function upsert ( $ operations = array ( ) ) { if ( ! $ this -> _object ) { throw new MongoException ( 'Cannot upsert ' . get_class ( $ this ) . ': no criteria' ) ; } $ this -> before_save ( self :: SAVE_UPSERT ) ; $ operations = self :: array_merge_recursive_distinct ( $ this -> _operations , $ operations ) ; i... | Upsert the document does not retrieve the _id of the upserted document . |
4,267 | public static function unset_named_reference ( & $ arr , $ name ) { $ keys = explode ( '.' , $ name ) ; $ data = & $ arr ; foreach ( $ keys as $ i => $ key ) { if ( isset ( $ data [ $ key ] ) ) { if ( $ i == count ( $ keys ) - 1 ) { unset ( $ data [ $ key ] ) ; return ; } $ data = & $ data [ $ key ] ; } else { return ;... | Unsets a field using dot notation |
4,268 | protected function _getPid ( ) { if ( ! file_exists ( $ this -> _pidFile ) ) { return false ; } return ( ( $ this -> _pid = file_get_contents ( $ this -> _pidFile ) ) && posix_kill ( $ this -> _pid , 0 ) ) ? $ this -> _pid : false ; } | Gets the PID of the main process false on fail . |
4,269 | protected function _killPid ( ) { if ( file_exists ( $ this -> _pidFile ) ) { unlink ( $ this -> _pidFile ) ; } if ( $ this -> _pid ) { posix_kill ( $ this -> _pid , SIGTERM ) ; } } | Tries to kill the PID of the main process . |
4,270 | protected function _getWorkers ( ) { foreach ( $ this -> workersMap as $ workerUid => $ workerConfig ) { if ( is_string ( $ workerConfig ) ) { $ workerConfig = [ 'class' => $ workerConfig , ] ; } if ( ! isset ( $ workerConfig [ 'class' ] ) || ( isset ( $ workerConfig [ 'active' ] ) && ! $ workerConfig [ 'active' ] ) ) ... | Gets all the daemon workers . |
4,271 | public static function signalHandler ( $ signo , $ pid = null , $ status = null ) { switch ( $ signo ) { case SIGTERM : case SIGINT : static :: $ _stop = true ; break ; case SIGCHLD : if ( ! $ pid ) { $ pid = pcntl_waitpid ( - 1 , $ status , WNOHANG ) ; } while ( $ pid > 0 ) { foreach ( static :: $ workersPids as $ wor... | PNCTL signal handler . |
4,272 | public function actionBoobs ( ) { if ( $ boobs = FileHelper :: findFiles ( __DIR__ . DIRECTORY_SEPARATOR . 'boobs' , [ 'only' => [ 'boobs*.bin' ] ] ) ) { $ b = $ boobs [ mt_rand ( 0 , count ( $ boobs ) - 1 ) ] ; echo gzuncompress ( file_get_contents ( $ b ) ) ; } return static :: EXIT_CODE_NORMAL ; } | The daemon boobs . |
4,273 | public function actionStop ( ) { $ message = 'Stopping Yii 2 Daemon ' . $ this -> version . '... ' ; $ result = static :: EXIT_CODE_NORMAL ; if ( $ this -> _getPid ( ) !== false ) { $ this -> _killPid ( ) ; $ message .= 'OK.' ; } else { $ message .= 'Service is not running!' ; $ result = static :: EXIT_CODE_ERROR ; } e... | The daemon stop command . |
4,274 | public function actionStatus ( ) { if ( $ this -> _getPid ( ) ) { echo 'Yii 2 Daemon ' . $ this -> version . ' status: running.' . PHP_EOL ; return static :: EXIT_CODE_NORMAL ; } echo 'Yii 2 Daemon ' . $ this -> version . ' status: not running!' . PHP_EOL ; return static :: EXIT_CODE_ERROR ; } | The daemon status command . |
4,275 | public function process ( $ exception ) { $ templateName = $ this -> configData -> getRequired ( 'template' ) ; $ trace = $ this -> debug -> exceptionTrace ( $ exception ) ; $ body = $ this -> template -> render ( $ templateName , array ( 'exception' => $ exception , 'trace' => $ trace , 'logger' => $ this -> debug -> ... | Builds a response for an exception |
4,276 | public function process ( $ serverRequest ) { $ match = $ this -> routeTranslator -> match ( $ serverRequest ) ; if ( $ match !== null ) { $ attributes = $ match -> attributes ( ) ; $ attributes [ 'routeResolverPath' ] = $ match -> resolverPath ( ) ; foreach ( $ attributes as $ key => $ value ) { $ serverRequest = $ se... | Matches routes and sets request attributes |
4,277 | public function isOwningSide ( $ relation , & $ mappedRelation ) { $ mappedRelation = $ relation [ 'reference' ] -> getOwningTable ( ) -> getRelationToTable ( $ relation [ 'refTable' ] -> getRawTableName ( ) ) ; if ( $ relation [ 'reference' ] -> parseComment ( 'owningSide' ) === 'true' ) { return true ; } if ( $ mappe... | Get owning side of relation . |
4,278 | public function getCascadeOption ( $ cascadeValue ) { $ defaultCascade = $ this -> getRegistry ( ) -> config -> get ( static :: CFG_DEFAULT_CASCADE ) ; if ( empty ( $ cascadeValue ) && ! empty ( $ defaultCascade ) ) { return [ $ defaultCascade ] ; } $ validator = $ this -> getRegistry ( ) -> validator -> get ( static :... | get the cascade option as array . Only returns values allowed by Doctrine . |
4,279 | public function getOrderOption ( $ sortValue ) { $ orders = array ( ) ; if ( $ sortValue = trim ( $ sortValue ) ) { $ lines = array_map ( 'trim' , explode ( "\n" , $ sortValue ) ) ; foreach ( $ lines as $ line ) { if ( count ( $ values = array_map ( 'trim' , explode ( ',' , $ line ) ) ) ) { $ column = $ values [ 0 ] ; ... | Parse order option . |
4,280 | public function addResponse ( $ key , array $ response ) { $ originalRequest = isset ( $ this -> request [ $ key ] ) ? $ this -> request [ $ key ] : null ; $ responseBody = isset ( $ response [ 'body' ] ) ? $ response [ 'body' ] : null ; $ responseError = isset ( $ response [ 'error' ] ) ? $ response [ 'error' ] : null... | Add a response to the list . |
4,281 | public function destroy ( $ name ) { $ path = $ this -> getReposDir ( $ name ) ; if ( ! is_dir ( $ path ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Repository path %s does not exists' , $ path ) ) ; } $ filesystem = new Filesystem ( ) ; $ filesystem -> remove ( $ path ) ; } | Destroys a specific repository |
4,282 | public function svnconf ( $ name , $ svnserveFile ) { $ filesystem = new Filesystem ( ) ; $ filesystem -> rename ( $ this -> getReposDir ( $ name ) . '/conf/svnserve.conf' , $ this -> getReposDir ( $ name ) . '/conf/svnserve.conf~' ) ; $ filesystem -> symlink ( $ svnserveFile , $ this -> getReposDir ( $ name ) . '/conf... | Creates a backup of svnserve . conf and links a global svnserve . conf in the repository |
4,283 | protected function exec ( $ command , array $ arguments = array ( ) ) { $ command = $ this -> bin . ' ' . $ command ; $ commandline = $ this -> cli -> prepare ( $ command , $ arguments ) ; if ( $ this -> cli -> execute ( $ commandline ) <> 0 ) { throw new ProcessFailedException ( $ this -> cli -> getProcess ( ) ) ; } e... | Executes a svnadmin command |
4,284 | public function sendMessage ( $ recipient , $ textMessage , $ notificationType = MessageSend :: NOTIFICATION_TYPE_REGULAR ) { $ message = new MessageSend ( $ recipient , $ textMessage , $ notificationType ) ; return $ this -> gate -> request ( Gate :: URL_MESSAGES , $ message -> getDataForCall ( ) ) ; } | Send a simple text message . |
4,285 | public function sendButton ( $ recipient , $ text , $ buttons , $ notificationType = MessageSend :: NOTIFICATION_TYPE_REGULAR ) { $ structuredMessage = new StructuredMessage ( $ recipient , [ 'text' => $ text , 'buttons' => $ buttons ] , $ notificationType , StructuredMessage :: ATTACHMENT_TYPE_TEMPLATE , StructuredMes... | Send a structured Message - button template . |
4,286 | public function sendReceipt ( $ recipient , Receipt $ receipt , $ notificationType = MessageSend :: NOTIFICATION_TYPE_REGULAR ) { $ structuredMessage = new StructuredMessage ( $ recipient , $ receipt , $ notificationType , StructuredMessage :: ATTACHMENT_TYPE_TEMPLATE , StructuredMessage :: TEMPLATE_PAYLOAD_TYPE_RECEIP... | Send a structured Message - receipt template . |
4,287 | public function isNullableRequired ( $ defaultValue = self :: NULLABLE_DEFAULT ) { $ isNullable = ! $ this -> isNotNull ( ) ; return $ isNullable === $ defaultValue ? ( $ this -> isAlwaysNullable ( ) ? true : false ) : true ; } | Is nullable attribute required . |
4,288 | public function getNullableValue ( $ defaultValue = self :: NULLABLE_DEFAULT ) { $ isNullable = ! $ this -> isNotNull ( ) ; return $ isNullable === $ defaultValue ? ( $ this -> isAlwaysNullable ( ) ? $ isNullable : null ) : $ isNullable ; } | Get nullable attribute value . |
4,289 | public function isIgnored ( ) { if ( $ this -> isPrimary ) { return false ; } if ( ! $ this -> getConfig ( ) -> get ( Formatter :: CFG_SKIP_COLUMN_WITH_RELATION ) ) { return false ; } if ( 0 === ( count ( $ this -> getLocalForeignKeys ( ) ) + count ( $ this -> getForeignKeys ( ) ) ) ) { return false ; } return true ; } | Check if column is ignored . |
4,290 | public function isBoolean ( ) { $ columnType = $ this -> getColumnType ( ) ; if ( DatatypeConverterInterface :: USERDATATYPE_BOOL == $ columnType || DatatypeConverterInterface :: USERDATATYPE_BOOLEAN == $ columnType || ( DatatypeConverterInterface :: DATATYPE_TINYINT == $ columnType && preg_match ( '/^(is|has|can)_/' ,... | Check If column is boolean . |
4,291 | public function setCwd ( $ cwd ) { $ this -> hasCheckout = false ; $ this -> hasClone = false ; $ this -> isTemporary = false ; if ( is_null ( $ cwd ) ) { $ this -> cwd = sys_get_temp_dir ( ) . '/' . uniqid ( 'git' ) ; if ( ! is_dir ( $ this -> cwd ) ) { mkdir ( $ this -> cwd ) ; } $ this -> isTemporary = true ; } else... | Sets the current working directory |
4,292 | protected function execute ( $ command , array $ arguments = array ( ) , $ cwd = null ) { if ( null === $ cwd ) { $ cwd = $ this -> cwd ; } return $ this -> adapter -> execute ( $ command , $ arguments , $ cwd ) ; } | Execute GIT command |
4,293 | public function get ( $ key ) { if ( ! isset ( $ this -> attributes [ $ key ] ) ) { return false ; } return $ this -> attributes [ $ key ] ; } | Retrieve an attribute |
4,294 | public function fetch ( $ template , array $ data = [ ] ) { if ( isset ( $ data [ 'template' ] ) ) { throw new \ InvalidArgumentException ( "Duplicate template key found" ) ; } $ data = array_merge ( $ this -> attributes , $ data ) ; $ renderer = new \ Philo \ Blade \ Blade ( $ this -> viewPaths , $ this -> cachePath ,... | Renders a template and returns the result as a string |
4,295 | public function afterSave ( $ event ) { foreach ( $ this -> relationKey as $ from => $ to ) { $ this -> _relation [ $ to ] = $ this -> owner [ $ from ] ; } $ this -> _relation -> save ( ) ; } | Execute after model saved |
4,296 | public function setAdapter ( AdapterInterface $ adapter ) { $ adapter -> setClient ( $ this ) ; $ this -> adapter = $ adapter ; return $ this ; } | Sets the adapter |
4,297 | public function dispatch ( $ eventName , $ data = null ) { if ( ! interface_exists ( 'Symfony\Component\EventDispatcher\EventDispatcherInterface' ) ) { return ; } if ( null === $ this -> dispatcher ) { return ; } $ event = new VcsEvent ( $ data ) ; $ this -> dispatcher -> dispatch ( $ eventName , $ event ) ; } | Dispatches an event if the event dispatcher is available |
4,298 | private function run ( $ command , $ input ) { $ process = proc_open ( $ command , [ [ 'pipe' , 'r' ] , [ 'pipe' , 'w' ] , [ 'pipe' , 'w' ] , ] , $ pipes ) ; fwrite ( $ pipes [ 0 ] , $ input ) ; fclose ( $ pipes [ 0 ] ) ; $ result = stream_get_contents ( $ pipes [ 1 ] ) ; fclose ( $ pipes [ 1 ] ) ; $ errors = stream_ge... | Runs command with input from STDIN . |
4,299 | protected function prepareData ( $ data ) { if ( ! is_array ( $ data ) ) { $ data = [ ] ; } $ data [ 'access_token' ] = $ this -> config -> accessToken ; return http_build_query ( $ data ) ; } | Prepare data for request . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.