idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
31,100
public static function getSubscribedEvents ( ) : array { return [ ScriptEvents :: POST_CREATE_PROJECT_CMD => 'copyProjectExtraFiles' , PackageEvents :: POST_PACKAGE_INSTALL => 'copyModuleFiles' , PackageEvents :: POST_PACKAGE_UPDATE => 'copyModuleFiles' , PackageEvents :: PRE_PACKAGE_UPDATE => 'removeModuleFiles' , PackageEvents :: PRE_PACKAGE_UNINSTALL => 'removeModuleFiles' , ] ; }
Registered events after the plugin is loaded
31,101
public function copyProjectExtraFiles ( Event $ event ) : void { $ extras = $ event -> getComposer ( ) -> getPackage ( ) -> getExtra ( ) ; if ( array_key_exists ( 'copy-files' , $ extras ) ) { $ this -> installer -> getIo ( ) -> write ( sprintf ( ' - Copied additional file(s)' ) , true ) ; $ this -> copyExtras ( $ extras [ 'copy-files' ] ) ; } }
Copy extra files from compose . json of project
31,102
public function copyModuleFiles ( PackageEvent $ event ) : void { $ package = $ this -> extractPackage ( $ event ) ; $ this -> packagePath = $ this -> vendorPath . DS . $ package -> getName ( ) ; if ( $ package -> getType ( ) === 'bluz-module' && file_exists ( $ this -> packagePath ) ) { if ( $ package -> getExtra ( ) && isset ( $ package -> getExtra ( ) [ 'copy-files' ] ) ) { $ this -> copyExtras ( $ package -> getExtra ( ) [ 'copy-files' ] ) ; } $ this -> copyModule ( ) ; } }
Hook which is called after install package It copies bluz module
31,103
public function removeModuleFiles ( PackageEvent $ event ) : void { $ package = $ this -> extractPackage ( $ event ) ; $ this -> packagePath = $ this -> vendorPath . DS . $ package -> getName ( ) ; if ( $ package -> getType ( ) === 'bluz-module' && file_exists ( $ this -> packagePath ) ) { if ( $ package -> getExtra ( ) && isset ( $ package -> getExtra ( ) [ 'copy-files' ] ) ) { $ this -> removeExtras ( $ package -> getExtra ( ) [ 'copy-files' ] ) ; } $ this -> removeModule ( ) ; } }
Hook which is called before update package It checks bluz module
31,104
protected function copyModule ( ) : void { foreach ( self :: DIRECTORIES as $ directory ) { $ this -> copy ( $ this -> packagePath . DS . $ directory . DS , PATH_ROOT . DS . $ directory . DS ) ; } $ this -> installer -> getIo ( ) -> write ( sprintf ( ' - Copied <comment>%s</comment> module to application' , basename ( $ this -> packagePath ) ) , true ) ; }
Copy Module files
31,105
protected function copy ( $ source , $ target ) : void { if ( ! file_exists ( $ source ) ) { return ; } if ( is_file ( $ target ) && ! is_dir ( $ target ) ) { $ this -> installer -> getIo ( ) -> write ( sprintf ( ' - File <comment>%s</comment> already exists' , $ target ) , true , IOInterface :: VERBOSE ) ; return ; } $ isRenameFile = substr ( $ target , - 1 ) !== '/' && ! is_dir ( $ source ) ; if ( file_exists ( $ target ) && ! is_dir ( $ target ) && ! $ isRenameFile ) { throw new \ InvalidArgumentException ( 'Destination directory is not a directory' ) ; } try { if ( $ isRenameFile ) { $ this -> getFilesystem ( ) -> mkdir ( \ dirname ( $ target ) ) ; } else { $ this -> getFilesystem ( ) -> mkdir ( $ target ) ; } } catch ( IOException $ e ) { throw new \ InvalidArgumentException ( sprintf ( 'Could not create directory `%s`' , $ target ) ) ; } if ( false === file_exists ( $ source ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Source directory or file `%s` does not exist' , $ source ) ) ; } if ( is_dir ( $ source ) ) { $ finder = new Finder ; $ finder -> files ( ) -> in ( $ source ) ; foreach ( $ finder as $ file ) { try { $ this -> getFilesystem ( ) -> copy ( $ file , $ target . DS . $ file -> getRelativePathname ( ) ) ; } catch ( IOException $ e ) { throw new \ InvalidArgumentException ( sprintf ( 'Could not copy `%s`' , $ file -> getBaseName ( ) ) ) ; } } } else { try { if ( $ isRenameFile ) { $ this -> getFilesystem ( ) -> copy ( $ source , $ target ) ; } else { $ this -> getFilesystem ( ) -> copy ( $ source , $ target . '/' . basename ( $ source ) ) ; } } catch ( IOException $ e ) { throw new \ InvalidArgumentException ( sprintf ( 'Could not copy `%s`' , $ source ) ) ; } } $ this -> installer -> getIo ( ) -> write ( sprintf ( ' - Copied file(s) from <comment>%s</comment> to <comment>%s</comment>' , $ source , $ target ) , true , IOInterface :: VERBOSE ) ; }
It recursively copies the files and directories
31,106
protected function removeModule ( ) : void { foreach ( self :: DIRECTORIES as $ directory ) { $ this -> remove ( $ directory ) ; } $ this -> installer -> getIo ( ) -> write ( sprintf ( ' - Removed <comment>%s</comment> module from application' , basename ( $ this -> packagePath ) ) , true ) ; }
It recursively removes the files and empty directories
31,107
protected function remove ( $ directory ) : void { $ sourcePath = $ this -> packagePath . DS . $ directory ; if ( ! is_dir ( $ sourcePath ) ) { return ; } foreach ( $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ sourcePath , \ RecursiveDirectoryIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: CHILD_FIRST ) as $ item ) { $ current = PATH_ROOT . DS . $ directory . DS . $ iterator -> getSubPathName ( ) ; if ( is_dir ( $ current ) ) { if ( \ count ( scandir ( $ current , SCANDIR_SORT_ASCENDING ) ) === 2 ) { rmdir ( $ current ) ; $ this -> installer -> getIo ( ) -> write ( " - Removed directory `{$iterator->getSubPathName()}`" , true , IOInterface :: VERBOSE ) ; } else { $ this -> installer -> getIo ( ) -> write ( sprintf ( ' - <comment>Skipped directory `%s`</comment>' , $ directory . DS . $ iterator -> getSubPathName ( ) ) , true , IOInterface :: VERBOSE ) ; } continue ; } if ( ! is_file ( $ current ) ) { continue ; } if ( md5_file ( $ item ) === md5_file ( $ current ) ) { unlink ( $ current ) ; $ this -> installer -> getIo ( ) -> write ( " - Removed file `{$iterator->getSubPathName()}`" , true , IOInterface :: VERBOSE ) ; } else { $ this -> installer -> getIo ( ) -> write ( " - <comment>File `{$iterator->getSubPathName()}` has changed</comment>" , true , IOInterface :: VERBOSE ) ; } } }
It recursively removes the files and directories
31,108
protected static function startTimer ( $ includeWalltime = true ) { if ( $ includeWalltime ) { self :: $ starttime = $ _SERVER [ 'REQUEST_TIME' ] ; } else { self :: $ starttime = microtime ( true ) ; } }
Starts the timer for measurement .
31,109
protected static function initFilesystem ( $ virtualized = false ) { self :: $ registry -> setFilesystem ( Doozr_Loader_Serviceloader :: load ( 'filesystem' , $ virtualized ) ) ; return true ; }
Initializes the filesystem access .
31,110
protected static function initDependencyInjection ( ) { $ collection = new Doozr_Di_Collection ( ) ; $ importer = new Doozr_Di_Importer_Json ( ) ; $ dependency = new Doozr_Di_Dependency ( ) ; $ map = new Doozr_Di_Map_Static ( $ collection , $ importer , $ dependency ) ; $ map -> generate ( self :: $ registry -> getParameter ( 'doozr.directory.root' ) . 'Data/Private/Config/.map.json' ) ; $ container = Doozr_Di_Container :: getInstance ( ) ; $ container -> factory ( new Doozr_Di_Factory ( self :: $ registry ) ) -> map ( $ map ) ; self :: $ registry -> setContainer ( $ container ) ; return true ; }
Initialize the Dependency - Injection container and load the map for wiring from a static JSON - representation .
31,111
protected static function initLogging ( ) { self :: $ registry -> getContainer ( ) -> getMap ( ) -> wire ( [ 'doozr.datetime.service' => Doozr_Loader_Serviceloader :: load ( 'datetime' ) , ] ) ; $ logger = self :: $ registry -> getContainer ( ) -> build ( 'doozr.logging' ) ; $ logger -> attach ( self :: $ registry -> getContainer ( ) -> build ( 'doozr.logging.collecting' ) ) ; self :: $ registry -> setLogging ( $ logger ) ; return true ; }
Initializes the logging - manager of the Doozr Framework . The first initialized logging is of type collecting . So it collects all entries as long as the configuration isn t parsed and the real configured loggers are attached .
31,112
protected static function initPath ( ) { self :: $ registry -> setPath ( Doozr_Path :: getInstance ( self :: $ registry -> getParameter ( 'doozr.directory.root' ) ) ) ; return true ; }
Initializes the path - manager of the Doozr Framework . The path - manager returns always the correct path to predefined parts of the framework and it is also cappable of combining paths in correct slashed writing .
31,113
protected static function initConfiguration ( ) { $ caching = self :: $ registry -> getParameter ( 'doozr.kernel.caching' ) ; $ namespace = self :: $ registry -> getParameter ( 'doozr.namespace.flat' ) . '.cache.configuration' ; $ cache = Doozr_Loader_Serviceloader :: load ( 'cache' , self :: $ registry -> getParameter ( 'doozr.kernel.caching.container' ) , $ namespace , [ ] , self :: $ registry -> getParameter ( 'doozr.unix' ) , $ caching ) ; self :: $ registry -> getContainer ( ) -> getMap ( ) -> wire ( [ 'doozr.configuration.reader.json' => new Doozr_Configuration_Reader_Json ( Doozr_Loader_Serviceloader :: load ( 'filesystem' ) , $ cache , $ caching ) , 'doozr.cache.service' => $ cache , ] ) ; $ configuration = self :: $ registry -> getContainer ( ) -> build ( 'doozr.configuration' , [ $ caching , ] ) ; $ configuration -> read ( self :: $ registry -> getPath ( ) -> get ( 'configuration' ) . '.config.json' ) ; $ serviceConfigurationFiles = self :: retrieveServiceConfigurationFiles ( ) ; foreach ( $ serviceConfigurationFiles as $ serviceConfigurationFile ) { $ configuration -> read ( $ serviceConfigurationFile ) ; } $ userlandConfigurationFiles = self :: retrieveUserlandConfigurationFiles ( ) ; foreach ( $ userlandConfigurationFiles as $ userlandConfigurationFile ) { $ configuration -> read ( $ userlandConfigurationFile ) ; } self :: $ registry -> setConfiguration ( $ configuration ) ; if ( true === self :: $ registry -> getParameter ( 'doozr.kernel.debugging' ) ) { self :: $ registry -> getDebugbar ( ) -> addCollector ( new DebugBar \ DataCollector \ ConfigCollector ( json_decode ( json_encode ( self :: $ registry -> getConfiguration ( ) -> get ( ) ) , true ) ) ) ; } return true ; }
Initialize and prepare the configuration used for running the framework and the app .
31,114
protected static function configureLogging ( ) { $ collectingLogger = self :: $ registry -> getLogging ( ) -> getLogger ( 'collecting' ) ; $ collection = $ collectingLogger -> getCollectionRaw ( ) ; if ( true === self :: $ registry -> getParameter ( 'doozr.kernel.logging' ) ) { self :: $ registry -> getLogging ( ) -> detachAll ( true ) ; foreach ( self :: $ registry -> getConfiguration ( ) -> kernel -> logging -> logger as $ logger ) { $ loggerInstance = self :: $ registry -> getContainer ( ) -> build ( 'doozr.logging.' . strtolower ( $ logger -> name ) , [ ( isset ( $ logger -> level ) ) ? $ logger -> level : self :: $ registry -> getLogging ( ) -> getDefaultLoglevel ( ) , ] ) ; self :: $ registry -> getLogging ( ) -> attach ( $ loggerInstance ) ; } foreach ( $ collection as $ key => $ entry ) { self :: $ registry -> getLogging ( ) -> log ( $ entry [ 'type' ] , $ entry [ 'message' ] , unserialize ( $ entry [ 'context' ] ) , $ entry [ 'time' ] , $ entry [ 'fingerprint' ] , $ entry [ 'separator' ] ) ; } } else { self :: $ registry -> getLogging ( ) -> detachAll ( true ) ; } return true ; }
Configures logging . It attaches the real configured loggers from configuration and removes the collecting logging . This method also injects the collected entries into the new attached loggers .
31,115
protected static function initResponse ( ) { if ( true === self :: $ registry -> getParameter ( 'doozr.kernel.debugging' ) ) { self :: $ registry -> getDebugbar ( ) [ 'time' ] -> startMeasure ( 'preparing-response' , 'Preparing response' ) ; } self :: $ registry -> setResponse ( self :: $ registry -> getContainer ( ) -> build ( 'Doozr_Response_' . self :: $ registry -> getParameter ( 'doozr.kernel.runtime.environment' ) ) ) ; if ( true === self :: $ registry -> getParameter ( 'doozr.kernel.debugging' ) ) { self :: $ registry -> getDebugbar ( ) [ 'time' ] -> stopMeasure ( 'preparing-response' ) ; } return true ; }
Initialize the response state .
31,116
protected static function stopTimer ( ) { self :: $ kernelExecutionTime = self :: getDateTime ( ) -> getMicrotimeDiff ( self :: $ starttime ) ; self :: $ registry -> getLogging ( ) -> debug ( 'Kernel execution time: ' . self :: $ kernelExecutionTime . ' seconds' ) ; }
Stops the timer for measurements and log the core - execution time .
31,117
protected static function getDateTime ( ) { if ( null === self :: $ dateTime ) { self :: $ dateTime = Doozr_Loader_Serviceloader :: load ( 'datetime' ) ; } return self :: $ dateTime ; }
Returns instance of Datetime module .
31,118
protected function buildErrorResponse ( Response $ response , $ statusCode , $ statusMessage , $ expose = false ) { if ( $ statusCode < 200 || $ statusCode > 510 ) { $ statusCode = 500 ; } $ body = new Doozr_Response_Body ( 'php://memory' , 'w' ) ; if ( false === $ expose ) { $ statusMessage = constant ( 'Doozr_Http::REASONPHRASE_' . $ statusCode ) ; } $ body -> write ( '<h1>' . $ statusMessage . '</h1>' ) ; return $ response -> withStatus ( $ statusCode , $ statusMessage ) -> withBody ( $ body ) ; }
Returns a prepared response with error message and HTTP status code set .
31,119
protected static function filterRequest ( Request $ request , $ filters ) { $ tmp = [ ] ; foreach ( $ filters as $ filter ) { $ tmp [ ] = $ filter ; } $ filter = new \ Doozr_Filter ( $ tmp ) ; return $ request -> withUri ( $ request -> getUri ( ) -> withPath ( $ filter -> apply ( $ request -> getUri ( ) -> getPath ( ) ) ) ) ; }
Filters the request base URI to filter development and debugging stuff .
31,120
public function import ( array $ recipe ) { foreach ( $ recipe as $ key => $ value ) { $ method = 'set' . ucfirst ( $ key ) ; if ( false === is_callable ( [ $ this , $ method ] ) ) { throw new Doozr_Di_Exception ( sprintf ( 'Property not supported: "%s"' , $ key ) ) ; } $ this -> { $ method } ( $ value ) ; } }
Generic import for recipes .
31,121
public function asArray ( ) { return [ 'id' => $ this -> getId ( ) , 'className' => $ this -> getClassName ( ) , 'instance' => $ this -> getInstance ( ) , 'arguments' => $ this -> getArguments ( ) , 'type' => $ this -> getType ( ) , 'target' => $ this -> getTarget ( ) , 'position' => $ this -> getPosition ( ) , ] ; }
Returns the current dependency as array .
31,122
public function offsetSet ( $ offset , $ value ) { if ( true === is_null ( $ offset ) ) { $ this -> className = $ value ; } else { $ this -> { $ offset } = $ value ; } }
Implements offsetSet .
31,123
private function resolveType ( BlockTypeInterface $ type ) { $ typeExtensions = [ ] ; $ parentType = $ type -> getParent ( ) ; $ fqcn = \ get_class ( $ type ) ; foreach ( $ this -> extensions as $ extension ) { $ typeExtensions = array_merge ( $ typeExtensions , $ extension -> getTypeExtensions ( $ fqcn ) ) ; } return $ this -> resolvedTypeFactory -> createResolvedType ( $ type , $ typeExtensions , $ parentType ? $ this -> getType ( $ parentType ) : null ) ; }
Wraps a type into a ResolvedBlockTypeInterface implementation and connects it with its parent type .
31,124
protected static function removeFormatOfDateTimeString ( ? string $ v , string $ dateMask ) : ? \ DateTime { if ( is_string ( $ v ) === true && self :: checkDateTime ( $ v , static :: RegExp , $ dateMask ) === true ) { if ( $ dateMask === "HH:mm:ss" || $ dateMask === "HH:mm" ) { $ v = "2000-01-01 " . $ v ; $ dateMask = "yyyy-MM-dd " . $ dateMask ; } return TryParse :: toDateTime ( $ v , $ dateMask ) ; } return null ; }
Devolve um objeto DateTime para uma string passada em um determinado formato .
31,125
public function buildOpReturnForIssuance ( $ raw_amount , $ asset , $ divisible , $ description , $ txid ) { $ amount_hex = $ this -> paddedRawAmountHex ( $ raw_amount ) ; $ asset_hex = $ this -> padHexString ( $ this -> assetNameToIDHex ( $ asset ) , 8 ) ; $ divisible_hex = $ this -> padHexString ( ( $ divisible ? 1 : 0 ) , 1 ) ; $ call_data_hex = '000000000000000000' ; $ description_hex = unpack ( 'H*0' , $ description ) [ 0 ] ; $ description_len_hex = $ this -> padHexString ( dechex ( strlen ( $ description_hex ) / 2 ) , 1 ) ; $ data_hex = $ asset_hex . $ amount_hex . $ divisible_hex . $ call_data_hex . $ description_len_hex . $ description_hex ; if ( strlen ( $ data_hex ) > 160 ) { throw new Exception ( "Description too long" , 1 ) ; } return $ this -> assembleCounterpartyOpReturn ( 20 , $ data_hex , $ txid ) ; }
description should be 41 characters or less
31,126
public function close ( ) { $ this -> started = false ; \ Wslim \ Ioc :: logger ( 'session' ) -> debug ( sprintf ( '[%s]close' , static :: getId ( ) ) ) ; }
Saves and closes the session
31,127
public function regenerate ( $ destroy = false , $ lifetime = null ) { if ( ! $ this -> isStarted ( ) ) { return false ; } if ( null !== $ lifetime ) { ini_set ( 'session.cookie_lifetime' , $ lifetime ) ; } \ Wslim \ Ioc :: logger ( 'session' ) -> debug ( sprintf ( '[%s]regenerate' , static :: getId ( ) ) ) ; return session_regenerate_id ( $ destroy ) ; }
Regenerates the session
31,128
public function get ( $ key , $ default = null ) { $ this -> start ( ) ; $ value = isset ( $ _SESSION [ $ key ] ) ? $ _SESSION [ $ key ] : '' ; \ Wslim \ Ioc :: logger ( 'session' ) -> debug ( sprintf ( '[%s]get %s:%s' , static :: getId ( ) , $ key , print_r ( $ value , true ) ) ) ; return $ value ; }
Read session information for the given name
31,129
public function set ( $ key , $ value = null ) { $ this -> start ( ) ; $ _SESSION [ $ key ] = $ value ; $ sdata = is_scalar ( $ key ) ? [ $ key => $ value ] : $ key ; \ Wslim \ Ioc :: logger ( 'session' ) -> debug ( sprintf ( '[%s]set %s:%s' , static :: getId ( ) , $ key , print_r ( $ value , true ) ) ) ; return $ this ; }
Writes the given session information to the given name
31,130
protected function factory ( $ class , $ path , $ arguments = null ) { include_once $ path . 'Service' . DIRECTORY_SEPARATOR . str_replace ( '_' , DIRECTORY_SEPARATOR , $ class ) . '.php' ; if ( $ arguments ) { return self :: instantiate ( $ class , $ arguments ) ; } else { return new $ class ( ) ; } }
This method is intend to act as factory for creating an instance of a configuration container .
31,131
public function actionIndex ( ) { if ( $ this -> confirm ( 'Do you want to update RBAC configuration?' ) ) { $ this -> stdout ( 'Performing RBAC update...' . "\n" ) ; $ installer = new Installer ( ) ; $ installer -> update ( $ this -> module -> configData ( ) ) ; $ this -> stdout ( 'RBAC configuration up to date!' . "\n" , Console :: FG_GREEN ) ; } }
RBAC configuration installation
31,132
public function update ( $ data , $ user_id , $ updatePassword = true ) { $ fields = array ( 'ID' => $ user_id ) ; if ( AD_UPDATE_NAME && isset ( $ data -> displayname ) && ! empty ( $ data -> displayname ) ) { $ name = $ this -> format :: parseDisplayName ( $ data -> displayname , $ data ) ; $ fields [ 'first_name' ] = $ name [ 'firstname' ] ; $ fields [ 'last_name' ] = $ name [ 'lastname' ] ; $ fields [ 'display_name' ] = $ name [ 'firstname' ] . " " . $ name [ 'lastname' ] ; } if ( isset ( $ data -> mail ) && is_email ( $ data -> mail ) && AD_UPDATE_EMAIL ) { $ fields [ 'user_email' ] = strtolower ( $ data -> mail ) ; } if ( $ updatePassword === true ) { $ user = get_user_by ( 'ID' , $ user_id ) ; if ( $ user && ! AD_RANDOM_PASSWORD && AD_SAVE_PASSWORD && isset ( $ _POST [ 'pwd' ] ) && ! empty ( $ _POST [ 'pwd' ] ) ) { if ( ! wp_check_password ( $ _POST [ 'pwd' ] , $ user -> data -> user_pass , $ user -> ID ) ) { $ fields [ 'user_pass' ] = $ _POST [ 'pwd' ] ; } } elseif ( AD_RANDOM_PASSWORD ) { $ passUpdated = get_user_meta ( $ user_id , 'pass_updated' , true ) ; if ( $ passUpdated == false || strtotime ( $ passUpdated ) < strtotime ( 'now - 3 month' ) ) { $ fields [ 'user_pass' ] = wp_generate_password ( ) ; update_user_meta ( $ user_id , 'pass_updated' , current_time ( 'mysql' ) ) ; } } } if ( count ( $ fields ) != 1 ) { wp_update_user ( $ fields ) ; } if ( AD_UPDATE_META && ( is_object ( $ data ) || is_array ( $ data ) ) ) { foreach ( ( array ) $ data as $ meta_key => $ meta_value ) { if ( ! in_array ( $ meta_key , apply_filters ( 'adApiWpIntegration/profile/disabledMetaKey' , array ( "sn" , "samaccountname" , "mail" , "userprincipalname" ) ) ) ) { update_user_meta ( $ user_id , AD_META_PREFIX . apply_filters ( 'adApiWpIntegration/profile/metaKey' , $ meta_key ) , $ meta_value ) ; } } } update_user_meta ( $ user_id , AD_META_PREFIX . apply_filters ( 'adApiWpIntegration/profile/metaKey' , "last_sync" ) , date ( "Y-m-d H:i:s" ) ) ; }
Update user profile details
31,133
private function hydrate ( ) { $ query = clone $ this -> query ; foreach ( array ( 'orders' , 'limit' , 'offset' ) as $ field ) { $ query -> getQuery ( ) -> { $ field } = null ; } $ this -> total = $ query -> count ( ) ; $ query = clone $ this -> query ; $ this -> entries = $ query -> get ( ) ; $ this -> items = $ this -> entries -> all ( ) ; }
Hydrate the datas .
31,134
public function setKeytype ( $ keytype ) { if ( in_array ( $ keytype , $ this -> allowedKeytypes ) === false ) { throw new Doozr_Form_Service_Exception ( 'Passed keytype: "' . $ keytype . '" is not allowed or invalid.' ) ; } $ this -> setAttribute ( 'keytype' , $ keytype ) ; }
Setter for keytype .
31,135
private function sendPushNotification ( $ fields ) { $ url = 'https://fcm.googleapis.com/fcm/send' ; $ headers = array ( 'Authorization: key=' . $ this -> api_key , 'Content-Type: application/json' ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_POST , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , json_encode ( $ fields ) ) ; curl_setopt ( $ ch , CURLINFO_HEADER_OUT , true ) ; $ info = curl_getinfo ( $ ch ) ; $ result = curl_exec ( $ ch ) ; if ( $ result === FALSE ) { die ( 'Curl failed: ' . curl_error ( $ ch ) ) ; } curl_close ( $ ch ) ; return $ result ; }
function makes curl request to gcm servers
31,136
static function Rotate ( array $ array , $ startIndex ) { $ startArray = array_slice ( $ array , 0 , $ startIndex , true ) ; $ endArray = array_slice ( $ array , $ startIndex , null , true ) ; return array_merge ( $ endArray , $ startArray ) ; }
Rotates the array result begins with given index items before are appended
31,137
public function Check ( $ value ) { if ( $ this -> trimValue ) $ value = trim ( $ value ) ; $ result = array ( ) ; if ( ! preg_match ( $ this -> pattern , $ value ) ) $ this -> error = self :: NoMatch ; return $ this -> error == '' ; }
Checks the value against the pattern of this reg exp validator
31,138
static function HexRGB ( $ noHash = false , $ errorlLabelPrefix = '' , $ trimValue = true ) { $ regStart = $ noHash ? '' : '#' ; return new self ( "/^" . $ regStart . "[A-Fa-f0-9]{6}$/" , $ errorlLabelPrefix , $ trimValue ) ; }
Reg Exp validator for six characters rgb color hex codes
31,139
protected function registerAutoloader ( $ app ) { $ autoloaderApp = new Doozr_Loader_Autoloader_Spl_Config ( ) ; $ autoloaderApp -> _namespace ( $ app -> namespace ) -> namespaceSeparator ( '_' ) -> addExtension ( 'php' ) -> path ( substr ( $ app -> path , 0 , - 1 ) ) -> description ( 'Autoloader for App classes with namespace: "' . $ app -> namespace . '"' ) -> priority ( 0 ) ; Doozr_Loader_Autoloader_Spl_Facade :: attach ( [ $ autoloaderApp ] ) ; }
Registers an autoloader instance SPL with highest priority for loading classes of the app .
31,140
public function update ( $ data = null ) { if ( $ this -> hasMethod ( '__update' ) && is_callable ( [ $ this , '__update' ] ) ) { return $ this -> __update ( $ data ) ; } $ this -> notify ( ) ; }
Update of crUd .
31,141
protected function delete ( $ data = null ) { if ( $ this -> hasMethod ( '__delete' ) && is_callable ( [ $ this , '__delete' ] ) ) { return $ this -> __delete ( $ data ) ; } $ this -> notify ( ) ; }
Delete of cruD .
31,142
protected function isRequired ( $ argument , $ scope = 'Index' , $ method = Doozr_Http :: REQUEST_METHOD_GET ) { if ( false === isset ( $ this -> required [ $ method ] ) ) { return false ; } if ( false === isset ( $ this -> required [ $ method ] [ $ scope ] ) ) { return false ; } if ( false === is_array ( $ argument ) ) { $ argument = [ $ argument ] ; } foreach ( $ argument as $ requiredVariable ) { pre ( $ requiredVariable ) ; } return true ; }
Returns TRUE if a passed arguments is required by presenter FALSE if not .
31,143
protected function getRequired ( $ scope = 'Index' , $ method = Doozr_Http :: REQUEST_METHOD_GET ) { if ( ! isset ( $ this -> required [ $ method ] ) ) { return [ ] ; } if ( ! isset ( $ this -> required [ $ method ] [ $ scope ] ) ) { return [ ] ; } return $ this -> required [ $ method ] [ $ scope ] ; }
Returns all required fields of presenter .
31,144
public function match ( Context $ context ) { $ name = $ this -> getName ( $ context ) ; if ( $ this -> map -> hasRoute ( $ name ) ) { return $ this -> map -> getRoute ( $ name ) ; } return false ; }
Get a route based on command context
31,145
private function sessionExpiry ( ) { $ dateTime = new DateTime ( ) ; if ( null !== $ this -> sessionOptions [ 'SessionExpiry' ] ) { $ expiryDateTime = new DateTime ( $ _SESSION [ 'Expiry' ] ) ; $ expiryDateTime -> add ( new DateInterval ( $ this -> sessionOptions [ 'SessionExpiry' ] ) ) ; if ( $ expiryDateTime < $ dateTime ) { $ this -> destroy ( ) ; } } }
Expire session after a specified time .
31,146
protected function view ( $ name , array $ data = array ( ) ) { $ tpl = $ this -> viewEngine -> template ( $ name ) ; $ tpl -> vars -> add ( $ data ) ; return $ tpl -> render ( ) ; }
Render Template View
31,147
public function setCode ( $ code ) { $ this -> code = trim ( $ code ) ; $ this -> codeLength = strlen ( $ this -> code ) ; return $ this ; }
Sets the code to be compressed .
31,148
protected function read ( ) { while ( $ this -> currentPosition < $ this -> codeLength ) { $ startPosition = $ this -> currentPosition ; $ currentChar = $ this -> code { $ this -> currentPosition } ; if ( in_array ( $ currentChar , $ this -> whitespaces ) ) { $ this -> readWhitespace ( ) ; } else { switch ( $ currentChar ) { case '/' : { $ this -> readSlash ( ) ; break ; } case '#' : { $ this -> readDirective ( ) ; break ; } case '"' : { $ this -> readString ( ) ; break ; } } } if ( $ this -> currentPosition === $ startPosition ) { $ this -> compressedCode .= $ currentChar ; ++ $ this -> currentPosition ; } } }
Reads and handles the current character of the code .
31,149
protected function readSlash ( ) { if ( $ this -> currentPosition + 1 < $ this -> codeLength ) { $ nextChar = $ this -> code { $ this -> currentPosition + 1 } ; if ( $ nextChar === '/' ) { $ this -> skipUntil ( "\n" ) ; } elseif ( $ nextChar === '*' ) { $ this -> skipUntil ( '*/' ) ; } } }
Reads and handles a slash in the code .
31,150
protected function readString ( ) { $ startPosition = $ this -> currentPosition ; ++ $ this -> currentPosition ; while ( $ this -> currentPosition < $ this -> codeLength ) { $ currentChar = $ this -> code { $ this -> currentPosition } ; if ( $ currentChar === '\\' ) { $ this -> currentPosition += 2 ; } elseif ( $ currentChar === '"' ) { break ; } else { ++ $ this -> currentPosition ; } } ++ $ this -> currentPosition ; $ this -> compressedCode .= substr ( $ this -> code , $ startPosition , $ this -> currentPosition - $ startPosition ) ; }
Reads and handles a quoted string .
31,151
protected function copyUntil ( $ string ) { $ newPosition = $ this -> find ( $ string ) ; $ this -> compressedCode .= substr ( $ this -> code , $ this -> currentPosition , $ newPosition - $ this -> currentPosition ) ; $ this -> currentPosition = $ newPosition ; }
Copies some code to the compressed code without modification . The current position will be after the specified string .
31,152
protected function skipWhitespace ( ) { while ( $ this -> currentPosition < $ this -> codeLength && in_array ( $ this -> code { $ this -> currentPosition } , $ this -> whitespaces ) ) { ++ $ this -> currentPosition ; } }
Skips any whitespace characters .
31,153
protected function find ( $ string ) { $ position = strpos ( $ this -> code , $ string , $ this -> currentPosition ) ; if ( $ position === false ) { $ position = $ this -> codeLength ; } return $ position ; }
Finds the next position of the specified string .
31,154
protected function isWhitespaceRequired ( ) { $ result = false ; if ( ! empty ( $ this -> compressedCode ) && $ this -> currentPosition < $ this -> codeLength ) { $ compressedLength = strlen ( $ this -> compressedCode ) ; $ lastChar = $ this -> compressedCode { $ compressedLength - 1 } ; $ nextChar = $ this -> code { $ this -> currentPosition } ; if ( $ lastChar === '}' && $ nextChar === '}' && $ compressedLength >= 2 ) { $ secondLastChar = $ this -> compressedCode { $ compressedLength - 2 } ; $ result = ( $ secondLastChar === '}' ) ; } else { $ result = ! in_array ( $ lastChar , $ this -> ignoreFollowingWhitespace ) && ! in_array ( $ nextChar , $ this -> ignoreFollowingWhitespace ) ; } } return $ result ; }
Checks whether a whitespace is required at the current position of the compressed code .
31,155
public function search ( ) { if ( ! Input :: has ( 'q' ) ) { return $ this -> jsonErrorResponse ( '"q" is required.' ) ; } $ options = $ this -> getParams ( 'offset' , 'limit' , 'includes' , 'order_by' ) ; $ products = Subbly :: api ( 'subbly.product' ) -> searchBy ( Input :: get ( 'q' ) , $ options ) ; return $ this -> jsonCollectionResponse ( 'products' , $ products , array ( 'query' => Input :: get ( 'q' ) , ) ) ; }
Search one or many Product .
31,156
public function show ( $ id ) { $ options = $ this -> getParams ( 'includes' ) ; $ product = Subbly :: api ( 'subbly.product' ) -> find ( $ id , $ options ) ; return $ this -> jsonResponse ( array ( 'product' => $ this -> presenter -> single ( $ product ) , ) ) ; }
Get Product datas .
31,157
public function refreshData ( $ token , $ data = null ) { $ key = $ token ; if ( $ key ) { $ data = static :: formatData ( $ data ) ; $ sdata = static :: getStorage ( ) -> get ( $ key ) ; if ( $ sdata ) { $ data = array_merge ( $ sdata , $ data ) ; } $ data [ '_expire_time_' ] = time ( ) + static :: getExpire ( ) ; static :: getStorage ( ) -> set ( $ key , $ data ) ; } }
refresh token rel data
31,158
public function clearExpired ( ) { if ( $ this -> options [ 'cache' ] ) { $ keys = Ioc :: cache ( $ this -> options [ 'name' ] ) -> clearExpired ( ) ; } return ErrorInfo :: success ( $ this -> options [ 'name' ] . ' clear success: ' . $ count . ' items' ) ; }
clear expired token
31,159
public function attachMemberTagMember ( User $ user , Member $ member ) { return $ user -> selected_context -> id === $ member -> id ; }
Allow User to add Member to their selected context
31,160
public function detachMemberTagMember ( User $ user , Member $ member ) { return $ user -> selected_context -> id === $ member -> id ; }
Allow User to remove their selected context from Member
31,161
public function getAll ( array $ getters ) { foreach ( $ getters as $ getter ) { if ( ! is_a ( $ getter , Getter :: class ) ) { continue ; } $ this -> get ( $ getter ) ; } }
Get from all getters specified
31,162
public function get ( Getter $ getter ) { for ( $ year = ( int ) date ( 'Y' ) ; $ year > 1900 ; $ year -- ) { if ( $ this -> checkYear ( $ year ) and $ this -> getYear ( $ getter , $ year ) ) { $ this -> addTime ( 60 ) ; sleep ( 1 * 60 ) ; } } }
Get all the data from the getter and saves what is not in the database .
31,163
public function checkYear ( int $ year ) { $ y = date ( 'Y' ) ; if ( $ y == $ year ) { return false ; } $ d1 = \ Model :: factory ( UF :: class ) -> whereLike ( 'fecha' , $ year . '%' ) -> count ( 'id' ) ; $ d0 = Carbon :: parse ( $ year . '-01-01' ) ; if ( $ d1 = ( 365 + $ d0 -> format ( 'L' ) ) ) { return true ; } return false ; }
Checks if the year is saved in the database .
31,164
public function listGetters ( ) { $ data = config ( 'getters.uf' ) ; $ getters = [ ] ; foreach ( $ data as $ get ) { $ getters [ ] = new $ get [ 'class' ] ( ) ; } return $ getters ; }
Get an array of getters in the configuration
31,165
public function registerBundles ( ) { $ bundles [ ] = new Symfony \ Bundle \ FrameworkBundle \ FrameworkBundle ( ) ; $ bundles [ ] = new Symfony \ Bundle \ SecurityBundle \ SecurityBundle ( ) ; $ bundles [ ] = new Symfony \ Bundle \ TwigBundle \ TwigBundle ( ) ; $ bundles [ ] = new Symfony \ Bundle \ MonologBundle \ MonologBundle ( ) ; $ bundles [ ] = new Doctrine \ Bundle \ DoctrineBundle \ DoctrineBundle ( ) ; $ bundles [ ] = new Splash \ Bundle \ SplashBundle ( ) ; $ bundles [ ] = new Splash \ Connectors \ Faker \ FakerBundle ( ) ; if ( in_array ( $ this -> getEnvironment ( ) , array ( 'dev' , 'test' ) , true ) ) { $ bundles [ ] = new Symfony \ Bundle \ DebugBundle \ DebugBundle ( ) ; if ( 'dev' === $ this -> getEnvironment ( ) ) { $ bundles [ ] = new Symfony \ Bundle \ WebProfilerBundle \ WebProfilerBundle ( ) ; } if ( ( 'dev' === $ this -> getEnvironment ( ) ) && class_exists ( '\\Symfony\\Bundle\\WebServerBundle\\WebServerBundle' ) ) { $ bundles [ ] = new Symfony \ Bundle \ WebServerBundle \ WebServerBundle ( ) ; } } return $ bundles ; }
Register Symfony Bundles
31,166
protected function getHistory ( $ key = null ) { return ( true === isset ( $ this -> history [ $ key ] ) ) ? $ this -> history [ $ key ] : null ; }
Getter for history .
31,167
protected function restoreState ( ) { foreach ( $ this -> getIniKeys ( ) as $ key ) { ini_set ( $ key , $ this -> getHistory ( $ key ) ) ; } return $ this ; }
Restores a state from array input .
31,168
public function install ( ) { if ( true !== $ this -> isInstalled ( ) ) { try { $ this -> dumpState ( ) -> installed ( true ) -> makeVerbose ( ) -> whoops ( new Run ( ) ) -> installWhoops ( ) -> getLogger ( ) -> debug ( 'Debugging tools installed.' ) ; } catch ( Doozr_Debugging_Exception $ exception ) { $ this -> installed ( false ) -> uninstallWhoops ( ) -> restoreState ( ) ; throw new Doozr_Debugging_Exception ( sprintf ( 'Debugging could not be installed! Error: %s' , $ exception -> getMessage ( ) ) ) ; } } else { throw new Doozr_Debugging_Exception ( 'Debugging is already installed!' ) ; } return $ this ; }
Enables debugging by making the system verbose and by enabling PHP to fetch all errors notice and so on .
31,169
public function uninstall ( ) { if ( true === $ this -> isInstalled ( ) ) { try { $ this -> installed ( false ) -> uninstallWhoops ( ) -> whoops ( null ) -> restoreState ( ) -> getLogger ( ) -> debug ( 'Debugging tools uninstalled.' ) ; } catch ( Doozr_Debugging_Exception $ exception ) { throw new Doozr_Debugging_Exception ( sprintf ( 'Debugging could not be uninstalled! Error: %s' , $ exception -> getMessage ( ) ) ) ; } } else { throw new Doozr_Debugging_Exception ( 'Debugging could not be uninstalled. It\'s not installed!' ) ; } }
Uninstalls debugging handler .
31,170
protected function installWhoops ( ) { if ( true === $ this -> isCli ( ) ) { $ exceptionHandler = new PlainTextHandler ( ) ; } else { $ exceptionHandler = new PrettyPageHandler ( ) ; $ constants = get_defined_constants ( ) ; $ exceptionHandler -> setPageTitle ( 'Doozr' ) ; $ data = [ ] ; foreach ( $ constants as $ key => $ value ) { if ( 'DOOZR_' === substr ( $ key , 0 , 6 ) ) { $ data [ $ key ] = ( true === is_bool ( $ value ) ) ? ( ( true === $ value ) ? 'TRUE' : 'FALSE' ) : $ value ; } } ksort ( $ data ) ; $ exceptionHandler -> addDataTable ( 'Doozr Environment' , $ data ) ; } $ this -> getWhoops ( ) -> pushHandler ( $ exceptionHandler ) ; $ this -> getWhoops ( ) -> register ( ) ; return $ this ; }
Installs whoops exception handler .
31,171
protected function makeVerbose ( $ errorReporting = PHP_INT_MAX , $ iniValue = 1 ) { error_reporting ( $ errorReporting ) ; foreach ( $ this -> getIniKeys ( ) as $ key ) { ini_set ( $ key , $ iniValue ) ; } return $ this ; }
Makes PHP verbose to get at much debugging output as possible .
31,172
private function FlagsString ( ) { $ result = '' ; foreach ( $ this -> flags as $ flag ) { if ( $ result ) { $ result .= ',' ; } $ result .= $ flag -> ToString ( ) ; } if ( $ result ) { $ result = '[' . $ result . ']' ; } return $ result ; }
Converts flags to string
31,173
private function preparedUpdate ( $ data , $ where ) { $ sqldata = empty ( $ data ) ? $ this -> _ar : $ data ; $ sql = $ this -> dealUpdateSQL ( $ this -> GetTable ( ) , $ sqldata , $ where ) ; $ phl = $ this -> dbh -> prepare ( $ sql ) ; $ res = $ phl -> execute ( $ sqldata ) ; $ this -> initialize ( ) ; return $ res ; }
prepared Update func
31,174
private function NotPreparedUpdate ( $ data , $ where ) { $ sqldata = empty ( $ data ) ? $ this -> _ar : $ data ; $ sql = $ this -> dealUpdateSQL ( $ this -> GetTable ( ) , $ sqldata , $ where , false ) ; return $ this -> exec ( $ sql ) ; }
not prepared Update func
31,175
public function all ( $ param = true ) { $ this -> isAr = true ; if ( $ this -> isPretreatment ) { self :: $ Pre = $ this -> bindSql ( ) ; if ( ! $ param ) return self :: $ Pre -> queryString ; return $ this -> dbh -> pall ( self :: $ Pre ) ; } $ bind = $ this -> bindSql ( ) ; if ( ! $ param ) return $ this -> PrintSQL ( ) ; $ this -> initialize ( ) ; return $ bind -> all ( ) ; }
Grabbing all the data
31,176
public function one ( $ param = true ) { $ this -> isAr = true ; if ( $ this -> isPretreatment ) { self :: $ Pre = $ this -> bindSql ( ) ; if ( ! $ param ) return self :: $ Pre -> queryString ; return $ this -> dbh -> pone ( $ this -> bindSql ( ) ) ; } $ bind = $ this -> bindSql ( ) ; if ( ! $ param ) return $ this -> PrintSQL ( ) ; $ this -> initialize ( ) ; return $ bind -> one ( ) ; }
Grabbing One the Data
31,177
public function getAsQuery ( $ forCount = false ) { $ table = $ model = null ; if ( $ this -> model ) { $ model = $ this -> model ; $ table = $ model :: getTableName ( ) ; } $ join = $ this -> getJoin ( $ forCount ) ; $ group = ( $ group = $ this -> getGroup ( ) ) ? ' GROUP BY ' . $ group : '' ; $ having = ( $ having = $ this -> getHaving ( ) ) ? ' HAVING ' . $ having : '' ; $ order = ( $ order = $ this -> getOrder ( ) ) ? ' ORDER BY ' . $ order : '' ; $ limit = ( $ limit = $ this -> getLimit ( ) ) ? ' LIMIT ' . $ limit : '' ; $ procedure = ( $ procedure = $ this -> getProcedure ( ) ) ? ' PROCEDURE ' . $ procedure : '' ; $ into = ( $ into = $ this -> getInto ( ) ) ? ' INTO ' . $ into : '' ; $ for_update = $ this -> for_update ? ' FOR UPDATE' : '' ; $ lock_in_share_mode = $ this -> lock_in_share_mode ? ' LOCK IN SHARE MODE' : '' ; $ q = ( $ this -> model ? "SELECT " . $ this -> getSelect ( ) . " FROM `$table` as `t` " : "" ) . $ join . " WHERE " . $ this -> getCondition ( ) . $ group . $ having . $ order . $ limit . $ procedure . $ into . $ for_update . $ lock_in_share_mode ; return $ q ; }
Get as string query .
31,178
public function forDelete ( $ deleteOptions = [ ] ) { $ table = $ model = null ; if ( $ this -> model ) { $ model = $ this -> model ; $ table = $ model :: getTableName ( ) ; } $ join = $ this -> getJoin ( ) ; $ order = ( $ order = $ this -> getOrder ( ) ) ? ' ORDER BY ' . $ order : '' ; $ limit = ( $ limit = $ this -> getLimit ( ) ) ? ' LIMIT ' . $ limit : '' ; $ options = implode ( " " , $ deleteOptions ) ; $ q = ( $ this -> model ? "DELETE $options FROM `t` USING `$table` as `t` " : "" ) . $ join . " WHERE (" . $ this -> getCondition ( ) . ")" . $ order . $ limit ; return $ q ; }
Get query For Delete
31,179
public function compareColumns ( $ column1 , $ column2 , $ partial = false , $ link = 'AND' ) { $ this -> conditionColumns [ ] = $ column2 ; $ this -> conditionColumns [ ] = $ column1 ; if ( is_array ( $ column2 ) ) { foreach ( $ column2 as & $ col ) $ col = $ this -> _column ( $ col ) ; return $ this -> addCondition ( $ this -> _column ( $ column1 ) . ' IN (' . implode ( ', ' , $ column2 ) . ')' , array ( ) , $ link ) ; } if ( $ partial ) { return $ this -> addCondition ( $ this -> _column ( $ column1 ) . ' LIKE CONCAT("%", ' . $ this -> _column ( $ column2 ) . ' , "%")' , array ( ) , $ link ) ; } $ operators = array ( '>=' , '<=' , '!=' , '>' , '<' ) ; $ matched = false ; foreach ( $ operators as $ operator ) { if ( $ operator == substr ( $ column2 , 0 , strlen ( $ operator ) ) ) { $ column2 = trim ( substr ( $ column2 , strlen ( $ operator ) ) ) ; $ matched = true ; break ; } } $ operator = $ matched ? $ operator : '=' ; return $ this -> addCondition ( $ this -> _column ( $ column1 ) . ' ' . $ operator . ' ' . $ this -> _column ( $ column2 ) , array ( ) , $ link ) ; }
Same as compareColumn but instead of value another column is used .
31,180
public function addInCondition ( $ column , $ values , $ link = 'AND' ) { $ this -> conditionColumns [ ] = $ column ; return $ this -> compareColumn ( $ column , $ values , false , $ link ) ; }
This is a shortcut to compareColumn when only multiple values can be sent .
31,181
public function addBetweenCondition ( $ column , $ start , $ end , $ link = 'AND' ) { $ this -> conditionColumns [ ] = $ column ; return $ this -> addCondition ( $ this -> _column ( $ column ) . ' BETWEEN ' . $ this -> _param ( $ column , $ start ) . ' AND ' . $ this -> _param ( $ column , $ end ) , array ( ) , $ link ) ; }
Adds a new condition that compares value of a column be between to other values .
31,182
public function addInSelectCondition ( $ column , $ query , $ params = array ( ) , $ link = 'AND' ) { $ this -> conditionColumns [ ] = $ column ; return $ this -> addCondition ( $ this -> _column ( $ column ) . ' IN (' . $ query . ')' , $ params , $ link ) ; }
Add a new condition to search a column in the result of a query ; Will create a subselect in the condition ;
31,183
public function addIsNullCondition ( $ column ) { $ this -> conditionColumns [ ] = $ column ; return $ this -> addCondition ( $ this -> _column ( $ column ) . " IS NULL" ) ; }
Checks if a column is null
31,184
public function addIsNotNullCondition ( $ column ) { $ this -> conditionColumns [ ] = $ column ; return $ this -> addCondition ( $ this -> _column ( $ column ) . " IS NOT NULL" ) ; }
Checks if a column is not null
31,185
public function addCondition ( $ condition , $ params = array ( ) , $ link = 'AND' ) { if ( is_array ( $ condition ) ) { $ condition = $ this -> _fromArray ( $ condition ) ; } if ( ! $ this -> condition ) { $ this -> condition = $ condition ; $ this -> setParams ( $ params ) ; return $ this ; } $ this -> condition = '(' . $ this -> condition . ') ' . $ link . ' (' . $ condition . ')' ; $ this -> setParams ( $ params ) ; return $ this ; }
Adds another condition to the current one .
31,186
public function getJoin ( $ forCount = false ) { if ( ! $ this -> with ) { return $ this -> join ; } if ( ! $ this -> relationsParser ) { $ this -> relationsParser = RelationsParser :: parse ( $ this -> model , $ this , $ this -> conditionColumns ) ; } return ( $ forCount ? $ this -> relationsParser -> getForCount ( ) : $ this -> relationsParser -> getForMainSelect ( ) ) . ' ' . $ this -> join ; }
Get join info query for current condition ;
31,187
public function getExtraRelations ( $ models ) { if ( ! $ this -> relationsParser ) { return [ ] ; } $ relationsLeft = $ this -> relationsParser -> getRelationsToBeSelectedSeparately ( ) ; foreach ( $ relationsLeft as $ path => $ details ) { $ this -> relationsParser -> getChildrenForModels ( $ models , $ path , $ details , $ this -> fields ) ; } }
Return list of relations that were not selected in main query .
31,188
public function getSelect ( ) { if ( $ this -> fields && $ this -> fields != '*' && ( ! ( is_string ( $ this -> fields ) && '*' == $ this -> fields [ 0 ] && 'END) AS `__parentRelationKey`' == substr ( $ this -> fields , - 29 ) ) ) ) { if ( is_string ( $ this -> fields ) ) { return $ this -> fields ; } $ columns = array ( ) ; foreach ( $ this -> fields as $ field ) { $ columns [ ] = trim ( $ field ) ; } return implode ( ', ' , $ columns ) ; } if ( ( is_string ( $ this -> fields ) && '*' == $ this -> fields [ 0 ] && 'END) AS `__parentRelationKey`' == substr ( $ this -> fields , - 29 ) ) ) { return implode ( ', ' , $ this -> getAllColumnsForSelect ( ) ) . substr ( $ this -> fields , 1 ) ; } else { return implode ( ', ' , $ this -> getAllColumnsForSelect ( ) ) ; } }
Get fields for select ; If model is set then the fields are processed so that it will return the data in a way that can be used to generate the models .
31,189
public function getLimit ( ) { if ( false !== strpos ( $ this -> limit , ',' ) ) return $ this -> limit ; return $ this -> limit ? $ this -> limit . ' OFFSET ' . $ this -> offset : '' ; }
Return SQL limit ;
31,190
public static function getFrom ( $ condition , $ model ) { if ( is_a ( $ condition , '\\mpf\datasources\\sql\\ModelCondition' ) ) { $ condition -> model = $ model ; return $ condition ; } if ( is_array ( $ condition ) && count ( $ condition ) ) $ cond = new static ( $ condition ) ; else { $ cond = new static ; if ( $ condition ) $ cond -> addCondition ( $ condition ) ; } $ cond -> model = $ model ; return $ cond ; }
Get ModelCondition or subclass from a condition that can be string or array or another condition object in wich case it will return that object ;
31,191
protected function getAllColumnsForSelect ( ) { $ with = is_array ( $ this -> with ) ? $ this -> with : ( $ this -> with ? explode ( ',' , $ this -> with ) : array ( ) ) ; if ( ! count ( $ with ) ) return [ '*' ] ; $ model = $ this -> model ; $ db = $ model :: getDb ( ) ; $ columns = $ this -> _columnsForModel ( $ model :: getTableName ( ) , $ db ) ; foreach ( $ this -> relationsParser -> getListOfSelectedRelations ( ) as $ name => $ relation ) { $ cols = $ this -> _columnsForRelation ( $ relation , $ db , $ name ) ; foreach ( $ cols as $ column ) { $ columns [ ] = $ column ; } } return $ columns ; }
Return list of columns to select from current tables ;
31,192
function setPageNum ( $ page_number ) { $ this -> page = $ page_number ; if ( ! is_numeric ( $ this -> page ) || $ this -> page < 1 ) { $ this -> page = 1 ; } if ( $ this -> total !== null ) { $ this -> sanitizePageNum ( ) ; } }
Sets the current page number
31,193
function getOffset ( ) { $ offset = ( $ this -> getPageNum ( ) * $ this -> limit ) - $ this -> limit ; if ( $ offset < 0 ) { $ offset = 0 ; } return $ offset ; }
Gets the offset for a query
31,194
function getTotal ( ) { if ( $ this -> total === null ) { $ q = clone $ this -> query ; $ q -> setLimit ( null ) ; $ q -> setOffset ( null ) ; if ( $ this -> className ) { $ total = call_user_func ( array ( $ this -> className , 'doCount' ) , $ q ) ; } else { $ total = $ q -> doCount ( ) ; } $ this -> total = $ total ; } return $ this -> total ; }
Gets the count of the results of the query
31,195
function getEnd ( ) { $ end = $ this -> getPageNum ( ) * $ this -> limit ; if ( $ end > $ this -> getTotal ( ) ) return $ this -> getTotal ( ) ; return $ end ; }
Gets the number of the last record on the page
31,196
function getPageCount ( ) { if ( ! $ this -> limit ) { return 1 ; } $ rem = ( $ this -> getTotal ( ) % $ this -> limit ) ; $ rem = ( $ rem >= 0 ) ? $ rem : 0 ; $ total_pages = ( $ this -> getTotal ( ) - $ rem ) / $ this -> limit ; if ( $ rem ) $ total_pages ++ ; return $ total_pages ; }
Gets the total number of pages
31,197
public static function getUser ( $ user_id ) { $ sql = new Pluf_SQL ( 'login=%s' , array ( $ user_id ) ) ; return Pluf :: factory ( 'User' ) -> getOne ( $ sql -> gen ( ) ) ; }
Given a user id retrieve it .
31,198
function freeze ( ) { $ this -> frozen = array ( ) ; $ this -> frozenRoutes = array ( ) ; $ this -> application -> boot ( ) ; $ this -> application -> flush ( ) ; $ this -> application [ 'debug' ] = true ; $ this -> application [ 'exception_handler' ] -> disable ( ) ; $ output = $ this -> application [ 'freezer.destination' ] ; if ( ! is_dir ( $ output ) ) { mkdir ( $ output , 0755 , true ) ; } $ routes = array ( ) ; foreach ( $ this -> generators as $ g ) { foreach ( $ g ( ) as $ route ) { $ routes [ ] = $ route ; } } $ route = null ; foreach ( $ routes as $ route ) { if ( is_array ( $ route ) ) { $ routeName = $ route [ 0 ] ; $ params = @ $ route [ 1 ] ? : array ( ) ; $ this -> freezeRoute ( $ routeName , $ params ) ; } else { $ this -> freezeUrl ( ( string ) $ route ) ; } } }
Freezes the application and writes the generated files to the destination directory .
31,199
function freezeUrl ( $ url ) { if ( in_array ( $ url , $ this -> frozen ) ) { return ; } $ client = new HttpKernel \ Client ( $ this -> application ) ; $ client -> request ( 'GET' , $ url ) ; $ response = $ client -> getResponse ( ) ; if ( ! $ response -> isOk ( ) ) { return ; } $ destination = $ this -> application [ 'freezer.destination' ] . $ this -> getFileName ( $ url ) ; if ( ! is_dir ( dirname ( $ destination ) ) ) { mkdir ( dirname ( $ destination ) , 0755 , true ) ; } file_put_contents ( $ destination , $ response -> getContent ( ) ) ; $ this -> frozen [ ] = $ url ; }
Freezes a given URL