idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
55,300 | public static function encode ( $ data ) { if ( ! is_string ( $ data ) ) { throw new InvalidArgumentException ( 'data must be string' ) ; } $ encodedData = parent :: encode ( $ data ) ; return rtrim ( strtr ( $ encodedData , '+/' , '-_' ) , '=' ) ; } | Encode to base64url . |
55,301 | public static function decode ( $ data ) { if ( ! is_string ( $ data ) ) { throw new InvalidArgumentException ( 'data must be string' ) ; } $ convertedData = strtr ( $ data , '-_' , '+/' ) ; switch ( strlen ( $ convertedData ) % 4 ) { case 0 : break ; case 2 : $ convertedData .= '==' ; break ; case 3 : $ convertedData ... | Decode base64url . |
55,302 | public function getEnabledProjects ( ) { return array_filter ( $ this -> codex -> projects -> all ( ) , function ( Project $ project ) { return $ project -> config ( 'git.enabled' , false ) === true ; } ) ; } | Get all projects that have the git addon enabled . |
55,303 | public function set ( $ name , $ value ) { if ( ! is_string ( $ name ) ) { throw new \ Exception ( "Invalid configuration key." ) ; } $ this -> config [ $ name ] = $ value ; } | Set a setting on configuration object |
55,304 | public function get ( $ name , $ default = null ) { if ( empty ( $ default ) && ! $ this -> exists ( $ name ) ) { throw new \ Exception ( "Configuration Missing: '$name' is not defined." ) ; } return $ this -> exists ( $ name ) ? $ this -> prepare ( $ this -> config [ $ name ] , $ name ) : $ default ; } | Get a setting from configuration object |
55,305 | public function getSection ( $ targetSection ) { $ config = array ( ) ; foreach ( $ this -> config as $ key => $ value ) { if ( substr ( $ key , 0 , strlen ( $ targetSection ) ) . "." == "$targetSection." ) { $ varname = strpos ( $ key , '.' ) !== false ? ltrim ( substr ( $ key , strlen ( $ targetSection ) ) , '.' ) : ... | Returns a collection of configurations by its section prefix |
55,306 | private function loadFromArray ( $ configList ) { foreach ( $ configList as $ section => $ config ) { foreach ( $ config as $ key => $ value ) { $ this -> set ( $ section . '.' . $ key , $ value ) ; } } } | Loads configuration data from array |
55,307 | public function load ( $ value = null ) { if ( is_array ( $ value ) ) { $ this -> loadFromArray ( $ value ) ; } elseif ( is_string ( $ value ) && file_exists ( $ value ) ) { $ this -> loadFromFile ( $ value ) ; } } | Loads configuration from array or string sources |
55,308 | public function handle ( \ ErrorException $ exception , array $ context ) { $ levels = array_flip ( $ this -> sevirity ) ; $ sevirity = $ exception -> getSeverity ( ) ; if ( ! in_array ( $ sevirity , $ levels ) ) { $ sevirity = 9802 ; } $ sevirities = array_slice ( $ levels , $ levels [ $ this -> level ] - 9809 , null ... | Handle the log request by deciding the severity and if we should log it or not Unknown severities will become alerts |
55,309 | private function setAutoMode ( $ val ) { $ this -> _defaultBehaviour = $ val ; $ _SESSION [ $ this -> _sessionAutoName ] = $ this -> _defaultBehaviour ; } | Sets the auto mode on or off |
55,310 | function fromString ( $ modStr ) { $ this -> _reset ( ) ; if ( strpos ( $ modStr , 'b' ) !== false ) { $ this -> asBinary ( ) ; $ modStr = str_replace ( 'b' , '' , $ modStr ) ; } $ modXXX = array_search ( strtolower ( $ modStr ) , $ this -> mode_available ) ; $ modXXX = ( $ modXXX !== false ) ? $ modXXX : strtoupper ( ... | Set From String |
55,311 | function openForWrite ( ) { $ this -> mode_xxx [ 'write' ] = 'W' ; if ( ! $ this -> hasCreate ( ) && ! $ this -> hasXCreate ( ) ) $ this -> createFile ( ) ; return $ this ; } | Open File For Write |
55,312 | function toString ( ) { $ ModeXXX = implode ( '' , $ this -> mode_xxx ) ; if ( ! array_key_exists ( $ ModeXXX , $ this -> mode_available ) ) throw new \ Exception ( sprintf ( 'Invalid Open Mode Statement (%s). it`s must readable/writable or both with optional flags.' . ' like: r+, W, rb+, ...' , $ ModeXXX ) ) ; $ mode ... | Get Access Mode As String |
55,313 | public function setGearmanHost ( string $ hostname ) : void { if ( empty ( $ hostname ) ) { throw new ManagerException ( 'Hostname can not be empty.' ) ; } $ this -> gearmanHost = $ hostname ; } | Sets the Gearman hostname . |
55,314 | public function setGearmanPort ( int $ port ) : void { if ( $ port < 1 || $ port > 65535 ) { throw new ManagerException ( 'Invalid port number.' ) ; } $ this -> gearmanPort = $ port ; } | Sets Gearman server port . |
55,315 | public function setLogPath ( string $ logPath ) : void { if ( ! file_exists ( $ logPath ) ) { throw new ManagerException ( 'Invalid log path. Folder not found.' ) ; } $ this -> logPath = $ logPath ; } | Sets path to log folder . |
55,316 | public function setRunPath ( string $ runPath ) : void { if ( ! file_exists ( $ runPath ) ) { throw new ManagerException ( 'Invalid run path. Folder not found.' ) ; } $ this -> runPath = $ runPath ; } | Sets path to run folder . |
55,317 | public function setConfigPath ( string $ configPath ) : void { if ( ! file_exists ( $ configPath ) ) { throw new ManagerException ( 'Invalid config path. File not found.' ) ; } $ this -> configPath = $ configPath ; } | Sets path to config file . |
55,318 | public function start ( string $ poolOnly = '' ) : void { $ this -> reloadPids ( ) ; foreach ( $ this -> poolsConfig as $ pool => $ workerConfig ) { if ( ! empty ( $ poolOnly ) && $ poolOnly !== $ pool ) { continue ; } if ( ! empty ( $ this -> pids [ $ pool ] ) ) { continue ; } for ( $ i = 0 ; $ i < $ workerConfig [ 'i... | Startup workers . |
55,319 | public function restart ( $ workerId = '' ) : void { $ this -> stop ( $ workerId ) ; sleep ( 2 ) ; $ this -> start ( $ workerId ) ; } | Restart workers . |
55,320 | public function status ( ) : array { $ this -> reloadPids ( ) ; $ workerStatus = [ ] ; if ( empty ( $ this -> pids ) ) { return $ workerStatus ; } $ Client = new \ GearmanClient ( ) ; $ Client -> addServer ( $ this -> gearmanHost , $ this -> gearmanPort ) ; $ Client -> setTimeout ( 1000 ) ; foreach ( $ this -> pids as ... | Pings every worker and displays result . |
55,321 | public function keepalive ( ) : bool { $ this -> reloadPids ( ) ; if ( $ this -> managerIsRunning ( ) === true ) { return false ; } if ( empty ( $ this -> pids ) ) { $ this -> start ( ) ; return true ; } $ this -> adjustRunningWorkers ( ) ; $ this -> reloadPids ( ) ; return true ; } | Pings every worker and does a restart if worker is not responding . |
55,322 | protected function startupWorker ( $ pool ) : void { $ workerId = $ this -> getId ( ) ; $ baseCmd = 'php %s --config %s --pool %s --name %s' ; $ launcherPath = __DIR__ . '/cli/worker.php' ; $ startupCmd = sprintf ( $ baseCmd , $ launcherPath , $ this -> getConfigPath ( ) , $ pool , $ workerId ) ; exec ( escapeshellcmd ... | Starts a new worker . |
55,323 | protected function adjustRunningWorkers ( ) : void { foreach ( $ this -> poolsConfig as $ pool => $ workerConfig ) { $ workersActive = count ( $ this -> pids [ $ pool ] ) ; $ workersTarget = ( int ) $ workerConfig [ 'instances' ] ; if ( $ workersActive >= $ workersTarget ) { continue ; } $ workerDiff = $ workersTarget ... | Starts up new workers if there are currently running less workers than required . |
55,324 | protected function loadPids ( ) : void { foreach ( $ this -> poolsConfig as $ pool => $ poolConfig ) { $ pidFiles = glob ( $ this -> runPath . '/' . $ pool . '/*.pid' ) ; foreach ( $ pidFiles as $ pidFile ) { $ workerId = basename ( $ pidFile , '.pid' ) ; $ pid = file_get_contents ( $ pidFile ) ; if ( $ this -> pidIsVa... | Gets the process - ids for all workers . |
55,325 | protected function removePidFileByPid ( int $ pid ) : bool { foreach ( $ this -> pids as $ pool => $ poolPids ) { foreach ( $ poolPids as $ workerId => $ workerPid ) { if ( $ pid !== $ workerPid ) { continue ; } $ pidFile = $ this -> runPath . '/' . $ pool . '/' . $ pid . '.pid' ; return $ this -> removePidFile ( $ pid... | Generates path to file for given pid and removes that file . |
55,326 | protected function managerIsRunning ( ) : bool { global $ argv ; $ cliOutput = [ ] ; exec ( 'ps x | grep ' . $ argv [ 0 ] , $ cliOutput ) ; $ processCount = 0 ; if ( empty ( $ cliOutput ) ) { return false ; } foreach ( $ cliOutput as $ line ) { if ( strpos ( $ line , 'grep' ) !== false ) { continue ; } if ( strpos ( $ ... | Checks if an instance of worker manager is already running . |
55,327 | final protected function executeQuery ( $ sql ) { $ statement = $ this -> connection -> prepare ( $ sql ) ; $ statement -> execute ( ) ; return $ statement -> fetchAll ( ) ; } | Executes an SQL query using the specified doctrine connection name |
55,328 | private function parseCriteria ( array $ criteria ) { $ out = '' ; if ( ! empty ( $ criteria ) ) { $ conditions = [ ] ; foreach ( $ criteria as $ field => $ value ) { if ( is_array ( $ value ) ) { $ values = array_map ( function ( $ value ) { return $ this -> connection -> quote ( $ value ) ; } , $ value ) ; $ conditio... | Parses query criteria into a query string |
55,329 | private function parseSort ( array $ sort ) { $ out = '' ; if ( ! empty ( $ sort ) ) { $ conditions = [ ] ; foreach ( $ sort as $ field => $ direction ) { $ direction = $ direction ? 'DESC' : 'ASC' ; $ conditions [ ] = sprintf ( '%s %s' , $ field , $ direction ) ; } $ out = sprintf ( ' ORDER BY %s' , implode ( ', ' , $... | Parses sort fields into an order by clause |
55,330 | public function init ( $ param = null ) { $ this -> setOptions ( $ param ) ; try { $ this -> readIndexList ( ) ; if ( ! empty ( $ this -> cacheListing ) ) { $ this -> loadCache ( ) ; } $ this -> setConnected ( true ) ; } catch ( CacheException $ e ) { throw $ e ; } return true ; } | initializes the cache |
55,331 | protected function loadCache ( ) { if ( empty ( $ this -> cacheListing ) ) return false ; foreach ( $ this -> cacheListing as $ key => $ entry ) { if ( ! $ entry ) { continue ; } if ( ! ( $ entry instanceof Entry ) ) { unset ( $ entry ) ; continue ; } if ( ! $ entry -> getId ( ) ) { unset ( $ this -> cacheListing [ $ k... | load all the items into the current memory for faster access |
55,332 | public function get ( $ key = null ) { if ( ! isset ( $ this -> list [ $ key ] ) ) return null ; $ this -> currentIdentifier = $ this -> cacheListing [ $ key ] -> getId ( ) ; return $ this -> list [ $ key ] ; } | Gets a cache entry by key |
55,333 | public function set ( $ key , $ value = null , $ expiration = 0 ) { if ( empty ( $ key ) ) return false ; if ( isset ( $ this -> list [ $ key ] ) ) { if ( ! $ this -> list [ $ key ] == $ value ) return true ; $ this -> list [ $ key ] = $ value ; $ this -> cacheListing [ $ key ] -> data = $ value ; $ this -> cacheListin... | Sets a cache entry by key |
55,334 | public function flush ( ) { if ( ! empty ( $ this -> cacheListing ) ) { foreach ( $ this -> cacheListing as $ entry ) { if ( $ entry instanceof Entry ) { $ entry -> delete ( ) ; } } $ this -> cacheListing = array ( ) ; } @ shmop_delete ( $ this -> indexIdentifier ) ; return true ; } | deletes the whole cache |
55,335 | public function delete ( $ key , $ time = 0 ) { if ( empty ( $ key ) || empty ( $ this -> cacheListing [ $ key ] ) ) return true ; $ entry = $ this -> cacheListing [ $ key ] ; $ entry -> delete ( ) ; unset ( $ this -> cacheListing [ $ key ] ) ; return true ; } | delete a cache entry |
55,336 | public function deleteFromList ( $ key_array = array ( ) ) { if ( empty ( $ key_array ) ) return true ; foreach ( $ key_array as $ key ) { if ( ! isset ( $ this -> cacheListing [ $ key ] ) ) continue ; $ entry = $ this -> cacheListing [ $ key ] ; $ entry -> delete ( ) ; unset ( $ this -> cacheListing [ $ key ] ) ; } re... | cleans up the cache list |
55,337 | public function getConnectionString ( ) { $ dsn = 'mysql:' ; $ connectionSettings = $ this -> getConnectionSettings ( ) ; if ( $ this -> isSocket ( ) ) { $ dsn .= ( string ) 'unix_socket=' . $ connectionSettings -> getHost ( ) . ';' ; } else { $ dsn .= ( string ) 'host=' . $ connectionSettings -> getHost ( ) . ';' ; if... | simplifaction for connection strings |
55,338 | public function getRootPages ( ) : array { return $ this -> connection -> createQueryBuilder ( ) -> select ( 'language' , 'id' , 'fallback' ) -> from ( 'tl_page' ) -> where ( 'type=:type' ) -> setParameter ( 'type' , 'root' ) -> orderBy ( 'fallback' ) -> addOrderBy ( 'sorting' ) -> execute ( ) -> fetchAll ( \ PDO :: FE... | Fetch the root pages from the database . |
55,339 | public function getPagesByPidList ( array $ pidList ) : array { return $ this -> connection -> createQueryBuilder ( ) -> select ( 'id' , 'pid' , 'languageMain' , 'type' ) -> from ( 'tl_page' ) -> where ( 'pid IN (:lookupQueue)' ) -> setParameter ( 'lookupQueue' , $ pidList , Connection :: PARAM_INT_ARRAY ) -> orderBy (... | Fetch pages by pids . |
55,340 | public function getArticlesByPid ( int $ pageId , string $ inColumn = null ) : array { $ builder = $ this -> connection -> createQueryBuilder ( ) -> select ( 'id' , 'pid' , 'inColumn' , 'languageMain' ) -> from ( 'tl_article' ) -> where ( 'pid=:pid' ) -> setParameter ( 'pid' , $ pageId ) -> orderBy ( 'inColumn' ) -> ad... | Fetch articles by pid . |
55,341 | public function getContentByPidFrom ( int $ articleId , string $ pTable ) : array { $ result = $ this -> connection -> createQueryBuilder ( ) -> select ( 'id' , 'type' ) -> from ( 'tl_content' ) -> where ( 'pid=:pid' ) -> setParameter ( 'pid' , $ articleId ) -> andWhere ( 'ptable=:ptable' ) -> setParameter ( 'ptable' ,... | Fetch all content elements from an article . |
55,342 | public function getListClassNames ( ) { $ classes = parent :: getListClassNames ( ) ; if ( $ this -> hasFontIcon ( ) && $ this -> ShowIcons ) { $ classes [ ] = 'fa-ul' ; } return $ classes ; } | Answers an array of list class names for the HTML template . |
55,343 | public function get ( $ page = 1 ) { $ index = $ page - 1 ; if ( ! isset ( $ this -> pages [ $ index ] ) ) { throw new RuntimeException ( sprintf ( 'Invalid page %s of %s' , $ page , $ this -> count ( ) ) ) ; } return $ this -> pages [ $ index ] ; } | Get contents for the given page |
55,344 | function validate ( ) { if ( $ this -> end && $ this -> start ) { parent :: validate ( ) ; } else { if ( $ this -> end ) { throw new Exception ( "Class {$this->getName()} contains no targets for @Start." ) ; } else { throw new Exception ( "Class {$this->getName()} contains no targets for @End." ) ; } } } | Validates the relation object making sure it has a start and an end property . |
55,345 | function findProperty ( $ name ) { $ property = Reflection :: getProperty ( $ name ) ; if ( $ this -> start -> matches ( $ property ) ) { return $ this -> start ; } if ( $ this -> end -> matches ( $ property ) ) { return $ this -> end ; } return parent :: findProperty ( $ name ) ; } | Find properties based on a method name . |
55,346 | public function render ( $ zoneName , array $ parameters = array ( ) ) { $ context = $ this -> contextStack -> getCurrent ( ) ; $ template = $ context -> getTemplate ( ) ; $ zoneType = $ template -> getTemplateType ( ) -> getZoneTypes ( ) -> search ( array ( 'name' => $ zoneName ) ) -> first ( ) ; if ( ! $ zoneType ) {... | Render given zone name on current Synapse context . |
55,347 | public function get ( $ path ) { assert ( is_string ( $ path ) ) ; if ( $ this -> filesystem -> listContents ( $ path ) ) { return new Directory ( $ this , $ path ) ; } try { $ info = $ this -> filesystem -> getMetadata ( $ path ) ; if ( $ info ) { if ( $ info [ "type" ] == "file" ) { return new File ( $ this , $ path ... | Get an object from the filesystem based on its path . |
55,348 | private function file_or_dir ( $ path , $ is_file ) { assert ( is_bool ( $ is_file ) ) ; $ obj = $ this -> get ( $ path ) ; if ( $ obj !== null && $ is_file === $ obj -> isFile ( ) ) { return $ obj ; } return null ; } | Get an object from fs that either is as file or a dir . |
55,349 | public function newFDirectory ( FSObject $ fs_object , \ Closure $ contents_lazy ) { $ fdir = new FDirectory ( $ fs_object , $ contents_lazy ) ; if ( $ this -> strict_evaluation ) { $ fdir -> fcontents ( ) ; } return $ fdir ; } | Create an FDirectory with metadata from some FSObject and some content that could be lazily produced by some function . |
55,350 | private function createIndex ( ) { $ basepath = $ this -> config [ "basePath" ] ; $ pattern = $ this -> config [ "pattern" ] ; $ path = "$basepath/$pattern" ; $ index = [ ] ; foreach ( glob_recursive ( $ path ) as $ file ) { $ filepath = substr ( $ file , strlen ( $ basepath ) + 1 ) ; $ matches = [ ] ; preg_match ( $ t... | Generate an index from the directory structure . |
55,351 | private function getFrontmatter ( $ file ) { $ basepath = $ this -> config [ "basePath" ] ; $ filter1 = $ this -> config [ "textfilter-frontmatter" ] ; $ filter2 = $ this -> config [ "textfilter-title" ] ; $ filter = array_merge ( $ filter1 , $ filter2 ) ; $ path = $ basepath . "/" . $ file ; $ src = file_get_contents ... | Get the frontmatter of a document . |
55,352 | private function loadFileContentPhaseOne ( $ key ) { $ basepath = $ this -> config [ "basePath" ] ; $ filter = $ this -> config [ "textfilter-frontmatter" ] ; $ path = $ basepath . "/" . $ this -> index [ $ key ] [ "file" ] ; if ( ! is_file ( $ path ) ) { $ msg = t ( "The content '!ROUTE' does not exists as a file '!FI... | Load content file and frontmatter this is the first time we process the content . |
55,353 | public static function calcularParcelamento ( $ capital , $ taxa , $ tempo , $ semjuros ) { $ parcelamento = array ( ) ; for ( $ i = 1 ; $ i <= $ tempo ; $ i ++ ) { $ m = $ capital * pow ( ( 1 + $ taxa / 100 ) , $ i ) ; if ( $ i <= $ semjuros ) { $ parcelamento [ $ i ] = array ( 'parcela' => self :: formataValor ( ( $ ... | Calculo de Parcelamento |
55,354 | public static function getValorParcela ( $ total , $ parcela , $ taxa ) { if ( ! is_numeric ( $ total ) || $ total <= 0 ) { return ( false ) ; } if ( ( int ) $ parcela != $ parcela ) { return ( false ) ; } if ( ! is_numeric ( $ taxa ) || $ taxa < 0 ) { return ( false ) ; } $ taxa = $ taxa / 100 ; $ denominador = 0 ; if... | Retorna o valor da parcela |
55,355 | protected function getPathFromContent ( ) { $ pathFromContent = str_replace ( $ this -> getPathToContent ( ) , '' , $ this -> getFile ( ) -> getRealPath ( ) ) ; return trim ( $ pathFromContent , DIRECTORY_SEPARATOR ) ; } | Returns the path relative to the content directory |
55,356 | protected function getPathToContent ( ) { $ reverseContentPath = $ this -> getReverseContentPath ( ) ; $ contentPathParts = array_reverse ( explode ( DIRECTORY_SEPARATOR , $ reverseContentPath ) ) ; $ pathToContent = trim ( implode ( DIRECTORY_SEPARATOR , $ contentPathParts ) , DIRECTORY_SEPARATOR ) ; return DIRECTORY_... | Detects the path to content directory by examining the path to the file |
55,357 | public static function inspect ( array $ args , $ raw = false , $ callback = null ) { $ process = self :: runCommand ( 'inspect' , $ args , $ callback ) ; if ( $ process -> isSuccessful ( ) && ! $ raw ) { $ decoded = json_decode ( $ process -> getOutput ( ) ) ; return reset ( $ decoded ) ; } return $ process ; } | Return low - level information on a container or image . |
55,358 | public function delete ( $ resource ) { $ event = $ this -> createResourceEvent ( $ resource ) ; $ this -> dispatcher -> dispatch ( $ this -> config -> getEventName ( 'pre_delete' ) , $ event ) ; if ( ! $ event -> isPropagationStopped ( ) ) { $ this -> removeResource ( $ event ) ; $ this -> dispatcher -> dispatch ( $ t... | Deletes the resource . |
55,359 | public function message ( $ message , $ level = 'info' ) { $ this -> session -> create ( 'flash_notification.message' , $ message ) ; $ this -> session -> create ( 'flash_notification.level' , $ level ) ; } | To show flash message with twitter bootstrap alert - info |
55,360 | public function overlay ( $ title , $ message , $ submitbutton = false , $ allowText = 'Save' , $ allowType = 'success' , $ dismissText = 'Close' , $ dismissType = 'default' ) { $ this -> message ( $ message ) ; $ this -> session -> create ( 'flash_notification.title' , $ title ) ; $ this -> session -> create ( 'flash_... | To show flash message with twitter bootstrap model |
55,361 | public function getStatement ( string $ query_string ) : ResultSet { if ( ! $ this -> is_connected ) { $ this -> connect ( ) ; } $ stmt = $ this -> dbconn -> prepare ( $ query_string ) ; if ( false === $ stmt ) { throw new DatabaseQueryException ( 'The query could not be prepared. | ' . $ query_string . ' | ' . $ this ... | Returns a statement object representing a prepared statement for the database . |
55,362 | protected function _nameConvert ( $ string ) { if ( strpos ( $ string , 'HTTP_' ) !== false ) { $ string = substr ( $ string , \ strlen ( 'HTTP_' ) ) ; } else { return false ; } $ arr_char = explode ( '_' , strtolower ( $ string ) ) ; $ newString = array_shift ( $ arr_char ) ; foreach ( $ arr_char as $ val ) { $ newStr... | HTTP_USER_AGENT = > userAgent |
55,363 | public function getIp ( ) { $ ip = '' ; if ( $ _SERVER [ 'REMOTE_ADDR' ] ) { $ ip = $ _SERVER [ 'REMOTE_ADDR' ] ; } elseif ( getenv ( 'HTTP_CLIENT_IP' ) ) { $ ip = getenv ( 'HTTP_CLIENT_IP' ) ; } elseif ( getenv ( 'HTTP_X_FORWARDED_FOR' ) ) { $ ip = getenv ( 'HTTP_X_FORWARDED_FOR' ) ; } elseif ( getenv ( 'HTTP_X_FORWAR... | get client Ip |
55,364 | protected function normalize ( ) { $ val = $ this -> base [ 'value' ] ; if ( $ val ) { switch ( $ this -> base [ 'return_format' ] ) { case 'array' : $ this -> atId = $ val [ 'ID' ] ; $ this -> atUrl = $ val [ 'url' ] ; $ this -> atTitle = $ val [ 'title' ] ; $ this -> atCaption = $ val [ 'caption' ] ; $ this -> atDesc... | Normalize attachment data depending on how the underlying field is configured . |
55,365 | protected function getTemplate ( $ tpl , $ outputtype = '' , $ trusted = true ) { $ tpl = $ this -> config -> templatePath . $ tpl ; if ( $ outputtype == '' ) { $ outputtype = 'html' ; } $ cachefile = dirname ( $ this -> _templateName ) . '/' ; if ( $ cachefile == './' ) { $ cachefile = '' ; } if ( $ this -> config -> ... | include the compiled template file and call one of the generated function . |
55,366 | public function make ( \ ReflectionProperty $ reflectionParameter ) { if ( ! $ this -> parser ) { throw new \ RuntimeException ( "Missing the parser Parser!" ) ; } $ result = $ this -> parser -> parse ( $ reflectionParameter -> getDocComment ( ) ) ; if ( ! $ result ) { return [ ] ; } $ validatorSet = [ ] ; $ this -> mi... | returns null if there is no result from the parser |
55,367 | public static function joinPaths ( $ path1 , $ path2 ) { $ abspath = $ path1 [ 0 ] == '/' ; $ paths = array_filter ( func_get_args ( ) ) ; $ paths = array_map ( function ( $ path ) { $ path = preg_replace ( '%^/%' , '' , $ path ) ; $ path = preg_replace ( '%/$%' , '' , $ path ) ; return $ path ; } , $ paths ) ; $ path ... | Joins two paths together . Works for operating system paths or for URLs . |
55,368 | public static function uniqueFilename ( $ basepath , $ prefix = '' , $ suffix = '' ) { $ filename = $ prefix ; while ( $ filename == $ prefix || file_exists ( self :: joinPaths ( $ basepath , $ filename ) ) ) { for ( $ charnum = 0 ; $ charnum < 30 ; $ charnum ++ ) { $ ascii = 48 + rand ( 0 , 60 ) ; if ( $ ascii > 57 ) ... | Generates a unique file name in a directory and creates an empty file with this name . |
55,369 | private function configureMenus ( array $ menus , ContainerBuilder $ container ) { if ( ! $ container -> hasDefinition ( 'ekyna_admin.menu.pool' ) ) { return ; } $ pool = $ container -> getDefinition ( 'ekyna_admin.menu.pool' ) ; foreach ( $ menus as $ groupName => $ groupConfig ) { $ pool -> addMethodCall ( 'createGro... | Configures the menus . |
55,370 | protected function waitForSiteByName ( $ site_name ) { return $ this -> retry ( 50 , function ( ) use ( $ site_name ) { $ this -> sites = $ this -> fetchSites ( fp_env ( 'ACACHA_FORGE_SERVER' ) ) ; $ site = $ this -> getSiteByName ( $ this -> sites , $ site_name ) ; return $ site ? $ site : null ; } ) ; } | Wait for site to be available by name! |
55,371 | protected function waitForSite ( $ site_id ) { return $ this -> retry ( 50 , function ( ) use ( $ site_id ) { $ this -> sites = $ this -> fetchSites ( fp_env ( 'ACACHA_FORGE_SERVER' ) ) ; $ site = $ this -> getSite ( $ this -> sites , $ site_id ) ; return $ site -> status == 'installed' ? $ site : null ; } ) ; } | Wait for site to be installed! |
55,372 | public function source ( $ source , $ sourceType = 'local' ) { $ this -> sourcePath = $ source ; $ this -> sourceType = $ sourceType ; return $ this ; } | Set the source file . |
55,373 | protected function parseCsv ( $ filename , ConfigurationInterface $ config ) { $ length = $ config -> getLength ( ) ; $ delimiter = $ config -> getDelimiter ( ) ; $ enclosure = $ config -> getEnclosureChar ( ) ; $ escape = $ config -> getEscapeChar ( ) ; $ result = [ ] ; if ( ( $ handle = fopen ( $ filename , 'r' ) ) !... | Parses CSV file . |
55,374 | protected function populateClasses ( ) { $ this -> classes = [ ] ; $ cData = count ( $ this -> data ) ; for ( $ i = 0 ; $ i < $ cData ; ++ $ i ) { $ data = $ this -> data [ $ i ] ; foreach ( $ data as $ key => $ value ) { if ( array_key_exists ( $ key , $ this -> classes ) ) { if ( array_search ( $ value , $ this -> cl... | Populates classes . |
55,375 | public function add ( array $ options ) { if ( false == empty ( $ options ) ) { $ this -> options = $ this -> options + $ options ; } } | Add new entry in the options . Do not use array_merge as it rewrites the keys . |
55,376 | public function has ( $ name ) { return Arrays :: exists ( $ name , $ this -> options ) && false === empty ( $ this -> options [ $ name ] ) ; } | Check that an entry exists . |
55,377 | public function ampifyImgs ( ) { $ explodedContent = explode ( $ this -> imgSeparator , $ this -> content ) ; $ explodedContent = $ this -> reattachSeparator ( $ explodedContent ) ; $ newContent = [ ] ; foreach ( $ explodedContent as $ value ) { $ srcAttributeExists = preg_match ( "/src=.*>/" , $ value ) ; if ( $ srcAt... | Convert img tags to amp - img specification . |
55,378 | public function reattachSeparator ( $ content ) { $ separator = $ this -> imgSeparator ; $ content = array_map ( function ( $ val ) use ( $ separator ) { if ( preg_match ( '/src=\".+\"/' , $ val ) == 1 ) { return $ separator . $ val ; } else if ( preg_match ( '/src=\".+\"/' , $ val ) == 0 ) { return $ val ; } } , $ con... | Reattach seperator which was lost after the string explosion into an array |
55,379 | public function listenForm ( ) { $ this -> dispatcher -> listen ( 'antares.form: profile.*' , function ( $ name , array $ params = [ ] ) { $ row = $ params [ 0 ] ; $ builder = $ params [ 1 ] ; $ builder -> grid -> fieldset ( function ( Fieldset $ fieldset ) { $ fieldset -> legend ( trans ( 'antares/translations::messag... | Appends account user form with language select field |
55,380 | public function listenFormSave ( ) { $ this -> dispatcher -> listen ( 'eloquent.saved: App\User' , function ( $ model ) { if ( ! is_null ( $ language = Input :: get ( 'language' ) ) ) { $ uid = auth ( ) -> user ( ) -> id ; $ meta = UserMeta :: firstOrNew ( [ 'user_id' => $ uid , 'name' => 'language' ] ) ; $ meta -> val... | Listen for event when user changes language |
55,381 | public static function fromResponseValue ( array $ value , \ PHPUnit_Extensions_Selenium2TestCase_URL $ parentFolder , \ PHPUnit_Extensions_Selenium2TestCase_Driver $ driver ) { if ( ! isset ( $ value [ 'ELEMENT' ] ) ) { throw new \ InvalidArgumentException ( 'Element not found.' ) ; } $ url = $ parentFolder -> descend... | Creates the element object from a value returned by Selenium WebDriver . |
55,382 | public function element ( \ PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $ criteria ) { $ value = $ this -> postCommand ( 'element' , $ criteria ) ; return static :: fromResponseValue ( $ value , $ this -> url -> ascend ( ) , $ this -> driver ) ; } | Finds an element in the scope of this element . |
55,383 | public function elements ( \ PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $ criteria ) { $ values = $ this -> postCommand ( 'elements' , $ criteria ) ; $ elements = array ( ) ; foreach ( $ values as $ value ) { $ elements [ ] = static :: fromResponseValue ( $ value , $ this -> url -> ascend ( ) , $ this -> driv... | Finds elements in the scope of this element . |
55,384 | protected function setExpression ( $ expression ) { if ( is_string ( $ expression ) ) { $ expression = CronExpression :: factory ( $ expression ) ; } elseif ( ! $ expression instanceof CronExpression ) { throw new \ InvalidArgumentException ( 'Expression should be a string or an instanceof CronExpression.' ) ; } $ this... | Set the cron expression . |
55,385 | public function getNextRunDate ( ) { if ( $ this -> nextRunDate === null ) { $ nextRun = $ this -> cronExpression -> getNextRunDate ( ) ; $ this -> nextRunDate = $ nextRun -> getTimestamp ( ) ; } return $ this -> nextRunDate ; } | Returns the timestamp of the next run date . |
55,386 | public function handle ( Authenticatable $ user ) { $ social = $ this -> session -> get ( 'orchestra.oneauth' ) ; if ( is_null ( $ social ) ) { return ; } $ model = User :: where ( 'provider' , '=' , $ social [ 'provider' ] ) -> where ( 'uid' , '=' , $ social [ 'user' ] -> getId ( ) ) -> first ( ) ; if ( is_null ( $ mo... | Handle user logged in . |
55,387 | private static function getMigrationScripts ( int $ start , int $ end , array $ skip ) { return MigrationsManager :: getMigrationsManager ( ) -> getMigrationScripts ( $ start , $ end , $ skip ) ; } | Retrieve the registered migration scripts relevant to the current migration range . |
55,388 | protected function createEndpoints ( ContainerInterface $ container , array $ aliases ) : array { $ result = [ ] ; foreach ( $ aliases as $ alias ) { $ result [ ] = $ container -> get ( $ alias ) ; } return $ result ; } | Creates the fetchers to use . |
55,389 | public static function create ( $ template = 'Response' ) { $ return = null ; switch ( $ template ) { case 'Discovery' : $ return = new AlexaResponse ( new Response ( new Event ( new Header ( ) , new Payload ( ) ) ) ) ; break ; case 'StateReport' : $ return = new AlexaResponse ( new Response ( new Event ( new Header ( ... | Create AlexaResponse skeleton |
55,390 | public function isInsideBlock ( $ blockName , $ onlyUpper = false ) { if ( $ onlyUpper ) { return ( end ( $ this -> _blockStack ) == $ blockName ) ; } for ( $ i = count ( $ this -> _blockStack ) - 1 ; $ i >= 0 ; -- $ i ) { if ( $ this -> _blockStack [ $ i ] == $ blockName ) { return true ; } } return false ; } | for plugins it says if the plugin is inside the given block . |
55,391 | public static function set_db ( $ db , $ connection_name = self :: DEFAULT_CONNECTION ) { self :: _setupDbConfig ( $ connection_name ) ; self :: $ _db [ $ connection_name ] = $ db ; if ( ! is_null ( self :: $ _db [ $ connection_name ] ) ) { self :: _setupIdentifierQuoteCharacter ( $ connection_name ) ; self :: _setupLi... | Set the PDO object used by One to communicate with the database . This is public in case the One should use a ready - instantiated PDO object as its database connection . Accepts an optional string key to identify the connection if multiple connections are used . |
55,392 | protected static function _detectLimitClauseStyle ( $ connection_name ) { switch ( self :: get_db ( $ connection_name ) -> getAttribute ( PDO :: ATTR_DRIVER_NAME ) ) { case 'sqlsrv' : case 'dblib' : case 'mssql' : return One :: LIMIT_STYLE_TOP_N ; default : return One :: LIMIT_STYLE_LIMIT ; } } | Returns a constant after determining the appropriate limit clause style |
55,393 | public static function get_db ( $ connection_name = self :: DEFAULT_CONNECTION ) { self :: _setupDb ( $ connection_name ) ; return self :: $ _db [ $ connection_name ] ; } | Returns the PDO instance used by the the One to communicate with the database . This can be called if any low - level DB access is required outside the class . If multiple connections are used accepts an optional key name for the connection . |
55,394 | public function find_one ( $ id = null ) { if ( ! is_null ( $ id ) ) { $ this -> where_id_is ( $ id ) ; } $ this -> limit ( 1 ) ; $ rows = $ this -> _run ( ) ; if ( empty ( $ rows ) ) { return false ; } return $ this -> _createInstanceFromRow ( $ rows [ 0 ] ) ; } | Tell the One that you are expecting a single result back from your query and execute it . Will return a single instance of the One class or false if no rows were returned . As a shortcut you may supply an ID as a parameter to this method . This will perfOne a primary key lookup on the table . |
55,395 | protected function _callAggregateDbFunction ( $ sqlFunction , $ column ) { $ alias = Inflector :: lower ( $ sqlFunction ) ; $ sqlFunction = Inflector :: upper ( $ sqlFunction ) ; if ( '*' != $ column ) { $ column = $ this -> _quoteIdentifier ( $ column ) ; } $ result_columns = $ this -> _resultColumns ; $ this -> _resu... | Execute an aggregate query on the current connection . |
55,396 | public function raw_query ( $ query , $ parameters = [ ] ) { $ this -> _is_raw_query = true ; $ this -> _raw_query = $ query ; $ this -> _raw_parameters = $ parameters ; return $ this ; } | PerfOne a raw query . The query can contain placeholders in either named or question mark style . If placeholders are used the parameters should be an array of values which will be bound to the placeholders in the query . If this method is called all other query building methods will be ignored . |
55,397 | protected function _addResultColumn ( $ expr , $ alias = null ) { if ( ! is_null ( $ alias ) ) { $ expr .= " AS " . $ this -> _quoteIdentifier ( $ alias ) ; } if ( $ this -> _using_default_resultColumns ) { $ this -> _resultColumns = array ( $ expr ) ; $ this -> _using_default_resultColumns = false ; } else { $ this ->... | Internal method to add an unquoted expression to the set of columns returned by the SELECT query . The second optional argument is the alias to return the expression as . |
55,398 | public function count_null_id_columns ( ) { if ( Arrays :: is ( $ this -> _getIdColumnName ( ) ) ) { return count ( array_filter ( $ this -> id ( ) , 'is_null' ) ) ; } else { return is_null ( $ this -> id ( ) ) ? 1 : 0 ; } } | Counts the number of columns that belong to the primary key and their value is null . |
55,399 | public function select_many_expr ( ) { $ columns = func_get_args ( ) ; if ( ! empty ( $ columns ) ) { $ columns = $ this -> _nOnealiseSelectManyColumns ( $ columns ) ; foreach ( $ columns as $ alias => $ column ) { if ( is_numeric ( $ alias ) ) { $ alias = null ; } $ this -> select_expr ( $ column , $ alias ) ; } } ret... | Add an unquoted expression to the list of columns returned by the SELECT query . Many columns can be supplied as either an array or as a list of parameters to the method . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.