idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
16,200 | public function setParam ( $ name , $ value ) { switch ( $ name ) { case 'processor' : $ this -> setProcessor ( $ value ) ; break ; case 'message' : $ this -> setMessage ( $ value ) ; break ; case 'result' : $ this -> setResult ( $ value ) ; break ; default : parent :: setParam ( $ name , $ value ) ; break ; } return $... | Set an individual event parameter |
16,201 | public function build ( ) { switch ( $ this -> provider ) { default : case Provider :: RACKSPACE : $ class = __NAMESPACE__ . '\\RackspaceFactory' ; break ; case Provider :: OPENSTACK : $ class = __NAMESPACE__ . '\\OpenStackFactory' ; break ; } return $ this -> buildFactory ( $ class ) -> buildClient ( ) ; } | Will initialize the build process ; first the factory is built then the factory builds the client |
16,202 | protected function buildFactory ( $ factoryClass ) { $ factory = $ factoryClass :: newInstance ( ) ; $ factory -> setConfig ( $ this -> config ) ; $ factory -> validateConfig ( ) ; return $ factory ; } | Build the concrete factory class responsible for creating a concrete client object |
16,203 | public function getStartDate ( ) { $ topic = BaseManager :: build ( 'FelixOnline\Core\Topic' , 'article_topic' , 'topic' ) -> filter ( 'topic = "%s"' , array ( $ this -> getSlug ( ) ) ) ; $ article = BaseManager :: build ( 'FelixOnline\Core\Article' , 'article' , 'id' ) -> join ( $ topic , 'LEFT' , 'id' , 'article' ) -... | Get date that the first article was posted |
16,204 | public static function setEnvironment ( $ env = self :: ENV_STAGE ) { $ prefix = '' ; if ( $ env === self :: ENV_STAGE ) { $ prefix = 's' ; } static :: $ apiHost = $ prefix . 'api.fortifi.io' ; } | Set the environment to connect to |
16,205 | public function trigger ( Payload $ payload ) { if ( ! $ this -> command ) { return $ this -> targetState ( ) ; } return call_user_func ( $ this -> command , $ payload ) ? $ this -> targetState ( ) : $ this -> errorState ( ) ; } | Triggers event and return next state name or null if there is no state change |
16,206 | public function parse ( ) { $ data = file_get_contents ( "http://api.openweathermap.org/data/2.5/weather?zip=420000,ru&units=metric" ) ; $ this -> record -> formatted = str_replace ( "{weather}" , $ data , $ this -> record -> formatted ) ; return $ this -> record ; } | Replace macros with useful data |
16,207 | public function addComment ( $ orderIncrementId , $ status , $ comment = null , $ notify = null ) { return $ this -> __createAction ( 'salesOrderAddComment' , func_get_args ( ) ) ; } | Allows you to add a new comment to the order . |
16,208 | public static function getRaw ( $ name ) { $ value = null ; $ rawCookies = ! empty ( $ _SERVER [ 'HTTP_COOKIE' ] ) ? explode ( '; ' , $ _SERVER [ 'HTTP_COOKIE' ] ) : array ( ) ; foreach ( $ rawCookies as $ kv ) { $ pair = explode ( '=' , $ kv , 2 ) ; $ k = array_shift ( $ pair ) ; $ v = array_shift ( $ pair ) ; $ k = s... | Returns the coocie value that s received in the header |
16,209 | protected static function cookieParams ( $ args = array ( ) ) { $ params = array ( ) ; if ( count ( $ args ) == 1 ) { if ( is_array ( $ args [ 0 ] ) ) { $ params = $ args [ 0 ] ; } else { $ params [ 'value' ] = $ args [ 0 ] ; } } elseif ( count ( $ args ) == 2 ) { if ( is_string ( $ args [ 1 ] ) ) { $ params [ 'name' ]... | return cookie parameters |
16,210 | static public function getType ( $ strType ) { $ arrReservere = array ( 'array' => 'ArrayObject' , 'bool' => 'BooleanObject' , 'boolean' => 'BooleanObject' , 'datetime' => 'DateTimeObject' , 'dictionary' => 'DictionaryObject' , 'enum' => 'EnumObject' , 'id' => 'IdObject' , 'int' => 'IntObject' , 'float' => 'FloatObject... | Get Type Method |
16,211 | private function setViewService ( Di $ di , Config $ config , $ moduleName ) { $ viewsDir = $ config [ 'view' ] [ $ moduleName ] ; $ volt = $ this -> setVoltOptions ( $ config , $ moduleName ) ; $ options = [ 'di' => $ di , 'views_dir' => $ viewsDir , 'volt' => $ volt ] ; $ di -> set ( 'view' , new View ( $ options ) ,... | Set service view for application when module start |
16,212 | private function setUrlService ( Di $ di , Config $ config , $ name ) { $ base = $ static = '/' ; if ( isset ( $ config [ 'url' ] ) ) { $ default = isset ( $ config [ 'url' ] [ 'default' ] ) ? $ config [ 'url' ] [ 'default' ] : '/' ; if ( isset ( $ config [ 'url' ] [ $ name ] ) ) { $ base = isset ( $ config [ 'url' ] [... | Set url service when module start |
16,213 | public function check_dir ( $ need_not_empty = true ) { $ ok = false ; if ( is_dir ( $ this -> _dir_path ) && is_readable ( $ this -> _dir_path ) ) { $ ok = true ; if ( $ need_not_empty ) { $ ok = ( count ( scandir ( $ this -> _dir_path ) ) > 0 ) ? true : false ; } } return $ ok ; } | Verifie la validite du repertoire . |
16,214 | public function get_path_files ( ) { $ path_files = array ( ) ; $ tmp_contents_dir = scandir ( $ this -> _dir_path ) ; foreach ( $ tmp_contents_dir as $ tmp_content_dir ) { if ( is_file ( $ this -> _dir_path . $ tmp_content_dir ) ) { $ service_name = strtolower ( preg_replace ( '/\\.[^.\\s]{3,4}$/' , '' , $ tmp_content... | Donne le chemin de tout les fichiers contenus dans le repertoire |
16,215 | protected function _setColumnNumber ( $ columnNumber ) { if ( $ columnNumber !== null ) { try { $ columnNumber = $ this -> _normalizeInt ( $ columnNumber ) ; } catch ( RootException $ e ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Invalid column number' ) , null , $ e , $ columnNumber ) ; } if ... | Assigns a column number to this instance . |
16,216 | public function wizardAction ( ) { $ this -> writeln ( 'DB wizard for a profile' ) ; $ profileName = $ this -> ask ( 'Enter the <underline>profile name</underline> to edit' , 'default' ) ; $ fields = $ this -> askArray ( array ( 'name' => array ( 'DB name' , ) , 'user' => array ( 'DB user' , 'root' , ) , 'pass' => arra... | Using for generating profile for database |
16,217 | public function updateAllAction ( ) { QC :: executeSQL ( 'SET FOREIGN_KEY_CHECKS = 0' ) ; ModelOperator :: getInstance ( DC :: getEnvironment ( ) -> getUserClassesRoot ( ) . 'db/' ) -> updateDBForAllModels ( ) ; ModelOperator :: getInstance ( ) -> generateAllModelClasses ( ) ; $ this -> writeln ( 'DB updated' ) ; } | Update database and models |
16,218 | public function createDbAction ( ) { $ config = DC :: getDatabaseConfig ( 'profiles/default' ) ; DatabaseService :: configProfile ( array ( 'user' => $ config [ 'user' ] , 'pass' => $ config [ 'pass' ] , ) ) ; DBOperator :: getInstance ( ) -> createDB ( $ config [ 'name' ] ) ; $ this -> notify ( $ config [ 'name' ] , '... | Created database for profile default |
16,219 | public function addChild ( Node $ child ) { $ this -> children [ ] = $ child ; $ child -> parent = $ this ; $ child -> properties [ 'parent' ] = $ this -> getId ( ) ; } | Adds the given node to this node s children |
16,220 | private function getSibling ( $ offset ) { $ siblingsAndSelf = $ this -> parent -> getChildren ( ) ; $ pos = array_search ( $ this , $ siblingsAndSelf ) ; if ( isset ( $ siblingsAndSelf [ $ pos + $ offset ] ) ) { return $ siblingsAndSelf [ $ pos + $ offset ] ; } return null ; } | Returns the sibling with the given offset from this node or NULL if there is no such sibling |
16,221 | public function getSiblings ( $ includeSelf = false ) { $ siblings = array ( ) ; foreach ( $ this -> parent -> getChildren ( ) as $ child ) { if ( $ includeSelf || $ child -> getId ( ) != $ this -> getId ( ) ) { $ siblings [ ] = $ child ; } } return $ siblings ; } | Returns siblings of the node optionally including the node itself . |
16,222 | public function get ( $ name ) { $ lowerName = strtolower ( $ name ) ; if ( isset ( $ this -> properties [ $ lowerName ] ) ) { return $ this -> properties [ $ lowerName ] ; } throw new \ InvalidArgumentException ( "Undefined property: $name (Node ID: " . $ this -> properties [ 'id' ] . ')' ) ; } | Returns a single node property by its name . |
16,223 | public function createNew ( string $ name , bool $ production ) : array { return $ this -> sendPost ( sprintf ( '/companies/%s/credentials' , $ this -> companySlug ) , [ ] , [ 'name' => $ name , 'production' => $ production ] ) ; } | Creates a new credential for the given company . |
16,224 | public function listen ( int $ port = 119 , string $ address = self :: DEFAULT_ADDRESS , array $ options = [ ] ) { $ server = $ this -> factory -> create ( $ address , $ port , $ options ) ; $ this -> servers [ ] = $ server ; $ coroutine = new Coroutine ( $ this -> accept ( $ server ) ) ; $ coroutine -> done ( ) ; } | Starts the server and begins listening for connections . |
16,225 | public function getHandler ( string $ handler ) : Handler { if ( ! isset ( $ this -> handlers [ $ handler ] ) ) { if ( ! class_exists ( $ handler ) || ! class_implements ( $ handler , Handler :: class ) ) { throw new \ RuntimeException ( "No handler found for '$handler'." ) ; } $ instance = new $ handler ( ) ; $ this -... | Gets a command handler instance . |
16,226 | private function accept ( SocketServer $ server ) : Generator { yield from log ( ) -> log ( Log :: INFO , 'NNTP server listening on %s:%d' , $ server -> getAddress ( ) , $ server -> getPort ( ) ) ; while ( $ server -> isOpen ( ) ) { $ socket = yield from $ server -> accept ( ) ; $ coroutine = new Coroutine ( $ this -> ... | Accepts incoming connections as they are made . |
16,227 | public static function create ( array $ data ) : Location { $ location = new Location ( ) ; parent :: fill ( $ data , $ location ) ; return $ location ; } | Creates a location object with the given data |
16,228 | protected function createId ( $ id ) { if ( is_null ( $ id ) ) { return md5 ( join ( '_' , [ $ this -> config [ 'shortcode' ] , $ this -> mobile , time ( ) , ] ) ) ; } return $ id ; } | Create a message id . |
16,229 | static public function getHeaders ( $ url ) { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_NOBODY , true ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , false ) ; curl_setopt ( $ ch , CURLOPT_HEADER , false ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , true ) ; curl_setopt ( $ ch , CURLOPT_MAXREDIRS ... | Get Headers function |
16,230 | public static function get ( $ var , $ key , $ default = null ) { if ( $ key === null ) return $ var ; elseif ( isset ( $ var -> $ key ) ) return $ var -> $ key ; elseif ( isset ( $ var [ $ key ] ) ) return $ var [ $ key ] ; else return $ default ; } | Return value of the specified key from an array or object or a default if the key isn t set . |
16,231 | public static function pluck ( $ vars , $ field , $ preserve_keys = true ) { $ values = [ ] ; foreach ( $ vars as $ k => $ v ) { $ values [ $ k ] = static :: get ( $ v , $ field ) ; } return $ preserve_keys ? $ values : array_values ( $ values ) ; } | Extract a single field from an array of arrays or objects . |
16,232 | public function findActual ( ) { if ( null === $ this -> actual ) { $ this -> actual = $ this -> find ( $ this -> getSiteInfo ( ) -> getSubdomainId ( ) ) ; } return $ this -> actual ; } | Find the current actual sub - domain |
16,233 | protected function renderElementIcon ( ElementInterface $ element ) { $ render = '' ; $ icon = $ element -> getOption ( 'icon' ) ; if ( $ icon ) { $ iconHelper = $ this -> getIconHelper ( ) ; $ render = $ iconHelper ( $ icon ) ; } return $ render ; } | Render element icon |
16,234 | protected function setElementClass ( ElementInterface $ element ) { $ class = $ element -> getAttribute ( 'class' ) ; $ type = $ element -> getOption ( 'type' ) ? : self :: TYPE_DEFAULT ; if ( ! in_array ( $ type , self :: TYPES , true ) ) { throw new Exception \ DomainException ( sprintf ( '%s requires that the button... | Set element class |
16,235 | public function offsetGet ( $ offset ) { if ( $ this -> get !== null ) { return $ this -> get -> invoke ( $ this -> obj , $ offset ) ; } throw new NoSuchPropertyException ( $ this -> name ) ; } | Executes the accessor for a given array property |
16,236 | public function offsetSet ( $ offset , $ value ) : void { if ( $ this -> set !== null ) { $ this -> set -> invoke ( $ this -> obj , $ offset , $ value ) ; return ; } throw new NoSuchPropertyException ( $ this -> name ) ; } | Executes the mutator for a given array property |
16,237 | public function getIterator ( ) : Traversable { if ( $ this -> iterator !== null ) { return $ this -> iterator -> invoke ( $ this -> obj ) ; } throw new NoSuchPropertyException ( $ this -> name ) ; } | Returns the iterator for the array |
16,238 | public function send ( ) { foreach ( $ this -> messages as $ mail ) { $ this -> mailer -> send ( $ mail ) ; } return $ this ; } | Send all messages |
16,239 | private function getScreenshotStatus ( $ status ) : int { switch ( mb_strtoupper ( $ status ) ) { case 'IN_QUEUE' : return ScreenshotStatus :: IN_QUEUE ; case 'IN_PROCESS' : return ScreenshotStatus :: IN_PROCESS ; case 'FINISHED' : return ScreenshotStatus :: FINISHED ; case 'ERROR' : return ScreenshotStatus :: ERROR ; ... | Get screenshot status by its name |
16,240 | public static function send ( $ clean = TRUE ) { if ( ! headers_sent ( ) ) { foreach ( self :: $ headers as $ header ) { if ( is_array ( $ header ) ) { call_user_func_array ( 'header' , $ header ) ; } else { header ( $ header ) ; } } if ( $ clean ) { self :: $ headers = array ( ) ; } } self :: $ sent = TRUE ; } | Send HTTP Headers |
16,241 | public static function location ( $ url , $ code = 301 ) { self :: set ( array ( 'Location: ' . $ url , TRUE , $ code ) ) ; return self :: send ( ) ; } | Set and redirect HTTP Header Location |
16,242 | public static function contentType ( $ type , $ charset = 'utf-8' ) { $ type = isset ( self :: $ types [ $ type ] ) ? self :: $ types [ $ type ] : $ type ; self :: set ( 'Content-Type: ' . $ type . '; charset=' . $ charset ) ; } | Set HTTP Content - Type |
16,243 | protected function readFile ( string $ file ) : array { if ( ! file_exists ( $ file ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Configuration %s is not exists' , $ file ) , E_WARNING ) ; } if ( ! is_array ( ( $ configs = $ this -> parseFromFile ( $ file ) ) ) ) { throw new \ RuntimeException ( sprintf ( 'In... | Read current file |
16,244 | public static function getTypes ( ) : array { return [ self :: TYPE_DELIVERY => self :: TYPE_DELIVERY , self :: TYPE_SALE => self :: TYPE_SALE , self :: TYPE_REGULATION => self :: TYPE_REGULATION , self :: TYPE_RETURN => self :: TYPE_RETURN , ] ; } | Returns the valid types . |
16,245 | protected function updateCurrency ( Money $ money ) : self { if ( $ this -> currency && $ money -> getCurrency ( ) -> getCode ( ) !== $ this -> currency ) { throw new CurrencyMismatchException ( 'The currency on this stock movement is not the same as the one your Money object' ) ; } $ this -> currency = $ money -> getC... | Updates the shared currency . |
16,246 | protected function money ( int $ val ) : Money { if ( ! $ this -> currency ) { throw new UnsetCurrencyException ( 'The currency is not set on this stock movement' ) ; } return new Money ( $ val , new Currency ( $ this -> currency ) ) ; } | Returns a new Money object based on the shared currency If no currency is set it throws an exception . |
16,247 | private static function treeGoDown ( $ id , $ data , & $ hidden ) { foreach ( $ data as $ row ) { if ( $ row [ 'parent_id' ] == $ id ) { if ( false === in_array ( $ row [ 'id' ] , $ hidden ) ) { $ hidden [ ] = $ row [ 'id' ] ; } self :: treeGoDown ( $ row [ 'id' ] , $ data , $ hidden ) ; } } } | Recursively finds all children of node with given id |
16,248 | public function handle ( ) { $ response = '' ; try { $ this -> app -> instance ( 'mode' , 'web' ) ; $ this -> app -> boot ( ) ; $ request = $ this -> prepareRequest ( ) ; $ response = $ this -> runRoute ( $ request ) ; } catch ( \ Exception $ e ) { $ this -> reportException ( $ e ) ; $ response = Router :: toResponse (... | Handle web . |
16,249 | public static function Folders ( $ SourceFolders ) { if ( ! is_array ( $ SourceFolders ) ) $ SourceFolders = array ( $ SourceFolders ) ; $ BlackList = Gdn :: Config ( 'Garden.FolderBlacklist' ) ; if ( ! is_array ( $ BlackList ) ) $ BlackList = array ( '.' , '..' ) ; $ Result = array ( ) ; foreach ( $ SourceFolders as $... | Returns an array of all folder names within the source folder or FALSE if SourceFolder does not exist . |
16,250 | public static function GetContents ( ) { $ File = CombinePaths ( func_get_args ( ) ) ; if ( file_exists ( $ File ) && is_file ( $ File ) ) return self :: _GetContents ( $ File ) ; else return FALSE ; } | Returns the contents of the specified file or FALSE if it does not exist . Note that this is only useful for static content since any php code will be parsed as if it were within this method of this object . |
16,251 | public static function SaveFile ( $ FileName , $ FileContents , $ Flags = VANILLA_FILE_PUT_FLAGS ) { $ DirName = dirname ( $ FileName ) ; $ FileBaseName = basename ( $ FileName ) ; if ( ! is_dir ( $ DirName ) ) throw new Exception ( sprintf ( 'Requested save operation [%1$s] could not be completed because target folder... | Saves the specified file with the provided file contents . |
16,252 | public static function ServeFile ( $ File , $ Name = '' , $ MimeType = '' , $ ServeMode = 'attachment' ) { $ FileIsLocal = ( substr ( $ File , 0 , 4 ) == 'http' ) ? FALSE : TRUE ; $ FileAvailable = ( $ FileIsLocal ) ? is_readable ( $ File ) : TRUE ; if ( $ FileAvailable ) { Gdn :: Database ( ) -> CloseConnection ( ) ; ... | Serves a file to the browser . |
16,253 | public static function Copy ( $ source , $ dest , $ options = array ( 'folderPermission' => 0755 , 'filePermission' => 0755 ) ) { $ result = false ; if ( is_file ( $ source ) ) { if ( $ dest [ strlen ( $ dest ) - 1 ] == '/' ) { if ( ! file_exists ( $ dest ) ) { cmfcDirectory :: makeAll ( $ dest , $ options [ 'folderPer... | Copy file or folder from source to destination |
16,254 | function save ( string $ filename = null ) : bool { if ( ! empty ( $ filename ) ) $ this -> filename = $ filename ; return ( file_put_contents ( $ this -> filename , json_encode ( $ this -> confValues , JSON_PRETTY_PRINT ) ) !== false ) ; } | Save Configuration file |
16,255 | public function get ( string $ key , string $ default = null ) { $ keys = explode ( '.' , $ key ) ; $ val = $ this -> confValues ; for ( $ i = 0 ; $ i < count ( $ keys ) ; $ i ++ ) { $ val = ( $ val [ $ keys [ $ i ] ] ?? null ) ; if ( is_null ( $ val ) ) break ; } return $ val ?? $ default ; } | Get a config item |
16,256 | protected function resolveThemeFile ( $ type , $ file , $ scope , $ asFileInfo = false ) { $ themePath = ( $ scope ) ? $ scope . '/' . ltrim ( $ file , '/' ) : ltrim ( $ file , '/' ) ; $ path = false ; $ stack = $ this -> getFallbackThemes ( ) ; array_unshift ( $ stack , $ this -> getCurrentTheme ( ) ) ; while ( ( $ pa... | Internal resolve theme file |
16,257 | public function getPath ( ) { $ sname = '' ; $ gname = '' ; $ vname = $ this -> getName ( ) ; if ( $ this -> getConfigGroup ( ) ) { if ( $ this -> getConfigGroup ( ) -> getConfigSection ( ) ) { $ sname = $ this -> getConfigGroup ( ) -> getConfigSection ( ) -> getName ( ) ; } $ gname = $ this -> getConfigGroup ( ) -> ge... | Return the path for this ConfigValue |
16,258 | public function returnFullDataStorage ( ) { $ aStorage = $ this -> getSNMP ( ) -> realWalk1d ( self :: OID_STORAGE ) ; $ aReturn = Array ( ) ; $ aReturn [ 'memory_size' ] = $ aStorage [ self :: OID_STORAGE_MEMORY_SIZE ] [ 0 ] ; $ aReturn [ 'index' ] = $ aStorage [ self :: OID_STORAGE_INDEX ] ; $ aReturn [ 'type' ] = $ ... | Returns Full Data Storage |
16,259 | public function get_cookie ( $ name ) { $ retval = NULL ; if ( isset ( $ _COOKIE ) && isset ( $ _COOKIE [ $ name ] ) ) { $ retval = $ _COOKIE [ $ name ] ; } return ( $ retval ) ; } | Retrieve data for an existing cookie . |
16,260 | public static function fromString ( $ string , $ separator = ' ' ) { $ string = ( string ) $ string ; if ( $ separator === '' ) { return new StringList ( str_split ( $ string ) , '' ) ; } $ prefix = '' ; $ suffix = '' ; if ( $ string [ 0 ] == $ separator ) { $ prefix = $ separator ; } if ( $ string [ strlen ( $ string ... | Creates a Stringlist from a string . |
16,261 | public function copy ( ) { $ copy = parent :: copy ( ) ; $ copy -> delimiter = $ this -> delimiter ; $ copy -> prefix = $ this -> prefix ; $ copy -> suffix = $ this -> suffix ; return $ copy ; } | Returns a copy |
16,262 | public function onRegister ( Event \ Register $ event ) { $ userModel = $ this -> getServiceLocator ( ) -> get ( 'Grid\User\Model\User\Model' ) ; $ user = $ userModel -> register ( $ event -> getData ( ) ) ; $ event -> setUser ( $ user ) ; if ( is_null ( $ event -> getUser ( ) ) ) { $ event -> stopPropagation ( true ) ... | Handles register event |
16,263 | public function onSave ( Event \ Save $ event ) { $ success = $ event -> getUser ( ) -> save ( ) ; $ event -> setResult ( ( bool ) $ success ) ; if ( $ event -> getResult ( ) === false ) { $ event -> stopPropagation ( true ) ; } return $ event ; } | Handles save event |
16,264 | public function onDelete ( Event \ Delete $ event ) { $ success = $ event -> getUser ( ) -> delete ( ) ; $ event -> setResult ( ( bool ) $ success ) ; if ( $ event -> getResult ( ) === false ) { $ event -> stopPropagation ( true ) ; } return $ event ; } | Handles delete event |
16,265 | public function run ( callable $ applicationThick ) { try { $ promiseManager = $ this -> getContainerManager ( ) -> getContainer ( ) -> get ( PromiseManager :: class ) ; $ promiseManager -> addPromise ( 'shutdown' , function ( ) { ShutdownPromisePool :: callAllPromises ( ) ; } ) ; $ applicationThick ( ) ; RouterStore :... | Run the App |
16,266 | public function setPath ( string $ appRoot ) { $ this -> path = new Path ( $ appRoot , $ this -> coreRoot ) ; $ this -> containerManager -> getContainer ( ) -> instance ( Path :: class , $ this -> path ) ; } | Set path instance by App |
16,267 | public function env ( string $ var , $ default = null ) { $ value = getenv ( $ var ) ?? null ; if ( $ value === false ) { return $ default instanceof Closure ? $ default ( ) : $ default ; } switch ( strtolower ( $ value ) ) { case 'true' : case '(true)' : return true ; case 'false' : case '(false)' : return false ; cas... | Accessor to environment vars |
16,268 | protected function initServiceContainer ( Container $ container ) { $ sr = new ServiceRegistrator ( $ this -> coreRoot , "Wpci\\Core\\" , $ container ) ; $ sr -> exclude ( Path :: class ) ; $ sr -> prepareArguments ( View :: class , [ TemplateInterface :: class => MustacheTemplate :: class , ResponseInterface :: class ... | Service container inti instructions |
16,269 | final protected function isCollectionClass ( $ collectionItem ) { if ( is_null ( $ this -> collectionClass ) ) { return true ; } else { return is_a ( $ collectionItem , $ this -> collectionClass -> getValue ( ) ) ; } } | Checks if a proposed collection item is the correct collection item class . |
16,270 | final protected function setCollectionClass ( $ class ) { try { $ this -> collectionClass = new StringType ( $ class ) ; } catch ( TypeValidationException $ e ) { $ this -> collectionClass = CollectionConstants :: _UNMAPPABLE_CLASS ; } catch ( ValueOutOfBoundsException $ e ) { $ this -> collectionClass = CollectionCons... | Sets the expected class for the collection s items . |
16,271 | public function log ( $ message , $ level , array $ context = array ( ) ) { $ return = true ; if ( ! isset ( self :: $ levels [ $ level ] ) ) { throw new \ OutOfBoundsException ( 'Log level invalid' ) ; } if ( ( int ) $ level <= $ this -> level ) { $ message = sprintf ( $ this -> logFormat . PHP_EOL , date ( $ this -> ... | Writes a log message of a given level . |
16,272 | public function showAction ( $ id ) { $ acl = $ this -> get ( 'bacon_acl.service.authorization' ) ; if ( ! $ acl -> authorize ( 'users' , 'SHOW' ) ) { throw $ this -> createAccessDeniedException ( ) ; } $ breadcumbs = $ this -> container -> get ( 'bacon_breadcrumbs' ) ; $ breadcumbs -> addItem ( array ( 'title' => 'Use... | Finds and displays a User entity . |
16,273 | public function getUser ( ) { if ( null === $ this -> user && $ this -> isLogin ( ) ) { $ username = Base :: instance ( ) -> get ( static :: SESSION_USER ) ; $ this -> user = Security :: instance ( ) -> getUserProvider ( ) -> loadByUsername ( $ username ) ; try { Authentication :: instance ( ) -> checkUser ( $ this -> ... | Get user load from session if needed |
16,274 | public function setUri ( $ uri ) { $ uri = ( string ) $ uri ; if ( empty ( $ uri ) ) { $ uri = '#' ; } else if ( ! preg_match ( '(^(' . static :: VALID_SCHEMES . '))' , $ uri ) ) { if ( preg_match ( '(^[a-z0-9-]+(\.[a-z0-9-]+)+(/.*)?$)' , $ uri ) ) { $ uri = static :: DEFAULT_SCHEME . $ uri ; } else { $ uri = '/' . ltr... | Setter for uri |
16,275 | public static function buildDeleteRelationQuery ( Relation $ relation ) { $ query = "DELETE FROM `" . $ relation -> getTable ( ) . "` " ; $ query .= "WHERE " . $ relation -> getLocalColumn ( ) . " = :id;" ; return $ query ; } | Build a delete query for a relation . |
16,276 | public static function buildRelationQuery ( $ entity , Relation $ relation ) { $ relQuery = "" ; $ getid = "getId" ; if ( $ relation -> getCardinality ( ) == Relation :: $ manyToMany ) { $ m = "get" . $ relation -> getName ( ) ; $ relQuery .= "INSERT INTO " . $ relation -> getTable ( ) . " (" . $ relation -> getLocalCo... | Return the insert relation query . |
16,277 | public static function buildUpdateQuery ( $ entity , Mapper $ mapper ) { $ fields = "" ; foreach ( $ mapper -> getPropertys ( ) as $ property ) { if ( $ property -> getColumn ( ) != "id" ) { $ method = "get" . $ property -> getName ( ) ; $ entity -> $ method ( ) ; if ( $ property -> isNumeric ( ) ) { $ fieldValue = "`=... | Return the update query for the entity . |
16,278 | public static function buildSelectRelation ( $ relation , $ mapperRelation ) { $ query = "" ; $ fields = "" ; foreach ( $ mapperRelation -> getPropertys ( ) as $ property ) { $ fields .= "c." . $ property -> getColumn ( ) . ", " ; } $ fields = substr_replace ( $ fields , "" , - 2 ) ; if ( $ relation -> getCardinality (... | Get the query for select the related entitys . |
16,279 | public function getData ( $ key , $ fetcher = self :: DEFAULT_FETCHER_NAME ) { return $ this -> getDataFetcher ( $ fetcher ) -> getData ( $ key ) ; } | Get real substitution data |
16,280 | public static function getCurrentIP ( ) { $ ip = '' ; foreach ( [ 'HTTP_CLIENT_IP' , 'HTTP_X_FORWARDED_FOR' , 'HTTP_X_FORWARDED' , 'HTTP_X_CLUSTER_CLIENT_IP' , 'HTTP_FORWARDED_FOR' , 'HTTP_FORWARDED' , 'REMOTE_ADDR' ] as $ headerKey ) { if ( $ item = getenv ( $ headerKey ) ) { foreach ( array_filter ( explode ( ',' , $... | Gets the current IP address |
16,281 | public function renderMethod ( MethodInterface $ method ) { if ( ! $ method -> supports ( MethodInterface :: BROWSER_PLATFORM ) ) { throw new \ InvalidArgumentException ( 'Renderer only accepts browser methods.' ) ; } return 'window.analytics.' . $ method -> getName ( ) . '(' . $ this -> renderArguments ( $ method ) . ... | Renders the library method . |
16,282 | public function renderPage ( $ name = null , $ category = null , array $ properties = array ( ) ) { return $ this -> renderMethod ( new PageMethod ( $ name , $ category , $ properties ) ) ; } | Renders a page method . |
16,283 | public function renderQueue ( Queue $ queue ) { $ render = '' ; while ( $ method = $ queue -> dequeue ( MethodInterface :: BROWSER_PLATFORM ) ) { $ render .= $ this -> renderMethod ( $ method ) . "\n" ; } return trim ( $ render ) ; } | Renders a queue of library methods . |
16,284 | private function renderArgument ( $ argument ) { if ( is_array ( $ argument ) ) { $ argument = json_encode ( $ argument ) ; } elseif ( null === $ argument ) { $ argument = 'null' ; } elseif ( is_string ( $ argument ) ) { $ argument = '"' . $ argument . '"' ; } return $ argument ; } | Renders a method argument . |
16,285 | public static function identity ( $ type = Matrix44 :: class ) : Matrix { $ matrix = new $ type ( ) ; for ( $ i = 0 ; $ i < $ type :: ROWS ; $ i ++ ) { for ( $ j = 0 ; $ j < $ type :: COLUMNS ; $ j ++ ) { $ matrix [ $ i ] [ $ j ] = $ i === $ j ? 1 : 0 ; } } return $ matrix ; } | Create an identity matrix of given matrix type . |
16,286 | public static function mul ( Matrix $ matrix , $ value ) : Matrix { if ( $ value instanceof Matrix ) { return self :: mulMatrix ( $ matrix , $ value ) ; } if ( is_numeric ( $ value ) ) { return self :: mulScalar ( $ matrix , $ value ) ; } $ type = gettype ( $ value ) ; throw new InvalidArgumentException ( "Invalid type... | Matrix multiplication . |
16,287 | public static function mulScalar ( Matrix $ matrix , float $ scalar ) : Matrix { $ type = get_class ( $ matrix ) ; $ result = new $ type ( ) ; for ( $ i = 0 ; $ i < $ type :: ROWS ; $ i ++ ) { for ( $ j = 0 ; $ j < $ type :: COLUMNS ; $ j ++ ) { $ result [ $ i ] [ $ j ] = $ matrix [ $ i ] [ $ j ] * $ scalar ; } } retur... | Matrix scalar multiplication . |
16,288 | public static function add ( Matrix $ matrix , Matrix $ matrix2 ) : Matrix { $ type = get_class ( $ matrix ) ; $ type2 = get_class ( $ matrix2 ) ; if ( $ type !== $ type2 ) { throw new InvalidArgumentException ( "Can only add matrices of same size." ) ; } $ result = new $ type ( ) ; for ( $ i = 0 ; $ i < $ type :: ROWS... | Matrix Matrix addition . |
16,289 | public static function makeRotationX ( float $ angle , string $ type = Math :: DEGREES ) : Matrix33 { if ( $ type === Math :: DEGREES ) { $ angle = Math :: degToRad ( $ angle ) ; } return new Matrix33 ( 1 , 0 , 0 , 0 , cos ( $ angle ) , - sin ( $ angle ) , 0 , sin ( $ angle ) , cos ( $ angle ) ) ; } | Create a rotation matrix with given X angle rotation . |
16,290 | public static function pickAppDir ( $ path ) { if ( $ path [ 0 ] !== '/' ) return $ path ; $ root = null ; foreach ( self :: $ namespaces as $ p => $ ns ) { if ( strpos ( $ path , $ p ) === 0 ) { if ( $ root === null || strlen ( $ root ) < strlen ( $ p ) ) $ root = $ p ; } } return $ root ? $ root : $ path ; } | pick the app dir from some path . |
16,291 | public static function pickRootDir ( $ path ) { if ( $ path [ 0 ] !== '/' ) return $ path ; $ f = function ( $ names , $ count ) { for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { array_pop ( $ names ) ; } return $ names ; } ; $ root = null ; foreach ( self :: $ namespaces as $ p => $ ns ) { $ d = join ( DS , $ f ( explode (... | pick the root dir from some path . |
16,292 | public static function getNamespaceByPath ( $ path , $ is_dir = true ) { if ( $ path [ 0 ] !== '/' ) return null ; $ root_ns = '' ; $ filepath = $ path ; foreach ( self :: $ namespaces as $ p => $ ns ) { if ( strpos ( $ path , $ p ) !== false ) { $ root_ns = $ ns ; $ filepath = substr ( $ path , strlen ( $ p ) + 1 ) ; ... | get namespace by filepath |
16,293 | public function rest_api_init ( $ server ) { register_rest_route ( 'sekisyo/v1' , 'license/(?P<guid>[^/]+)/?' , [ [ 'methods' => 'POST' , 'callback' => [ $ this , 'handle_rest_post' ] , 'args' => [ 'guid' => [ 'required' => true , ] , 'license' => [ 'required' => true , ] , ] , 'permission_callback' => function ( $ req... | Handle API request |
16,294 | public function check_validity ( ) { foreach ( $ this -> plugins as $ plugin ) { if ( $ plugin -> valid ) { $ plugin -> update_license ( $ plugin -> license , true ) ; if ( ! $ plugin -> fail_limit ) { continue ; } do_action ( 'sekisyo_update_error' , $ plugin -> guid , $ plugin -> failed , $ plugin ) ; if ( $ plugin -... | Check validity with cron job |
16,295 | public static function get ( $ guid ) { $ instance = self :: get_instance ( ) ; if ( isset ( $ instance -> plugins [ $ guid ] ) ) { return $ instance -> plugins [ $ guid ] ; } else { new \ WP_Error ( sprintf ( __ ( 'Plugin %s is not registered.' , 'sekisyo' ) , $ guid ) , 404 , [ 'status' => 404 , ] ) ; } } | Get plugin instance . |
16,296 | public static function is_valid ( $ guids = [ ] ) { $ instance = self :: get_instance ( ) ; foreach ( $ guids as $ guid ) { if ( isset ( $ instance -> plugins [ $ guid ] ) && $ instance -> plugins [ $ guid ] -> valid ) { return true ; } } return false ; } | Detect if this plugin is valid |
16,297 | public function addMetaBoxes ( ) { $ this -> metaBoxes -> rewind ( ) ; while ( $ this -> metaBoxes -> valid ( ) ) { $ metaBox = $ this -> metaBoxes -> current ( ) ; foreach ( $ metaBox -> getSupportedPostTypes ( ) as $ postType ) { add_meta_box ( $ metaBox -> getID ( ) , $ metaBox -> getTitle ( ) , array ( $ metaBox , ... | Registers all the meta boxes added |
16,298 | public static function set ( Grid $ grid , Tile $ tile ) { $ rows = $ grid -> rows - $ tile -> height + 1 ; $ columns = $ grid -> columns - $ tile -> width + 1 ; $ row = rand ( 0 , $ rows - 1 ) ; $ column = rand ( 0 , $ columns - 1 ) ; $ initialRow = $ row ; $ initialColumn = $ column ; while ( ! $ grid -> isEmptyForTi... | Set a tile randomly within a grid . |
16,299 | public static function tryToFill ( Grid $ grid , Distribution $ distribution ) { $ smallTiles = $ distribution -> small ; $ tallTiles = $ distribution -> tall ; $ wideTiles = $ distribution -> wide ; for ( $ i = 0 ; $ i < $ distribution -> getTiles ( ) ; $ i ++ ) { if ( $ wideTiles === 0 && $ tallTiles === 0 ) { static... | Fill a tiles distribution randomly within a grid . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.