idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
50,200
private function ClearInstalledBundles ( ) { $ bundles = PathUtil :: Bundles ( ) ; $ sql = new Sql \ Builder ( $ this -> connection ) ; $ inList = $ sql -> InListFromValues ( $ bundles ) ; $ tbl = InstalledBundle :: Schema ( ) -> Table ( ) ; $ where = $ sql -> NotIn ( $ tbl -> Field ( 'Bundle' ) , $ inList ) ; Installe...
Clears installed bundles
50,201
private function InstallBundle ( $ bundle ) { $ manifest = ClassFinder :: Manifest ( $ bundle ) ; foreach ( $ manifest -> Dependencies ( ) as $ dependency ) { if ( ! $ this -> InstallDependency ( $ dependency ) ) { return false ; } } $ bundleInstaller = new BundleInstaller ( $ manifest , $ this -> connection , $ this -...
Installs a single bundle
50,202
private function InstallDependency ( BundleDependency $ dependency ) { $ bundle = $ dependency -> BundleName ( ) ; if ( array_key_exists ( $ bundle , $ this -> failedBundles ) ) { return false ; } $ installedVersion = $ this -> InstalledVersion ( $ bundle ) ; $ manifest = ClassFinder :: Manifest ( $ bundle ) ; if ( ! $...
Installs a dependency
50,203
protected function getModuleOutput ( $ module ) { $ console = $ this -> console ; $ head = sprintf ( "%s\n%s\n%s\n" , str_repeat ( '-' , $ console -> getWidth ( ) ) , 'Testing Module: ' . $ module , str_repeat ( '-' , $ console -> getWidth ( ) ) ) ; return $ console -> colorize ( $ head , ColorInterface :: BLUE ) ; }
Get module output
50,204
protected function renderTable ( $ data , $ cols , $ consoleWidth ) { $ result = '' ; $ padding = 2 ; if ( $ cols == 1 ) { foreach ( $ data as $ row ) { $ result .= $ row [ 0 ] . "\n" ; } return $ result ; } $ strWrapper = StringUtils :: getWrapper ( 'UTF-8' ) ; $ maxW = array ( ) ; for ( $ x = 1 ; $ x <= $ cols ; $ x ...
Render a text table containing the data provided that will fit inside console window s width .
50,205
public function copy ( ) { $ angle = new Angle ( ) ; $ angle -> radians = $ this -> radians ; $ angle -> sin = $ this -> sin ; $ angle -> cos = $ this -> cos ; $ angle -> tan = $ this -> tan ; return $ angle ; }
Returns a copy of the current angle .
50,206
public function set ( $ radians ) { $ this -> radians = $ radians ; $ this -> sin = sin ( $ radians ) ; $ this -> cos = cos ( $ radians ) ; $ this -> tan = tan ( $ radians ) ; return $ this ; }
Resets the angle in radians .
50,207
public function onFlush ( OnFlushEventArgs $ eventArgs ) { $ this -> eventQueue -> setOpened ( true ) ; $ uow = $ eventArgs -> getEntityManager ( ) -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityInsertions ( ) as $ entity ) { if ( $ entity instanceof ResourceInterface ) { $ this -> eventQueue -> scheduleIn...
On flush event handler .
50,208
public static function find ( array $ query ) { if ( isset ( $ query [ 'semester' ] ) && $ query [ 'semester' ] instanceof Semester ) { $ query [ 'semester' ] = $ query [ 'semester' ] -> daisyFormat ( ) ; } $ csis = Client :: get ( "courseSegment" , $ query ) ; return array_map ( function ( $ data ) { return new self (...
Retrieve an array of CourseSegmentInstance objects according to a search query .
50,209
protected function addUniqueRuleException ( array $ rules , $ id ) { foreach ( $ rules as $ key => & $ rule ) { if ( is_array ( $ rule ) ) { $ rule = $ this -> addUniqueRuleException ( $ rule , $ id ) ; continue ; } $ unique_pos = strpos ( $ rule , 'unique:' ) ; if ( $ unique_pos !== false ) { $ next_rule_pos = strpos ...
Add exception to any unique rules for given object id
50,210
public function newValidator ( array & $ params , array $ rules , $ clean = true ) { if ( ! empty ( $ params [ 'id' ] ) ) { $ rules = $ this -> addUniqueRuleException ( $ rules , $ params [ 'id' ] ) ; } if ( $ clean ) { $ params = $ this -> cleanParams ( $ params , $ rules ) ; } return ValidatorFacade :: make ( $ param...
Set new validator instance
50,211
private function getBody ( ) { if ( $ this -> body ) { return $ this -> body ; } elseif ( $ this -> files || $ this -> forceMultipart ) { return $ this -> body = $ this -> createMultipart ( ) ; } elseif ( $ this -> fields ) { return $ this -> body = $ this -> createUrlEncoded ( ) ; } else { return $ this -> body = Stre...
Return a stream object that is built from the POST fields and files .
50,212
public function generate ( $ till = self :: UNTIL_FRAGMENT ) { $ url = null !== $ this -> getScheme ( ) ? $ this -> getScheme ( ) . '://' : '' ; if ( $ till !== self :: UNTIL_SCHEME ) { $ url .= null !== $ this -> getUser ( ) ? $ this -> getUser ( ) . ':' : '' ; if ( $ till !== self :: UNTIL_USER ) { $ url .= null !== ...
Adds all the components of the url until the end or until the first parameter has been reached to generate a URL
50,213
private function pdoPrepare ( $ sql ) { try { $ pdoStatement = $ this -> getPdo ( ) -> prepare ( $ sql ) ; } catch ( \ PDOException $ e ) { throw new \ RuntimeException ( "Failed to prepare SQL query: {$sql} << {$e->getMessage()}" , 0 , $ e ) ; } return $ pdoStatement ; }
Prepares a PDO statement .
50,214
public function escapeAndQuote ( $ value ) { if ( null === $ value ) { $ pdoType = \ PDO :: PARAM_NULL ; } else { $ pdoType = \ PDO :: PARAM_STR ; } return $ this -> getPdo ( ) -> quote ( $ value , $ pdoType ) ; }
Escapes and quotes provided scalar value .
50,215
public function getPdo ( ) { if ( ! $ this -> pdo ) { $ this -> connect ( ) ; } $ this -> pdo -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; $ this -> pdo -> setAttribute ( \ PDO :: ATTR_DEFAULT_FETCH_MODE , \ PDO :: FETCH_ASSOC ) ; return $ this -> pdo ; }
Returns the wrapped PDO object .
50,216
private function connect ( ) { $ dsn = "{$this->credentials->getDriver()}:host={$this->credentials->getHost()}" ; try { $ pdo = new \ PDO ( $ dsn , $ this -> credentials -> getUsername ( ) , $ this -> credentials -> getPassword ( ) ) ; } catch ( \ PDOException $ e ) { throw new \ RuntimeException ( 'Failed to connect t...
Attempts to connect to database .
50,217
public function unsetSessionUser ( $ sessionKey = NULL ) { $ sessionKey = $ sessionKey ? : SessionUser :: DEFAULT_KEY_NAME ; $ user = Session :: getSessionDataBag ( ) -> get ( $ sessionKey ) ; if ( $ user ) { if ( ! $ user instanceof SessionUser ) { throw new UserException ( sprintf ( "Session key '%s' doesn't hold a S...
remove session user from session returns the removed session user
50,218
public function getSessionUser ( $ sessionKey = NULL ) { $ sessionKey = $ sessionKey ? : SessionUser :: DEFAULT_KEY_NAME ; $ sessionUser = Session :: getSessionDataBag ( ) -> get ( $ sessionKey ) ; if ( $ sessionUser instanceof SessionUser ) { return $ sessionUser ; } }
retrieve a stored session user stored under a session key returns stored value only when it is a SessionUser instance
50,219
public function elementsOverview ( array $ list , array $ options = [ ] ) { $ options = array_replace ( [ "includeNavigation" => true ] , $ options ) ; $ options [ "inElementsOverview" ] = true ; $ elements = array_map ( function ( $ reference ) { return new Element ( $ reference ) ; } , $ list ) ; return $ this -> app...
Renders a overview of the given elements
50,220
public function get ( $ key , $ default = null , $ package = null ) { if ( $ package ) { return $ this -> getForPackage ( $ package , $ key , $ default ) ; } return Arr :: get ( $ this -> mainConfiguration , $ key , $ default ) ; }
Return value stored under provided key
50,221
public function getForPackage ( $ package , $ key , $ default = null ) { if ( empty ( $ this -> packagesConfiguration [ $ package ] ) ) { return $ default ; } return Arr :: get ( $ this -> packagesConfiguration [ $ package ] , $ key , $ default ) ; }
Return value stored under provided key for given package
50,222
public function set ( $ key , $ value , $ package = null ) { if ( ! is_null ( $ package ) ) { $ this -> setForPackage ( $ package , $ key , $ value ) ; return $ this ; } $ mainConfiguration = $ this -> mainConfiguration ; Arr :: set ( $ mainConfiguration , $ key , $ value ) ; return $ this ; }
Store given value under given key
50,223
public function setForPackage ( $ package , $ key , $ value ) { $ packageConfiguration = empty ( $ this -> packagesConfiguration [ $ package ] ) ? array ( ) : $ this -> packagesConfiguration [ $ package ] ; Arr :: set ( $ packageConfiguration , $ key , $ value ) ; $ this -> packagesConfiguration [ $ package ] = $ packa...
Store given value under given key for given package
50,224
public function findFile ( $ filePath ) { if ( file_exists ( $ filePath ) ) { return $ filePath ; } foreach ( $ this -> supportedExtensions as $ extension ) { $ extendedFilePath = $ filePath . '.' . $ extension ; if ( file_exists ( $ extendedFilePath ) ) { return $ extendedFilePath ; } $ extendedFilePath = $ filePath ....
Tries to find existing file with supported extension
50,225
private function processFile ( $ filePath , $ group = null , $ baseDir = null ) { if ( is_null ( $ baseDir ) ) { $ baseDir = $ this -> baseDirectory ; } if ( ! is_string ( $ baseDir ) ) { $ baseDir = '' ; } if ( $ baseDir ) { $ baseDir = rtrim ( $ baseDir , '/' ) . '/' ; } $ content = $ this -> findAndParseFile ( $ bas...
Processing the file optionally putting result under group
50,226
private function extractFileNameBase ( $ filePath ) { $ directories = explode ( '/' , $ filePath ) ; $ fileName = array_pop ( $ directories ) ; $ fileNameParts = explode ( '.' , $ fileName ) ; if ( count ( $ fileNameParts ) > 1 ) { $ extension = array_pop ( $ fileNameParts ) ; } $ result = implode ( '.' , $ fileNamePar...
Return file name base without directories and without extension
50,227
private function assembleEnvironmentFilePath ( $ filePath , $ environment = true ) { if ( true === $ environment ) { $ environment = $ this -> environmentInstance -> getEnvironment ( ) ; } $ directories = explode ( '/' , $ filePath ) ; $ fileName = array_pop ( $ directories ) ; $ fileNameWithoutExtension = $ this -> ex...
Assemble path to configuration file with environment taken into account
50,228
protected function getDesiredImageQuality ( $ ext , $ format ) { switch ( $ ext ) { case 'jpeg' : case 'jpg' : $ qualityConfig = $ this -> jpegQuality ; break ; case 'png' : $ qualityConfig = $ this -> pngQuality ; break ; default : $ qualityConfig = null ; } if ( empty ( $ qualityConfig ) ) { return null ; } if ( is_a...
Figure out image quality .
50,229
public function index ( ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_LIST ) ; $ redirects = Redirect :: query ( ) -> paginate ( 50 ) ; $ this -> setTitle ( $ title = trans ( 'seo::redirects.titles.redirections-list' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ this -> view ( 'admin.redirects.index' ,...
Get the index page .
50,230
public function create ( ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_CREATE ) ; $ statuses = RedirectStatuses :: all ( ) ; $ this -> setTitle ( $ title = trans ( 'seo::redirects.titles.create-redirection' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ this -> view ( 'admin.redirects.create' , compact ...
Get the create form .
50,231
public function store ( CreateRedirectRequest $ request ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_CREATE ) ; $ redirect = Redirect :: createRedirect ( $ request -> getValidatedData ( ) ) ; $ this -> transNotification ( 'created' , [ ] , $ redirect -> toArray ( ) ) ; return redirect ( ) -> route ( 'admin::...
Store the new redirect .
50,232
public function show ( Redirect $ redirect ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_SHOW ) ; $ this -> setTitle ( $ title = trans ( 'seo::redirects.titles.redirection-details' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ this -> view ( 'admin.redirects.show' , compact ( 'redirect' ) ) ; }
Show the redirect details page .
50,233
public function edit ( Redirect $ redirect ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_UPDATE ) ; $ statuses = RedirectStatuses :: all ( ) ; $ this -> setTitle ( $ title = trans ( 'seo::redirects.titles.edit-redirection' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ this -> view ( 'admin.redirects.ed...
Get the edit page .
50,234
public function update ( Redirect $ redirect , UpdateRedirectRequest $ request ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_UPDATE ) ; $ redirect -> update ( $ request -> getValidatedData ( ) ) ; $ this -> transNotification ( 'updated' , [ ] , $ redirect -> toArray ( ) ) ; return redirect ( ) -> route ( 'adm...
Update the redirect .
50,235
public function delete ( Redirect $ redirect ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_DELETE ) ; $ redirect -> delete ( ) ; return $ this -> jsonResponseSuccess ( [ 'message' => $ this -> transNotification ( 'deleted' , [ ] , $ redirect -> toArray ( ) ) ] ) ; }
Delete a redirect record .
50,236
protected function transNotification ( $ action , array $ replace = [ ] , array $ context = [ ] ) { $ title = trans ( "seo::redirects.messages.{$action}.title" ) ; $ message = trans ( "seo::redirects.messages.{$action}.message" , $ replace ) ; Log :: info ( $ message , $ context ) ; $ this -> notifySuccess ( $ message ...
Notify with translation .
50,237
public static function generate ( $ contact , $ options = array ( ) ) { if ( ! isset ( Lightrail :: $ apiKey ) || empty ( Lightrail :: $ apiKey ) ) { throw new Exceptions \ BadParameterException ( "Lightrail.apiKey is empty or not set." ) ; } if ( ! isset ( Lightrail :: $ sharedSecret ) || empty ( Lightrail :: $ shared...
Generate a shopper token that can be used to make Lightrail calls restricted to that particular shopper . The shopper can be defined by the contactId userSuppliedId or shopperId .
50,238
private function prepareServices ( ) { $ services = new Container ; $ services -> set ( Router :: class , new Router , true ) ; $ services -> set ( Dispatcher :: class , new Dispatcher , true ) ; $ services -> set ( PackageManager :: class , new PackageManager , true ) ; $ services -> set ( EventManager :: class , new ...
Prepares services required by Tonis . We ll put them in the DIC so that they re available to other factories if necessary .
50,239
public function format ( Address $ address ) { $ fields = [ 'p-street-address' => $ address -> getStreet ( ) , 'p-extended-address' => $ address -> getExtended ( ) , 'p-post-office-box' => $ address -> getPobox ( ) , 'p-locality' => $ address -> getLocality ( ) , 'p-region' => $ address -> getRegion ( ) , 'p-postal-cod...
Formats an address .
50,240
function addMilliseconds ( $ milliseconds ) { if ( ! is_int ( $ milliseconds ) ) return false ; if ( $ milliseconds == 0 ) return true ; $ millisecond = $ this -> millisecond + $ milliseconds ; $ milliseconds = $ millisecond % 1000 ; if ( $ milliseconds < 0 ) { $ milliseconds += 1000 ; } $ seconds = ( int ) ( ( $ milli...
public instance methods
50,241
function dayOfWeek ( ) { $ num = func_num_args ( ) ; if ( $ num == 3 ) { $ args = func_get_args ( ) ; $ y = $ args [ 0 ] ; $ m = $ args [ 1 ] ; $ d = $ args [ 2 ] ; } else { $ y = $ this -> year ; $ m = $ this -> month ; $ d = $ this -> day ; } $ d += $ m < 3 ? $ y -- : $ y - 2 ; return ( ( int ) ( 23 * $ m / 9 ) + $ d...
public instance & static methods
50,242
protected function callFactoryMethod ( $ typeName , $ factory , $ methodName , array $ resolvers = NULL , InjectionPointInterface $ point = NULL ) { $ ref = new \ ReflectionMethod ( get_class ( $ factory ) , $ methodName ) ; foreach ( $ ref -> getParameters ( ) as $ param ) { if ( Configuration :: class === $ this -> g...
Create an object instance by calling a factory method on an object .
50,243
protected function reviveMarker ( $ typeName , array $ params = NULL ) { static $ refs = [ ] ; if ( empty ( $ refs [ $ typeName ] ) ) { $ refs [ $ typeName ] = new \ ReflectionClass ( $ typeName ) ; } $ marker = $ refs [ $ typeName ] -> newInstanceWithoutConstructor ( ) ; foreach ( ( array ) $ params as $ k => $ v ) { ...
Revives a marker instance by creating it without constructor invocation .
50,244
public function createFromImportedData ( $ name , $ data ) { if ( ! is_array ( $ data ) ) { return new GroupParameter ( $ name , [ $ data ] ) ; } elseif ( ! $ this -> isAssociativeArray ( $ data ) ) { return new GroupParameter ( $ name , $ data ) ; } $ parameter = new GroupParameter ( $ name ) ; foreach ( $ data as $ c...
Create GroupParameter instance from imported data .
50,245
public function createRequiredFromTemplates ( $ templates ) { $ parameters = [ ] ; if ( ! empty ( $ templates ) ) { foreach ( $ templates as $ template ) { if ( $ template -> required ) { $ parameters [ ] = $ this -> createFromTemplate ( $ template ) ; } } } return $ parameters ; }
Create GroupParameter instances from all given required templates .
50,246
public function createFromTemplate ( $ template ) { $ parameter = new GroupParameter ( ) ; $ parameter -> setName ( $ template -> name ) ; $ parameter -> setTemplate ( $ template ) ; if ( $ template -> type == GroupParameterType :: HASHTABLE && isset ( $ template -> entries ) ) { $ parameter -> setChildren ( $ this -> ...
Create GroupParameter instance from given template .
50,247
protected function setRootDir ( $ rootDir ) { if ( ! is_string ( $ rootDir ) || ! is_dir ( $ rootDir ) || ! is_readable ( $ rootDir ) ) { throw new InvalidArgumentException ( Message :: get ( Message :: CONFIG_DIR_INVALID , $ rootDir ) , Message :: CONFIG_DIR_INVALID ) ; } $ this -> root_dir = rtrim ( $ rootDir , '/\\'...
Set root directory
50,248
public function addToken ( $ token ) { if ( ! in_array ( $ token , $ this -> tokens ) ) { $ this -> tokens [ ] = $ token ; } return $ this ; }
Add a token device .
50,249
function TopMost ( ) { $ sql = Access :: SqlBuilder ( ) ; $ tbl = PageContent :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tbl -> Field ( 'Page' ) , $ sql -> Value ( $ this -> page -> GetID ( ) ) ) -> And_ ( $ sql -> Equals ( $ tbl -> Field ( 'Area' ) , $ sql -> Value ( $ this -> area -> GetID ( ) ) ) ) -...
Returns the root and first content element in a page and area
50,250
public function setCredentials ( $ credentials ) { if ( function_exists ( 'env' ) ) { $ host = env ( 'DB_HOST' ) ; $ dbname = env ( 'DB_DATABASE' ) ; $ username = env ( 'DB_USERNAME' ) ; $ password = env ( 'DB_PASSWORD' ) ; } else { $ host = $ credentials [ 'host' ] ; $ dbname = $ credentials [ 'dbname' ] ; $ username ...
Set the credentials to connect with mysql
50,251
public function setTitles ( $ titles ) { $ titles = is_array ( $ titles ) ? $ titles : func_get_args ( ) ; if ( count ( $ titles ) > 0 ) { $ this -> titles = '"' . implode ( '", "' , $ titles ) . '"' ; } }
Set the titles for the csv
50,252
public function setColumns ( $ columns ) { $ columns = is_array ( $ columns ) ? $ columns : func_get_args ( ) ; if ( count ( $ columns ) > 0 ) { $ this -> columns = implode ( ', ' , $ columns ) ; } }
Set the columns to export
50,253
public function join ( $ table , $ key_one , $ operator , $ key_two = null ) { if ( is_null ( $ key_two ) ) { $ key_two = $ operator ; $ operator = '=' ; } $ this -> joins .= " JOIN {$table} ON {$key_one} {$operator} {$key_two} " ; return $ this ; }
Add a join to the query
50,254
public function where ( $ field , $ value , $ not = false ) { $ reserverd_word = $ this -> with_where ? 'AND' : 'WHERE' ; $ operator = $ not ? '!=' : '=' ; $ this -> query .= "{$reserverd_word} {$field} {$operator} '{$value}'" ; $ this -> with_where = true ; return $ this ; }
Add a condition to the initial query
50,255
public function execute ( ) { $ this -> columns = $ this -> columns ? : '*' ; $ query = "SELECT {$this->columns} FROM $this->table " ; if ( $ this -> joins ) { $ query .= $ this -> joins ; } $ query .= $ this -> query ; if ( is_null ( $ this -> filename ) ) { $ this -> filename = '/tmp/file.csv' ; } $ query .= " ...
Function for generate csv and return the filename
50,256
public function dispatch ( Request $ request ) { $ resourceParts = explode ( '/' , $ request -> getResource ( ) ) ; $ resourceName = $ resourceParts [ 0 ] ; $ subResourceName = false ; if ( count ( $ resourceParts ) > 1 ) { $ subResourceName = $ resourceParts [ 1 ] ; } try { $ resourceMetadata = $ this -> resourceMetad...
Processes a REST request returning a Response object .
50,257
protected function registerListeners ( $ service ) { $ serviceMetadata = $ this -> serviceMetadataFactory -> getMetadataFor ( get_class ( $ service ) ) ; foreach ( $ serviceMetadata -> getAllListeners ( ) as $ event => $ listeners ) { foreach ( $ listeners as $ listener ) { $ this -> eventManager -> addListener ( $ eve...
Registers listeners for the supplied service instance . Listeners are obtained from ServiceMetadata for the class of the instance .
50,258
private function getUsersPermissions ( ) { return [ [ 'name' => 'Users - List all users' , 'description' => 'Allow to list all users.' , 'slug' => UsersPolicy :: PERMISSION_LIST , ] , [ 'name' => 'Users - View a user' , 'description' => 'Allow to view a user\'s details.' , 'slug' => UsersPolicy :: PERMISSION_SHOW , ] ,...
Get user s permissions seeds .
50,259
private function getRolesPermissions ( ) { return [ [ 'name' => 'Roles - List all roles' , 'description' => 'Allow to list all roles.' , 'slug' => RolesPolicy :: PERMISSION_LIST , ] , [ 'name' => 'Roles - View a role' , 'description' => 'Allow to view the role\'s details.' , 'slug' => RolesPolicy :: PERMISSION_SHOW , ]...
Get role s permissions seeds .
50,260
public static function getRouteByName ( string $ name ) : Route { foreach ( static :: $ routes as $ routes ) { foreach ( $ routes as $ route ) { if ( $ route -> getName ( ) === $ name ) { return $ route ; } } } return null ; }
Tries to fetch a route by name returns null if it doesn t exist
50,261
public function getAlias ( $ abstract ) { if ( ! isset ( $ this -> aliases [ $ abstract ] ) ) { return $ abstract ; } if ( $ this -> aliases [ $ abstract ] === $ abstract ) { throw new LogicException ( "[{$abstract}] is aliased to itself." ) ; } return $ this -> getAlias ( $ this -> aliases [ $ abstract ] ) ; }
Get the alias for an abstract if available .
50,262
private function initServer ( ) { $ this -> http = new Object ( ) ; $ this -> server = new Object ( ) ; foreach ( $ _SERVER as $ key => $ val ) { $ key = str_replace ( 'request_' , '' , strtolower ( $ key ) ) ; if ( substr ( $ key , 0 , 5 ) === 'http_' ) { $ this -> http -> { Util :: _toCamel ( substr ( $ key , 5 ) ) }...
initializes server values
50,263
public function isAjax ( ) { return ( isset ( $ this -> http -> xRequestedWith ) && $ this -> http -> xRequestedWith = 'XMLHttpRequest' || isset ( $ this -> http -> requestedWith ) && $ this -> http -> requestedWith = 'XMLHttpRequest' ) ; }
Checks if the request is an ajax
50,264
public static function getInstance ( $ id = 'default' ) { if ( ! isset ( static :: $ instances [ $ id ] ) ) { static :: $ instances [ $ id ] = new self ( ) ; } return static :: $ instances [ $ id ] ; }
If identifier exists it will be return instance if not new instance will create .
50,265
public function path ( $ path ) { $ path = strtolower ( trim ( $ path ) ) ; $ first = substr ( $ path , 0 , 1 ) ; if ( $ first == '@' && isset ( $ this -> aliases [ $ path ] ) ) { $ path = $ this -> aliases [ $ path ] ; } elseif ( $ first == '/' ) { $ path = preg_replace ( '/\\//' , $ this -> root ( ) . '/' , $ path , ...
Translate path alias into a actual path or build path . Return absolute path .
50,266
public static function toCamelcase ( $ string , $ capitalizeFirstCharacter = false ) { if ( false === is_string ( $ string ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ string ) ) , E_USER_ERROR ) ; } if ( false === is_bool ( $ capit...
Converts string underscores to camelCase
50,267
public static function toSnakecase ( $ string ) { if ( false === is_string ( $ string ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ string ) ) , E_USER_ERROR ) ; } return ltrim ( strtolower ( preg_replace ( '/[A-Z]([A-Z](?![a-z]))*/'...
Converts string camelcase to snakecase
50,268
protected function resolveValue ( $ name , & $ source = null , $ sanitize = true , $ array = false ) { $ result = $ array ? array ( ) : null ; if ( empty ( $ name ) ) { $ result = $ source ; } elseif ( isset ( $ source [ $ name ] ) ) { $ result = $ source [ $ name ] ; } if ( ! $ sanitize ) { return $ result ; } if ( is...
Resolve a value from the given collection .
50,269
public function setRequestOrder ( $ requestOrder ) { if ( ! is_string ( $ requestOrder ) ) { throw new InvalidArgumentException ( 'Expected requestOrder to be a string' ) ; } if ( empty ( $ requestOrder ) ) { throw new InvalidArgumentException ( 'An empty string is not a valid requestOrder value' ) ; } $ this -> reques...
Set the request order .
50,270
public function value ( $ name ) { if ( empty ( $ this -> requestOrder ) ) { throw new RuntimeException ( 'Unable to determine the request order' ) ; } $ result = null ; foreach ( $ this -> requestOrder as $ token ) { $ method = $ this -> resolveRequestOrderMethod ( $ token ) ; if ( empty ( $ method ) ) { continue ; } ...
Retrieve a value using the configured request order
50,271
public function files ( $ name , $ sanitize = true ) { return $ this -> resolveValue ( $ name , $ _FILES , $ sanitize , true ) ; }
Retrieve the the date associated with a file upload
50,272
public function put ( $ source = 'php://input' , $ sanitize = true ) { if ( is_null ( $ source ) ) { $ source = 'php://input' ; } $ source = @ fopen ( $ source , 'r' ) ; if ( ! is_resource ( $ source ) ) { throw new InvalidArgumentException ( 'Expected parameter 1 to be an open-able resource' ) ; } $ data = null ; whil...
Retrieve date from the input stream
50,273
public function domain ( $ maxLevels = 0 ) { $ parts = explode ( '.' , $ this -> uri ( ) -> getHost ( ) ) ; return implode ( '.' , array_slice ( $ parts , - 1 * $ maxLevels ) ) ; }
Retrieve the current domain
50,274
public function protocol ( $ raw = false ) { if ( $ raw ) { return $ this -> server ( 'SERVER_PROTOCOL' ) ; } $ parts = explode ( '/' , $ this -> server ( 'SERVER_PROTOCOL' ) ) ; return strtolower ( array_shift ( $ parts ) ) . $ this -> server ( 'HTTPS' ) === 'on' ? 's' : '' ; }
Retrieve the requests protocol
50,275
public static function determineFileUploadMaxSize ( ) { static $ maxSize = - 1 ; if ( $ maxSize < 0 ) { $ maxSize = self :: parsePhpIniSize ( ini_get ( 'post_max_size' ) ) ; $ upload_max = self :: parsePhpIniSize ( ini_get ( 'upload_max_filesize' ) ) ; if ( $ upload_max > 0 && $ upload_max < $ maxSize ) { $ maxSize = $...
Returns a file size limit in bytes based on the PHP upload_max_filesize and post_max_size
50,276
public function getView ( ) { if ( is_null ( $ this -> prefix ) ) { return $ this -> getBaseView ( ) ; } $ view = $ this -> concatViewAndPrefix ( $ this -> prefix , $ this -> view ) ; $ prefixes = clone $ this -> prefixes ; $ this -> attempted ( $ view ) ; while ( ! view ( ) -> exists ( $ view ) ) { if ( is_null ( $ th...
Find the most reasonable view available .
50,277
protected function parseController ( $ class ) { $ controller = new ReflectionClass ( $ class ) ; $ this -> fullController = $ controller -> name ; $ class = $ controller -> getShortName ( ) ; $ this -> controller = strtolower ( str_replace ( 'Controller' , '' , $ class ) ) ; }
Get a properly formatted controller name .
50,278
protected function parseAction ( $ action ) { if ( $ action === $ this -> fullController ) { return $ this -> action = null ; } $ this -> action = strtolower ( preg_replace ( [ '/^get/' , '/^post/' , '/^put/' , '/^patch/' , '/^delete/' ] , '' , $ action ) ) ; }
Get a properly formatted action name .
50,279
protected function getPrefixes ( ) { $ router = app ( \ Illuminate \ Routing \ Router :: class ) ; $ this -> prefixes = collect ( explode ( '/' , $ router -> getCurrentRoute ( ) -> getPrefix ( ) ) ) ; $ this -> prefixes = $ this -> removeControllerFromPrefixes ( $ this -> prefixes ) -> filter ( ) ; if ( $ this -> prefi...
Search for any prefixes attached to this route .
50,280
protected function setView ( ) { $ views = [ $ this -> controller , $ this -> action , ] ; $ this -> view = implode ( '.' , array_filter ( $ views ) ) ; }
Combine the controller and action to create a proper view string .
50,281
private function getBaseView ( ) { $ this -> attempted ( $ this -> view ) ; return view ( ) -> exists ( $ this -> view ) ? $ this -> view : null ; }
Return the base view if it exists .
50,282
public function checkConfig ( ) { $ views = [ $ this -> fullController , $ this -> action , ] ; $ this -> configIndex = implode ( '.' , array_filter ( $ views ) ) ; return array_get ( config ( 'view-routing' ) , $ this -> configIndex ) ; }
Check the view routing config for the controller and method .
50,283
public static function sanitizeOutput ( $ buffer ) { if ( ! isset ( $ _GET [ 'unsanitized' ] ) ) { $ search = array ( '/\>[^\S ]+/s' , '/[^\S ]+\</s' , '/(\s)+/s' , '/<!--(.|\s)*? ) ; $ replace = array ( '>' , '<' , '\\1' , '' ) ; $ buffer = preg_replace ( $ search , $ replace , $ buffer ) ; return $ buffer ; } return ...
Minify the html for the outputbuffer
50,284
public function resolver ( $ name = null ) { if ( null === $ this -> __templateResolver ) { $ this -> setResolver ( new TemplatePathStack ( ) ) ; } if ( null !== $ name ) { $ viewPath = $ this -> __templateResolver -> resolve ( $ name , $ this ) ; return $ this -> __templateResolver -> resolve ( $ name , $ this ) ; } r...
Retrieve template name or template resolver
50,285
public function setVars ( $ variables ) { if ( ! is_array ( $ variables ) && ! $ variables instanceof ArrayAccess ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Expected array or ArrayAccess object; received "%s"' , ( is_object ( $ variables ) ? get_class ( $ variables ) : gettype ( $ variables ) ) ) )...
Set variable storage
50,286
public function vars ( $ key = null ) { if ( null === $ this -> __vars ) { $ this -> setVars ( new Variables ( ) ) ; } if ( null === $ key ) { return $ this -> __vars ; } return $ this -> __vars [ $ key ] ; }
Get a single variable or all variables
50,287
public function get ( $ key ) { if ( null === $ this -> __vars ) { $ this -> setVars ( new Variables ( ) ) ; } return $ this -> __vars [ $ key ] ; }
Get a single variable
50,288
public static function factory ( $ config = array ( ) ) { $ default = array ( 'base_url' => 'https://addons.mozilla.org/nl/firefox/addon/' , 'debug' => false ) ; $ required = array ( 'base_url' , 'app_name' ) ; $ config = Collection :: fromConfig ( $ config , $ default , $ required ) ; $ client = new self ( $ config ->...
Factory method to create a new MozillaAddonsClient
50,289
public static function insert ( $ name , $ callback , $ once = false ) { if ( static :: bound ( $ name ) ) { array_unshift ( static :: $ events [ $ name ] , [ $ once ? 'once' : 'always' => $ callback ] ) ; } else { static :: bind ( $ name , $ callback , $ once ) ; } }
Identical to the append method except the event handler is added to the start of the queue .
50,290
public static function fire ( $ name , $ data = [ ] , $ stop = false ) { if ( static :: bound ( $ name ) ) { static :: $ fired [ $ name ] = true ; foreach ( static :: $ events [ $ name ] as $ key => $ value ) { list ( $ type , $ callback ) = each ( $ value ) ; if ( is_string ( $ callback ) ) { $ callback = [ $ instance...
Trigger all callback functions for an event .
50,291
protected function setDefaultConnectionAttributes ( ) { $ config = Application :: getInstance ( ) -> getConfig ( ) ; $ options = [ \ PDO :: ATTR_ERRMODE => \ PDO :: ERRMODE_EXCEPTION , \ PDO :: ATTR_DEFAULT_FETCH_MODE => \ PDO :: FETCH_ASSOC , \ PDO :: ATTR_STRINGIFY_FETCHES => false ] ; if ( ! isset ( $ config -> keep...
set initial attributes for database connection
50,292
public function current ( ) { return isset ( $ this -> rows [ $ this -> rowsCounter ] ) ? $ this -> rows [ $ this -> rowsCounter ] : false ; }
This method return current row
50,293
private function appendPage ( ) { $ result = $ this -> executeNextSdkCommand ( ) ; $ iterator = $ this -> commands -> parseResult ( $ result , $ this -> hydrationMode , $ this -> refresh , $ this -> readOnly , $ this -> primers ) ; $ this -> getInnerIterator ( ) -> append ( $ iterator ) ; if ( $ result instanceof SdkRe...
Get a result page and populate the inner iterator .
50,294
public function setOptions ( $ options = [ ] ) { if ( false === is_array ( $ options ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type array, "%s" given' , __METHOD__ , gettype ( $ options ) ) , E_USER_ERROR ) ; } $ this -> options = array_merge ( $ this -> options , $ options ) ; }
Set debug options
50,295
private function action ( ) { $ options = ( object ) $ this -> options ; if ( true === $ options -> write ) { $ this -> writeToFile ( ) ; } if ( true == $ options -> display ) { return $ this -> displayError ( ) ; } exit ( ) ; }
Determines what to do with the error
50,296
private function writeToFile ( ) { $ logger = $ this -> getLogger ( ) ; $ logger -> setDirectory ( Path :: get ( 'log-error' ) ) ; $ error = $ this -> error -> toJson ( $ this -> options [ 'types' ] ) ; if ( false === $ error ) { $ this -> error -> setContext ( null ) ; $ this -> error -> setBacktrace ( null ) ; } $ er...
Writes current error to log file
50,297
private function displayError ( ) { if ( count ( $ this -> options [ 'ip' ] ) === 0 || true === in_array ( Request :: getIp ( ) , $ this -> options [ 'ip' ] ) ) { $ error = [ 'type' => $ this -> error -> getType ( ) , 'text' => $ this -> error -> getMessage ( ) , 'file' => $ this -> error -> getFile ( ) , 'line' => $ t...
Prints the error to client
50,298
private function formatBacktrace ( ) { $ backtrace = $ this -> error -> getBacktrace ( ) ; if ( null !== $ backtrace ) { array_shift ( $ backtrace ) ; array_shift ( $ backtrace ) ; foreach ( $ backtrace as $ index => $ stack ) { foreach ( [ 'type' , 'args' ] as $ type ) { if ( true === isset ( $ backtrace [ $ index ] [...
Formats the backtrace
50,299
public function stylesheet ( $ file ) { $ dirtypes = [ 'css' , 'stylesheets' , 'styles' ] ; $ asset = '' ; if ( $ this -> _generator -> isValidUrl ( $ file ) ) { $ asset = $ file ; } else { foreach ( $ dirtypes as $ dir ) { $ ext = substr ( $ file , strrpos ( $ file , '.' ) + 1 ) ; $ file = $ file . ( ( $ ext != 'css' ...
Returns a stylesheet HTML tag with given filename .