idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
29,100 | public function down ( array $ fixtures = array ( ) ) { if ( empty ( $ fixtures ) ) { $ fixtures = array_keys ( $ this -> fixtures ) ; } $ this -> driver -> truncate ( $ fixtures ) ; $ this -> fixtures = array_diff_key ( $ this -> fixtures , array_flip ( $ fixtures ) ) ; } | Destroy fixtures . |
29,101 | protected function loadFixtures ( array $ fixtures = null ) { foreach ( $ this -> fetchFixtures ( $ fixtures ) as $ fixture ) { $ this -> processFixture ( $ fixture ) ; } } | Load fixtures . |
29,102 | protected function fetchFixtures ( array $ fixtures = null ) { $ availableFixtures = glob ( "{$this->config['location']}/*.php" ) ; foreach ( $ availableFixtures as $ i => $ fixture ) { $ tableName = basename ( $ fixture , '.php' ) ; if ( $ fixtures && ! in_array ( $ tableName , $ fixtures ) ) { unset ( $ availableFixtures [ $ i ] ) ; } } return array_values ( $ availableFixtures ) ; } | Fetches fixture files names for all or only a subset of fixtures . |
29,103 | protected function processFixture ( $ fixture ) { $ tableName = basename ( $ fixture , '.php' ) ; $ records = include $ fixture ; if ( ! is_array ( $ records ) ) { throw new Exceptions \ InvalidFixtureDataException ( "Invalid fixture: $fixture, please ensure this file returns an array of data." , 1 ) ; } $ this -> fixtures [ $ tableName ] = $ this -> driver -> buildRecords ( $ tableName , $ records ) ; } | Process a fixture adding its data into the database . |
29,104 | public function format ( $ value , $ notation = null , $ country = null , $ encoding = null , $ symbolPosition = null ) { $ country = ( ! $ country ) ? $ this -> locale : $ country ; $ formatted = number_format ( $ value , $ this -> getConfiguration ( ) -> currency -> minor_unit , $ this -> getConfiguration ( ) -> currency -> decimal_point , $ this -> getConfiguration ( ) -> currency -> thousands_separator ) ; if ( ! $ symbolPosition ) { $ symbolPosition = $ this -> getConfiguration ( ) -> currency -> symbol_position ; } if ( $ notation !== null ) { $ country = ( $ country !== null ) ? $ country : $ this -> locale ; if ( $ country === null ) { throw new Doozr_I18n_Service_Exception ( sprintf ( 'Please pass $country to "%s".' , __METHOD__ ) ) ; } if ( $ notation === self :: NOTATION_SYMBOL ) { $ notation = $ this -> getConfiguration ( ) -> { $ country } -> major_symbol ; } else { $ notation = $ this -> getConfiguration ( ) -> { $ country } -> major_short ; } $ notationSpace = $ this -> getConfiguration ( ) -> currency -> notation_space ; if ( $ symbolPosition == 'l' ) { $ formatted = $ notation . $ notationSpace . $ formatted ; } else { $ formatted = $ formatted . $ notationSpace . $ notation ; } } return $ formatted ; } | This method is intend to format a given value as correct currency . |
29,105 | public function getCurrencyCode ( ) { try { return $ this -> getConfiguration ( ) -> currency -> code ; } catch ( Exception $ e ) { throw new Doozr_I18n_Service_Exception ( 'Error reading currency code from L10N configuration.' , null , $ e ) ; } } | This method is intend to return the currency - code for the current active locale . |
29,106 | protected function conditionalSet ( $ key , $ value ) { if ( ! $ this -> has ( $ key ) ) { $ this -> set ( $ key , $ value ) ; } } | Set a value in a container only if it is not defined already . |
29,107 | public function walk ( SpecificationInterface $ specification , $ query ) { foreach ( $ this -> visitors as $ visitor ) { if ( $ visitor -> supports ( $ specification ) ) { $ visitor -> visit ( $ specification , $ this , $ query ) ; } } } | Apply known specification visitors to the supplied specification to build the query |
29,108 | public static function create ( string $ name , int $ lifetime = 300 ) : string { $ token = sha1 ( microtime ( ) ) ; $ tokenData = [ 'token' => $ token , 'time' => time ( ) , 'lifetime' => $ lifetime ] ; Session :: set ( $ name , $ tokenData , self :: $ namespace ) ; return $ token ; } | Create token . |
29,109 | public static function get ( string $ name ) : ? string { $ data = Session :: get ( $ name , null , self :: $ namespace ) ; if ( is_array ( $ data ) && array_key_exists ( 'token' , $ data ) ) { return $ data [ 'token' ] ; } return null ; } | Get token . |
29,110 | public static function isValid ( string $ name , string $ token ) : bool { $ savedToken = Session :: get ( $ name , null , self :: $ namespace ) ; if ( isset ( $ savedToken [ 'token' ] ) ) { if ( time ( ) >= $ savedToken [ 'time' ] + $ savedToken [ 'lifetime' ] ) { $ savedToken [ 'token' ] = '' ; } return $ token === $ savedToken [ 'token' ] ; } return false ; } | Is token valid . |
29,111 | public static function fromConfig ( array $ config , string $ language ) : Translator { $ translations = ( new Processor ( ) ) -> processConfiguration ( new TranslatorConfiguration ( ) , [ $ config ] ) ; return new static ( $ translations , $ language ) ; } | Makes Translator instance from config |
29,112 | public function format ( & $ data ) { $ data = $ this -> normalize ( $ data ) ; $ data = $ this -> convertToString ( $ data ) ; return $ data ; } | Normalises the variable JSON encodes it if needed and cleans up the result |
29,113 | public function normalize ( $ data , $ depth = 0 ) { $ scalar = $ this -> normalizeScalar ( $ data ) ; if ( ! is_array ( $ scalar ) ) { return $ scalar ; } $ decisionArray = [ 'normalizeTraversable' => [ $ data , $ depth ] , 'normalizeDate' => [ $ data ] , 'normalizeObject' => [ $ data , $ depth ] , 'normalizeResource' => [ $ data ] , ] ; foreach ( $ decisionArray as $ functionName => $ arguments ) { $ dataType = call_user_func_array ( [ $ this , $ functionName ] , $ arguments ) ; if ( $ dataType !== null ) { return $ dataType ; } } return '[unknown(' . gettype ( $ data ) . ')]' ; } | Converts Objects Arrays Dates and Exceptions to a String or an Array |
29,114 | public function convertToString ( $ data ) { if ( ! is_string ( $ data ) ) { $ data = @ json_encode ( $ data , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ; $ data = str_replace ( [ '\\u0000' , '\\\\' ] , [ "" , "\\" ] , $ data ) ; } return $ data ; } | JSON encodes data which isn t already a string and cleans up the result |
29,115 | private function normalizeScalar ( $ data ) { if ( null === $ data || is_scalar ( $ data ) ) { if ( is_float ( $ data ) ) { $ data = $ this -> normalizeFloat ( $ data ) ; } return $ data ; } return [ ] ; } | Returns various filtered scalar elements |
29,116 | private function normalizeFloat ( $ data ) { if ( is_infinite ( $ data ) ) { $ postfix = 'INF' ; if ( $ data < 0 ) { $ postfix = '-' . $ postfix ; } $ data = $ postfix ; } else { if ( is_nan ( $ data ) ) { $ data = 'NaN' ; } } return $ data ; } | Normalises infinite and trigonometric floats |
29,117 | private function normalizeTraversable ( $ data , $ depth = 0 ) { if ( is_array ( $ data ) || $ data instanceof \ Traversable ) { return $ this -> normalizeTraversableElement ( $ data , $ depth ) ; } return null ; } | Returns an array containing normalized elements |
29,118 | private function normalizeTraversableElement ( $ data , $ depth ) { $ maxObjectRecursion = $ this -> maxRecursionDepth ; $ maxArrayItems = $ this -> maxArrayItems ; $ count = 1 ; $ normalized = [ ] ; $ nextDepth = $ depth + 1 ; foreach ( $ data as $ key => $ value ) { if ( $ count >= $ maxArrayItems ) { $ normalized [ '...' ] = 'Over ' . $ maxArrayItems . ' items, aborting normalization' ; break ; } $ count ++ ; if ( $ depth < $ maxObjectRecursion ) { $ normalized [ $ key ] = $ this -> normalize ( $ value , $ nextDepth ) ; } } return $ normalized ; } | Converts each element of a traversable variable to String |
29,119 | private function normalizeObject ( $ data , $ depth ) { if ( is_object ( $ data ) ) { if ( $ data instanceof \ Exception ) { return $ this -> normalizeException ( $ data ) ; } $ maxObjectRecursion = $ this -> maxRecursionDepth ; $ arrayObject = new \ ArrayObject ( $ data ) ; $ serializedObject = $ arrayObject -> getArrayCopy ( ) ; if ( $ depth < $ maxObjectRecursion ) { $ depth ++ ; $ response = $ this -> normalize ( $ serializedObject , $ depth ) ; return [ $ this -> getObjetName ( $ data ) => $ response ] ; } return $ this -> getObjetName ( $ data ) ; } return null ; } | Converts an Object to an Array |
29,120 | private function normalizeException ( \ Exception $ exception ) { $ data = [ 'class' => get_class ( $ exception ) , 'message' => $ exception -> getMessage ( ) , 'code' => $ exception -> getCode ( ) , 'file' => $ exception -> getFile ( ) . ':' . $ exception -> getLine ( ) , ] ; $ trace = $ exception -> getTraceAsString ( ) ; $ data [ 'trace' ] = $ trace ; $ previous = $ exception -> getPrevious ( ) ; if ( $ previous ) { $ data [ 'previous' ] = $ this -> normalizeException ( $ previous ) ; } return $ data ; } | Converts an Exception to String |
29,121 | public function addHook ( HookFactory $ hook ) : void { $ hook -> init ( ) ; $ this -> hooks [ $ hook -> name ] = $ hook ; } | Prida formular do nastaveni |
29,122 | public function getRealPath ( ) { if ( null === $ this -> asset || empty ( $ this -> asset ) ) { return null ; } return $ this -> normalizePath ( $ this -> realPath ( $ this -> realPath ) ) ; } | Returns the asset s full path |
29,123 | protected function setUp ( ) { if ( empty ( $ this -> asset ) ) { return ; } $ this -> asset = $ this -> normalizePath ( $ this -> asset ) ; $ this -> realPath = $ this -> locateResource ( ) ; if ( null === $ this -> realPath ) { $ this -> realPath = $ this -> asset ; } $ this -> absolutePath = $ this -> retrieveBundleWebFolder ( ) ; } | Sets up the asset information |
29,124 | protected function retrieveBundleWebFolder ( ) { $ asset = $ this -> asset ; $ namespacesFile = $ this -> kernel -> getRootDir ( ) . '/../vendor/composer/autoload_namespaces.php' ; if ( file_exists ( $ namespacesFile ) ) { $ map = require $ namespacesFile ; foreach ( $ map as $ namespace => $ paths ) { if ( ! is_array ( $ paths ) ) { $ paths = array ( $ paths ) ; } foreach ( $ paths as $ path ) { if ( strpos ( $ this -> asset , $ path ) !== false ) { preg_match ( '/Bundle(.*)/' , $ this -> asset , $ matches ) ; $ asset = str_replace ( "\\" , "" , $ namespace ) . $ matches [ 1 ] ; break ; } } } } preg_match ( '/([^@\/][\w]+Bundle)\/(Resources\/public)?\/(.*)/' , $ asset , $ matches ) ; if ( ! empty ( $ matches ) && count ( $ matches ) == 4 ) { return sprintf ( 'bundles/%s/%s' , preg_replace ( '/bundle$/' , '' , strtolower ( $ matches [ 1 ] ) ) , $ matches [ 3 ] ) ; } preg_match ( '/[\/]?(bundles.*)/' , strtolower ( $ asset ) , $ matches ) ; if ( ! empty ( $ matches ) ) { return $ matches [ 1 ] ; } $ asset = str_replace ( "@" , "" , strtolower ( $ asset ) ) ; $ bundleDir = preg_replace ( '/bundle$/' , '' , $ asset ) ; return ( $ bundleDir !== $ asset ) ? 'bundles/' . $ bundleDir : null ; } | Retrieves the web bundle folder from the current asset |
29,125 | protected function locateResource ( $ asset = null ) { if ( null === $ asset ) { $ asset = $ this -> asset ; } $ asset = $ this -> normalizePath ( $ asset ) ; if ( \ substr ( $ asset , 0 , 1 ) != '@' ) $ asset = '@' . $ asset ; try { preg_match ( '/(@[^\/]+)?([\w\/\.\-_]+)?/' , $ asset , $ match ) ; if ( empty ( $ match [ 1 ] ) ) { return ; } $ resource = $ this -> kernel -> locateResource ( $ match [ 1 ] ) ; $ resourceLength = strlen ( $ resource ) - 1 ; if ( substr ( $ resource , $ resourceLength , 1 ) == '/' ) $ resource = substr ( $ resource , 0 , $ resourceLength ) ; return ( isset ( $ match [ 2 ] ) ) ? $ resource . $ match [ 2 ] : $ resource ; } catch ( \ Exception $ e ) { return null ; } } | Locates a resource defined by a relative path |
29,126 | public static function has ( $ name , $ range = null ) { static :: _init ( ) ; $ range = $ range ? : self :: $ range ; $ exists = isset ( self :: $ data [ $ range ] [ $ name ] ) ? true : false ; if ( ! $ exists ) { $ names = explode ( '.' , $ name , 3 ) ; $ count = count ( $ names ) ; if ( $ count >= 1 ) { $ exists = array_key_exists ( $ names [ 0 ] , array_keys ( self :: $ data [ $ range ] ) ) ; if ( $ count >= 2 && $ exists ) { $ exists = isset ( self :: $ data [ $ range ] [ $ names [ 0 ] ] ) && array_key_exists ( $ names [ 1 ] , array_keys ( self :: $ data [ $ range ] [ $ names [ 0 ] ] ) ) ; } if ( $ count >= 3 && $ exists ) { $ exists = isset ( self :: $ data [ $ range ] [ $ names [ 0 ] ] [ $ names [ 1 ] ] ) && array_key_exists ( $ names [ 2 ] , array_keys ( self :: $ data [ $ range ] [ $ names [ 0 ] ] [ $ names [ 1 ] ] ) ) ; } } } return $ exists ; } | has some config |
29,127 | public static function get ( $ name = null , $ range = null , $ inherit = true ) { $ range = $ range ? : self :: $ range ; static :: autoload ( $ range ) ; $ value = null ; if ( empty ( $ name ) ) { $ value = isset ( self :: $ data [ $ range ] ) ? self :: $ data [ $ range ] : null ; } elseif ( isset ( self :: $ data [ $ range ] [ $ name ] ) ) { $ value = self :: $ data [ $ range ] [ $ name ] ; } elseif ( strpos ( $ name , '.' ) ) { $ names = explode ( '.' , $ name , 3 ) ; if ( count ( $ names ) > 2 ) { $ value = isset ( self :: $ data [ $ range ] [ $ names [ 0 ] ] [ $ names [ 1 ] ] [ $ names [ 2 ] ] ) ? self :: $ data [ $ range ] [ $ names [ 0 ] ] [ $ names [ 1 ] ] [ $ names [ 2 ] ] : null ; } else { $ value = isset ( self :: $ data [ $ range ] [ $ names [ 0 ] ] [ $ names [ 1 ] ] ) ? self :: $ data [ $ range ] [ $ names [ 0 ] ] [ $ names [ 1 ] ] : null ; } } if ( $ range !== self :: $ range && $ inherit ) { if ( $ value === null ) { $ value = self :: get ( $ name , self :: $ range , false ) ; } elseif ( is_array ( $ value ) ) { $ vd = self :: get ( $ name , self :: $ range , false ) ; $ value = ArrayHelper :: merge ( $ vd , $ value ) ; } } return $ value ; } | get config if no params it get all config |
29,128 | static public function getCommon ( $ name = null , $ default = null ) { $ value = self :: get ( $ name , self :: $ range ) ; return $ value === null ? $ default : $ value ; } | get only common range |
29,129 | public static function set ( $ name , $ value = null , $ range = null , $ overwrite = true ) { static :: _init ( ) ; $ range = $ range ? : self :: $ range ; if ( ! isset ( self :: $ data [ $ range ] ) ) { self :: $ data -> set ( $ range , [ ] ) ; } if ( ! $ name && is_array ( $ value ) ) { foreach ( $ value as $ k => $ v ) { self :: set ( $ k , $ v , $ range , $ overwrite ) ; } return self :: $ data [ $ range ] ; } elseif ( is_string ( $ name ) ) { $ old = static :: $ data -> get ( $ range ) ; if ( ! strpos ( $ name , '.' ) ) { $ temp = [ $ name => $ value ] ; if ( $ overwrite || ! isset ( $ old [ $ name ] ) ) { $ new = ArrayHelper :: merge ( $ old , $ temp ) ; static :: $ data -> set ( $ range , $ new ) ; } return self :: $ data [ $ range ] [ $ name ] ; } else { $ names = explode ( '.' , $ name , 2 ) ; $ temp = [ $ names [ 0 ] => [ $ names [ 1 ] => $ value ] ] ; if ( $ overwrite || ! isset ( $ old [ $ names [ 0 ] ] [ $ names [ 1 ] ] ) ) { $ new = ArrayHelper :: merge ( $ old , $ temp ) ; static :: $ data -> set ( $ range , $ new ) ; } return self :: $ data [ $ range ] [ $ names [ 0 ] ] [ $ names [ 1 ] ] ; } } elseif ( is_array ( $ name ) ) { if ( ! empty ( $ value ) && is_string ( $ value ) ) { return static :: set ( $ value , $ name , null , $ overwrite ) ; } else { foreach ( $ name as $ k => $ v ) { self :: set ( $ k , $ v , $ range , $ overwrite ) ; } return self :: $ data [ $ range ] ; } } else { return self :: $ data [ $ range ] ; } } | set config value |
29,130 | public static function setDefault ( $ name , $ value = null , $ range = null ) { return static :: set ( $ name , $ value , $ range , false ) ; } | set default value don t overwrite exists key |
29,131 | public static function reset ( $ range = null ) { static :: _init ( ) ; $ range = $ range ? : self :: $ range ; if ( true === $ range ) { self :: $ data -> clear ( ) ; } else { self :: $ data -> set ( $ range , [ ] ) ; } } | reset can clear all |
29,132 | static public function getUploadUrl ( $ isAbsolute = true ) { $ url = static :: getCommon ( 'uploadUrl' ) ; if ( $ isAbsolute && strpos ( $ url , 'http' ) !== 0 ) { $ baseUrl = static :: getRootUrl ( ) ; $ url = rtrim ( $ baseUrl , '/' ) . '/' . trim ( $ url , '/' ) ; } return $ url ; } | get uplaod base url |
29,133 | static public function getUploadFileUrl ( $ filename ) { if ( $ filename && strpos ( $ filename , 'http' ) !== 0 ) { $ filename = static :: getUploadFileRelativePath ( $ filename ) ; if ( static :: isRootImageFile ( $ filename ) ) { return static :: getRootUrl ( ) . '/' . $ filename ; } $ filename = static :: getUploadUrl ( true ) . '/' . $ filename ; } return $ filename ; } | get uplaod file full url |
29,134 | static public function getUploadFilePath ( $ filename ) { if ( $ filename ) { $ filename = static :: getUploadFileRelativePath ( $ filename ) ; if ( static :: isRootImageFile ( $ filename ) ) { return static :: getWebRootPath ( ) . $ filename ; } $ filename = static :: getUploadPath ( ) . $ filename ; } return $ filename ; } | get upload file absolute path |
29,135 | static public function getUploadFileRelativePath ( $ filename ) { if ( $ filename ) { $ filename = str_replace ( '\\' , '/' , $ filename ) ; $ filename = str_replace ( static :: getUploadUrl ( ) , '' , $ filename ) ; $ filename = trim ( str_replace ( static :: getUploadPath ( ) , '' , $ filename ) , '/' ) ; if ( strpos ( $ filename , 'http' ) === 0 ) { $ filename = str_replace ( static :: getRootUrl ( ) , '' , $ filename ) ; } } return $ filename ; } | get upload file relative path |
29,136 | public function searchBy ( $ searchQuery , array $ options = array ( ) , $ statementsType = null ) { $ query = $ this -> newSearchQuery ( $ searchQuery , array ( 'status' , 'total_price' , 'created_at' , 'updated_at' , ) , $ statementsType , $ options ) ; if ( is_array ( $ searchQuery ) ) { if ( array_key_exists ( 'user_uid' , $ searchQuery ) || array_key_exists ( 'user_id' , $ searchQuery ) ) { $ query -> join ( 'users' , 'users.id' , '=' , 'orders.user_id' ) ; } if ( array_key_exists ( 'user_uid' , $ searchQuery ) ) { $ query -> where ( 'users.uid' , '=' , $ searchQuery [ 'user_uid' ] ) ; } if ( array_key_exists ( 'user_id' , $ searchQuery ) ) { $ query -> where ( 'users.uid' , '=' , $ searchQuery [ 'user_id' ] ) ; } } return new Collection ( $ query ) ; } | Search a Order by options . |
29,137 | public function update ( ) { $ args = func_get_args ( ) ; $ order = null ; if ( count ( $ args ) == 1 && $ args [ 0 ] instanceof Order ) { $ order = $ args [ 0 ] ; } elseif ( count ( $ args ) == 2 && ! empty ( $ args [ 0 ] ) && is_array ( $ args [ 1 ] ) ) { $ order = $ this -> find ( $ args [ 0 ] ) ; $ order -> fill ( $ args [ 1 ] ) ; } if ( $ order instanceof Order ) { if ( $ this -> fireEvent ( 'updating' , array ( $ order ) ) === false ) { return false ; } $ order -> setCaller ( $ this ) ; $ order -> save ( ) ; $ this -> fireEvent ( 'updated' , array ( $ order ) ) ; return $ order ; } throw new Exception ( sprintf ( Exception :: CANT_UPDATE_MODEL , 'Subbly\\Model\\Order' , $ this -> name ( ) ) ) ; } | Update a Order . |
29,138 | public function relativePathFor ( $ name , array $ data = [ ] , array $ queryParams = [ ] ) { $ route = $ this -> getNamedRoute ( $ name ) ; $ pattern = $ route -> getPattern ( ) ; $ routeDatas = $ this -> routeParser -> parse ( $ pattern ) ; $ routeDatas = array_reverse ( $ routeDatas ) ; $ segments = [ ] ; foreach ( $ routeDatas as $ routeData ) { foreach ( $ routeData as $ item ) { if ( is_string ( $ item ) ) { $ segments [ ] = $ item ; continue ; } if ( ! array_key_exists ( $ item [ 0 ] , $ data ) ) { $ segments = [ ] ; $ segmentName = $ item [ 0 ] ; break ; } $ segments [ ] = $ data [ $ item [ 0 ] ] ; } if ( ! empty ( $ segments ) ) { break ; } } if ( empty ( $ segments ) ) { throw new InvalidArgumentException ( 'Missing data for URL segment: ' . $ segmentName ) ; } $ url = implode ( '' , $ segments ) ; if ( $ queryParams ) { $ url .= '?' . http_build_query ( $ queryParams ) ; } return $ url ; } | Build the path for a named route excluding the base path |
29,139 | protected function getClientId ( $ client ) { if ( $ client instanceof Client ) { if ( ! empty ( $ client -> id ) ) { $ id = $ client -> id ; } elseif ( ! empty ( $ client -> email ) ) { $ id = $ this -> api -> searchClientId ( $ client -> email ) ; } else { throw new YouHostingException ( "You need to provide either a client ID (recommended) or client e-mail to search for" ) ; } } elseif ( is_numeric ( $ client ) ) { $ id = $ client ; } else { $ id = $ this -> api -> searchClientId ( $ client ) ; } return ( int ) $ id ; } | Get the client ID from a Client object e - mail or id |
29,140 | protected function getAccountId ( $ account ) { if ( $ account instanceof Account ) { if ( ! empty ( $ account -> id ) ) { $ id = $ account -> id ; } elseif ( ! empty ( $ account -> domain ) ) { $ id = $ this -> api -> searchAccountId ( $ account -> domain ) ; } else { throw new YouHostingException ( "You need to provide either an account ID (recommended) or account domain to search for" ) ; } } elseif ( is_numeric ( $ account ) ) { $ id = $ account ; } else { $ id = $ this -> api -> searchAccountId ( $ account ) ; } return ( int ) $ id ; } | Get an account id from either an id email or account object |
29,141 | public function checkDomain ( $ type , $ domain , $ subdomain = "" ) { return $ this -> api -> checkDomain ( $ type , $ domain , $ subdomain ) ; } | Check if a domain name is available |
29,142 | public function suspendAccount ( $ account , $ reason = "" , $ info = "" ) { return $ this -> api -> suspendAccount ( $ this -> getAccountId ( $ account ) , $ reason , $ info ) ; } | Suspend a hosting account |
29,143 | public function suspendClient ( $ client , $ allAccounts = false , $ allVps = false , $ reason = "" , $ info = "" ) { return $ this -> api -> suspendClient ( $ this -> getClientId ( $ client ) , $ allAccounts , $ allVps , $ reason , $ info ) ; } | Suspend a client profile |
29,144 | public function unsuspendAccount ( $ account , $ reason = "" , $ info = "" ) { return $ this -> api -> unsuspendAccount ( $ this -> getAccountId ( $ account ) , $ reason , $ info ) ; } | Reactivate a hosting account |
29,145 | public function changeAccountStatus ( $ account , $ status , $ reason = "" , $ info = "" ) { return $ this -> api -> changeAccountStatus ( $ this -> getAccountId ( $ account ) , $ status , $ reason , $ info ) ; } | Change the status of a hosting account |
29,146 | public function changeClientStatus ( $ client , $ status , $ allAccounts = false , $ allVps = false , $ reason = "none" , $ info = "" ) { return $ this -> api -> changeClientStatus ( $ this -> getClientId ( $ client ) , $ status , $ allAccounts , $ allVps , $ reason , $ info ) ; } | Change the status of a client profile |
29,147 | public function changeAccountPassword ( $ account , $ password ) { return $ this -> api -> changeAccountPassword ( $ this -> getAccountId ( $ account ) , $ password ) ; } | Change the password of a hosting account |
29,148 | public function changeClientPassword ( $ client , $ password ) { return $ this -> api -> changeClientPassword ( $ this -> getClientId ( $ client ) , $ password ) ; } | Change the password of a client profile |
29,149 | public function updateBalance ( $ client , $ amount , $ description , $ gateway , $ invoiceId = null ) { return $ this -> api -> updateBalance ( $ this -> getClientId ( $ client ) , $ amount , $ description , $ gateway , $ invoiceId ) ; } | Apply a transaction to the balance of a client |
29,150 | public function coverInvoice ( $ client , $ invoiceId = null ) { return $ this -> api -> coverInvoice ( $ this -> getClientId ( $ client ) , $ invoiceId ) ; } | Cover invoices of the client using the account balance |
29,151 | protected function createRetryMessage ( EnvelopeInterface $ envelope , $ attempt , \ Exception $ exception = null ) { $ headers = $ envelope -> getHeaders ( ) ; $ headers [ RetryProcessor :: PROPERTY_KEY ] = $ attempt ; if ( $ exception ) { $ headers [ 'x-exception' ] = [ 'message' => $ exception -> getMessage ( ) , 'type' => get_class ( $ exception ) , 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) , ] ; } $ properties = new MessageProperties ( [ MessageProperties :: KEY_CONTENT_TYPE => $ envelope -> getContentType ( ) , MessageProperties :: KEY_DELIVERY_MODE => $ envelope -> getDeliveryMode ( ) , MessageProperties :: KEY_HEADERS => $ headers , MessageProperties :: KEY_PRIORITY => $ envelope -> getPriority ( ) , ] ) ; return new Message ( $ envelope -> getBody ( ) , $ properties , $ envelope -> getDeliveryTag ( ) , $ envelope -> getRoutingKey ( ) ) ; } | Creates a new message to retry . |
29,152 | public static function add ( $ request , $ match ) { $ perm = Pluf_Shortcuts_GetObjectOr404 ( 'User_Role' , $ match [ 'role_id' ] ) ; $ group = Pluf_Shortcuts_GetObjectOr404 ( 'User_Group' , isset ( $ match [ 'group_id' ] ) ? $ match [ 'group_id' ] : $ request -> REQUEST [ 'group_id' ] ) ; $ perm -> setAssoc ( $ group ) ; return $ group ; } | Add new group to a role . In other word grant a role to a group . Id of added group should be specified in request . |
29,153 | public static function get ( $ request , $ match ) { $ perm = Pluf_Shortcuts_GetObjectOr404 ( 'User_Role' , $ match [ 'role_id' ] ) ; $ groupModel = new User_Group ( ) ; $ param = array ( 'view' => 'join_role' , 'filter' => array ( 'id=' . $ match [ 'group_id' ] , 'role_id=' . $ perm -> id ) ) ; $ groups = $ groupModel -> getList ( $ param ) ; if ( $ groups -> count ( ) == 0 ) { throw new Pluf_Exception_DoesNotExist ( 'Group has not such role' ) ; } return $ groups [ 0 ] ; } | Returns information of a group of a role . |
29,154 | public static function delete ( $ request , $ match ) { $ perm = Pluf_Shortcuts_GetObjectOr404 ( 'User_Role' , $ match [ 'role_id' ] ) ; $ owner = Pluf_Shortcuts_GetObjectOr404 ( 'User_Group' , $ match [ 'group_id' ] ) ; $ perm -> delAssoc ( $ owner ) ; return $ owner ; } | Deletes a group from a role . Id of deleted group should be specify in the match . |
29,155 | private function initTypeGuesser ( ) { $ this -> typeGuesserLoaded = true ; $ this -> typeGuesser = $ this -> loadTypeGuesser ( ) ; if ( null !== $ this -> typeGuesser && ! $ this -> typeGuesser instanceof BlockTypeGuesserInterface ) { throw new UnexpectedTypeException ( $ this -> typeGuesser , 'Fxp\Component\Block\BlockTypeGuesserInterface' ) ; } } | Initializes the type guesser . |
29,156 | public function getType ( ) { $ type = null ; if ( ( $ parent = $ this -> getParent ( ) ) instanceof ElementHandler && $ parent -> hasAttribute ( self :: ATTRIBUTE_TYPE ) ) { $ type = $ parent -> getAttribute ( self :: ATTRIBUTE_TYPE ) -> getValue ( false , false ) ; } return $ type ; } | Tries to get attribute type on the same node in order to return the value of the attribute in its type |
29,157 | public static function getValueWithinItsType ( $ value , $ knownType = null ) { if ( is_int ( $ value ) || ( ! is_null ( $ value ) && in_array ( $ knownType , array ( 'time' , 'positiveInteger' , 'unsignedLong' , 'unsignedInt' , 'short' , 'long' , 'int' , 'integer' , ) , true ) ) ) { return intval ( $ value ) ; } elseif ( is_float ( $ value ) || ( ! is_null ( $ value ) && in_array ( $ knownType , array ( 'float' , 'double' , 'decimal' , ) , true ) ) ) { return floatval ( $ value ) ; } elseif ( is_bool ( $ value ) || ( ! is_null ( $ value ) && in_array ( $ knownType , array ( 'bool' , 'boolean' , ) , true ) ) ) { return ( $ value === 'true' || $ value === true || $ value === 1 || $ value === '1' ) ; } return $ value ; } | Returns the value with good type |
29,158 | function add ( iRoute $ router , $ allowOverride = true , $ priority = null ) { $ router = $ this -> _prepareRouter ( $ router ) ; $ this -> _priorityQueue ( ) -> insert ( $ router , [ 'order' => $ priority ] ) ; $ this -> routesAdd [ $ router -> getName ( ) ] = $ router ; $ allowOverride = ( bool ) $ allowOverride ; if ( false === $ allowOverride ) $ this -> _routes_strict_override [ $ router -> getName ( ) ] = true ; return $ this ; } | Add Parallel Router |
29,159 | function explore ( $ routeName ) { $ routeName = trim ( ( string ) $ routeName , self :: SEPARATOR ) ; $ selfName = $ this -> getName ( ) ; if ( strpos ( $ routeName , $ selfName ) !== 0 ) return false ; if ( $ selfName === $ routeName ) return $ this ; foreach ( $ this -> routesAdd as $ nr ) { if ( $ routeName === $ nr -> getName ( ) ) return $ nr ; if ( ( $ nr instanceof iRouterStack ) && ( $ return = $ nr -> explore ( $ routeName ) ) ) return $ return ; } return false ; } | Explore Router With Name |
29,160 | function setName ( $ name ) { $ selfCurrName = $ this -> getName ( ) ; if ( $ name == $ selfCurrName ) return $ this ; $ this -> name = ( string ) $ name ; foreach ( $ this -> _priorityQueue ( ) as $ route ) { $ nestedName = $ route -> getName ( ) ; $ nestedNewName = $ name . substr ( $ nestedName , strlen ( $ selfCurrName ) ) ; $ route -> setName ( $ nestedNewName ) ; $ nr = $ this -> routesAdd [ $ nestedName ] ; $ nr -> setName ( $ nestedNewName ) ; unset ( $ this -> routesAdd [ $ nestedName ] ) ; $ this -> routesAdd [ $ nestedNewName ] = $ nr ; } return $ this ; } | Set Route Name |
29,161 | public function initialize ( $ pid ) { if ( $ this -> user -> tests ( ) -> instance ( $ pid ) -> start ( ) ) return true ; else return false ; } | start or continue a test |
29,162 | public function value ( $ key ) { if ( ! isset ( $ _COOKIE [ $ key ] ) ) { return null ; } if ( $ this -> hashed ) { list ( $ value , $ hash ) = unserialize ( $ _COOKIE [ $ key ] ) ; if ( $ hash != hash ( 'sha256' , $ value . $ this -> salt ) ) { return null ; } } else { $ value = $ _COOKIE [ $ key ] ; } return unserialize ( $ value ) ; } | Get cookie value for selected key . |
29,163 | public function set ( $ key , $ value , $ days = null , $ hours = null , $ minutes = null ) { $ days = null !== $ days ? $ days : $ this -> days ; $ hours = null !== $ hours ? $ hours : $ this -> hours ; $ minutes = null !== $ minutes ? $ minutes : $ this -> minutes ; $ value = serialize ( $ value ) ; if ( $ this -> hashed ) { $ value = serialize ( array ( $ value , hash ( 'sha256' , $ value . $ this -> salt ) ) ) ; } $ domain = ltrim ( $ _SERVER [ 'SERVER_NAME' ] , "www." ) ; return setcookie ( $ key , $ value , time ( ) + $ minutes * 60 + $ hours * 3600 + $ days * 24 * 3600 , '/' , $ domain , $ this -> secured , $ this -> httpOnly ) ; } | Set a cookie using current parameters . |
29,164 | public function delete ( $ key ) { $ domain = ltrim ( $ _SERVER [ 'SERVER_NAME' ] , "www." ) ; unset ( $ _COOKIE [ $ key ] ) ; setcookie ( $ key , "" , - 1 , '/' , $ domain , $ this -> secured , $ this -> httpOnly ) ; } | Delete a single cookie value |
29,165 | public function fetchAll ( $ returnType = Table :: RETURN_MODEL ) { $ return = $ this -> select ( array ( ) , $ returnType ) ; if ( is_a ( $ return , 'DBScribe\Table' ) ) $ return = $ return -> execute ( ) ; if ( is_bool ( $ return ) ) return new ArrayCollection ( ) ; return $ return ; } | Fetches all rows in the database |
29,166 | public function findOneBy ( $ column , $ value , $ returnType = Table :: RETURN_MODEL ) { return $ this -> findOneWhere ( array ( array ( $ column => $ value ) ) , $ returnType ) ; } | Finds a row by a column value |
29,167 | public function findOne ( $ idValue , $ returnType = Table :: RETURN_MODEL ) { if ( is_object ( $ idValue ) ) { $ getPK = 'get' . ucfirst ( U :: _toCamel ( $ this -> getPrimaryKey ( ) ) ) ; $ idValue = $ idValue -> $ getPK ( ) ; } return $ this -> findOneBy ( $ this -> getPrimaryKey ( ) , $ idValue , $ returnType ) ; } | Finds a row by the id column |
29,168 | public function find ( $ id , $ returnType = Table :: RETURN_MODEL ) { return $ this -> findBy ( $ this -> getPrimaryKey ( ) , $ id , $ returnType ) ; } | Finds a row by the primary column |
29,169 | public function findOneWhere ( $ criteria , $ returnType = Table :: RETURN_MODEL ) { $ this -> limit ( 1 ) ; $ result = $ this -> findWhere ( $ criteria , $ returnType ) ; if ( is_array ( $ result ) ) { $ result = array_values ( $ result ) ; return ( $ returnType === Table :: RETURN_JSON ) ? json_encode ( $ result [ 0 ] ) : $ result [ 0 ] ; } else if ( is_object ( $ result ) ) { return $ result -> first ( ) ; } } | Finds a row with the given criteria |
29,170 | public function select ( $ model = array ( ) , $ returnType = Table :: RETURN_MODEL ) { $ this -> insertJoins ( ) ; if ( ! is_array ( $ model ) ) { $ model = array ( $ model ) ; } $ this -> isSelect = true ; return parent :: select ( $ model , $ returnType ) ; } | Selects data from database with non - NULL model properties as criteria |
29,171 | public function update ( $ model , $ whereProperty = 'id' ) { if ( ! is_array ( $ model ) ) { $ model = array ( $ model ) ; } return parent :: update ( $ model , $ whereProperty ) ; } | Updates the database with the model properties |
29,172 | public function delete ( $ model ) { if ( $ model ) { if ( ! is_array ( $ model ) ) { $ model = array ( $ model ) ; } return parent :: delete ( $ model ) ; } else { return parent :: delete ( ) ; } return $ this ; } | Deletes data from the database |
29,173 | public function createCidrRule ( $ protocol , $ cidr_ips , $ from_port , $ to_port = null ) { $ params = array_merge ( $ this -> getCommonRuleParams ( $ protocol , $ from_port , $ to_port ) , array ( 'security_group_rule[source_type]' => 'cidr_ips' , 'security_group_rule[cidr_ips]' => $ cidr_ips ) ) ; $ this -> executeCommand ( 'security_group_rules_create' , $ params ) ; } | Creates a CIDR based security group rule . Requires that security group already be created or shown . |
29,174 | public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; $ parent = $ this -> Parent ( ) ; if ( $ parent -> exists ( ) && ! $ parent instanceof Blog ) { $ first_blog = Blog :: get ( ) -> first ( ) ; if ( $ first_blog ) { $ this -> ParentID = $ first_blog -> ID ; } } $ this -> extend ( 'onBeforeWrite' ) ; } | Ensure the Parent is a Blog if not move it to the first blog |
29,175 | public function onBeforePublish ( ) { $ publishDate = $ this -> dbObject ( 'PublishDate' ) ; if ( ! $ publishDate -> getValue ( ) ) { $ this -> PublishDate = DBDatetime :: now ( ) -> getValue ( ) ; $ this -> write ( ) ; } $ this -> Summary = trim ( $ this -> Summary ) ; $ this -> extend ( 'onBeforePublish' ) ; } | Update the PublishDate to now if the BlogPost would otherwise be published without a date . |
29,176 | public function updateAchievementCriterias ( $ owner , string $ type , $ data = null ) : int { $ criterias = $ this -> storage -> getOwnerCriteriasByType ( $ owner , $ type , $ data ) ; if ( ! count ( $ criterias ) ) { return 0 ; } $ this -> achievementsToCheck = [ ] ; $ achievements = $ this -> storage -> getAchievementsByCriterias ( $ criterias ) ; $ updatedCriteriasCount = 0 ; foreach ( $ criterias as $ criteria ) { if ( $ criteria -> completed ( ) ) { continue ; } $ achievement = $ this -> storage -> getAchievementForCriteria ( $ criteria , $ achievements ) ; if ( is_null ( $ achievement ) ) { continue ; } $ change = $ this -> getCriteriaChange ( $ owner , $ criteria , $ achievement , $ data ) ; if ( is_null ( $ change ) ) { continue ; } $ this -> setCriteriaProgress ( $ owner , $ criteria , $ achievement , $ change ) ; $ updatedCriteriasCount ++ ; } if ( count ( $ this -> achievementsToCheck ) > 0 ) { $ this -> checkCompletedAchievements ( $ owner ) ; } return $ updatedCriteriasCount ; } | Updates criterias progress by given type & checks referred achievements for completeness state . |
29,177 | public function getCriteriaChange ( $ owner , AchievementCriteria $ criteria , Achievement $ achievement , $ data = null ) { $ handler = $ this -> handlers -> getHandlerFor ( $ criteria -> type ( ) ) ; if ( ! $ handler instanceof CriteriaHandler ) { return null ; } return $ handler -> handle ( $ owner , $ criteria , $ achievement , $ data ) ; } | Requests new progress value for given owner & criteria . |
29,178 | protected function completedCriteriaFor ( Achievement $ achievement ) { if ( ! in_array ( $ achievement -> id ( ) , $ this -> achievementsToCheck ) ) { $ this -> achievementsToCheck [ ] = $ achievement -> id ( ) ; } } | Saves achievement to completeness check list . |
29,179 | protected function checkCompletedAchievements ( $ owner ) : int { $ achievements = $ this -> storage -> getAchievementsWithProgressFor ( $ owner , $ this -> achievementsToCheck ) ; $ this -> achievementsToCheck = [ ] ; if ( ! $ achievements || ! count ( $ achievements ) ) { return 0 ; } $ completedAchievements = array_filter ( $ achievements , function ( Achievement $ achievement ) { return ! $ achievement -> completed ( ) && $ this -> isCompletedAchievement ( $ achievement ) ; } ) ; if ( count ( $ completedAchievements ) > 0 ) { $ this -> storage -> setAchievementsCompleted ( $ owner , $ completedAchievements ) ; } return count ( $ completedAchievements ) ; } | Checks all saved achievements for completeness state . |
29,180 | protected function isCompletedCriteria ( AchievementCriteria $ criteria , AchievementCriteriaProgress $ progress ) : bool { $ progress -> completed = $ progress -> value >= $ criteria -> maxValue ( ) ; return $ progress -> completed ; } | Determines if given criteria was completed . |
29,181 | protected function isCompletedAchievement ( Achievement $ achievement ) : bool { $ completedCriterias = array_filter ( $ achievement -> criterias ( ) , function ( AchievementCriteria $ criteria ) { return $ this -> isCompletedCriteria ( $ criteria , $ criteria -> progress ( ) ) ; } ) ; return count ( $ achievement -> criterias ( ) ) === count ( $ completedCriterias ) ; } | Determines if given achievement was completed . |
29,182 | static public function web ( ) { $ key = 'app.web' ; if ( ! static :: has ( $ key ) ) { if ( ! ( $ app = static :: app ( ) ) || $ app -> isCli ( ) ) { static :: setShared ( $ key , new \ Wslim \ Web \ App ( Config :: getWebAppPath ( ) ) ) ; } else { static :: setShared ( $ key , $ app ) ; } } return static :: get ( $ key ) ; } | get web app |
29,183 | static public function cli ( ) { $ key = 'app.cli' ; if ( ! static :: has ( $ key ) ) { if ( ! ( $ app = static :: app ( ) ) || ! $ app -> isCli ( ) ) { static :: setShared ( $ key , new \ Wslim \ Console \ App ( Config :: getCliAppPath ( ) ) ) ; } } return static :: get ( $ key ) ; } | get console app |
29,184 | static public function load ( $ file , $ auto_decrypt = false ) { if ( substr ( trim ( $ file ) , - 4 ) !== '.php' ) { return false ; } $ fileIdentifier = md5 ( $ file ) ; if ( empty ( $ GLOBALS [ '__composer_autoload_files' ] [ $ fileIdentifier ] ) && file_exists ( $ file ) ) { $ GLOBALS [ '__composer_autoload_files' ] [ $ fileIdentifier ] = true ; if ( ! $ auto_decrypt ) { return require $ file ; } $ value = file_get_contents ( $ file ) ; if ( strpos ( $ value , '<' ) !== false ) { $ value = require $ file ; } else { $ value = Crypt :: instance ( ) -> decrypt ( $ value ) ; $ handle = tmpfile ( ) ; $ numbytes = fwrite ( $ handle , $ value ) ; $ value = require stream_get_meta_data ( $ handle ) [ 'uri' ] ; fclose ( $ handle ) ; } return $ value ; } return false ; } | load file consistent with composer |
29,185 | static public function encryptFile ( $ filename ) { $ value = file_get_contents ( $ filename ) ; if ( strpos ( $ value , '<?php' ) !== false ) { $ bfile = pathinfo ( $ filename , PATHINFO_FILENAME ) ; $ ext = pathinfo ( $ filename , PATHINFO_EXTENSION ) ; $ bfile .= '.encrypt.' . $ ext ; $ encrypt = Crypt :: instance ( ) -> encrypt ( $ value ) ; return file_put_contents ( $ bfile , $ encrypt ) ; } return true ; } | encrypt file origin file is remain . |
29,186 | static public function session ( $ name = null ) { $ id = 'session' ; if ( ! static :: has ( $ id ) ) { static :: setShared ( $ id , function ( ) { $ options = Config :: get ( 'session' ) ; if ( $ options [ 'storage' ] == 'file' ) { if ( ! isset ( $ options [ 'save_path' ] ) && isset ( $ options [ 'path' ] ) ) { $ options [ 'save_path' ] = $ options [ 'path' ] ; } $ options [ 'save_path' ] = isset ( $ options [ 'save_path' ] ) ? ltrim ( $ options [ 'save_path' ] , '/' ) : 'sessions' ; $ options [ 'save_path' ] = Config :: getStoragePath ( ) . $ options [ 'save_path' ] ; } $ obj = new Session ( $ options ) ; $ obj -> start ( ) ; return $ obj ; } ) ; } return static :: get ( $ id ) ; } | get session instance |
29,187 | static public function widget ( $ name = null ) { if ( $ name = static :: findClass ( $ name , 'widget' ) ) { $ id = 'widget' . ( $ name ? '.' . $ name : '' ) ; if ( ! static :: has ( $ id ) ) { static :: setShared ( $ id , function ( ) use ( $ name ) { if ( $ name instanceof \ Wslim \ View \ Widget ) { return $ name :: instance ( ) ; } else { return new $ name ; } } ) ; } return static :: get ( $ id ) ; } return null ; } | get widget instance |
29,188 | static public function formatNamespace ( $ namespace ) { if ( is_array ( $ namespace ) ) { foreach ( $ namespace as $ k => $ v ) { $ namespace [ $ k ] = static :: formatNamespace ( $ v ) ; } } else { $ namespace = trim ( str_replace ( '/' , '\\' , $ namespace ) , '\\' ) . '\\' ; } return $ namespace ; } | format namespace from a \ b to \\ a \\ b \\ |
29,189 | static public function setNamespaces ( $ nss ) { static :: initNamespace ( ) ; $ nss = ( array ) $ nss ; $ rnss = [ ] ; foreach ( $ nss as $ ns => $ path ) { if ( ! is_numeric ( $ ns ) ) { $ ns = static :: formatNamespace ( $ ns ) ; static :: loader ( ) -> setPsr4 ( $ ns , $ path ) ; } else { $ ns = static :: formatNamespace ( $ path ) ; } $ rnss [ ] = $ ns ; } static :: $ namespaces = array_merge ( static :: $ namespaces , $ rnss ) ; return static :: $ namespaces = array_unique ( static :: $ namespaces ) ; } | set global usable and search namespaces |
29,190 | static public function getNamespaces ( $ type = null ) { static :: initNamespace ( ) ; if ( $ type ) { $ nss = [ ] ; foreach ( static :: $ namespaces as $ k => $ v ) { $ nss [ $ k ] = $ v . ucfirst ( $ type ) . '\\' ; } return $ nss ; } else { return static :: $ namespaces ; } } | get usable and search namespaces |
29,191 | function getAllRoles ( $ force = false ) { if ( $ force == false and ! is_null ( $ this -> _cache_perms ) ) { return $ this -> _cache_perms ; } $ this -> _cache_perms = array ( ) ; $ this -> _cache_perms = ( array ) $ this -> get_roles_list ( ) ; return $ this -> _cache_perms ; } | Gets all roles of a group |
29,192 | function hasAppPerms ( $ app ) { foreach ( $ this -> getAllRoles ( ) as $ perm ) { if ( 0 === strpos ( $ perm , $ app . '.' ) ) { return true ; } } return false ; } | Check an application role |
29,193 | public function constructProxyHeader ( ) { return implode ( $ this -> version == 1 ? "\x20" : "" , array_filter ( [ $ this -> getSignature ( ) , $ this -> getVersionCommand ( ) , $ this -> getProtocol ( ) , $ this -> getAddressLength ( ) , $ this -> getAddresses ( ) , $ this -> getPorts ( ) , $ this -> version == 1 ? "\r\n" : null ] ) ) ; } | Constructs the header by concatenating all relevant fields . |
29,194 | public static function createForward4 ( $ sourceAddress , $ sourcePort , $ targetAddress , $ targetPort , $ version = 2 ) { $ result = new static ( ) ; $ result -> version = $ version ; $ result -> sourceAddress = $ sourceAddress ; $ result -> targetPort = $ targetPort ; $ result -> targetAddress = $ targetAddress ; $ result -> sourcePort = $ sourcePort ; return $ result ; } | This function creates the forwarding header . This header should be sent over the upstream connection as soon as it is established . |
29,195 | function setColumns ( $ columns ) { $ this -> columns = array ( ) ; if ( $ columns === null ) { return $ this ; } if ( is_string ( $ columns ) ) { return $ this -> addColumn ( $ columns ) ; } foreach ( $ columns as $ alias => & $ column ) { $ this -> addColumn ( $ column , is_int ( $ alias ) ? null : $ alias ) ; } return $ this ; } | Set array of strings of columns to be selected |
29,196 | function setTable ( $ table_name , $ alias = null ) { if ( $ table_name instanceof Query ) { if ( ! $ alias ) { throw new RuntimeException ( 'The nested query must have an alias.' ) ; } $ table_name = clone $ table_name ; } elseif ( null === $ alias ) { $ space = strrpos ( $ table_name , ' ' ) ; $ as = strrpos ( strtoupper ( $ table_name ) , ' AS ' ) ; if ( $ as != $ space - 3 ) { $ as = false ; } if ( $ space ) { $ alias = trim ( substr ( $ table_name , $ space + 1 ) ) ; $ table_name = trim ( substr ( $ table_name , 0 , $ as === false ? $ space : $ as ) ) ; } } if ( $ alias ) { $ this -> setAlias ( $ alias ) ; } $ this -> table = $ table_name ; return $ this ; } | Sets the table to be queried . This can be a string table name or an instance of Query if you would like to nest queries . This function also supports arbitrary SQL . |
29,197 | function addJoin ( $ table_or_column , $ on_clause_or_column = null , $ join_type = self :: JOIN ) { if ( $ table_or_column instanceof QueryJoin ) { $ this -> joins [ ] = clone $ table_or_column ; return $ this ; } if ( null === $ on_clause_or_column ) { if ( $ join_type == self :: JOIN || $ join_type == self :: INNER_JOIN ) { $ this -> addTable ( $ table_or_column ) ; return $ this ; } $ on_clause_or_column = '1 = 1' ; } $ this -> joins [ ] = new QueryJoin ( $ table_or_column , $ on_clause_or_column , $ join_type ) ; return $ this ; } | Add a JOIN to the query . |
29,198 | function joinOnce ( $ table_or_column , $ on_clause_or_column = null , $ join_type = self :: JOIN ) { if ( $ table_or_column instanceof QueryJoin ) { $ join = clone $ table_or_column ; } else { if ( null === $ on_clause_or_column ) { if ( $ join_type == self :: JOIN || $ join_type == self :: INNER_JOIN ) { foreach ( $ this -> extraTables as & $ table ) { if ( $ table == $ table_or_column ) { return $ this ; } } $ this -> addTable ( $ table_or_column ) ; return $ this ; } $ on_clause_or_column = '1 = 1' ; } $ join = new QueryJoin ( $ table_or_column , $ on_clause_or_column , $ join_type ) ; } foreach ( $ this -> joins as & $ existing_join ) { if ( $ join -> getTable ( ) == $ existing_join -> getTable ( ) ) { if ( $ join -> getAlias ( ) != $ existing_join -> getAlias ( ) ) { continue ; } return $ this ; } } $ this -> joins [ ] = $ join ; return $ this ; } | Add a join after checking to see if Query already has a join for the same table and alias . Similar to php s include_once |
29,199 | function addOr ( $ column , $ value = null , $ operator = self :: EQUAL , $ quote = null ) { if ( func_num_args ( ) === 1 ) { $ this -> where -> addOr ( $ column ) ; } else { $ this -> where -> addOr ( $ column , $ value , $ operator , $ quote ) ; } return $ this ; } | Shortcut to adding an OR statement to the Query s WHERE Condition . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.