idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
2,400
public function getValue ( $ name = 'key' ) { if ( ! isset ( $ this -> rawData [ $ name ] ) ) { return null ; } return $ this -> rawData [ $ name ] ; }
Returns aggregation value by name .
2,401
public function getBuckets ( ) { if ( ! isset ( $ this -> rawData [ 'buckets' ] ) ) { return null ; } $ buckets = [ ] ; foreach ( $ this -> rawData [ 'buckets' ] as $ bucket ) { $ buckets [ ] = new self ( $ bucket ) ; } return $ buckets ; }
Returns array of bucket values .
2,402
public function getAggregation ( $ name ) { if ( ! isset ( $ this -> rawData [ $ name ] ) ) { return null ; } return new self ( $ this -> rawData [ $ name ] ) ; }
Returns sub - aggregation .
2,403
public function find ( $ path ) { $ name = explode ( '.' , $ path , 2 ) ; $ aggregation = $ this -> getAggregation ( $ name [ 0 ] ) ; if ( $ aggregation === null || ! isset ( $ name [ 1 ] ) ) { return $ aggregation ; } return $ aggregation -> find ( $ name [ 1 ] ) ; }
Applies path method to aggregations .
2,404
public function importIndex ( Manager $ manager , $ filename , OutputInterface $ output , $ options ) { $ reader = $ this -> getReader ( $ manager , $ this -> getFilePath ( $ filename ) , $ options ) ; $ progress = new ProgressBar ( $ output , $ reader -> count ( ) ) ; $ progress -> setRedrawFrequency ( 100 ) ; $ progr...
Imports Elasticsearch index data .
2,405
protected function getFilePath ( $ filename ) { if ( $ filename { 0 } == '/' || strstr ( $ filename , ':' ) !== false ) { return $ filename ; } return realpath ( getcwd ( ) . '/' . $ filename ) ; }
Returns a real file path .
2,406
private function askForPropertyName ( InputInterface $ input , OutputInterface $ output , $ default = null ) { return $ this -> questionHelper -> ask ( $ input , $ output , $ this -> getQuestion ( "\n" . 'Property name in Elasticsearch' , $ default , [ $ this , 'validateFieldName' ] ) ) ; }
Asks for property name
2,407
private function askForPropertyOptions ( InputInterface $ input , OutputInterface $ output ) { $ output -> writeln ( "\n" . '<info>Enter property options, for example <comment>"index"="not_analyzed"</comment>' . ' allows mapper to index this field, so it is searchable, but value will be not analyzed.</info>' ) ; return...
Asks for property options
2,408
private function askForPropertyClass ( InputInterface $ input , OutputInterface $ output ) { return $ this -> questionHelper -> ask ( $ input , $ output , $ this -> getQuestion ( "\n" . 'Property class' , null , [ $ this , 'validatePropertyClass' ] , array_merge ( $ this -> getDocumentClasses ( ) , array_keys ( $ this ...
Asks for property class
2,409
private function getDocumentClasses ( ) { $ metadataCollector = $ this -> getContainer ( ) -> get ( 'es.metadata_collector' ) ; $ classes = [ ] ; foreach ( $ this -> getContainer ( ) -> getParameter ( 'es.managers' ) as $ manager ) { $ documents = $ metadataCollector -> getMappings ( $ manager [ 'mappings' ] ) ; foreac...
Returns available document classes
2,410
private function parseShortcutNotation ( $ shortcut ) { $ shortcut = str_replace ( '/' , '\\' , $ shortcut ) ; if ( false === $ pos = strpos ( $ shortcut , ':' ) ) { throw $ this -> getException ( 'The document name isn\'t valid ("%s" given, expecting something like AcmeBundle:Post)' , [ $ shortcut ] ) ; } return [ sub...
Parses shortcut notation
2,411
public function validatePropertyClass ( $ input ) { list ( $ bundle , $ document ) = $ this -> parseShortcutNotation ( $ input ) ; try { $ bundlePath = $ this -> getContainer ( ) -> get ( 'kernel' ) -> getBundle ( $ bundle ) -> getPath ( ) ; } catch ( \ Exception $ e ) { throw $ this -> getException ( 'Bundle "%s" does...
Validates property class
2,412
public function validateFieldName ( $ field ) { if ( ! $ field || $ field != lcfirst ( preg_replace ( '/[^a-zA-Z]+/' , '' , $ field ) ) ) { throw $ this -> getException ( 'The parameter isn\'t valid ("%s" given, expecting camelcase separated words)' , [ $ field ] ) ; } if ( in_array ( strtolower ( $ field ) , $ this ->...
Validates field name
2,413
public function validatePropertyType ( $ type ) { if ( ! in_array ( $ type , $ this -> getPropertyTypes ( ) ) ) { throw $ this -> getException ( 'The property type isn\'t valid ("%s" given, expecting one of following: %s)' , [ $ type , implode ( ', ' , $ this -> getPropertyTypes ( ) ) ] ) ; } return $ type ; }
Validates property type
2,414
public function validateDocumentAnnotation ( $ annotation ) { if ( ! in_array ( $ annotation , $ this -> getDocumentAnnotations ( ) ) ) { throw $ this -> getException ( 'The document annotation isn\'t valid ("%s" given, expecting one of following: %s)' , [ $ annotation , implode ( ', ' , $ this -> getDocumentAnnotation...
Validates document annotation
2,415
public function validatePropertyAnnotation ( $ annotation ) { if ( ! in_array ( $ annotation , $ this -> propertyAnnotations ) ) { throw $ this -> getException ( 'The property annotation isn\'t valid ("%s" given, expecting one of following: %s)' , [ $ annotation , implode ( ', ' , $ this -> propertyAnnotations ) ] ) ; ...
Validates property annotation
2,416
public function validatePropertyVisibility ( $ visibility ) { if ( ! in_array ( $ visibility , $ this -> propertyVisibilities ) ) { throw $ this -> getException ( 'The property visibility isn\'t valid ("%s" given, expecting one of following: %s)' , [ $ visibility , implode ( ', ' , $ this -> propertyVisibilities ) ] ) ...
Validates property visibility
2,417
private function getQuestion ( $ question , $ default = null , callable $ validator = null , array $ values = null ) { $ question = new Question ( sprintf ( '<info>%s</info>%s: ' , $ question , $ default ? sprintf ( ' [<comment>%s</comment>]' , $ default ) : '' ) , $ default ) ; $ question -> setValidator ( $ validator...
Returns formatted question
2,418
private function getOptionsLabel ( array $ options , $ suffix ) { $ label = sprintf ( '<info>%s:</info> ' , $ suffix ) ; foreach ( $ options as & $ option ) { $ option = sprintf ( '<comment>%s</comment>' , $ option ) ; } return [ '' , $ label . implode ( ', ' , $ options ) . '.' ] ; }
Returns options label
2,419
private function getException ( $ format , $ args = [ ] ) { $ formatter = $ this -> getHelperSet ( ) -> get ( 'formatter' ) ; return new \ InvalidArgumentException ( $ formatter -> formatBlock ( vsprintf ( $ format , $ args ) , 'bg=red' , true ) ) ; }
Returns formatted exception
2,420
private function getPropertyTypes ( ) { $ reflection = new \ ReflectionClass ( 'ONGR\ElasticsearchBundle\Annotation\Property' ) ; return $ this -> getContainer ( ) -> get ( 'es.annotations.cached_reader' ) -> getPropertyAnnotation ( $ reflection -> getProperty ( 'type' ) , 'Doctrine\Common\Annotations\Annotation\Enum' ...
Returns available property types
2,421
public function getNamespace ( $ namespace , $ documentsDirectory = null ) { if ( ! $ documentsDirectory ) { $ documentsDirectory = $ this -> documentDir ; } if ( strpos ( $ namespace , ':' ) !== false ) { list ( $ bundle , $ document ) = explode ( ':' , $ namespace ) ; $ bundle = $ this -> getBundleClass ( $ bundle ) ...
Formats namespace from short syntax .
2,422
public function getBundleClass ( $ name ) { if ( array_key_exists ( $ name , $ this -> bundles ) ) { return $ this -> bundles [ $ name ] ; } throw new \ LogicException ( sprintf ( 'Bundle \'%s\' does not exist.' , $ name ) ) ; }
Returns bundle class namespace else throws an exception .
2,423
public function getBundleDocumentClasses ( $ bundle , $ documentsDirectory = null ) { if ( ! $ documentsDirectory ) { $ documentsDirectory = $ this -> documentDir ; } $ bundleReflection = new \ ReflectionClass ( $ this -> getBundleClass ( $ bundle ) ) ; $ documentsDirectory = DIRECTORY_SEPARATOR . str_replace ( '\\' , ...
Returns a list of bundle document classes .
2,424
public function setNextFreeIndex ( Manager $ manager , \ DateTime $ time = null ) { if ( $ time === null ) { $ time = new \ DateTime ( ) ; } $ date = $ time -> format ( 'Y.m.d' ) ; $ indexName = $ manager -> getIndexName ( ) ; $ nameBase = $ indexName . '-' . $ date ; $ name = $ nameBase ; $ i = 0 ; $ manager -> setInd...
Constructs index name with date suffix . Sets name in the connection .
2,425
protected function initialize ( ) { if ( $ this -> handle !== null ) { return ; } $ this -> handle = fopen ( $ this -> filename , 'w' ) ; fwrite ( $ this -> handle , "[\n" ) ; fwrite ( $ this -> handle , json_encode ( $ this -> metadata ) ) ; }
Performs initialization .
2,426
public function finalize ( ) { $ this -> initialize ( ) ; if ( is_resource ( $ this -> handle ) ) { fwrite ( $ this -> handle , "\n]" ) ; fclose ( $ this -> handle ) ; } }
Performs finalization .
2,427
public function push ( $ document ) { $ this -> initialize ( ) ; $ this -> currentPosition ++ ; if ( isset ( $ this -> metadata [ 'count' ] ) && $ this -> currentPosition > $ this -> metadata [ 'count' ] ) { throw new \ OverflowException ( sprintf ( 'This writer was set up to write %d documents, got more.' , $ this -> ...
Writes single document to stream .
2,428
public function generate ( BundleInterface $ bundle , $ document , $ annotation , $ type , array $ properties ) { $ documentPath = $ bundle -> getPath ( ) . '/Document/' . str_replace ( '\\' , '/' , $ document ) . '.php' ; $ class = [ 'name' => $ bundle -> getNamespace ( ) . '\\Document\\' . $ document , 'annotation' =...
Generates document class
2,429
public function getAggregations ( ) { $ aggregations = [ ] ; foreach ( parent :: getAggregations ( ) as $ key => $ aggregation ) { $ aggregations [ $ key ] = $ this -> getAggregation ( $ key ) ; } return $ aggregations ; }
Returns aggregations .
2,430
public function getAggregation ( $ name ) { $ aggregations = parent :: getAggregations ( ) ; if ( ! array_key_exists ( $ name , $ aggregations ) ) { return null ; } return new AggregationValue ( $ aggregations [ $ name ] ) ; }
Get a specific aggregation by name . It fetches from the top level only .
2,431
public function onKernelTerminate ( ) { foreach ( $ this -> managers as $ key => $ value ) { if ( $ value [ 'force_commit' ] ) { try { $ manager = $ this -> container -> get ( sprintf ( 'es.manager.%s' , $ key ) ) ; } catch ( \ Exception $ e ) { continue ; } $ manager -> commit ( ) ; } } }
Forces commit to elasticsearch on kernel terminate
2,432
public function find ( $ id , $ routing = null ) { return $ this -> manager -> find ( $ this -> type , $ id , $ routing ) ; }
Returns a single document data by ID or null if document is not found .
2,433
public function findByIds ( array $ ids ) { $ args = [ ] ; $ manager = $ this -> getManager ( ) ; $ args [ 'body' ] [ 'docs' ] = [ ] ; $ args [ 'index' ] = $ manager -> getIndexName ( ) ; $ args [ 'type' ] = $ this -> getType ( ) ; foreach ( $ ids as $ id ) { $ args [ 'body' ] [ 'docs' ] [ ] = [ '_id' => $ id ] ; } $ m...
Returns documents by a set of ids
2,434
public function getScrollConfiguration ( $ raw , $ scrollDuration ) { $ scrollConfig = [ ] ; if ( isset ( $ raw [ '_scroll_id' ] ) ) { $ scrollConfig [ '_scroll_id' ] = $ raw [ '_scroll_id' ] ; $ scrollConfig [ 'duration' ] = $ scrollDuration ; } return $ scrollConfig ; }
Parses scroll configuration from raw response .
2,435
public function findDocuments ( Search $ search ) { $ results = $ this -> executeSearch ( $ search ) ; return new DocumentIterator ( $ results , $ this -> getManager ( ) , $ this -> getScrollConfiguration ( $ results , $ search -> getScroll ( ) ) ) ; }
Returns DocumentIterator with composed Document objects from array response .
2,436
public function findArray ( Search $ search ) { $ results = $ this -> executeSearch ( $ search ) ; return new ArrayIterator ( $ results , $ this -> getManager ( ) , $ this -> getScrollConfiguration ( $ results , $ search -> getScroll ( ) ) ) ; }
Returns ArrayIterator with access to unmodified documents directly .
2,437
public function findRaw ( Search $ search ) { $ results = $ this -> executeSearch ( $ search ) ; return new RawIterator ( $ results , $ this -> getManager ( ) , $ this -> getScrollConfiguration ( $ results , $ search -> getScroll ( ) ) ) ; }
Returns RawIterator with access to node with all returned values included .
2,438
private function executeSearch ( Search $ search ) { return $ this -> getManager ( ) -> search ( [ $ this -> getType ( ) ] , $ search -> toArray ( ) , $ search -> getUriParams ( ) ) ; }
Executes search to the elasticsearch and returns raw response .
2,439
public function count ( Search $ search , array $ params = [ ] , $ returnRaw = false ) { $ body = array_merge ( [ 'index' => $ this -> getManager ( ) -> getIndexName ( ) , 'type' => $ this -> type , 'body' => $ search -> toArray ( ) , ] , $ params ) ; $ results = $ this -> getManager ( ) -> getClient ( ) -> count ( $ b...
Counts documents by given search .
2,440
public function remove ( $ id , $ routing = null ) { $ params = [ 'index' => $ this -> getManager ( ) -> getIndexName ( ) , 'type' => $ this -> type , 'id' => $ id , ] ; if ( $ routing ) { $ params [ 'routing' ] = $ routing ; } $ response = $ this -> getManager ( ) -> getClient ( ) -> delete ( $ params ) ; return $ res...
Removes a single document data by ID .
2,441
public function update ( $ id , array $ fields = [ ] , $ script = null , array $ params = [ ] ) { $ body = array_filter ( [ 'doc' => $ fields , 'script' => $ script , ] ) ; $ params = array_merge ( [ 'id' => $ id , 'index' => $ this -> getManager ( ) -> getIndexName ( ) , 'type' => $ this -> type , 'body' => $ body , ]...
Partial document update .
2,442
protected function getManager ( $ name ) { $ id = $ this -> getManagerId ( $ name ) ; if ( $ this -> getContainer ( ) -> has ( $ id ) ) { return $ this -> getContainer ( ) -> get ( $ id ) ; } throw new \ RuntimeException ( sprintf ( 'Manager named `%s` not found. Available: `%s`.' , $ name , implode ( '`, `' , array_ke...
Returns elasticsearch manager by name from service container .
2,443
protected function readMetadata ( ) { if ( $ this -> metadata !== null ) { return ; } $ line = fgets ( $ this -> getFileHandler ( ) ) ; if ( trim ( $ line ) !== '[' ) { throw new \ InvalidArgumentException ( 'Given file does not match expected pattern.' ) ; } $ line = trim ( fgets ( $ this -> getFileHandler ( ) ) ) ; $...
Reads metadata from file .
2,444
protected function configureResolver ( OptionsResolver $ resolver ) { $ resolver -> setRequired ( [ '_id' , '_type' , '_source' ] ) -> setDefaults ( [ '_score' => null , 'fields' => [ ] ] ) -> addAllowedTypes ( '_id' , [ 'integer' , 'string' ] ) -> addAllowedTypes ( '_type' , 'string' ) -> addAllowedTypes ( '_source' ,...
Configures OptionResolver for resolving document metadata fields .
2,445
private function getOptionsResolver ( ) { if ( ! $ this -> optionsResolver ) { $ this -> optionsResolver = new OptionsResolver ( ) ; $ this -> configureResolver ( $ this -> optionsResolver ) ; } return $ this -> optionsResolver ; }
Returns configured options resolver instance .
2,446
private function generateDocumentBody ( array $ metadata ) { $ lines = [ ] ; if ( $ properties = $ this -> generateDocumentProperties ( $ metadata ) ) { $ lines [ ] = $ properties ; } if ( $ this -> hasMultipleEmbedded ( $ metadata ) ) { $ lines [ ] = $ this -> generateDocumentConstructor ( $ metadata ) ; } if ( $ meth...
Generates document body
2,447
private function generateDocumentProperties ( array $ metadata ) { $ lines = [ ] ; foreach ( $ metadata [ 'properties' ] as $ property ) { $ lines [ ] = $ this -> generatePropertyDocBlock ( $ property ) ; $ lines [ ] = $ this -> spaces . $ property [ 'visibility' ] . ' $' . $ property [ 'field_name' ] . ";\n" ; } retur...
Generates document properties
2,448
private function generateDocumentMethods ( array $ metadata ) { $ lines = [ ] ; foreach ( $ metadata [ 'properties' ] as $ property ) { if ( isset ( $ property [ 'visibility' ] ) && $ property [ 'visibility' ] === 'public' ) { continue ; } $ lines [ ] = $ this -> generateDocumentMethod ( $ property , $ this -> setMetho...
Generates document methods
2,449
private function generateDocumentConstructor ( array $ metadata ) { $ fields = [ ] ; foreach ( $ metadata [ 'properties' ] as $ prop ) { if ( $ prop [ 'annotation' ] == 'embedded' && isset ( $ prop [ 'property_multiple' ] ) && $ prop [ 'property_multiple' ] ) { $ fields [ ] = sprintf ( '%s$this->%s = new Collection();'...
Generates document constructor
2,450
private function generateDocumentMethod ( array $ metadata , $ template ) { return $ this -> prefixWithSpaces ( str_replace ( [ '<methodName>' , '<fieldName>' ] , [ ucfirst ( $ metadata [ 'field_name' ] ) , $ metadata [ 'field_name' ] ] , $ template ) ) ; }
Generates document method
2,451
private function generatePropertyDocBlock ( array $ metadata ) { $ lines = [ $ this -> spaces . '/**' , $ this -> spaces . ' * @var string' , $ this -> spaces . ' *' , ] ; $ column = [ ] ; if ( isset ( $ metadata [ 'property_name' ] ) && $ metadata [ 'property_name' ] != $ metadata [ 'field_name' ] ) { $ column [ ] = '...
Returns property doc block
2,452
private function generateDocumentDocBlock ( array $ metadata ) { return str_replace ( [ '<className>' , '<annotation>' , '<options>' ] , [ $ this -> getClassName ( $ metadata ) , ucfirst ( $ metadata [ 'annotation' ] ) , $ metadata [ 'annotation' ] != 'object' ? ( $ metadata [ 'type' ] != lcfirst ( $ this -> getClassNa...
Generates document doc block
2,453
private function getClassName ( array $ metadata ) { return ( $ pos = strrpos ( $ metadata [ 'name' ] , '\\' ) ) ? substr ( $ metadata [ 'name' ] , $ pos + 1 , strlen ( $ metadata [ 'name' ] ) ) : $ metadata [ 'name' ] ; }
Returns class name
2,454
private function getAnalysisNode ( ) { $ builder = new TreeBuilder ( ) ; $ node = $ builder -> root ( 'analysis' ) ; $ node -> info ( 'Defines analyzers, normalizers, tokenizers and filters' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> arrayNode ( 'tokenizer' ) -> defaultValue ( [ ] ) -> prototype ( 'variable' ) -> ...
Analysis configuration node .
2,455
private function getManagersNode ( ) { $ builder = new TreeBuilder ( ) ; $ node = $ builder -> root ( 'managers' ) ; $ node -> isRequired ( ) -> requiresAtLeastOneElement ( ) -> useAttributeAsKey ( 'name' ) -> info ( 'Maps managers to connections and bundles' ) -> prototype ( 'array' ) -> children ( ) -> arrayNode ( 'i...
Managers configuration node .
2,456
public function parse ( \ ReflectionClass $ class ) { $ className = $ class -> getName ( ) ; if ( $ class -> isTrait ( ) ) { return false ; } if ( ! isset ( $ this -> documents [ $ className ] ) ) { $ document = $ this -> reader -> getClassAnnotation ( $ class , self :: DOCUMENT_ANNOTATION ) ; if ( $ document === null ...
Parses documents by used annotations and returns mapping for elasticsearch with some extra metadata .
2,457
private function getPropertyAnnotationData ( \ ReflectionProperty $ property ) { $ result = $ this -> reader -> getPropertyAnnotation ( $ property , self :: PROPERTY_ANNOTATION ) ; if ( $ result !== null && $ result -> name === null ) { $ result -> name = Caser :: snake ( $ property -> getName ( ) ) ; } return $ result...
Returns property annotation data from reader .
2,458
private function getEmbeddedAnnotationData ( \ ReflectionProperty $ property ) { $ result = $ this -> reader -> getPropertyAnnotation ( $ property , self :: EMBEDDED_ANNOTATION ) ; if ( $ result !== null && $ result -> name === null ) { $ result -> name = Caser :: snake ( $ property -> getName ( ) ) ; } return $ result...
Returns Embedded annotation data from reader .
2,459
private function getHashMapAnnotationData ( \ ReflectionProperty $ property ) { $ result = $ this -> reader -> getPropertyAnnotation ( $ property , self :: HASH_MAP_ANNOTATION ) ; if ( $ result !== null && $ result -> name === null ) { $ result -> name = Caser :: snake ( $ property -> getName ( ) ) ; } return $ result ...
Returns HashMap annotation data from reader .
2,460
private function getMetaFieldAnnotationData ( $ property , $ directory ) { $ annotation = $ this -> reader -> getPropertyAnnotation ( $ property , self :: ID_ANNOTATION ) ; $ annotation = $ annotation ? : $ this -> reader -> getPropertyAnnotation ( $ property , self :: PARENT_ANNOTATION ) ; $ annotation = $ annotation ...
Returns meta field annotation data from reader .
2,461
private function getMutatorMethods ( \ ReflectionClass $ reflectionClass , $ property , $ propertyType ) { $ camelCaseName = ucfirst ( Caser :: camel ( $ property ) ) ; $ setterName = 'set' . $ camelCaseName ; if ( ! $ reflectionClass -> hasMethod ( $ setterName ) ) { $ message = sprintf ( 'Missing %s() method in %s cl...
Checks if class have setter and getter and returns them in array .
2,462
private function registerAnnotations ( ) { $ annotations = [ 'Document' , 'Property' , 'Embedded' , 'ObjectType' , 'Nested' , 'Id' , 'ParentDocument' , 'Routing' , 'Version' , 'HashMap' , ] ; foreach ( $ annotations as $ annotation ) { AnnotationRegistry :: registerFile ( __DIR__ . "/../Annotation/{$annotation}.php" ) ...
Registers annotations to registry so that it could be used by reader .
2,463
private function getDocumentType ( $ document , $ directory ) { $ namespace = $ this -> finder -> getNamespace ( $ document , $ directory ) ; $ reflectionClass = new \ ReflectionClass ( $ namespace ) ; $ document = $ this -> getDocumentAnnotationData ( $ reflectionClass ) ; return empty ( $ document -> type ) ? Caser :...
Returns document type .
2,464
private function getDocumentPropertiesReflection ( \ ReflectionClass $ reflectionClass ) { if ( in_array ( $ reflectionClass -> getName ( ) , $ this -> properties ) ) { return $ this -> properties [ $ reflectionClass -> getName ( ) ] ; } $ properties = [ ] ; foreach ( $ reflectionClass -> getProperties ( ) as $ propert...
Returns all defined properties including private from parents .
2,465
private function getAnalyzers ( \ ReflectionClass $ reflectionClass ) { $ analyzers = [ ] ; foreach ( $ this -> getDocumentPropertiesReflection ( $ reflectionClass ) as $ name => $ property ) { $ directory = $ this -> guessDirName ( $ property -> getDeclaringClass ( ) ) ; $ type = $ this -> getPropertyAnnotationData ( ...
Parses analyzers list from document mapping .
2,466
private function getProperties ( \ ReflectionClass $ reflectionClass , $ properties = [ ] , $ flag = false ) { $ mapping = [ ] ; foreach ( $ this -> getDocumentPropertiesReflection ( $ reflectionClass ) as $ name => $ property ) { $ directory = $ this -> guessDirName ( $ property -> getDeclaringClass ( ) ) ; $ type = $...
Returns properties of reflection class .
2,467
private function getObjectMapping ( $ className , $ directory ) { $ namespace = $ this -> finder -> getNamespace ( $ className , $ directory ) ; if ( array_key_exists ( $ namespace , $ this -> objects ) ) { return $ this -> objects [ $ namespace ] ; } $ reflectionClass = new \ ReflectionClass ( $ namespace ) ; switch (...
Returns object mapping .
2,468
public function addMessage ( $ key , $ message ) { if ( ! isset ( $ this -> storage [ $ this -> storageKey ] [ $ key ] ) ) { $ this -> storage [ $ this -> storageKey ] [ $ key ] = [ ] ; } $ this -> storage [ $ this -> storageKey ] [ $ key ] [ ] = $ message ; }
Add flash message for the next request
2,469
public function addMessageNow ( $ key , $ message ) { if ( ! isset ( $ this -> forNow [ $ key ] ) ) { $ this -> forNow [ $ key ] = [ ] ; } $ this -> forNow [ $ key ] [ ] = $ message ; }
Add flash message for current request
2,470
public function getMessages ( ) { $ messages = $ this -> fromPrevious ; foreach ( $ this -> forNow as $ key => $ values ) { if ( ! isset ( $ messages [ $ key ] ) ) { $ messages [ $ key ] = [ ] ; } foreach ( $ values as $ value ) { array_push ( $ messages [ $ key ] , $ value ) ; } } return $ messages ; }
Get flash messages
2,471
public function getFirstMessage ( $ key , $ default = null ) { $ messages = self :: getMessage ( $ key ) ; if ( is_array ( $ messages ) && count ( $ messages ) > 0 ) { return $ messages [ 0 ] ; } return $ default ; }
Get the first Flash message
2,472
public function clearMessage ( $ key ) { if ( isset ( $ this -> storage [ $ this -> storageKey ] [ $ key ] ) ) { unset ( $ this -> storage [ $ this -> storageKey ] [ $ key ] ) ; } if ( isset ( $ this -> fromPrevious [ $ key ] ) ) { unset ( $ this -> fromPrevious [ $ key ] ) ; } if ( isset ( $ this -> forNow [ $ key ] )...
Clear specific message
2,473
public function getIdentClass_v2 ( ) { $ class = new StdClass ; $ class -> surname = $ this -> getLastName ( ) ; $ class -> givenName = $ this -> getFirstName ( ) ; $ class -> dateOfBirth = $ this -> getBirthday ( ) ; $ class -> minimumAge = $ this -> getMinimumAge ( ) ; return $ class ; }
Get the Ident - DHL - Class
2,474
public function getLabelData ( $ index = null ) { if ( $ index === null ) return $ this -> labelData ; else return $ this -> labelData [ $ index ] ; }
Getter for LabelData - Objects
2,475
private function loadResponse_v2 ( $ response ) { if ( isset ( $ response -> Status ) ) { if ( isset ( $ response -> Status -> statusCode ) ) $ this -> setStatusCode ( ( int ) $ response -> Status -> statusCode ) ; if ( isset ( $ response -> Status -> statusText ) ) { if ( is_array ( $ response -> Status -> statusText ...
Loads a DHL - Response into this Object
2,476
public function getExportDocPositionClass_v2 ( ) { $ class = new StdClass ; $ class -> description = $ this -> getDescription ( ) ; $ class -> countryCodeOrigin = $ this -> getCountryCodeOrigin ( ) ; $ class -> customsTariffNumber = $ this -> getCustomsTariffNumber ( ) ; $ class -> amount = $ this -> getAmount ( ) ; $ ...
Returns a Class for ExportDocPosition
2,477
protected function getAPIUrl ( ) { if ( $ this -> getCustomAPIURL ( ) !== null ) return $ this -> getCustomAPIURL ( ) ; return self :: DHL_WSDL_LIB_URL . $ this -> getVersion ( ) . '/geschaeftskundenversand-api-' . $ this -> getVersion ( ) . '.wsdl' ; }
Get the Business - API - URL for this Version
2,478
public function setShipmentOrders ( $ shipmentOrders ) { if ( ! is_array ( $ shipmentOrders ) ) { trigger_error ( '[DHL-PHP-SDK]: The type of $shipmentOrders is NOT an array, but is required to set as array! Called method ' . __METHOD__ . ' in class ' . __CLASS__ , E_USER_ERROR ) ; $ this -> addError ( __METHOD__ . ': ...
Set the list with all Shipment - Orders Objects
2,479
private function checkRequestCount ( $ array , $ action , $ maxReq = self :: MAX_DHL_REQUESTS ) { $ count = count ( $ array ) ; if ( $ count > self :: MAX_DHL_REQUESTS ) $ this -> addError ( 'There are only ' . $ maxReq . ' Request/s for one call allowed for the action "' . $ action . '"! You tried to request ' . $ cou...
Check if the request - Array is to long
2,480
private function buildAuthHeader ( ) { $ auth_params = array ( 'user' => $ this -> getCredentials ( ) -> getUser ( ) , 'signature' => $ this -> getCredentials ( ) -> getSignature ( ) , 'type' => 0 ) ; return new SoapHeader ( self :: DHL_SOAP_HEADER_URI , 'Authentification' , $ auth_params ) ; }
Build SOAP - Auth - Header
2,481
private function buildSoapClient ( ) { $ header = $ this -> buildAuthHeader ( ) ; if ( $ this -> isTest ( ) ) $ location = self :: DHL_SANDBOX_URL ; else $ location = self :: DHL_PRODUCTION_URL ; $ auth_params = array ( 'login' => $ this -> getCredentials ( ) -> getApiUser ( ) , 'password' => $ this -> getCredentials (...
Builds the Soap - Client
2,482
private function sendDoManifestRequest ( $ data ) { switch ( $ this -> getMayor ( ) ) { case 1 : return $ this -> getSoapClient ( ) -> DoManifestTD ( $ data ) ; case 2 : default : return $ this -> getSoapClient ( ) -> doManifest ( $ data ) ; } }
Creates the doManifest - Request via SOAP
2,483
public function doManifest ( $ shipmentNumbers ) { switch ( $ this -> getMayor ( ) ) { case 1 : $ data = $ this -> createDoManifestClass_v1 ( $ shipmentNumbers ) ; break ; case 2 : default : $ data = $ this -> createDoManifestClass_v2 ( $ shipmentNumbers ) ; } try { $ response = $ this -> sendDoManifestRequest ( $ data...
Creates the doManifest - Request
2,484
private function createDoManifestClass_v1 ( $ shipmentNumbers ) { trigger_error ( '[DHL-PHP-SDK]: Version 1 Methods are deprecated and will removed soon (Called method ' . __METHOD__ . ')!' , E_USER_DEPRECATED ) ; trigger_error ( '[DHL-PHP-SDK]: Called Version 1 Method: ' . __METHOD__ . ' is incomplete (does nothing)!'...
Creates the Data - Object for Manifest
2,485
public function getManifest ( $ manifestDate , $ useIntTime = false ) { if ( $ useIntTime ) { $ oldDate = $ manifestDate ; $ manifestDate = date ( 'Y-m-d' , $ manifestDate ) ; if ( $ manifestDate === false ) { $ this -> addError ( 'Could not convert given time() value "' . $ oldDate . '" to YYYY-MM-DD... Called method:...
Creates the getManifest - Request
2,486
private function createGetManifestClass_v2 ( $ manifestDate ) { $ data = new StdClass ; if ( is_array ( $ manifestDate ) ) $ this -> addError ( 'You can only request 1 date on getManifest - multiple requests in 1 call are not allowed here' ) ; $ data -> Version = $ this -> getVersionClass ( ) ; $ data -> manifestDate =...
Creates the Data - Object for getManifest
2,487
private function sendCreateRequest ( $ data ) { switch ( $ this -> getMayor ( ) ) { case 1 : return $ this -> getSoapClient ( ) -> CreateShipmentDD ( $ data ) ; case 2 : default : return $ this -> getSoapClient ( ) -> createShipmentOrder ( $ data ) ; } }
Creates the Shipment - Order Request via SOAP
2,488
public function createShipmentOrder ( ) { switch ( $ this -> getMayor ( ) ) { case 1 : $ data = $ this -> createShipmentClass_v1 ( ) ; break ; case 2 : default : if ( $ this -> countShipmentOrders ( ) < 1 ) $ data = $ this -> createShipmentClass_v2_legacy ( ) ; else $ data = $ this -> createShipmentClass_v2 ( ) ; } $ r...
Creates the Shipment - Request
2,489
private function sendDeleteRequest ( $ data ) { switch ( $ this -> getMayor ( ) ) { case 1 : return $ this -> getSoapClient ( ) -> DeleteShipmentDD ( $ data ) ; case 2 : default : return $ this -> getSoapClient ( ) -> deleteShipmentOrder ( $ data ) ; } }
Creates the Shipment - Order - Delete Request via SOAP
2,490
public function deleteShipmentOrder ( $ shipmentNumbers ) { switch ( $ this -> getMayor ( ) ) { case 1 : $ data = $ this -> createDeleteClass_v1 ( $ shipmentNumbers ) ; break ; case 2 : default : $ data = $ this -> createDeleteClass_v2 ( $ shipmentNumbers ) ; } try { $ response = $ this -> sendDeleteRequest ( $ data ) ...
Deletes a Shipment
2,491
private function sendGetLabelRequest ( $ data ) { switch ( $ this -> getMayor ( ) ) { case 1 : return $ this -> getSoapClient ( ) -> getLabelDD ( $ data ) ; case 2 : default : return $ this -> getSoapClient ( ) -> getLabel ( $ data ) ; } }
Requests a Label again via SOAP
2,492
public function getLabel ( $ shipmentNumbers ) { switch ( $ this -> getMayor ( ) ) { case 1 : $ data = $ this -> getLabelClass_v1 ( $ shipmentNumbers ) ; break ; case 2 : default : $ data = $ this -> getLabelClass_v2 ( $ shipmentNumbers ) ; } try { $ response = $ this -> sendGetLabelRequest ( $ data ) ; } catch ( Excep...
Requests a Shipment - Label again
2,493
private function sendGetExportDocRequest ( $ data ) { switch ( $ this -> getMayor ( ) ) { case 1 : return $ this -> getSoapClient ( ) -> getExportDocDD ( $ data ) ; case 2 : default : return $ this -> getSoapClient ( ) -> getExportDoc ( $ data ) ; } }
Requests the Export - Document again via SOAP
2,494
public function getExportDoc ( $ shipmentNumbers ) { switch ( $ this -> getMayor ( ) ) { case 1 : $ data = $ this -> getExportDocClass_v1 ( $ shipmentNumbers ) ; break ; case 2 : default : $ data = $ this -> getExportDocClass_v2 ( $ shipmentNumbers ) ; } try { $ response = $ this -> sendGetExportDocRequest ( $ data ) ;...
Requests a Export - Document again
2,495
public function validateShipment ( ) { switch ( $ this -> getMayor ( ) ) { case 1 : $ data = null ; break ; case 2 : default : $ data = $ this -> createShipmentClass_v2 ( ) ; } try { $ response = $ this -> sendValidateShipmentRequest ( $ data ) ; } catch ( Exception $ e ) { $ this -> addError ( $ e -> getMessage ( ) ) ...
Validates a Shipment
2,496
private function sendValidateShipmentRequest ( $ data ) { switch ( $ this -> getMayor ( ) ) { case 1 : throw new Exception ( __FUNCTION__ . ': Method doesn\'t exists for Version 1!' ) ; case 2 : default : return $ this -> getSoapClient ( ) -> validateShipment ( $ data ) ; } }
Requests the Validation of a Shipment via SOAP
2,497
public function updateShipmentOrder ( $ shipmentNumber ) { if ( is_array ( $ shipmentNumber ) || $ this -> countShipmentOrders ( ) > 1 ) { $ this -> addError ( __FUNCTION__ . ': Updating Shipments is a Single-Operation only!' ) ; return false ; } switch ( $ this -> getMayor ( ) ) { case 1 : $ data = null ; break ; case...
Updates the Shipment - Request
2,498
private function sendUpdateRequest ( $ data ) { switch ( $ this -> getMayor ( ) ) { case 1 : throw new Exception ( __FUNCTION__ . ': Method doesn\'t exists for Version 1!' ) ; case 2 : default : return $ this -> getSoapClient ( ) -> updateShipmentOrder ( $ data ) ; } }
Requests the Update of a Shipment via SOAP
2,499
public static function getInfo ( $ productType ) { if ( ! self :: isInit ( ) ) self :: init ( ) ; if ( ! array_key_exists ( $ productType , self :: $ dhlProducts ) ) return null ; return self :: $ dhlProducts [ $ productType ] ; }
Get the Product - Object by Type