idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
13,800
|
public function setCountry ( $ country ) { if ( $ country === null ) { throw new Klarna_ArgumentNotSetException ( 'Country' ) ; } if ( is_numeric ( $ country ) ) { if ( ! is_int ( $ country ) ) { $ country = intval ( $ country ) ; } $ this -> country = $ country ; return ; } if ( strlen ( $ country ) == 2 || strlen ( $ country ) == 3 ) { $ this -> setCountry ( KlarnaCountry :: fromCode ( $ country ) ) ; return ; } throw new KlarnaException ( "Failed to set country! ($country)" ) ; }
|
Sets the country use either a two letter representation or the integer constant .
|
13,801
|
public function toArray ( ) { return array ( 'email' => $ this -> getEmail ( ) , 'telno' => $ this -> getTelno ( ) , 'cellno' => $ this -> getCellno ( ) , 'fname' => $ this -> getFirstName ( ) , 'lname' => $ this -> getLastName ( ) , 'company' => $ this -> getCompanyName ( ) , 'careof' => $ this -> getCareof ( ) , 'street' => $ this -> getStreet ( ) , 'house_number' => $ this -> getHouseNumber ( ) , 'house_extension' => $ this -> getHouseExt ( ) , 'zip' => $ this -> getZipCode ( ) , 'city' => $ this -> getCity ( ) , 'country' => $ this -> getCountry ( ) , ) ; }
|
Returns an associative array representing this object .
|
13,802
|
static function postRequest ( $ url , array $ post ) { $ handle = curl_init ( $ url ) ; curl_setopt_array ( $ handle , [ CURLOPT_POST => count ( $ post ) , CURLOPT_POSTFIELDS => http_build_query ( $ post ) , CURLOPT_RETURNTRANSFER => 1 ] ) ; $ result = curl_exec ( $ handle ) ; curl_close ( $ handle ) ; return $ result ; }
|
Get result string of post request
|
13,803
|
public function parse ( SourceStream $ code , SourceStorageInterface $ storage = NULL ) { $ buffer = new SourceBuffer ( ) ; $ this -> doParse ( $ code , $ buffer , $ storage ) ; return $ buffer ; }
|
Parse the given code and create a SourceGenerator from it extracted data for static analysis is stored in the given storage implementation .
|
13,804
|
protected function lookup ( $ localName , $ namespace = '' , array $ import = [ ] ) { if ( $ localName == '' ) { return $ localName ; } switch ( strtolower ( $ localName ) ) { case 'bool' : case 'int' : case 'float' : case 'string' : case 'array' : case 'callable' : return strtolower ( $ localName ) ; break ; } if ( $ localName [ 0 ] == '\\' ) { return ltrim ( $ localName , '\\' ) ; } if ( false === ( strpos ( $ localName , '\\' ) ) ) { $ n = strtolower ( $ localName ) ; return isset ( $ import [ $ n ] ) ? $ import [ $ n ] : ltrim ( $ namespace . '\\' . $ localName , '\\' ) ; } $ parts = explode ( '\\' , $ localName , 2 ) ; $ alias = strtolower ( $ parts [ 0 ] ) ; if ( isset ( $ import [ $ alias ] ) ) { return ltrim ( $ import [ $ alias ] . '\\' . $ parts [ 1 ] , '\\' ) ; } return ltrim ( $ namespace . '\\' . $ localName , '\\' ) ; }
|
Lookup a fully qualified name in the given namespace considering imports .
|
13,805
|
protected function parseTypeModifiers ( array $ tokens ) { $ modifiers = 0 ; foreach ( $ tokens as $ tok ) { if ( is_array ( $ tok ) ) { switch ( $ tok [ 0 ] ) { case T_ABSTRACT : $ modifiers |= MetaInfo :: IS_ABSTRACT ; break ; case T_FINAL : $ modifiers |= MetaInfo :: IS_FINAL ; break ; } } } return $ modifiers ; }
|
Extract all type modifiers from the given tokens and combine them into a bit mask .
|
13,806
|
protected function parseFieldModifiers ( array $ tokens ) { $ modifiers = MetaInfo :: IS_PUBLIC ; foreach ( $ tokens as $ tok ) { if ( is_array ( $ tok ) ) { switch ( $ tok [ 0 ] ) { case T_VAR : case T_PUBLIC : $ modifiers = ( $ modifiers | MetaInfo :: MASK_VISIBILITY ) ^ MetaInfo :: IS_NOT_PUBLIC ; break ; case T_PRIVATE : $ modifiers = ( $ modifiers | MetaInfo :: MASK_VISIBILITY ) ^ MetaInfo :: IS_NOT_PRIVATE ; break ; case T_PROTECTED : $ modifiers = ( $ modifiers | MetaInfo :: MASK_VISIBILITY ) ^ MetaInfo :: IS_NOT_PROTECTED ; break ; case T_STATIC : $ modifiers |= MetaInfo :: IS_STATIC ; break ; } } } return $ modifiers ; }
|
Parse all field modifiers from the given tokens and combine them into a bit mask .
|
13,807
|
protected function parseMethodModifiers ( array $ tokens ) { $ modifiers = MetaInfo :: IS_PUBLIC ; foreach ( $ tokens as $ tok ) { if ( is_array ( $ tok ) ) { switch ( $ tok [ 0 ] ) { case T_PUBLIC : $ modifiers = ( $ modifiers | MetaInfo :: MASK_VISIBILITY ) ^ MetaInfo :: IS_NOT_PUBLIC ; break ; case T_PRIVATE : $ modifiers = ( $ modifiers | MetaInfo :: MASK_VISIBILITY ) ^ MetaInfo :: IS_NOT_PRIVATE ; break ; case T_PROTECTED : $ modifiers = ( $ modifiers | MetaInfo :: MASK_VISIBILITY ) ^ MetaInfo :: IS_NOT_PROTECTED ; break ; case T_STATIC : $ modifiers |= MetaInfo :: IS_STATIC ; break ; case T_ABSTRACT : $ modifiers |= MetaInfo :: IS_ABSTRACT ; break ; case T_FINAL : $ modifiers |= MetaInfo :: IS_FINAL ; break ; } } } return $ modifiers ; }
|
Parse all method modifiers from the given tokens and combine them into a bit mask .
|
13,808
|
protected static function buildMessage ( $ template , array $ arguments ) { if ( self :: hasFormatter ( ) ) { return self :: getFormatter ( ) -> formatMessage ( $ template , $ arguments ) ; } else { array_walk ( $ arguments , function ( & $ value ) { $ value = is_scalar ( $ value ) ? ( string ) $ value : substr ( print_r ( $ value , true ) , 0 , 50 ) ; } ) ; $ count = substr_count ( $ template , '%s' ) ; $ size = sizeof ( $ arguments ) ; if ( $ count > $ size ) { $ arguments = $ arguments + array_fill ( $ size , $ count - $ size , '' ) ; } else { $ template .= str_repeat ( ' %s' , $ size - $ count ) ; } return vsprintf ( $ template , $ arguments ) ; } }
|
Build message from template and arguments .
|
13,809
|
public function get ( $ item = null ) { if ( empty ( $ this -> _detect ) || ! array_key_exists ( $ item , $ this -> _detect ) ) { $ this -> _detect = $ this -> detect ( ) ; } if ( $ item ) { return ( array_key_exists ( $ item , $ this -> _detect ) ) ? $ this -> _detect [ $ item ] : false ; } return $ this -> _detect ; }
|
Retrieves the full results of the current client detection or a specific parameter . Available parameters are hidpi width height speed modern touch and cookies .
|
13,810
|
private function detect ( ) { $ detect = array ( ) ; $ defaults = $ this -> getDefaults ( ) ; if ( $ this -> isDetected ( ) ) { $ detect = json_decode ( $ _COOKIE [ $ this -> cookieName ] , true ) ; if ( ! is_null ( $ detect ) ) { foreach ( $ detect as $ k => $ v ) { if ( $ v === "false" ) { $ detect [ $ k ] = $ v = false ; } if ( $ v === "true" ) { $ detect [ $ k ] = $ v = true ; } if ( $ v === false && in_array ( $ k , DetectDefaults :: SERVER ) ) { $ detect [ $ k ] = ( array_key_exists ( $ k , $ defaults ) ) ? $ defaults [ $ k ] : $ v ; } } } } elseif ( ! $ this -> DetectByUserAgent instanceof DetectByUserAgent ) { $ this -> DetectByUserAgent = new DetectByUserAgent ( ) ; $ detect = $ this -> DetectByUserAgent -> detect ( ) ; } return ( ! empty ( $ detect ) ) ? array_merge ( $ defaults , $ detect ) : $ defaults ; }
|
Parses the cookie left by d . js . If the cookie is not set due to Javascript being disabled or cookies being being blocked DetectByUserAgent is used to determine the values by the user agent .
|
13,811
|
public static function fromNative ( ) { $ args = func_get_args ( ) ; $ year = new Year ( $ args [ 0 ] ) ; $ month = Month :: fromNative ( $ args [ 1 ] ) ; $ day = new MonthDay ( $ args [ 2 ] ) ; return new static ( $ year , $ month , $ day ) ; }
|
Returns a new Date from native year month and day values
|
13,812
|
public static function fromNativeDateTime ( \ DateTime $ date ) { $ year = \ intval ( $ date -> format ( 'Y' ) ) ; $ month = Month :: fromNativeDateTime ( $ date ) ; $ day = \ intval ( $ date -> format ( 'd' ) ) ; return new static ( new Year ( $ year ) , $ month , new MonthDay ( $ day ) ) ; }
|
Returns a new Date from a native PHP \ DateTime
|
13,813
|
public function sameValueAs ( ValueObjectInterface $ date ) { if ( false === Util :: classEquals ( $ this , $ date ) ) { return false ; } return $ this -> getYear ( ) -> sameValueAs ( $ date -> getYear ( ) ) && $ this -> getMonth ( ) -> sameValueAs ( $ date -> getMonth ( ) ) && $ this -> getDay ( ) -> sameValueAs ( $ date -> getDay ( ) ) ; }
|
Tells whether two Date are equal by comparing their values
|
13,814
|
public function toNativeDateTime ( ) { $ year = $ this -> getYear ( ) -> toNative ( ) ; $ month = $ this -> getMonth ( ) -> getNumericValue ( ) ; $ day = $ this -> getDay ( ) -> toNative ( ) ; $ date = new \ DateTime ( ) ; $ date -> setDate ( $ year , $ month , $ day ) ; $ date -> setTime ( 0 , 0 , 0 ) ; return $ date ; }
|
Returns a native PHP \ DateTime version of the current Date
|
13,815
|
public function ComparePosition ( $ other , $ useLineNo = false ) { $ thisDomNode = $ this -> getUnderlyingObject ( ) ; $ otherDomNode = $ other -> getUnderlyingObject ( ) ; $ doc1 = $ thisDomNode -> baseURI ; $ doc2 = $ otherDomNode -> baseURI ; if ( strcasecmp ( $ doc1 , $ doc2 ) != 0 ) return XmlNodeOrder :: Unknown ; $ thisPath = $ thisDomNode -> getNodePath ( ) ; $ otherPath = $ otherDomNode -> getNodePath ( ) ; $ convert = function ( $ xPath , $ nodePath ) { $ parts = explode ( "/" , $ nodePath ) ; $ length = 0 ; foreach ( $ parts as $ key => & $ part ) { $ length ++ ; if ( $ part == "" ) continue ; $ length += strlen ( $ part ) ; $ result = $ xPath -> evaluate ( "count(" . substr ( $ nodePath , 0 , $ length - 1 ) . "/preceding-sibling::*) + 1" ) ; $ part = $ result ; } unset ( $ part ) ; return implode ( "/" , $ parts ) ; } ; $ xPath = new \ DOMXPath ( $ thisDomNode instanceof \ DOMDocument ? $ thisDomNode : $ thisDomNode -> ownerDocument ) ; $ thisPath = $ convert ( $ xPath , $ thisPath ) ; $ xPath = new \ DOMXPath ( $ otherDomNode instanceof \ DOMDocument ? $ otherDomNode : $ otherDomNode -> ownerDocument ) ; $ otherPath = $ convert ( $ xPath , $ otherPath ) ; if ( $ useLineNo ) { $ thisPath = $ thisDomNode -> getLineNo ( ) . "-" . $ thisPath ; $ otherPath = $ otherDomNode -> getLineNo ( ) . "-" . $ otherPath ; } $ compare = strnatcasecmp ( $ thisPath , $ otherPath ) ; return $ compare == 0 ? XmlNodeOrder :: Same : ( $ compare < 0 ? XmlNodeOrder :: Before : XmlNodeOrder :: After ) ; }
|
Compares the position of the current XPathNavigator with the position of the XPathNavigator specified .
|
13,816
|
public function getLineNo ( ) { if ( ! isset ( $ this -> domNode ) || $ this -> domNode instanceof \ DOMDocument ) { return 0 ; } return $ this -> domNode -> getLineNo ( ) ; }
|
return the line number in the underlying XML document of the current node
|
13,817
|
public function GetAttribute ( $ localName , $ namespaceURI ) { if ( $ this -> domNode -> nodeType != XML_ELEMENT_NODE ) { return "" ; } foreach ( $ this -> domNode -> attributes as $ attribute ) { if ( $ attribute -> namespaceURI != $ namespaceURI || $ attribute -> localName != $ localName ) { continue ; } return ( string ) $ attribute -> nodeValue ; } return "" ; }
|
Gets the value of the attribute with the specified local name and namespace URI .
|
13,818
|
public function getHasChildren ( $ type = null ) { if ( is_null ( $ this -> domNode ) ) return false ; $ hasAnyChildren = $ this -> domNode -> hasChildNodes ( ) ; if ( ! $ hasAnyChildren || is_null ( $ type ) ) return $ hasAnyChildren ; $ clone = $ this -> CloneInstance ( ) ; return $ clone -> MoveToChild ( $ type ) ; }
|
Not used but implement Gets a value indicating whether the current node has any child nodes .
|
13,819
|
public function getInnerXml ( ) { if ( is_null ( $ this -> domNode ) ) return null ; $ owner = $ this -> domNode instanceof \ DOMDocument ? $ this -> domNode : $ this -> domNode -> ownerDocument ; $ xml = $ owner -> saveXml ( $ this -> domNode , LIBXML_NOEMPTYTAG ) ; $ xml = ltrim ( preg_replace ( "/^<\?xml.*\?>/" , "" , $ xml ) ) ; $ xml = ltrim ( preg_replace ( "/^<!DOCTYPE[^>[]*(\[[^]]*\])?>/s" , "" , $ xml ) ) ; return $ xml ; }
|
Not used but implement Gets or sets the markup representing the child nodes of the current node .
|
13,820
|
public function getLocalName ( ) { if ( is_null ( $ this -> domNode ) ) return null ; if ( $ this -> domNode instanceof \ DOMNameSpaceNode ) { return $ this -> domNode -> localName ; } else { return $ this -> domNode -> nodeType == XPathNodeType :: ProcessingInstruction ? "{$this->domNode->nodeName}" : "{$this->domNode->localName}" ; } }
|
When overridden in a derived class gets the XPathNavigator . Name of the current node without any namespace prefix .
|
13,821
|
public function getName ( ) { if ( is_null ( $ this -> domNode ) ) return null ; if ( $ this -> domNode instanceof \ DOMNameSpaceNode ) { return $ this -> domNode -> prefix ; } else { return empty ( $ this -> domNode -> prefix ) ? "{$this->domNode->localName}" : "{$this->domNode->prefix}:{$this->domNode->localName}" ; } }
|
When overridden in a derived class gets the qualified name of the current node .
|
13,822
|
public function getNamespaceURI ( ) { if ( is_null ( $ this -> domNode ) ) return null ; return is_null ( $ this -> domNode -> namespaceURI ) ? "" : $ this -> domNode -> namespaceURI ; }
|
When overridden in a derived class gets the namespace URI of the current node .
|
13,823
|
public function getNodeType ( ) { if ( is_null ( $ this -> domNode ) ) return null ; return isset ( DOMXPathNavigator :: $ nodeTypeMap [ $ this -> domNode -> nodeType ] ) ? DOMXPathNavigator :: $ nodeTypeMap [ $ this -> domNode -> nodeType ] : XPathNodeType :: Element ; }
|
When overridden in a derived class gets the XPathNodeType of the current node .
|
13,824
|
public function getOuterXml ( ) { if ( is_null ( $ this -> domNode ) ) return "" ; return is_null ( $ this -> domNode -> parentNode ) ? $ this -> domNode -> ownerDocument -> saveXml ( $ this -> domNode ) : $ this -> domNode -> ownerDocument -> saveXml ( $ this -> domNode -> parentNode ) ; }
|
Gets or sets the markup representing the opening and closing tags of the current node and its child nodes .
|
13,825
|
public function getSchemaInfo ( ) { if ( is_null ( $ this -> domNode ) ) return null ; switch ( $ this -> domNode -> nodeType ) { case XML_ATTRIBUTE_NODE : case XML_ELEMENT_NODE : return new DOMName ( $ this -> domNode ) ; case XML_TEXT_NODE : return new DOMName ( $ this -> domNode -> parentNode ) ; default : return new DOMSchemaInfo ( $ this -> domNode ) ; } }
|
Gets the schema information that has been assigned to the current node as a result of schema validation .
|
13,826
|
public function CloneInstance ( ) { return is_null ( $ this -> domNode ) ? $ this : new DOMXPathNavigator ( $ this -> domNode , $ this -> nsManager , $ this -> nsTable ) ; }
|
When overridden in a derived class creates a new XPathNavigator positioned at the same node as this XPathNavigator .
|
13,827
|
public function IsSamePosition ( $ other ) { if ( is_null ( $ this -> domNode ) || is_null ( $ other ) ) return false ; return $ this -> domNode -> isSameNode ( $ other -> getUnderlyingObject ( ) ) ; }
|
When overridden in a derived class determines whether the current XPathNavigator is at the same position as the specified XPathNavigator .
|
13,828
|
public function MoveTo ( $ other ) { if ( is_null ( $ this -> domNode ) || is_null ( $ other ) ) return false ; $ this -> domNode = $ other -> getUnderlyingObject ( ) ; return true ; }
|
When overridden in a derived class moves the XPathNavigator to the same position as the specified XPathNavigator .
|
13,829
|
public function MoveToChild ( $ kind ) { if ( is_null ( $ this -> domNode ) || is_null ( $ kind ) || ! property_exists ( $ this -> domNode , 'firstChild' ) ) return false ; $ domNodeTypes = array_keys ( array_filter ( \ lyquidity \ XPath2 \ DOM \ DOMXPathNavigator :: $ nodeTypeMap , function ( $ nodeType ) use ( $ kind ) { return $ kind == \ lyquidity \ xml \ xpath \ XPathNodeType :: All || $ nodeType == $ kind ; } ) ) ; $ next = $ this -> domNode -> firstChild ; if ( is_null ( $ next ) ) return ; do { if ( in_array ( $ next -> nodeType , $ domNodeTypes ) ) { $ this -> domNode = $ next ; return true ; } } while ( ! is_null ( $ next = $ next -> nextSibling ) ) ; return false ; }
|
Moves the XPathNavigator to the child node of the XPathNodeType specified .
|
13,830
|
public function MoveToFirstAttribute ( ) { if ( is_null ( $ this -> domNode ) || $ this -> domNode instanceof \ DOMAttr || ! $ this -> domNode -> hasAttributes ( ) ) return false ; $ this -> domNode = $ this -> domNode -> attributes -> item ( 0 ) ; return true ; }
|
When overridden in a derived class moves the XPathNavigator to the first attribute of the current node .
|
13,831
|
public function MoveToAttribute ( $ localName , $ namespaceURI ) { if ( ! $ this -> MoveToFirstAttribute ( ) ) { return false ; } do { if ( $ this -> getLocalName ( ) == $ localName && ( ( is_null ( $ namespaceURI ) && empty ( $ this -> getNamespaceURI ( ) ) ) || $ this -> getNamespaceURI ( ) == $ namespaceURI ) ) { return true ; } } while ( $ this -> MoveToNextAttribute ( ) ) ; $ this -> MoveToParent ( ) ; return false ; }
|
Moves the XPathNavigator to the attribute with the matching local name and namespace URI .
|
13,832
|
public function MoveToFirstChild ( ) { if ( is_null ( $ this -> domNode ) || ( ! $ this -> domNode instanceof \ DOMDocument && ! $ this -> domNode instanceof \ DOMElement ) || ! $ this -> domNode -> hasChildNodes ( ) ) return false ; $ this -> domNode = $ this -> domNode -> firstChild ; return true ; }
|
When overridden in a derived class moves the XPathNavigator to the first child node of the current node .
|
13,833
|
public function MoveToFirstNamespace ( $ namespaceScope = XPathNamespaceScope :: Local ) { if ( is_null ( $ this -> domNode ) ) return false ; if ( $ this -> domNode -> nodeType != XML_ELEMENT_NODE && $ this -> domNode -> nodeType != XML_DOCUMENT_NODE ) return false ; $ expression = $ namespaceScope == XPathNamespaceScope :: Local ? 'namespace::*[not(. = ../../namespace::*)]' : 'namespace::*' ; $ xpath = new \ DOMXPath ( $ this -> domNode -> nodeType == XML_DOCUMENT_NODE ? $ this -> domNode : $ this -> domNode -> ownerDocument ) ; $ namespaces = $ xpath -> query ( $ expression , $ this -> domNode ) ; if ( ! $ namespaces || $ namespaces -> length == 0 ) return false ; $ this -> domNode = $ namespaces [ $ namespaces -> length - 1 ] ; return true ; }
|
When overridden in a derived class moves the XPathNavigator to the first namespace node that matches the XPathNamespaceScope specified .
|
13,834
|
public function MoveToFirst ( ) { if ( ! isset ( $ this -> domNode ) || ! $ this -> getIsNode ( ) ) return false ; if ( $ this -> domNode instanceof \ DOMDocument || $ this -> domNode -> parentNode instanceof \ DOMDocument ) return true ; $ this -> domNode = $ this -> domNode -> parentNode -> firstChild ; return true ; }
|
Moves the XPathNavigator to the first sibling node of the current node .
|
13,835
|
public function MoveToFollowing ( $ kind , $ end = null ) { if ( is_null ( $ this -> domNode ) || is_null ( $ kind ) || $ this -> domNode instanceof \ DOMAttr || $ this -> domNode instanceof \ DOMNameSpaceNode ) return false ; if ( ! is_null ( $ end ) && $ this -> IsSamePosition ( $ end ) ) return false ; if ( $ this -> domNode instanceof \ DOMDocument ) { $ this -> domNode = $ this -> domNode -> documentElement ; return true ; } $ node = $ this -> domNode ; while ( true ) { if ( $ node -> hasChildNodes ( ) ) { $ node = $ node -> firstChild ; } else { while ( true ) { if ( is_null ( $ node -> nextSibling ) ) { if ( $ node -> parentNode instanceof \ DOMDocument ) return false ; $ node = $ node -> parentNode ; } else { $ node = $ node -> nextSibling ; if ( ! is_null ( $ end ) && $ node -> isSameNode ( $ end -> getUnderlyingObject ( ) ) ) return false ; break ; } } } if ( XPathNodeType :: All == $ kind || $ node -> nodeType == $ kind ) break ; } $ this -> domNode = $ node ; return true ; }
|
Moves the XPathNavigator to the following element of the XPathNodeType specified to the boundary specified in document order .
|
13,836
|
public function MoveToNext ( $ kind = XPathNodeType :: All ) { if ( is_null ( $ this -> domNode ) || is_null ( $ kind ) ) return false ; $ domNodeTypes = array_keys ( array_filter ( DOMXPathNavigator :: $ nodeTypeMap , function ( $ nodeType ) use ( $ kind ) { return $ kind == XPathNodeType :: All || $ nodeType == $ kind ; } ) ) ; $ next = $ this -> domNode ; while ( ! is_null ( $ next = $ next -> nextSibling ) ) { if ( in_array ( $ next -> nodeType , $ domNodeTypes ) ) { $ this -> domNode = $ next ; return true ; } } return false ; }
|
Moves the XPathNavigator to the next sibling node of the current node that matches the XPathNodeType specified .
|
13,837
|
public function MoveToNextAttribute ( ) { if ( is_null ( $ this -> domNode ) || ! $ this -> domNode instanceof \ DOMAttr ) { return false ; } $ next = $ this -> domNode -> nextSibling ; if ( is_null ( $ next ) ) return false ; $ this -> domNode = $ next ; return true ; }
|
When overridden in a derived class moves the XPathNavigator to the next attribute .
|
13,838
|
public function MoveToNextNamespace ( $ namespaceScope = XPathNamespaceScope :: Local ) { if ( is_null ( $ this -> domNode ) ) return false ; if ( $ this -> domNode -> nodeType != XML_NAMESPACE_DECL_NODE ) return false ; $ expression = $ namespaceScope == XPathNamespaceScope :: Local ? 'namespace::*[not(. = ../../namespace::*)]' : 'namespace::*' ; $ xpath = new \ DOMXPath ( $ this -> domNode -> nodeType == XML_DOCUMENT_NODE ? $ this -> domNode : $ this -> domNode -> ownerDocument ) ; $ namespaces = $ xpath -> query ( $ expression , $ this -> domNode -> parentNode ) ; if ( ! count ( $ namespaces ) ) return false ; $ current = - 1 ; foreach ( $ namespaces as $ node ) { $ current ++ ; if ( $ this -> domNode -> parentNode -> getNodePath ( ) . "/" . $ this -> domNode -> nodeName == $ node -> parentNode -> getNodePath ( ) . "/" . $ node -> nodeName ) { break ; } } if ( $ current <= 0 ) return false ; $ current -- ; $ this -> domNode = $ namespaces [ $ current ] ; return true ; }
|
When overridden in a derived class moves the XPathNavigator to the next namespace node matching the XPathNamespaceScope specified .
|
13,839
|
public function MoveToParent ( ) { if ( is_null ( $ this -> domNode ) ) return false ; $ parent = $ this -> domNode -> parentNode ; if ( is_null ( $ parent ) ) return false ; $ this -> domNode = $ parent ; return true ; }
|
When overridden in a derived class moves the XPathNavigator to the parent node of the current node .
|
13,840
|
public function MoveToPrevious ( ) { if ( is_null ( $ this -> domNode ) || $ this -> domNode instanceof \ DOMAttr ) return false ; $ previous = $ this -> domNode -> previousSibling ; if ( is_null ( $ previous ) ) return false ; $ this -> domNode = $ previous ; return true ; }
|
When overridden in a derived class moves the XPathNavigator to the previous sibling node of the current node .
|
13,841
|
public function ToString ( ) { if ( is_null ( $ this -> domNode ) ) return "" ; if ( $ this -> domNode instanceof \ DOMDocument ) { $ result = $ this -> domNode -> saveXML ( null ) ; $ result = preg_replace ( "/^<\?xml.*\?>\s/" , "" , $ result ) ; return $ result ; } else { $ result = $ this -> domNode -> ownerDocument -> SaveXML ( $ this -> domNode ) ; return $ result ; } }
|
Gets the text value of the current node .
|
13,842
|
private function getCdnURI ( $ path ) { $ cleancdn = explode ( '/' , $ path ) ; unset ( $ cleancdn [ 0 ] ) ; unset ( $ cleancdn [ 1 ] ) ; reset ( $ cleancdn ) ; return implode ( $ cleancdn , '/' ) ; }
|
Retrieves a clean version of the CDN URI
|
13,843
|
public function executeCommand ( array $ arguments , $ processBuilderCallback = null ) { $ processBuilder = clone $ this -> processBuilder ; $ processBuilder -> setArguments ( $ arguments ) ; if ( is_callable ( $ processBuilderCallback ) ) { $ processBuilderCallback ( $ processBuilder ) ; } $ process = $ processBuilder -> getProcess ( ) ; $ process -> run ( ) ; if ( ! $ process -> isSuccessful ( ) ) { if ( 127 === $ process -> getExitCode ( ) ) { throw new ExecutableNotFoundException ( $ process ) ; } throw new ProcessFailedException ( $ process ) ; } return $ process ; }
|
Executes given command
|
13,844
|
public function deleteTable ( $ tableName ) { try { $ this -> db -> deleteTable ( $ tableName ) ; } catch ( \ Exception $ e ) { throw new DbException ( $ e -> getMessage ( ) ) ; } }
|
Delete a table from db
|
13,845
|
protected function retrieveModels ( array $ entity = [ ] ) { $ models = [ ] ; foreach ( ( array ) $ entity as $ node ) { $ models [ ] = $ this -> models -> get ( $ node ) ; } if ( empty ( $ models ) ) { $ models = $ this -> models -> all ( ) ; } return $ models ; }
|
Returns array with models for operation
|
13,846
|
protected function buildCreate ( array $ models ) { $ schemaManager = $ this -> connection -> getSchemaManager ( ) ; foreach ( $ models as $ model ) { if ( $ schemaManager -> tablesExist ( [ $ model -> table ( ) ] ) ) { throw new SchemaException ( sprintf ( 'Unable to create table, table "%s" already exists' , $ model -> table ( ) ) ) ; } $ this -> createTable ( $ this -> schema , $ model ) ; } $ this -> queries = array_merge ( $ this -> queries , $ this -> schema -> toSql ( $ this -> connection -> getDatabasePlatform ( ) ) ) ; }
|
Builds create table queries
|
13,847
|
protected function createTable ( SchemaAsset $ schema , ModelInterface $ model ) { $ table = $ schema -> createTable ( $ this -> quoteIdentifier ( $ model -> table ( ) ) ) ; foreach ( $ model -> fields ( ) as $ field ) { $ table -> addColumn ( $ this -> quoteIdentifier ( $ field -> mappedName ( ) ) , $ field -> type ( ) , $ field -> attributes ( ) ) ; } foreach ( $ model -> indexes ( ) as $ index ) { switch ( $ index -> type ( ) ) { case 'primary' : $ table -> setPrimaryKey ( $ this -> quoteIdentifier ( $ index -> fields ( ) ) , $ this -> quoteIdentifier ( $ index -> name ( ) ) ) ; break ; case 'unique' : $ table -> addUniqueIndex ( $ this -> quoteIdentifier ( $ index -> fields ( ) ) , $ this -> quoteIdentifier ( $ index -> name ( ) ) ) ; break ; case 'foreign' : $ table -> addForeignKeyConstraint ( $ index -> table ( ) , $ this -> quoteIdentifier ( array_keys ( $ index -> fields ( ) ) ) , $ this -> quoteIdentifier ( array_values ( $ index -> fields ( ) ) ) , [ 'onUpdate' => 'CASCADE' , 'onDelete' => 'RESTRICT' ] , $ this -> quoteIdentifier ( $ index -> name ( ) ) ) ; break ; case 'index' : default : $ table -> addIndex ( $ this -> quoteIdentifier ( $ index -> fields ( ) ) , $ this -> quoteIdentifier ( $ index -> name ( ) ) ) ; } } }
|
Creates table from model into schema
|
13,848
|
protected function quoteIdentifier ( $ identifier ) { if ( ! is_array ( $ identifier ) ) { return $ this -> connection -> quoteIdentifier ( $ identifier ) ; } foreach ( $ identifier as & $ value ) { $ value = $ this -> connection -> quoteIdentifier ( $ value ) ; unset ( $ value ) ; } return $ identifier ; }
|
Quotes SQL identifier or array of identifiers
|
13,849
|
protected function buildDrop ( array $ models ) { $ fromSchema = $ this -> connection -> getSchemaManager ( ) -> createSchema ( ) ; $ toSchema = clone $ fromSchema ; foreach ( $ models as $ model ) { if ( ! $ toSchema -> hasTable ( $ model -> table ( ) ) ) { continue ; } $ toSchema -> dropTable ( $ model -> table ( ) ) ; } $ sql = $ fromSchema -> getMigrateToSql ( $ toSchema , $ this -> connection -> getDatabasePlatform ( ) ) ; $ this -> queries = array_merge ( $ this -> queries , $ sql ) ; }
|
Builds drop table query
|
13,850
|
public function construct ( $ subject , & $ data = array ( ) ) { if ( null === $ this -> constructed ) { $ this -> constructed = unserialize ( sprintf ( 'O:%d:"%s":0:{}' , strlen ( $ subject ) , $ subject ) ) ; } return clone $ this -> constructed ; }
|
Construct a new object .
|
13,851
|
protected function serializer ( ) { if ( null === $ this -> serializer ) { $ self = $ this ; $ this -> serializer = Closure :: bind ( $ this -> bindSerializer ( ) , null , $ this -> class ) ; } return $ this -> serializer ; }
|
Get a reference to the bound serialization closure .
|
13,852
|
protected function deserializer ( ) { if ( null === $ this -> deserializer ) { $ self = $ this ; $ this -> deserializer = Closure :: bind ( $ this -> bindDeserializer ( ) , null , $ this -> class ) ; } return $ this -> deserializer ; }
|
Get a reference to the bound deserialization closure .
|
13,853
|
public static function initField ( $ configuration = [ ] ) { if ( ! array_key_exists ( 'type' , $ configuration ) || ! class_exists ( $ configuration [ 'type' ] ) ) { throw new InvalidFieldTypeException ( 'You did not specify a type on this class.' ) ; } $ collection = new static ( ) ; $ collection -> configuration = $ configuration ; $ collection -> type = $ configuration [ 'type' ] ; if ( array_key_exists ( 'max_items' , $ configuration ) ) { $ collection -> maxItems = $ configuration [ 'max_items' ] ; } return $ collection ; }
|
Initialize a collection with the configuration
|
13,854
|
protected function validateSet ( $ key , $ value ) { $ maxItems = $ this -> getMaxItems ( ) ; if ( ( is_null ( $ key ) || ! array_key_exists ( $ key , $ this -> items ) ) && $ maxItems != 0 && $ this -> count ( ) >= $ maxItems ) { throw new ItemCountException ( 'The maximum number of items has been reached on this field.' ) ; } if ( is_null ( $ key ) && is_null ( $ value ) ) { throw new NullValueException ( 'You cannot add a null value' ) ; } }
|
Validate input of OffsetSet
|
13,855
|
protected function getFieldInstance ( $ value ) { if ( $ value instanceof Field ) { return $ value ; } $ container = new $ this -> type ( ) ; $ container -> value = $ value ; return $ container ; }
|
Get a field from a value
|
13,856
|
public function clear ( ) { foreach ( $ this -> items as $ item ) { $ this -> deleted [ ] = $ item ; } $ this -> items = [ ] ; }
|
Remove all items in this collection
|
13,857
|
public function toArray ( ) { if ( $ this -> getMaxItems ( ) != 1 ) { return parent :: toArray ( ) ; } if ( ! array_key_exists ( 0 , $ this -> items ) ) { return null ; } return $ this -> get ( 0 ) -> toArray ( ) ; }
|
As we use a field collection even if we have only one value we use it that way .
|
13,858
|
function getScriptPath ( ) { $ fileName = $ this -> stack -> pop ( ) ; if ( $ this -> baseDir ) { return $ this -> baseDir . \ DIRECTORY_SEPARATOR . $ fileName ; } else { return ( string ) $ fileName ; } }
|
Get script file path
|
13,859
|
function assign ( $ array ) { if ( ! is_array ( $ array ) && ! ( $ array instanceof \ Traversable ) ) { throw new \ InvalidArgumentException ( '$array must be array or Traversable.' ) ; } foreach ( $ array as $ key => $ value ) { $ this -> storage [ $ key ] = $ value ; } }
|
assign view vars
|
13,860
|
public static function getText ( $ code ) { $ code = ( int ) $ code ; if ( ! self :: exists ( $ code ) ) { throw new \ DomainException ( 'Http Code does not exist!' ) ; } return self :: $ httpCodes [ $ code ] ; }
|
Return text for the specified http code .
|
13,861
|
public function execGET ( $ url , array $ params = [ ] ) { $ url = $ this -> baseUrl . $ url ; if ( $ params !== [ ] ) { $ url .= '?' . http_build_query ( $ params ) ; } $ this -> addOptions ( [ CURLOPT_URL => $ url , CURLOPT_HTTPGET => true , ] ) ; return $ this -> exec ( ) ; }
|
Execute a GET request to a given URL with optional parameters .
|
13,862
|
public function execPOST ( $ url , array $ params = [ ] ) { $ url = $ this -> baseUrl . $ url ; $ this -> addOptions ( [ CURLOPT_URL => $ url , CURLOPT_POST => true , CURLOPT_POSTFIELDS => $ params , ] ) ; return $ this -> exec ( ) ; }
|
Execute a POST request to a given URL with optional parameters .
|
13,863
|
public function configureSequence ( ) : \ Generator { $ sequence = $ this -> config [ 'configure' ] ?? $ this -> config [ 'configureSequence' ] ?? [ ] ; foreach ( $ sequence as $ item ) { yield $ this -> parseSequence ( $ item ) ; } }
|
Get list of configure sequences .
|
13,864
|
public function updateSequence ( ) : \ Generator { $ sequence = $ this -> config [ 'update' ] ?? $ this -> config [ 'updateSequence' ] ?? [ ] ; foreach ( $ sequence as $ item ) { yield $ this -> parseSequence ( $ item ) ; } }
|
Get list of all update sequences .
|
13,865
|
private function getAdapter ( TableInterface $ table , $ format ) { $ adapters = $ table -> getConfig ( ) -> getExportAdapters ( ) ; foreach ( $ adapters as $ adapter ) { if ( $ adapter -> supports ( $ format ) ) { return $ adapter ; } } return null ; }
|
Returns the adapter supporting the given format .
|
13,866
|
public static function sortDocumentsByField ( $ documents , $ field , $ order = 'ASC' ) { self :: $ orderByField = $ field ; self :: $ order = strtoupper ( $ order ) === 'ASC' ? 'ASC' : 'DESC' ; usort ( $ documents , '\CloudControl\Cms\util\DocumentSorter::fieldCompare' ) ; if ( $ order === 'DESC' ) { return array_reverse ( $ documents ) ; } return $ documents ; }
|
Sorts an array of Document instances
|
13,867
|
protected static function fieldCompare ( Document $ a , Document $ b ) { $ field = self :: $ orderByField ; if ( property_exists ( '\CloudControl\Cms\storage\entities\Document' , $ field ) ) { return strcasecmp ( $ a -> { $ field } , $ b -> { $ field } ) ; } if ( ! isset ( $ a -> fields -> { $ field } [ 0 ] ) ) { return - 3 ; } if ( ! isset ( $ b -> fields -> { $ field } [ 0 ] ) ) { return 3 ; } return strcasecmp ( $ a -> fields -> { $ field } [ 0 ] , $ b -> fields -> { $ field } [ 0 ] ) ; }
|
Compares two documents
|
13,868
|
private function checkCacheValid ( $ cacheFile ) { if ( file_exists ( $ cacheFile ) && ( filemtime ( $ cacheFile ) > filemtime ( $ this -> filePath ) ) ) { return true ; } return false ; }
|
Returns true if the cache file exists and is current .
|
13,869
|
public function ApplyMetricsToCanvas ( ) { $ destinationCanvas = @ imageCreateTrueColor ( $ this -> _metrics -> frameWidth , $ this -> _metrics -> frameHeight ) ; $ backColor = imagecolorallocate ( $ destinationCanvas , 255 , 255 , 255 ) ; if ( $ this -> _metrics -> sourceFormat == 3 ) { $ backColor = imagecolorallocatealpha ( $ destinationCanvas , 255 , 255 , 255 , 127 ) ; imagealphablending ( $ destinationCanvas , true ) ; imagesavealpha ( $ destinationCanvas , true ) ; } imagefill ( $ destinationCanvas , 1 , 1 , $ backColor ) ; @ imageCopyResampled ( $ destinationCanvas , $ this -> GetCanvas ( ) , $ this -> _metrics -> offsetX , $ this -> _metrics -> offsetY , 0 , 0 , $ this -> _metrics -> scaleWidth , $ this -> _metrics -> scaleHeight , $ this -> _metrics -> sourceWidth , $ this -> _metrics -> sourceHeight ) ; $ this -> SetCanvas ( $ destinationCanvas ) ; $ this -> _metrics -> Commit ( ) ; }
|
Makes sure that the current image metrics are applied to the canvas essentially committing the changes .
|
13,870
|
private function HasAnyPageRight ( BackendPageRights $ pageRights ) { return $ pageRights -> GetRemove ( ) || $ pageRights -> GetCreateIn ( ) || $ pageRights -> GetEdit ( ) || $ pageRights -> GetMove ( ) ; }
|
True if any of the page rights is true
|
13,871
|
private function HasAnyContentRight ( BackendContentRights $ contentRights ) { return $ contentRights -> GetEdit ( ) || $ contentRights -> GetRemove ( ) || $ contentRights -> GetCreateIn ( ) || $ contentRights -> GetMove ( ) ; }
|
True if any of the content rights is true
|
13,872
|
private function GrantGroupOnContent ( Usergroup $ group , Usergroup $ contentGroup , BackendContentRights $ contentRights , BackendAction $ action ) { if ( ! $ group -> Equals ( $ contentGroup ) ) { return GrantResult :: NoAccess ( ) ; } $ allowed = false ; switch ( $ action ) { case BackendAction :: Create ( ) : $ allowed = $ contentRights -> GetCreateIn ( ) ; break ; case BackendAction :: Edit ( ) : $ allowed = $ contentRights -> GetEdit ( ) ; break ; case BackendAction :: Move ( ) : $ allowed = $ contentRights -> GetMove ( ) ; break ; case BackendAction :: Delete ( ) : $ allowed = $ contentRights -> GetRemove ( ) ; break ; case BackendAction :: Read ( ) : $ allowed = $ this -> HasAnyContentRight ( $ contentRights ) ; break ; } return $ allowed ? GrantResult :: Allowed ( ) : GrantResult :: NoAccess ( ) ; }
|
Calculates the grant result for a group on a content
|
13,873
|
private function GrantCreateLayout ( ) { $ groups = $ this -> GetGroups ( ) ; foreach ( $ groups as $ group ) { if ( $ group -> GetCreateLayouts ( ) ) { return GrantResult :: Allowed ( ) ; } } return GrantResult :: NoAccess ( ) ; }
|
Grant access to create a new layout by common group settings
|
13,874
|
private function GrantOnContent ( Content $ content , BackendAction $ action ) { if ( $ this -> GetUser ( ) -> Equals ( $ content -> GetUser ( ) ) ) { return GrantResult :: Allowed ( ) ; } $ contentRights = RightsFinder :: FindContentRights ( $ content ) ; $ contentGroup = GroupFinder :: FindContentGroup ( $ content ) ; if ( ! $ contentRights || ! $ contentGroup ) { return GrantResult :: NoAccess ( ) ; } $ groups = $ this -> GetGroups ( ) ; foreach ( $ groups as $ group ) { $ result = $ this -> GrantGroupOnContent ( $ group , $ contentGroup , $ contentRights , $ action ) ; if ( $ result -> Equals ( GrantResult :: Allowed ( ) ) ) { return $ result ; } } return GrantResult :: NoAccess ( ) ; }
|
Calculates the grant result for a content
|
13,875
|
function GrantAddPageToSite ( Site $ site ) { $ page = new Page ( ) ; $ page -> SetUserGroup ( $ site -> GetUserGroup ( ) ) ; $ siteRights = $ site -> GetUserGroupRights ( ) ; if ( $ siteRights ) { $ page -> SetUserGroupRights ( $ siteRights -> GetPageRights ( ) ) ; } return $ this -> Grant ( BackendAction :: Create ( ) , $ page ) ; }
|
Grant evaluation for adding a page on top of the site
|
13,876
|
function GrantAddContentToPageArea ( Page $ page , Area $ area ) { $ result = $ this -> Grant ( BackendAction :: Create ( ) , $ area ) ; if ( ! $ result -> ToBool ( ) ) { return $ result ; } return $ this -> GrantAddContentToPage ( $ page ) ; }
|
Grant evaluation vor a page are
|
13,877
|
function GrantAddContentToPage ( Page $ page ) { $ content = new Content ( ) ; $ content -> SetUserGroup ( GroupFinder :: FindPageGroup ( $ page ) ) ; $ pageRights = RightsFinder :: FindPageRights ( $ page ) ; if ( $ pageRights ) { $ content -> SetUserGroupRights ( $ pageRights -> GetContentRights ( ) ) ; } return $ this -> Grant ( BackendAction :: Create ( ) , $ content ) ; }
|
Grant evaluation for adding content on top of a page area
|
13,878
|
function GrantAddContentToLayoutArea ( Area $ area ) { $ result = $ this -> Grant ( BackendAction :: Create ( ) , $ area ) ; if ( ! $ result -> ToBool ( ) ) { return $ result ; } return $ this -> GrantAddContentToLayout ( $ area -> GetLayout ( ) ) ; }
|
Grant evaluation for adding content to layout area
|
13,879
|
function GrantAddContentToLayout ( Layout $ layout ) { $ content = new Content ( ) ; $ content -> SetUserGroup ( $ layout -> GetUserGroup ( ) ) ; $ layoutRights = $ layout -> GetUserGroupRights ( ) ; if ( $ layoutRights ) { $ content -> SetUserGroupRights ( $ layoutRights -> GetContentRights ( ) ) ; } return $ this -> Grant ( BackendAction :: Create ( ) , $ content ) ; }
|
Grant evaluation for adding content on top of a layout area
|
13,880
|
function GrantAddContentToContainer ( Container $ container ) { $ content = new Content ( ) ; $ content -> SetUserGroup ( $ container -> GetUserGroup ( ) ) ; $ containerRights = $ container -> GetUserGroupRights ( ) ; if ( $ containerRights ) { $ content -> SetUserGroupRights ( $ containerRights -> GetContentRights ( ) ) ; } return $ this -> Grant ( BackendAction :: Create ( ) , $ content ) ; }
|
Grant evaluation for adding content on top of a container
|
13,881
|
public static function serialize ( $ value ) : string { $ serialized = json_encode ( self :: encode ( $ value , new SplObjectStorage ( ) ) , JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new \ InvalidArgumentException ( json_last_error_msg ( ) ) ; } return $ serialized ; }
|
Serialize the given value into a JSON encoded string .
|
13,882
|
private static function objectProperties ( $ object ) : array { if ( $ object instanceof Serializable ) { return [ '$' => $ object -> serialize ( ) ] ; } $ class = get_class ( $ object ) ; $ properties = [ ] ; do { try { $ properties += Closure :: bind ( function ( ) use ( $ object ) { return get_object_vars ( $ object ) ; } , null , $ class ) -> __invoke ( ) ; } catch ( Throwable $ e ) { return get_object_vars ( $ object ) ; } } while ( $ class = get_parent_class ( $ class ) ) ; return method_exists ( $ object , '__sleep' ) ? array_intersect_key ( $ properties , array_flip ( $ object -> __sleep ( ) ) ) : $ properties ; }
|
Get array of all the object properties .
|
13,883
|
public static function apply ( $ field ) { if ( 'repeater' === $ field [ 'type' ] && is_array ( $ field [ 'value' ] ) ) { self :: transform_image_fields ( $ field ) ; self :: transform_to_object ( $ field ) ; } return $ field [ 'value' ] ; }
|
Apply the transforms
|
13,884
|
public static function transform_image_fields ( & $ field ) { if ( empty ( $ field [ 'value' ] ) ) { return $ field [ 'value' ] ; } foreach ( $ field [ 'sub_fields' ] as $ sub_field ) { if ( 'image' === $ sub_field [ 'type' ] && 'id' === $ sub_field [ 'return_format' ] ) { foreach ( $ field [ 'value' ] as $ id => $ item ) { $ field [ 'value' ] [ $ id ] [ $ sub_field [ 'name' ] ] = Image :: get_image_fields ( $ field , $ item [ $ sub_field [ 'name' ] ] , $ sub_field [ 'name' ] ) ; } } } }
|
Do the image size transform for an image sub fields .
|
13,885
|
public static function transform_to_object ( & $ field ) { if ( 1 !== count ( $ field [ 'value' ] ) ) { return $ field [ 'value' ] ; } $ as_array = ! ( 1 === $ field [ 'min' ] && 1 === $ field [ 'max' ] ) ; $ as_array = apply_filters ( Filter :: REPEATER_AS_ARRAY , $ as_array , $ field ) ; $ field [ 'value' ] = $ as_array ? $ field [ 'value' ] : $ field [ 'value' ] [ 0 ] ; }
|
Transform to an object if the filter is set and there is only 1 item .
|
13,886
|
private function listOfKnownCpuArchitectures ( ) { $ arc = array_merge ( $ this -> listOfCpuArchitecturesX86 ( ) , $ this -> listOfCpuArchitecturesX64 ( ) ) ; ksort ( $ arc ) ; return $ arc ; }
|
Holds a list of Known CPU Srchitectures as array
|
13,887
|
public function quote ( $ value ) { if ( is_array ( $ value ) ) { $ result = [ ] ; foreach ( $ value as $ single ) { $ result [ ] = $ this -> quote ( $ single ) ; } return sprintf ( '(%s)' , implode ( ', ' , $ result ) ) ; } else { return $ this -> pdo -> quote ( $ value ) ; } }
|
Quote a value for use in a query .
|
13,888
|
public function setLoaders ( array $ loaders ) { $ this -> loaders = array ( ) ; foreach ( $ loaders as $ type => $ loader ) { if ( ! $ loader instanceof ResourceLoaderInterface ) { throw new \ InvalidArgumentException ( "Not a valid resource loader." ) ; } $ this -> loaders [ $ type ] = $ loader ; } }
|
sets the list of available resource loaders
|
13,889
|
protected function getLoader ( $ type ) { if ( ! isset ( $ this -> loaders [ $ type ] ) ) { throw new \ InvalidArgumentException ( "No loader defined for type '${type}'." ) ; } return $ this -> loaders [ $ type ] ; }
|
Get the resource loader for a given type
|
13,890
|
protected function getResourceType ( $ name ) { if ( ! isset ( $ this -> types [ $ name ] ) ) { $ template = $ this -> parser -> parse ( $ name ) ; if ( $ template instanceof TemplateReferenceInterface ) { $ this -> types [ $ name ] = $ template -> get ( 'engine' ) ; } } if ( ! isset ( $ this -> types [ $ name ] ) ) { throw new \ RuntimeException ( "Could not load the given resource." ) ; } return $ this -> types [ $ name ] ; }
|
Returns the type of a resource
|
13,891
|
private function registerGroupChange ( $ custId , $ groupIdOld , $ groupIdNew ) { $ data = new EChangeGroup ( ) ; $ data -> setCustomerRef ( $ custId ) ; $ data -> setGroupOld ( $ groupIdOld ) ; $ data -> setGroupNew ( $ groupIdNew ) ; $ dateChanged = $ this -> hlpDate -> getUtcNowForDb ( ) ; $ data -> setDateChanged ( $ dateChanged ) ; $ this -> daoChangeGroup -> create ( $ data ) ; }
|
Save group change event into registry .
|
13,892
|
protected function getSetters ( $ object ) { $ class = get_class ( $ object ) ; if ( array_key_exists ( $ class , $ this -> classMethodsCache ) === true ) { return $ this -> classMethodsCache [ $ class ] ; } $ regex = '/\[\s\<(?P<required>[^\>]+)\>\s' . '(?:(?P<typehint_a>[^\s]+|(?P<typehint_b>[^\s]+)\sor\s(?P<typehint_c>[^\s]+))\s)?' . '(?P<variable>\$[^\s]+)\s(?:=\s(?P<default>[^\]]+)\s)?\]/' ; $ reflectionClass = new ReflectionClass ( $ object ) ; $ methods = $ reflectionClass -> getMethods ( ReflectionMethod :: IS_PUBLIC ) ; $ setters = new Collection \ Method ( ) ; foreach ( $ methods as $ method ) { if ( substr ( $ method -> getName ( ) , 0 , 3 ) !== 'set' ) { continue ; } $ parameters = $ method -> getParameters ( ) ; $ parameter = $ parameters [ 0 ] ; $ raw = ( string ) $ parameter ; if ( ( $ result = preg_match ( $ regex , $ raw , $ matches ) ) === false || $ result === 0 ) { continue ; } $ required = ( $ matches [ 'required' ] === 'required' ) ; $ variable = $ matches [ 'variable' ] ; $ default = $ required ? null : $ matches [ 'default' ] ; $ typehint = null ; if ( empty ( $ matches [ 'typehint_b' ] ) === false ) { $ typehint = $ matches [ 'typehint_b' ] ; } else if ( empty ( $ matches [ 'typehint_a' ] ) === false ) { $ typehint = $ matches [ 'typehint_a' ] ; } switch ( $ default ) { case null : case 'NULL' : $ default = null ; break ; case 'Array' : $ default = array ( ) ; break ; default : $ default = trim ( $ default , "'" ) ; break ; } $ childObject = ( $ typehint !== null && $ typehint !== 'array' ) ; $ setters -> offsetSet ( $ method -> getName ( ) , new Entity \ Method ( $ required , $ default , $ typehint , $ childObject ) ) ; } return $ this -> classMethodsCache [ $ class ] = $ setters ; }
|
Get the setters of an object
|
13,893
|
public function setSupportedMediaTypes ( array $ mediaTypes ) { foreach ( $ mediaTypes as $ mediaType => $ converterClass ) { if ( ! is_string ( $ mediaType ) ) { throw new Exception ( 'Media type must be a string.' ) ; } if ( ! is_string ( $ converterClass ) ) { throw new Exception ( 'Converter class name must be a string.' ) ; } } $ this -> supportedMediaTypes = $ mediaTypes ; }
|
Sets the list of supported media types for negotiation .
|
13,894
|
public function negotiate ( $ content , MediaTypeList $ mediaTypeList ) { $ contentType = $ mediaTypeList -> getBestMatch ( array_keys ( $ this -> supportedMediaTypes ) ) ; if ( ! $ contentType ) { throw new Exception ( 'A suitable Content-Type could not be found.' ) ; } $ result = new NegotiatedResult ( ) ; $ result -> contentType = $ contentType ; $ result -> content = $ this -> encode ( $ content , $ contentType ) ; return $ result ; }
|
Negotiates content based on a set of input criteria .
|
13,895
|
private function loadFromExtensions ( array $ content ) { foreach ( $ content as $ namespace => $ values ) { if ( in_array ( $ namespace , array ( 'imports' , 'parameters' , 'services' ) ) ) { continue ; } if ( ! is_array ( $ values ) && null !== $ values ) { $ values = array ( ) ; } $ this -> container -> loadFromExtension ( $ namespace , $ values ) ; } }
|
Loads from Extensions .
|
13,896
|
public function setUrl ( $ url ) { $ this -> url = $ url ; if ( $ this -> url && substr ( $ this -> url , - 1 ) !== '/' ) { $ this -> url .= '/' ; } return $ this ; }
|
Sets the request url .
|
13,897
|
public function add ( $ route , $ callable , $ type = 'any' ) { if ( $ route && substr ( $ route , - 1 ) !== '/' ) { $ route .= '/' ; } $ this -> routes [ strtolower ( $ type ) ] [ $ route ] = $ callable ; return $ this ; }
|
Adds a route to the router .
|
13,898
|
public function getMethodsByRoute ( $ route ) { if ( ! $ route ) { return [ ] ; } $ methods = [ ] ; foreach ( $ this -> routes as $ method => $ routes ) { foreach ( $ routes as $ availableRoute => $ callable ) { if ( $ availableRoute === $ route ) { $ methods [ ] = $ method ; continue 2 ; } $ regex = '/^' . str_replace ( '/' , '\/' , $ availableRoute ) . '/Uim' ; if ( preg_match ( $ regex , $ route , $ matches ) === 1 && $ matches [ 0 ] === $ route ) { $ methods [ ] = $ method ; continue 2 ; } } } return $ methods ; }
|
Returns an array of methods defined for a specific route . Useful for an OPTIONS request .
|
13,899
|
public function execute ( ) { if ( ! $ this -> url || trim ( $ this -> url ) == '' ) { $ this -> url = '/' ; } if ( substr ( $ this -> url , 0 , 1 ) !== '/' ) { $ this -> url = '/' . $ this -> url ; } if ( isset ( $ this -> routes [ $ this -> method ] [ $ this -> url ] ) ) { return call_user_func_array ( $ this -> routes [ $ this -> method ] [ $ this -> url ] , [ ] ) ; } if ( isset ( $ this -> routes [ 'any' ] [ $ this -> url ] ) ) { return call_user_func_array ( $ this -> routes [ 'any' ] [ $ this -> url ] , [ ] ) ; } $ methods = [ $ this -> method , 'any' ] ; foreach ( $ methods as $ method ) { foreach ( $ this -> routes [ $ method ] as $ route => $ callable ) { $ regex = '/^' . str_replace ( '/' , '\/' , $ route ) . '/Uim' ; $ matches = [ ] ; if ( preg_match ( $ regex , $ this -> url , $ matches ) === 1 && $ matches [ 0 ] === $ this -> url ) { array_shift ( $ matches ) ; return call_user_func_array ( $ callable , $ matches ) ; } } } if ( ! isset ( $ this -> routes [ 'any' ] [ '/' ] ) ) { header ( 'HTTP/1.1 404 Not Found' ) ; exit ; } return call_user_func_array ( $ this -> routes [ 'any' ] [ '/' ] , [ ] ) ; }
|
Executes the router based on the url .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.