idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
20,700
public function forgetMe ( $ email_address ) { $ action = "forget_me" ; $ options = array ( 'email_addr' => $ email_address , 'sid_token' => $ this -> sid_token ) ; return $ this -> client -> post ( $ action , $ options ) ; }
Forget users email and sid_token
20,701
public function trackLogIn ( $ ip , array $ user , $ userAgent = null , array $ source = null , array $ session = null , array $ device = null ) { $ this -> trackEvent ( self :: VERB_LOG_IN , $ ip , $ user , $ userAgent , $ source , $ session , $ device ) ; }
Track the successful authentication of a client .
20,702
public function trackLogInDenied ( $ ip , array $ user = null , $ userAgent = null , array $ source = null , array $ session = null , array $ device = null ) { $ this -> trackEvent ( self :: VERB_LOG_IN_DENIED , $ ip , $ user , $ userAgent , $ source , $ session , $ device ) ; }
Track the unsuccessful authentication of a client .
20,703
public function trackEvent ( $ verb , $ ip , array $ user = null , $ userAgent = null , array $ source = null , array $ session = null , array $ device = null ) { $ event = [ self :: PARAM_VERB => $ verb , self :: PARAM_IP => $ ip ] ; if ( ! is_null ( $ userAgent ) ) { $ event [ self :: PARAM_USER_AGENT ] = $ userAgent ; } if ( ! is_null ( $ user ) ) { $ event [ self :: PARAM_USER ] = array_filter ( [ self :: PARAM_USER__ID => $ this -> findValue ( self :: PARAM_USER__ID , $ user ) , self :: PARAM_USER__NAME => $ this -> findValue ( self :: PARAM_USER__NAME , $ user ) , self :: PARAM_USER__EMAIL => $ this -> findValue ( self :: PARAM_USER__EMAIL , $ user ) , self :: PARAM_USER__MOBILE => $ this -> findValue ( self :: PARAM_USER__MOBILE , $ user ) , self :: PARAM_USER__AUTHENTICATED => $ this -> findValue ( self :: PARAM_USER__AUTHENTICATED , $ user ) , ] ) ; } if ( ! is_null ( $ source ) ) { $ event [ self :: PARAM_SOURCE ] = array_filter ( [ self :: PARAM_SOURCE__NAME => $ this -> findValue ( self :: PARAM_SOURCE__NAME , $ source ) , self :: PARAM_SOURCE__LOGO_URL => $ this -> findValue ( self :: PARAM_SOURCE__LOGO_URL , $ source ) ] ) ; } $ event [ self :: PARAM_SESSION ] = array_filter ( [ self :: PARAM_SESSION__ID => $ this -> findValue ( self :: PARAM_SESSION__ID , $ session ) ] ) ; if ( isset ( $ _COOKIE [ ThisData :: TD_COOKIE_NAME ] ) ) { $ event [ self :: PARAM_SESSION ] [ self :: PARAM_SESSION__TD_COOKIE_ID ] = $ _COOKIE [ ThisData :: TD_COOKIE_NAME ] ; } if ( $ this -> configuration [ Builder :: CONF_EXPECT_JS_COOKIE ] ) { $ event [ self :: PARAM_SESSION ] [ self :: PARAM_SESSION__TD_COOKIE_EXPECTED ] = $ this -> configuration [ Builder :: CONF_EXPECT_JS_COOKIE ] ; } if ( ! is_null ( $ device ) ) { $ event [ self :: PARAM_DEVICE ] = array_filter ( [ self :: PARAM_DEVICE__ID => $ this -> findValue ( self :: PARAM_DEVICE__ID , $ device ) ] ) ; } $ this -> execute ( 'POST' , ThisData :: ENDPOINT_EVENTS , array_filter ( $ event ) ) ; }
Tracks an event using the ThisData API .
20,704
public function getEvents ( array $ options = null ) { $ url = ThisData :: ENDPOINT_EVENTS ; if ( ! is_null ( $ options ) ) { $ url .= '?' . http_build_query ( $ options ) ; } $ response = $ this -> synchronousExecute ( 'GET' , $ url ) ; return json_decode ( $ response -> getBody ( ) , TRUE ) ; }
Fetches events from the ThisData API .
20,705
public function initialize ( TranslatorInterface $ translator ) { $ event = new CreateTranslatorEvent ( $ translator ) ; $ this -> eventDispatcher -> dispatch ( $ event :: NAME , $ event ) ; return $ translator ; }
Initialize the translator .
20,706
public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; if ( ! $ this -> OriginalPublishedDate ) { $ this -> OriginalPublishedDate = date ( 'Y-m-d 12:00:00' ) ; } $ parent = $ this -> Parent ( ) ; $ section = $ this -> findSection ( ) ; $ this -> NewsSectionID = $ section -> ID ; $ newlyCreated = $ section -> ID == $ parent -> ID ; $ changedPublishDate = $ this -> isChanged ( 'OriginalPublishedDate' , 2 ) ; if ( ( $ changedPublishDate || $ newlyCreated ) && ( $ section -> AutoFiling || $ section -> FilingMode ) ) { if ( ! $ this -> Created ) { $ this -> Created = date ( 'Y-m-d H:i:s' ) ; } $ pp = $ this -> PartitionParent ( ) ; if ( $ pp -> ID != $ this -> ParentID ) { $ this -> ParentID = $ pp -> ID ; } } }
When the article is saved and this article s section dictates that it needs to be filed then do so
20,707
protected function publishSection ( ) { $ parent = DataObject :: get_by_id ( 'NewsHolder' , $ this -> ParentID ) ; while ( $ parent && $ parent instanceof NewsHolder ) { if ( ! $ parent -> isPublished ( ) ) { $ parent -> doPublish ( ) ; } $ parent = $ parent -> Parent ( ) ; } }
Ensure s the section is published .
20,708
public function Link ( $ action = '' ) { if ( strlen ( $ this -> ExternalURL ) && ! strlen ( $ this -> Content ) ) { return $ this -> ExternalURL ; } if ( $ this -> InternalFile ( ) -> ID ) { $ file = $ this -> InternalFile ( ) ; return $ file -> Link ( $ action ) ; } return parent :: Link ( $ action ) ; }
Link to the news article . If it has an external URL set or a file link to that instead .
20,709
public function pagesAffectedByChanges ( ) { $ parent = $ this -> Parent ( ) ; $ urls = array ( $ this -> Link ( ) ) ; while ( $ parent && $ parent -> ParentID > - 1 && $ parent instanceof NewsHolder ) { $ urls [ ] = $ parent -> Link ( ) ; $ parent = $ parent -> Parent ( ) ; } $ this -> extend ( 'updatePagesAffectedByChanges' , $ urls ) ; return $ urls ; }
Pages to update cache file for static publisher
20,710
protected function renderZone ( $ zone , $ args = array ( ) ) { $ sep = isset ( $ args [ 'seperator' ] ) ? $ args [ 'seperator' ] : ' ' ; if ( $ this -> debug === true ) { echo "\n\n" . '<!-- Template Zone: ' . $ zone . ' ; } $ content = '' ; if ( isset ( $ this -> content [ $ zone ] ) ) { foreach ( $ this -> content [ $ zone ] as $ item ) { switch ( $ item [ 'type' ] ) { case 'hook' : $ content .= call_user_func_array ( $ item [ 'hook' ] , array ( $ args , $ item [ 'arguments' ] ) ) ; break ; case 'html' : $ content .= $ sep . ( string ) $ item [ 'html' ] ; break ; case 'template' : $ content .= $ this -> renderTemplate ( $ item [ 'template' ] , $ item [ 'params' ] ) ; break ; case 'zone' : $ content .= $ this -> renderZone ( $ item [ 'zone' ] , $ item [ 'params' ] ) ; break ; } } } if ( \ Skinny :: hasContent ( $ zone ) ) { foreach ( \ Skinny :: getContent ( $ zone ) as $ item ) { if ( isset ( $ item [ 'html' ] ) ) { if ( $ this -> debug === true ) { $ content .= '<!--Skinny:MoveToSkin: ' . $ template . ' ; } $ content .= $ sep . $ item [ 'html' ] ; } else if ( isset ( $ item [ 'template' ] ) ) { if ( $ this -> debug === true ) { $ content .= '<!--Skinny:Template (via #skintemplate): ' . $ item [ 'template' ] . ' ; } $ content .= $ this -> renderTemplate ( $ item [ 'template' ] , $ item [ 'params' ] ) ; } } } return $ content ; }
Render zone content optionally passing arguments to provide to object methods
20,711
public function addHookTo ( $ zone , $ hook , Array $ args = array ( ) ) { if ( ! isset ( $ this -> content [ $ zone ] ) ) { $ this -> content [ $ zone ] = array ( ) ; } if ( ! is_array ( $ hook ) && method_exists ( $ this , $ hook ) ) { $ hook = array ( $ this , $ hook ) ; } if ( ! is_callable ( $ hook , false , $ callbable_name ) ) { throw new \ Exception ( 'Invalid skin content hook for zone:' . $ zone . ' (Hook callback was: ' . $ callbable_name . ')' ) ; } $ this -> content [ $ zone ] [ ] = array ( 'type' => 'hook' , 'hook' => $ hook , 'arguments' => $ args ) ; }
Add the result of a function callback to a zone
20,712
public function addTemplateTo ( $ zone , $ template , Array $ params = array ( ) ) { if ( ! isset ( $ this -> content [ $ zone ] ) ) $ this -> content [ $ zone ] = array ( ) ; $ this -> content [ $ zone ] [ ] = array ( 'type' => 'template' , 'template' => $ template , 'params' => $ params ) ; }
Render the output of a template to a zone
20,713
public function addHTMLTo ( $ zone , $ content ) { if ( ! isset ( $ this -> content [ $ zone ] ) ) $ this -> content [ $ zone ] = array ( ) ; $ this -> content [ $ zone ] [ ] = array ( 'type' => 'html' , 'html' => $ content ) ; }
Add html content to a zone
20,714
public function addZoneTo ( $ zone , $ name , Array $ params = array ( ) ) { if ( ! isset ( $ this -> content [ $ zone ] ) ) $ this -> content [ $ zone ] = array ( ) ; $ this -> content [ $ zone ] [ ] = array ( 'type' => 'zone' , 'zone' => $ name , 'params' => $ params ) ; }
Add a zone to a zone . Allows adding zones without editing template files .
20,715
public function displayImage ( $ string , $ size = 64 , $ color = null , $ backgroundColor = null ) { $ imageData = $ this -> getImageData ( $ string , $ size , $ color , $ backgroundColor ) ; return Response :: make ( $ imageData , 200 , [ 'Content-Type' => 'image/png' ] ) ; }
Laravel Response Wrapper to Display an Identicon image .
20,716
public function getResult ( ) { if ( ! $ this -> result && $ this -> response && $ this -> response -> getHttpStatus ( ) >= 200 && $ this -> response -> getHttpStatus ( ) < 300 ) { $ this -> result = json_decode ( $ this -> response -> getRawResponse ( ) ) ; } return $ this -> result ; }
Gets the raw result set as an object graph .
20,717
protected function inflateRawResult ( $ doc , $ convertToObject = true ) { $ field = SolrSearchService :: SERIALIZED_OBJECT . '_t' ; if ( isset ( $ doc -> $ field ) && $ convertToObject ) { $ raw = unserialize ( $ doc -> $ field ) ; if ( isset ( $ raw [ 'SS_TYPE' ] ) ) { $ class = $ raw [ 'SS_TYPE' ] ; $ object = Injector :: inst ( ) -> create ( $ class ) ; $ object -> update ( $ raw ) ; $ object -> ID = str_replace ( SolrSearchService :: RAW_DATA_KEY , '' , $ doc -> id ) ; return $ object ; } return ArrayData :: create ( $ raw ) ; } $ data = array ( 'ID' => str_replace ( SolrSearchService :: RAW_DATA_KEY , '' , $ doc -> id ) , ) ; if ( isset ( $ doc -> attr_SS_URL [ 0 ] ) ) { $ data [ 'Link' ] = $ doc -> attr_SS_URL [ 0 ] ; } if ( isset ( $ doc -> title ) ) { $ data [ 'Title' ] = $ doc -> title ; } if ( isset ( $ doc -> title_as ) ) { $ data [ 'Title' ] = $ doc -> title_as ; } foreach ( $ doc as $ key => $ val ) { if ( $ key != 'attr_SS_URL' ) { $ name = null ; if ( strpos ( $ key , 'attr_' ) === 0 ) { $ name = str_replace ( 'attr_' , '' , $ key ) ; } else if ( preg_match ( '/(.*?)_(' . implode ( '|' , self :: $ solr_attrs ) . ')$/' , $ key , $ matches ) ) { $ name = $ matches [ 1 ] ; } $ val = $ doc -> $ key ; if ( is_array ( $ val ) && count ( $ val ) == 1 ) { $ data [ $ name ] = $ val [ 0 ] ; } else { $ data [ $ name ] = $ val ; } } } return ArrayData :: create ( $ data ) ; }
Inflate a raw result into an object of a particular type
20,718
public function getFacets ( ) { if ( $ this -> returnedFacets ) { return $ this -> returnedFacets ; } $ result = $ this -> getResult ( ) ; if ( ! isset ( $ result -> facet_counts ) ) { return ; } if ( isset ( $ result -> facet_counts -> exception ) ) { return array ( ) ; } $ elems = $ result -> facet_counts -> facet_fields ; $ facets = array ( ) ; foreach ( $ elems as $ field => $ values ) { $ elemVals = array ( ) ; foreach ( $ values as $ vname => $ vcount ) { if ( $ vname == '_empty_' ) { continue ; } $ r = new stdClass ; $ r -> Name = $ vname ; $ r -> Query = $ vname ; $ r -> Count = $ vcount ; $ elemVals [ ] = $ r ; } $ facets [ $ field ] = $ elemVals ; } $ query_elems = $ result -> facet_counts -> facet_queries ; if ( $ query_elems ) { foreach ( $ query_elems as $ vname => $ count ) { if ( $ vname == '_empty_' ) { continue ; } list ( $ field , $ query ) = explode ( ':' , $ vname ) ; $ r = new stdClass ; $ r -> Type = 'query' ; $ r -> Name = $ vname ; $ r -> Query = $ query ; $ r -> Count = $ count ; $ existing = isset ( $ facets [ $ field ] ) ? $ facets [ $ field ] : array ( ) ; $ existing [ ] = $ r ; $ facets [ $ field ] = $ existing ; } } $ this -> returnedFacets = $ facets ; return $ this -> returnedFacets ; }
Gets the details about facets found in this query
20,719
public static function createSerializer ( ) { $ normalizers = array ( new AccountNormalizer ( ) , new ActorNormalizer ( ) , new AttachmentNormalizer ( ) , new ContextNormalizer ( ) , new ContextActivitiesNormalizer ( ) , new DefinitionNormalizer ( ) , new DocumentDataNormalizer ( ) , new ExtensionsNormalizer ( ) , new InteractionComponentNormalizer ( ) , new LanguageMapNormalizer ( ) , new ObjectNormalizer ( ) , new ResultNormalizer ( ) , new StatementNormalizer ( ) , new StatementResultNormalizer ( ) , new TimestampNormalizer ( ) , new VerbNormalizer ( ) , new ArrayDenormalizer ( ) , new FilterNullValueNormalizer ( new PropertyNormalizer ( ) ) , new PropertyNormalizer ( ) , ) ; $ encoders = array ( new JsonEncoder ( ) , ) ; return new SymfonySerializer ( $ normalizers , $ encoders ) ; }
Creates a new Serializer .
20,720
public function sync ( Authorization $ processor , $ vendor , $ package = null ) { return $ processor -> sync ( $ this , $ vendor , $ package ) ; }
Get sync roles action .
20,721
public function updateSucceed ( $ metric ) { \ resolve ( Synchronizer :: class ) -> handle ( ) ; $ message = \ trans ( 'orchestra/control::response.acls.update' ) ; return $ this -> redirectWithMessage ( \ handles ( "orchestra::control/acl?name={$metric}" ) , $ message ) ; }
Response when ACL is updated .
20,722
function canHandleType ( $ value , ? \ Plasma \ ColumnDefinitionInterface $ column ) : bool { $ cb = $ this -> filter ; return $ cb ( $ value , $ column ) ; }
Whether the type extension can handle the conversion of the passed value . Before this method is used the common types are checked first . class - > interface - > type - > this .
20,723
public function compare ( TimePoint $ timepoint ) { $ first = $ this -> date ; $ second = $ this -> timePointToDateTime ( $ timepoint ) ; if ( $ first < $ second ) { return - 1 ; } if ( $ first > $ second ) { return 1 ; } return 0 ; }
Compares two points in time
20,724
public function file ( UploadedFile $ file ) { $ this -> file = $ file ; $ this -> filename = $ file -> getClientOriginalName ( ) ; $ this -> sanitizeFilename ( ) ; return $ this ; }
Sets the uploaded file to be validated and moved
20,725
public function move ( ) { if ( $ this -> makeFilenameUnique ) { $ this -> getUniqueFilename ( ) ; } if ( $ this -> _validate ( ) ) { $ this -> _createDirs ( ) ; if ( $ this -> file -> isValid ( ) ) { $ this -> file -> move ( $ this -> uploadDir , $ this -> filename ) ; } else { throw new Exception ( $ this -> file -> getErrorMessage ( ) ) ; } } return $ this -> getUploadPath ( ) ; }
Validates and moves the uploaded file to it s destination
20,726
public function getUniqueFilename ( ) { $ pathInfo = pathinfo ( $ this -> filename ) ; $ filename = $ pathInfo [ 'filename' ] ; $ extension = $ pathInfo [ 'extension' ] ; $ increment = 1 ; while ( $ this -> fileExists ( $ filename . "_" . $ increment , $ extension ) ) { $ increment ++ ; } $ this -> filename = $ filename . "_" . $ increment . '.' . $ extension ; return $ this ; }
Returns a unique file name for the upload by appending a sequential number . Checks to make sure file doesn t exist before returning a name .
20,727
private function _validate ( ) { $ this -> checkOverwritePermission ( ) ; $ this -> checkHasValidUploadDirectory ( ) ; $ this -> checkFileSize ( ) ; $ this -> checkFileTypeIsAllowed ( ) ; $ this -> checkFileTypeIsNotBlocked ( ) ; return true ; }
Validates the upload against the specified options .
20,728
private function checkFileTypeIsAllowed ( ) { if ( count ( $ this -> allowedMimeTypes ) > 0 ) { if ( ! in_array ( $ this -> file -> getMimeType ( ) , $ this -> allowedMimeTypes ) ) { throw new InvalidFileTypeException ( "Invalid File Type: " . $ this -> file -> getMimeType ( ) . " has not been allowed" ) ; } } }
Checks that the file type is allowed if none specified then all non - blocked file types will be accepted
20,729
private function checkFileTypeIsNotBlocked ( ) { if ( in_array ( $ this -> file -> getMimeType ( ) , $ this -> blockedMimeTypes ) ) { throw new InvalidFileTypeException ( "Invalid File Type: " . $ this -> file -> getMimeType ( ) . " type has been blocked" ) ; } }
Validate blocked MIME types this can be used instead of allowed_mime_types to block uploads of specific file types .
20,730
public function uploadDir ( $ dir ) { $ this -> uploadDir = $ dir ; if ( ! $ this -> hasTrailingSlash ( ) ) { $ this -> uploadDir .= "/" ; } return $ this ; }
Sets the upload directory
20,731
public function theOperationInFile ( $ filename ) { $ queryFile = sprintf ( '%s%s%s' , self :: $ currentFeatureFile -> getPath ( ) , DIRECTORY_SEPARATOR , $ filename ) ; if ( file_exists ( $ queryFile ) ) { $ file = new File ( $ queryFile ) ; $ this -> client -> setGraphQL ( file_get_contents ( $ file -> getPathname ( ) ) ) ; } else { throw new FileNotFoundException ( null , 0 , null , $ queryFile ) ; } }
Find for a file to read the GraphQL query the file must not contains more than one query
20,732
public function theOperationNamedInFile ( $ queryName , $ file ) { $ this -> theOperationInFile ( $ file ) ; $ this -> operationName = $ queryName ; if ( $ this -> client -> getGraphQL ( ) ) { $ pattern = '/(query|mutation|subscription)\s+(?!' . $ queryName . '\s*[\({])(.+\n)+}\n*/' ; $ this -> client -> setGraphQL ( preg_replace ( $ pattern , null , $ this -> client -> getGraphQL ( ) ) ) ; } if ( $ queryName ) { if ( strpos ( $ this -> client -> getGraphQL ( ) , $ queryName ) === false ) { throw new \ RuntimeException ( sprintf ( 'Does not exist any operation called "%s" in "%s"' , $ queryName , $ file ) ) ; } } }
Find for specific query name in given file . The file can contain multiple named queries .
20,733
public function setVariableEqualTo ( $ path , $ value ) { $ accessor = new PropertyAccessor ( ) ; $ variables = $ this -> client -> getVariables ( ) ; $ accessor -> setValue ( $ variables , sprintf ( "[%s]" , $ path ) , $ value ) ; $ this -> client -> setVariables ( $ variables ) ; }
Set query variable with scalar value before run the given query
20,734
public function debugLastQuery ( ) { if ( $ this -> client -> getGraphQL ( ) ) { $ response = $ this -> client -> getResponse ( ) ; $ content = $ response -> getContent ( ) ; $ json = @ json_decode ( $ content , true ) ; $ error = $ response -> getStatusCode ( ) >= 400 ; if ( $ json && isset ( $ json [ 'errors' ] ) ) { $ error = true ; } $ bg = $ error ? 41 : 42 ; print_r ( "\n\n" ) ; print_r ( "\033[{$bg}m-------------------- RESPONSE ----------------------\033[0m\n\n" ) ; print_r ( sprintf ( "STATUS: [%s] %s \n" , $ response -> getStatusCode ( ) , Response :: $ statusTexts [ $ response -> getStatusCode ( ) ] ?? 'Unknown Status' ) ) ; if ( $ json ) { $ output = json_encode ( $ json , JSON_PRETTY_PRINT ) ; } else { $ output = $ content ; } print_r ( $ output ) ; print_r ( "\n\n" ) ; print_r ( "\033[46m------------------- VARIABLES-----------------------\033[0m\n\n" ) ; $ variables = $ this -> client -> getVariables ( ) ?? null ; print_r ( json_encode ( $ variables , JSON_PRETTY_PRINT ) ) ; $ query = $ this -> client -> getGraphQL ( ) ?? null ; $ type = 'QUERY' ; if ( preg_match ( '/^\s*mutation/' , $ query ) ) { $ type = 'MUTATION' ; } print_r ( "\n\n\033[43m----------------------- $type ---------------------\033[0m\n\n" ) ; print_r ( $ query ?? null ) ; print_r ( "\n\n" ) ; print_r ( "-----------------------------------------------------\n\n" ) ; ob_flush ( ) ; } else { throw new \ RuntimeException ( 'Does not exist any executed query on current test, try use this method after "send" the query.' ) ; } }
Print helpful debug information for latest executed query
20,735
public function createService ( ) { $ translator = new TranslatorChain ( ) ; $ translator -> add ( new LangArrayTranslator ( $ this -> dispatcher ) ) ; $ initializer = new TranslatorInitializer ( $ this -> dispatcher ) ; return $ initializer -> initialize ( $ translator ) ; }
Create the translator service .
20,736
private function load ( ) : void { if ( $ this -> state === self :: STATE_LOADED ) return ; if ( $ this -> parameters !== [ ] ) { $ this [ 'parametersForm' ] -> setDefaults ( $ this -> parameters ) ; $ this -> subreport -> attach ( $ this -> parameters ) ; } $ this -> subreport -> compile ( ) ; if ( ! $ this -> subreport -> isState ( Subreport :: STATE_PREPROCESSED ) ) { $ this -> subreport -> preprocess ( ) ; } $ this -> state = self :: STATE_LOADED ; }
Compile preprocess and attach subreport
20,737
public function call ( string $ method , array $ arguments ) : Response { try { return $ this -> request ( 'GET' , $ method , [ 'query' => $ arguments ] ) ; } catch ( \ Exception $ e ) { throw new ClientException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } }
Performs the http call .
20,738
protected function getHandlerStack ( ) { $ handlerStack = HandlerStack :: create ( $ this -> getHandler ( ) ) ; $ this -> configureHandlerStack ( $ handlerStack ) ; return $ handlerStack ; }
Return the stack of handlers and middlewares responsible for processing requests .
20,739
protected function getApiKeyMiddleware ( ) { $ handleRequest = function ( RequestInterface $ request ) { return $ request -> withUri ( Uri :: withQueryValue ( $ request -> getUri ( ) , static :: PARAM_API_KEY , $ this -> apiKey ) ) ; } ; return Middleware :: mapRequest ( $ handleRequest ) ; }
Return the Guzzle Middleware responsible for ensuring the API key is always present in a request .
20,740
private function fig_trans ( Context $ context ) { $ source = $ this -> getAttribute ( 'source' , $ context -> getView ( ) -> defaultTransSource ) ; $ key = $ this -> getAttribute ( 'key' , null ) ; $ dictionaryName = $ this -> getAttribute ( 'dict' , null ) ; $ dictionary = $ context -> getDictionary ( $ dictionaryName ) ; $ dicSource = ( $ dictionary ? $ dictionary -> getSource ( ) : null ) ; if ( ( ( null == $ source ) && ( $ dicSource == $ context -> getView ( ) -> getLanguage ( ) ) ) || ( $ source == $ context -> getView ( ) -> getLanguage ( ) ) ) { $ context -> pushDoNotRenderFigParams ( ) ; $ value = $ this -> renderChildren ( $ context ) ; $ context -> popDoNotRenderFigParams ( ) ; } else { if ( null == $ key ) { $ key = $ this -> renderChildren ( $ context ) ; } $ value = $ context -> translate ( $ key , $ dictionaryName ) ; } $ arguments = array ( ) ; foreach ( $ this -> children as $ child ) { if ( $ child instanceof ViewElementTag ) { if ( $ child -> name == $ context -> view -> figNamespace . 'param' ) { if ( isset ( $ child -> attributes [ 'value' ] ) ) { $ arguments [ $ child -> attributes [ 'name' ] ] = $ this -> evaluate ( $ context , $ child -> attributes [ 'value' ] ) ; } else { $ arguments [ $ child -> attributes [ 'name' ] ] = $ child -> render ( $ context ) ; } } } } $ matches = array ( ) ; while ( preg_match ( '/{([^}]+)}/' , $ value , $ matches ) ) { $ attributeName = $ matches [ 1 ] ; if ( array_key_exists ( $ attributeName , $ arguments ) ) { $ attributeValue = $ arguments [ $ attributeName ] ; } else { $ attributeValue = $ this -> evalAttribute ( $ context , $ attributeName ) ; } $ value = str_replace ( '{' . $ attributeName . '}' , $ attributeValue , $ value ) ; } if ( $ value == '' ) { $ value = $ key ; } return $ value ; }
Translates a caption given its key and dictionary name .
20,741
public static function createFromHex ( $ hexString ) : ? GUID { $ hexString = str_replace ( static :: $ searchChars , static :: $ replaceChars , $ hexString ) ; if ( ! preg_match ( '/^[0-9A-Fa-f]{32}$/' , $ hexString ) ) { return null ; } $ bin = pack ( 'H*' , $ hexString ) ; if ( ! static :: validate ( $ bin ) ) { return null ; } return new static ( $ bin ) ; }
Creates a GUID object from a hex string
20,742
public static function create ( ) : GUID { $ guid = \ random_bytes ( 16 ) ; $ guid [ 6 ] = chr ( ord ( $ guid [ 6 ] ) & 0x0f | 0x40 ) ; $ guid [ 8 ] = chr ( ord ( $ guid [ 8 ] ) & 0x3f | 0x80 ) ; return new static ( $ guid ) ; }
Creates a new V4 UUID
20,743
protected static function validate ( $ guid ) { if ( ByteString :: strlen ( $ guid ) !== 16 ) { return false ; } $ byte = $ guid [ 6 ] ; $ byte = ( ord ( $ byte ) & 0xF0 ) >> 4 ; if ( $ byte !== 4 ) { return false ; } $ byte = $ guid [ 8 ] ; $ byte = ( ord ( $ byte ) & 0xC0 ) ; if ( $ byte !== 0x80 ) { return false ; } return true ; }
Validates the given string is a correct byte stream for a GUID .
20,744
public function format ( $ format = self :: STANDARD ) { $ hexStr = strtolower ( $ this -> asHex ( ) ) ; $ parts = [ substr ( $ hexStr , 0 , 8 ) , substr ( $ hexStr , 8 , 4 ) , substr ( $ hexStr , 12 , 4 ) , substr ( $ hexStr , 16 , 4 ) , substr ( $ hexStr , 20 ) ] ; if ( $ format & self :: UPPERCASE ) { $ parts = array_map ( function ( $ v ) { return strtoupper ( $ v ) ; } , $ parts ) ; } $ separator = '' ; if ( $ format & self :: HYPHENATED ) { $ separator = self :: SEPERATOR_HYPHEN ; } $ formatted = implode ( $ separator , $ parts ) ; if ( $ format & self :: BRACES ) { $ formatted = sprintf ( '{%s}' , $ formatted ) ; } return $ formatted ; }
Outputs a formatted version of the GUID string
20,745
public function asHex ( ) { $ normalizer = function ( $ val ) { return str_pad ( strtoupper ( dechex ( $ val ) ) , 2 , '0' , STR_PAD_LEFT ) ; } ; $ out = unpack ( 'C*' , $ this -> guid ) ; $ out = array_map ( $ normalizer , $ out ) ; $ out = implode ( '' , $ out ) ; return $ out ; }
Outputs the guid as a straight hex string
20,746
public function getSynopsis ( bool $ short = false ) : string { $ key = $ short ? 'short' : 'long' ; if ( ! isset ( $ this -> synopsis [ $ key ] ) ) { $ this -> synopsis [ $ key ] = trim ( sprintf ( '%s %s' , $ this -> getName ( ) , $ this -> getDefinition ( ) -> getSynopsis ( $ short ) ) ) ; } return $ this -> synopsis [ $ key ] ; }
Get the command s synopsis .
20,747
public function setDefinition ( $ definition ) { if ( $ definition instanceof InputDefinition ) { $ this -> definition = $ definition ; } else { $ this -> definition -> setDefinition ( $ definition ) ; } $ this -> applicationDefinitionMerged = false ; }
Sets the input definition for the command .
20,748
public function dump ( ) { $ message = '' ; if ( ! empty ( $ this -> warnings ) ) { uasort ( $ this -> warnings , function ( $ a , $ b ) { if ( count ( $ a ) === count ( $ b ) ) { return 0 ; } return ( count ( $ a ) > count ( $ b ) ) ? - 1 : 1 ; } ) ; foreach ( $ this -> warnings as $ message => $ warnings ) { $ count = count ( $ warnings ) ; print_r ( sprintf ( "\n\033[0;30m\033[43m %sx: %s\033[0m\n" , $ count , $ message ) ) ; } } return $ message ; }
Dump all warning ordered by amount of times triggered
20,749
public function read ( $ path ) { $ data = $ this -> readJson ( $ path ) ; $ this -> validator ( ) -> validate ( $ data ) ; return $ this -> createConfiguration ( $ data ) ; }
Read a Composer configuration file .
20,750
protected function readJson ( $ path ) { $ jsonData = @ file_get_contents ( $ path ) ; if ( false === $ jsonData ) { throw new ConfigurationReadException ( $ path ) ; } $ data = json_decode ( $ jsonData ) ; $ jsonError = json_last_error ( ) ; if ( JSON_ERROR_NONE !== $ jsonError ) { throw new InvalidJsonException ( $ path , $ jsonError ) ; } return new ObjectAccess ( $ data ) ; }
Read JSON data from the supplied path .
20,751
protected function createConfiguration ( ObjectAccess $ data ) { $ autoloadData = new ObjectAccess ( $ data -> getDefault ( 'autoload' , ( object ) array ( ) ) ) ; return new Configuration ( $ data -> getDefault ( 'name' ) , $ data -> getDefault ( 'description' ) , $ data -> getDefault ( 'version' ) , $ data -> getDefault ( 'type' ) , $ data -> getDefault ( 'keywords' ) , $ data -> getDefault ( 'homepage' ) , $ this -> createTime ( $ data -> getDefault ( 'time' ) ) , $ this -> arrayize ( $ data -> getDefault ( 'license' ) ) , $ this -> createAuthors ( $ data -> getDefault ( 'authors' ) ) , $ this -> createSupport ( $ data -> getDefault ( 'support' ) ) , $ this -> objectToArray ( $ data -> getDefault ( 'require' ) ) , $ this -> objectToArray ( $ data -> getDefault ( 'require-dev' ) ) , $ this -> objectToArray ( $ data -> getDefault ( 'conflict' ) ) , $ this -> objectToArray ( $ data -> getDefault ( 'replace' ) ) , $ this -> objectToArray ( $ data -> getDefault ( 'provide' ) ) , $ this -> objectToArray ( $ data -> getDefault ( 'suggest' ) ) , $ this -> createAutoloadPsr ( $ autoloadData -> getDefault ( 'psr-4' ) ) , $ this -> createAutoloadPsr ( $ autoloadData -> getDefault ( 'psr-0' ) ) , $ autoloadData -> getDefault ( 'classmap' ) , $ autoloadData -> getDefault ( 'files' ) , $ data -> getDefault ( 'include-path' ) , $ data -> getDefault ( 'target-dir' ) , $ this -> createStability ( $ data -> getDefault ( 'minimum-stability' ) ) , $ data -> getDefault ( 'prefer-stable' ) , $ this -> createRepositories ( ( array ) $ data -> getDefault ( 'repositories' ) ) , $ this -> createProjectConfiguration ( $ data -> getDefault ( 'config' ) ) , $ this -> createScripts ( $ data -> getDefault ( 'scripts' ) ) , $ data -> getDefault ( 'extra' ) , $ data -> getDefault ( 'bin' ) , $ this -> createArchiveConfiguration ( $ data -> getDefault ( 'archive' ) ) , $ data -> data ( ) ) ; }
Create a configuration object from the supplied JSON data .
20,752
protected function createAuthors ( array $ authors = null ) { if ( null !== $ authors ) { foreach ( $ authors as $ index => $ author ) { $ authors [ $ index ] = $ this -> createAuthor ( new ObjectAccess ( $ author ) ) ; } } return $ authors ; }
Create an author list from the supplied raw value .
20,753
protected function createAuthor ( ObjectAccess $ author ) { return new Author ( $ author -> get ( 'name' ) , $ author -> getDefault ( 'email' ) , $ author -> getDefault ( 'homepage' ) , $ author -> getDefault ( 'role' ) , $ author -> data ( ) ) ; }
Create an author from the supplied raw value .
20,754
protected function createSupport ( stdClass $ support = null ) { if ( null !== $ support ) { $ supportData = new ObjectAccess ( $ support ) ; $ support = new SupportInformation ( $ supportData -> getDefault ( 'email' ) , $ supportData -> getDefault ( 'issues' ) , $ supportData -> getDefault ( 'forum' ) , $ supportData -> getDefault ( 'wiki' ) , $ supportData -> getDefault ( 'irc' ) , $ supportData -> getDefault ( 'source' ) , $ supportData -> data ( ) ) ; } return $ support ; }
Create a support information object from the supplied raw value .
20,755
protected function createAutoloadPsr ( stdClass $ autoloadPsr = null ) { if ( null !== $ autoloadPsr ) { $ autoloadPsr = $ this -> objectToArray ( $ autoloadPsr ) ; foreach ( $ autoloadPsr as $ namespace => $ paths ) { $ autoloadPsr [ $ namespace ] = $ this -> arrayize ( $ paths ) ; } } return $ autoloadPsr ; }
Create PSR - style autoload information from the supplied raw value .
20,756
protected function createStability ( $ stability ) { if ( null !== $ stability ) { $ stability = Stability :: memberByValue ( $ stability , false ) ; } return $ stability ; }
Create a stability enumeration from the supplied raw data .
20,757
protected function createRepositories ( array $ repositories = null ) { if ( null !== $ repositories ) { foreach ( $ repositories as $ index => $ repository ) { $ repositories [ $ index ] = $ this -> createRepository ( new ObjectAccess ( $ repository ) ) ; } } return $ repositories ; }
Create a repository list from the supplied raw value .
20,758
protected function createRepository ( ObjectAccess $ repository ) { if ( $ repository -> exists ( 'packagist' ) ) { return new PackagistRepository ( $ repository -> get ( 'packagist' ) , $ repository -> data ( ) ) ; } $ type = $ repository -> get ( 'type' ) ; if ( 'package' === $ type ) { $ repository = new PackageRepository ( $ this -> objectToArray ( $ repository -> get ( 'package' ) ) , $ this -> objectToArray ( $ repository -> getDefault ( 'options' ) ) , $ repository -> data ( ) ) ; } else { $ repository = new Repository ( $ type , $ repository -> getDefault ( 'url' ) , $ this -> objectToArray ( $ repository -> getDefault ( 'options' ) ) , $ repository -> data ( ) ) ; } return $ repository ; }
Create a repository from the supplied raw value .
20,759
protected function createProjectConfiguration ( stdClass $ config = null ) { if ( null === $ config ) { return new ProjectConfiguration ( null , null , null , null , null , null , null , $ this -> defaultCacheDir ( ) ) ; } $ configData = new ObjectAccess ( $ config ) ; $ cacheDir = $ configData -> getDefault ( 'cache-dir' ) ; if ( null === $ cacheDir ) { $ cacheDir = $ this -> defaultCacheDir ( ) ; } return new ProjectConfiguration ( $ configData -> getDefault ( 'process-timeout' ) , $ configData -> getDefault ( 'use-include-path' ) , $ this -> createInstallationMethod ( $ configData -> getDefault ( 'preferred-install' ) ) , $ configData -> getDefault ( 'github-protocols' ) , $ this -> objectToArray ( $ configData -> getDefault ( 'github-oauth' ) ) , $ configData -> getDefault ( 'vendor-dir' ) , $ configData -> getDefault ( 'bin-dir' ) , $ cacheDir , $ configData -> getDefault ( 'cache-files-dir' ) , $ configData -> getDefault ( 'cache-repo-dir' ) , $ configData -> getDefault ( 'cache-vcs-dir' ) , $ configData -> getDefault ( 'cache-files-ttl' ) , $ configData -> getDefault ( 'cache-files-maxsize' ) , $ configData -> getDefault ( 'prepend-autoloader' ) , $ configData -> getDefault ( 'autoloader-suffix' ) , $ configData -> getDefault ( 'optimize-autoloader' ) , $ configData -> getDefault ( 'github-domains' ) , $ configData -> getDefault ( 'notify-on-install' ) , $ this -> createVcsChangePolicy ( $ configData -> getDefault ( 'discard-changes' ) ) , $ configData -> data ( ) ) ; }
Create a project configuration object from the supplied raw value .
20,760
protected function defaultCacheDir ( ) { $ cacheDir = getenv ( 'COMPOSER_CACHE_DIR' ) ; if ( $ cacheDir ) { return $ cacheDir ; } $ home = getenv ( 'COMPOSER_HOME' ) ; $ isWindows = defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ; if ( ! $ home ) { if ( $ isWindows ) { if ( $ envAppData = getenv ( 'APPDATA' ) ) { $ home = strtr ( $ envAppData , '\\' , '/' ) . '/Composer' ; } } elseif ( $ envHome = getenv ( 'HOME' ) ) { $ home = rtrim ( $ envHome , '/' ) . '/.composer' ; } } if ( $ home && ! $ cacheDir ) { if ( $ isWindows ) { if ( $ cacheDir = getenv ( 'LOCALAPPDATA' ) ) { $ cacheDir .= '/Composer' ; } else { $ cacheDir = $ home . '/cache' ; } $ cacheDir = strtr ( $ cacheDir , '\\' , '/' ) ; } else { $ cacheDir = $ home . '/cache' ; } } if ( ! $ cacheDir ) { return null ; } return $ cacheDir ; }
Get the default cache directory for the current environment .
20,761
protected function createInstallationMethod ( $ method ) { if ( is_string ( $ method ) ) { return InstallationMethod :: memberByValue ( $ method , false ) ; } if ( is_object ( $ method ) ) { $ methods = array ( ) ; foreach ( $ method as $ project => $ projectMethod ) { $ methods [ $ project ] = InstallationMethod :: memberByValue ( $ projectMethod , false ) ; } return $ methods ; } return null ; }
Create a installation method enumeration from the supplied raw data .
20,762
protected function createVcsChangePolicy ( $ policy ) { if ( null !== $ policy ) { $ policy = VcsChangePolicy :: memberByValue ( $ policy , false ) ; } return $ policy ; }
Create a VCS change policy enumeration from the supplied raw data .
20,763
protected function createScripts ( stdClass $ scripts = null ) { if ( null !== $ scripts ) { $ scriptsData = new ObjectAccess ( $ scripts ) ; $ scripts = new ScriptConfiguration ( $ this -> arrayize ( $ scriptsData -> getDefault ( 'pre-install-cmd' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'post-install-cmd' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'pre-update-cmd' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'post-update-cmd' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'pre-status-cmd' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'post-status-cmd' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'pre-package-install' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'post-package-install' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'pre-package-update' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'post-package-update' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'pre-package-uninstall' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'post-package-uninstall' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'pre-autoload-dump' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'post-autoload-dump' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'post-root-package-install' ) ) , $ this -> arrayize ( $ scriptsData -> getDefault ( 'post-create-project-cmd' ) ) , $ scriptsData -> data ( ) ) ; } return $ scripts ; }
Create a script configuration object from the supplied raw value .
20,764
protected function createArchiveConfiguration ( stdClass $ archive = null ) { if ( null !== $ archive ) { $ archiveData = new ObjectAccess ( $ archive ) ; $ archive = new ArchiveConfiguration ( $ archiveData -> getDefault ( 'exclude' ) , $ archiveData -> data ( ) ) ; } return $ archive ; }
Create an archive configuration object from the supplied raw value .
20,765
protected function objectToArray ( stdClass $ data = null ) { if ( null !== $ data ) { $ data = ( array ) $ data ; foreach ( $ data as $ key => $ value ) { if ( $ value instanceof stdClass ) { $ data [ $ key ] = $ this -> objectToArray ( $ value ) ; } } } return $ data ; }
Recursively convert the supplied object to an associative array .
20,766
final function execute ( ) { $ content = $ this -> parseContent ( $ this -> data [ 'bodycontent' ] ) ; if ( ! $ this -> getLayoutClass ( ) ) { throw new \ Exception ( 'No layout class defined.' ) ; } $ layoutClass = $ this -> getLayoutClass ( ) ; $ layout = new $ layoutClass ( $ this -> getSkin ( ) , $ this ) ; $ layout -> addHTMLTo ( 'head' , $ this -> html ( 'headelement' ) ) ; $ layout -> addHTMLTo ( 'logo' , $ this -> data [ 'logopath' ] ) ; $ layout -> addHTMLTo ( 'prepend:body' , $ this -> html ( 'prebodyhtml' ) ) ; if ( $ this -> showTitle ) { $ layout -> addHTMLTo ( 'content-container.class' , 'has-title' ) ; $ layout -> addHTMLTo ( 'title-html' , $ this -> data [ 'title' ] ) ; } $ layout -> addHTMLTo ( 'content-html' , $ content ) ; if ( ! empty ( $ this -> data [ 'sitenotice' ] ) ) { $ layout -> addHTMLTo ( 'site-notice' , $ this -> data [ 'sitenotice' ] ) ; } if ( $ this -> showTagline ) { $ layout -> addHTMLTo ( 'content-container.class' , 'has-tagline' ) ; $ layout -> addHTMLTo ( 'tagline' , $ this -> getMsg ( 'tagline' ) ) ; } $ breadcrumbTrees = $ this -> breadcrumbs ( ) ; $ layout -> addTemplateTo ( 'breadcrumbs' , 'breadcrumbs' , array ( 'trees' => $ breadcrumbTrees ) ) ; $ layout -> addHookTo ( 'footer-links' , array ( $ this , 'getFooterLinks' ) ) ; $ layout -> addHookTo ( 'footer-icons' , array ( $ this , 'getFooterIcons' ) ) ; $ layout -> addHookTo ( 'append:body' , array ( $ this , 'afterFooter' ) ) ; $ this -> data [ 'pageLanguage' ] = $ this -> getSkin ( ) -> getTitle ( ) -> getPageViewLanguage ( ) -> getCode ( ) ; $ this -> initialize ( ) ; echo $ layout -> render ( ) ; }
This is called by MediaWiki to render the skin .
20,767
function transclude ( $ string ) { echo $ GLOBALS [ 'wgParser' ] -> parse ( '{{' . $ string . '}}' , $ this -> getSkin ( ) -> getRelevantTitle ( ) , new ParserOptions ) -> getText ( ) ; }
Transclude a MediaWiki page
20,768
public function parseContent ( $ html ) { $ pattern = '~<p>ADDTEMPLATE\(([\w_:-]*)\):([\w_-]+):ETALPMETDDA<\/p>~m' ; if ( preg_match_all ( $ pattern , $ html , $ matches , PREG_SET_ORDER ) ) { foreach ( $ matches as $ match ) { if ( ! empty ( $ match [ 1 ] ) ) { $ this -> getLayout ( ) -> addTemplateTo ( $ match [ 1 ] , $ match [ 2 ] ) ; $ html = str_replace ( $ match [ 0 ] , '' , $ html ) ; } else { $ html = str_replace ( $ match [ 0 ] , $ this -> getLayout ( ) -> renderTemplate ( $ match [ 2 ] ) , $ html ) ; } } } return $ html ; }
parse the bodytext and insert any templates added by the skintemplate parser function
20,769
private function arrayToObject ( array $ data , FieldsAwareDefinitionInterface $ definition ) { $ class = null ; if ( $ definition instanceof ClassAwareDefinitionInterface ) { $ class = $ definition -> getClass ( ) ; } foreach ( $ data as $ fieldName => & $ value ) { if ( ! $ definition -> hasField ( $ fieldName ) ) { continue ; } $ fieldDefinition = $ definition -> getField ( $ fieldName ) ; $ value = $ this -> normalizeValue ( $ value , $ fieldDefinition -> getType ( ) ) ; } unset ( $ value ) ; if ( class_exists ( $ class ) ) { $ object = new $ class ( ) ; } else { $ object = $ data ; } foreach ( $ data as $ key => $ value ) { if ( ! $ definition -> hasField ( $ key ) ) { continue ; } $ fieldDefinition = $ definition -> getField ( $ key ) ; if ( \ is_array ( $ value ) && $ this -> endpoint -> hasType ( $ fieldDefinition -> getType ( ) ) ) { $ childType = $ this -> endpoint -> getType ( $ fieldDefinition -> getType ( ) ) ; if ( $ childType instanceof FieldsAwareDefinitionInterface ) { $ value = $ this -> arrayToObject ( $ value , $ childType ) ; } } $ this -> setObjectValue ( $ object , $ fieldDefinition , $ value ) ; } return $ object ; }
Convert a array into object using given definition
20,770
public function getUserData ( ) { $ username = $ this -> _username ; $ this -> _requestUrl = self :: USER_DATA_URL . '?username=' . $ username ; $ this -> executeGet ( ) ; if ( $ this -> _responseInfo [ 'http_code' ] == self :: HTTP_CODE_OK ) { $ responseObject = json_decode ( $ this -> _responseBody ) ; return $ responseObject -> UserData ; } throw new AfricasTalkingGatewayException ( $ this -> _responseBody ) ; }
User info method
20,771
private function processAllMessages ( ) { $ processed = [ ] ; $ receivers = $ this -> receivers ( ) ; $ messages = $ this -> manager -> getMessages ( ) ; foreach ( $ receivers as $ receiver ) { foreach ( $ messages as $ index => $ message ) { $ this -> composition ( $ receiver , $ message ) ; $ id = $ this -> sendMessage ( $ receiver , $ message ) ; $ copy = new stdClass ( ) ; $ copy -> id = $ id ; $ copy -> type = $ message -> type ; $ copy -> sender = $ this -> account [ 'number' ] ; $ copy -> nickname = $ this -> account [ 'nickname' ] ; $ copy -> to = implode ( ', ' , ( array ) $ receiver ) ; $ copy -> message = $ message ; if ( isset ( $ message -> file ) && ! $ message -> hash ) { $ copy -> message -> hash = $ messages [ $ index ] -> hash = base64_encode ( hash_file ( "sha256" , $ message -> file , true ) ) ; } foreach ( $ this -> manager -> getInjectedVars ( ) as $ key => $ value ) { $ copy -> $ key = $ value ; } $ processed [ ] = $ copy ; } } $ this -> broadcast = false ; $ this -> manager -> clear ( ) ; return $ processed ; }
Process all messages types
20,772
private function sendMessage ( $ receiver , $ message ) { $ id = null ; switch ( $ message -> type ) { case 'text' : $ id = $ this -> broadcast ? $ this -> gateway ( ) -> sendBroadcastMessage ( $ receiver , $ message -> message ) : $ this -> gateway ( ) -> sendMessage ( $ receiver , $ message -> message ) ; break ; case 'image' : $ id = $ this -> broadcast ? $ this -> gateway ( ) -> sendBroadcastImage ( $ receiver , $ message -> file , false , $ message -> filesize , $ message -> hash , $ message -> caption ) : $ this -> gateway ( ) -> sendMessageImage ( $ receiver , $ message -> file , false , $ message -> filesize , $ message -> hash , $ message -> caption ) ; break ; case 'audio' : $ id = $ this -> broadcast ? $ this -> gateway ( ) -> sendBroadcastAudio ( $ receiver , $ message -> file , false , $ message -> filesize , $ message -> hash ) : $ this -> gateway ( ) -> sendMessageAudio ( $ receiver , $ message -> file , false , $ message -> filesize , $ message -> hash ) ; break ; case 'video' : $ id = $ this -> broadcast ? $ this -> gateway ( ) -> sendBroadcastVideo ( $ receiver , $ message -> file , false , $ message -> filesize , $ message -> hash , $ message -> caption ) : $ this -> gateway ( ) -> sendMessageVideo ( $ receiver , $ message -> file , false , $ message -> filesize , $ message -> hash , $ message -> caption ) ; break ; case 'location' : $ id = $ this -> broadcast ? $ this -> gateway ( ) -> sendBroadcastLocation ( $ receiver , $ message -> longitude , $ message -> latitude , $ message -> caption , $ message -> url ) : $ this -> gateway ( ) -> sendMessageLocation ( $ receiver , $ message -> longitude , $ message -> latitude , $ message -> caption , $ message -> url ) ; break ; case 'vcard' : $ id = $ this -> broadcast ? $ this -> gateway ( ) -> sendBroadcastVcard ( $ receiver , $ message -> name , $ message -> vcard -> show ( ) ) : $ this -> gateway ( ) -> sendVcard ( $ receiver , $ message -> name , $ message -> vcard -> show ( ) ) ; break ; default : break ; } while ( $ this -> gateway ( ) -> pollMessage ( ) ) ; return $ id ; }
Select the best way to send messages and send them returning the MessageID
20,773
private function receivers ( ) { if ( count ( $ this -> manager -> getReceivers ( ) ) <= 10 ) { return $ this -> manager -> getReceivers ( ) ; } $ this -> broadcast = true ; $ receivers = [ ] ; $ allReceivers = $ this -> manager -> getReceivers ( ) ; while ( count ( $ allReceivers ) ) { $ target = [ ] ; $ count = 1 ; while ( $ count <= $ this -> config [ 'broadcast-limit' ] && count ( $ allReceivers ) ) { $ target [ ] = array_shift ( $ allReceivers ) ; $ count ++ ; } $ receivers [ ] = $ target ; } return $ receivers ; }
Set receivers in a broadcast array if needed
20,774
private function composition ( $ receiver , stdClass $ message ) { if ( ! $ this -> broadcast ) { $ this -> typing ( $ receiver ) ; sleep ( $ this -> manager -> composition ( $ message ) ) ; $ this -> paused ( $ receiver ) ; } }
Smart composition before sending messages
20,775
public function connectAndLogin ( ) { if ( ! $ this -> connected ) { $ account = $ this -> config [ "default" ] ; $ this -> whatsProt -> connect ( ) ; $ this -> whatsProt -> loginWithPassword ( $ this -> password ) ; $ this -> whatsProt -> sendGetClientConfig ( ) ; $ this -> whatsProt -> sendGetServerProperties ( ) ; $ this -> whatsProt -> sendGetGroups ( ) ; $ this -> whatsProt -> sendGetBroadcastLists ( ) ; $ this -> whatsProt -> sendGetPrivacyBlockedList ( ) ; $ this -> whatsProt -> sendAvailableForChat ( $ this -> config [ "accounts" ] [ $ account ] [ 'nickname' ] ) ; $ this -> connected = true ; } }
Connect to Whatsapp server and Login
20,776
public function logoutAndDisconnect ( ) { if ( $ this -> connected ) { sleep ( rand ( 1 , 2 ) ) ; $ this -> offline ( ) ; $ this -> whatsProt -> disconnect ( ) ; $ this -> connected = false ; } }
Logout and disconnect from Whatsapp server
20,777
public function getCMSFields ( ) { $ fields = parent :: getCMSFields ( ) ; $ modes = array ( '' => 'No filing' , 'day' => '/Year/Month/Day' , 'month' => '/Year/Month' , 'year' => '/Year' ) ; $ fields -> addFieldToTab ( 'Root.Main' , new DropdownField ( 'FilingMode' , _t ( 'NewsHolder.FILING_MODE' , 'File into' ) , $ modes ) , 'Content' ) ; $ fields -> addFieldToTab ( 'Root.Main' , new DropdownField ( 'FileBy' , _t ( 'NewsHolder.FILE_BY' , 'File by' ) , array ( 'Published' => 'Published' , 'Created' => 'Created' ) ) , 'Content' ) ; $ fields -> addFieldToTab ( 'Root.Main' , new CheckboxField ( 'PrimaryNewsSection' , _t ( 'NewsHolder.PRIMARY_SECTION' , 'Is this a primary news section?' ) , true ) , 'Content' ) ; $ fields -> addFieldToTab ( 'Root.Main' , new DropdownField ( 'OrderBy' , _t ( 'NewsHolder.ORDER_BY' , 'Order by' ) , array ( 'OriginalPublishedDate' => 'Published' , 'Created' => 'Created' ) ) , 'Content' ) ; $ fields -> addFieldToTab ( 'Root.Main' , new DropdownField ( 'OrderDir' , _t ( 'NewsHolder.ORDER_DIR' , 'Order direction' ) , array ( 'DESC' => 'Descending date' , 'ASC' => 'Ascending date' ) ) , 'Content' ) ; $ this -> extend ( 'updateNewsHolderCMSFields' , $ fields ) ; return $ fields ; }
Gets the fields to display for this news holder in the CMS
20,778
public function Articles ( $ number = null ) { if ( ! $ number ) { $ number = $ this -> numberToDisplay ; } $ start = isset ( $ _REQUEST [ 'start' ] ) ? ( int ) $ _REQUEST [ 'start' ] : 0 ; if ( $ start < 0 ) { $ start = 0 ; } $ articles = null ; $ filter = null ; if ( $ this -> PrimaryNewsSection ) { $ filter = array ( 'NewsSectionID' => $ this -> ID ) ; } else { $ subholders = $ this -> SubSections ( ) ; if ( $ subholders ) { $ subholders -> push ( $ this ) ; } else { $ subholders = null ; } if ( $ subholders && $ subholders -> Count ( ) ) { $ ids = $ subholders -> column ( 'ID' ) ; $ filter = array ( 'ParentID' => $ ids ) ; } else { $ filter = array ( 'ParentID' => ( int ) $ this -> ID ) ; } } $ orderBy = strlen ( $ this -> OrderBy ) ? $ this -> OrderBy : 'OriginalPublishedDate' ; $ dir = strlen ( $ this -> OrderDir ) ? $ this -> OrderDir : 'DESC' ; if ( ! in_array ( $ dir , array ( 'ASC' , 'DESC' ) ) ) { $ dir = 'DESC' ; } $ articles = NewsArticle :: get ( ) -> filter ( $ filter ) -> sort ( array ( $ orderBy => $ dir ) ) -> limit ( $ number , $ start ) ; $ entries = PaginatedList :: create ( $ articles ) ; $ entries -> setPaginationFromQuery ( $ articles -> dataQuery ( ) -> query ( ) ) ; return $ entries ; }
Returns a list of articles within this news holder .
20,779
public function SubSections ( $ allChildren = true ) { $ subs = null ; $ childHolders = NewsHolder :: get ( ) -> filter ( 'ParentID' , $ this -> ID ) ; if ( $ childHolders && $ childHolders -> count ( ) ) { $ subs = new ArrayList ( ) ; foreach ( $ childHolders as $ holder ) { $ subs -> push ( $ holder ) ; if ( $ allChildren === true ) { $ subSub = $ holder -> SubSections ( ) ; if ( $ subSub ) { $ subs -> merge ( $ subSub ) ; } } } } return $ subs ; }
Returns a list of sub news sections if available
20,780
public function getPartitionedHolderForArticle ( $ article ) { if ( $ this -> FileBy == 'Published' && $ article -> OriginalPublishedDate ) { $ date = $ article -> OriginalPublishedDate ; } else if ( $ this -> hasField ( $ this -> FileBy ) ) { $ field = $ this -> FileBy ; $ date = $ this -> $ field ; } else { $ date = $ article -> Created ; } $ year = date ( 'Y' , strtotime ( $ date ) ) ; $ month = date ( 'M' , strtotime ( $ date ) ) ; $ day = date ( 'd' , strtotime ( $ date ) ) ; $ yearFolder = $ this -> dateFolder ( $ year ) ; if ( ! $ yearFolder ) { throw new Exception ( "Failed retrieving folder" ) ; } if ( $ this -> FilingMode == 'year' ) { return $ yearFolder ; } $ monthFolder = $ yearFolder -> dateFolder ( $ month ) ; if ( ! $ monthFolder ) { throw new Exception ( "Failed retrieving folder" ) ; } if ( $ this -> FilingMode == 'month' ) { return $ monthFolder ; } $ dayFolder = $ monthFolder -> dateFolder ( $ day ) ; if ( ! $ dayFolder ) { throw new Exception ( "Failed retrieving folder" ) ; } return $ dayFolder ; }
Gets an appropriate sub article holder for the given article page
20,781
public function TotalChildArticles ( $ number = null ) { if ( ! $ number ) { $ number = $ this -> numberToDisplay ; } $ start = isset ( $ _REQUEST [ 'start' ] ) ? ( int ) $ _REQUEST [ 'start' ] : 0 ; if ( $ start < 0 ) { $ start = 0 ; } $ articles = NewsArticle :: get ( 'NewsArticle' , '' , '"OriginalPublishedDate" DESC, "ID" DESC' , '' , $ start . ',' . $ number ) -> filter ( array ( 'ID' => $ this -> getDescendantIDList ( ) ) ) ; $ entries = PaginatedList :: create ( $ articles ) ; $ entries -> setPaginationFromQuery ( $ articles -> dataQuery ( ) -> query ( ) ) ; return $ entries ; }
We do not want to use NewsHolder - > SubSections because this splits the paginations into the categories the articles are in which means the pagination will not work or will display multiple times
20,782
public function autoloadTypes ( ) { if ( self :: $ loaded ) { return ; } if ( ! $ this -> kernel -> isDebug ( ) && $ this -> loadFromCacheCache ( ) ) { self :: $ loaded = true ; return ; } self :: $ loaded = true ; foreach ( $ this -> kernel -> getBundles ( ) as $ bundle ) { $ path = $ bundle -> getPath ( ) . '/Type' ; if ( file_exists ( $ path ) ) { $ this -> registerBundleTypes ( $ path , $ bundle -> getNamespace ( ) ) ; } } if ( Kernel :: VERSION_ID >= 40000 ) { $ path = $ this -> kernel -> getRootDir ( ) . '/Type' ; if ( file_exists ( $ path ) ) { $ this -> registerBundleTypes ( $ path , 'App' ) ; } } $ this -> saveCache ( ) ; }
Autoload all registered types
20,783
protected function registerBundleTypes ( $ path , $ namespace ) { $ finder = new Finder ( ) ; foreach ( $ finder -> in ( $ path ) -> name ( '/Type.php$/' ) -> getIterator ( ) as $ file ) { $ className = preg_replace ( '/.php$/' , null , $ file -> getFilename ( ) ) ; if ( $ file -> getRelativePath ( ) ) { $ subNamespace = str_replace ( '/' , '\\' , $ file -> getRelativePath ( ) ) ; $ fullyClassName = $ namespace . '\\Type\\' . $ subNamespace . '\\' . $ className ; } else { $ fullyClassName = $ namespace . '\\Type\\' . $ className ; } if ( class_exists ( $ fullyClassName ) ) { $ ref = new \ ReflectionClass ( $ fullyClassName ) ; if ( $ ref -> isSubclassOf ( Type :: class ) && $ ref -> isInstantiable ( ) ) { $ requiredParams = false ; foreach ( $ ref -> getConstructor ( ) -> getParameters ( ) as $ parameter ) { if ( $ parameter -> getClass ( ) && $ parameter -> getClass ( ) -> implementsInterface ( DefinitionInterface :: class ) ) { continue 2 ; } } if ( $ requiredParams ) { $ error = sprintf ( 'The graphql type defined in class "%s" is not instantiable because has some required parameters in the constructor.' , $ fullyClassName ) ; throw new \ LogicException ( $ error ) ; } $ instance = $ ref -> newInstance ( ) ; TypeRegistry :: addTypeMapping ( $ instance -> name , $ fullyClassName ) ; } } } }
Register all GraphQL types for given path
20,784
private function dateTimeToTimePoint ( DateTime $ date ) { if ( ! $ date -> getTimezone ( ) instanceof DateTimeZone || preg_match ( '#^[+-]{1}[0-9]{2}:?[0-9]{2}$#' , $ date -> getTimezone ( ) -> getName ( ) ) ) { $ date -> setTimezone ( new DateTimeZone ( 'UTC' ) ) ; } try { $ timezone = new DateTimeZone ( $ date -> getTimezone ( ) -> getName ( ) ) ; } catch ( Exception $ e ) { $ date -> setTimezone ( new DateTimeZone ( 'UTC' ) ) ; } return new TimePoint ( ( int ) $ date -> format ( 'Y' ) , ( int ) $ date -> format ( 'm' ) , ( int ) $ date -> format ( 'd' ) , ( int ) $ date -> format ( 'H' ) , ( int ) $ date -> format ( 'i' ) , ( int ) $ date -> format ( 's' ) , $ date -> getTimezone ( ) -> getName ( ) , ( int ) $ date -> format ( 'u' ) ) ; }
Convert a DateTime to a TimePoint
20,785
private function dateIntervalToIntervalSpec ( DateInterval $ interval ) { $ date = sprintf ( '%uY%uM%uD' , $ interval -> y , $ interval -> m , $ interval -> d ) ; $ time = sprintf ( '%uH%uM%uS' , $ interval -> h , $ interval -> i , $ interval -> s ) ; $ extra = '' ; if ( $ interval -> invert ) { $ extra .= 'I' ; } if ( $ interval -> days ) { $ extra .= $ interval -> days . 'D' ; } if ( strlen ( $ extra ) > 0 ) { $ extra = '-' . $ extra ; } return sprintf ( 'P%sT%s%s' , $ date , $ time , $ extra ) ; }
Create a Dateinterval spec from DateInterval properties
20,786
protected static function sortPluralizedCompare ( $ a , $ b ) { if ( $ a == $ b ) { return 0 ; } $ rangeA = explode ( ':' , $ a ) ; $ rangeB = explode ( ':' , $ b ) ; if ( isset ( $ rangeA [ 0 ] ) && isset ( $ rangeB [ 0 ] ) ) { return strcmp ( $ rangeA [ 0 ] , $ rangeB [ 0 ] ) ; } if ( ! isset ( $ rangeA [ 0 ] ) && isset ( $ rangeB [ 0 ] ) ) { return - 1 ; } if ( isset ( $ rangeA [ 0 ] ) && ! isset ( $ rangeB [ 0 ] ) ) { return 1 ; } if ( isset ( $ rangeA [ 1 ] ) && isset ( $ rangeB [ 1 ] ) ) { return strcmp ( $ rangeA [ 1 ] , $ rangeB [ 1 ] ) ; } if ( ! isset ( $ rangeA [ 1 ] ) && isset ( $ rangeB [ 1 ] ) ) { return 1 ; } if ( isset ( $ rangeA [ 1 ] ) && ! isset ( $ rangeB [ 1 ] ) ) { return - 1 ; } return 0 ; }
Compare function for the pluralization array to be used as sorting callback .
20,787
public function setValuePluralized ( $ string , $ value , $ min = null , $ max = null , $ domain = null , $ locale = null ) { if ( ! $ domain ) { $ domain = 'default' ; } if ( ! $ locale ) { $ locale = 'default' ; } if ( ! ( isset ( $ this -> values [ $ locale ] ) && is_array ( $ this -> values [ $ locale ] ) ) ) { $ this -> values [ $ locale ] = array ( ) ; } if ( ! ( isset ( $ this -> values [ $ locale ] [ $ domain ] ) && is_array ( $ this -> values [ $ locale ] [ $ domain ] ) ) ) { $ this -> values [ $ locale ] [ $ domain ] = array ( ) ; } if ( isset ( $ this -> values [ $ locale ] [ $ domain ] [ $ string ] ) && is_array ( $ this -> values [ $ locale ] [ $ domain ] [ $ string ] ) ) { $ lang = $ this -> values [ $ locale ] [ $ domain ] [ $ string ] ; } else { $ lang = array ( ) ; } $ lang [ $ this -> determineKey ( $ min , $ max ) ] = $ value ; $ lang = $ this -> sortPluralized ( $ lang ) ; $ this -> setValue ( $ string , $ lang , $ domain , $ locale ) ; return $ this ; }
Set a pluralized value in the translator .
20,788
protected function determineKey ( $ min , $ max ) { $ minGiven = ( $ min !== null ) ; $ maxGiven = ( $ max !== null ) ; if ( ! $ minGiven && ! $ maxGiven ) { throw new InvalidArgumentException ( 'You must specify a valid value for min, max or both.' ) ; } if ( $ minGiven && ! $ maxGiven ) { return $ min . ':' ; } elseif ( ! $ minGiven && $ maxGiven ) { return ':' . $ max ; } if ( $ min === $ max ) { return $ min ; } return $ min . ':' . $ max ; }
Determine the correct pluralization key .
20,789
public function setValue ( $ string , $ value , $ domain = null , $ locale = null ) { if ( ! $ domain ) { $ domain = 'default' ; } if ( ! $ locale ) { $ locale = 'default' ; } if ( ! ( isset ( $ this -> values [ $ locale ] ) && is_array ( $ this -> values [ $ locale ] ) ) ) { $ this -> values [ $ locale ] = array ( ) ; } if ( ! ( isset ( $ this -> values [ $ locale ] [ $ domain ] ) && is_array ( $ this -> values [ $ locale ] [ $ domain ] ) ) ) { $ this -> values [ $ locale ] [ $ domain ] = array ( ) ; } $ this -> values [ $ locale ] [ $ domain ] [ $ string ] = $ value ; return $ this ; }
Set a translation value in the translator .
20,790
protected function getValue ( $ string , $ domain , $ locale ) { if ( ! $ domain ) { $ domain = 'default' ; } if ( ! $ locale ) { $ locale = 'default' ; } if ( ! isset ( $ this -> values [ $ locale ] [ $ domain ] [ $ string ] ) ) { return $ string ; } return $ this -> values [ $ locale ] [ $ domain ] [ $ string ] ; }
Retrieve the value .
20,791
private function getOrCreateEndpoint ( $ endpoint ) { if ( ! array_key_exists ( $ endpoint , $ this -> endpoints ) ) { if ( ! array_key_exists ( $ endpoint , self :: $ endpointClassMap ) ) { throw new \ Exception ( sprintf ( 'Unknown endpoint "%s"' , $ endpoint ) ) ; } $ endpointClass = self :: $ endpointClassMap [ $ endpoint ] ; $ this -> endpoints [ $ endpoint ] = $ this -> createEndpoint ( $ endpointClass ) ; } return $ this -> endpoints [ $ endpoint ] ; }
Create or return an cached instance of the requested endpoint .
20,792
public function getQueryBuilder ( $ type = 'default' ) { return isset ( $ this -> queryBuilders [ $ type ] ) ? Injector :: inst ( ) -> create ( $ this -> queryBuilders [ $ type ] ) : Injector :: inst ( ) -> create ( $ this -> queryBuilders [ 'default' ] ) ; }
Gets the query builder for the given search type
20,793
public function index ( $ dataObject , $ stage = null , $ fieldBoost = array ( ) ) { $ document = $ this -> convertObjectToDocument ( $ dataObject , $ stage , $ fieldBoost ) ; if ( $ document ) { try { $ this -> getSolr ( ) -> addDocument ( $ document ) ; $ this -> getSolr ( ) -> commit ( ) ; if ( mt_rand ( 0 , 100 ) == 42 ) { $ this -> getSolr ( ) -> optimize ( ) ; } } catch ( Exception $ ie ) { SS_Log :: log ( $ ie , SS_Log :: ERR ) ; } } }
Assuming here that we re indexing a stdClass object with an ID field that is a unique identifier
20,794
protected function objectToFields ( $ dataObject ) { $ ret = array ( ) ; $ fields = Config :: inst ( ) -> get ( $ dataObject -> ClassName , 'db' ) ; $ fields [ 'Created' ] = 'SS_Datetime' ; $ fields [ 'LastEdited' ] = 'SS_Datetime' ; $ ret [ 'ClassName' ] = array ( 'Type' => 'Varchar' , 'Value' => $ dataObject -> class ) ; $ ret [ 'SS_ID' ] = array ( 'Type' => 'Int' , 'Value' => $ dataObject -> ID ) ; foreach ( $ fields as $ name => $ type ) { if ( preg_match ( '/^(\w+)\(/' , $ type , $ match ) ) { $ type = $ match [ 1 ] ; } $ value = $ dataObject -> $ name ; if ( $ type == 'MultiValueField' && $ value instanceof MultiValueField ) { $ value = $ value -> getValues ( ) ; } $ ret [ $ name ] = array ( 'Type' => $ type , 'Value' => $ value ) ; } $ rels = Config :: inst ( ) -> get ( $ dataObject -> ClassName , 'has_one' ) ; if ( $ rels ) foreach ( array_keys ( $ rels ) as $ rel ) { $ ret [ "{$rel}ID" ] = array ( 'Type' => 'ForeignKey' , 'Value' => $ dataObject -> { $ rel . "ID" } ) ; } if ( $ dataObject -> hasMethod ( 'additionalSolrValues' ) ) { $ extras = $ dataObject -> invokeWithExtensions ( 'additionalSolrValues' ) ; if ( $ extras && is_array ( $ extras ) ) { foreach ( $ extras as $ add ) { foreach ( $ add as $ k => $ v ) { $ ret [ $ k ] = array ( 'Type' => $ this -> mapper -> mapValueToType ( $ k , $ v ) , 'Value' => $ v , ) ; } } } } return $ ret ; }
Pull out all the fields that should be indexed for a particular object
20,795
public function unindex ( $ typeOrId ) { $ id = $ typeOrId ; if ( is_object ( $ typeOrId ) ) { $ type = $ typeOrId -> class ; $ id = $ type . '_' . $ typeOrId -> ID ; } else { $ id = self :: RAW_DATA_KEY . $ id ; } try { $ this -> getSolr ( ) -> deleteByQuery ( 'id:' . $ id ) ; $ this -> getSolr ( ) -> deleteByQuery ( 'id:' . $ id . '_*' ) ; $ this -> getSolr ( ) -> commit ( ) ; } catch ( Exception $ ie ) { SS_Log :: log ( $ ie , SS_Log :: ERR ) ; } }
Delete a data object from the index
20,796
public function parseSearch ( $ query , $ type = 'default' ) { if ( strpos ( $ query , ':' ) ) { return $ query ; } if ( isset ( $ this -> queryBuilders [ $ type ] ) ) { return $ this -> queryBuilders [ $ type ] -> parse ( $ query ) ; } $ lucene = implode ( ':' . $ query . ' OR ' , self :: $ default_query_fields ) . ':' . $ query ; return $ lucene ; }
Parse a raw user search string into a query appropriate for execution .
20,797
public function query ( $ query , $ offset = 0 , $ limit = 20 , $ params = array ( ) , $ andWith = array ( ) ) { if ( is_string ( $ query ) ) { $ builder = $ this -> getQueryBuilder ( 'default' ) ; $ builder -> baseQuery ( $ query ) ; $ query = $ builder ; } if ( ClassInfo :: exists ( 'Subsite' ) ) { $ query -> andWith ( 'SubsiteID_i' , Subsite :: currentSubsiteID ( ) ) ; } $ stage = Versioned :: current_stage ( ) ; if ( ! $ stage && ! ( isset ( $ params [ 'ignore_stage' ] ) && $ params [ 'ignore_stage' ] ) ) { $ stage = 'Live' ; } if ( ! isset ( $ params [ 'ignore_stage' ] ) || ! $ params [ 'ignore_stage' ] ) { $ query -> addFilter ( 'SS_Stage_ms' , $ stage ) ; } if ( $ andWith ) { foreach ( $ andWith as $ field => $ value ) { $ query -> andWith ( $ field , $ value ) ; } } $ extraParams = $ query -> getParams ( ) ; $ params = array_merge ( $ params , $ extraParams ) ; $ query = $ query -> toString ( ) ; $ response = null ; $ rawResponse = null ; $ solr = $ this -> getSolr ( ) ; $ key = null ; if ( $ this -> cache ) { $ key = md5 ( $ query . $ offset . $ limit . serialize ( $ params ) ) ; if ( $ rawResponse = $ this -> cache -> load ( $ key ) ) { $ response = new Apache_Solr_Response ( $ rawResponse , array ( 'HTTP/1.1 200 OK' , 'Content-Type: text/plain; charset=utf-8' ) , $ solr -> getCreateDocuments ( ) , $ solr -> getCollapseSingleValueArrays ( ) ) ; } } if ( ! $ response ) { if ( $ this -> isConnected ( ) ) { try { $ response = $ this -> getSolr ( ) -> search ( $ query , $ offset , $ limit , $ params ) ; } catch ( Exception $ e ) { SS_Log :: log ( $ e , SS_Log :: WARN ) ; } } } $ queryParams = new stdClass ( ) ; $ queryParams -> offset = $ offset ; $ queryParams -> limit = $ limit ; $ queryParams -> params = $ params ; $ results = new SolrResultSet ( $ query , $ response , $ queryParams , $ this ) ; if ( $ this -> cache && ! $ rawResponse && $ key && $ response ) { $ this -> cache -> save ( $ response -> getRawResponse ( ) , $ key , array ( ) , $ this -> cacheTime ) ; } return $ results ; }
Perform a raw query against the search index returning a SolrResultSet object that can be used to extract a more complete result set
20,798
public function getFacetsForFields ( $ fields , $ number = 10 ) { if ( ! is_array ( $ fields ) ) { $ fields = array ( $ fields ) ; } return $ this -> query ( '*' , 0 , 1 , array ( 'facet' => 'true' , 'facet.field' => $ fields , 'facet.limit' => 10 , 'facet.mincount' => 1 ) ) ; }
Method used to return details about the facets stored for content if any for an empty query .
20,799
public function getSolr ( ) { if ( ! $ this -> client ) { if ( ! $ this -> solrTransport ) { $ this -> solrTransport = new Apache_Solr_HttpTransport_Curl ; } $ this -> client = new Apache_Solr_Service ( self :: $ solr_details [ 'host' ] , self :: $ solr_details [ 'port' ] , self :: $ solr_details [ 'context' ] , $ this -> solrTransport ) ; } return $ this -> client ; }
Get the solr service client