idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
8,300
private function getReflection ( string $ className ) : \ ReflectionClass { if ( empty ( $ this -> reflectionContainer [ $ className ] ) ) { $ this -> reflectionContainer [ $ className ] = new \ ReflectionClass ( $ className ) ; } return $ this -> reflectionContainer [ $ className ] ; }
Retrieve reflection .
8,301
public function getEntry ( $ language , $ entryId ) { if ( isset ( $ this -> entries [ $ language ] ) && isset ( $ this -> entries [ $ language ] [ $ entryId ] ) ) { return $ this -> entries [ $ language ] [ $ entryId ] ; } return null ; }
Get the translatable entry
8,302
public function setEntry ( $ language , $ entryId , $ entryValue ) { $ language = ( string ) $ language ; $ entryId = ( string ) $ entryId ; $ entryValue = ( string ) $ entryValue ; if ( ! isset ( $ this -> entries [ $ language ] ) && $ entryValue ) { $ this -> entries [ $ language ] = array ( ) ; } if ( $ entryValue )...
Set the translatable entry for the specific language
8,303
public function removeEntry ( $ entryId , $ language = null ) { $ entryId = ( string ) $ entryId ; foreach ( $ this -> entries as $ languageKey => $ entries ) { if ( $ language && $ language !== $ languageKey ) { continue ; } if ( isset ( $ this -> entries [ $ languageKey ] [ $ entryId ] ) ) { unset ( $ this -> entries...
Remove entries of the given id
8,304
public function removeLanguage ( $ language ) { $ language = ( string ) $ language ; if ( isset ( $ this -> entries [ $ language ] ) ) { unset ( $ this -> entries [ $ language ] ) ; } return $ this ; }
Remove entries of the given language
8,305
public function render ( \ DOMDocument $ domDocument ) { $ domElement = $ domDocument -> createElement ( "dico" ) ; foreach ( $ this -> entries as $ language => $ entries ) { $ languageElement = $ domDocument -> createElement ( "language" ) ; $ languageElement -> setAttribute ( "id" , $ language ) ; foreach ( $ entries...
Render the Dico
8,306
public static function create ( $ host , $ port , $ password ) { $ factory = new \ Socket \ Raw \ Factory ( ) ; $ socket = $ factory -> createClient ( sprintf ( '%s:%s' , $ host , $ port ) ) ; return new \ gries \ Rcon \ Connection ( $ socket , $ password ) ; }
Create a new RconConnection
8,307
function getLoginURL ( $ scope = null , $ redirectURI = null ) { $ redirectURI = $ redirectURI ? : $ this -> getCurrentURI ( ) ; self :: $ persistance -> setVariable ( 'redirect_uri' , $ redirectURI ) ; return $ this -> getAuthorizationURL ( $ redirectURI , $ scope ) ; }
When a user is not authentified you need to create a link to the URL returned by this method .
8,308
function getLogoutURL ( $ redirectURI = null ) { $ redirectURI = $ redirectURI ? : $ this -> getCurrentURI ( ) ; return $ this -> logoutURL . '?' . http_build_query ( array ( 'redirect_uri' => $ redirectURI ) , '' , '&' ) ; }
If you want to place a logout button you can use this link to log the user out of the player page too . Don t forget to empty your sessions .
8,309
protected function getAccessToken ( ) { $ token = self :: $ persistance -> getVariable ( 'token' ) ; if ( ! $ this -> isAccessTokenExpired ( $ token ) ) { return $ token -> access_token ; } else if ( $ token !== null && $ token -> refresh_token !== null ) { $ token = $ this -> getTokenFromRefreshToken ( $ token -> refr...
Tries to get an access token . If one is found in the session it returns it . If a code is found in the request it tries to exchange it for an access token on the OAuth2 Token Endpoint Else it returns false
8,310
public function all ( OutputInterface $ output , array $ response ) { $ this -> printTable ( $ output , [ 'Key' , 'Name' , 'Type' , 'Public' , 'Dependencies' , 'Outdated' , 'Updated At' , 'Bad Licenses' , 'Unknown Licenses' ] , [ 'ids' , 'name' , 'project_type' , 'public' , 'dep_number' , 'out_number' , 'updated_at' , ...
output for projects API .
8,311
public function licenses ( OutputInterface $ output , array $ response ) { $ table = $ this -> createTable ( $ output ) ; $ table -> setHeaders ( [ 'license' , 'name' ] ) ; foreach ( $ response [ 'licenses' ] as $ license => $ projects ) { foreach ( $ projects as $ project ) { $ name = $ license === 'unknown' ? '<error...
output for licenses API .
8,312
protected function executeInTransaction ( string $ method ) : void { try { $ this -> database -> beginTransaction ( ) ; $ this -> { $ method } ( ) ; $ this -> database -> commit ( ) ; } catch ( Exception $ exception ) { $ this -> database -> rollBack ( ) ; $ this -> handleException ( $ exception ) ; } }
Execute the migration command inside a transaction layer .
8,313
public function getElement ( $ using , $ value ) { try { $ results = $ this -> curl ( 'POST' , '/element' , array ( 'using' => $ using , 'value' => $ value ) ) ; } catch ( E5xx_NoSuchElementWebDriverError $ e ) { throw new E5xx_NoSuchElementWebDriverError ( 500 , sprintf ( 'Element not found with %s, %s' , $ using , $ ...
retrieve an element from the currently loaded page
8,314
public function getElements ( $ using , $ value ) { try { $ results = $ this -> curl ( 'POST' , '/elements' , array ( 'using' => $ using , 'value' => $ value ) ) ; } catch ( E5xx_NoSuchElementWebDriverError $ e ) { throw new E5xx_NoSuchElementWebDriverError ( sprintf ( 'Element not found with %s, %s' , $ using , $ valu...
Find all occurances of an element on the current page
8,315
protected function newWebDriverElement ( $ value ) { if ( ! array_key_exists ( 'ELEMENT' , ( array ) $ value ) ) { return null ; } return new WebDriverElement ( $ this -> getElementPath ( $ value [ 'ELEMENT' ] ) , $ value [ 'ELEMENT' ] ) ; }
helper method to wrap an element inside the WebDriverElement object
8,316
public function schema ( $ key = null , $ value = null ) { $ numArgs = func_num_args ( ) ; if ( 0 === $ numArgs ) { return $ this -> schema ; } elseif ( 1 === $ numArgs ) { if ( is_array ( $ key ) ) { $ this -> schema = new NObject ( $ key ) ; } elseif ( $ this -> schema -> offsetExists ( $ key ) ) { return $ this -> s...
Getter and setter of collection schema . If there is no argument specified the method will set and override schema . If argument specified method will act as getter to specific field schema .
8,317
public function prepare ( $ key , $ value , $ schema = null ) { if ( is_null ( $ schema ) ) { $ schema = $ this -> schema ( $ key ) ; if ( is_null ( $ schema ) ) { return $ value ; } } return $ schema -> prepare ( $ value ) ; }
Prepare data value for specific field name
8,318
public function attach ( $ document ) { if ( isset ( $ this -> connection ) ) { $ document = $ this -> connection -> unmarshall ( $ document ) ; } $ document = new NObject ( $ document ) ; $ this -> applyHook ( 'attaching' , $ document ) ; if ( isset ( $ this -> options [ 'model' ] ) ) { $ Model = $ this -> options [ '...
Attach document to Norm system as model .
8,319
public function find ( $ criteria = array ( ) ) { if ( ! is_array ( $ criteria ) ) { $ criteria = array ( '$id' => $ criteria , ) ; } $ criteria = new NObject ( $ criteria ) ; $ this -> applyHook ( 'searching' , $ criteria ) ; $ cursor = $ this -> connection -> query ( $ this , $ criteria -> toArray ( ) ) ; $ this -> a...
Find data with specified criteria
8,320
public function findOne ( $ criteria = array ( ) ) { $ model = $ this -> fetchCache ( $ criteria ) ; if ( is_null ( $ model ) ) { $ cursor = $ this -> find ( $ criteria ) ; $ model = $ cursor -> getNext ( ) ; $ this -> rememberCache ( $ criteria , $ model ) ; } return $ model ; }
Find one document from collection
8,321
public function newInstance ( $ cloned = array ( ) ) { if ( $ cloned instanceof Model ) { $ cloned = $ cloned -> toArray ( Model :: FETCH_PUBLISHED ) ; } if ( isset ( $ this -> options [ 'model' ] ) ) { $ Model = $ this -> options [ 'model' ] ; return new $ Model ( $ cloned , array ( 'collection' => $ this ) ) ; } else...
Create new instance of model
8,322
public function filter ( Model $ model , $ key = null ) { if ( is_null ( $ this -> filter ) ) { $ this -> filter = Filter :: fromSchema ( $ this -> schema ( ) ) ; } $ this -> applyHook ( 'filtering' , $ model , $ key ) ; $ result = $ this -> filter -> run ( $ model , $ key ) ; $ this -> applyHook ( 'filtered' , $ model...
Filter model data with functions to cleanse prepare and validate data . When key argument specified filter will run partially for specified key only .
8,323
public function save ( Model $ model , $ options = array ( ) ) { $ options = array_merge ( array ( 'filter' => true , 'observer' => true , ) , $ options ) ; if ( $ options [ 'filter' ] ) { $ this -> filter ( $ model ) ; } if ( $ options [ 'observer' ] ) { $ this -> applyHook ( 'saving' , $ model , $ options ) ; } $ mod...
Save model to persistent state
8,324
public function remove ( Model $ model = null ) { if ( func_num_args ( ) === 0 ) { $ this -> connection -> remove ( $ this ) ; } else { if ( is_null ( $ model ) ) { throw new \ Exception ( '[Norm/Collection] Cannot remove null model' ) ; } $ this -> applyHook ( 'removing' , $ model ) ; $ result = $ this -> connection -...
Remove single model
8,325
protected function rememberCache ( $ criteria , $ model ) { $ ser = serialize ( $ criteria ) ; $ this -> cache [ $ ser ] = $ model ; }
Put item in cache bags .
8,326
protected function fetchCache ( $ criteria ) { $ ser = serialize ( $ criteria ) ; if ( isset ( $ this -> cache [ $ ser ] ) ) { return $ this -> cache [ $ ser ] ; } }
Get item from cache .
8,327
public static function add ( $ type , $ data = [ ] , $ function = 0 , $ styles = 0 , $ scripts = 0 ) { if ( ! is_admin ( ) || ! self :: required_params_exist ( $ type , $ data ) ) { return false ; } $ data = self :: set_params ( $ data , $ function , $ styles , $ scripts ) ; $ slug = $ data [ 'slug' ] ; self :: $ data ...
Add menu or submenu .
8,328
private static function required_params_exist ( $ type , $ data ) { $ required = [ 'name' , 'slug' ] ; if ( 'submenu' === $ type ) { array_push ( $ required , 'parent' ) ; } foreach ( $ required as $ field ) { if ( ! isset ( $ data [ $ field ] ) || empty ( $ data [ $ field ] ) ) { return false ; } } return true ; }
Validate if the required parameters exist .
8,329
private static function set ( $ type , $ slug ) { global $ pagenow ; $ data = self :: $ data [ $ type ] [ $ slug ] ; do_action ( 'wp_menu_pre_add_' . $ type . '_page' ) ; if ( 'menu' === $ type ) { $ page = add_menu_page ( $ data [ 'title' ] , $ data [ 'name' ] , $ data [ 'capability' ] , $ data [ 'slug' ] , $ data [ '...
Set menu and submenu admin .
8,330
private static function validate_method ( $ method ) { if ( $ method && isset ( $ method [ 0 ] ) && isset ( $ method [ 1 ] ) ) { if ( method_exists ( $ method [ 0 ] , $ method [ 1 ] ) ) { return true ; } } return false ; }
Check if method exists .
8,331
private function getVarsWithoutCircularReferences ( $ showNulls , & $ previousDTOs = [ ] ) { $ previousDTOs [ spl_object_hash ( $ this ) ] = true ; $ classProperties = $ this -> reflection -> getProperties ( \ ReflectionProperty :: IS_PROTECTED ) ; $ vars = array ( ) ; foreach ( $ classProperties as $ property ) { if (...
Export protected class parameters as an associative array .
8,332
public function getDefaultRedis ( ) : ? Connection { $ factory = Redis :: getFacadeRoot ( ) ; if ( isset ( $ factory ) ) { return $ factory -> connection ( ) ; } return $ factory ; }
Get a default redis value if any is available
8,333
public static function check ( Identifiable $ element ) { $ elementId = $ element -> getId ( ) ; if ( ! $ elementId ) { $ element -> setId ( new static ( ) ) ; return $ element -> getId ( ) ; } $ dangerousCharacters = array ( ' ' , '|' , PHP_EOL ) ; $ danger = false ; foreach ( $ dangerousCharacters as $ dangerousChara...
Check and return the Id of an Identifable Element
8,334
public function is ( $ characteristic ) { switch ( strtolower ( $ characteristic ) ) { case "ajax" : return ( isset ( $ this -> _env [ 'HTTP_X_REQUESTED_WITH' ] ) && $ this -> _env [ 'HTTP_X_REQUESTED_WITH' ] == "XMLHttpRequest" ) ; case "delete" : return ( $ this -> method == "DELETE" ) ; case "flash" : return ( $ thi...
Checks for request characteristics .
8,335
protected function parseUrl ( $ url = "" ) { $ parsed = ( $ url ) ? parse_url ( $ url ) : parse_url ( $ this -> _env [ 'REQUEST_URI' ] ) ; if ( preg_match ( '/[a-zA-Z0-9_]+\.php/i' , $ parsed [ 'path' ] , $ matches ) ) { $ parsed [ 'path' ] = preg_replace ( "/$matches[0]/" , '/' , $ parsed [ 'path' ] ) ; } return $ par...
Get parsed url
8,336
public function setControl ( Control $ control ) { $ control -> checkId ( ) ; $ control -> addScriptFeature ( $ this ) ; $ this -> control = $ control ; $ this -> updateScriptEvents ( ) ; return $ this ; }
Set the Control
8,337
protected function updateScriptEvents ( ) { if ( ! $ this -> control || ! ScriptLabel :: isEventLabel ( $ this -> labelName ) ) { return $ this ; } if ( $ this -> control instanceof Scriptable ) { $ this -> control -> setScriptEvents ( true ) ; } return $ this ; }
Enable Script Events on the Control if needed
8,338
protected function buildScriptText ( ) { $ controlId = Builder :: escapeText ( $ this -> control -> getId ( ) ) ; $ scriptText = '' ; $ closeBlock = false ; if ( ScriptLabel :: isEventLabel ( $ this -> labelName ) ) { $ scriptText .= "if (Event.ControlId == {$controlId}) {declare Control <=> Event.Control;" ; $ closeBl...
Build the script text for the Control
8,339
public function getCachePath ( ) : string { $ path = $ this -> getRuntimePath ( ) . DIRECTORY_SEPARATOR . 'cache' ; FileHelper :: createDirectory ( $ path ) ; return $ path ; }
Returns the path to the file cache directory .
8,340
public function api ( $ name ) { $ this -> initializeClient ( $ this -> url , $ this -> client ) ; $ class = 'Rs\\VersionEye\\Api\\' . ucfirst ( $ name ) ; if ( class_exists ( $ class ) ) { return new $ class ( $ this -> client ) ; } else { throw new \ InvalidArgumentException ( 'unknown api "' . $ name . '" requested'...
returns an api .
8,341
private function initializeClient ( $ url , HttpClient $ client = null ) { if ( $ client ) { return $ this -> client = $ client ; } return $ this -> client = $ this -> createDefaultHttpClient ( $ url ) ; }
initializes the http client .
8,342
private static function generateVersion ( $ namespace , $ name , $ version ) { if ( ! self :: isValid ( $ namespace ) ) { return false ; } $ nhex = str_replace ( array ( '-' , '{' , '}' ) , '' , $ namespace ) ; $ nstr = '' ; $ len = strlen ( $ nhex ) ; for ( $ i = 0 ; $ i < $ len ; $ i += 2 ) { $ nstr .= chr ( hexdec (...
Generates v3 or v5 UUIDs .
8,343
public function addDirectory ( $ directory ) { $ directories = $ this -> getDirectory ( true ) ; if ( is_string ( $ directory ) ) { $ directory = explode ( ',' , $ directory ) ; } else if ( ! is_array ( $ directory ) ) { require_once 'Zend/Validate/Exception.php' ; throw new Zend_Validate_Exception ( 'Invalid options t...
Adds the file directory which will be checked
8,344
protected function updateCode ( ) : array { $ output = [ ] ; $ returnValue = 0 ; $ updateMaster = 'ls' ; if ( $ this -> getBranch ( ) !== 'master' ) { $ updateMaster = ' git checkout master && git pull && git checkout ' . $ this -> getBranch ( ) . ' ' ; } $ commands = [ 'git reset --hard HEAD' , 'git pull' , $ updateMa...
Executes the actual deployment commands .
8,345
protected function getItem ( $ foreignKey ) { $ value = $ foreignKey [ 'field' ] ; if ( ! empty ( $ foreignKey [ 'name' ] ) ) { $ value .= "', '" . $ foreignKey [ 'name' ] ; } $ output = sprintf ( "\$table->foreign('%s')->references('%s')->on('%s')" , $ value , $ foreignKey [ 'references' ] , $ foreignKey [ 'on' ] ) ; ...
Return string for adding a foreign key
8,346
public static function error ( $ number , $ string , $ file , $ line ) { throw new \ ErrorException ( $ string , 0 , $ number , $ file , $ line ) ; }
Convert errors to \ ErrorException instances
8,347
public static function create ( $ file = null , $ data = null , $ encode = false ) { $ view = parent :: create ( static :: view_namespace ( ) . '::' . $ file , $ data , $ encode ) ; \ CCAsset :: holder ( 'theme' ) -> path = static :: public_namespace ( ) ; \ CCAsset :: holder ( 'vendor' ) -> path = 'assets/vendor/' ; r...
theme creator returns a new view instance
8,348
protected function _parse ( $ response ) { $ defaults = array ( 'body' => '' , 'headers' => array ( 'Content-Type: text/html; charset=utf-8' ) , 'status' => 200 ) ; if ( is_array ( $ response ) ) { $ response += $ defaults ; } elseif ( is_string ( $ response ) ) { $ defaults [ 'body' ] = $ response ; $ response = $ def...
Parses a response .
8,349
public static final function byName ( $ enumName ) { $ instances = self :: getInstances ( get_called_class ( ) ) ; return isset ( $ instances [ $ enumName ] ) ? $ instances [ $ enumName ] : null ; }
Returns the enum value instance representing the provided const name or null when the const name is not present in the enum .
8,350
private final static function & getInstances ( $ fqcn ) { if ( ! isset ( self :: $ instances [ $ fqcn ] ) ) { self :: loadClass ( $ fqcn ) ; } return self :: $ instances [ $ fqcn ] ; }
Returns the array of all value singletons of one Enum class
8,351
private final static function loadClass ( $ fqcn ) { $ reflectionClass = new ReflectionClass ( $ fqcn ) ; $ constants = $ reflectionClass -> getConstants ( ) ; foreach ( $ constants as $ name => $ value ) { $ instance = new $ fqcn ( $ fqcn , $ name , $ value ) ; if ( is_callable ( [ $ instance , '__initEnum' ] ) ) { $ ...
Uses reflection to load and cache all value singletons of the class represented by the fqcn .
8,352
public function validateScopes ( $ scopeParam = '' , ClientEntity $ client , $ redirectUri = null ) { $ scopesList = explode ( $ this -> server -> getScopeDelimiter ( ) , $ scopeParam ) ; for ( $ i = 0 ; $ i < count ( $ scopesList ) ; $ i ++ ) { $ scopesList [ $ i ] = trim ( $ scopesList [ $ i ] ) ; if ( $ scopesList [...
Given a list of scopes validate them and return an array of Scope entities
8,353
public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof SystemSettingsQuery ) { return $ criteria ; } $ query = new SystemSettingsQuery ( null , null , $ modelAlias ) ; if ( $ criteria instanceof Criteria ) { $ query -> mergeWith ( $ criteria ) ; } return $ query ; }
Returns a new SystemSettingsQuery object .
8,354
public function filterByKey ( $ key = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ key ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ key ) ) { $ key = str_replace ( '*' , '%' , $ key ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlia...
Filter the query on the key column
8,355
public function buildUrl ( ) { $ url = $ this -> getApiUrl ( ) ; if ( $ endpoint = $ this -> getEndpoint ( ) ) { $ url .= $ endpoint ; } if ( $ id = $ this -> getId ( ) ) { $ url .= '/' . $ id ; } $ parameters = [ ] ; if ( $ include = $ this -> getInclude ( ) ) { if ( is_array ( $ include ) ) { $ include = implode ( ',...
Build api call url .
8,356
public function httpGetRequest ( $ url ) { if ( $ this -> useCache ( ) ) { $ cache = $ this -> getCache ( ) ; if ( $ response = $ cache -> get ( $ url ) ) { return $ response ; } } if ( empty ( $ this -> client ) ) { $ this -> client = new Client ( [ 'verify' => false ] ) ; } $ this -> response = $ this -> client -> re...
Make a GET request and respond with json decoded to array .
8,357
public function httpPostRequest ( $ url , $ parameters ) { if ( empty ( $ this -> client ) ) { $ this -> client = new Client ( [ 'verify' => false ] ) ; } $ this -> response = $ this -> client -> request ( 'POST' , $ url , [ 'headers' => $ this -> getHeaders ( ) , 'json' => $ parameters ] ) ; $ response = json_decode (...
Make a POST request and respond with json decoded to array .
8,358
public function get ( $ fields = null ) { if ( ! empty ( $ fields ) ) { $ this -> fields ( $ fields ) ; } return $ this -> httpGetRequest ( $ this -> buildUrl ( ) ) ; }
Call get request .
8,359
public function first ( ) { $ response = $ this -> httpGetRequest ( $ this -> buildUrl ( ) ) ; if ( empty ( $ response -> data [ 0 ] ) ) { return false ; } return $ response -> data [ 0 ] ; }
Get first item from get response .
8,360
public function flush ( ) { $ this -> filters = [ ] ; $ this -> include = null ; $ this -> id = null ; $ this -> endpoint = null ; $ this -> sort = null ; $ this -> fields = null ; $ this -> pageSize = null ; $ this -> response = null ; }
Unset all call parameters .
8,361
public function useCache ( $ caching = null ) { if ( is_null ( $ caching ) ) { return ( $ this -> useCache && $ this -> getCache ( ) ) ; } $ this -> useCache = ( bool ) $ caching ; return $ this ; }
Check if cache can be used in this request or set caching for request .
8,362
protected function resetJsonResult ( ) { $ this -> jsonResult [ 'skipped' ] = false ; $ this -> jsonResult [ 'pass' ] = false ; $ this -> jsonResult [ 'failure' ] = false ; $ this -> jsonResult [ 'error' ] = false ; $ this -> jsonResult [ 'unknown' ] = false ; }
initializer for json result set in write progress method
8,363
protected function writeScanPassStatistic ( CoverFishResult $ coverFishResult ) { $ passStatistic = '%s file(s) and %s method(s) scanned, scan succeeded, no problems found.%s' ; $ passStatistic = sprintf ( $ passStatistic , $ coverFishResult -> getFileCount ( ) , $ coverFishResult -> getTestCount ( ) , PHP_EOL ) ; $ sc...
write scan pass results
8,364
protected function writeScanFailStatistic ( CoverFishResult $ coverFishResult ) { $ errorStatistic = '%s file(s) and %s method(s) scanned, coverage failed: %s cover annotation problem(s) found!%s' ; $ errorStatistic = sprintf ( $ errorStatistic , $ coverFishResult -> getFileCount ( ) , $ coverFishResult -> getTestCount...
write scan fail result
8,365
protected static function __zipWith ( callable $ f , array $ a , array $ b ) : array { $ result = [ ] ; while ( ( $ ai = array_shift ( $ a ) ) !== null && ( $ bi = array_shift ( $ b ) ) !== null ) { $ result [ ] = $ f ( $ ai , $ bi ) ; } return $ result ; }
Custom Array Zip
8,366
protected static function __dropWhile ( callable $ predicate , array $ list ) : array { foreach ( $ list as $ item ) { if ( $ predicate ( $ item ) ) { array_shift ( $ list ) ; } else { break ; } } return $ list ; }
Drop Elements with Predicate
8,367
protected static function __takeWhile ( callable $ predicate , array $ list ) : array { $ result = [ ] ; foreach ( $ list as $ item ) { if ( $ predicate ( $ item ) ) { $ result [ ] = $ item ; } else { break ; } } return $ result ; }
Take Elements with Predicate
8,368
public static function thumb ( $ src , $ url = '#' , $ htmlOptions = array ( ) ) { static :: addCssClass ( $ htmlOptions , 'th' ) ; return \ CHtml :: link ( \ CHtml :: image ( $ src ) , $ url , $ htmlOptions ) ; }
Renders a Foundation thumbnail
8,369
public static function addCssClass ( & $ options , $ class ) { if ( isset ( $ options [ 'class' ] ) ) { $ classes = ' ' . $ options [ 'class' ] . ' ' ; if ( ( $ pos = strpos ( $ classes , ' ' . $ class . ' ' ) ) === false ) { $ options [ 'class' ] .= ' ' . $ class ; } } else { $ options [ 'class' ] = $ class ; } }
Adds a CSS class to the specified options . If the CSS class is already in the options it will not be added again .
8,370
public function callUrl ( $ url , $ args = array ( ) , $ returnType = 'raw' , $ requestType = 'GET' , $ cache = 300 , $ enctype = Zend_Http_Client :: ENC_URLENCODED ) { $ body = null ; $ cacheKey = md5 ( $ url . $ requestType . var_export ( $ args , true ) . var_export ( $ this -> globalParams , true ) ) ; $ requestTyp...
Call a URL directly without it being mapped to a configured web method .
8,371
protected function getClient ( $ uri ) { if ( ! $ this -> httpClient || ! $ this -> maintainSession ) { $ this -> httpClient = new Zend_Http_Client ( $ uri , array ( 'maxredirects' => 0 , 'timeout' => 10 ) ) ; if ( $ this -> useCookies ) { $ this -> httpClient -> setCookieJar ( ) ; } } else { $ this -> httpClient -> se...
Create and return the http client defined in a separate method for testing purposes
8,372
protected function waitFrame ( ) { $ frameType = $ this -> input -> readOctet ( ) ; $ channel = $ this -> input -> readShort ( ) ; $ size = $ this -> input -> readLong ( ) ; $ payload = $ this -> input -> read ( $ size ) ; $ ch = $ this -> input -> readOctet ( ) ; if ( $ ch != 0xCE ) { throw new \ Exception ( sprintf (...
Wait for a frame from the server
8,373
public function waitChannel ( $ channelId ) { while ( true ) { list ( $ frameType , $ frameChannel , $ payload ) = $ this -> waitFrame ( ) ; if ( $ frameChannel == $ channelId ) { return array ( $ frameType , $ payload ) ; } array_push ( $ this -> channels [ $ frameChannel ] -> frame_queue , array ( $ frameType , $ pay...
Wait for a frame from the server destined for a particular channel .
8,374
public function channel ( $ channelId = null ) { if ( isset ( $ this -> channels [ $ channelId ] ) ) { return $ this -> channels [ $ channelId ] ; } else { $ channelId = $ channelId ? : $ this -> getFreeChannelId ( ) ; $ ch = new Channel ( $ this -> connection , $ channelId ) ; return $ this -> channels [ $ channelId ]...
Fetch a Channel object identified by the numeric channel_id or create that object if it doesn t already exist .
8,375
public function close ( $ replyCode = 0 , $ replyText = '' , $ methodSig = array ( 0 , 0 ) ) { $ args = new Writer ( ) ; $ args -> writeShort ( $ replyCode ) ; $ args -> writeShortStr ( $ replyText ) ; $ args -> writeShort ( $ methodSig [ 0 ] ) ; $ args -> writeShort ( $ methodSig [ 1 ] ) ; $ this -> sendMethodFrame ( ...
request a connection close
8,376
protected function openOk ( Reader $ args ) { $ this -> knownHosts = $ args -> readShortstr ( ) ; if ( $ this -> debug ) { Helper :: debugMsg ( "Open OK! known_hosts: " . $ this -> knownHosts ) ; } return null ; }
signal that the connection is ready
8,377
protected function redirect ( Reader $ args ) { $ host = $ args -> readShortstr ( ) ; $ this -> knownHosts = $ args -> readShortstr ( ) ; if ( $ this -> debug ) { Helper :: debugMsg ( sprintf ( 'Redirected to [%s], known_hosts [%s]' , $ host , $ this -> knownHosts ) ) ; } return $ host ; }
asks the client to use a different server
8,378
protected function _xSecureOk ( $ response ) { $ args = new Writer ( ) ; $ args -> writeLongStr ( $ response ) ; $ this -> sendMethodFrame ( array ( 10 , 21 ) , $ args ) ; }
security mechanism response
8,379
protected function start ( Reader $ args ) { $ this -> versionMajor = $ args -> readOctet ( ) ; $ this -> versionMinor = $ args -> readOctet ( ) ; $ this -> serverProperties = $ args -> readTable ( ) ; $ this -> mechanisms = explode ( " " , $ args -> readLongstr ( ) ) ; $ this -> locales = explode ( " " , $ args -> rea...
start connection negotiation
8,380
protected function tune ( Reader $ args ) { $ v = $ args -> readShort ( ) ; if ( $ v ) { $ this -> channelMax = $ v ; } $ v = $ args -> readLong ( ) ; if ( $ v ) { $ this -> frameMax = $ v ; } $ this -> heartbeat = $ args -> readShort ( ) ; $ this -> xTuneOk ( $ this -> channelMax , $ this -> frameMax , 0 ) ; }
propose connection tuning parameters
8,381
protected function xTuneOk ( $ channelMax , $ frameMax , $ heartbeat ) { $ args = new Writer ( ) ; $ args -> writeShort ( $ channelMax ) ; $ args -> writeLong ( $ frameMax ) ; $ args -> writeShort ( $ heartbeat ) ; $ this -> sendMethodFrame ( array ( 10 , 31 ) , $ args ) ; $ this -> waitTuneOk = False ; }
negotiate connection tuning parameters
8,382
public function service ( $ service , $ subject , $ predicate = null , $ object = null ) { $ this -> graphBuilder -> service ( $ service , $ subject , $ predicate , $ object ) ; return $ this ; }
Adds the given graph or triple as an service condition .
8,383
public function convertToRconData ( $ id ) { $ idAndTypePacked = pack ( 'VV' , $ id , $ this -> type ) ; $ endOfMessage = chr ( 0 ) . chr ( 0 ) ; $ message = $ idAndTypePacked . $ this -> body . $ endOfMessage ; $ data = pack ( "V" , strlen ( $ message ) ) . $ message ; return $ data ; }
The message id used for this message . This will be encoded in the RconData .
8,384
public function _add_meta_boxes ( $ post_type , $ post ) { $ post_type_object = get_post_type_object ( $ post_type ) ; if ( empty ( $ post_type_object ) || empty ( $ post_type_object -> public ) ) { return ; } add_meta_box ( 'wp-seo' , __ ( 'SEO' , 'inc2734-wp-seo' ) , array ( $ this , '_wp_seo_meta_box' ) , $ post_typ...
Add meta box in pages of public post type
8,385
public function _wp_seo_meta_box ( $ post ) { ?> <?php wp_nonce_field ( 'wp-seo-meta-box-action' , 'wp-seo-meta-box-nonce' ) ; ?> <p> <label for="wp-seo-meta-description"> <b> <?php esc_html_e ( 'Meta description' , 'inc2734-wp-seo' ) ; ?> </b> </label><br /> <input type="text" name="wp-seo-meta-descript...
Display meta box
8,386
public function _save_meta_description ( $ post_id ) { if ( empty ( $ _POST [ 'wp-seo-meta-box-nonce' ] ) ) { return ; } if ( ! wp_verify_nonce ( wp_unslash ( filter_input ( INPUT_POST , 'wp-seo-meta-box-nonce' ) ) , 'wp-seo-meta-box-action' ) ) { return ; } if ( defined ( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { retur...
Save meta description
8,387
public function _save_meta_robots ( $ post_id ) { if ( empty ( $ _POST [ 'wp-seo-meta-box-nonce' ] ) ) { return ; } if ( ! wp_verify_nonce ( wp_unslash ( filter_input ( INPUT_POST , 'wp-seo-meta-box-nonce' ) ) , 'wp-seo-meta-box-action' ) ) { return ; } if ( defined ( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return ; }...
Save meta robots
8,388
public static function getTypeInstance ( $ type ) { $ type = ucfirst ( strtolower ( $ type ) ) ; if ( ! isset ( self :: $ instances [ $ type ] ) ) { $ class = 'JFusion\\Api\\Platform\\' . $ type ; self :: $ instances [ $ type ] = new $ class ( ) ; } return self :: $ instances [ $ type ] ; }
Get a platform type object .
8,389
public static function generate_token ( $ length ) { $ byte_length = ( $ length / 2 ) ; $ new_token = bin2hex ( openssl_random_pseudo_bytes ( $ byte_length , $ strong_enough ) ) ; if ( $ strong_enough == false || empty ( $ new_token ) ) { $ exception = bootstrap :: get_library ( 'exception' ) ; throw new $ exception ( ...
generates cryptographically strong tokens
8,390
public function setLayers ( array $ layers ) { $ this -> layers = array_values ( array_filter ( $ layers , function ( $ layer ) : bool { return $ layer instanceof Layer ; } ) ) ; return $ this ; }
Sets the layers of the icon .
8,391
public function register_asset ( \ Amarkal \ Assets \ AbstractAsset $ new_asset ) { if ( NULL == $ this -> assets ) { $ this -> assets = array ( ) ; $ this -> assets [ ] = $ new_asset ; } else { foreach ( $ this -> assets as $ asset ) { if ( $ asset -> handle == $ new_asset -> handle && get_class ( $ asset ) == get_cla...
Register a single asset
8,392
public static function expandNamespace ( $ classOrClassName , $ expandNamespace ) { if ( mb_strpos ( $ classOrClassName , '\\' ) !== 0 && self :: getNamespace ( $ classOrClassName ) === NULL ) { return $ expandNamespace . '\\' . ltrim ( $ classOrClassName , '\\' ) ; } return $ classOrClassName ; }
Erweitert einen nicht qualifzierten Klassenamen mit einem Namespace
8,393
public function userCanReachCenter ( User $ user , Center $ center ) { foreach ( $ user -> getGroupCenters ( ) as $ groupCenter ) { if ( $ center -> getId ( ) === $ groupCenter -> getCenter ( ) -> getId ( ) ) { return true ; } } return false ; }
Determines if a user is active on this center
8,394
public function getReachableCenters ( User $ user , Role $ role , Scope $ scope = null ) { $ centers = array ( ) ; foreach ( $ user -> getGroupCenters ( ) as $ groupCenter ) { $ permissionGroup = $ groupCenter -> getPermissionsGroup ( ) ; foreach ( $ permissionGroup -> getRoleScopes ( ) as $ roleScope ) { if ( $ this -...
Get reachable Centers for the given user role and optionnaly Scope
8,395
public function getReachableScopes ( User $ user , Role $ role , Center $ center ) { return $ this -> getReachableCircles ( $ user , $ role , $ center ) ; }
Return all reachable scope for a given user center and role
8,396
public function getReachableCircles ( User $ user , Role $ role , Center $ center ) { $ scopes = array ( ) ; foreach ( $ user -> getGroupCenters ( ) as $ groupCenter ) { if ( $ center -> getId ( ) === $ groupCenter -> getCenter ( ) -> getId ( ) ) { $ permissionGroup = $ groupCenter -> getPermissionsGroup ( ) ; foreach ...
Return all reachable circle for a given user center and role
8,397
protected function isRoleReached ( Role $ childRole , Role $ parentRole ) { $ reachableRoles = $ this -> roleHierarchy -> getReachableRoles ( [ $ parentRole ] ) ; return in_array ( $ childRole , $ reachableRoles ) ; }
Test if a parent role may give access to a given child role
8,398
public function getCacheStore ( ) : ? Store { if ( ! $ this -> hasCacheStore ( ) ) { $ this -> setCacheStore ( $ this -> getDefaultCacheStore ( ) ) ; } return $ this -> cacheStore ; }
Get cache store
8,399
public function getDefaultCacheStore ( ) : ? Store { $ manager = Cache :: getFacadeRoot ( ) ; if ( isset ( $ manager ) ) { $ repository = $ manager -> store ( ) ; return $ repository -> getStore ( ) ; } return $ manager ; }
Get a default cache store value if any is available