idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
35,100
public function validate ( array $ options = array ( ) ) { $ validated = false ; if ( $ validator = $ this -> getValidator ( ) ) { $ validated = $ this -> _validator -> validate ( $ options ) ; if ( $ this -> xpdo -> getDebug ( ) === true ) { $ this -> xpdo -> log ( xPDO :: LOG_LEVEL_DEBUG , "Validator class executed, ...
Validate the field values using an xPDOValidator .
35,101
public function isValidated ( $ key = '' ) { $ unvalidated = array_diff ( $ this -> _dirty , $ this -> _validated ) ; if ( empty ( $ key ) ) { $ validated = ( count ( $ unvalidated ) > 0 ) ; } else { $ validated = ! in_array ( $ this -> getField ( $ key ) , $ unvalidated ) ; } return $ validated ; }
Indicates if the object or specified field has been validated .
35,102
public function isLazy ( $ key = '' ) { $ lazy = false ; if ( empty ( $ key ) ) { $ lazy = ( count ( $ this -> _lazy ) > 0 ) ; } else { $ key = $ this -> getField ( $ key , true ) ; if ( $ key !== false ) { $ lazy = in_array ( $ key , $ this -> _lazy ) ; } } return $ lazy ; }
Indicates if the object or specified field is lazy .
35,103
protected function _getRelatedObjectsByFK ( $ alias , $ criteria = null , $ cacheFlag = true ) { $ collection = array ( ) ; if ( isset ( $ this -> _relatedObjects [ $ alias ] ) && ( is_object ( $ this -> _relatedObjects [ $ alias ] ) || ( is_array ( $ this -> _relatedObjects [ $ alias ] ) && ! empty ( $ this -> _relate...
Gets related objects by a foreign key and specified criteria .
35,104
protected function _initFields ( ) { foreach ( $ this -> _fieldMeta as $ k => $ v ) { $ this -> fieldNames [ $ k ] = $ this -> xpdo -> escape ( $ this -> _table ) . '.' . $ this -> xpdo -> escape ( $ k ) ; } }
Initializes the field names with the qualified table name .
35,105
public function toJSON ( $ keyPrefix = '' , $ rawValues = false ) { $ json = '' ; $ array = $ this -> toArray ( $ keyPrefix , $ rawValues ) ; if ( $ array ) { $ json = $ this -> xpdo -> toJSON ( $ array ) ; } return $ json ; }
Returns a JSON representation of the object .
35,106
public function fromJSON ( $ jsonSource , $ keyPrefix = '' , $ setPrimaryKeys = false , $ rawValues = false , $ adhocValues = false ) { $ array = $ this -> xpdo -> fromJSON ( $ jsonSource , true ) ; if ( $ array ) { $ this -> fromArray ( $ array , $ keyPrefix , $ setPrimaryKeys , $ rawValues , $ adhocValues ) ; } else ...
Sets the object fields from a JSON object string .
35,107
public function encode ( $ source , $ type = 'md5' ) { if ( ! is_string ( $ source ) || empty ( $ source ) ) { $ this -> xpdo -> log ( xPDO :: LOG_LEVEL_ERROR , 'xPDOObject::encode() -- Attempt to encode source data that is not a string (or is empty); encoding skipped.' ) ; return $ source ; } switch ( $ type ) { case ...
Encodes a string using the specified algorithm .
35,108
public function setDirty ( $ key = '' ) { if ( empty ( $ key ) ) { foreach ( array_keys ( $ this -> _fieldMeta ) as $ fIdx => $ fieldKey ) { $ this -> setDirty ( $ fieldKey ) ; } } else { $ key = $ this -> getField ( $ key , true ) ; if ( $ key !== false ) { $ this -> _dirty [ $ key ] = $ key ; if ( isset ( $ this -> _...
Add the field to a collection of field keys that have been modified .
35,109
protected function _getDataType ( $ key ) { $ type = 'text' ; $ actualKey = $ this -> getField ( $ key , true ) ; if ( $ actualKey !== false && isset ( $ this -> _fieldMeta [ $ actualKey ] [ 'dbtype' ] ) ) { $ type = strtolower ( $ this -> _fieldMeta [ $ actualKey ] [ 'dbtype' ] ) ; } elseif ( $ this -> xpdo -> getDebu...
Gets the database data type for the specified field .
35,110
protected function _setRaw ( $ key , $ val ) { $ set = false ; if ( $ val === null ) { $ this -> _fields [ $ key ] = null ; $ set = true ; } else { $ phptype = $ this -> _getPHPType ( $ key ) ; $ dbtype = $ this -> _getDataType ( $ key ) ; switch ( $ phptype ) { case 'int' : case 'integer' : case 'boolean' : $ this -> ...
Set a raw value on a field converted to the appropriate type .
35,111
protected function _getAliases ( $ class , $ limit = 0 ) { $ aliases = array ( ) ; $ limit = intval ( $ limit ) ; $ array = array ( 'aggregates' => $ this -> _aggregates , 'composites' => $ this -> _composites ) ; foreach ( $ array as $ relType => $ relations ) { foreach ( $ relations as $ alias => $ def ) { if ( isset...
Find aliases for any defined object relations of the specified class .
35,112
protected function fetch ( ) { $ row = $ this -> stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ; if ( is_array ( $ row ) && ! empty ( $ row ) ) { $ instance = $ this -> xpdo -> call ( $ this -> class , '_loadInstance' , array ( & $ this -> xpdo , $ this -> class , $ this -> alias , $ row ) ) ; if ( $ instance === null ) { $ t...
Fetch the next row from the result set and set it as current .
35,113
protected function _executeScript ( & $ transport , $ options ) { $ installed = false ; $ vOptions = $ this -> get ( $ transport , $ options ) ; if ( isset ( $ vOptions [ 'object' ] ) && isset ( $ vOptions [ 'object' ] [ 'source' ] ) ) { $ object = $ vOptions [ 'object' ] ; if ( $ this -> validate ( $ transport , $ obj...
Execute the script represented by and stored in this vehicle .
35,114
public static function isValidClause ( $ clause ) { $ output = rtrim ( $ clause , ' ;' ) ; $ output = preg_replace ( "/\\\\'.*?\\\\'/" , '{mask}' , $ output ) ; $ output = preg_replace ( '/\\".*?\\"/' , '{mask}' , $ output ) ; $ output = preg_replace ( "/'.*?'/" , '{mask}' , $ output ) ; $ output = preg_replace ( '/".*...
Make sure a clause is valid and does not contain SQL injection attempts .
35,115
public function command ( $ command = 'SELECT' ) { $ command = strtoupper ( trim ( $ command ) ) ; if ( preg_match ( '/(SELECT|UPDATE|DELETE)/' , $ command ) ) { $ this -> query [ 'command' ] = $ command ; if ( in_array ( $ command , array ( 'DELETE' , 'UPDATE' ) ) ) $ this -> _alias = $ this -> xpdo -> getTableName ( ...
Set the type of SQL command you want to build .
35,116
public function distinct ( $ on = null ) { if ( $ on === null ) { if ( empty ( $ this -> query [ 'distinct' ] ) || $ this -> query [ 'distinct' ] !== 'DISTINCT' ) { $ this -> query [ 'distinct' ] = 'DISTINCT' ; } else { $ this -> query [ 'distinct' ] = '' ; } } else { $ this -> query [ 'distinct' ] = $ on == true ? 'DI...
Set the DISTINCT attribute of the query .
35,117
public function select ( $ columns = '*' ) { if ( ! is_array ( $ columns ) ) { $ columns = trim ( $ columns ) ; if ( $ columns == '*' || $ columns === $ this -> _alias . '.*' || $ columns === $ this -> xpdo -> escape ( $ this -> _alias ) . '.*' ) { $ columns = $ this -> xpdo -> getSelectColumns ( $ this -> _class , $ t...
Specify columns to return from the SQL query .
35,118
public function join ( $ class , $ alias = '' , $ type = xPDOQuery :: SQL_JOIN_CROSS , $ conditions = array ( ) , $ conjunction = xPDOQuery :: SQL_AND , $ binding = null , $ condGroup = 0 ) { if ( $ this -> xpdo -> loadClass ( $ class ) ) { $ alias = $ alias ? $ alias : $ class ; $ target = & $ this -> query [ 'from' ]...
Join a table represented by the specified class .
35,119
public function from ( $ class , $ alias = '' ) { if ( $ class = $ this -> xpdo -> loadClass ( $ class ) ) { $ alias = $ alias ? $ alias : $ class ; $ this -> query [ 'from' ] [ 'tables' ] [ ] = array ( 'table' => $ this -> xpdo -> getTableName ( $ class ) , 'alias' => $ alias ) ; } return $ this ; }
Add a FROM clause to the query .
35,120
public function condition ( & $ target , $ conditions = '1' , $ conjunction = xPDOQuery :: SQL_AND , $ binding = null , $ condGroup = 0 ) { $ condGroup = intval ( $ condGroup ) ; if ( ! isset ( $ target [ $ condGroup ] ) ) $ target [ $ condGroup ] = array ( ) ; try { $ target [ $ condGroup ] [ ] = $ this -> parseCondit...
Add a condition to the query .
35,121
public function sortby ( $ column , $ direction = 'ASC' ) { if ( ! in_array ( strtoupper ( $ direction ) , array ( 'ASC' , 'DESC' , 'ASCENDING' , 'DESCENDING' ) , true ) ) { $ direction = '' ; } if ( ! static :: isValidClause ( $ column ) ) { $ this -> xpdo -> log ( xPDO :: LOG_LEVEL_ERROR , 'SQL injection attempt dete...
Add an ORDER BY clause to the query .
35,122
public function bindGraph ( $ graph ) { if ( is_string ( $ graph ) ) { $ graph = $ this -> xpdo -> fromJSON ( $ graph ) ; } if ( is_array ( $ graph ) ) { if ( $ this -> graph !== $ graph ) { $ this -> graph = $ graph ; $ this -> select ( $ this -> xpdo -> getSelectColumns ( $ this -> _class , $ this -> _alias , $ this ...
Bind an object graph to the query .
35,123
public function bindGraphNode ( $ parentClass , $ parentAlias , $ classAlias , $ relations ) { if ( $ fkMeta = $ this -> xpdo -> getFKDefinition ( $ parentClass , $ classAlias ) ) { $ class = $ fkMeta [ 'class' ] ; $ local = $ fkMeta [ 'local' ] ; $ foreign = $ fkMeta [ 'foreign' ] ; $ this -> select ( $ this -> xpdo -...
Bind the node of an object graph to the query .
35,124
public function hydrateGraph ( $ rows , $ cacheFlag = true ) { $ instances = array ( ) ; $ collectionCaching = $ this -> xpdo -> getOption ( xPDO :: OPT_CACHE_DB_COLLECTIONS , array ( ) , 1 ) ; if ( is_object ( $ rows ) ) { if ( $ cacheFlag && $ this -> xpdo -> _cacheEnabled && $ collectionCaching > 0 ) { $ cacheRows =...
Hydrates a graph of related objects from a single result set .
35,125
public function hydrateGraphNode ( & $ row , & $ instance , $ alias , $ relations ) { $ relObj = null ; if ( $ relationMeta = $ instance -> getFKDefinition ( $ alias ) ) { if ( $ row [ $ alias . '_' . $ relationMeta [ 'foreign' ] ] != null ) { $ relObj = $ this -> xpdo -> call ( $ relationMeta [ 'class' ] , '_loadInsta...
Hydrates a node of the object graph .
35,126
public function prepare ( $ bindings = array ( ) , $ byValue = true , $ cacheFlag = null ) { $ this -> stmt = null ; if ( $ this -> construct ( ) && $ this -> stmt = $ this -> xpdo -> prepare ( $ this -> sql ) ) { $ this -> bind ( $ bindings , $ byValue , $ cacheFlag ) ; } else { $ this -> xpdo -> log ( xPDO :: LOG_LEV...
Prepares the xPDOQuery for execution .
35,127
public function isConditionalClause ( $ string ) { $ matched = false ; if ( is_string ( $ string ) ) { if ( ! static :: isValidClause ( $ string ) ) { throw new xPDOException ( "SQL injection attempt detected: {$string}" ) ; } foreach ( $ this -> _operators as $ operator ) { if ( strpos ( strtoupper ( $ string ) , $ op...
Determines if a string contains a conditional operator .
35,128
public function buildConditionalClause ( $ conditions , & $ conjunction = xPDOQuery :: SQL_AND , $ isFirst = true ) { $ clause = '' ; if ( is_array ( $ conditions ) ) { $ groups = count ( $ conditions ) ; $ currentGroup = 1 ; $ first = true ; $ origConjunction = $ conjunction ; $ groupConjunction = $ conjunction ; fore...
Builds conditional clauses from xPDO condition expressions .
35,129
public function wrap ( $ criteria ) { if ( $ criteria instanceof xPDOQuery ) { $ this -> _class = $ criteria -> _class ; $ this -> _alias = $ criteria -> _alias ; $ this -> graph = $ criteria -> graph ; $ this -> query = $ criteria -> query ; } $ this -> sql = $ criteria -> sql ; $ this -> stmt = $ criteria -> stmt ; $...
Wrap an existing xPDOCriteria into this xPDOQuery instance .
35,130
public function connect ( $ driverOptions = array ( ) ) { if ( $ this -> pdo === null ) { if ( is_array ( $ driverOptions ) && ! empty ( $ driverOptions ) ) { $ this -> config [ 'driverOptions' ] = array_merge ( $ this -> config [ 'driverOptions' ] , $ driverOptions ) ; } try { $ this -> pdo = new \ PDO ( $ this -> con...
Actually make a connection for this instance via PDO .
35,131
public function getOption ( $ key , $ options = null , $ default = null ) { if ( is_array ( $ options ) ) { $ options = array_merge ( $ this -> config , $ options ) ; } else { $ options = $ this -> config ; } return $ this -> xpdo -> getOption ( $ key , $ options , $ default ) ; }
Get an option set for this xPDOConnection instance .
35,132
public static function parseSignature ( $ signature ) { $ exploded = explode ( '-' , $ signature ) ; $ name = current ( $ exploded ) ; $ version = '' ; $ part = next ( $ exploded ) ; while ( $ part !== false ) { $ dotPos = strpos ( $ part , '.' ) ; if ( $ dotPos > 0 && is_numeric ( substr ( $ part , 0 , $ dotPos ) ) ) ...
Parse the name and version from a package signature .
35,133
public static function compareSignature ( $ signature1 , $ signature2 ) { $ value = false ; $ parsed1 = self :: parseSignature ( $ signature1 ) ; $ parsed2 = self :: parseSignature ( $ signature2 ) ; if ( $ parsed1 [ 0 ] === $ parsed2 [ 0 ] ) { $ value = version_compare ( $ parsed1 [ 1 ] , $ parsed2 [ 1 ] ) ; } return ...
Compares two package versions by signature .
35,134
public static function _pack ( & $ xpdo , $ filename , $ path , $ source ) { $ packed = false ; $ packResults = false ; $ errors = array ( ) ; if ( $ xpdo -> getOption ( xPDOTransport :: ARCHIVE_WITH , null , 0 ) != xPDOTransport :: ARCHIVE_WITH_PCLZIP && class_exists ( 'ZipArchive' ) ) { if ( $ xpdo -> getDebug ( ) ==...
Pack the resources from path relative to source into an archive with filename .
35,135
public function writeManifest ( ) { $ written = false ; if ( ! empty ( $ this -> vehicles ) ) { if ( ! empty ( $ this -> attributes [ 'setup-options' ] ) && is_array ( $ this -> attributes [ 'setup-options' ] ) ) { $ cacheManager = $ this -> xpdo -> getCacheManager ( ) ; $ cacheManager -> copyFile ( $ this -> attribute...
Write the package manifest file .
35,136
public function getDependencies ( array $ requires = array ( ) ) { $ requiresAttribute = $ this -> getAttribute ( 'requires' ) ; if ( is_array ( $ requiresAttribute ) ) { $ requires = array_merge ( $ requiresAttribute , $ requires ) ; } return $ requires ; }
Get dependency requirements for this xPDOTransport .
35,137
public static function checkPlatformDependencies ( $ dependencies ) { if ( is_array ( $ dependencies ) ) { foreach ( $ dependencies as $ depName => $ depRequire ) { switch ( $ depName ) { case 'php' : if ( self :: satisfies ( PHP_VERSION , $ depRequire ) ) { unset ( $ dependencies [ $ depName ] ) ; } break ; default : ...
Check if any specified platform dependencies are satisfied .
35,138
public static function satisfies ( $ version , $ constraint ) { $ satisfied = false ; $ constraint = trim ( $ constraint ) ; if ( substr ( $ constraint , 0 , 1 ) === '~' ) { $ requirement = substr ( $ constraint , 1 ) ; $ constraint = ">={$requirement},<" . self :: nextSignificantRelease ( $ requirement ) ; } if ( strp...
Test if a version satisfies a version constraint .
35,139
public static function nextSignificantRelease ( $ version ) { $ parsed = explode ( '.' , $ version , 3 ) ; if ( count ( $ parsed ) > 1 ) array_pop ( $ parsed ) ; $ parsed [ count ( $ parsed ) - 1 ] ++ ; if ( count ( $ parsed ) === 1 ) $ parsed [ ] = '0' ; return implode ( '.' , $ parsed ) ; }
Get the next significant release version for a given version string .
35,140
public static function retrieve ( & $ xpdo , $ source , $ target , $ state = xPDOTransport :: STATE_PACKED ) { $ instance = null ; $ signature = basename ( $ source , '.transport.zip' ) ; if ( file_exists ( $ source ) ) { if ( is_writable ( $ target ) ) { $ manifest = xPDOTransport :: unpack ( $ xpdo , $ source , $ tar...
Get an xPDOTransport instance from an existing package .
35,141
public static function unpack ( & $ xpdo , $ from , $ to , $ state = xPDOTransport :: STATE_PACKED ) { $ manifest = null ; if ( $ state !== xPDOTransport :: STATE_UNPACKED ) { $ resources = xPDOTransport :: _unpack ( $ xpdo , $ from , $ to ) ; } else { $ resources = true ; } if ( $ resources ) { $ manifestFilename = $ ...
Unpack the package to prepare for installation and return a manifest .
35,142
public static function _unpack ( & $ xpdo , $ from , $ to ) { $ resources = false ; if ( $ xpdo -> getOption ( xPDOTransport :: ARCHIVE_WITH , null , 0 ) != xPDOTransport :: ARCHIVE_WITH_PCLZIP && class_exists ( 'ZipArchive' ) ) { $ archive = new xPDOZip ( $ xpdo , $ from ) ; if ( $ archive ) { $ resources = $ archive ...
Unpack a zip archive to a specified location .
35,143
public static function manifestVersion ( $ manifest ) { $ version = false ; if ( is_array ( $ manifest ) ) { if ( isset ( $ manifest [ xPDOTransport :: MANIFEST_VERSION ] ) ) { $ version = $ manifest [ xPDOTransport :: MANIFEST_VERSION ] ; } elseif ( isset ( $ manifest [ xPDOTransport :: MANIFEST_VEHICLES ] ) ) { $ ver...
Returns the structure version of the given manifest array .
35,144
protected static function _convertManifestVer1_0 ( $ manifestVehicles ) { $ manifest = array ( ) ; foreach ( $ manifestVehicles as $ vClass => $ vehicles ) { foreach ( $ vehicles as $ vKey => $ vehicle ) { $ entry = array ( 'class' => $ vClass , 'native_key' => $ vehicle [ 'native_key' ] , 'filename' => $ vehicle [ 'fi...
Converts older manifest vehicles to 1 . 0 format .
35,145
protected static function _convertManifestVer1_1 ( $ vehicles ) { $ manifest = array ( ) ; foreach ( $ vehicles as $ vKey => $ vehicle ) { $ entry = $ vehicle ; if ( ! isset ( $ vehicle [ 'vehicle_class' ] ) ) { $ entry [ 'vehicle_class' ] = 'xPDOObjectVehicle' ; } if ( ! isset ( $ vehicle [ 'vehicle_package' ] ) ) { $...
Converts 1 . 0 manifest vehicles to 1 . 1 format .
35,146
public function getPhpType ( $ dbtype ) { $ phptype = 'string' ; if ( $ dbtype !== null ) { foreach ( $ this -> dbtypes as $ type => $ patterns ) { foreach ( $ patterns as $ pattern ) { if ( preg_match ( $ pattern , $ dbtype ) ) { $ phptype = $ type ; break 2 ; } } } } return $ phptype ; }
Gets the PHP field type based upon the specified database type .
35,147
public function get ( & $ transport , $ options = array ( ) , $ element = null ) { $ object = null ; $ element = parent :: get ( $ transport , $ options , $ element ) ; if ( isset ( $ element [ 'class' ] ) && isset ( $ element [ 'object' ] ) ) { $ vClass = $ element [ 'class' ] ; if ( ! empty ( $ element [ 'package' ] ...
Retrieve an xPDOObject instance represented in this vehicle .
35,148
public function install ( & $ transport , $ options ) { $ parentObj = null ; $ parentMeta = null ; $ installed = $ this -> _installObject ( $ transport , $ options , $ this -> payload , $ parentObj , $ parentMeta ) ; return $ installed ; }
Install the xPDOObjects represented by vehicle into the transport host .
35,149
public function _installRelated ( & $ transport , & $ parent , $ element , $ options , $ owner = '' ) { $ installed = true ; if ( $ parent instanceof xPDOObject && isset ( $ element [ xPDOTransport :: RELATED_OBJECTS ] ) && is_array ( $ element [ xPDOTransport :: RELATED_OBJECTS ] ) ) { foreach ( $ element [ xPDOTransp...
Installs a related object from the vehicle .
35,150
public function _uninstallRelated ( & $ transport , & $ parent , $ element , $ options ) { $ uninstalled = true ; if ( is_object ( $ parent ) && isset ( $ element [ xPDOTransport :: RELATED_OBJECTS ] ) && is_array ( $ element [ xPDOTransport :: RELATED_OBJECTS ] ) ) { $ uninstalled = false ; foreach ( $ element [ xPDOT...
Uninstalls related objects from the vehicle .
35,151
protected function _putRelated ( & $ transport , $ alias , & $ object , & $ payloadElement ) { if ( is_array ( $ payloadElement ) ) { if ( is_object ( $ object ) && $ object instanceof xPDOObject ) { if ( isset ( $ this -> payload [ 'related_object_attributes' ] [ $ alias ] ) && is_array ( $ this -> payload [ 'related_...
Recursively put related objects into the vehicle .
35,152
public function equals ( $ obj ) { return ( is_object ( $ obj ) && $ obj instanceof xPDOCriteria && $ this -> sql === $ obj -> sql && ! array_diff_assoc ( $ this -> bindings , $ obj -> bindings ) ) ; }
Compares to see if two xPDOCriteria instances are the same .
35,153
public function prepare ( $ bindings = array ( ) , $ byValue = true , $ cacheFlag = null ) { if ( $ this -> stmt === null || ! is_object ( $ this -> stmt ) ) { if ( ! empty ( $ this -> sql ) && $ stmt = $ this -> xpdo -> prepare ( $ this -> sql ) ) { $ this -> stmt = & $ stmt ; $ this -> bind ( $ bindings , $ byValue ,...
Prepares the sql and bindings of this instance into a PDOStatement .
35,154
public function toSQL ( $ parseBindings = true ) { $ sql = $ this -> sql ; if ( $ parseBindings && ! empty ( $ this -> bindings ) ) { $ sql = $ this -> xpdo -> parseBindings ( $ sql , $ this -> bindings ) ; } return $ sql ; }
Converts the current xPDOQuery to parsed SQL .
35,155
protected function _compilePayload ( & $ transport ) { parent :: _compilePayload ( $ transport ) ; $ body = array ( ) ; $ cacheManager = $ transport -> xpdo -> getCacheManager ( ) ; if ( $ cacheManager ) { if ( isset ( $ this -> payload [ 'object' ] ) ) { $ object = $ this -> payload [ 'object' ] ; $ fileSource = $ obj...
Copies the transport into the vehicle and transforms the payload for storage .
35,156
protected function _installTransport ( & $ transport , $ options ) { $ installed = false ; $ vOptions = $ this -> get ( $ transport , $ options ) ; if ( isset ( $ vOptions [ 'object' ] ) && isset ( $ vOptions [ 'object' ] [ 'source' ] ) && isset ( $ vOptions [ 'object' ] [ 'target' ] ) && isset ( $ vOptions [ 'object' ...
Install the xPDOTransport from the vehicle payload .
35,157
public function addMessage ( $ field , $ name , $ message = null ) { if ( empty ( $ message ) ) $ message = $ name ; array_push ( $ this -> messages , array ( 'field' => $ field , 'name' => $ name , 'message' => $ message , ) ) ; }
Add a validation message to the stack .
35,158
public function pack ( $ source , array $ options = array ( ) ) { $ results = array ( ) ; if ( $ this -> _archive ) { $ target = $ this -> getOption ( xPDOZip :: ZIP_TARGET , $ options , '' ) ; if ( is_dir ( $ source ) ) { if ( $ dh = opendir ( $ source ) ) { if ( $ source [ strlen ( $ source ) - 1 ] !== '/' ) $ source...
Pack the contents from the source into the archive .
35,159
public function unpack ( $ target , $ options = array ( ) ) { $ results = false ; if ( $ this -> _archive ) { if ( is_dir ( $ target ) && is_writable ( $ target ) ) { $ results = $ this -> _archive -> extractTo ( $ target ) ; } } return $ results ; }
Unpack the compressed contents from the archive to the target .
35,160
public function getOption ( $ key , $ options = null , $ default = null ) { $ option = $ default ; if ( is_array ( $ key ) ) { if ( ! is_array ( $ option ) ) { $ default = $ option ; $ option = array ( ) ; } foreach ( $ key as $ k ) { $ option [ $ k ] = $ this -> getOption ( $ k , $ options , $ default ) ; } } elseif (...
Get an option from supplied options the xPDOZip instance options or xpdo itself .
35,161
protected function addPaginationHeaders ( $ pagination ) { $ links = [ ] ; foreach ( $ pagination -> getLinks ( true ) as $ rel => $ url ) { $ links [ ] = "<$url>; rel=$rel" ; } $ this -> response -> setHeader ( $ this -> totalCountHeader , $ pagination -> totalCount ) ; $ this -> response -> setHeader ( $ this -> page...
Adds HTTP headers about the pagination to the response .
35,162
public function run ( $ id = null ) { $ app = $ this -> getApp ( ) ; if ( $ app -> getRequest ( ) -> getMethod ( ) !== 'OPTIONS' ) { $ app -> getResponse ( ) -> setStatusCode ( 405 ) ; } $ options = $ id === null ? $ this -> collectionOptions : $ this -> resourceOptions ; $ app -> getResponse ( ) -> getHeaderCollection...
Responds to the OPTIONS request .
35,163
protected function compileShortcode ( $ matches ) { $ this -> setMatches ( $ matches ) ; $ attributes = $ this -> parseAttributes ( $ this -> matches [ 3 ] ) ; return new Shortcode ( $ this -> getName ( ) , $ attributes , $ this -> getContent ( ) ) ; }
Get Compiled Attributes .
35,164
protected function parseAttributes ( $ text ) { $ text = htmlspecialchars_decode ( $ text , ENT_QUOTES ) ; $ attributes = [ ] ; $ pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/' ; if ( preg_match_all ( $ pattern , preg_replace ...
Parse the shortcode attributes
35,165
public function get ( $ attribute , $ fallback = null ) { $ value = $ this -> { $ attribute } ; if ( ! is_null ( $ value ) ) { return $ attribute . '="' . $ value . '"' ; } elseif ( ! is_null ( $ fallback ) ) { return $ attribute . '="' . $ fallback . '"' ; } }
Get html attribute
35,166
public function enableCompiler ( ) { $ state = $ this -> app [ 'config' ] -> get ( 'laravel-shortcodes::enabled' , false ) ; if ( $ state ) { $ this -> app [ 'shortcode.compiler' ] -> enable ( ) ; } }
Enable the compiler .
35,167
public function registerView ( ) { $ finder = $ this -> app [ 'view' ] -> getFinder ( ) ; $ this -> app -> singleton ( 'view' , function ( $ app ) use ( $ finder ) { $ resolver = $ app [ 'view.engine.resolver' ] ; $ env = new Factory ( $ resolver , $ finder , $ app [ 'events' ] , $ app [ 'shortcode.compiler' ] ) ; $ en...
Register Laravel view .
35,168
public function createFrame ( $ command , array $ headers , $ body , $ legacyMode ) { foreach ( $ this -> resolver as $ resolver ) { if ( $ frame = $ resolver ( $ command , $ headers , $ body , $ legacyMode ) ) { return $ frame ; } } return $ this -> defaultFrame ( $ command , $ headers , $ body , $ legacyMode ) ; }
Creates a frame instance out of the given frame details .
35,169
private function defaultFrame ( $ command , array $ headers , $ body , $ legacyMode ) { $ frame = new Frame ( $ command , $ headers , $ body ) ; $ frame -> legacyMode ( $ legacyMode ) ; return $ frame ; }
Creates a new default frame instance .
35,170
public function setWaitCallback ( $ waitCallback ) { if ( $ waitCallback !== null ) { if ( ! is_callable ( $ waitCallback ) ) { throw new \ InvalidArgumentException ( '$waitCallback must be callable.' ) ; } } $ this -> waitCallback = $ waitCallback ; }
Sets a wait callback that will be invoked when the connection is waiting for new data .
35,171
private function parseUrl ( $ url ) { $ parsed = parse_url ( $ url ) ; if ( $ parsed === false ) { throw new ConnectionException ( 'Unable to parse url ' . $ url ) ; } array_push ( $ this -> hosts , $ parsed + [ 'port' => '61613' , 'scheme' => 'tcp' ] ) ; }
Parse a broker URL
35,172
protected function getHostList ( ) { $ hosts = array_values ( $ this -> hosts ) ; if ( $ this -> params [ 'randomize' ] ) { shuffle ( $ hosts ) ; } return $ hosts ; }
Get the host list .
35,173
protected function connectSocket ( array $ host ) { $ this -> activeHost = $ host ; $ errNo = null ; $ errStr = null ; $ context = stream_context_create ( $ this -> context ) ; $ flags = STREAM_CLIENT_CONNECT ; if ( $ this -> persistentConnection ) { $ flags |= STREAM_CLIENT_PERSISTENT ; } $ socket = @ stream_socket_cl...
Try to connect to given host .
35,174
public function writeFrame ( Frame $ stompFrame ) { if ( ! $ this -> isConnected ( ) ) { throw new ConnectionException ( 'Not connected to any server.' , $ this -> activeHost ) ; } $ this -> writeData ( $ stompFrame , $ this -> writeTimeout ) ; $ this -> observers -> sentFrame ( $ stompFrame ) ; return true ; }
Write frame to server .
35,175
private function writeData ( $ stompFrame , $ timeout ) { $ data = ( string ) $ stompFrame ; $ offset = 0 ; $ size = strlen ( $ data ) ; $ lastByteTime = microtime ( true ) ; do { $ written = @ fwrite ( $ this -> connection , substr ( $ data , $ offset ) , $ this -> maxWriteBytes ) ; if ( $ written === false ) { throw ...
Write passed data to the stream respecting passed timeout .
35,176
public function readFrame ( ) { if ( $ frame = $ this -> parser -> nextFrame ( ) ) { return $ this -> onFrame ( $ frame ) ; } if ( ! $ this -> hasDataToRead ( ) ) { return false ; } do { $ read = @ fread ( $ this -> connection , $ this -> maxReadBytes ) ; if ( $ read === false ) { throw new ConnectionException ( sprint...
Try to read a frame from the server .
35,177
public function hasDataToRead ( ) { if ( ! $ this -> isConnected ( ) ) { throw new ConnectionException ( 'Not connected to any server.' , $ this -> activeHost ) ; } $ isDataInBuffer = $ this -> connectionHasDataToRead ( $ this -> readTimeout [ 0 ] , $ this -> readTimeout [ 1 ] ) ; if ( ! $ isDataInBuffer ) { $ this -> ...
Check if connection has new data which can be read .
35,178
private function connectionHasDataToRead ( $ timeoutSec , $ timeoutMicros ) { $ timeout = microtime ( true ) + $ timeoutSec + ( $ timeoutMicros ? $ timeoutMicros / 1000000 : 0 ) ; while ( ( $ hasData = $ this -> isDataOnStream ( ) ) === false ) { if ( $ timeout < microtime ( true ) ) { return false ; } if ( $ this -> w...
See if the connection has data left .
35,179
private function isDataOnStream ( ) { $ read = [ $ this -> connection ] ; $ write = null ; $ except = null ; $ hasStreamInfo = @ stream_select ( $ read , $ write , $ except , 0 ) ; if ( $ hasStreamInfo === false ) { $ error = error_get_last ( ) ; if ( $ error && isset ( $ error [ 'message' ] ) && stripos ( $ error [ 'm...
Checks if there is readable data on the stream .
35,180
final public function getConnectFrame ( $ login = '' , $ passcode = '' , array $ versions = [ ] , $ host = null , $ heartbeat = [ 0 , 0 ] ) { $ frame = $ this -> createFrame ( 'CONNECT' ) ; $ frame -> legacyMode ( true ) ; if ( $ login || $ passcode ) { $ frame -> addHeaders ( [ 'login' => $ login , 'passcode' => $ pas...
Get the connect frame
35,181
public function getSubscribeFrame ( $ destination , $ subscriptionId = null , $ ack = 'auto' , $ selector = null ) { if ( $ this -> hasVersion ( Version :: VERSION_1_1 ) ) { $ validAcks = [ 'auto' , 'client' , 'client-individual' ] ; } else { $ validAcks = [ 'auto' , 'client' ] ; } if ( ! in_array ( $ ack , $ validAcks...
Get subscribe frame .
35,182
public function getUnsubscribeFrame ( $ destination , $ subscriptionId = null ) { $ frame = $ this -> createFrame ( 'UNSUBSCRIBE' ) ; $ frame [ 'destination' ] = $ destination ; $ frame [ 'id' ] = $ subscriptionId ; return $ frame ; }
Get unsubscribe frame .
35,183
public function getNackFrame ( Frame $ frame , $ transactionId = null , $ requeue = null ) { if ( $ requeue !== null ) { throw new \ LogicException ( 'requeue header not supported' ) ; } if ( $ this -> version === Version :: VERSION_1_0 ) { throw new StompException ( 'Stomp Version 1.0 has no support for NACK Frames.' ...
Get message not acknowledge frame .
35,184
public function getDisconnectFrame ( ) { $ frame = $ this -> createFrame ( 'DISCONNECT' ) ; if ( $ this -> hasClientId ( ) ) { $ frame [ 'client-id' ] = $ this -> getClientId ( ) ; } return $ frame ; }
Get the disconnect frame .
35,185
protected function createFrame ( $ command ) { $ frame = new Frame ( $ command ) ; if ( $ this -> version === Version :: VERSION_1_0 ) { $ frame -> legacyMode ( true ) ; } return $ frame ; }
Creates a Frame according to the detected STOMP version .
35,186
public function getSubscribeFrame ( $ destination , $ subscriptionId = null , $ ack = 'auto' , $ selector = null , $ durable = false ) { $ frame = parent :: getSubscribeFrame ( $ destination , $ subscriptionId , $ ack , $ selector ) ; if ( $ this -> hasClientId ( ) && $ durable ) { $ frame [ 'persistent' ] = 'true' ; }...
Apollo subscribe frame .
35,187
public function getUnsubscribeFrame ( $ destination , $ subscriptionId = null , $ durable = false ) { $ frame = parent :: getUnsubscribeFrame ( $ destination , $ subscriptionId ) ; if ( $ durable ) { $ frame [ 'persistent' ] = 'true' ; } return $ frame ; }
Apollo unsubscribe frame .
35,188
protected function onHeartbeatFrame ( Frame $ frame , array $ beats ) { if ( $ frame -> getCommand ( ) === self :: FRAME_SERVER_CONNECTED ) { $ this -> intervalServer = $ beats [ 1 ] ; if ( $ this -> intervalClient === null ) { $ this -> intervalClient = $ this -> intervalServer ; } } else { $ this -> intervalClient = ...
A frame with heartbeat details was detected .
35,189
private function assertReadTimeoutSufficient ( $ interval ) { $ readTimeout = $ this -> connection -> getReadTimeout ( ) ; $ readTimeoutMs = ( $ readTimeout [ 0 ] * 1000 ) + ( $ readTimeout [ 1 ] / 1000 ) ; if ( $ interval < $ readTimeoutMs ) { throw new HeartbeatException ( 'Client heartbeat is lower than connection r...
Verify that the client configured heartbeats don t conflict with the connection read timeout .
35,190
protected function onDelay ( ) { try { $ this -> connection -> sendAlive ( $ this -> intervalClient / 1000 ) ; } catch ( ConnectionException $ e ) { throw new HeartbeatException ( 'Could not send heartbeat to server.' , $ e ) ; } $ this -> rememberActivity ( ) ; }
Send a beat to the server .
35,191
public function subscribe ( ) { if ( ! $ this -> active ) { $ this -> reachedEnd = false ; $ this -> client -> sendFrame ( $ this -> getProtocol ( ) -> getSubscribeFrame ( $ this -> subscription -> getDestination ( ) , $ this -> subscription -> getSubscriptionId ( ) , $ this -> subscription -> getAck ( ) , $ this -> su...
Initialize subscription .
35,192
public function read ( ) { if ( ! $ this -> active || $ this -> reachedEnd ) { return false ; } if ( $ frame = $ this -> client -> readFrame ( ) ) { if ( $ this -> stopOnEnd && $ frame [ 'browser' ] == 'end' ) { $ this -> reachedEnd = true ; return false ; } } return $ frame ; }
Read next message .
35,193
public function getProtocol ( $ clientId , $ default = 'ActiveMQ/5.11.1' ) { $ server = trim ( $ this -> frame [ 'server' ] ) ? : $ default ; $ version = $ this -> getVersion ( ) ; if ( stristr ( $ server , 'rabbitmq' ) !== false ) { return new RabbitMq ( $ clientId , $ version , $ server ) ; } if ( stristr ( $ server ...
Returns the protocol to use .
35,194
public function getSubscribeFrame ( $ destination , $ subscriptionId = null , $ ack = 'auto' , $ selector = null , $ durable = false ) { $ frame = parent :: getSubscribeFrame ( $ destination , $ subscriptionId , $ ack , $ selector ) ; $ frame [ 'activemq.prefetchSize' ] = $ this -> prefetchSize ; if ( $ durable ) { $ f...
ActiveMq subscribe frame .
35,195
public function nextFrame ( ) { if ( $ this -> parse ( ) ) { $ frame = $ this -> getFrame ( ) ; $ this -> frame = null ; if ( $ this -> observer ) { $ this -> observer -> receivedFrame ( $ frame ) ; } return $ frame ; } return null ; }
Parse current buffer and return the next available frame otherwise return null .
35,196
public function parse ( ) { if ( $ this -> buffer === '' ) { return false ; } $ this -> frame = null ; $ this -> offset = 0 ; $ this -> bufferSize = strlen ( $ this -> buffer ) ; while ( $ this -> offset < $ this -> bufferSize ) { if ( $ this -> mode === self :: MODE_HEADER ) { $ this -> skipEmptyLines ( ) ; if ( $ thi...
Parse current buffer for frames .
35,197
private function detectFrameHead ( ) { $ firstCrLf = strpos ( $ this -> buffer , self :: HEADER_STOP_CR_LF , $ this -> offset ) ; $ firstLf = strpos ( $ this -> buffer , self :: HEADER_STOP_LF , $ this -> offset ) ; if ( $ firstCrLf !== false && ( $ firstLf === false || $ firstLf > $ firstCrLf ) ) { $ this -> extractFr...
Detect frame header end marker starting from current offset .
35,198
private function detectFrameEnd ( ) { $ bodySize = null ; if ( $ this -> expectedBodyLength ) { if ( ( $ this -> bufferSize - $ this -> offset ) >= $ this -> expectedBodyLength ) { $ bodySize = $ this -> expectedBodyLength ; } } elseif ( ( $ frameEnd = strpos ( $ this -> buffer , self :: FRAME_END , $ this -> offset ) ...
Detect frame end marker starting from current offset .
35,199
private function setFrame ( $ bodySize ) { $ this -> frame = $ this -> factory -> createFrame ( $ this -> command , $ this -> headers , ( string ) substr ( $ this -> buffer , $ this -> offset , $ bodySize ) , $ this -> legacyMode ) ; $ this -> expectedBodyLength = null ; $ this -> headers = [ ] ; $ this -> mode = self ...
Adds a frame from current known command headers . Uses current offset and given body size .