idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
50,200 | public function onReflectSuccess ( $ event ) { $ filename = $ event [ 'file' ] -> getPathname ( ) ; $ appEvent = $ this -> stopwatch -> stop ( $ filename ) ; $ time = $ appEvent -> getDuration ( ) ; self :: $ logger -> info ( 'AST built in {time} on file "{file}"' , array ( 'time' => Timer :: toTimeString ( $ time ) , ... | After parsing a file of the data source . |
50,201 | public function onReflectError ( $ event ) { $ filename = $ event [ 'file' ] -> getPathname ( ) ; $ this -> stopwatch -> stop ( $ filename ) ; self :: $ logger -> error ( 'Parse error in {time} on file "{file"}: {error}' , array ( 'time' => Timer :: toTimeString ( $ time ) , 'file' => $ filename , 'error' => $ event [ ... | PHP - Parser raised an error . |
50,202 | public function onReflectComplete ( $ event ) { $ appEvent = $ this -> stopwatch -> stop ( $ event [ 'source' ] ) ; $ time = $ appEvent -> getDuration ( ) ; self :: $ logger -> notice ( 'Parsing data source {source} completed in {time}' , array ( 'time' => Timer :: toTimeString ( $ time ) , 'source' => $ event [ 'sourc... | A parse request is over . |
50,203 | public function dir ( OutputInterface $ output , $ response ) { if ( empty ( $ response ) ) { $ output -> writeln ( '<info>No plugin installed</info>' ) ; } else { $ headers = array ( 'Plugin Class' , 'Events Subscribed' ) ; $ rows = array ( ) ; foreach ( $ response as $ pluginClass => $ events ) { $ first = true ; for... | Plugin list results |
50,204 | public static function getJsonConfigFilename ( ) { $ scanDir = getenv ( 'BARTLETT_SCAN_DIR' ) ; if ( $ scanDir ) { $ dirs = explode ( PATH_SEPARATOR , $ scanDir ) ; foreach ( $ dirs as $ scanDir ) { $ filename = $ scanDir . DIRECTORY_SEPARATOR . getenv ( 'BARTLETTRC' ) ; if ( file_exists ( $ filename ) && is_file ( $ f... | Search a json file on a list of scan directory pointed by the BARTLETT_SCAN_DIR env var . Config filename is identify by the BARTLETTRC env var . |
50,205 | public static function setScanDir ( ) { if ( ! getenv ( "BARTLETT_SCAN_DIR" ) ) { $ home = defined ( 'PHP_WINDOWS_VERSION_BUILD' ) ? 'USERPROFILE' : 'HOME' ; $ dirs = array ( realpath ( '.' ) , getenv ( $ home ) . DIRECTORY_SEPARATOR . '.config' , DIRECTORY_SEPARATOR . 'etc' , ) ; putenv ( "BARTLETT_SCAN_DIR=" . implod... | Defines the scan directories where to search for a json config file . |
50,206 | protected function visitClass ( Node \ Stmt \ Class_ $ class ) { $ this -> metrics [ 'classes' ] ++ ; $ this -> metrics [ 'llocClasses' ] += $ this -> llocClasses ; } | Explore each user classes found in the current namespace . |
50,207 | public function run ( OutputInterface $ output , $ response ) { $ output -> writeln ( '<comment>Diagnostics:</comment>' ) ; foreach ( $ response as $ key => $ value ) { if ( strcasecmp ( 'php_version' , $ key ) == 0 ) { $ output -> writeln ( 'Checking php settings:' ) ; $ output -> writeln ( sprintf ( '- Requires PHP '... | Diagnose run results |
50,208 | protected function visitClass ( Node \ Stmt \ Class_ $ class ) { $ this -> testClass = false ; $ parent = $ class -> extends ; if ( empty ( $ parent ) ) { if ( substr ( $ class -> name , - 8 ) == 'TestCase' ) { $ this -> testClass = true ; } } else { if ( ( string ) $ parent === 'PHPUnit_Framework_TestCase' ) { $ this ... | Visits a class node . |
50,209 | public function isHandling ( array $ record ) { $ level = array_search ( $ record [ 'level' ] , self :: $ levels ) ; return $ level >= $ this -> level ; } | Checks whether the given record will be handled by this handler . |
50,210 | public function interpolate ( array $ record ) { if ( false === strpos ( $ record [ 'message' ] , '{' ) ) { return $ record ; } $ replacements = array ( ) ; foreach ( $ record [ 'context' ] as $ key => $ val ) { if ( is_null ( $ val ) || is_scalar ( $ val ) || ( is_object ( $ val ) && method_exists ( $ val , "__toStrin... | Processes a record s message according to PSR - 3 rules |
50,211 | public function class_ ( $ argument , $ source , $ alias = null , $ engine = 'plantuml' ) { return $ this -> request ( 'diagram/class' , 'POST' , array ( $ argument , $ source , $ alias , $ engine ) ) ; } | Generates diagram about a user class present in a data source . |
50,212 | public function exists ( $ request ) { $ this -> key = $ request [ 'source' ] ; if ( $ this -> entries = $ this -> cache -> fetch ( $ this -> key ) ) { return true ; } return false ; } | Checks if cache exists for a request . |
50,213 | public function fetch ( $ request ) { if ( ! $ this -> exists ( $ request ) ) { return ; } $ manifest = null ; foreach ( $ this -> entries as $ index => $ entry ) { if ( $ entry [ 'sourceFile' ] === $ request [ 'file' ] -> getPathname ( ) ) { $ manifest = $ entry ; break ; } } if ( ! isset ( $ manifest ) ) { return ; }... | Get a response from the cache for a request . |
50,214 | public function cache ( $ request ) { $ currentTime = time ( ) ; $ entries = array ( ) ; if ( $ this -> exists ( $ request ) ) { foreach ( $ this -> entries as $ entry ) { if ( $ entry [ 'expiration' ] < $ currentTime ) { continue ; } if ( $ entry [ 'sourceFile' ] === $ request [ 'file' ] -> getPathname ( ) ) { $ this ... | Cache a FILE parse . |
50,215 | public function delete ( $ request ) { $ entriesCleared = 0 ; if ( $ this -> exists ( $ request ) ) { foreach ( $ this -> entries as $ entry ) { if ( $ entry [ 'cacheData' ] ) { if ( $ this -> cache -> delete ( $ entry [ 'cacheData' ] ) ) { $ entriesCleared ++ ; } } } $ this -> cache -> delete ( $ this -> key ) ; } ret... | Deletes cache entries that match a request . |
50,216 | public function onReflectProgress ( GenericEvent $ event ) { if ( $ response = $ this -> storage -> fetch ( $ event ) ) { ++ $ this -> stats [ self :: STATS_HITS ] ; $ this -> hashUserData = sha1 ( serialize ( $ response ) ) ; $ event [ 'notModified' ] = $ response ; } else { $ this -> hashUserData = null ; } } | Checks if results in cache will satisfy the source before parsing . |
50,217 | public function onReflectSuccess ( GenericEvent $ event ) { if ( sha1 ( serialize ( $ event [ 'ast' ] ) ) !== $ this -> hashUserData ) { ++ $ this -> stats [ self :: STATS_MISSES ] ; $ this -> storage -> cache ( $ event ) ; } } | If possible store results in cache after source parsing . |
50,218 | public function generateCommands ( array $ classes = null ) { if ( ! isset ( $ classes ) ) { $ classes = array ( ) ; } $ path = dirname ( __DIR__ ) . '/Api' ; if ( \ Phar :: running ( false ) ) { $ iterator = new \ Phar ( $ path ) ; } else { $ iterator = new \ DirectoryIterator ( $ path ) ; } foreach ( $ iterator as $ ... | Generates Commands from all Api Methods or a predefined set . |
50,219 | private function generateCommand ( $ namespace , \ ReflectionMethod $ method ) { $ factory = DocBlockFactory :: createInstance ( ) ; $ docBlock = $ factory -> create ( $ method -> getDocComment ( ) ) ; $ methodShortName = $ method -> getShortName ( ) ; $ command = new Command ( $ namespace . ':' . $ this -> dash ( $ me... | Creates a Command based on an Api Method |
50,220 | private function buildDefinition ( $ namespace , \ ReflectionMethod $ method , $ params , $ cmdExceptions ) { $ definition = new InputDefinition ( ) ; foreach ( $ method -> getParameters ( ) as $ pos => $ parameter ) { $ name = $ parameter -> getName ( ) ; $ description = null ; if ( isset ( $ params [ $ pos ] ) ) { if... | Builds the Input Definition based upon Api Method Parameters |
50,221 | public function registerPlugins ( ) { $ jsonFile = Environment :: getJsonConfigFilename ( ) ; if ( ! $ jsonFile ) { return ; } $ config = new Config ; $ var = $ config -> validate ( $ jsonFile ) ; foreach ( $ var [ 'plugins' ] as $ plugin ) { if ( class_exists ( $ plugin [ 'class' ] ) ) { if ( isset ( $ plugin [ 'optio... | Loads all plugins declared in the JSON config file . |
50,222 | protected function printFormattedLines ( OutputInterface $ output , array $ lines ) { foreach ( $ lines as $ ident => $ contents ) { list ( $ format , $ args ) = $ contents ; $ output -> writeln ( vsprintf ( $ format , $ args ) ) ; } } | Helper that convert an array key - value pairs to a console report . |
50,223 | public function autoload ( ) { spl_autoload_register ( function ( $ className ) { $ className = str_replace ( "\\" , DS , $ className ) ; $ classNameOnly = basename ( $ className ) ; $ namespace = substr ( $ className , 0 , - strlen ( $ classNameOnly ) ) ; if ( is_file ( $ class = BASE_PATH . "{$className}.php" ) ) { r... | Magic autoload . |
50,224 | public function ip ( ) { if ( isset ( $ _SERVER [ "HTTP_CLIENT_IP" ] ) ) { $ ip = $ _SERVER [ "HTTP_CLIENT_IP" ] ; } elseif ( isset ( $ _SERVER [ "HTTP_X_FORWARDED_FOR" ] ) ) { $ ip = $ _SERVER [ "HTTP_X_FORWARDED_FOR" ] ; } elseif ( isset ( $ _SERVER [ "HTTP_X_FORWARDED" ] ) ) { $ ip = $ _SERVER [ "HTTP_X_FORWARDED" ]... | Get user IP . |
50,225 | public function platform ( ) { if ( preg_match ( '/linux/i' , $ this -> server [ 'HTTP_USER_AGENT' ] ) ) { return 'linux' ; } elseif ( preg_match ( '/macintosh|mac os x/i' , $ this -> server [ 'HTTP_USER_AGENT' ] ) ) { return 'mac' ; } elseif ( preg_match ( '/windows|win32/i' , $ this -> server [ 'HTTP_USER_AGENT' ] ) ... | Get user platform . |
50,226 | public function route ( array $ method , $ uri , $ callback , $ options = [ ] ) { if ( is_array ( $ uri ) ) { foreach ( $ uri as $ u ) { $ this -> route ( $ method , $ u , $ callback , $ options ) ; } return $ this ; } $ options = array_merge ( [ 'ajaxOnly' => false , 'continue' => false ] , ( array ) $ options ) ; if ... | Register a route with callback . |
50,227 | public function group ( $ group , callable $ callback , array $ options = [ ] ) { $ options = array_merge ( [ 'as' => $ group , 'namespace' => $ group ] , $ options ) ; if ( is_array ( $ group ) ) { foreach ( $ group as $ k => $ p ) { $ this -> group ( $ p , $ callback , [ 'as' => $ options [ 'as' ] [ $ k ] , 'namespac... | Group of routes . |
50,228 | protected function bindArgs ( array $ pram , array $ args ) { if ( count ( $ pram ) == count ( $ args ) ) { $ newArgs = array_combine ( $ pram , $ args ) ; } else { $ newArgs = [ ] ; foreach ( $ pram as $ p ) { $ newArgs [ $ p ] = array_shift ( $ args ) ; } if ( isset ( $ args [ 0 ] ) && count ( $ args ) == 1 ) { forea... | Bind args and parameters . |
50,229 | protected function namedParameters ( $ uri , $ isGroup = false ) { $ this -> patt = [ ] ; $ this -> prams = [ ] ; return preg_replace_callback ( '/\/\{([a-z-0-9]+)\}\??(:\(?[^\/]+\)?)?/i' , function ( $ m ) use ( $ isGroup ) { if ( isset ( $ m [ 2 ] ) ) { $ rep = substr ( $ m [ 2 ] , 1 ) ; $ patt = isset ( $ this -> pa... | Register a parameter name with validation from route uri . |
50,230 | protected function prepare ( $ patt , $ strict = true ) { if ( substr ( $ patt , 0 , 3 ) == '/(/' ) { $ patt = substr ( $ patt , 1 ) ; } return '~^' . $ patt . ( $ strict ? '$' : '' ) . '~i' ; } | Prepare a regex pattern . |
50,231 | protected function matched ( $ patt , $ call = true ) { if ( preg_match ( $ patt , $ this -> req -> path , $ m ) ) { if ( $ call ) { $ this -> matched = true ; } array_shift ( $ m ) ; $ this -> matchedArgs = array_map ( [ $ this , 'trimSlash' ] , $ m ) ; return true ; } return false ; } | Checks whether the current route matches the specified pattern . |
50,232 | public function _as ( $ name ) { if ( empty ( $ name ) ) return $ this ; $ name = rtrim ( $ this -> getGroupAs ( ) . str_replace ( '/' , '.' , strtolower ( $ name ) ) , '.' ) ; $ patt = $ this -> patt ; $ pram = $ this -> prams ; if ( $ this -> isGroup ) { $ patt = array_merge ( $ this -> pattGroup , $ patt ) ; if ( co... | Set a route name . |
50,233 | public function getRoute ( $ name , array $ args = [ ] ) { $ name = strtolower ( $ name ) ; if ( isset ( $ this -> routes [ $ name ] ) ) { $ route = $ this -> routes [ $ name ] ; foreach ( $ args as $ k => $ v ) { $ route = str_replace ( ':' . $ k , $ v , $ route ) ; } return $ route ; } return null ; } | Register a new listener into the specified event . |
50,234 | public function end ( ) { ob_start ( ) ; if ( $ this -> matched && count ( $ this -> routeCallback ) ) { count ( $ this -> before ) && $ this -> emit ( $ this -> before ) ; foreach ( $ this -> routeCallback as $ call ) { $ this -> callback ( $ call , $ this -> req -> args ) ; } count ( $ this -> after ) && $ this -> em... | Run and get a response . |
50,235 | protected function callback ( $ callback , array $ args = [ ] ) { if ( isset ( $ callback ) ) { if ( is_callable ( $ callback ) && $ callback instanceof \ Closure ) { $ o = new \ ArrayObject ( $ args ) ; $ o -> app = App :: instance ( ) ; $ callback = $ callback -> bindTo ( $ o ) ; } elseif ( is_string ( $ callback ) &... | Call a route that has been matched . |
50,236 | public static function all ( $ page = 1 , $ per_page = 10 ) { $ collections = self :: get ( "/collections" , [ 'query' => [ 'page' => $ page , 'per_page' => $ per_page ] ] ) ; $ collectionsArray = self :: getArray ( $ collections -> getBody ( ) , get_called_class ( ) ) ; return new ArrayObject ( $ collectionsArray , $ ... | Retrieve all collections for a given page |
50,237 | public static function find ( $ id ) { $ collection = json_decode ( self :: get ( "/collections/{$id}" ) -> getBody ( ) , true ) ; return new self ( $ collection ) ; } | Retrieve a specific collection |
50,238 | public function add ( $ photo_id ) { $ photo_and_collection = json_decode ( self :: post ( "/collections/{$this->id}/add" , [ 'query' => [ 'photo_id' => $ photo_id ] ] ) -> getBody ( ) , true ) ; $ this -> photos = [ ] ; } | Add a photo in user s collection |
50,239 | public static function create ( $ title , $ description = '' , $ private = false ) { $ collection = json_decode ( self :: post ( "/collections" , [ 'query' => [ 'title' => $ title , 'description' => $ description , 'private' => $ private ] ] ) -> getBody ( ) , true ) ; return new self ( $ collection ) ; } | Create a new collection . The user needs to connect their account and authorize the write_collections permission scope . |
50,240 | public function related ( ) { $ collections = self :: get ( "/collections/{$this->id}/related" ) ; $ collectionsArray = self :: getArray ( $ collections -> getBody ( ) , get_called_class ( ) ) ; return new ArrayObject ( $ collectionsArray , $ collections -> getHeaders ( ) ) ; } | Get related collections to current collection |
50,241 | public static function find ( $ id ) { $ category = json_decode ( self :: get ( "/categories/{$id}" ) -> getBody ( ) , true ) ; return new self ( $ category ) ; } | Retrieve the a Category object from the id specified |
50,242 | public static function all ( $ page = 1 , $ per_page = 10 ) { $ categories = self :: get ( "/categories" , [ 'query' => [ 'page' => $ page , 'per_page' => $ per_page ] ] ) ; $ categoriesArray = self :: getArray ( $ categories -> getBody ( ) , get_called_class ( ) ) ; return new ArrayObject ( $ categoriesArray , $ categ... | Retrieve all the categories on a specific page . Returns an ArrayObject that contains Category objects . |
50,243 | public function photos ( $ page = 1 , $ per_page = 10 ) { if ( ! isset ( $ this -> photos [ "{$page}-{$per_page}" ] ) ) { $ photos = self :: get ( "/categories/{$this->id}/photos" , [ 'query' => [ 'page' => $ page , 'per_page' => $ per_page ] ] ) ; $ this -> photos [ "{$page}-{$per_page}" ] = [ 'body' => self :: getArr... | Retrieve all the photos for a specific category on a specific page . Returns an ArrayObject that contains Photo objects . |
50,244 | private static function initProvider ( $ credentials = [ ] ) { return new Unsplash ( [ 'clientId' => isset ( $ credentials [ 'applicationId' ] ) ? $ credentials [ 'applicationId' ] : null , 'clientSecret' => isset ( $ credentials [ 'secret' ] ) ? $ credentials [ 'secret' ] : null , 'redirectUri' => isset ( $ credential... | Create an unsplash provider from the credentials provided by the user . If only the applicationId is set non - public scoped permissions won t work since access tokens can t be created without the secret and callback url |
50,245 | private static function initAccessToken ( $ accessToken ) { if ( is_array ( $ accessToken ) ) { return new AccessToken ( $ accessToken ) ; } elseif ( is_a ( $ accessToken , '\League\OAuth2\Client\Token\AccessToken' ) ) { return $ accessToken ; } else { return null ; } } | Create an Access Token the provider can use for authentication |
50,246 | public function send ( $ method , $ arguments ) { $ uri = $ arguments [ 0 ] ; $ params = isset ( $ arguments [ 1 ] ) ? $ arguments [ 1 ] : [ ] ; if ( substr ( $ uri , 0 , 1 ) !== '/' ) { $ uri = '/' . $ uri ; } $ response = $ this -> httpClient -> send ( new Request ( $ method , new Uri ( $ uri ) ) , $ params ) ; retur... | Send an http request through the http client . |
50,247 | private function setHandler ( $ authorization ) { $ stack = new HandlerStack ( ) ; $ stack -> setHandler ( new CurlHandler ( ) ) ; $ this -> authorization = $ authorization ; $ stack -> push ( Middleware :: mapRequest ( function ( Request $ request ) { return $ request -> withHeader ( 'Authorization' , $ this -> author... | Generate a new handler that will manage the HTTP requests . |
50,248 | public static function find ( $ id ) { $ photo = json_decode ( self :: get ( "/photos/{$id}" ) -> getBody ( ) , true ) ; return new self ( $ photo ) ; } | Retrieve the a photo object from the ID specified |
50,249 | public static function all ( $ page = 1 , $ per_page = 10 , $ order_by = 'latest' ) { $ photos = self :: get ( "/photos" , [ 'query' => [ 'page' => $ page , 'per_page' => $ per_page , 'order_by' => $ order_by ] ] ) ; $ photosArray = self :: getArray ( $ photos -> getBody ( ) , get_called_class ( ) ) ; return new ArrayO... | Retrieve all the photos on a specific page . Returns an ArrayObject that contains Photo objects . |
50,250 | public static function search ( $ search , $ category = null , $ page = 1 , $ per_page = 10 , $ orientation = null ) { $ photos = self :: get ( "/photos/search" , [ 'query' => [ 'query' => $ search , 'category' => $ category , 'orientation' => $ orientation , 'page' => $ page , 'per_page' => $ per_page ] ] ) ; $ photos... | Retrieve all the photos on a specific page depending on search results Returns ArrayObject that contain Photo object . |
50,251 | public static function create ( $ filePath ) { if ( ! file_exists ( $ filePath ) ) { throw new Exception ( [ "{$filePath} has not been found" ] ) ; } $ file = fopen ( $ filePath , 'r' ) ; $ photo = json_decode ( self :: post ( "photos" , [ 'multipart' => [ [ 'name' => 'photo' , 'contents' => $ file ] ] , 'headers' => [... | Create a new photo . The user needs to connect their account and authorize the write_photo permission scope . |
50,252 | public function photographer ( ) { if ( ! isset ( $ this -> photographer ) ) { $ this -> photographer = User :: find ( $ this -> user [ 'username' ] ) ; } return $ this -> photographer ; } | Retrieve the user that uploaded the photo |
50,253 | public static function random ( $ filters = [ ] ) { if ( isset ( $ filters [ 'category' ] ) && is_array ( $ filters [ 'category' ] ) ) { $ filters [ 'category' ] = implode ( ',' , $ filters [ 'category' ] ) ; } $ filters [ 'featured' ] = ( isset ( $ filters [ 'featured' ] ) && $ filters [ 'featured' ] ) ? 'true' : null... | Retrieve a single random photo given optional filters . |
50,254 | public function statistics ( $ resolution = 'days' , $ quantity = 30 ) { $ statistics = self :: get ( "photos/{$this->id}/statistics" , [ 'query' => [ 'resolution' => $ resolution , 'quantity' => $ quantity ] ] ) ; $ statisticsArray = self :: getArray ( $ statistics -> getBody ( ) , Stat :: class ) ; return new ArrayOb... | Retrieve statistics for a photo |
50,255 | public function download ( ) { $ download_path = parse_url ( $ this -> links [ 'download_location' ] , PHP_URL_PATH ) ; $ download_query = parse_url ( $ this -> links [ 'download_location' ] , PHP_URL_QUERY ) ; $ link = self :: get ( $ download_path . "?" . $ download_query ) ; $ linkClass = \ GuzzleHttp \ json_decode ... | Triggers a download for a photo Required under API Guidelines |
50,256 | public function update ( array $ parameters = [ ] ) { json_decode ( self :: put ( "/photos/{$this->id}" , [ 'query' => $ parameters ] ) -> getBody ( ) , true ) ; parent :: update ( $ parameters ) ; } | Update an existing photo |
50,257 | public static function photos ( $ search , $ page = 1 , $ per_page = 10 , $ orientation = null , $ collections = null ) { $ query = [ 'query' => $ search , 'page' => $ page , 'per_page' => $ per_page ] ; if ( ! empty ( $ orientation ) ) { $ query [ 'orientation' ] = $ orientation ; } if ( ! empty ( $ collections ) ) { ... | Retrieve a single page of photo results depending on search results Returns ArrayObject that contain PageResult object . |
50,258 | public static function collections ( $ search , $ page = 1 , $ per_page = 10 ) { $ collections = self :: get ( "/search/collections" , [ 'query' => [ 'query' => $ search , 'page' => $ page , 'per_page' => $ per_page ] ] ) ; return self :: getPageResult ( $ collections -> getBody ( ) , $ collections -> getHeaders ( ) , ... | Retrieve a single page of collection results depending on search results Returns ArrayObject that contain PageResult object . |
50,259 | public static function users ( $ search , $ page = 1 , $ per_page = 10 ) { $ users = self :: get ( "/search/users" , [ 'query' => [ 'query' => $ search , 'page' => $ page , 'per_page' => $ per_page ] ] ) ; return self :: getPageResult ( $ users -> getBody ( ) , $ users -> getHeaders ( ) , User :: class ) ; } | Retrieve a single page of user results depending on search results Returns ArrayObject that contain PageResult object . |
50,260 | public function getConnectionUrl ( $ scopes = [ ] ) { $ connectionUrl = $ this -> provider -> getAuthorizationUrl ( [ 'scope' => $ scopes ] ) ; $ _SESSION [ self :: STATE ] = $ this -> provider -> getState ( ) ; return $ connectionUrl ; } | Retrieve the URL that generates the authorization code |
50,261 | public function generateToken ( $ code ) { $ this -> token = $ this -> provider -> getAccessToken ( 'authorization_code' , [ 'code' => $ code ] ) ; return $ this -> token ; } | Generate a new access token object from an authorization code |
50,262 | public function refreshToken ( ) { if ( is_null ( $ this -> token ) || is_null ( $ this -> token -> getRefreshToken ( ) ) ) { return null ; } $ grant = new RefreshToken ( ) ; $ refreshToken = $ this -> provider -> getAccessToken ( $ grant , [ 'refresh_token' => $ this -> token -> getRefreshToken ( ) ] ) ; $ this -> tok... | Refresh an expired token and generate a new AccessToken object . |
50,263 | public function getAuthorizationToken ( ) { $ authorizationToken = "Client-ID {$this->provider->getClientId()}" ; if ( ! is_null ( $ this -> token ) ) { if ( $ this -> token -> hasExpired ( ) ) { $ this -> refreshToken ( ) ; } $ authorizationToken = "Bearer {$this->token->getToken()}" ; } return $ authorizationToken ; ... | Generate the authorization string to pass in via the http header . Check if a token is linked to the connection object and use the client ID if there is not . The method will also refresh the access token if it has expired . |
50,264 | private static function getErrorMessage ( $ response ) { $ body = $ response -> getBody ( ) ; $ message = json_decode ( $ body , true ) ; $ errors = [ ] ; if ( is_array ( $ message ) && isset ( $ message [ 'errors' ] ) ) { $ errors = $ message [ 'errors' ] ; } if ( $ body == self :: RATE_LIMIT_ERROR_MESSAGE ) { $ error... | Retrieve the error messages in the body |
50,265 | public function totalPages ( ) { $ total = $ this -> totalObjects ( ) ; $ perPage = $ this -> objectsPerPage ( ) ; return ( int ) ceil ( $ total / $ perPage ) ; } | Total number of pages for this call |
50,266 | public function totalObjects ( ) { $ total = 0 ; if ( ! empty ( $ this -> headers [ self :: TOTAL ] ) && is_array ( $ this -> headers [ self :: TOTAL ] ) ) { $ total = ( int ) $ this -> headers [ self :: TOTAL ] [ 0 ] ; } return $ total ; } | Total of object in the collections Value come from X - Total header s value |
50,267 | public function objectsPerPage ( ) { $ perPage = 10 ; if ( ! empty ( $ this -> headers [ self :: PER_PAGE ] ) && is_array ( $ this -> headers [ self :: PER_PAGE ] ) ) { $ perPage = ( int ) $ this -> headers [ self :: PER_PAGE ] [ 0 ] ; } return $ perPage ; } | Number of element per page |
50,268 | public function currentPage ( ) { if ( isset ( $ this -> pages [ self :: NEXT ] ) ) { $ page = $ this -> pages [ self :: NEXT ] - 1 ; } else { $ page = $ this -> pages [ self :: PREV ] + 1 ; } return $ page ; } | Current page number based on the Link header |
50,269 | public static function find ( $ username ) { $ user = json_decode ( self :: get ( "/users/{$username}" ) -> getBody ( ) , true ) ; return new self ( $ user ) ; } | Retrieve a User object from the username specified |
50,270 | public function collections ( $ page = 1 , $ per_page = 10 ) { if ( ! isset ( $ this -> collections [ "{$page}-{$per_page}" ] ) ) { $ collections = self :: get ( "/users/{$this->username}/collections" , [ 'query' => [ 'page' => $ page , 'per_page' => $ per_page ] ] ) ; $ this -> collections [ "{$page}-{$per_page}" ] = ... | Retrieve all the collections for a specific user on a given page . Returns an ArrayObject that contains Collection objects . |
50,271 | public function likes ( $ page = 1 , $ per_page = 10 , $ order_by = 'latest' ) { if ( ! isset ( $ this -> likes [ "{$page}-{$per_page}-{$order_by}" ] ) ) { $ likes = self :: get ( "/users/{$this->username}/likes" , [ 'query' => [ 'page' => $ page , 'per_page' => $ per_page , 'order_by' => $ order_by ] ] ) ; $ this -> l... | Retrieve all the photos liked by a specific user on a given page . Returns an ArrayObject that contains Photo object |
50,272 | public static function find ( $ id ) { $ curatedBatch = json_decode ( self :: get ( "/collections/curated/{$id}" ) -> getBody ( ) , true ) ; return new self ( $ curatedBatch ) ; } | Retrieve a specific curated batch |
50,273 | public static function all ( $ page = 1 , $ per_page = 10 ) { $ curatedBatches = self :: get ( "/collections/curated" , [ 'query' => [ 'page' => $ page , 'per_page' => $ per_page ] ] ) ; $ curatedBatchesArray = self :: getArray ( $ curatedBatches -> getBody ( ) , get_called_class ( ) ) ; return new ArrayObject ( $ cura... | Retrieve all curated batches for a given page |
50,274 | private static function getItem ( $ id ) { if ( ! isset ( self :: $ items [ $ id ] ) ) throw new \ Exception ( "Item $id not found" ) ; return self :: $ items [ $ id ] ; } | Get item by id |
50,275 | public static function clientException ( ResponseInterface $ response , $ data ) { return static :: fromResponse ( $ response , isset ( $ data [ 'message' ] ) ? $ data [ 'message' ] : json_encode ( $ data ) ) ; } | Creates client exception from response |
50,276 | public function trigger ( $ handler , Event $ event ) { if ( $ listener = $ this -> getListener ( $ handler ) ) { return call_user_func_array ( $ listener , [ $ event ] ) ; } } | trigger event . |
50,277 | public function addListener ( $ handler , callable $ callable ) { if ( ! class_exists ( $ handler ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invlaid Handler "%s"' , $ handler ) ) ; } if ( ! is_subclass_of ( $ handler , Event :: class ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The Handler "%s" ... | add listener . |
50,278 | public static function jsonEncode ( $ data , array $ context = [ ] ) { $ defaults = [ 'json_encode_options' => defined ( 'JSON_UNESCAPED_UNICODE' ) ? JSON_UNESCAPED_UNICODE : 0 , ] ; return ( new JsonEncoder ( ) ) -> encode ( $ data , 'json' , array_replace ( $ defaults , $ context ) ) ; } | json encode . |
50,279 | public static function jsonDecode ( $ data , array $ context = [ ] ) { $ defaults = [ 'json_decode_associative' => true , 'json_decode_recursion_depth' => 512 , 'json_decode_options' => 0 , ] ; return ( new JsonEncoder ( ) ) -> decode ( $ data , 'json' , array_replace ( $ defaults , $ context ) ) ; } | json decode . |
50,280 | public static function xmlEncode ( $ data , array $ context = [ ] ) { $ defaults = [ 'xml_root_node_name' => 'xml' , 'xml_format_output' => true , 'xml_version' => '1.0' , 'xml_encoding' => 'utf-8' , 'xml_standalone' => false , ] ; return ( new XmlEncoder ( ) ) -> encode ( $ data , 'xml' , array_replace ( $ defaults , ... | xml encode . |
50,281 | public function setResponse ( Entity $ entity ) { $ body = $ entity -> getBody ( ) ; $ body [ 'ToUserName' ] = $ this [ 'FromUserName' ] ; $ body [ 'FromUserName' ] = $ this [ 'ToUserName' ] ; $ body [ 'MsgType' ] = $ entity -> getType ( ) ; $ body [ 'CreateTime' ] = time ( ) ; $ response = new XmlResponse ( $ body ) ;... | response message entity . |
50,282 | public function handle ( EventListenerInterface $ listener ) { if ( ! $ listener -> getListeners ( ) ) { return ; } $ content = $ this -> request -> getContent ( ) ; try { $ options = Serializer :: parse ( $ content ) ; } catch ( \ InvalidArgumentException $ e ) { $ options = [ ] ; } foreach ( $ listener -> getListener... | handle event via request . |
50,283 | public function withSSLCert ( $ sslCert , $ sslKey ) { $ this -> sslCert = $ sslCert ; $ this -> sslKey = $ sslKey ; return $ this ; } | Request SSL Cert . |
50,284 | public function send ( $ asArray = true ) { $ options = [ ] ; if ( ! empty ( $ this -> query ) ) { $ options [ 'query' ] = $ this -> query ; } if ( ! empty ( $ this -> body ) ) { $ options [ 'body' ] = $ this -> body ; } if ( $ this -> sslCert && $ this -> sslKey ) { $ options [ 'cert' ] = $ this -> sslCert ; $ options... | Send Request . |
50,285 | public function findPagesByURL ( $ url ) { $ page = null ; $ page = $ this -> model -> where ( 'url' , $ url ) -> where ( 'is_published' , 1 ) -> where ( 'published_at' , '<=' , Carbon :: now ( config ( 'app.timezone' ) ) -> format ( 'Y-m-d H:i:s' ) ) -> first ( ) ; if ( $ page && app ( ) -> getLocale ( ) !== config ( ... | Find Pages by given URL . |
50,286 | public function revert ( $ id ) { $ archive = Archive :: find ( $ id ) ; $ model = app ( $ archive -> entity_type ) ; $ modelInstance = $ model -> find ( $ archive -> entity_id ) ; $ archiveData = ( array ) json_decode ( $ archive -> entity_data ) ; $ modelInstance -> fill ( $ archiveData ) ; $ modelInstance -> save ( ... | Rollback to a previous version of an entity a specific moment . |
50,287 | public function rollback ( $ entity , $ id ) { $ modelString = str_replace ( '_' , '\\' , $ entity ) ; if ( ! class_exists ( $ modelString ) ) { Cms :: notification ( 'Could not rollback Model not found' , 'warning' ) ; return redirect ( URL :: previous ( ) ) ; } $ model = app ( $ modelString ) ; $ modelInstance = $ mo... | Rollback to a previous version of an entity . |
50,288 | public function preview ( $ entity , $ id ) { $ modelString = 'Grafite\Cms\Models\\' . ucfirst ( $ entity ) ; if ( ! class_exists ( $ modelString ) ) { $ modelString = 'Grafite\Cms\Models\\' . ucfirst ( $ entity ) . 's' ; } $ model = new $ modelString ( ) ; $ modelInstance = $ model -> find ( $ id ) ; $ data = [ $ enti... | Preview content . |
50,289 | public function deleteHero ( $ entity , $ id ) { $ entity = app ( 'Grafite\Cms\Models\\' . ucfirst ( $ entity ) ) -> find ( $ id ) ; if ( app ( FileService :: class ) -> delete ( $ entity -> hero_image ) ) { $ entity -> update ( [ 'hero_image' => null , ] ) ; Cms :: notification ( 'Hero image deleted.' , 'success' ) ; ... | Delete the hero image |
50,290 | public function promotion ( $ slug ) { $ promotion = app ( PromotionRepository :: class ) -> getBySlug ( $ slug ) ; if ( $ promotion ) { if ( Gate :: allows ( 'cms' , Auth :: user ( ) ) ) { $ promotion -> details .= '<a href="' . url ( config ( 'cms.backend-route-prefix' , 'cms' ) . '/promotions/' . $ promotion -> id .... | Get an promotion . |
50,291 | public function images ( $ tag = null ) { $ images = [ ] ; if ( is_array ( $ tag ) ) { foreach ( $ tag as $ tagName ) { $ images = array_merge ( $ images , $ this -> imageRepo -> getImagesByTag ( $ tag ) -> get ( ) -> toArray ( ) ) ; } } elseif ( is_null ( $ tag ) ) { $ images = array_merge ( $ images , $ this -> image... | Get images . |
50,292 | public function store ( $ payload ) { $ payload [ 'question' ] = htmlentities ( $ payload [ 'question' ] ) ; $ payload [ 'is_published' ] = ( isset ( $ payload [ 'is_published' ] ) ) ? ( bool ) $ payload [ 'is_published' ] : 0 ; $ payload [ 'published_at' ] = ( isset ( $ payload [ 'published_at' ] ) && ! empty ( $ payl... | Stores FAQ into database . |
50,293 | public function update ( $ item , $ payload ) { $ payload [ 'question' ] = htmlentities ( $ payload [ 'question' ] ) ; if ( ! empty ( $ payload [ 'lang' ] ) && $ payload [ 'lang' ] !== config ( 'cms.default-language' , 'en' ) ) { return $ this -> translationRepo -> createOrUpdate ( $ item -> id , 'Grafite\Cms\Models\FA... | Updates FAQ into database . |
50,294 | public function update ( $ id , PromotionRequest $ request ) { $ promotion = $ this -> repository -> find ( $ id ) ; if ( empty ( $ promotion ) ) { Cms :: notification ( 'Promotions not found' , 'warning' ) ; return redirect ( route ( $ this -> routeBase . '.promotions.index' ) ) ; } $ promotion = $ this -> repository ... | Update the specified Promotions in storage . |
50,295 | public function boot ( ) { $ this -> publishes ( [ __DIR__ . '/PublishedAssets/Views/themes' => base_path ( 'resources/themes' ) , __DIR__ . '/PublishedAssets/Controllers' => app_path ( 'Http/Controllers/Cms' ) , __DIR__ . '/PublishedAssets/Middleware' => app_path ( 'Http/Middleware' ) , __DIR__ . '/PublishedAssets/Rou... | Alias the services in the boot . |
50,296 | public function all ( ) { $ query = $ this -> model ; if ( Schema :: hasColumn ( str_plural ( $ this -> modelName ) , 'is_published' ) ) { $ query = $ query -> where ( 'is_published' , true ) ; } if ( Schema :: hasColumn ( str_plural ( $ this -> modelName ) , 'published_at' ) ) { $ query = $ query -> where ( 'published... | Collect all items of a resource |
50,297 | public function search ( $ term ) { $ query = $ this -> model -> orderBy ( 'created_at' , 'desc' ) ; $ query -> where ( 'id' , 'LIKE' , '%' . $ input [ 'term' ] . '%' ) ; $ columns = Schema :: getColumnListing ( str_plural ( $ this -> modelName ) ) ; foreach ( $ columns as $ attribute ) { $ query -> orWhere ( $ attribu... | Search for the API Item |
50,298 | public function store ( $ payload ) { $ payload [ 'external' ] = isset ( $ payload [ 'external' ] ) ? $ payload [ 'external' ] : 0 ; if ( $ payload [ 'external' ] != 0 && empty ( $ payload [ 'external_url' ] ) ) { throw new Exception ( "Your link was missing a URL" , 1 ) ; } if ( ! isset ( $ payload [ 'page_id' ] ) ) {... | Stores Links into database . |
50,299 | public function update ( $ link , $ payload ) { $ payload [ 'external' ] = isset ( $ payload [ 'external' ] ) ? $ payload [ 'external' ] : 0 ; if ( ! empty ( $ payload [ 'lang' ] ) && $ payload [ 'lang' ] !== config ( 'cms.default-language' , 'en' ) ) { return $ this -> translationRepo -> createOrUpdate ( $ link -> id ... | Updates Links into database . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.