idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
44,700 | static function _fetchURL ( $ url ) { if ( self :: $ disable_url_fetch ) { return false ; } $ parts = parse_url ( $ url ) ; $ data = '' ; switch ( $ parts [ 'scheme' ] ) { case 'http' : $ fsock = @ fsockopen ( $ parts [ 'host' ] , isset ( $ parts [ 'port' ] ) ? $ parts [ 'port' ] : 80 ) ; if ( ! $ fsock ) { return false ; } fputs ( $ fsock , "GET $parts[path] HTTP/1.0\r\n" ) ; fputs ( $ fsock , "Host: $parts[host]\r\n\r\n" ) ; $ line = fgets ( $ fsock , 1024 ) ; if ( strlen ( $ line ) < 3 ) { return false ; } preg_match ( '#HTTP/1.\d (\d{3})#' , $ line , $ temp ) ; if ( $ temp [ 1 ] != '200' ) { return false ; } while ( ! feof ( $ fsock ) && fgets ( $ fsock , 1024 ) != "\r\n" ) { } while ( ! feof ( $ fsock ) ) { $ data .= fread ( $ fsock , 1024 ) ; } break ; } return $ data ; } | Fetches a URL |
44,701 | function _reformatKey ( $ algorithm , $ key ) { switch ( $ algorithm ) { case 'rsaEncryption' : return "-----BEGIN RSA PUBLIC KEY-----\r\n" . chunk_split ( base64_encode ( substr ( base64_decode ( $ key ) , 1 ) ) , 64 ) . '-----END RSA PUBLIC KEY-----' ; default : return $ key ; } } | Reformat public keys |
44,702 | function setDNProp ( $ propName , $ propValue , $ type = 'utf8String' ) { if ( empty ( $ this -> dn ) ) { $ this -> dn = array ( 'rdnSequence' => array ( ) ) ; } if ( ( $ propName = $ this -> _translateDNProp ( $ propName ) ) === false ) { return false ; } foreach ( ( array ) $ propValue as $ v ) { if ( ! is_array ( $ v ) && isset ( $ type ) ) { $ v = array ( $ type => $ v ) ; } $ this -> dn [ 'rdnSequence' ] [ ] = array ( array ( 'type' => $ propName , 'value' => $ v ) ) ; } return true ; } | Set a Distinguished Name property |
44,703 | function setDN ( $ dn , $ merge = false , $ type = 'utf8String' ) { if ( ! $ merge ) { $ this -> dn = null ; } if ( is_array ( $ dn ) ) { if ( isset ( $ dn [ 'rdnSequence' ] ) ) { $ this -> dn = $ dn ; return true ; } foreach ( $ dn as $ prop => $ value ) { if ( ! $ this -> setDNProp ( $ prop , $ value , $ type ) ) { return false ; } } return true ; } $ results = preg_split ( '#((?:^|, *|/)(?:C=|O=|OU=|CN=|L=|ST=|SN=|postalCode=|streetAddress=|emailAddress=|serialNumber=|organizationalUnitName=|title=|description=|role=|x500UniqueIdentifier=|postalAddress=))#' , $ dn , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; for ( $ i = 1 ; $ i < count ( $ results ) ; $ i += 2 ) { $ prop = trim ( $ results [ $ i ] , ', =/' ) ; $ value = $ results [ $ i + 1 ] ; if ( ! $ this -> setDNProp ( $ prop , $ value , $ type ) ) { return false ; } } return true ; } | Set a Distinguished Name |
44,704 | function getPublicKey ( ) { if ( isset ( $ this -> publicKey ) ) { return $ this -> publicKey ; } if ( isset ( $ this -> currentCert ) && is_array ( $ this -> currentCert ) ) { foreach ( array ( 'tbsCertificate/subjectPublicKeyInfo' , 'certificationRequestInfo/subjectPKInfo' ) as $ path ) { $ keyinfo = $ this -> _subArray ( $ this -> currentCert , $ path ) ; if ( ! empty ( $ keyinfo ) ) { break ; } } } if ( empty ( $ keyinfo ) ) { return false ; } $ key = $ keyinfo [ 'subjectPublicKey' ] ; switch ( $ keyinfo [ 'algorithm' ] [ 'algorithm' ] ) { case 'rsaEncryption' : $ publicKey = new RSA ( ) ; $ publicKey -> loadKey ( $ key ) ; $ publicKey -> setPublicKey ( ) ; break ; default : return false ; } return $ publicKey ; } | Gets the public key |
44,705 | function loadSPKAC ( $ spkac ) { if ( is_array ( $ spkac ) && isset ( $ spkac [ 'publicKeyAndChallenge' ] ) ) { unset ( $ this -> currentCert ) ; unset ( $ this -> currentKeyIdentifier ) ; unset ( $ this -> signatureSubject ) ; $ this -> currentCert = $ spkac ; return $ spkac ; } $ asn1 = new ASN1 ( ) ; $ temp = preg_replace ( '#(?:SPKAC=)|[ \r\n\\\]#' , '' , $ spkac ) ; $ temp = preg_match ( '#^[a-zA-Z\d/+]*={0,2}$#' , $ temp ) ? base64_decode ( $ temp ) : false ; if ( $ temp != false ) { $ spkac = $ temp ; } $ orig = $ spkac ; if ( $ spkac === false ) { $ this -> currentCert = false ; return false ; } $ asn1 -> loadOIDs ( $ this -> oids ) ; $ decoded = $ asn1 -> decodeBER ( $ spkac ) ; if ( empty ( $ decoded ) ) { $ this -> currentCert = false ; return false ; } $ spkac = $ asn1 -> asn1map ( $ decoded [ 0 ] , $ this -> SignedPublicKeyAndChallenge ) ; if ( ! isset ( $ spkac ) || $ spkac === false ) { $ this -> currentCert = false ; return false ; } $ this -> signatureSubject = substr ( $ orig , $ decoded [ 0 ] [ 'content' ] [ 0 ] [ 'start' ] , $ decoded [ 0 ] [ 'content' ] [ 0 ] [ 'length' ] ) ; $ algorithm = & $ spkac [ 'publicKeyAndChallenge' ] [ 'spki' ] [ 'algorithm' ] [ 'algorithm' ] ; $ key = & $ spkac [ 'publicKeyAndChallenge' ] [ 'spki' ] [ 'subjectPublicKey' ] ; $ key = $ this -> _reformatKey ( $ algorithm , $ key ) ; switch ( $ algorithm ) { case 'rsaEncryption' : $ this -> publicKey = new RSA ( ) ; $ this -> publicKey -> loadKey ( $ key ) ; $ this -> publicKey -> setPublicKey ( ) ; break ; default : $ this -> publicKey = null ; } $ this -> currentKeyIdentifier = null ; $ this -> currentCert = $ spkac ; return $ spkac ; } | Load a SPKAC CSR |
44,706 | function _timeField ( $ date ) { if ( $ date instanceof Element ) { return $ date ; } $ dateObj = new DateTime ( $ date , new DateTimeZone ( 'GMT' ) ) ; $ year = $ dateObj -> format ( 'Y' ) ; if ( $ year < 2050 ) { return array ( 'utcTime' => $ date ) ; } else { return array ( 'generalTime' => $ date ) ; } } | Helper function to build a time field according to RFC 3280 section - 4 . 1 . 2 . 5 Validity - 5 . 1 . 2 . 4 This Update - 5 . 1 . 2 . 5 Next Update - 5 . 1 . 2 . 6 Revoked Certificates by choosing utcTime iff year of date given is before 2050 and generalTime else . |
44,707 | function signSPKAC ( $ signatureAlgorithm = 'sha1WithRSAEncryption' ) { if ( ! is_object ( $ this -> privateKey ) ) { return false ; } $ origPublicKey = $ this -> publicKey ; $ class = get_class ( $ this -> privateKey ) ; $ this -> publicKey = new $ class ( ) ; $ this -> publicKey -> loadKey ( $ this -> privateKey -> getPublicKey ( ) ) ; $ this -> publicKey -> setPublicKey ( ) ; $ publicKey = $ this -> _formatSubjectPublicKey ( ) ; if ( ! $ publicKey ) { return false ; } $ this -> publicKey = $ origPublicKey ; $ currentCert = isset ( $ this -> currentCert ) ? $ this -> currentCert : null ; $ signatureSubject = isset ( $ this -> signatureSubject ) ? $ this -> signatureSubject : null ; if ( isset ( $ this -> currentCert ) && is_array ( $ this -> currentCert ) && isset ( $ this -> currentCert [ 'publicKeyAndChallenge' ] ) ) { $ this -> currentCert [ 'signatureAlgorithm' ] [ 'algorithm' ] = $ signatureAlgorithm ; $ this -> currentCert [ 'publicKeyAndChallenge' ] [ 'spki' ] = $ publicKey ; if ( ! empty ( $ this -> challenge ) ) { $ this -> currentCert [ 'publicKeyAndChallenge' ] [ 'challenge' ] = $ this -> challenge & str_repeat ( "\x7F" , strlen ( $ this -> challenge ) ) ; } } else { $ this -> currentCert = array ( 'publicKeyAndChallenge' => array ( 'spki' => $ publicKey , 'challenge' => ! empty ( $ this -> challenge ) ? $ this -> challenge : '' ) , 'signatureAlgorithm' => array ( 'algorithm' => $ signatureAlgorithm ) , 'signature' => false ) ; } $ publicKeyAndChallenge = $ this -> currentCert [ 'publicKeyAndChallenge' ] ; $ this -> loadSPKAC ( $ this -> saveSPKAC ( $ this -> currentCert ) ) ; $ result = $ this -> _sign ( $ this -> privateKey , $ signatureAlgorithm ) ; $ result [ 'publicKeyAndChallenge' ] = $ publicKeyAndChallenge ; $ this -> currentCert = $ currentCert ; $ this -> signatureSubject = $ signatureSubject ; return $ result ; } | Sign a SPKAC |
44,708 | function setStartDate ( $ date ) { if ( ! is_object ( $ date ) || ! is_a ( $ date , 'DateTime' ) ) { $ date = new DateTime ( $ date , new DateTimeZone ( @ date_default_timezone_get ( ) ) ) ; } $ this -> startDate = $ date -> format ( 'D, d M Y H:i:s O' ) ; } | Set certificate start date |
44,709 | function _isSubArrayValid ( $ root , $ path ) { if ( ! is_array ( $ root ) ) { return false ; } foreach ( explode ( '/' , $ path ) as $ i ) { if ( ! is_array ( $ root ) ) { return false ; } if ( ! isset ( $ root [ $ i ] ) ) { return true ; } $ root = $ root [ $ i ] ; } return true ; } | Check for validity of subarray |
44,710 | function _getExtensions ( $ cert = null , $ path = null ) { $ exts = $ this -> _extensions ( $ cert , $ path ) ; $ extensions = array ( ) ; if ( is_array ( $ exts ) ) { foreach ( $ exts as $ extension ) { $ extensions [ ] = $ extension [ 'extnId' ] ; } } return $ extensions ; } | Returns a list of all extensions in use |
44,711 | function setExtension ( $ id , $ value , $ critical = false , $ replace = true ) { return $ this -> _setExtension ( $ id , $ value , $ critical , $ replace ) ; } | Set a certificate CSR or CRL Extension |
44,712 | function getAttributes ( $ csr = null ) { if ( empty ( $ csr ) ) { $ csr = $ this -> currentCert ; } $ attributes = $ this -> _subArray ( $ csr , 'certificationRequestInfo/attributes' ) ; $ attrs = array ( ) ; if ( is_array ( $ attributes ) ) { foreach ( $ attributes as $ attribute ) { $ attrs [ ] = $ attribute [ 'type' ] ; } } return $ attrs ; } | Returns a list of all CSR attributes in use |
44,713 | function setKeyIdentifier ( $ value ) { if ( empty ( $ value ) ) { unset ( $ this -> currentKeyIdentifier ) ; } else { $ this -> currentKeyIdentifier = base64_encode ( $ value ) ; } } | Sets the subject key identifier |
44,714 | function setDomain ( ) { $ this -> domains = func_get_args ( ) ; $ this -> removeDNProp ( 'id-at-commonName' ) ; $ this -> setDNProp ( 'id-at-commonName' , $ this -> domains [ 0 ] ) ; } | Set the domain name s which the cert is to be valid for |
44,715 | function revoke ( $ serial , $ date = null ) { if ( isset ( $ this -> currentCert [ 'tbsCertList' ] ) ) { if ( is_array ( $ rclist = & $ this -> _subArray ( $ this -> currentCert , 'tbsCertList/revokedCertificates' , true ) ) ) { if ( $ this -> _revokedCertificate ( $ rclist , $ serial ) === false ) { if ( ( $ i = $ this -> _revokedCertificate ( $ rclist , $ serial , true ) ) !== false ) { if ( ! empty ( $ date ) ) { $ rclist [ $ i ] [ 'revocationDate' ] = $ this -> _timeField ( $ date ) ; } return true ; } } } } return false ; } | Revoke a certificate . |
44,716 | function unrevoke ( $ serial ) { if ( is_array ( $ rclist = & $ this -> _subArray ( $ this -> currentCert , 'tbsCertList/revokedCertificates' ) ) ) { if ( ( $ i = $ this -> _revokedCertificate ( $ rclist , $ serial ) ) !== false ) { unset ( $ rclist [ $ i ] ) ; $ rclist = array_values ( $ rclist ) ; return true ; } } return false ; } | Unrevoke a certificate . |
44,717 | function getRevoked ( $ serial ) { if ( is_array ( $ rclist = $ this -> _subArray ( $ this -> currentCert , 'tbsCertList/revokedCertificates' ) ) ) { if ( ( $ i = $ this -> _revokedCertificate ( $ rclist , $ serial ) ) !== false ) { return $ rclist [ $ i ] ; } } return false ; } | Get a revoked certificate . |
44,718 | function listRevoked ( $ crl = null ) { if ( ! isset ( $ crl ) ) { $ crl = $ this -> currentCert ; } if ( ! isset ( $ crl [ 'tbsCertList' ] ) ) { return false ; } $ result = array ( ) ; if ( is_array ( $ rclist = $ this -> _subArray ( $ crl , 'tbsCertList/revokedCertificates' ) ) ) { foreach ( $ rclist as $ rc ) { $ result [ ] = $ rc [ 'userCertificate' ] -> toString ( ) ; } } return $ result ; } | List revoked certificates |
44,719 | function removeRevokedCertificateExtension ( $ serial , $ id ) { if ( is_array ( $ rclist = & $ this -> _subArray ( $ this -> currentCert , 'tbsCertList/revokedCertificates' ) ) ) { if ( ( $ i = $ this -> _revokedCertificate ( $ rclist , $ serial ) ) !== false ) { return $ this -> _removeExtension ( $ id , "tbsCertList/revokedCertificates/$i/crlEntryExtensions" ) ; } } return false ; } | Remove a Revoked Certificate Extension |
44,720 | function getRevokedCertificateExtensions ( $ serial , $ crl = null ) { if ( ! isset ( $ crl ) ) { $ crl = $ this -> currentCert ; } if ( is_array ( $ rclist = $ this -> _subArray ( $ crl , 'tbsCertList/revokedCertificates' ) ) ) { if ( ( $ i = $ this -> _revokedCertificate ( $ rclist , $ serial ) ) !== false ) { return $ this -> _getExtensions ( $ crl , "tbsCertList/revokedCertificates/$i/crlEntryExtensions" ) ; } } return false ; } | Returns a list of all extensions in use for a given revoked certificate |
44,721 | function setRevokedCertificateExtension ( $ serial , $ id , $ value , $ critical = false , $ replace = true ) { if ( isset ( $ this -> currentCert [ 'tbsCertList' ] ) ) { if ( is_array ( $ rclist = & $ this -> _subArray ( $ this -> currentCert , 'tbsCertList/revokedCertificates' , true ) ) ) { if ( ( $ i = $ this -> _revokedCertificate ( $ rclist , $ serial , true ) ) !== false ) { return $ this -> _setExtension ( $ id , $ value , $ critical , $ replace , "tbsCertList/revokedCertificates/$i/crlEntryExtensions" ) ; } } } return false ; } | Set a Revoked Certificate Extension |
44,722 | function getOID ( $ name ) { static $ reverseMap ; if ( ! isset ( $ reverseMap ) ) { $ reverseMap = array_flip ( $ this -> oids ) ; } return isset ( $ reverseMap [ $ name ] ) ? $ reverseMap [ $ name ] : $ name ; } | Returns the OID corresponding to a name |
44,723 | function getServerKeyPublicExponent ( $ raw_output = false ) { return $ raw_output ? $ this -> server_key_public_exponent -> toBytes ( ) : $ this -> server_key_public_exponent -> toString ( ) ; } | Return the server key public exponent |
44,724 | function getServerKeyPublicModulus ( $ raw_output = false ) { return $ raw_output ? $ this -> server_key_public_modulus -> toBytes ( ) : $ this -> server_key_public_modulus -> toString ( ) ; } | Return the server key public modulus |
44,725 | function getHostKeyPublicExponent ( $ raw_output = false ) { return $ raw_output ? $ this -> host_key_public_exponent -> toBytes ( ) : $ this -> host_key_public_exponent -> toString ( ) ; } | Return the host key public exponent |
44,726 | function getHostKeyPublicModulus ( $ raw_output = false ) { return $ raw_output ? $ this -> host_key_public_modulus -> toBytes ( ) : $ this -> host_key_public_modulus -> toString ( ) ; } | Return the host key public modulus |
44,727 | function getSupportedCiphers ( $ raw_output = false ) { return $ raw_output ? array_keys ( $ this -> supported_ciphers ) : array_values ( $ this -> supported_ciphers ) ; } | Return a list of ciphers supported by SSH1 server . |
44,728 | function getSupportedAuthentications ( $ raw_output = false ) { return $ raw_output ? array_keys ( $ this -> supported_authentications ) : array_values ( $ this -> supported_authentications ) ; } | Return a list of authentications supported by SSH1 server . |
44,729 | public function filter ( $ callback ) { $ this -> assertMutable ( 'Attempting to filter immutable array' ) ; $ this -> filters [ ] = $ callback ; $ this -> applyFilters ( ) ; return $ this ; } | Filters Items using callback . |
44,730 | private function applyFilters ( ) { if ( $ this -> isImmutable ) { return ; } $ this -> exchangeArray ( $ this -> originalItems ) ; if ( count ( $ this -> filters ) > 0 ) { $ filtered_array = array_filter ( $ this -> getArrayCopy ( ) , function ( $ item ) { foreach ( $ this -> filters as $ callback ) { if ( call_user_func ( $ callback , $ item ) === true ) { return true ; } } return false ; } ) ; $ this -> exchangeArray ( array_values ( $ filtered_array ) ) ; } foreach ( $ this -> getArrayCopy ( ) as $ item ) { if ( $ item instanceof MultiValue ) { foreach ( $ this -> filters as $ callback ) { $ item -> filter ( $ callback ) ; } } } } | Apply all filters . |
44,731 | public function immutable ( ) { $ this -> isImmutable = true ; foreach ( $ this -> getArrayCopy ( ) as $ item ) { if ( $ item instanceof MultiValue ) { $ item -> immutable ( ) ; } } return $ this ; } | Make this MultiValue Immutable . |
44,732 | public function setFields ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Protobuf \ Field :: class ) ; $ this -> fields = $ arr ; return $ this ; } | The list of fields . |
44,733 | public function setOneofs ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> oneofs = $ arr ; return $ this ; } | The list of types appearing in oneof definitions in this type . |
44,734 | public static function convert ( Anchor $ protobufAnchor ) { $ anchorMap = null ; $ ASN1 = new ASN1 ( ) ; $ X509 = new X509 ( ) ; $ anchorSubType = $ protobufAnchor -> getSubType ( ) ; $ yotiSignedTimeStamp = self :: convertToYotiSignedTimestamp ( $ protobufAnchor ) ; $ X509CertsList = self :: convertCertsListToX509 ( $ X509 , $ protobufAnchor -> getOriginServerCerts ( ) ) ; $ anchorTypesMap = self :: getAnchorTypesMap ( ) ; foreach ( $ X509CertsList as $ certX509Obj ) { $ certExtsArr = $ certX509Obj -> tbsCertificate -> extensions ; foreach ( $ anchorTypesMap as $ oid => $ anchorType ) { foreach ( $ certExtsArr as $ extObj ) { $ extArr = ( array ) $ extObj ; $ oidFound = array_search ( $ oid , $ extArr , true ) ; if ( $ oidFound !== false && is_string ( $ extArr [ 'extnValue' ] ) ) { $ extEncodedValue = $ extArr [ 'extnValue' ] ; if ( $ decodedAnchorValue = self :: decodeAnchorValue ( $ ASN1 , $ X509 , $ extEncodedValue ) ) { $ yotiAnchor = self :: createYotiAnchor ( $ decodedAnchorValue , $ anchorType , $ anchorSubType , $ yotiSignedTimeStamp , $ X509CertsList ) ; $ anchorMap = [ 'oid' => $ oid , 'yoti_anchor' => $ yotiAnchor ] ; return $ anchorMap ; } } } } } return $ anchorMap ; } | Convert Protobuf Anchor to a map of oid - > Yoti Anchor |
44,735 | private static function convertCertToX509 ( X509 $ X509 , $ certificate ) { $ X509Data = $ X509 -> loadX509 ( $ certificate ) ; return json_decode ( json_encode ( $ X509Data ) , false ) ; } | Return X509 Cert Object . |
44,736 | public function getPayloadJSON ( ) { $ data = is_string ( $ this -> data ) ? mb_convert_encoding ( $ this -> data , 'UTF-8' ) : $ this -> data ; return json_encode ( $ data ) ; } | Get payload as a JSON string . |
44,737 | public function setType ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Protobuf \ Internal \ FieldDescriptorProto_Type :: class ) ; $ this -> type = $ var ; $ this -> has_type = true ; return $ this ; } | If type_name is set this need not be set . If both this and type_name are set this must be one of TYPE_ENUM TYPE_MESSAGE or TYPE_GROUP . |
44,738 | public function setExtendee ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> extendee = $ var ; $ this -> has_extendee = true ; return $ this ; } | For extensions this is the name of the type being extended . It is resolved in the same manner as type_name . |
44,739 | public function setJsonName ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> json_name = $ var ; $ this -> has_json_name = true ; return $ this ; } | JSON name of this field . The value is set by protocol compiler . If the user has set a json_name option on this field that option s value will be used . Otherwise it s deduced from the field s name by converting it to camelCase . |
44,740 | public function setBreakpoint ( Environment $ environment , $ context ) { if ( function_exists ( 'xdebug_break' ) ) { $ arguments = func_get_args ( ) ; $ arguments = array_slice ( $ arguments , 2 ) ; xdebug_break ( ) ; } } | If Xdebug is detected makes the debugger break . |
44,741 | protected function getElementByKey ( $ array , $ getKey = null , $ default = null ) { $ data = $ array ; if ( $ getKey ) { $ keyParts = explode ( ':' , $ getKey ) ; foreach ( $ keyParts as $ key ) { if ( is_array ( $ data ) && isset ( $ data [ $ key ] ) ) { $ data = $ data [ $ key ] ; } elseif ( is_object ( $ data ) && isset ( $ data -> $ key ) ) { $ data = $ data -> $ key ; } else { $ data = null ; break ; } } } if ( $ data === null ) { $ data = $ default ; } return $ data ; } | get all values or vulue by key |
44,742 | public function setParamByKey ( $ setKey , $ setVal ) { $ this -> params = $ this -> setArrayElementByKey ( $ this -> params , $ setKey , $ setVal ) ; } | set value in params by key |
44,743 | protected function setArrayElementByKey ( $ array , $ setKey , $ setVal ) { $ link = & $ array ; $ keyParts = explode ( ':' , $ setKey ) ; foreach ( $ keyParts as $ key ) { if ( is_numeric ( $ key ) && ( string ) ( ( integer ) $ key ) === $ key ) { $ key = ( integer ) $ key ; } if ( ! isset ( $ link [ $ key ] ) ) { $ link [ $ key ] = [ ] ; } $ link = & $ link [ $ key ] ; } $ link = $ setVal ; return $ array ; } | set value in array by key |
44,744 | public static function isEnough ( ConnectorInterface $ connector , $ accountName , $ type , $ trxJsonString = '' ) { $ bandwidth = Bandwidth :: getBandwidthByAccountName ( $ accountName , $ type , $ connector ) ; $ bandwidth [ 'needed' ] = mb_strlen ( $ trxJsonString , '8bit' ) + $ bandwidth [ 'used' ] ; return $ bandwidth [ 'needed' ] < $ bandwidth [ 'available' ] ; } | Checking Bandwidth for Trx |
44,745 | public function generate ( \ ReflectionClass $ originalClass , PhpClass $ class ) { $ methods = ReflectionUtils :: getOverrideableMethods ( $ originalClass , true ) ; if ( empty ( $ methods ) ) { return ; } if ( null !== $ this -> markerInterface ) { $ class -> setImplementedInterfaces ( array_merge ( $ class -> getImplementedInterfaces ( ) , array ( $ this -> markerInterface ) ) ) ; } $ initializer = new PhpProperty ( ) ; $ initializer -> setName ( $ this -> prefix . 'lazyInitializer' ) ; $ initializer -> setVisibility ( PhpProperty :: VISIBILITY_PRIVATE ) ; $ class -> setProperty ( $ initializer ) ; $ initialized = new PhpProperty ( ) ; $ initialized -> setName ( $ this -> prefix . 'initialized' ) ; $ initialized -> setDefaultValue ( false ) ; $ initialized -> setVisibility ( PhpProperty :: VISIBILITY_PRIVATE ) ; $ class -> setProperty ( $ initialized ) ; $ initializerSetter = new PhpMethod ( ) ; $ initializerSetter -> setName ( $ this -> prefix . 'setLazyInitializer' ) ; $ initializerSetter -> setBody ( '$this->' . $ this -> prefix . 'lazyInitializer = $initializer;' ) ; $ parameter = new PhpParameter ( ) ; $ parameter -> setName ( 'initializer' ) ; $ parameter -> setType ( '\CG\Proxy\LazyInitializerInterface' ) ; $ initializerSetter -> addParameter ( $ parameter ) ; $ class -> setMethod ( $ initializerSetter ) ; $ this -> addMethods ( $ class , $ methods ) ; $ initializingMethod = new PhpMethod ( ) ; $ initializingMethod -> setName ( $ this -> prefix . 'initialize' ) ; $ initializingMethod -> setVisibility ( PhpMethod :: VISIBILITY_PRIVATE ) ; $ initializingMethod -> setBody ( $ this -> writer -> reset ( ) -> writeln ( 'if (null === $this->' . $ this -> prefix . 'lazyInitializer) {' ) -> indent ( ) -> writeln ( 'throw new \RuntimeException("' . $ this -> prefix . 'setLazyInitializer() must be called prior to any other public method on this object.");' ) -> outdent ( ) -> write ( "}\n\n" ) -> writeln ( '$this->' . $ this -> prefix . 'lazyInitializer->initializeObject($this);' ) -> writeln ( '$this->' . $ this -> prefix . 'initialized = true;' ) -> getContent ( ) ) ; $ class -> setMethod ( $ initializingMethod ) ; } | Generates the necessary methods in the class . |
44,746 | public function createInstance ( array $ args = array ( ) ) { $ generatedClass = $ this -> getClassName ( $ this -> class ) ; if ( ! class_exists ( $ generatedClass , false ) ) { eval ( $ this -> generateClass ( ) ) ; } $ ref = new \ ReflectionClass ( $ generatedClass ) ; return $ ref -> newInstanceArgs ( $ args ) ; } | Creates a new instance of the enhanced class . |
44,747 | final public function generateClass ( ) { static $ docBlock ; if ( empty ( $ docBlock ) ) { $ writer = new Writer ( ) ; $ writer -> writeln ( '/**' ) -> writeln ( ' * CG library enhanced proxy class.' ) -> writeln ( ' *' ) -> writeln ( ' * This code was generated automatically by the CG library, manual changes to it' ) -> writeln ( ' * will be lost upon next generation.' ) -> write ( ' */' ) ; $ docBlock = $ writer -> getContent ( ) ; } $ this -> generatedClass = PhpClass :: create ( ) -> setDocblock ( $ docBlock ) -> setParentClassName ( $ this -> class -> name ) ; $ proxyClassName = $ this -> getClassName ( $ this -> class ) ; if ( false === strpos ( $ proxyClassName , NamingStrategyInterface :: SEPARATOR ) ) { throw new \ RuntimeException ( sprintf ( 'The proxy class name must be suffixed with "%s" and an optional string, but got "%s".' , NamingStrategyInterface :: SEPARATOR , $ proxyClassName ) ) ; } $ this -> generatedClass -> setName ( $ proxyClassName ) ; if ( ! empty ( $ this -> interfaces ) ) { $ this -> generatedClass -> setInterfaceNames ( array_map ( function ( $ v ) { return '\\' . $ v ; } , $ this -> interfaces ) ) ; foreach ( $ this -> getInterfaceMethods ( ) as $ method ) { $ method = PhpMethod :: fromReflection ( $ method ) ; $ method -> setAbstract ( false ) ; $ this -> generatedClass -> setMethod ( $ method ) ; } } if ( ! empty ( $ this -> generators ) ) { foreach ( $ this -> generators as $ generator ) { $ generator -> generate ( $ this -> class , $ this -> generatedClass ) ; } } return $ this -> generateCode ( $ this -> generatedClass ) ; } | Creates a new enhanced class |
44,748 | protected function getInterfaceMethods ( ) { $ methods = array ( ) ; foreach ( $ this -> interfaces as $ interface ) { $ ref = new \ ReflectionClass ( $ interface ) ; $ methods = array_merge ( $ methods , $ ref -> getMethods ( ) ) ; } return $ methods ; } | Adds stub methods for the interfaces that have been implemented . |
44,749 | public function proceed ( ) { if ( isset ( $ this -> interceptors [ $ this -> pointer ] ) ) { return $ this -> interceptors [ $ this -> pointer ++ ] -> intercept ( $ this ) ; } $ this -> reflection -> setAccessible ( true ) ; return $ this -> reflection -> invokeArgs ( $ this -> object , $ this -> arguments ) ; } | Proceeds down the call - chain and eventually calls the original method . |
44,750 | public static function maybeDecode ( $ value , $ asArray = false ) { if ( ! is_string ( $ value ) ) { return $ value ; } $ decoded = json_decode ( $ value , $ asArray ) ; if ( json_last_error ( ) == JSON_ERROR_NONE && ( is_object ( $ decoded ) || is_array ( $ decoded ) ) ) { return $ decoded ; } else { json_decode ( "[]" ) ; return $ value ; } } | Checks if a value is json encoded |
44,751 | public static function maybeEncode ( $ value ) { if ( is_array ( $ value ) || is_object ( $ value ) ) { $ value = json_encode ( $ value ) ; } return $ value ; } | Checks if a value needs to get json encoded |
44,752 | public function getMeta ( $ key , $ default = null , $ getObj = false ) { $ meta = $ this -> meta ( ) -> where ( 'key' , $ key ) -> get ( ) ; if ( $ getObj ) { $ collection = $ meta ; } else { $ collection = new Collection ( ) ; foreach ( $ meta as $ m ) { $ collection -> put ( $ m -> id , $ m -> value ) ; } } if ( 0 == $ collection -> count ( ) ) { return $ default ; } return $ collection -> count ( ) <= 1 ? $ collection -> first ( ) : $ collection ; } | Gets meta data |
44,753 | public function updateMeta ( $ key , $ newValue , $ oldValue = false ) { $ meta = $ this -> getMeta ( $ key , null , true ) ; if ( $ meta == null ) { return $ this -> addMeta ( $ key , $ newValue ) ; } $ obj = $ this -> getEditableItem ( $ meta , $ oldValue ) ; if ( $ obj !== false ) { $ isSaved = $ obj -> update ( [ 'value' => $ newValue ] ) ; return $ isSaved ? $ obj : $ obj -> getErrors ( ) ; } return null ; } | Updates meta data |
44,754 | public function addMeta ( $ key , $ value ) { $ existing = $ this -> meta ( ) -> where ( 'key' , $ key ) -> where ( 'value' , Helpers :: maybeEncode ( $ value ) ) -> first ( ) ; if ( $ existing ) { return false ; } $ meta = $ this -> meta ( ) -> create ( [ 'key' => $ key , 'value' => $ value , ] ) ; return $ meta -> isSaved ( ) ? $ meta : $ meta -> getErrors ( ) ; } | Adds meta data |
44,755 | public function appendMeta ( $ key , $ value ) { $ meta = $ this -> getMeta ( $ key ) ; if ( ! $ meta ) { $ meta = [ ] ; } elseif ( ! is_array ( $ meta ) ) { $ meta = [ $ meta ] ; } if ( is_array ( $ value ) ) { $ meta = array_merge ( $ meta , $ value ) ; } else { $ meta [ ] = $ value ; } return $ this -> updateMeta ( $ key , array_values ( array_unique ( $ meta ) ) ) ; } | Appends a value to an existing meta entry Resets all keys |
44,756 | public function deleteMeta ( $ key , $ value = false ) { if ( $ value ) { $ meta = $ this -> getMeta ( $ key , null , true ) ; if ( $ meta == null ) { return false ; } $ obj = $ this -> getEditableItem ( $ meta , $ value ) ; return $ obj !== false ? $ obj -> delete ( ) : false ; } else { return $ this -> meta ( ) -> where ( 'key' , $ key ) -> delete ( ) ; } } | Deletes meta data |
44,757 | protected function getEditableItem ( $ meta , $ value ) { if ( $ meta instanceof Collection ) { if ( $ value === false ) { return false ; } $ filtered = $ meta -> filter ( function ( $ m ) use ( $ value ) { return $ m -> value == $ value ; } ) ; $ obj = $ filtered -> first ( ) ; if ( $ obj == null ) { return false ; } } else { $ obj = $ meta ; } return $ obj -> exists ? $ obj : false ; } | Gets an item to edit |
44,758 | public function meta ( ) { $ meta_model = isset ( $ this -> meta_model ) ? $ this -> meta_model : Meta :: class ; return $ this -> morphMany ( $ meta_model , 'metable' ) ; } | Attaches meta data |
44,759 | public function lastId ( $ field = null ) { try { $ this -> checkDialect ( ) ; } catch ( \ Exception $ e ) { $ this -> error = $ e -> getMessage ( ) ; return 0 ; } return $ this -> dialect -> lastInsertId ( $ field ) ; } | get the last inserted id |
44,760 | public function start ( $ session_id = null ) { if ( $ this -> session_id ) { return $ this -> session_id ; } $ session_expire = $ this -> expire ; $ http_only = true ; @ ini_set ( 'session.use_cookies' , 1 ) ; @ session_set_cookie_params ( $ session_expire , '/' , '' , false , $ http_only ) ; if ( $ session_expire ) { @ ini_set ( 'session.gc_maxlifetime' , $ session_expire + 2 ) ; } $ session_name = get_session_name ( ) ; if ( empty ( $ session_id ) ) { $ session_id = isset ( $ _COOKIE [ $ session_name ] ) ? $ _COOKIE [ $ session_name ] : null ; if ( empty ( $ session_id ) && isset ( $ _REQUEST [ $ session_name ] ) ) { $ session_id = $ _REQUEST [ $ session_name ] ; } } try { @ session_name ( $ session_name ) ; if ( ! empty ( $ session_id ) ) { $ this -> session_id = $ session_id ; @ session_id ( $ session_id ) ; @ session_start ( ) ; } else { @ session_start ( ) ; $ this -> session_id = session_id ( ) ; } } catch ( \ Exception $ e ) { $ msg = 'Cannot start session: ' . $ e -> getMessage ( ) ; log_error ( $ msg ) ; return '' ; } return $ this -> session_id ; } | start the session |
44,761 | private function generateSQL ( & $ sql , $ from , $ joins , $ where , $ having , $ group , $ values ) { $ froms = [ ] ; foreach ( $ from as $ f ) { $ froms [ ] = $ f [ 0 ] . ' AS ' . $ f [ 1 ] ; } $ sql [ ] = implode ( ',' , $ froms ) ; if ( $ joins ) { foreach ( $ joins as $ join ) { $ sql [ ] = $ join [ 2 ] . ' ' . $ join [ 0 ] . ' AS ' . $ join [ 3 ] . ' ON (' . $ join [ 1 ] . ')' ; } } if ( $ where && count ( $ where ) > 0 ) { $ sql [ ] = 'WHERE ' . $ where -> getWhereCondition ( $ this , $ values ) ; } if ( $ group ) { $ sql [ ] = 'GROUP BY ' . implode ( ' , ' , $ group ) ; } if ( $ having ) { $ sql [ ] = 'HAVING ' . implode ( ' AND ' , $ having ) ; } } | generate the common SQL for select and select count |
44,762 | public function echoHeader ( ) { if ( $ this -> status != 200 ) { http_response_code ( $ this -> status ) ; } else if ( defined ( 'CACHE_EXPIRE' ) && CACHE_EXPIRE ) { Response :: cache ( CACHE_EXPIRE ) ; } if ( ! empty ( $ this -> headers ) && is_array ( $ this -> headers ) ) { foreach ( $ this -> headers as $ name => $ value ) { @ header ( "$name: $value" , true ) ; } } } | set http response header |
44,763 | public function left ( $ table , ... $ on ) { $ this -> join ( $ table , Condition :: cleanField ( $ on [ 0 ] ) . '=' . Condition :: cleanField ( $ on [ 1 ] ) , self :: LEFT ) ; return $ this ; } | left join . |
44,764 | public function right ( $ table , ... $ on ) { $ this -> join ( $ table , Condition :: cleanField ( $ on [ 0 ] ) . '=' . Condition :: cleanField ( $ on [ 1 ] ) , self :: RIGHT ) ; return $ this ; } | right join . |
44,765 | public function inner ( $ table , ... $ on ) { $ this -> join ( $ table , Condition :: cleanField ( $ on [ 0 ] ) . '=' . Condition :: cleanField ( $ on [ 1 ] ) , self :: INNER ) ; return $ this ; } | inner join . |
44,766 | protected function prepareFields ( $ fields , $ values ) { $ _fields = [ ] ; foreach ( $ fields as $ field ) { if ( $ field instanceof Query ) { $ field -> setDialect ( $ this -> dialect ) ; $ field -> setBindValues ( $ values ) ; $ as = $ field -> getAlias ( ) ; if ( $ as ) { $ _fields [ ] = '(' . $ field . ') AS ' . $ this -> sanitize ( '`' . $ as . '`' ) ; } } else if ( $ field instanceof ImmutableValue ) { $ _fields [ ] = $ field -> __toString ( ) ; } else { $ _fields [ ] = $ this -> sanitize ( $ field ) ; } } if ( $ _fields ) { return implode ( ',' , $ _fields ) ; } else { return false ; } } | prepare the fields in select SQL |
44,767 | protected final function hasMany ( $ tableCls , $ foreign_key = '' , $ value_key = '' ) { if ( ! $ tableCls instanceof View ) { $ tableCls = new SimpleTable ( $ tableCls , $ this -> dbconnection ) ; } if ( ! $ foreign_key ) { $ foreign_key = $ this -> foreignKey ; } if ( ! $ value_key ) { $ value_key = $ this -> primaryKey ; } $ sql = $ tableCls -> select ( ) ; return [ $ sql , $ foreign_key , $ value_key , false , 'hasMany' ] ; } | one - to - many . |
44,768 | protected final function belongsTo ( $ tableCls , $ value_key = '' , $ foreign_key = '' ) { if ( ! $ tableCls instanceof View ) { $ tableCls = new SimpleTable ( $ tableCls , $ this -> dbconnection ) ; } if ( ! $ foreign_key ) { $ foreign_key = $ tableCls -> primaryKey ; } if ( ! $ value_key ) { $ value_key = $ tableCls -> foreignKey ; } $ sql = $ tableCls -> select ( ) ; return [ $ sql , $ foreign_key , $ value_key , true , 'belongsTo' ] ; } | one - to - one and one - to - many inverse |
44,769 | public function getTablesFromSQL ( $ sql ) { $ p = '/CREATE\s+TABLE\s+(IF\s+NOT\s+EXISTS\s+)?([^\(]+)/mi' ; $ tables = [ ] ; $ views = [ ] ; if ( preg_match_all ( $ p , $ sql , $ ms , PREG_SET_ORDER ) ) { foreach ( $ ms as $ m ) { if ( count ( $ m ) == 3 ) { $ table = $ m [ 2 ] ; } else { $ table = $ m [ 1 ] ; } if ( $ table ) { $ table = trim ( trim ( $ table , '` ' ) ) ; $ tables [ ] = str_replace ( '{prefix}' , $ this -> tablePrefix , $ table ) ; } } } $ p = '/CREATE\s+VIEW\s+(IF\s+NOT\s+EXISTS\s+)?(.+?)\s+AS/mi' ; if ( preg_match_all ( $ p , $ sql , $ ms , PREG_SET_ORDER ) ) { foreach ( $ ms as $ m ) { if ( count ( $ m ) == 3 ) { $ table = $ m [ 2 ] ; } else { $ table = $ m [ 1 ] ; } if ( $ table ) { $ table = trim ( trim ( $ table , '` ' ) ) ; $ views [ ] = str_replace ( '{prefix}' , $ this -> tablePrefix , $ table ) ; } } } return [ 'tables' => $ tables , 'views' => $ views ] ; } | get tables from sql . |
44,770 | public function start ( ) { if ( $ this -> dialect ) { $ this -> transLevel += 1 ; $ dialect = $ this -> dialect ; if ( $ dialect -> inTransaction ( ) ) { return true ; } $ rst = $ dialect -> beginTransaction ( ) ; if ( $ rst ) { return true ; } else { $ this -> transLevel -= 1 ; } } return false ; } | start a database transaction |
44,771 | public function commit ( ) { if ( $ this -> dialect ) { $ dialect = $ this -> dialect ; if ( $ dialect -> inTransaction ( ) ) { $ this -> transLevel -= 1 ; if ( $ this -> transLevel > 0 ) { return true ; } try { if ( $ this -> commitType == 'rollback' ) { $ dialect -> rollBack ( ) ; return false ; } else { return $ dialect -> commit ( ) ; } } catch ( \ PDOException $ e ) { $ this -> error = $ e -> getMessage ( ) ; } finally { $ this -> transLevel = 0 ; $ this -> commitType = null ; } } } return false ; } | commit a transaction |
44,772 | public function exec ( $ sql ) { $ dialect = $ this -> dialect ; if ( is_null ( $ dialect ) ) { return false ; } try { $ sql = preg_replace_callback ( '#\{[a-z][a-z0-9_].*\}#i' , function ( $ r ) use ( $ dialect ) { return $ dialect -> getTableName ( $ r [ 0 ] ) ; } , $ sql ) ; return false !== $ dialect -> exec ( $ sql ) ; } catch ( \ Exception $ e ) { $ this -> error = $ e -> getMessage ( ) ; return false ; } } | execute a ddl SQL . |
44,773 | public function set ( $ data , $ batch = false ) { $ this -> data = $ data ; $ this -> batch = $ batch ; return $ this ; } | the data to be updated |
44,774 | public function field ( $ field , $ alias = null ) { if ( is_string ( $ field ) ) { $ fields = explode ( ',' , trim ( $ field ) ) ; foreach ( $ fields as $ field ) { $ this -> fields [ ] = Condition :: cleanField ( $ field . ( $ alias ? ' AS ' . $ alias : '' ) ) ; } } else if ( $ field instanceof Query ) { if ( $ alias ) { $ field -> alias ( $ alias ) ; } $ this -> fields [ ] = $ field ; } else if ( $ field instanceof ImmutableValue ) { if ( $ alias ) { $ field -> alias ( $ alias ) ; } $ this -> fields [ ] = $ field ; } return $ this ; } | append a field to result set . |
44,775 | public function exist ( $ filed = null ) { if ( $ filed ) { $ this -> field ( $ filed ) ; } return $ this -> total ( $ filed ) > 0 ; } | check if there is any row in database suits the condition . |
44,776 | public function with ( ... $ fields ) { foreach ( $ fields as $ f ) { $ this -> eagerFields [ $ f ] = $ f ; } return $ this ; } | eager loading fields |
44,777 | private function getSQL ( ) { try { $ this -> checkDialect ( ) ; } catch ( DialectException $ e ) { return null ; } if ( ! $ this -> values ) { $ this -> values = new BindValues ( ) ; } else if ( ! $ this -> valueFixed ) { $ this -> values -> reset ( ) ; } $ fields = $ this -> prepareFields ( $ this -> fields , $ this -> values ) ; $ from = $ this -> prepareFrom ( $ this -> sanitize ( $ this -> from ) ) ; $ joins = $ this -> prepareJoins ( $ this -> sanitize ( $ this -> joins ) ) ; $ having = $ this -> sanitize ( $ this -> having ) ; $ group = $ this -> sanitize ( $ this -> group ) ; $ order = $ this -> sanitize ( $ this -> order ) ; return $ this -> dialect -> getSelectSQL ( $ fields , $ from , $ joins , $ this -> where , $ having , $ group , $ order , $ this -> limit , $ this -> values , $ this -> forupdate ) ; } | get the raw SQL . |
44,778 | public function uploadFile ( $ realPath , $ file_name , $ file_type , UploadFileParameters $ params = null ) { if ( is_null ( $ params ) ) { $ params = new UploadFileParameters ( ) ; } $ params = $ params -> exportToArray ( ) ; $ params [ 'file' ] = $ realPath ; $ params [ 'fileUri' ] = $ file_name ; $ params [ 'fileType' ] = $ file_type ; $ requestData = $ this -> getDefaultRequestData ( 'multipart' , $ params ) ; return $ this -> sendRequest ( 'file' , $ requestData , self :: HTTP_METHOD_POST ) ; } | Uploads original source content to Smartling . |
44,779 | public function downloadFile ( $ fileUri , $ locale = '' , DownloadFileParameters $ params = null ) { if ( ( ! is_string ( $ locale ) ) || strlen ( $ locale ) < 2 ) { $ message = vsprintf ( 'Invalid locale value got. Expected a string of at least 2 chars length, but got: %s' , [ '' === $ locale ? 'Empty string' : var_export ( $ locale , true ) ] ) ; throw new SmartlingApiException ( $ message ) ; } $ params = ( is_null ( $ params ) ) ? [ ] : $ params -> exportToArray ( ) ; $ params [ 'fileUri' ] = $ fileUri ; $ requestData = $ this -> getDefaultRequestData ( 'query' , $ params ) ; unset ( $ requestData [ 'headers' ] [ 'Accept' ] ) ; return $ this -> sendRequest ( "locales/{$locale}/file" , $ requestData , self :: HTTP_METHOD_GET , true ) ; } | Downloads the requested file from Smartling . |
44,780 | public function getStatus ( $ fileUri , $ locale , ParameterInterface $ params = null ) { $ params = ( is_null ( $ params ) ) ? [ ] : $ params -> exportToArray ( ) ; $ params [ 'fileUri' ] = $ fileUri ; $ requestData = $ this -> getDefaultRequestData ( 'query' , $ params ) ; return $ this -> sendRequest ( "locales/$locale/file/status" , $ requestData , self :: HTTP_METHOD_GET ) ; } | Retrieves status about file translation progress . |
44,781 | public function getList ( ListFilesParameters $ params = null ) { $ params = ( is_null ( $ params ) ) ? [ ] : $ params -> exportToArray ( ) ; $ requestData = $ this -> getDefaultRequestData ( 'query' , $ params ) ; return $ this -> sendRequest ( 'files/list' , $ requestData , self :: HTTP_METHOD_GET ) ; } | Lists recently uploaded files . Returns a maximum of 500 files . |
44,782 | public function renameFile ( $ fileUri , $ newFileUri , ParameterInterface $ params = null ) { $ params = ( is_null ( $ params ) ) ? [ ] : $ params -> exportToArray ( ) ; $ params [ 'fileUri' ] = $ fileUri ; $ params [ 'newFileUri' ] = $ newFileUri ; $ requestData = $ this -> getDefaultRequestData ( 'form_params' , $ params ) ; return $ this -> sendRequest ( 'file/rename' , $ requestData , self :: HTTP_METHOD_POST ) ; } | Renames an uploaded file by changing the fileUri . |
44,783 | public function import ( $ locale , $ fileUri , $ fileType , $ fileRealPath , $ translationState , $ overwrite = false ) { $ params [ 'fileUri' ] = $ fileUri ; $ params [ 'fileType' ] = $ fileType ; $ params [ 'file' ] = $ fileRealPath ; $ params [ 'translationState' ] = $ translationState ; $ params [ 'overwrite' ] = $ overwrite ; $ requestData = $ this -> getDefaultRequestData ( 'multipart' , $ params ) ; return $ this -> sendRequest ( "/locales/$locale/file/import" , $ requestData , self :: HTTP_METHOD_POST ) ; } | Import files form Service . |
44,784 | public function uploadContext ( UploadContextParameters $ params ) { $ requestData = $ this -> getDefaultRequestData ( 'multipart' , $ params -> exportToArray ( ) ) ; return $ this -> sendRequest ( 'contexts' , $ requestData , self :: HTTP_METHOD_POST ) ; } | Upload a new context . |
44,785 | public function matchContext ( $ contextUid , MatchContextParameters $ params = null ) { $ endpoint = vsprintf ( 'contexts/%s/match/async' , $ contextUid ) ; $ requestData = $ this -> getDefaultRequestData ( 'json' , is_null ( $ params ) ? [ ] : $ params -> exportToArray ( ) ) ; return $ this -> sendRequest ( $ endpoint , $ requestData , self :: HTTP_METHOD_POST ) ; } | Match context async . |
44,786 | public function matchContextSync ( $ contextUid , MatchContextParameters $ params = null ) { $ this -> wait ( $ this -> matchContext ( $ contextUid , $ params ) ) ; } | Match context sync . |
44,787 | public function getMatchStatus ( $ matchId ) { $ endpoint = vsprintf ( '/match/%s' , $ matchId ) ; $ requestData = $ this -> getDefaultRequestData ( 'query' , [ ] ) ; return $ this -> sendRequest ( $ endpoint , $ requestData , self :: HTTP_METHOD_GET ) ; } | Get context match status . |
44,788 | public function getMissingResources ( MissingResourcesParameters $ params = null ) { $ requestData = $ this -> getDefaultRequestData ( 'query' , is_null ( $ params ) ? [ ] : $ params -> exportToArray ( ) ) ; return $ this -> sendRequest ( 'missing-resources' , $ requestData , self :: HTTP_METHOD_GET ) ; } | Get missing resources . |
44,789 | public function getAllMissingResources ( ) { $ missingResources = [ ] ; $ offset = FALSE ; $ all = TRUE ; $ start_time = time ( ) ; while ( ! is_null ( $ offset ) ) { $ delta = time ( ) - $ start_time ; if ( $ delta > $ this -> getTimeOut ( ) ) { $ all = FALSE ; break ; } if ( ! $ offset ) { $ params = NULL ; } else { $ params = new MissingResourcesParameters ( ) ; $ params -> setOffset ( $ offset ) ; } $ response = $ this -> getMissingResources ( $ params ) ; $ offset = ! empty ( $ response [ 'offset' ] ) ? $ response [ 'offset' ] : NULL ; $ missingResources = array_merge ( $ missingResources , $ response [ 'items' ] ) ; } return [ 'items' => $ missingResources , 'all' => $ all , ] ; } | Get all missing resources . |
44,790 | public function uploadResource ( $ resourceId , UploadResourceParameters $ params ) { $ endpoint = vsprintf ( 'resources/%s' , $ resourceId ) ; $ requestData = $ this -> getDefaultRequestData ( 'multipart' , $ params -> exportToArray ( ) ) ; return $ this -> sendRequest ( $ endpoint , $ requestData , self :: HTTP_METHOD_PUT ) ; } | Upload resource . |
44,791 | public function renderContext ( $ contextUid ) { $ endpoint = vsprintf ( 'contexts/%s/render' , $ contextUid ) ; $ requestData = $ this -> getDefaultRequestData ( 'form_params' , [ ] ) ; return $ this -> sendRequest ( $ endpoint , $ requestData , self :: HTTP_METHOD_POST ) ; } | Render context . |
44,792 | public function cancelJobSync ( $ jobId , CancelJobParameters $ parameters ) { $ endpoint = vsprintf ( 'jobs/%s/cancel' , [ $ jobId ] ) ; $ requestData = $ this -> getDefaultRequestData ( 'json' , $ parameters -> exportToArray ( ) ) ; $ this -> wait ( $ this -> sendRequest ( $ endpoint , $ requestData , self :: HTTP_METHOD_POST ) ) ; } | Cancels a job synchronously . |
44,793 | public function listJobs ( ListJobsParameters $ parameters ) { $ requestData = $ this -> getDefaultRequestData ( 'query' , $ parameters -> exportToArray ( ) ) ; return $ this -> sendRequest ( 'jobs' , $ requestData , self :: HTTP_METHOD_GET ) ; } | Returns a list of jobs . |
44,794 | public function getJob ( $ jobId ) { $ requestData = $ this -> getDefaultRequestData ( 'query' , [ ] ) ; return $ this -> sendRequest ( 'jobs/' . $ jobId , $ requestData , self :: HTTP_METHOD_GET ) ; } | Returns a job . |
44,795 | public function authorizeJob ( $ jobId ) { $ endpoint = vsprintf ( 'jobs/%s/authorize' , [ $ jobId ] ) ; $ requestData = $ this -> getDefaultRequestData ( 'json' , new \ stdClass ( ) ) ; $ requestData [ 'headers' ] [ 'Content-Type' ] = 'application/json' ; $ this -> sendRequest ( $ endpoint , $ requestData , self :: HTTP_METHOD_POST ) ; } | Authorizes a job . |
44,796 | public function addFileToJobSync ( $ jobId , AddFileToJobParameters $ parameters ) { $ endpoint = vsprintf ( 'jobs/%s/file/add' , [ $ jobId ] ) ; $ requestData = $ this -> getDefaultRequestData ( 'json' , $ parameters -> exportToArray ( ) ) ; $ this -> wait ( $ this -> sendRequest ( $ endpoint , $ requestData , self :: HTTP_METHOD_POST ) ) ; } | Adds file to a job synchronously . |
44,797 | public function addLocaleToJobSync ( $ jobId , $ localeId , AddLocaleToJobParameters $ parameters ) { $ endpoint = vsprintf ( 'jobs/%s/locales/%s' , [ $ jobId , $ localeId ] ) ; $ requestData = $ this -> getDefaultRequestData ( 'json' , $ parameters -> exportToArray ( ) ) ; $ this -> wait ( $ this -> sendRequest ( $ endpoint , $ requestData , self :: HTTP_METHOD_POST ) ) ; } | Adds locale to a job synchronously . |
44,798 | public function checkAsynchronousProcessingStatus ( $ jobId , $ processId ) { $ endpoint = vsprintf ( 'jobs/%s/processes/%s' , [ $ jobId , $ processId ] ) ; $ requestData = $ this -> getDefaultRequestData ( 'query' , [ ] ) ; return $ this -> sendRequest ( $ endpoint , $ requestData , self :: HTTP_METHOD_GET ) ; } | Checks status of async process . |
44,799 | public static function create ( $ userIdentifier , $ secretKey , $ logger = null ) { $ client = self :: initializeHttpClient ( self :: ENDPOINT_URL ) ; return new self ( $ userIdentifier , $ secretKey , $ client , $ logger ) ; } | Creates and returns instance of AuthTokenProvider |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.