idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
8,700
public function afterLoginRedirect ( ) { $ redirect = $ this -> getRequest ( ) -> query -> get ( 'redirect' , $ this -> Url ( ) -> default ( ) ) ; $ this -> flashRedirect ( $ this -> getModelManager ( ) -> getMessage ( 'login-success' ) , $ redirect , 'success' , 'index' ) ; }
Redirect after login
8,701
protected function setLoginMeta ( $ action ) { $ label = $ this -> getModelManager ( ) -> getLabel ( $ action . '-title' ) ; $ urlMethod = 'get' . ucfirst ( $ action ) . 'URL' ; $ this -> getView ( ) -> Breadcrumbs ( ) -> addItem ( $ label , $ this -> _getUser ( ) -> getManager ( ) -> $ urlMethod ( ) ) ; $ this -> getV...
Set Login Meta
8,702
public function loginWith ( ) { $ providerName = $ _REQUEST [ "provider" ] ; $ redirect = $ _GET [ 'redirect' ] ; $ userProfile = $ this -> getAuthProvider ( ) -> authenticate ( $ providerName ) ; if ( $ userProfile instanceof Exception ) { $ this -> getView ( ) -> set ( 'exception' , $ userProfile ) ; } else { $ userE...
Login with Auth Provider
8,703
public function oAuthLink ( ) { $ providerName = $ _REQUEST [ "provider" ] ; $ userProfile = $ this -> getAuthProvider ( ) -> authenticate ( $ providerName ) ; $ this -> _getUser ( ) -> first_name = $ userProfile -> firstName ; $ this -> _getUser ( ) -> last_name = $ userProfile -> lastName ; $ this -> _getUser ( ) -> ...
Link an OAuth to existing user
8,704
public function profile ( ) { $ formsProfile = $ this -> _getUser ( ) -> getForm ( 'profile' ) ; if ( $ formsProfile -> execute ( ) ) { $ redirect = $ this -> getRequest ( ) -> query -> get ( 'redirect' , $ this -> getModelManager ( ) -> getProfileURL ( ) ) ; $ this -> flashRedirect ( $ this -> getModelManager ( ) -> g...
User Profile Page
8,705
public function cancel ( ) { if ( $ this -> id === null ) { return false ; } $ key = $ this -> queue -> generateListKey ( ) ; $ id = "$key:" . $ this -> id ; $ result = $ this -> queue -> getClient ( ) -> getRedis ( ) -> multi ( ) -> zrem ( $ key ) -> zrem ( $ key . '-scheduled' ) -> del ( $ id ) -> hset ( \ date ( 'Y-...
Cancels a job from executing
8,706
public function retry ( $ backOffTime = null ) { $ retry = $ this -> getRetry ( ) ; $ this -> queue -> getClient ( ) -> getRedis ( ) -> hset ( \ date ( 'Y-m-d' ) . '_retry' , ( string ) \ time ( ) , \ json_encode ( [ 'class' => $ this -> getWorkerClass ( ) , 'args' => $ this -> getArgs ( ) , 'retry' => \ gettype ( $ re...
Retries a job
8,707
public function end ( ) { $ key = $ this -> queue -> generateListKey ( ) ; $ key = "$key:" . $ this -> id ; $ retry = $ this -> getRetry ( ) ; $ result = $ this -> queue -> getClient ( ) -> getRedis ( ) -> multi ( ) -> del ( $ key ) -> hset ( \ date ( 'Y-m-d' ) . '_pass' , ( string ) \ time ( ) , \ json_encode ( [ 'cla...
Ends a job and marks it as completed
8,708
private function hydrate ( ) { $ key = $ this -> queue -> generateListKey ( ) ; $ job = $ this -> queue -> getClient ( ) -> getRedis ( ) -> hGetAll ( "$key:" . $ this -> id ) ; if ( empty ( $ job ) ) { throw new JobNotFoundException ( 'Unable to fetch job details from Redis.' ) ; } $ this -> workerClass = $ job [ 'work...
Hydrates the model by pulling data from Redis
8,709
public static function createFromArray ( array $ array ) : Reader { $ classname = \ get_called_class ( ) ; $ instance = new $ classname ; $ instance -> type = 'array' ; $ instance -> buffer = $ array ; return $ instance ; }
Importa os dados a partir de um array
8,710
public function toArray ( ) : array { if ( $ this -> data !== null ) { return $ this -> data ; } if ( $ this -> type == 'spreadsheet' ) { $ this -> data = $ this -> parseDataFromSpreadsheet ( $ this -> buffer , $ this -> extension ) ; } else { $ this -> data = $ this -> parseDataFromArray ( $ this -> buffer ) ; } retur...
Devolve os dados em forma de array .
8,711
public function getCartTotal ( $ precision = 2 ) { $ items = $ this -> activeItems ; $ total = 0 ; foreach ( $ items as $ item ) { if ( $ item -> keep ) { $ total += $ item -> getTotalPrice ( ) ; } } return round ( $ total , $ precision ) ; }
Returns the total value of cart .
8,712
public function getActiveCount ( $ type = 'purchase' ) { if ( ! in_array ( $ type , [ 'primary' , 'purchase' , 'quantity' , 'weight' , 'volume' ] ) ) { return 0 ; } $ cartItems = $ this -> activeItems ; $ count = 0 ; foreach ( $ cartItems as $ cartItem ) { if ( $ cartItem -> keep ) { $ count += $ cartItem -> $ type ; }...
Returns the total items in cart .
8,713
public function renderContainer ( $ config = [ ] ) { $ containerView = CodeGenUtil :: isAbsolutePath ( $ this -> containerView , true ) ? $ this -> containerView : "$this->template/$this->containerView" ; return $ this -> render ( $ containerView , [ 'widget' => $ this ] ) ; }
Generate and return the HTML of container .
8,714
public function renderDragger ( $ config = [ ] ) { $ draggerView = CodeGenUtil :: isAbsolutePath ( $ this -> draggerView , true ) ? $ this -> draggerView : "$this->template/$this->draggerView" ; return $ this -> render ( $ draggerView , [ 'widget' => $ this ] ) ; }
Generate and return the HTML of file dragger having drag area .
8,715
public function renderChooser ( $ config = [ ] ) { $ chooserView = CodeGenUtil :: isAbsolutePath ( $ this -> chooserView , true ) ? $ this -> chooserView : "$this->template/$this->chooserView" ; return $ this -> render ( $ chooserView , [ 'widget' => $ this ] ) ; }
Generate and return the HTML of file chooser element .
8,716
public function renderPreloader ( $ config = [ ] ) { $ preloaderView = CodeGenUtil :: isAbsolutePath ( $ this -> preloaderView , true ) ? $ this -> preloaderView : "$this->template/$this->preloaderView" ; return $ this -> render ( $ preloaderView , [ 'widget' => $ this ] ) ; }
Generate and return the HTML of pre - loader used to show upload progress .
8,717
public function renderInfo ( $ config = [ ] ) { $ infoView = CodeGenUtil :: isAbsolutePath ( $ this -> infoView , true ) ? $ this -> infoView : "$this->template/$this->infoView" ; return $ this -> render ( $ infoView , [ 'widget' => $ this ] ) ; }
Generate and return the HTML of info having fields required to store file .
8,718
public function renderFields ( $ config = [ ] ) { $ fieldsView = CodeGenUtil :: isAbsolutePath ( $ this -> fieldsView , true ) ? $ this -> fieldsView : "$this->template/$this->fieldsView" ; return $ this -> render ( $ fieldsView , [ 'widget' => $ this ] ) ; }
Generate and return the HTML of fields . These fields will submit additional data required for file .
8,719
public function renderForm ( $ config = [ ] , $ html = [ ] ) { $ formView = CodeGenUtil :: isAbsolutePath ( $ this -> formView , true ) ? $ this -> formView : "$this->template/$this->formView" ; return $ this -> render ( $ formView , [ 'widget' => $ this , 'infoHtml' => $ html [ 'infoHtml' ] , 'fieldsHtml' => $ html [ ...
Generate and return the HTML of form to submit the uploaded file .
8,720
public function stepThereAreTheFollowingRecords ( $ dataObject , PyStringNode $ string ) { $ yaml = array_merge ( array ( $ dataObject . ':' ) , $ string -> getLines ( ) ) ; $ yaml = implode ( "\n " , $ yaml ) ; $ yamlFixture = new \ YamlFixture ( $ yaml ) ; $ yamlFixture -> writeInto ( $ this -> getFixtureFactory ( )...
Accepts YAML fixture definitions similar to the ones used in SilverStripe unit testing .
8,721
protected function prepareFixture ( $ class , $ identifier , $ data = array ( ) ) { if ( $ class == 'File' || is_subclass_of ( $ class , 'File' ) ) { $ data = $ this -> prepareAsset ( $ class , $ identifier , $ data ) ; } return $ data ; }
Prepares a fixture for use
8,722
private function checkWhichPart ( int $ dado , int $ position ) { if ( $ dado > 12 ) { $ current = $ this -> setDateInfo ( 'dia' , 'ano' ) ; if ( $ current ) { $ this -> data [ $ current ] = $ dado ; $ this -> position [ $ current ] = $ position ; } } else { $ current = $ this -> setDateInfo ( 'mes' , 'dia' , 'ano' ) ;...
filtra para determinar onde aplicar este valor inteiro .
8,723
public function addType ( $ mSlug , $ sLabel = '' , $ sDescription = '' , $ aHooks = [ ] ) { if ( empty ( $ mSlug ) ) { return false ; } if ( is_string ( $ mSlug ) ) { $ this -> aEventTypes [ $ mSlug ] = new \ stdClass ( ) ; $ this -> aEventTypes [ $ mSlug ] -> slug = $ mSlug ; $ this -> aEventTypes [ $ mSlug ] -> labe...
Adds a new event type to the stack
8,724
public function destroy ( $ iId ) { if ( empty ( $ iId ) ) { $ this -> setError ( 'Event ID not defined.' ) ; return false ; } $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> where ( 'id' , $ iId ) ; $ oDb -> delete ( $ this -> sTable ) ; if ( $ oDb -> affected_rows ( ) ) { return true ; } else { $ this -> setErro...
Destroys an event object
8,725
public function getAllRawQuery ( $ iPage = null , $ iPerPage = null , $ aData = [ ] ) { $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> select ( $ this -> sTableAlias . '.*' ) ; $ oDb -> select ( 'ue.email,u.first_name,u.last_name,u.profile_img,u.gender' ) ; $ this -> getCountCommonEvent ( $ aData ) ; if ( ! is_nu...
Returns all event objects .
8,726
public function countAll ( $ aData ) { $ this -> getCountCommonEvent ( $ aData ) ; $ oDb = Factory :: service ( 'Database' ) ; return $ oDb -> count_all_results ( $ this -> sTable . ' ' . $ this -> sTableAlias ) ; }
Count the total number of events for a certain query
8,727
public function getById ( $ iId ) { $ aEvents = $ this -> getAll ( [ 'where' => [ [ $ this -> sTableAlias . '.id' , $ iId ] , ] , ] ) ; if ( ! $ aEvents ) { return false ; } return $ aEvents [ 0 ] ; }
Return an individual event
8,728
public function getByType ( $ sType ) { $ aEvents = $ this -> getAll ( [ 'where' => [ [ $ this -> sTableAlias . '.type' , $ sType ] , ] , ] ) ; if ( ! $ aEvents ) { return false ; } return $ aEvents [ 0 ] ; }
Returns events of a particular type
8,729
public function getByUser ( $ iUserId ) { $ aEvents = $ this -> getAll ( [ 'where' => [ [ $ this -> sTableAlias . '.created_by' , $ iUserId ] , ] , ] ) ; if ( ! $ aEvents ) { return false ; } return $ aEvents [ 0 ] ; }
Returns events created by a user
8,730
public function getTypeBySlug ( $ sSlug ) { return isset ( $ this -> aEventTypes [ $ sSlug ] ) ? $ this -> aEventTypes [ $ sSlug ] : false ; }
Get an individual type of event
8,731
public function getAllTypesFlat ( ) { $ aTypes = $ this -> getAllTypes ( ) ; $ aOut = [ ] ; foreach ( $ aTypes as $ oType ) { $ aOut [ $ oType -> slug ] = $ oType -> label ? $ oType -> label : title_case ( str_replace ( '_' , ' ' , $ oType -> slug ) ) ; } return $ aOut ; }
Get the differing types of event as a flat array
8,732
protected function formatObject ( & $ oObj ) { $ oObj -> ref = $ oObj -> ref ? ( int ) $ oObj -> ref : null ; $ temp = $ this -> getTypeBySlug ( $ oObj -> type ) ; if ( empty ( $ temp ) ) { $ temp = new \ stdClass ( ) ; $ temp -> slug = $ oObj -> type ; $ temp -> label = '' ; $ temp -> description = '' ; $ temp -> hook...
Formats an event object
8,733
public static function topLevels ( ) : SetInterface { if ( self :: $ topLevels === null ) { self :: $ topLevels = ( new Set ( 'string' ) ) -> add ( 'application' ) -> add ( 'audio' ) -> add ( 'font' ) -> add ( 'example' ) -> add ( 'image' ) -> add ( 'message' ) -> add ( 'model' ) -> add ( 'multipart' ) -> add ( 'text' ...
List of allowed top levels
8,734
public static function fromString ( string $ string ) : self { $ string = new Str ( $ string ) ; $ pattern = sprintf ( '~%s/[\w\-.]+(\+\w+)?([;,] [\w\-.]+=[\w\-.]+)?~' , self :: topLevels ( ) -> join ( '|' ) ) ; if ( ! $ string -> matches ( $ pattern ) ) { throw new InvalidMediaTypeString ; } $ splits = $ string -> pre...
Build an object out of a string
8,735
public function parse ( ) { $ notification = ( isset ( $ _POST ) && isset ( $ _POST [ "xml" ] ) ) ? $ _POST [ "xml" ] : null ; if ( ! $ notification ) { throw new \ Exception ( 'Notification error' , 5000 ) ; } return new \ SimpleXMLElement ( $ notification ) ; }
Parse the notifications
8,736
public static function input ( $ question , $ default = null ) { echo $ question . ': ' ; $ handle = fopen ( 'php://stdin' , 'r' ) ; $ answer = fgets ( $ handle ) ; fclose ( $ handle ) ; $ answer = trim ( $ answer ) ; if ( ! $ answer ) { $ answer = $ default ; } return $ answer ; }
Queries the user for an input and returns the results
8,737
public function addLanguage ( $ lang = '' , $ prefix = '' , $ dir = null , $ min = false ) { if ( empty ( $ lang ) || substr ( $ lang , 0 , 2 ) == 'en' ) { return $ this ; } $ ext = $ min ? ( YII_DEBUG ? ".min.js" : ".js" ) : ".js" ; $ file = "{$prefix}{$lang}{$ext}" ; if ( $ dir === null ) { $ dir = 'js' ; } elseif ( ...
Adds a language JS locale file
8,738
public function save ( $ sString , $ sPath , $ iWidth = null , $ iHeight = null ) { $ rImg = $ this -> generateBarcode ( $ sString , $ iWidth , $ iHeight ) ; if ( $ rImg ) { imagepng ( $ rImg , $ sPath ) ; imagedestroy ( $ rImg ) ; return true ; } else { return false ; } }
Saves a barcode to disk
8,739
public function show ( $ sString , $ iWidth = null , $ iHeight = null ) { $ rImg = $ this -> generateBarcode ( $ sString , $ iWidth , $ iHeight ) ; if ( $ rImg ) { header ( 'Content-Type: image/png' ) ; imagepng ( $ rImg ) ; imagedestroy ( $ rImg ) ; exit ( 0 ) ; } else { return false ; } }
Sends a barcode to the browser as an image
8,740
public function base64 ( $ sString , $ iWidth = null , $ iHeight = null ) { $ rImg = $ this -> generateBarcode ( $ sString , $ iWidth , $ iHeight ) ; if ( $ rImg ) { ob_start ( ) ; imagepng ( $ rImg ) ; $ sContents = ob_get_contents ( ) ; ob_end_clean ( ) ; return base64_encode ( $ sContents ) ; } else { return false ;...
Returns the encoded image as a base64 string
8,741
public function getByUserId ( $ userId ) { $ modelClass = self :: $ modelClass ; $ cart = $ modelClass :: findByParentIdParentType ( $ userId , CoreGlobal :: TYPE_USER ) ; if ( ! isset ( $ cart ) ) { $ cart = $ this -> createByUserId ( $ userId ) ; } return $ cart ; }
Find cart if exist for the given user . If does not exist create it .
8,742
public static function getPidByFile ( string $ file , bool $ checkLive = false ) : int { if ( $ file && \ file_exists ( $ file ) ) { $ pid = ( int ) \ file_get_contents ( $ file ) ; if ( $ checkLive && self :: isRunning ( $ pid ) ) { return $ pid ; } \ unlink ( $ file ) ; } return 0 ; }
get PID by pid File
8,743
public static function run ( string $ command , string $ cwd = null ) : array { return Sys :: run ( $ command , $ cwd ) ; }
run a command . it is support windows
8,744
public static function setTitle ( string $ title ) : bool { if ( ! $ title || 'Darwin' === \ PHP_OS ) { return false ; } if ( \ function_exists ( 'cli_set_process_title' ) ) { \ cli_set_process_title ( $ title ) ; } elseif ( \ function_exists ( 'setproctitle' ) ) { \ setproctitle ( $ title ) ; } if ( $ error = \ error_...
Set process title .
8,745
public function getSetValuesBase ( array & $ values ) : void { if ( $ this -> name === '' ) { $ tmp = & $ values ; } else { $ values [ $ this -> name ] = [ ] ; $ tmp = & $ values [ $ this -> name ] ; } foreach ( $ this -> options as $ i => $ option ) { $ key = $ option [ $ this -> keyKey ] ; $ tmp [ $ key ] = ( ! empty...
Adds the value of checked checkboxes the values with the name of this form control as key .
8,746
private function inputAttributes ( array $ option ) : array { $ attributes = [ ] ; if ( is_array ( $ this -> inputAttributesMap ) ) { foreach ( $ this -> inputAttributesMap as $ key => $ name ) { if ( isset ( $ option [ $ key ] ) ) $ attributes [ $ name ] = $ option [ $ key ] ; } } $ attributes [ 'type' ] = 'checkbox' ...
Returns the attributes for the input element .
8,747
public function output ( \ Neos \ Flow \ Aop \ JoinPointInterface $ joinPoint ) { $ controller = $ joinPoint -> getProxy ( ) ; $ view = ObjectAccess :: getProperty ( $ controller , 'view' , true ) ; $ response = $ controller -> getControllerContext ( ) -> getResponse ( ) ; if ( $ view instanceof JsendView ) { $ view ->...
Directly outputs all the data instead of storing it in the buffer
8,748
private static function getClassConstants ( string $ className ) : array { return self :: $ constantCache [ $ className ] ?? self :: $ constantCache [ $ className ] = ( new \ ReflectionClass ( $ className ) ) -> getConstants ( ) ; }
Get a map of member names to values for the specified class name
8,749
final public static function parseValue ( $ searchValue , bool $ looseComparison = false ) : string { if ( false !== $ name = \ array_search ( $ searchValue , self :: getClassConstants ( static :: class ) , ! $ looseComparison ) ) { return $ name ; } throw new \ InvalidArgumentException ( 'Unknown enumeration value: ' ...
Get the name of the first member with the specified value
8,750
final public static function parseName ( string $ searchName , bool $ caseInsensitive = false ) { $ constants = self :: getClassConstants ( static :: class ) ; if ( isset ( $ constants [ $ searchName ] ) ) { return $ constants [ $ searchName ] ; } if ( $ caseInsensitive && null !== $ key = self :: searchArrayCaseInsens...
Get the value of the member with the specified name
8,751
public function getFormClassName ( $ type = null ) { if ( ! $ type ) { $ type = $ this -> getFormTypeDefault ( ) ; } $ module = $ this -> getRequest ( ) -> getModuleName ( ) ; if ( strpos ( $ type , 'admin-' ) !== false ) { $ module = 'admin' ; $ type = str_replace ( 'admin-' , '' , $ type ) ; } elseif ( strpos ( $ typ...
Get Form Class name by type
8,752
protected function initFormClassNameSlug ( ) { $ slug = \ inflector ( ) -> singularize ( \ inflector ( ) -> classify ( $ this -> getFormClassNameBase ( ) ) ) ; $ this -> setFormClassNameSlug ( $ slug ) ; }
Init form class name slug
8,753
protected static function searchForFileAndLineCalledFromStack ( array $ stack ) { for ( $ i = 0 ; $ i < count ( $ stack ) ; $ i ++ ) { if ( array_key_exists ( "file" , $ stack [ $ i ] ) && array_key_exists ( "line" , $ stack [ $ i ] ) ) return $ stack [ $ i ] ; } return null ; }
Search for a valid stack item with file and line not a raw class call . Return the stack item with this data or null in case not stack item found
8,754
public static function buildExceptionStore ( \ Exception $ e ) { $ exceptionStore = new ExceptionStore ( ) ; $ exceptionStore -> setMessage ( $ e -> getMessage ( ) ) ; $ exceptionStore -> setCode ( $ e -> getCode ( ) ) ; $ exceptionStore -> setExceptionClass ( get_class ( $ e ) ) ; $ t = explode ( '\n' , $ e -> getTrac...
Build a exceptionStore from a PHP Exception
8,755
public function createControl ( string $ name ) : Control { $ control = new TableColumnControl ( $ name ) ; $ control -> setTableColumn ( $ this -> tableColumn ) ; return $ control ; }
Creates and returns a button form control .
8,756
private function resolveImportTable ( Node $ node ) : array { try { return $ node -> getImportTablesForCurrentScope ( ) ; } catch ( Exception $ e ) { } foreach ( $ node -> getDescendantNodes ( ) as $ node ) { try { $ imports = $ node -> getImportTablesForCurrentScope ( ) ; if ( empty ( $ imports [ 0 ] ) ) { continue ; ...
Tolerant parser will resolve a docblock comment as the root node not the node to which the comment belongs . Here we attempt to get the import table from the current node if that fails then we just do whatever we can to get an import table .
8,757
private function resolveNamespace ( Node $ node ) { try { return $ this -> namespaceFromNode ( $ node ) ; } catch ( Exception $ e ) { } foreach ( $ node -> getDescendantNodes ( ) as $ node ) { try { return $ this -> namespaceFromNode ( $ node ) ; } catch ( Exception $ e ) { } } return '' ; }
As with resolve import table we try our best .
8,758
public static function initPage ( $ view , $ config = [ ] ) { $ model = isset ( $ view -> params [ 'model' ] ) ? $ view -> params [ 'model' ] : self :: findPage ( $ view , $ config ) ; if ( isset ( $ model ) ) { $ coreProperties = CoreProperties :: getInstance ( ) ; $ cmsProperties = CmsProperties :: getInstance ( ) ; ...
Generates the meta data of Page or Post .
8,759
public static function initModelPage ( $ view , $ config = [ ] ) { $ model = isset ( $ view -> params [ 'model' ] ) ? $ view -> params [ 'model' ] : self :: findModel ( $ config ) ; if ( isset ( $ model ) ) { $ coreProperties = CoreProperties :: getInstance ( ) ; $ cmsProperties = CmsProperties :: getInstance ( ) ; $ s...
Generates the meta data of Model using model content .
8,760
public static function findPage ( $ view , $ config = [ ] ) { $ moduleName = $ view -> context -> module -> id ; $ controllerName = Yii :: $ app -> controller -> id ; $ actionName = Yii :: $ app -> controller -> action -> id ; $ page = null ; if ( $ moduleName == 'core' && $ controllerName == 'site' ) { if ( $ actionNa...
Find and return the view according to the configuration passed to it .
8,761
private function getTokenFromAuthorizationHeaders ( ServerRequestInterface $ request ) : ? string { $ authorization_headers = $ request -> getHeader ( 'AUTHORIZATION' ) ; foreach ( $ authorization_headers as $ authorization_header ) { if ( 1 === \ Safe \ preg_match ( '/' . \ preg_quote ( 'Bearer' , '/' ) . '\s([a-zA-Z0...
Get the token from the authorization header .
8,762
private function getTokenFromRequestBody ( ServerRequestInterface $ request ) : ? string { try { $ parameters = RequestBodyParser :: parseFormUrlEncoded ( $ request ) ; return $ this -> getAccessTokenFromParameters ( $ parameters ) ; } catch ( \ Exception $ e ) { return null ; } }
Get the token from the request body .
8,763
private function getTokenFromQuery ( ServerRequestInterface $ request ) : ? string { $ query_params = $ request -> getQueryParams ( ) ; return $ this -> getAccessTokenFromParameters ( $ query_params ) ; }
Get the token from the query string .
8,764
public function sendCommand ( $ recipientMail , $ templateFile = 'resource://KayStrobach.Custom/Private/Templates/Mail/Default.html' ) { $ this -> output -> output ( 'Sending Mail to ' . $ recipientMail ) ; $ mailUtility = new MailUtility ( ) ; $ mailUtility -> send ( $ recipientMail , $ templateFile , [ 'values' => [ ...
An example command
8,765
public static function replicate ( $ data ) { $ copy = clone $ data ; foreach ( $ copy as $ key => $ value ) { if ( is_object ( $ value ) ) { $ copy -> { $ key } = static :: replicate ( $ value ) ; } } return $ copy ; }
Clone the object recursively .
8,766
protected static function load ( $ file ) { if ( null !== static :: DIRECTORY ) { return file_get_contents ( __DIR__ . '/../data/' . static :: DIRECTORY . '/' . $ file . '.json' ) ; } return file_get_contents ( __DIR__ . '/../data/' . $ file . '.json' ) ; }
Loads a JSON encoded fixture from the file system
8,767
public function process ( Request $ request , Handler $ handler ) : Response { $ request = $ request -> withAttribute ( $ this -> authAttribute , $ this -> resume ( ) ) ; return $ handler -> handle ( $ request ) ; }
Resumes Authenticated Session
8,768
public static function hasScalars ( array $ array ) : bool { $ ret = false ; foreach ( $ array as $ tmp ) { if ( is_object ( $ tmp ) ) { $ ret = true ; break ; } } return $ ret ; }
Returns true if array has one or more scalars . Otherwise returns false .
8,769
public function getHtml ( ) : string { if ( ! isset ( $ this -> attributes [ 'action' ] ) ) { $ this -> attributes [ 'action' ] = Abc :: $ request -> getRequestUri ( ) ; } $ this -> prepare ( ) ; $ html = $ this -> getHtmlStartTag ( ) ; $ html .= $ this -> getHtmlBody ( ) ; $ html .= $ this -> getHtmlEndTag ( ) ; retur...
Returns the HTML code of this form .
8,770
protected function prepare ( ) : void { if ( ! $ this -> prepared ) { $ this -> fieldSets -> prepare ( '' ) ; $ this -> prepared = true ; } }
Prepares this form for HTML code generation or loading submitted values .
8,771
protected function searchSubmitHandler ( ) : ? string { switch ( $ this -> attributes [ 'method' ] ) { case 'post' : $ values = & $ _POST ; break ; case 'get' : $ values = & $ _GET ; break ; default : throw new FallenException ( 'method' , $ this -> attributes [ 'method' ] ) ; } return $ this -> fieldSets -> searchSubm...
If this form has been submitted returns the name of the method for handling this form . Otherwise returns null .
8,772
public static function execInBackground ( string $ cmd ) : void { if ( self :: isWindows ( ) ) { \ pclose ( \ popen ( 'start /B ' . $ cmd , 'r' ) ) ; } else { \ exec ( $ cmd . ' > /dev/null &' ) ; } }
run a command in background
8,773
public static function getScreenSize ( bool $ refresh = false ) { static $ size ; if ( $ size !== null && ! $ refresh ) { return $ size ; } if ( self :: shIsAvailable ( ) ) { $ stty = [ ] ; if ( \ exec ( 'stty -a 2>&1' , $ stty ) && \ preg_match ( '/rows\s+(\d+);\s*columns\s+(\d+);/mi' , implode ( ' ' , $ stty ) , $ ma...
get screen size
8,774
public static function downBigFile ( $ file , $ as ) : void { header ( 'Expires: Mon, 1 Apr 1974 05:00:00 GMT' ) ; header ( 'Pragma: no-cache' ) ; header ( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' ) ; header ( 'Content-Description: File Download' ) ; header ( 'Content-Type: application/octet-stream' ...
If you want to download files from a linux server with a filesize bigger than 2GB you can use the following
8,775
public function pour ( ) : void { $ provider = $ this -> source -> getCask ( ) ; foreach ( $ provider as $ dataBag ) { try { $ this -> pipeLine -> rewind ( ) ; while ( $ this -> pipeLine -> valid ( ) ) { $ handler = $ this -> pipeLine -> current ( ) ; $ dataBag = $ handler -> pass ( $ dataBag ) ; $ this -> pipeLine -> ...
Pour source into pipeline .
8,776
protected function getPath ( $ name ) { $ name = isset ( $ this -> map [ $ name ] ) ? $ this -> map [ $ name ] : $ name ; return "{$this->basePath}/{$name}.svg" ; }
Returns the path of a svg .
8,777
public function setStability ( $ stability ) { if ( ! in_array ( $ stability , self :: $ stabilities , true ) ) { throw new InvalidArgumentException ( 'Invalid stability value. Must be one of "stable", "unstable" or "any".' ) ; } $ this -> stability = $ stability ; }
Set target stability .
8,778
static function create ( $ im ) { if ( is_resource ( $ im ) && get_resource_type ( $ im ) ) { return new ImageGD ( $ im ) ; } if ( $ im instanceof \ Imagick ) { return new ImageImagick ( $ im ) ; } }
Create a new Morpheus \ Image instance .
8,779
private function parity ( $ byte ) { $ parity = 0 ; for ( $ i = 7 ; $ i >= 0 ; $ i -- ) { $ parity ^= ( $ byte >> $ i ) & 1 ; } return ( bool ) $ parity ; }
Calculate the XOR parity of the given byte .
8,780
private function writeByte ( $ byte ) { list ( $ x , $ y ) = $ this -> coordinates -> current ( ) ; $ color = $ this -> getColor ( $ x , $ y ) ; $ color -> writeBits ( ( $ byte >> 5 ) & 7 ) ; $ this -> setColor ( $ x , $ y , $ color ) ; $ this -> coordinates -> next ( ) ; list ( $ x , $ y ) = $ this -> coordinates -> c...
Store a byte at the current coordinates pointer
8,781
public function path ( $ url ) { $ prefix = $ this -> config [ 'url_prefix' ] ; if ( preg_match ( '#^/#' , $ prefix ) && preg_match ( '#^http#' , $ url ) ) { $ url = parse_url ( $ url , PHP_URL_PATH ) ; } return substr ( $ url , strlen ( $ prefix ) ) ; }
Get the path on the disk given the URL .
8,782
public function revisionAtTimestamp ( $ timestamp ) { $ revision = $ this -> revisions ( ) -> where ( 'created_at' , '<=' , Carbon :: parse ( $ timestamp ) ) -> first ( ) ; return $ this -> wrapRevision ( $ revision ) ; }
Get record version at given timestamp .
8,783
private function rollbackToRevision ( Revision $ revision ) { if ( $ revision == null ) { return null ; } $ current = $ revision -> revisioned ; if ( $ this -> getConfigRollbackCleanup ( ) ) { $ revisionsToDelete = $ current -> revisions ( ) -> where ( 'id' , '>=' , $ revision -> id ) -> delete ( ) ; } $ current -> fil...
Rollback to a given revision .
8,784
public function getConfigRevisionForModel ( ) { if ( is_null ( $ this -> revisionEnabled ) ) { return true ; } if ( $ this -> revisionEnabled === false ) { return false ; } return true ; }
checks if revisions for this model shall be created
8,785
public function getConfigRevisionLimit ( ) { $ default = Config :: get ( 'revisionable.revisions.limit' ) ; if ( is_null ( $ this -> revisionLimit ) ) { return $ default ; } if ( ! is_numeric ( $ this -> revisionLimit ) ) { return $ default ; } return $ this -> revisionLimit ; }
Returns how many revisions of a model must be kept
8,786
public function getConfigRevisionLimitCleanup ( ) { $ default = Config :: get ( 'revisionable.revisions.limitCleanup' ) ; if ( is_null ( $ this -> revisionLimitCleanup ) ) { return $ default ; } if ( $ this -> revisionLimitCleanup == false ) { return false ; } return true ; }
Returns if older revisions shall be removed
8,787
public function is_included ( ) { $ queried_object = get_queried_object ( ) ; if ( ! empty ( $ queried_object -> taxonomy ) && $ queried_object -> taxonomy == $ this -> get_subtype ( ) ) { return true ; } return false ; }
Whether this the items of this locator should be included in the trail .
8,788
public static function integerAsOptions ( $ num ) { $ options = [ ] ; for ( $ i = 0 ; $ i <= $ num ; $ i ++ ) { $ options [ ] = $ i ; } shuffle ( $ options ) ; return $ options ; }
Take an integer and convert it into an array of shuffled options .
8,789
public static function stringToArray ( $ str ) { $ arr = [ ] ; for ( $ i = 0 ; $ i < self :: stringLength ( $ str ) ; $ i ++ ) { $ arr [ ] = function_exists ( 'mb_substr' ) ? mb_substr ( $ str , $ i , 1 ) : $ str [ $ i ] ; } return $ arr ; }
Convert a string to an array of letters .
8,790
public function withAttributes ( array $ attributes ) { $ clone = clone $ this ; foreach ( $ attributes as $ name => $ value ) { $ clone -> dom -> documentElement -> setAttribute ( $ name , $ value ) ; } return $ clone ; }
Set new attributes .
8,791
public function withA11y ( $ title = null , $ desc = null ) { $ clone = clone $ this ; $ clone -> dom -> documentElement -> setAttribute ( 'role' , 'img' ) ; $ ids = [ ] ; if ( $ title ) { self :: getOrCreateNode ( $ clone -> dom -> documentElement , 'title' , $ title ) -> setAttribute ( 'id' , $ ids [ ] = uniqid ( 'sv...
Set accessibility information to the svg .
8,792
private static function getOrCreateNode ( DOMElement $ svg , $ tagName , $ value ) { $ node = $ svg -> getElementsByTagName ( $ tagName ) ; if ( $ node -> length ) { $ node = $ node -> item ( 0 ) ; $ node -> nodeValue = $ value ; return $ node ; } $ newNode = new DOMElement ( $ tagName , $ value ) ; $ svg -> appendChil...
Returns a node by tagName . Create if it doesn t exist
8,793
public function setup ( ) { if ( ! $ this -> get_id ( ) ) { throw new Carbon_Breadcrumb_Exception ( 'The term breadcrumb items must have term ID specified.' ) ; } if ( ! $ this -> get_subtype ( ) ) { throw new Carbon_Breadcrumb_Exception ( 'The term breadcrumb items must have taxonomy specified.' ) ; } $ subtype = $ th...
Configure the title and link URL by using the specified term ID .
8,794
public function setup_link ( ) { $ link = get_term_link ( $ this -> term_object -> term_id , $ this -> term_object -> taxonomy ) ; $ this -> set_link ( $ link ) ; }
Setup the link of this item .
8,795
public function prepare_for_rendering ( $ trail ) { do_action ( 'carbon_breadcrumbs_before_render' , $ this ) ; $ auto_sort = apply_filters ( 'carbon_breadcrumbs_auto_sort_items' , true ) ; if ( $ auto_sort ) { $ trail -> sort_items ( ) ; } }
Prepare for rendering . Allows renderer to be modified in the last second . Also autosorts the trail items if autosorting is enabled .
8,796
public function render ( Carbon_Breadcrumb_Trail $ trail , $ return = false ) { if ( $ trail -> get_total_items ( ) < $ this -> get_min_items ( ) ) { return ; } $ this -> prepare_for_rendering ( $ trail ) ; $ items_output = $ this -> render_items ( $ trail ) ; $ output = $ this -> get_wrapper_before ( ) ; $ output .= i...
Render the given breadcrumb trail .
8,797
public function render_items ( $ trail ) { $ items_output = array ( ) ; $ counter = 0 ; $ all_items = $ trail -> get_flat_items ( ) ; foreach ( $ all_items as $ item ) { $ item = apply_filters ( 'carbon_breadcrumbs_item' , $ item , $ trail , $ this , $ counter ) ; if ( ! ( $ item instanceof Carbon_Breadcrumb_Item ) ) {...
Render the breadcrumb trail items .
8,798
public function grid ( ) { $ html = "<table class=\"word-search\">\n" ; foreach ( $ this -> puzzle -> toArray ( ) as $ row ) { $ html .= "<tr>\n" ; foreach ( $ row as $ cell ) { $ html .= sprintf ( "<td>%s</td>\n" , $ cell ) ; } $ html .= "</tr>\n" ; } $ html .= "</table>\n" ; return $ html ; }
Transform the grid .
8,799
public function wordList ( ) { $ html = "<ul>\n" ; foreach ( $ this -> puzzle -> getWordList ( ) as $ word ) { $ html .= sprintf ( "<li>%s</li>\n" , $ word -> word ) ; } $ html .= "</ul>\n" ; return $ html ; }
Transform the words list .