idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
56,700
public function processStream ( $ event ) { if ( $ event -> message -> isCtlFrame ( ) ) { if ( $ event -> message -> isCloseFrame ( ) ) { return $ this -> processClose ( $ event ) ; } else if ( $ event -> message -> isPingFrame ( ) ) { return $ this -> processPing ( $ event ) ; } else if ( $ event -> message -> isPongF...
process websocket stream request
56,701
public function processClose ( $ event ) { $ response = new Response ( ) ; $ response -> opcode = Request :: OPCODE_CLOSE ; return $ event -> sender -> close ( $ response ) ; }
process close request
56,702
public function processPing ( $ event ) { $ res = new Response ( ) ; $ res -> fin = 1 ; $ res -> opcode = Request :: OPCODE_PONG ; $ res -> mask = 0 ; $ res -> payload_len = 0 ; $ event -> sender -> send ( $ res ) ; }
process ping request send pong response to client .
56,703
public function addItem ( $ object , ? string $ key = null ) : void { $ this -> checkCallback ( ) ; if ( null !== $ key ) { if ( isset ( $ this -> members [ $ key ] ) ) { throw new CollectionException ( 'Unable to add to collection - key ' . $ key . ' already used.' ) ; } else { $ this -> members [ $ key ] = $ object ;...
Adds a new member to the collection
56,704
public function addItemAfter ( mixed $ object , string $ previous_key , ? string $ key = null ) : void { if ( ! isset ( $ this -> members [ $ previous_key ] ) ) { $ this -> addItem ( $ object , $ key ) ; return ; } $ position = array_search ( $ previous_key , array_keys ( $ this -> members ) ) ; $ this -> array_insert ...
Add the specified object after the indicated key .
56,705
public function addItemBefore ( mixed $ object , string $ latter_key , ? string $ key = null ) : void { if ( ! isset ( $ this -> members [ $ latter_key ] ) ) { $ this -> addItem ( $ object , $ key ) ; return ; } $ position = array_search ( $ latter_key , array_keys ( $ this -> members ) ) ; $ this -> array_insert ( $ o...
Add the object before the specified item .
56,706
private function array_insert ( mixed $ object , string $ key , int $ position ) : void { if ( 0 == count ( $ this -> members ) ) { $ this -> members [ $ key ] = $ object ; } elseif ( $ position == count ( $ this -> members ) ) { $ this -> members [ $ key ] = $ object ; } else { $ this -> members = array_slice ( $ this...
Add the object at a designated position in the array .
56,707
public function removeItem ( string $ key ) : void { $ this -> checkCallback ( ) ; if ( isset ( $ this -> members [ $ key ] ) ) { unset ( $ this -> members [ $ key ] ) ; } else { throw new CollectionException ( 'Unable to remove from collection - key ' . $ key . ' not found.' ) ; } }
\ Remove the item specified by the key from the collection
56,708
public function getItem ( string $ key ) { $ this -> checkCallback ( ) ; if ( isset ( $ this -> members [ $ key ] ) ) { return $ this -> members [ $ key ] ; } else { throw new CollectionException ( 'Unable to retrieve item from collection - key ' . $ key . ' not found.' ) ; } }
Returns the item represented by the key
56,709
public function exists ( string $ key ) : bool { $ this -> checkCallback ( ) ; return isset ( $ this -> members [ $ key ] ) ; }
Checks if the key is in use
56,710
private function checkCallback ( ) : void { if ( isset ( $ this -> onload ) && ! $ this -> is_loaded ) { $ this -> is_loaded = true ; call_user_func ( $ this -> onload , $ this ) ; } }
Call the specified callback if the collection is not loaded .
56,711
public static function generate ( $ options = array ( ) ) { $ sentencesToDisplay = isset ( $ options [ 'sentences' ] ) ? $ options [ 'sentences' ] : rand ( 1 , 10 ) ; $ author = isset ( $ options [ 'author' ] ) ? $ options [ 'author' ] : array_rand ( self :: $ authors , 1 ) ; $ path = __DIR__ . '/data/' . $ author . '....
Main generator method .
56,712
protected static function getSentences ( $ body , $ sentencesToDisplay = 2 ) { $ sentences = preg_split ( '/(\.|\?|\!)(\s)/' , $ body ) ; array_shift ( $ sentences ) ; if ( count ( $ sentences ) <= $ sentencesToDisplay ) { return $ body ; } else { $ results = array_slice ( $ sentences , 0 , $ sentencesToDisplay ) ; ret...
Returns the first N sentences from a string of text .
56,713
protected function injectFormCell ( BlockView $ view , BlockInterface $ block ) { $ section = BlockViewUtil :: getParent ( $ view , 'panel_section' ) ; if ( null !== $ section && $ section -> vars [ 'rendered' ] && $ view -> vars [ 'rendered' ] && null !== $ formPath = $ block -> getConfig ( ) -> getAttribute ( 'form_n...
Inject the form of panel cell in view .
56,714
protected function obtainServers ( ) { $ this -> servers = $ this -> fetchServers ( ) ; $ this -> server_names = collect ( $ this -> servers ) -> pluck ( 'name' ) -> toArray ( ) ; if ( empty ( $ this -> server_names ) ) { $ this -> error ( 'No valid servers assigned to user. Skipping SSH key installation on server...' ...
Obtain servers .
56,715
protected function obtainServer ( ) { if ( ! $ this -> server ) { if ( $ this -> argument ( 'server_name' ) ) { $ this -> server = $ this -> getForgeIdServer ( $ this -> servers , $ this -> argument ( 'server_name' ) ) ; if ( ! $ this -> server ) { $ this -> error ( 'No server name found on servers assigned to user!' )...
Obtain server .
56,716
protected function installSSHKeyOnServer ( ) { $ this -> info ( 'Adding SSH key to Laravel Forge server' ) ; $ this -> url = $ this -> endPointAPIURL ( ) ; $ response = $ this -> postKeyToLaravelForgeServer ( $ keyName = $ this -> getUniqueKeyNameFromEmail ( ) ) ; $ result = json_decode ( $ contents = $ response -> get...
Install ssh key on server .
56,717
protected function postKeyToLaravelForgeServer ( $ keyName = null ) { $ keyName ? $ keyName : $ this -> getUniqueKeyNameFromEmail ( ) ; return $ this -> http -> post ( $ this -> url , [ 'form_params' => [ 'name' => $ keyName , 'key' => file_get_contents ( $ _SERVER [ 'HOME' ] . self :: SSH_ID_RSA_PUB ) ] , 'headers' =>...
Post key to Laravel Forge Server .
56,718
protected function appendSSHConfig ( ) { $ ssh_config_file = $ this -> sshConfigFile ( ) ; $ hostname = $ this -> hostNameForConfigFile ( ) ; $ host_string = "Host " . $ hostname ; if ( strpos ( file_get_contents ( $ ssh_config_file ) , $ host_string ) !== false ) { $ this -> info ( "SSH config for host: $host_string a...
Append ssh config .
56,719
protected function ip_address ( ) { if ( fp_env ( 'ACACHA_FORGE_IP_ADDRESS' ) ) { $ ip_address = fp_env ( 'ACACHA_FORGE_IP_ADDRESS' ) ; } else { $ ip_address = $ this -> argument ( 'ip' ) ? $ this -> argument ( 'ip' ) : $ this -> ask ( 'IP Address?' ) ; } $ this -> validateIpAddress ( $ ip_address ) ; return $ ip_addre...
IP address .
56,720
protected function validateIpAddress ( $ ip_address ) { if ( ! filter_var ( $ ip_address , FILTER_VALIDATE_IP ) ) { $ this -> error ( "$ip_address is not a valid ip address! Exiting!" ) ; die ( ) ; } if ( ! $ this -> checkIp ( $ ip_address , $ this -> servers ) ) { $ this -> error ( "$ip_address doesn't match any of yo...
Validate ip address .
56,721
protected function createSSHKeys ( ) { $ email = $ this -> argument ( 'email' ) ? $ this -> argument ( 'email' ) : $ this -> getEmail ( ) ; $ this -> info ( "Running ssh-keygen -t rsa -b 4096 -C '$email'" ) ; passthru ( 'ssh-keygen -t rsa -b 4096 -C "' . $ email . '"' ) ; }
Create SSH Keys .
56,722
public function setTemplateDirectory ( $ directory ) { if ( $ directory == null ) { $ this -> templateDirectory = realpath ( find_tse_template ( $ this -> templateName ) ) ; $ this -> loadPackageTemplate ( $ this -> templateDirectory ) ; return ; } $ this -> templateDirectory = realpath ( $ directory ) ; $ this -> load...
Sets the template directory .
56,723
private function getTemplateDirectory ( ) { $ templateDirectory = realpath ( $ this -> templateDirectory . '/_template' ) ; if ( $ this -> files -> exists ( $ templateDirectory ) && $ this -> files -> isDirectory ( $ templateDirectory ) ) { $ this -> generator -> setInsideTemplateDirectory ( true ) ; return $ templateD...
This method will return the path that the engine should use when retrieving template content . If the developer has created a directory _template we will use that dir instead .
56,724
private function getCommonTemplateDirectory ( ) { $ commonDirectory = realpath ( $ this -> templateDirectory . '/_newup/common' ) ; if ( $ this -> files -> exists ( $ commonDirectory ) && $ this -> files -> isDirectory ( $ commonDirectory ) ) { return $ commonDirectory ; } return null ; }
Returns the common template directory .
56,725
public function build ( ) { $ output = Application :: getOutput ( ) ; $ input = Application :: getInput ( ) ; $ this -> package -> setRendererInstance ( $ this -> generator -> getRenderer ( ) ) ; $ this -> package -> setApplication ( app ( Application :: class ) ) ; $ this -> package -> setOutputInstance ( $ output ) ;...
Builds the package template .
56,726
private function loadPackageTemplate ( $ directory ) { $ namespacedPackageClass = $ this -> packageLoader -> loadPackage ( realpath ( $ directory ) ) ; $ this -> autoLoaderManager -> mergePackageLoader ( realpath ( $ directory ) ) ; $ this -> package = app ( $ namespacedPackageClass ) ; }
This method will load the package template instance .
56,727
public function setOptions ( $ options ) { $ this -> package -> setParsedOptions ( $ options ) ; $ this -> inputCollector -> setOptions ( $ options ) ; }
Sets the command options with their values .
56,728
public function setArguments ( $ arguments ) { $ this -> package -> setParsedArguments ( $ arguments ) ; $ this -> inputCollector -> setArguments ( $ arguments ) ; }
Sets the command arguments with their values .
56,729
public function addEventListener ( callable $ listener ) : void { $ dispatcher = type_check ( $ this -> getEventDispatcher ( ) , 'Jasny\EventDispatcher\EventDispatcher' , new LogicException ( 'Unsupported event dispatcher. Please overload the addEventListener method.' ) ) ; $ provider = type_check ( $ dispatcher -> get...
Add an event listener to the entity s event dispatcher .
56,730
public function setProtocol ( $ protocol ) { switch ( $ protocol ) { case self :: PROTOCOL_HTTPS : $ this -> _protocol = "https" ; break ; case self :: PROTOCOL_HTTP : $ this -> _protocol = "http" ; break ; default : throw new ChaincoinException ( "Invalid Protocol" ) ; } return $ this ; }
Set the protocol used to connect to the JSON - RPC server .
56,731
public function setCertificate ( $ filePath ) { if ( ! file_exists ( realpath ( $ filePath ) ) ) { throw new ChaincoinException ( "Invalid Certificate Path" ) ; } $ this -> _cert = realpath ( $ filePath ) ; $ this -> setProtocol ( self :: PROTOCOL_HTTPS ) ; return $ this ; }
Set the certificate to be used to confirm a HTTPS connection .
56,732
public function callMethod ( $ methodName , array $ parameters = array ( ) ) { $ this -> _status = null ; $ this -> _response = null ; $ this -> _rawResponse = null ; $ this -> _error = null ; $ parameters = array_values ( $ parameters ) ; $ this -> _id ++ ; $ input = json_encode ( array ( 'method' => $ methodName , 'p...
Call a method and return the response as an associative array .
56,733
public function connect ( MysqlConnection $ connection ) { try { if ( ! $ connection -> isConnected ( ) ) { throw new DatabaseException ( __METHOD__ . "\nConnection failure no ressource given" , self :: NO_RESSOURCE , self :: SEVERITY_LOG , __FILE__ , __LINE__ ) ; } if ( $ this -> _get_detail === true ) { $ this -> db_...
connects to the db based on the mysql Connection
56,734
public function fetchAssocList ( \ PDOStatement $ res , $ assign_by = null ) { $ result = array ( ) ; try { while ( $ row = $ res -> fetch ( \ PDO :: FETCH_ASSOC ) ) { if ( ! empty ( $ assign_by ) && ! is_array ( $ assign_by ) ) { $ result [ $ row [ $ assign_by ] ] = ( array ) $ row ; } elseif ( ! empty ( $ assign_by )...
fetches an array list of associative arrays which can be assigned to a specific key from the row as well
56,735
public function fetchNumericList ( \ PDOStatement $ res ) { $ result = new \ SplFixedArray ( $ res -> rowCount ( ) ) ; try { while ( $ row = $ res -> fetch ( \ PDO :: FETCH_NUM ) ) { $ result [ ] = ( array ) $ row ; } } catch ( DatabaseException $ e ) { throw $ e ; } return $ result ; }
fetches an array list of numeric arrays
56,736
public function fetchObjectList ( \ PDOStatement $ res , $ assign_by = null ) { try { $ result = [ ] ; while ( $ row = $ res -> fetch ( \ PDO :: FETCH_OBJ ) ) { if ( ! empty ( $ assign_by ) && ! is_array ( $ assign_by ) ) { $ result [ $ row -> $ assign_by ] = ( object ) $ row ; } elseif ( ! empty ( $ assign_by ) && is_...
fetches an object list of associative arrays which can be assigned to a specific key from the row as well
56,737
public function getDatabaseDetail ( MySQL $ db = null ) { if ( empty ( $ db ) || empty ( $ db -> db ) ) { $ db = $ this ; } return new MysqlDetail ( $ db ) ; }
wrapper for the db_detail object the parameter should be a valid db object
56,738
public function selectDb ( $ dbname , \ PDO $ db ) { if ( empty ( $ db ) || empty ( $ dbname ) ) return false ; try { if ( ! $ db -> query ( "USE `$dbname`" ) ) { $ this -> error = ( string ) $ db -> errorInfo ( ) ; $ this -> errorno = ( int ) $ db -> errorCode ( ) ; throw new DatabaseException ( __METHOD__ . "\nsql_er...
selects a db
56,739
public function setCharset ( $ charset = 'UTF8' , \ PDO $ db ) { try { if ( empty ( $ charset ) || ! $ db ) { throw new DatabaseException ( __METHOD__ . "\ncharset:$charset\nressource:" . print_r ( $ this -> db , true ) , self :: ERR_EXEC , self :: SEVERITY_LOG , __FILE__ , __LINE__ ) ; } $ this -> mysqli_client_encodi...
sets a different charset
56,740
public function setLoggerInstance ( LoggerInterface $ LogInterface = null ) { $ this -> oLog = $ LogInterface ?? new \ Psr \ Log \ NullLogger ( ) ; return $ this ; }
Setting Logger instance
56,741
public function setDefaultRepositoryClassName ( $ className ) { $ reflectionClass = new \ ReflectionClass ( $ className ) ; if ( ! $ reflectionClass -> implementsInterface ( ObjectRepository :: class ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid repository class "%s". It must be a Doctrine\Common\Pers...
Set default repository class name .
56,742
public function cron_callback ( $ hash ) { $ notifications = $ this -> storage -> get_notifications ( $ hash ) ; if ( empty ( $ notifications ) ) { return ; } $ strategy = $ this -> storage -> get_notifications_strategy ( $ hash ) ; $ rate = $ strategy -> get_suggested_rate ( ) ; if ( count ( $ notifications ) > $ rate...
Callback function given to WP Cron .
56,743
public function qb ( array $ definition , bool $ autoexec = false ) { $ builder = new QueryBuilder ( $ definition ) ; $ this -> sql = $ builder -> build ( ) ; $ this -> params = $ builder -> getParams ( ) ; return $ this -> query ( $ autoexec ) ; }
Run QueryBuilder as definition parser to create a sql query
56,744
public function sql ( string $ sql , array $ params = [ ] , bool $ autoexec = false ) { $ this -> sql = $ sql ; $ this -> params = $ params ; return $ this -> query ( $ autoexec ) ; }
Run query by sql string
56,745
private function query ( bool $ autoexec = false ) { $ this -> stmt = null ; $ this -> stmt = $ this -> dbh -> prepare ( str_replace ( '{db_prefix}' , $ this -> prefix , $ this -> sql ) ) ; if ( ! empty ( $ this -> params ) ) { foreach ( $ this -> params as $ parameter => $ value ) { $ this -> stmt -> bindValue ( $ par...
This is the db query method
56,746
public function bindValue ( string $ param , $ value , int $ type = null ) { if ( is_null ( $ type ) ) { switch ( true ) { case is_int ( $ value ) : $ type = \ PDO :: PARAM_INT ; break ; case is_bool ( $ value ) : $ type = \ PDO :: PARAM_BOOL ; break ; case is_null ( $ value ) : $ type = \ PDO :: PARAM_NULL ; break ; d...
Bind parameter by value to PDO statement
56,747
public function all ( ) : array { $ this -> execute ( ) ; $ data = $ this -> stmt -> fetchAll ( \ PDO :: FETCH_CLASS , '\Core\Data\DataObject' ) ; if ( ! empty ( $ data ) ) { $ data = $ this -> executeCallbackAndSchemeHandler ( $ data ) ; } return $ data ; }
Executes statement and returns result as an array of DataObjects
56,748
public function single ( ) { $ this -> execute ( ) ; $ data = $ this -> stmt -> fetchObject ( '\Core\Data\DataObject' ) ; if ( ! empty ( $ data ) ) { $ data = $ this -> executeCallbackAndSchemeHandler ( $ data ) ; } return $ data ; }
Executes statement and returns result as DataObject
56,749
public function column ( int $ column = 0 ) : array { $ this -> execute ( ) ; return $ this -> stmt -> fetchAll ( \ PDO :: FETCH_COLUMN , $ column ) ; }
Executes statement and returns all rows of specific column
56,750
public function find ( string $ table , string $ key_field , $ value ) { $ this -> qb ( [ 'table' => $ table , 'filter' => $ key_field . '=:' . $ key_field , 'params' => [ ':' . $ key_field => $ value ] ] ) ; return $ this -> single ( ) ; }
Finds one row by using one field and a value as filter
56,751
public function delete ( $ table , $ filter = '' , array $ params = [ ] ) : bool { $ query = [ 'table' => $ table , 'method' => 'DELETE' ] ; if ( $ filter ) { $ query [ 'filter' ] = $ filter ; if ( $ params ) { $ query [ 'params' ] = $ params ; } } $ this -> qb ( $ query , true ) ; return true ; }
Shorthand delete method .
56,752
public function debugSql ( string $ sql , array $ params = [ ] ) : string { if ( $ params ) { $ indexed = $ params == array_values ( $ params ) ; foreach ( $ params as $ k => $ v ) { if ( is_object ( $ v ) ) { if ( $ v instanceof \ DateTime ) { $ v = $ v -> format ( 'Y-m-d H:i:s' ) ; } else { continue ; } } elseif ( is...
Returns interpolated sql string with parameters
56,753
public function setScheme ( array $ scheme ) { $ scheme_handler = new SchemeHandler ( ) ; $ scheme_handler -> setScheme ( $ scheme ) ; $ this -> injectSchemeHandler ( $ scheme_handler ) ; }
Adds a scheme array based SchemeHandler object to the connector
56,754
public function add ( $ data ) { if ( is_array ( $ data ) ) { $ this -> listeners = array_merge ( $ this -> listeners , $ data ) ; } elseif ( $ data instanceof \ Symfony \ Component \ EventDispatcher \ EventlistenerInterface ) { if ( ! in_array ( get_class ( $ data ) , $ this -> loaded ) ) { $ this -> emitter -> addLis...
Adds to the listeners array .
56,755
protected function processTags ( PHP_CodeSniffer_File $ file , $ stackPtr , $ commentStart ) { $ tokens = $ file -> getTokens ( ) ; $ type = strtolower ( $ tokens [ $ stackPtr ] [ 'content' ] ) ; $ firstComment = $ tokens [ $ commentStart + 5 ] [ 'content' ] ; if ( $ type === 'class' ) { if ( substr ( $ firstComment , ...
Process tags inside the comment block .
56,756
protected function process ( array $ data ) { $ config = array ( ) ; foreach ( $ data as $ section => $ value ) { if ( Arrays :: isArray ( $ value ) ) { if ( strpos ( $ section , $ this -> nestSeparator ) !== false ) { $ sections = explode ( $ this -> nestSeparator , $ section ) ; $ config = array_merge_recursive ( $ c...
Process data from the parsed ini file .
56,757
private function buildNestedSection ( $ sections , $ value ) { if ( count ( $ sections ) == 0 ) { return $ this -> processSection ( $ value ) ; } $ nestedSection = array ( ) ; $ first = array_shift ( $ sections ) ; $ nestedSection [ $ first ] = $ this -> buildNestedSection ( $ sections , $ value ) ; return $ nestedSect...
Process a nested section
56,758
protected function processSection ( array $ section ) { $ config = array ( ) ; foreach ( $ section as $ key => $ value ) { $ this -> processKey ( $ key , $ value , $ config ) ; } return $ config ; }
Process a section .
56,759
public static function saveToFile ( $ data , $ file ) { $ file = Yii :: getAlias ( $ file ) ; file_put_contents ( $ file , "<?php\nreturn " . VarDumper :: export ( $ data ) . ";\n" , LOCK_EX ) ; self :: invalidateScriptCache ( $ file ) ; }
Saves the authorization data to a PHP script file .
56,760
public function compilePattern ( $ key ) { $ items = $ this -> patterns [ $ key ] ; if ( is_array ( $ items ) ) { $ items = implode ( null , $ items ) ; } return String :: insert ( $ items , $ this -> regexInject ) ; }
A helper method to help compile patterns
56,761
public function isClassFromFile ( $ className , $ file ) { $ realFile = $ this -> getFileDeclaringClass ( $ className ) ; if ( $ file === $ realFile ) { return true ; } return $ realFile ; }
Check if a class originates from the passed file .
56,762
public function add ( $ loader , $ name = null ) { if ( empty ( $ name ) ) { $ name = 'loader.' . count ( $ this -> loaders ) ; } $ this -> loaders [ $ name ] = $ loader ; }
Register a class loader .
56,763
public function register ( $ prepend = false ) { spl_autoload_call ( 'PhpCodeQuality\AutoloadValidation\Exception\ClassNotFoundException' ) ; spl_autoload_call ( 'PhpCodeQuality\AutoloadValidation\Exception\ParentClassNotFoundException' ) ; $ this -> previousLoaders = spl_autoload_functions ( ) ; foreach ( $ this -> pr...
Register this instance as an auto loader .
56,764
public function unregister ( ) { foreach ( array_reverse ( $ this -> previousLoaders ) as $ previousLoader ) { spl_autoload_register ( $ previousLoader , true ) ; } spl_autoload_unregister ( array ( $ this , 'loadClass' ) ) ; }
Unregister this instance as an auto loader .
56,765
private static function findDeclarations ( $ filePath ) { $ gathered = array ( ) ; $ gatheringNamespace = false ; $ namespace = null ; $ tokens = token_get_all ( file_get_contents ( $ filePath ) ) ; foreach ( $ tokens as $ index => $ token ) { if ( $ gatheringNamespace ) { if ( isset ( $ token [ 1 ] ) ) $ namespace .= ...
Go through the file and return an array of autoloadable tokens present .
56,766
public function flush ( ) { foreach ( $ this -> buffer as $ data ) { $ this -> output -> write ( $ data [ 'messages' ] , $ data [ 'newline' ] , $ data [ 'options' ] ) ; } $ this -> buffer = [ ] ; }
Flushes the buffer .
56,767
public function make ( IPost $ post ) { $ post -> setResponse ( $ this -> response -> view ( \ OogleeBConfig :: get ( 'config.post_view.view' ) , compact ( 'post' ) ) ) ; }
Make the post response .
56,768
public static function create ( $ filename , $ open_mode = 'r' , $ use_include_path = false , $ context = null ) { return new static ( $ filename , $ open_mode , $ use_include_path , $ context ) ; }
Creates a new file object .
56,769
public static function createTempPath ( $ prefix = 'php-' ) { $ temp = tempnam ( sys_get_temp_dir ( ) , $ prefix ) ; if ( false === $ temp ) { throw new FileException ( 'A new temporary file could not be created.' ) ; } return $ temp ; }
Creates a new temporary file and returns its path .
56,770
public static function createTempPathNamed ( $ name ) { $ dir = static :: createTempPath ( ) ; if ( ! unlink ( $ dir ) ) { throw new FileException ( 'The temporary file could not be deleted.' ) ; } if ( ! mkdir ( $ dir ) ) { throw new FileException ( 'A new temporary directory could not be created.' ) ; } $ path = $ di...
Creates a new named temporary file and returns its path .
56,771
public function seed ( $ className , $ params ) { $ blueprint = new Blueprint ( ) ; $ consequence = $ params ; $ class = $ className ; if ( is_array ( $ params ) ) { if ( empty ( $ params [ 'do' ] ) ) { throw new \ InvalidArgumentException ( 'Fixture template not supplied.' ) ; } if ( ! empty ( $ params [ 'class' ] ) )...
Lets you define a blueprint for your class
56,772
public function retrieve ( $ className , $ attributeOverrides = array ( ) ) { $ factory = $ this -> getFactory ( $ className ) ; return $ factory -> make ( $ attributeOverrides ) ; }
Creates an instance of your class using your blueprint
56,773
public function retrieveList ( $ className , $ count , $ attributeOverrides = array ( ) ) { $ list = array ( ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ list [ ] = $ this -> retrieve ( $ className , $ attributeOverrides ) ; } return $ list ; }
Returns an array containing specified amount of model instances
56,774
public function savedList ( $ className , $ count , $ attributeOverrides = array ( ) ) { $ list = array ( ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ list [ ] = $ this -> saved ( $ className , $ attributeOverrides ) ; } return $ list ; }
Returns an array containing specified amount of persisted model instances
56,775
public function userCan ( $ permission , $ object , $ user = null ) { if ( is_null ( $ user ) ) { $ user = app ( 'auth' ) -> user ( ) ; } $ adminGroups = $ this -> groupProvider ( ) -> findAdminGroups ( ) ; if ( $ adminGroups -> count ( ) > 0 && $ user -> inGroup ( $ adminGroups ) ) return true ; $ permObject = $ this ...
Determines whether or not a user has some permission on a given object
56,776
public function allowUser ( $ permissions , $ object , $ user = null ) { if ( is_null ( $ user ) ) { $ user = app ( 'auth' ) -> user ( ) ; } if ( ! is_array ( $ permissions ) ) { $ permissions = array ( $ permissions ) ; } foreach ( $ permissions as $ permission ) { $ this -> allowSinglePermission ( $ permission , $ ob...
Give a user permissions to a specific object
56,777
protected function allowSinglePermission ( $ permission , $ object , $ user ) { $ permObject = $ this -> permission -> findByPermissionAndObject ( $ permission , $ object ) ; if ( ! $ permObject ) { $ listOfPermissions = $ object -> getPermissions ( ) ; if ( ! isset ( $ listOfPermissions [ $ permission ] ) ) { throw ne...
Give a user some permission to a specific object
56,778
public function disallowUser ( $ permissions , $ object , $ user = null ) { if ( is_null ( $ user ) ) { $ user = app ( 'auth' ) -> user ( ) ; } if ( ! is_array ( $ permissions ) ) { $ permissions = array ( $ permissions ) ; } foreach ( $ permissions as $ permission ) { $ this -> disallowSinglePermission ( $ permission ...
Remove a user s permissions to a specific object
56,779
protected function disallowSinglePermission ( $ permission , $ object , $ user ) { $ permObject = $ this -> permission -> findByPermissionAndObject ( $ permission , $ object ) ; $ uop = $ this -> userObjectPermission -> findPermission ( $ user , $ object , $ permObject ) ; if ( $ uop ) { $ this -> userObjectPermission ...
Remove a user s permission to a specific object
56,780
public function allowGroup ( $ permissions , $ object , $ group ) { if ( ! is_array ( $ permissions ) ) { $ permissions = array ( $ permissions ) ; } foreach ( $ permissions as $ permission ) { $ this -> allowSingleGroupPermission ( $ permission , $ object , $ group ) ; } }
Give a group permissions to a specific object
56,781
protected function allowSingleGroupPermission ( $ permission , $ object , $ group ) { $ permObject = $ this -> permission -> findByPermissionAndObject ( $ permission , $ object ) ; if ( ! $ permObject ) { $ listOfPermissions = $ object -> getPermissions ( ) ; if ( ! isset ( $ listOfPermissions [ $ permission ] ) ) { th...
Give a group some permission to a specific object
56,782
public function disallowGroup ( $ permissions , $ object , $ group ) { if ( ! is_array ( $ permissions ) ) { $ permissions = array ( $ permissions ) ; } foreach ( $ permissions as $ permission ) { $ this -> disallowSingleGroupPermission ( $ permission , $ object , $ group ) ; } }
Remove a group s permissions to a specific object
56,783
protected function disallowSingleGroupPermission ( $ permission , $ object , $ group ) { $ permObject = $ this -> permission -> findByPermissionAndObject ( $ permission , $ object ) ; if ( $ permObject ) { $ gop = $ this -> groupObjectPermission -> findPermission ( $ group , $ object , $ permObject ) ; if ( $ gop ) { $...
Remove a group s specific permission to a specific object
56,784
public function getPermissions ( User \ UserInterface $ user = null , $ object = null , $ permission = null ) { if ( is_null ( $ user ) ) { $ user = app ( 'auth' ) -> user ( ) ; } if ( is_null ( $ object ) && is_null ( $ permission ) ) { return $ this -> getPermissionsByUser ( $ user ) ; } $ permObject = null ; if ( ! ...
Returns permissions for a given user
56,785
protected function getPermissionsByUser ( User \ UserInterface $ user ) { $ userPerms = $ this -> userObjectPermission -> findByUser ( $ user ) ; $ groupPerms = $ this -> groupObjectPermission -> findByGroups ( $ user -> getGroups ( ) ) ; return $ userPerms -> merge ( $ groupPerms ) ; }
Returns all permissions for a given user
56,786
public function getUsers ( $ permission , $ object ) { $ permObject = $ this -> permission -> findByPermissionAndObject ( $ permission , $ object ) ; if ( ! $ permObject ) return array ( ) ; return $ this -> userObjectPermission -> findByObject ( $ permObject , $ object ) ; }
Returns users who have a given permission on an object
56,787
public function getGroups ( $ permission , $ object ) { $ permObject = $ this -> permission -> findByPermissionAndObject ( $ permission , $ object ) ; if ( ! $ permObject ) return array ( ) ; return $ this -> groupObjectPermission -> findByObject ( $ permObject , $ object ) ; }
Returns groups who have a given permission on an object
56,788
protected function parse ( ) { $ this -> checkFormat ( ) ; $ this -> parsePalmDb ( ) ; $ this -> parsePalmDoc ( ) ; $ this -> parseMobiHeader ( ) ; $ this -> parseExth ( ) ; }
Parse the file data .
56,789
protected function parsePalmDb ( ) { $ file = $ this -> file ; $ file -> fseek ( $ this -> palmDbHeaderStart ) ; $ content = $ file -> fread ( 2 ) ; $ records = hexdec ( bin2hex ( $ content ) ) ; $ this -> palmDbHeader = new PalmDbHeader ( ) ; for ( $ i = 0 ; $ i < $ records ; ++ $ i ) { $ this -> palmDbHeader -> addRe...
Parse the PalmDb records from the file .
56,790
protected function parsePalmDoc ( ) { if ( ! $ this -> palmDbHeader ) { return ; } $ file = $ this -> file ; $ firstPalmDbRecord = $ this -> palmDbHeader -> getIterator ( ) -> offsetGet ( 0 ) ; $ offset = $ firstPalmDbRecord -> getOffset ( ) ; $ this -> palmDocHeaderStart = $ offset ; $ file -> fseek ( $ offset ) ; $ t...
Parse the PalmDoc header from the file .
56,791
protected function parseMobiHeader ( ) { if ( ! $ this -> palmDocHeader ) { return ; } $ file = $ this -> file ; $ this -> mobiHeaderStart = $ file -> ftell ( ) + 2 ; $ file -> fseek ( $ this -> mobiHeaderStart ) ; if ( $ file -> fread ( 4 ) === 'MOBI' ) { $ this -> mobiHeader = new MobiHeader ( $ this -> readData ( $ ...
Parse the MOBI header from the file .
56,792
protected function parseExth ( ) { if ( ! $ this -> mobiHeader ) { return ; } $ file = $ this -> file ; $ file -> fseek ( $ this -> mobiHeaderStart + $ this -> mobiHeader -> getLength ( ) + 4 ) ; $ this -> exthHeader = new ExthHeader ( $ this -> readData ( $ file , 4 ) ) ; $ records = $ this -> readData ( $ file , 4 ) ...
Parse EXTH header from the file .
56,793
public static function validateString ( $ string ) { if ( is_string ( $ string ) || ( is_object ( $ string ) && method_exists ( $ string , '__toString' ) ) ) { return ( string ) $ string ; } throw new \ InvalidArgumentException ( 'Expected data must either be a string or stringable' ) ; }
Validate and return a string .
56,794
public function findHeaders ( $ name ) { return array_filter ( $ this -> getHeaders ( ) , function ( $ header ) use ( $ name ) { return StringType :: startsWith ( $ header , "$name:" ) ; } ) ; }
Find all headers matching the specified name .
56,795
public function addMethod ( $ name , Closure $ closure ) { if ( method_exists ( $ this , $ name ) ) { throw new Exception ( 'Overriding core methods not allowed.' ) ; } $ this -> methods [ $ name ] = $ closure ; }
Add a method to the container
56,796
public function register ( ServiceProviderInterface $ provider ) { $ provider -> register ( $ this ) ; $ this -> providers [ get_class ( $ provider ) ] = $ provider ; }
Register a Service Provider
56,797
public function run ( $ method = null , $ path = null ) { $ method = $ method ? : $ this -> request -> getMethod ( ) ; $ path = $ path ? : $ this -> request -> currentPath ( ) ; $ this -> dispatchRouter ( $ method , $ path ) -> send ( ) ; }
Run the application and dispatch the router
56,798
public function getArray ( ) { $ config = @ include $ this -> location ; if ( ! is_array ( $ config ) ) { throw new \ Exception ( 'Config not found' ) ; } $ this -> config = $ config ; return $ config ; }
Get the array from the given location in construct
56,799
private function setLocale ( ) { $ plugin_i18n = new AppIntegrationI18n ( ) ; $ plugin_i18n -> set_domain ( $ this -> get_plugin_name ( ) ) ; $ this -> loader -> add_action ( 'plugins_loaded' , $ plugin_i18n , 'load_plugin_textdomain' ) ; }
Define the locale for this plugin for internationalization .