idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
48,800
private function getSaveToBody ( RequestInterface $ request , StreamInterface $ stream ) { if ( $ saveTo = $ request -> getConfig ( ) [ 'save_to' ] ) { $ saveTo = is_string ( $ saveTo ) ? new Stream ( Utils :: open ( $ saveTo , 'r+' ) ) : Stream :: factory ( $ saveTo ) ; } else { $ saveTo = Stream :: factory ( ) ; } Ut...
Drain the stream into the destination stream
48,801
private function createStream ( RequestInterface $ request , & $ http_response_header ) { static $ methods ; if ( ! $ methods ) { $ methods = array_flip ( get_class_methods ( __CLASS__ ) ) ; } $ params = [ ] ; $ options = $ this -> getDefaultOptions ( $ request ) ; foreach ( $ request -> getConfig ( ) -> toArray ( ) as...
Create the stream for the request with the context options .
48,802
public function openDir ( ) { if ( ! $ this -> isDir ( ) ) { throw new IOException ( "Not a directory" ) ; } $ dirconv = DirectoryConverter :: fromPath ( $ this ) ; $ dirconv -> setRoot ( $ this -> getRootDirectory ( ) ) ; $ type = $ this -> getDirectoryType ( ) ; return new $ type ( $ dirconv ) ; }
Open new Directory instance
48,803
public function get ( $ request , $ match , $ p ) { $ backend = parent :: getObject ( $ request , $ match , $ p ) ; if ( $ backend -> tenant !== Tenant_Shortcuts_GetMainTenant ( ) -> id ) { throw new Pluf_HTTP_Error404 ( "Object not found (" . $ p [ 'model' ] . "," . $ backend -> id . ")" ) ; } return $ backend ; }
Returns bank - backend determined by given id . This method returns backend if and only if backend with given id blongs to main tenant else it throws not found exception
48,804
public function set ( string $ key , $ value ) : Option { $ option = $ this -> repository -> find ( $ key ) ; return $ option -> setValue ( $ value ) ; }
Set the value for a specific key .
48,805
protected function containerName ( $ container = null ) { if ( $ container !== null ) { return $ container ; } $ pos = strrpos ( $ this -> entity , '\\' ) ; if ( $ pos === false ) { return $ this -> entity ; } return substr ( $ this -> entity , strrpos ( $ this -> entity , '\\' ) + 1 ) ; }
Returns container name or builds it from namespaced class name if passed name is empty string
48,806
protected function assignKeys ( array $ keys , array & $ container ) { foreach ( $ keys as $ local => $ foreign ) { $ this -> assertField ( $ local ) ; $ this -> assertField ( $ foreign ) ; $ container [ $ local ] = $ foreign ; } }
Assigns key pairs to passed container
48,807
protected function assertTroughKeys ( $ inKeys , $ outKeys ) { if ( empty ( $ inKeys ) || empty ( $ outKeys ) ) { throw new DefinitionException ( sprintf ( 'Invalid keys for relation "%s", must be two arrays with key-value pairs' , $ this -> entity , count ( $ inKeys ) ) ) ; } if ( count ( $ inKeys ) !== count ( $ outK...
Asserts trough keys must be same number in both arrays
48,808
protected function assertField ( $ field ) { if ( empty ( $ field ) ) { throw new DefinitionException ( sprintf ( 'Invalid field name for relation "%s.%s" can not be empty' , $ this -> entity , $ field ) ) ; } if ( is_numeric ( $ field ) ) { throw new DefinitionException ( sprintf ( 'Invalid field name for relation "%s...
Asserts field name
48,809
public function disableSubmit ( array & $ form , FormStateInterface $ form_state ) { $ types = array ( ) ; foreach ( $ form_state -> getValue ( 'types' ) as $ type => $ selected ) { if ( $ type === $ selected ) { $ types [ ] = $ type ; } } if ( empty ( $ types ) ) { drupal_set_message ( $ this -> t ( "Nothing to do" ) ...
Notification types admin form disable selected submit handler
48,810
public function find ( $ key , $ disableLateLoading = null ) { if ( ! is_bool ( $ disableLateLoading ) ) { $ disableLateLoading = false ; } if ( is_null ( $ key ) or ! is_scalar ( $ key ) or strlen ( trim ( $ key ) ) === 0 ) { return null ; } $ class = $ this -> entityClass ; try { return $ this -> entityFactory ( $ ke...
Lookup a entity based on it s primary key or key column This will either return null or a Entity
48,811
private function entityFactory ( ) { $ entity = $ this -> reflEntityClass -> newInstanceWithoutConstructor ( ) ; if ( $ this -> reflEntityManagerPropertyOfEntity ) { $ this -> reflEntityManagerPropertyOfEntity -> setValue ( $ entity , $ this -> entityManager ) ; } call_user_func_array ( [ $ entity , '__construct' ] , f...
Temp helper method which actually does the instantiation work and ensure our Entity has a link to the EntityManager
48,812
public function make ( array $ data = null ) { if ( ! $ this -> makeableSafetyCheck ( ) ) { return null ; } $ entity = $ this -> entityFactory ( ) ; if ( $ data !== null ) { $ entity -> set ( $ data , null , $ entity -> inputValidate ) ; } return $ entity ; }
Returns a new entity of the correct type .
48,813
protected function makeableSafetyCheck ( ) { switch ( $ this -> makeable ) { case self :: MAKEABLE_DISABLE : return false ; case self :: MAKEABLE_EXCEPTION : throw new EntityNotMakeableException ( "Making objects of this type is restricted. Are you using a view or some other derived data." ) ; } return true ; }
Check to see if a repository is makeable
48,814
public function hasReference ( $ reference , & $ referenceDetail = null ) { $ referenceDetail = null ; foreach ( $ this -> __get ( 'references' ) as $ name => $ detail ) { if ( $ name == $ reference or $ detail [ 0 ] == $ reference ) { $ referenceDetail = $ detail ; return $ name ; } } return null ; }
Check if Entity has link
48,815
public function referencesGet ( $ entityOrContainer , $ reference , $ source = null ) { if ( ! ( $ entityOrContainer instanceof Base || $ entityOrContainer instanceof Container ) ) { throw new \ InvalidArgumentException ( "You can only lookup references by Entity or Container" ) ; } if ( ! $ this -> hasReference ( $ re...
Get all references
48,816
public function hasLink ( $ link , & $ linkDetail = null ) { $ links = $ this -> __get ( 'links' ) ; if ( isset ( $ links [ $ link ] ) ) { $ linkDetail = $ links [ $ link ] ; return $ link ; } foreach ( $ links as $ via => $ linkDetail ) { if ( in_array ( $ link , $ linkDetail -> foreignEntities ) ) { return $ via ; } ...
Check if Entity has a named link
48,817
public function findByApiKey ( $ value ) { $ apiOptions = $ this -> __get ( 'apiOptions' ) ; if ( ! isset ( $ apiOptions [ 'findByKey' ] ) ) { return $ this -> find ( $ value , true ) ; } $ property = $ apiOptions [ 'findByKey' ] ; $ filter = $ this -> getFindFilterFactory ( ) -> get ( $ property , null , $ value ) ; r...
Look up a entity based on it s api key
48,818
private function getFindFilterFactory ( $ source = 0 ) { $ propertyMappers = [ PropertyMapperEntityData :: class ] ; if ( $ source & Base :: INITIAL ) { $ propertyMappers [ ] = [ PropertyMapperEntityInitial :: class ] ; } return new FindFilterComponentFactory ( $ propertyMappers ) ; }
Instantiate a appropriate FindFilterFactory
48,819
protected function findByFilterComponentsSourceSetup ( $ source ) { if ( ! ( $ source & ( self :: PERSISTED | self :: UNPERSISTED ) ) ) { $ source += self :: PERSISTED + self :: UNPERSISTED ; } if ( ! ( $ source & ( self :: CHANGED | self :: UNCHANGED ) ) ) { $ source += self :: CHANGED + self :: UNCHANGED ; } if ( ! (...
Set source defaults . Helper method of findByFilterComponents
48,820
public function findByFilterComponentsFormatReturnValue ( $ qty , Container $ output ) { if ( $ qty === FindFilterComponentFactory :: FIND_ALL ) { return $ output ; } switch ( $ count = count ( $ output ) ) { case 0 : return null ; case 1 : return $ output -> pop ( ) ; } throw new IncompatibleQtyException ( "{$count} e...
Format the return value of a findByFilterComponents query
48,821
protected function findByFilterComponentsDatabase ( array $ filterComponents , $ source ) { $ query = $ this -> buildQuery ( $ this -> db , $ filterComponents ) ; $ result = $ this -> db -> query ( $ query ) -> fetch ( Result :: FLATTEN_PREVENT ) ; $ isChangedFilterCallback = $ this -> getFilterByIsChangedCallback ( $ ...
Find a entity having been passed the filters .
48,822
protected function buildQuery ( QuoteInterface $ db , $ filterComponents ) { $ filterTags = array ( ) ; $ dataTypes = $ this -> dataTypesGet ( ) ; if ( $ dataTypesMissing = array_diff ( array_keys ( $ filterComponents ) , array_keys ( $ dataTypes ) ) ) { throw new \ LogicException ( sprintf ( "The following keys `%s` d...
Build a Query object
48,823
public function dataTypesGet ( $ filter = null ) { if ( func_num_args ( ) > 1 and \ Bond \ array_check ( 'is_string' , func_get_args ( ) ) ) { $ filter = func_get_args ( ) ; } if ( is_int ( $ filter ) ) { $ dataTypes = array ( ) ; if ( $ filter & DataType :: PRIMARY_KEYS ) { $ dataTypes += array_filter ( $ this -> data...
Helper function . Get dataTypes for this Entity .
48,824
public function getFilterByIsChangedCallback ( $ source ) { $ changed = ! ( $ source & self :: CHANGED ) ; $ unchanged = ! ( $ source & self :: UNCHANGED ) ; if ( $ changed and $ unchanged ) { return function ( ) { return false ; } ; } if ( ! $ changed and ! $ unchanged ) { return function ( ) { return true ; } ; } ret...
Filter entities by their changed status .
48,825
protected function makeNewContainer ( ) { $ container = new Container ( ) ; $ container -> classSet ( $ this -> entityClass ) ; $ container -> setPropertyMapper ( PropertyMapperEntityData :: class ) ; return $ container ; }
Get a new Container
48,826
public function actionCreate ( ) { $ model = new Role ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'view' , 'id' => $ model -> name ] ) ; } else { return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; } }
Creates a new Role model . If creation is successful the browser will be redirected to the view page .
48,827
protected function findModel ( $ id ) { if ( ( $ model = Role :: findByName ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( Yii :: t ( 'maddoger/user' , 'The requested role does not exist.' ) ) ; } }
Finds the Role model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
48,828
public function flush ( $ tag ) { $ args = func_get_args ( ) ; foreach ( $ args as $ item ) { if ( in_array ( $ item , $ this -> sequence ) ) { $ this -> $ item = [ ] ; } } return $ this ; }
MAKE LIKE SELECT TO EMPTY ARRAY!
48,829
public function getBindings ( ) { $ keys = func_num_args ( ) < 1 ? array_keys ( $ this -> bindings ) : func_get_args ( ) ; $ args = [ ] ; foreach ( $ keys as $ item ) { if ( ! array_key_exists ( $ item , $ this -> bindings ) ) { continue ; } $ args = array_merge ( $ args , $ this -> bindings [ $ item ] ) ; } return $ a...
Get the current query value bindings in a flattened array .
48,830
public function setLogo ( $ logo = null ) { if ( is_array ( $ logo ) ) { $ logo = null ; } $ this -> logo = $ logo ; return $ this ; }
Set logo .
48,831
public function compose ( Section $ section = null ) : Result { $ this -> container -> set ( 'section' , $ section ) ; if ( null !== $ section ) { $ this -> initParams ( ) ; $ this -> setParams ( $ section -> params ) ; $ this -> container -> set ( 'params' , $ this -> params ) ; } $ this -> setData ( $ section ) ; ret...
Main controller method compose all content .
48,832
protected function initParams ( ) : void { if ( 0 != count ( $ this -> params ) ) { return ; } $ this -> addParams ( [ Parameter :: makeBool ( 'isRoot' , '' , 'none' , false , true ) , Parameter :: makeBool ( 'isRss' , 'rss' , 'path' , false , false ) , Parameter :: makeInt ( 'itemId' , '' , 'path' , false , 0 ) , Para...
Initialization of structures of module parameters with default values .
48,833
protected function setDataFromModel ( ModelInterface $ model ) : void { $ this -> container -> set ( 'model' , $ model ) ; foreach ( get_class_methods ( $ model ) as $ method ) { if ( 0 !== strpos ( $ method , 'get' ) ) { continue ; } $ this -> data [ strtolower ( substr ( $ method , 3 ) ) ] = $ model -> $ method ( ) ;...
This implementation calls all methods with prefix get from model . Implementation may be overridden in inherited method to call only necessary model methods dependently from parameters .
48,834
public function composeWidgets ( array $ widgetsData ) : array { $ container = clone $ this -> container ; unset ( $ container -> widget ) ; unset ( $ container -> widgets ) ; unset ( $ container -> model ) ; $ widgetsResults = [ ] ; foreach ( $ widgetsData as $ place => $ placeWidgets ) { $ results = [ ] ; foreach ( $...
Create object for each widgets data item .
48,835
protected function setProperty ( $ name , $ value ) { $ this -> properties [ str_replace ( ' ' , '' , ltrim ( ucwords ( preg_replace ( '/[^A-Z^a-z^0-9]+/' , ' ' , 'z' . $ name ) ) , 'Z' ) ) ] = $ value ; $ this -> properties [ str_replace ( ' ' , '' , ucwords ( preg_replace ( '/[^A-Z^a-z^0-9]+/' , ' ' , $ name ) ) ) ] ...
Sets a property on this container .
48,836
public function getPages ( $ cursor = false ) { $ queryArray = [ 'pageSize' => 200 ] ; if ( $ cursor ) { $ queryArray [ 'cursor' ] = $ cursor ; } try { $ response = $ this -> client -> get ( $ this -> PagesUrl , [ 'headers' => [ 'Authorization' => 'Bearer ' . $ this -> login -> apiKey ] , 'verify' => $ this -> certFile...
Base function get call get users pages
48,837
public function getAllUserPages ( $ returnResponse = array ( ) , $ cursor = false ) { if ( empty ( $ this -> login -> apiKey ) ) { $ this -> login -> getApiKey ( ) ; } $ response = $ this -> getPages ( $ cursor ) ; $ response = json_decode ( $ response [ 'response' ] , true ) ; if ( empty ( $ returnResponse ) && empty ...
Recursive function to get all of a users pages
48,838
public function stripB3NonPublished ( $ pages ) { foreach ( $ pages [ '_items' ] as $ index => $ page ) { if ( $ page [ 'isBuilderThreePage' ] && ! $ page [ 'isBuilderThreePublished' ] ) { unset ( $ pages [ '_items' ] [ $ index ] ) ; } } return $ pages ; }
Remove non published B3 pages
48,839
public function sortPages ( $ pages ) { usort ( $ pages [ '_items' ] , function ( $ a , $ b ) { return strcmp ( strtolower ( $ a [ "name" ] ) , strtolower ( $ b [ "name" ] ) ) ; } ) ; return $ pages ; }
sort pages in alphabetical user
48,840
public function getSinglePageDownloadUrl ( $ pageId ) { try { $ response = $ this -> client -> get ( $ this -> PagesUrl . '/' . $ pageId , [ 'headers' => [ 'Authorization' => 'Bearer ' . $ this -> login -> apiKey ] , 'verify' => $ this -> certFile , ] ) ; $ body = json_decode ( $ response -> getBody ( ) , true ) ; $ ur...
Get the url to download the page url from
48,841
public function downloadPageHtml ( $ pageId , $ isRetry = false ) { if ( is_null ( $ this -> login -> apiKey ) ) { $ this -> login -> apiKey = $ this -> login -> getApiKey ( ) ; } $ response = $ this -> getSinglePageDownloadUrl ( $ pageId ) ; if ( $ response [ 'error' ] ) { return $ response ; } $ responseArray = json_...
get url for page then use a get request to get the html for the page
48,842
public function connection ( $ name = 'default' ) { if ( ! isset ( $ this ) ) return self :: getInstance ( ) -> clients [ Config :: get ( "redis.$name" ) ] ; return $ this -> clients [ Config :: get ( "redis.$name" ) ] ; }
Get a specific Redis connection instance .
48,843
public function write ( $ output ) { $ resource = fopen ( 'php://temp' , 'r+' ) ; ! $ resource && $ resource = null ; $ stream = new Stream ( $ resource ) ; $ stream -> write ( ( string ) $ output ) ; $ this -> stream = $ stream ; return $ this ; }
Writes data directly to the stream .
48,844
public function simpleRendeArray ( ) { $ array = [ ] ; $ count = $ this -> paginator -> getCount ( ) ; $ url = $ this -> path ; $ current = $ this -> paginator -> getCurrentPage ( ) ; $ appends = $ this -> createAppendString ( $ this -> paginator -> getAppends ( ) ) ; $ fragments = $ this -> createFragmentsString ( $ t...
create pagination with only previous and next buttons
48,845
private function createBeforeButton ( $ current , $ url , $ class , $ fragments ) { if ( $ this -> isAvaibleCurrentPage ( $ current ) && $ current > 1 ) { $ page = $ current - 1 ; return $ this -> buildChieldString ( "&laquo;" , $ url , $ class , $ fragments , $ page ) ; } else { return false ; } }
build before button string
48,846
private function createAfterButton ( $ current , $ limit , $ url , $ class , $ fragments ) { if ( $ this -> isAvaibleCurrentPage ( $ current ) && $ current < $ limit ) { $ page = $ current - 1 ; return $ this -> buildChieldString ( "&laquo;" , $ url , $ class , $ fragments , $ page ) ; } else { return false ; } }
&raquo ; build next button string
48,847
private function buildChieldString ( $ page , $ url , $ pageName , $ fragments , $ i ) { settype ( $ page , 'string' ) ; $ add = $ this -> buildAddUrl ( $ url ) ; $ string = $ url . $ add . $ i . $ fragments ; return sprintf ( "<li><a href='%s' class='%s'>%s</a></li>" , $ string , $ pageName , $ page ) ; }
create chield string
48,848
protected function fetchSubTemplateName ( ) { if ( ! empty ( $ this -> subTemplate ) ) return ; $ className = get_called_class ( ) ; if ( mb_strpos ( $ className , 'Controllers' ) === false ) { $ this -> system -> log ( ) -> notice ( "Fully qualified Controller class name does not contain 'Controllers' so we can't auto...
Fetch sub template name
48,849
public function connection ( $ config = null , $ forceConnect = false ) { if ( $ this -> connection && ! $ forceConnect ) { return $ this -> connection ; } ! isset ( $ config ) || $ this -> config ( $ config ) ; $ ref = new \ ReflectionClass ( $ this -> getHandler ( ) ) ; try { $ this -> connection = $ ref -> newInstan...
Returns a PDO connection
48,850
public function closeTag ( $ compiler , $ expectedTag ) { if ( count ( $ compiler -> _tag_stack ) > 0 ) { list ( $ _openTag , $ _data ) = array_pop ( $ compiler -> _tag_stack ) ; if ( in_array ( $ _openTag , ( array ) $ expectedTag ) ) { if ( is_null ( $ _data ) ) { return $ _openTag ; } else { return $ _data ; } } $ c...
Pop closing tag
48,851
public function acquire ( $ expires ) { if ( $ expires <= 0 ) { return true ; } $ k = $ this -> getName ( ) ; $ this -> lock = $ this -> factory -> createLock ( $ k , $ expires ) ; return $ this -> lock -> acquire ( ) ; }
Attempts to acquire the global lock for this job .
48,852
public function splitFile ( $ dstDir , $ chunkSize = 2048 ) { $ dstDir = rtrim ( $ dstDir , DIRECTORY_SEPARATOR ) ; $ srcFile = fopen ( $ this -> filePath , 'r' ) ; $ totalSize = filesize ( $ this -> filePath ) ; $ chunksNo = ceil ( $ totalSize / $ chunkSize ) ; $ lastChunkSize = $ totalSize % $ chunkSize ; if ( $ last...
Split file into chunks and save it to destination .
48,853
public static function v4 ( ) { return bin2hex ( Yii :: $ app -> security -> generateRandomKey ( 4 ) ) . "-" . bin2hex ( Yii :: $ app -> security -> generateRandomKey ( 2 ) ) . "-" . dechex ( mt_rand ( 0 , 0x0fff ) | 0x4000 ) . "-" . dechex ( mt_rand ( 0 , 0x3fff ) | 0x8000 ) . "-" . bin2hex ( Yii :: $ app -> security ...
Creates an v4 UUID
48,854
public static function fromParts ( string $ scheme , string $ host , int $ port = null , string $ path = '/' , string $ queryString = null ) : self { return self :: fromString ( $ scheme . '://' . $ host . ( null === $ port ? '' : ':' . $ port ) . $ path . ( ( null !== $ queryString ) ? ( substr ( $ queryString , 0 , 1...
creates http uri from given uri parts
48,855
public static function castFrom ( $ value , string $ name = 'Uri' ) : self { if ( $ value instanceof self ) { return $ value ; } if ( is_string ( $ value ) ) { return self :: fromString ( $ value ) ; } throw new \ InvalidArgumentException ( $ name . ' must be a string containing a HTTP URI or an instance of ' . get_cla...
casts given value to an instance of HttpUri
48,856
private function isValidForRfc ( string $ rfc ) : bool { if ( $ this -> parsedUri -> hasUser ( ) && Http :: RFC_7230 === $ rfc ) { throw new MalformedUri ( 'The URI ' . $ this -> parsedUri -> asString ( ) . ' is not a valid HTTP URI according to ' . Http :: RFC_7230 . ': contains userinfo, but this is disallowed' ) ; }...
checks if uri is valid according to given rfc
48,857
public static function exists ( $ httpUri , callable $ checkWith = null ) : bool { if ( $ httpUri instanceof self ) { return $ httpUri -> hasDnsRecord ( $ checkWith ) ; } if ( empty ( $ httpUri ) || ! is_string ( $ httpUri ) ) { return false ; } try { return self :: fromString ( $ httpUri ) -> hasDnsRecord ( $ checkWit...
checks whether given http uri exists i . e . has a DNS entry
48,858
public static function isValid ( $ httpUri ) : bool { if ( $ httpUri instanceof self ) { return true ; } if ( empty ( $ httpUri ) || ! is_string ( $ httpUri ) ) { return false ; } try { self :: fromString ( $ httpUri ) ; } catch ( MalformedUri $ murle ) { return false ; } return true ; }
checks whether given http uri is syntactically valid
48,859
protected function isSyntacticallyValid ( ) : bool { if ( ! parent :: isSyntacticallyValid ( ) ) { return false ; } if ( ! $ this -> parsedUri -> schemeEquals ( Http :: SCHEME ) && ! $ this -> parsedUri -> schemeEquals ( Http :: SCHEME_SSL ) ) { return false ; } return true ; }
Checks whether URI is a correct URI .
48,860
public function hasDnsRecord ( callable $ checkWith = null ) : bool { $ checkdnsrr = null === $ checkWith ? 'checkdnsrr' : $ checkWith ; if ( $ this -> parsedUri -> isLocalHost ( ) || $ checkdnsrr ( $ this -> parsedUri -> hostname ( ) , 'A' ) || $ checkdnsrr ( $ this -> parsedUri -> hostname ( ) , 'AAAA' ) || $ checkdn...
checks whether host of uri is listed in dns
48,861
public function hasDefaultPort ( ) : bool { if ( ! $ this -> parsedUri -> hasPort ( ) ) { return true ; } if ( $ this -> isHttp ( ) && $ this -> parsedUri -> portEquals ( Http :: PORT ) ) { return true ; } if ( $ this -> isHttps ( ) && $ this -> parsedUri -> portEquals ( Http :: PORT_SSL ) ) { return true ; } return fa...
checks whether the uri uses a default port or not
48,862
public function toHttp ( int $ port = null ) : self { if ( $ this -> isHttp ( ) ) { if ( null !== $ port && ! $ this -> parsedUri -> portEquals ( $ port ) ) { return new ConstructedHttpUri ( $ this -> parsedUri -> transpose ( [ 'port' => $ port ] ) ) ; } return $ this ; } $ changes = [ 'scheme' => Http :: SCHEME ] ; if...
transposes uri to http
48,863
public function toHttps ( int $ port = null ) : self { if ( $ this -> isHttps ( ) ) { if ( null !== $ port && ! $ this -> parsedUri -> portEquals ( $ port ) ) { return new ConstructedHttpUri ( $ this -> parsedUri -> transpose ( [ 'port' => $ port ] ) ) ; } return $ this ; } $ changes = [ 'scheme' => Http :: SCHEME_SSL ...
transposes uri to https
48,864
public function createSocket ( ) : Socket { return new Socket ( $ this -> hostname ( ) , $ this -> port ( ) , ( ( $ this -> isHttps ( ) ) ? ( 'ssl://' ) : ( null ) ) ) ; }
creates a socket to this uri
48,865
public function openSocket ( int $ timeout = 5 , callable $ openWith = null ) : Stream { $ socket = $ this -> createSocket ( ) ; if ( null !== $ openWith ) { $ socket -> openWith ( $ openWith ) ; } return $ socket -> connect ( ) -> setTimeout ( $ timeout ) ; }
opens socket to this uri
48,866
private function register ( $ socialUser ) { $ names = explode ( ' ' , $ socialUser -> getName ( ) ) ; $ username = is_null ( $ socialUser -> getNickname ( ) ) ? $ socialUser -> getEmail ( ) : $ socialUser -> getNickname ( ) ; $ userDetails = [ 'username' => $ username , 'email' => $ socialUser -> getEmail ( ) , 'first...
Create a new user from a social user .
48,867
public function eof ( ) { if ( ! $ this -> hasRead ) { $ this -> mark ( ) ; $ ret = fgetc ( $ this -> handle ) ; if ( $ ret === false ) return true ; $ this -> reset ( ) ; } return feof ( $ this -> handle ) ; }
Returns true if the end of the stream has been reached .
48,868
public function TopMost ( ) { $ sql = Access :: SqlBuilder ( ) ; $ tblParams = PageUrlParameter :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tblParams -> Field ( 'PageUrl' ) , $ sql -> Value ( $ this -> pageUrl -> GetID ( ) ) ) -> And_ ( $ sql -> IsNull ( $ tblParams -> Field ( 'Previous' ) ) ) ; return P...
Gets the first page url parameter
48,869
public static function init ( array $ attributes = array ( ) ) { self :: $ table_attributes = array ( ) ; self :: $ rows = array ( ) ; self :: $ row_data = array ( ) ; self :: $ headers = array ( ) ; self :: $ footers = array ( ) ; self :: setAttributes ( $ attributes ) ; }
Sets up a new table
48,870
public static function setHeaders ( array $ data , array $ attributes = array ( ) ) { foreach ( $ data as $ header ) { self :: addHeader ( $ header , $ attributes ) ; } }
Sets header data
48,871
public static function setFooters ( array $ data , array $ attributes = array ( ) ) { foreach ( $ data as $ footer ) { self :: addFooter ( $ footer , $ attributes ) ; } }
Sets footer data
48,872
public static function newRow ( array $ attrs = array ( ) ) { if ( ! empty ( self :: $ row_data ) ) self :: $ rows [ count ( self :: $ rows ) - 1 ] [ ] = self :: $ row_data ; self :: $ row_data = array ( ) ; self :: $ rows [ ] [ ] = $ attrs ; return count ( self :: $ rows ) ; }
Signals beginning of a new row
48,873
public static function render ( ) { self :: newRow ( ) ; ob_start ( ) ; ?> <table <?php echo ( ! empty ( self :: $ table_attributes ) ) ? self :: parseAttributes ( self :: $ table_attributes ) : "" ; ?> > <?php if ( ! empty ( self :: $ headers ) ) { ?> <thead> <tr> ...
Renders the HTML Table
48,874
public function getTransformer ( string $ target_class ) { if ( isset ( $ this -> transformers [ $ target_class ] ) ) return $ this -> transformers [ $ target_class ] ; foreach ( $ this -> transformers as $ class => $ transformer ) { $ inherit_mode = $ transformer -> getInheritMode ( ) ; if ( ( $ inherit_mode === Trans...
Get a transformer that converts to the target class . If a direct version is available that is returned . Otherwise a transformer registered to transform to a superclass of the target may be returned instead .
48,875
public function flush ( ) { if ( $ this -> stream === NULL ) { throw new \ RuntimeException ( sprintf ( 'Cannot flush detached stream' ) ) ; } if ( strlen ( $ this -> buffer ) ) { $ this -> stream -> write ( sprintf ( "%X\r\n%s\r\n" , strlen ( $ this -> buffer ) , $ this -> buffer ) ) ; $ this -> buffer = '' ; } }
Flush the current write buffer to the underlying output stream .
48,876
public function AddSchema ( $ schema ) { if ( is_null ( $ schema ) ) throw new \ lyquidity \ xml \ exceptions \ ArgumentNullException ( ) ; if ( ! $ schema instanceof XmlSchema ) throw new XmlSchemaException ( "The parameter is not a valid XmlSchema instance" ) ; $ this -> schemas [ $ schema -> getTargetNamespace ( ) ]...
Adds the given XmlSchema to the XmlSchemaSet .
48,877
public function set ( $ key , $ value ) { if ( ! is_null ( $ key ) && is_scalar ( $ key ) ) { return $ this -> _items [ $ key ] = $ value ; } else { throw new EnumeratorException ( 'Element could not be added to list. Index is not valid.' , E_NOTICE ) ; } }
add or replace a value with a specified key
48,878
public function getAssociations ( $ post_id = null ) { $ oConfig = Factory :: service ( 'Config' ) ; $ oDb = Factory :: service ( 'Database' ) ; $ _associations = $ oConfig -> item ( 'blog_post_associations' ) ; if ( ! $ _associations ) { return array ( ) ; } foreach ( $ _associations as & $ assoc ) { if ( $ post_id ) ...
Fetch all the associations for a particular post
48,879
public function getBlogUrl ( $ blogId ) { if ( isset ( $ this -> blogUrl [ $ blogId ] ) ) { return $ this -> blogUrl [ $ blogId ] ; } else { $ url = appSetting ( 'url' , 'blog-' . $ blogId ) ; $ url = $ url ? $ url : 'blog/' ; $ url = site_url ( $ url ) ; $ this -> blogUrl [ $ blogId ] = $ url ; return $ this -> blogUr...
Get the URL of a blog
48,880
public function compare ( Table $ oldTable , Table $ newTable ) { $ createdColumns = $ this -> getCreatedColumns ( $ oldTable , $ newTable ) ; $ alteredColumns = $ this -> getAlteredColumns ( $ oldTable , $ newTable ) ; $ droppedColumns = $ this -> getDroppedColumns ( $ oldTable , $ newTable ) ; $ this -> detectRenamed...
Compares two tables .
48,881
public function comparePrimaryKeys ( PrimaryKey $ oldPrimaryKey , PrimaryKey $ newPrimaryKey ) { return ( $ oldPrimaryKey -> getName ( ) !== $ newPrimaryKey -> getName ( ) ) || ( $ oldPrimaryKey -> getColumnNames ( ) !== $ newPrimaryKey -> getColumnNames ( ) ) ; }
Compares two primary keys .
48,882
public function compareForeignKeys ( ForeignKey $ oldForeignKey , ForeignKey $ newForeignKey ) { return ( $ oldForeignKey -> getName ( ) !== $ newForeignKey -> getName ( ) ) || ( $ oldForeignKey -> getLocalColumnNames ( ) !== $ newForeignKey -> getLocalColumnNames ( ) ) || ( $ oldForeignKey -> getForeignTableName ( ) !...
Compares two foreign keys .
48,883
public function compareIndexes ( Index $ oldIndex , Index $ newIndex ) { return ( $ oldIndex -> getName ( ) !== $ newIndex -> getName ( ) ) || ( $ oldIndex -> getColumnNames ( ) !== $ newIndex -> getColumnNames ( ) ) || ( $ oldIndex -> isUnique ( ) !== $ newIndex -> isUnique ( ) ) ; }
Compares two indexes .
48,884
public function compareChecks ( Check $ oldCheck , Check $ newCheck ) { return ( $ oldCheck -> getName ( ) !== $ newCheck -> getName ( ) ) || ( $ oldCheck -> getDefinition ( ) !== $ newCheck -> getDefinition ( ) ) ; }
Compares two checks .
48,885
private function detectRenamedColumns ( array & $ createdColumns , array & $ droppedColumns , array & $ alteredColumns ) { foreach ( $ createdColumns as $ createdIndex => $ createdColumn ) { foreach ( $ droppedColumns as $ droppedIndex => $ droppedColumn ) { $ columnDiff = $ this -> columnComparator -> compare ( $ drop...
Detects and rewrites renamed columns .
48,886
protected function parse ( ) { $ query = preg_replace ( '/OR\s+REPLACE/' , '' , $ this -> value ) ; if ( preg_match ( '/(CREATE|UPDATE|DELETE|ALTER|INSERT|DROP|SELECT|GRANT)\s+(SEQUENCE|INDEX|SYNONYM|TABLE|INTO|FROM|VIEW|)\s*([a-zA-Z-_]*)\s*/im' , $ query , $ matches ) ) { $ this -> type = trim ( strtolower ( $ matches...
Parse query Extract type & extra data
48,887
public function getMaxFileSize ( ) : int { if ( $ this -> maxFileSize === null ) { $ value = ini_get ( "upload_max_filesize" ) ; $ units = "BKMGT" ; $ unit = preg_replace ( "/[^$units]/i" , "" , $ value ) ; $ value = floatval ( $ value ) ; if ( $ unit ) { $ value *= pow ( 1024 , stripos ( $ units , $ unit [ 0 ] ) ) ; }...
Retrieve the upload_max_filesize ini setting
48,888
public function init ( $ config = NULL ) { $ option = new Option ( ) ; $ option -> shortCode = 'h' ; $ option -> longCode = 'help' ; $ option -> isOptional = TRUE ; $ option -> type = Type :: BOOLEAN ; $ option -> shortDescription = 'Show the help menu' ; $ this -> options [ ] = $ option ; $ option = new Option ( ) ; $...
This method adds the help and verbose options to the command .
48,889
public function removeOption ( $ longCode ) { $ retVal = FALSE ; $ i = 0 ; foreach ( $ this -> options as $ option ) { if ( $ longCode === $ option -> longCode ) { break ; } $ i ++ ; } if ( $ i !== count ( $ this -> options ) ) { unset ( $ this -> options [ $ i ] ) ; $ retVal = TRUE ; } return $ retVal ; }
Removes an option by its long code .
48,890
public static function getOption ( Command $ command , $ longCode ) { foreach ( $ command -> options as $ op ) { if ( '--' === substr ( $ longCode , 0 , 2 ) ) { $ longCode = substr ( $ longCode , 2 ) ; } elseif ( '-' === substr ( $ longCode , 0 , 1 ) ) { $ longCode = substr ( $ longCode , 1 ) ; } if ( $ op -> shortCode...
Gets an option either by short or long code .
48,891
public function getParentTemplateFilename ( ) { if ( empty ( $ this -> parentTemplateFilename ) ) { if ( preg_match ( $ this -> extendRex , $ this -> bufferInstance -> __rawContents , $ matches ) ) { $ this -> parentTemplateFilename = $ matches [ 1 ] ; } } return $ this -> parentTemplateFilename ; }
get filename of parent template
48,892
public function assign ( $ var , $ value = null ) { $ invalidProperties = [ '__rawContents' ] ; if ( is_array ( $ var ) ) { foreach ( $ var as $ k => $ v ) { if ( in_array ( $ k , $ invalidProperties ) ) { throw new SimpleTemplateException ( "Tried to assign invalid property '%s'" , $ k ) ; } $ this -> bufferInstance -...
assign value to variable which is then available within template
48,893
public function blockFilter ( $ filterId ) { if ( ! in_array ( $ filterId , $ this -> blockedFilters ) ) { $ this -> blockedFilters [ ] = $ filterId ; } return $ this ; }
block a pre - configured filter
48,894
public function display ( $ defaultFilters = null ) { $ this -> extend ( ) ; $ this -> fillBuffer ( ) ; if ( is_null ( $ defaultFilters ) ) { $ this -> defaultFilters = [ new AnchorHref ( ) , new ImageCache ( ) , ] ; if ( ! $ this -> ignoreLocales ) { $ this -> defaultFilters [ ] = new LocalizedPhrases ( ) ; } } else {...
output parsed template
48,895
private function extend ( ) { if ( preg_match ( $ this -> extendRex , $ this -> bufferInstance -> __rawContents , $ matches ) ) { $ blockRegExp = '~<!--\s*\{\s*block\s*:\s*' . $ matches [ 2 ] . '\s*\}\s* ; $ extendedContent = file_get_contents ( Application :: getInstance ( ) -> getRootPath ( ) . ( defined ( 'TPL_PATH'...
allow extension of a parent template with current template
48,896
private function applyFilters ( ) { foreach ( $ this -> defaultFilters as $ f ) { $ f -> apply ( $ this -> contents ) ; } foreach ( $ this -> filters as $ f ) { $ f -> apply ( $ this -> contents ) ; } }
applies all stacked filters to template before output
48,897
private function fillBuffer ( ) { $ closure = function ( $ outer ) { ob_start ( ) ; $ tpl = $ this ; eval ( '?>' . $ this -> __rawContents ) ; $ outer -> contents = ob_get_contents ( ) ; ob_end_clean ( ) ; } ; $ boundClosure = $ closure -> bindTo ( $ this -> bufferInstance ) ; $ boundClosure ( $ this ) ; }
fetches template file and evals content immediate output supressed by output buffering
48,898
public function collect ( Table $ table ) { foreach ( $ table -> getForeignKeys ( ) as $ foreignKey ) { $ this -> dropForeignKeyQueries = array_merge ( $ this -> dropForeignKeyQueries , $ this -> platform -> getDropForeignKeySQLQueries ( $ foreignKey , $ table -> getName ( ) ) ) ; } $ this -> dropTableQueries = array_m...
Collects queries to drop tables .
48,899
protected function parseURI ( $ uri , $ relative ) { $ result = array ( ) ; if ( ! $ relative ) { $ pos = strpos ( $ uri , ':' ) ; if ( ! $ pos ) { throw new \ InvalidArgumentException ( 'No scheme found' ) ; } $ result [ 'scheme' ] = substr ( $ uri , 0 , $ pos ) ; $ uri = ( string ) substr ( $ uri , $ pos + 1 ) ; } $ ...
Parses an URI using the grammar defined in RFC 3986 .